diff --git a/.github/ci/yamllint.yml b/.github/ci/yamllint.yml new file mode 100644 index 00000000..1cfe53c3 --- /dev/null +++ b/.github/ci/yamllint.yml @@ -0,0 +1,11 @@ +--- +extends: relaxed + +yaml-files: + - '*.yaml' + - '*.yml' + +rules: + truthy: disable + # 80 chars should be enough, but don't fail if a line is longer + line-length: disable diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..750607ca --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,119 @@ +--- +name: CI +on: + push: + tags: + - v* + branches: + - master + - ci + pull_request: +# Allows running this workflow manually + workflow_dispatch: + +permissions: + contents: read + +jobs: + yaml-lint: + name: "Lint YAML" + runs-on: ubuntu-latest + steps: + - name: "Checkout" + uses: actions/checkout@v3 + - name: "Run YAML linter" + uses: ibiqlik/action-yamllint@v3 + with: + config_file: '.github/ci/yamllint.yml' + + go-mod: + strategy: + matrix: + go: [ '1.20' ] + name: "Check go.mod" + runs-on: ubuntu-latest + steps: + - name: "Setup Go" + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - name: "Checkout" + uses: actions/checkout@v3 + - name: "Run go mod tidy" + run: go mod tidy -v + - name: "Check go.mod" + run: | + git diff --exit-code go.mod + - name: "Check go.sum" + run: | + git diff --exit-code go.sum + + binapi: + strategy: + matrix: + go: [ '1.20' ] + env: + VERSION: v0.8.0 + name: "Check generated binapi" + runs-on: ubuntu-latest + steps: + - name: "Setup Go" + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - name: "Checkout" + uses: actions/checkout@v3 + - name: "Generate binapi" + run: make gen-binapi-docker + - name: "Check binapi" + run: | + git diff --exit-code binapi + + build-test: + strategy: + matrix: + go: [ '1.20' ] + os: [ ubuntu-latest ] + name: "Build and test" + runs-on: ${{ matrix.os }} + steps: + - name: "Setup Go" + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - name: "Setup gotestsum" + uses: autero1/action-gotestsum@v1.0.0 + with: + gotestsum_version: 1.9.0 + - name: "Checkout" + uses: actions/checkout@v3 + - name: "Go Build" + run: go build -v ./... + - name: "Go Test" + run: gotestsum --format testname --jsonfile test.json -- -race ./... + - name: "Test results" + if: always() + uses: guyarb/golang-test-annotations@v0.6.0 + with: + test-results: test.json + + golangci: + strategy: + matrix: + go: [ '1.20' ] + name: "GolangCI" + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + steps: + - name: "Setup Go" + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - name: "Checkout" + uses: actions/checkout@v3 + - name: "Run golangci" + uses: golangci/golangci-lint-action@v3 # docs: https://github.com/golangci/golangci-lint-action + with: + version: latest diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..f0413627 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,42 @@ +--- +name: Test +on: + # Runs on branch push to master & PRs + push: + branches: + - master + pull_request: + paths-ignore: + - 'docs/**' + - '**.md' + # Runs daily at 05:05 + schedule: + - cron: '5 5 * * *' + # Allows running manually + workflow_dispatch: + +jobs: + integration: + name: "VPP Integration ${{ matrix.version }}" + runs-on: ubuntu-latest + env: + VPP_REPO: ${{ matrix.version }} + strategy: + fail-fast: false + matrix: + version: + - 'master' + - '2306' + - '2302' + - '2210' + + steps: + - name: "Checkout" + uses: actions/checkout@v3 + - name: "Setup Go" + uses: actions/setup-go@v3 + with: + go-version: '1.20' + - name: "Run Tests" + run: | + make test-integration diff --git a/.gitignore b/.gitignore index 81b7a5c1..a441bccb 100644 --- a/.gitignore +++ b/.gitignore @@ -5,15 +5,23 @@ .idea/ +.cache/ + /bin/ # cmd cmd/binapi-generator/binapi-generator cmd/vpp-proxy/vpp-proxy +cmd/govpp/govpp # examples +examples/api-trace/api-trace +examples/multi-vpp/multi-vpp examples/perf-bench/perf-bench examples/rpc-service/rpc-service examples/simple-client/simple-client examples/stats-client/stats-client +examples/stream-client/stream-client examples/union-example/union-example + +/govpp \ No newline at end of file diff --git a/.gitreview b/.gitreview deleted file mode 100644 index 429cd373..00000000 --- a/.gitreview +++ /dev/null @@ -1,4 +0,0 @@ -[gerrit] -host=gerrit.fd.io -port=29418 -project=govpp diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..e71710a3 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,22 @@ +# Configuration of golangci-lint +# +# see docs: https://golangci-lint.run/usage/configuration/ + +--- +run: + timeout: 5m + skip-dirs: + - adapter/mock + skip-files: + - ".*\\.ba.\\.go$" + +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - typecheck + - unused diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ff1fe11e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -dist: xenial -services: docker - -language: go -go: - - "1.13.x" - -go_import_path: github.com/alkiranet/govpp - -env: - global: - - GO_BUILD_TAGS=novpp - -before_script: - - export VPP_IMG="ligato/vpp-base:latest" - - docker pull $VPP_IMG - - go mod download - -script: - - make lint || true - - make test - - make build - - make gen-binapi-docker - -notifications: - slack: - rooms: - - ligato:QNOK2VgHH6k40T8nQxmSgRmo - on_success: change - on_failure: always diff --git a/CHANGELOG.md b/CHANGELOG.md index 145d1b15..0a39271f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,43 +11,255 @@ This file lists changes for the GoVPP releases. - --> +## 0.8.0 + +> _18 July 2023_ + +### Changes + +- Add VPP 23.06 to CI (#136) +- Improvements for GoVPP CLI (#135) +- Skip running CI tests for docs updates (#137) +- binapigen: initial support for counters and paths (#121) +- Refactor resolving VPP API input (#130) +- Update Dockerfile.integration (#134) +- Add README for examples (#128) +- Invalidate msgTable map during reconnect (#127) +- Add more GoVPP CLI features (#117) +- Update README.md (#115) +- Generate message comments (#109) +- Add User Guide (#110) +- Enhancements for binapigen (#93) +- Update Go and test if binapi is up-to-date (#105) +- Create RELEASE document (#89) + +### Fixes + +- Fix returning message reply on retval errors (#147) +- Fix memory leak for timers (#138) +- Fix channel pool (#131) +- Fix race in statsclient during reconnect (#126) +- Fix memory leak with reply timers (#124) +- Fix for Dockerfile smell DL3008 (#123) +- Fix disconnect for AsyncConnect case (#106) +- Fix binapi generation if old binapi files are not present (#73) + +### GoMemif + +- Fix memif abstract socket support (#119) +- Handle EINTR error (#99) + + +## 0.7.0 + +> _29 November 2022_ + +### Changes + +- Switch to using a generic pool for channels in Connection (#39) +- feat: Disable default reply timeout (#45) +- gomemif: migrate from vpp repository (#65) +- Run golangci-lint in CI (#69) +- Add GoVPP logo to README (#79) +- Introduce VPP integration tests (#75) +- docs: Add troubleshooting guide (#70) +- Add support of watching events to Connection (#80) + + +### Fixes + +- Fix format of package comment (#44) +- Fixes for staticcheck (#27) +- Prevent data race on msgMapByPath map (#50) +- Fix panic on the pool put/get operations (#54) +- Fix endless loop in Reset (#57) +- Fix generate RPC client for stream with reply (#72) +- Fix endless Stream's reply waiting on vpp disconnect (#77) +- Fix WaitReady if directory does not exist (#84) + +### Changes + +- Added GitHub CI +- Remove deprecated vppapiclient +- Remove unused Travis CI +- Remove gerrit remains + +## 0.6.0 + +> _09 September 2022_ + +### Changes + +- Added GitHub CI +- Remove deprecated vppapiclient +- Remove unused Travis CI +- Remove gerrit remains + +### Fixes + +- Call munmap when failed to check stat segment version (#34) + +## 0.5.0 + +> _28 July 2022_ + +### Features + +- Also generate APIName/APIVersion/CrcVersion constants for the types packages +- Stat segment client fixes & improvements + +### Fixes + +- Fix go 1.18 support +- Fixed data race in core.Connection.Close() +- Fix channel ID overlap + +## 0.4.0 + +> _17 January 2022_ + +### Binapi Generator + +- the generator code has been split into multiple packages: + - [vppapi](binapigen/vppapi) - parses VPP API (`.api.json`) files + - [binapigen](binapigen) - processes parsed VPP API files and handles code generation +- added support for VPP enumflags type +- previously required manual patches for generated code should no longer be needed +- many generated aliases were removed and referenced to `*_types` files for simpler reading +- any types imported from other VPP API (`*_types.api`) files are now automatically resolved for generated Go code +- marshal/unmarshal methods for memory client messages are now generated +- generated new helper methods for more convenient IP and MAC address conversion +- RPC service code is now generated into a separated file (`*_rpc.ba.go`) in the same directory and uses a new low level + stream API +- added option to generate HTTP handlers for RPC services +- generated code now contains comments with information about versions of VPP and binapi-generator +- in addition to the file name, the binapi generator now accepts full path (including extension, + e.g. `/usr/share/vpp/api/core/vpe.api.json`) +- dependency on `github.com/lunixbochs/struc` was removed +- generated helper methods for `vpe_types.Timestamp` +- generated API messages comment may contain additional information about the given API development state (in progress, + deprecated) +- type `[]bool` is now known to the generator +- enhanced VPP version resolution - the generator is more reliable to evaluate installed VPP version + +### Features + +- [socketclient](adapter/socketclient) was optimized and received a new method to add client name +- added new API [stream](api/api.go) for low-level access to VPP API + - the `Stream` API uses the same default values as the `Channel` API + - it supports the same functional options (request size, reply size, reply timeout) +- [statsclient](adapter/statsclient) supports additional options (retry period, retry timeout) +- the compatibility check error now contains a list of compatible and incompatible messages wrapped + as `CompatibilityError` +- removed global binary API adapter. This change allows GoVPP to manage multiple VPP connections with different sockets + simultaneously +- added support for the stats v2. The `statsclient` adapter recognizes the version automatically so the `StatsAPI` + remains unchanged. In relation to this change, the legacy support (i.e. stat segment v0) for VPP <=19.04 was dropped. +- GoVPP now recognizes VPP state `NotResponding` which can be used to prevent disconnecting in case the VPP hangs or is + overloaded +- added method `SetLogger()` for setting the global logger +- `StatsAPI` has a new method `GetMemory()` retrieving values related to the statseg memory heap +- the stats socket allows an option to connect asynchronously in the same manner as the API socket connection. + Use `AsyncConnectStats()` to receive `ConnectionEvent` notifications +- Instead of a cumulative value, the `statsclient` error counter now provides a value per worker +- `ListStats(patterns ...string)` returns `StatIdentifier` containing the message name and the ID (instead of the name + only) +- added support for VPP stat symlinks +- GoVPP received its own [API trace](api/trace.go). See the [example](examples/api-trace) for more details. + +### Fixes + +- `MsgCodec` will recover panic occurring during a message decoding +- calling `Unsubscibe` will close the notification channel +- GoVPP omits to send `sockclnt_delete` while cleaning up socket clients in order to remove VPP duplicated close + complaints - VPP handles it itself +- fixed major bug causing GoVPP to not receive stats updates after VPP restart +- fixed name conflict in generated union field constructors +- the size of unions composed of other unions is now calculated correctly +- fixed race condition in the VPP adapter mock +- fixed crash caused by the return value of uint kind +- fixed encoding/decoding of float64 +- fixed the stats reconnect procedure which occasionally failed re-enable the connection. +- fixed occasional panic during disconnect +- `statsclient` wait for socket procedure works properly +- fixed memory leak in health check + +### Other + +- improved log messages to provide more relevant info +- updated extras/libmemif to be compatible with the latest VPP changes +- default health check parameter was increased to 250 milliseconds (up from 100 milliseconds), and the default threshold + was increased to 2 (up from 1) +- improved decoding of message context (message evaluation uses also the package path, not just the message ID) +- `statsclient` now recognizes between empty stat directories and does not treat them as unknown +- proxy client was updated to VPP 20.05 + +#### Examples + +- added more code samples of working with unions in [binapi-types](examples/binapi-types) +- added profiling mode to [perf bench](examples/perf-bench) example +- improved [simple client](examples/simple-client) example to work properly even with multiple runs +- added [multi-vpp](examples/multi-vpp) example displaying management of two VPP instances from single application +- added [stream-client](examples/stream-client) example showing usage of the new stream API +- [simple client](examples/simple-client) and [binapi-types](examples/binapi-types) examples show usage of + the `vpe_types.Timestamp` +- added [API trace example](examples/api-trace) + +#### Dependencies + +- updated `github.com/sirupsen/logrus` dep to `v1.6.0` +- updated `github.com/lunixbochs/struc` dep to `v0.0.0-20200521075829-a4cb8d33dbbe` + ## 0.3.5 + > _18 May 2020_ ### Fixes + - statsclient: Fix stats data errors and panic for VPP 20.05 ## 0.3.4 + > _17 April 2020_ ### Features + - binapi-generator: Format generated Go source code in-process ## 0.3.3 + > _9 April 2020_ ### Fixes + - proxy: Unexport methods that do not satisfy rpc to remove warning ## 0.3.2 + > _20 March 2020_ ### Fixes + - statsclient: Fix panic occurring with VPP 20.05-rc0 (master) ## 0.3.1 + > _18 March 2020_ ### Fixes + - Fix import path in examples/binapi ## 0.3.0 + > _18 March 2020_ ### Fixes + - binapi-generator: Fix parsing default meta parameter ### Features + - api: Improve compatibility checking with new error types: `adapter.UnknownMsgError` and `api.CompatibilityError` - api: Added exported function `api.GetRegisteredMessageTypes()` @@ -57,26 +269,32 @@ This file lists changes for the GoVPP releases. - binapi-generator: Compact generated methods ### Other + - deps: Update `github.com/bennyscetbun/jsongo` to `v1.1.0` - regenerate examples/binapi for latest VPP from stable/2001 ## 0.2.0 + > _04 November 2019_ ### Fixes + - fixed socketclient for 19.08 - fixed binapi compatibility with master (20.01-rc0) - fixed panic during stat data conversion ### Features + - introduce proxy for remote access to stats and binapi - optimizations for statclient ### Other + - migrate to Go modules - print info for users when sockets are missing ## 0.1.0 + > _03 July 2019_ The first release that introduces versioning for GoVPP. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..308629eb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +ARG VPP_VERSION=v23.06 +ARG UBUNTU_VERSION=20.04 + +FROM ubuntu:${UBUNTU_VERSION} as vppbuild +ARG VPP_VERSION +RUN apt-get update +RUN DEBIAN_FRONTEND=noninteractive TZ=US/Central apt-get install -y git make python3 sudo asciidoc +RUN git clone https://github.com/FDio/vpp.git +WORKDIR /vpp +RUN git checkout ${VPP_VERSION} +#COPY patch/ patch/ +#RUN test -x "patch/patch.sh" && ./patch/patch.sh || exit 1 +RUN DEBIAN_FRONTEND=noninteractive TZ=US/Central UNATTENDED=y make install-dep +RUN make pkg-deb +RUN ./src/scripts/version > /vpp/VPP_VERSION + +FROM vppbuild as vppinstall +#COPY --from=vppbuild /var/lib/apt/lists/* /var/lib/apt/lists/ +#COPY --from=vppbuild [ "/vpp/build-root/libvppinfra_*_amd64.deb", "/vpp/build-root/vpp_*_amd64.deb", "/vpp/build-root/vpp-plugin-core_*_amd64.deb", "/vpp/build-root/vpp-plugin-dpdk_*_amd64.deb", "/pkg/"] +#RUN VPP_INSTALL_SKIP_SYSCTL=false apt install -f -y --no-install-recommends /pkg/*.deb ca-certificates iputils-ping iproute2 tcpdump; \ +# rm -rf /var/lib/apt/lists/*; \ +# rm -rf /pkg +RUN VPP_INSTALL_SKIP_SYSCTL=false apt install -f -y --no-install-recommends /vpp/build-root/*.deb ca-certificates iputils-ping iproute2 tcpdump; \ + rm -rf /var/lib/apt/lists/*; \ + rm -rf /pkg + +FROM golang:1.20-alpine3.18 as binapi-generator +ENV GO111MODULE=on +ENV CGO_ENABLED=0 +ENV GOBIN=/bin +ARG GOVPP_VERSION +COPY . /govpp +WORKDIR /govpp +RUN go build -o /bin/binapi-generator ./cmd/binapi-generator + +FROM binapi-generator as gen +COPY --from=vppinstall /usr/share/vpp/api/ /usr/share/vpp/api/ +COPY --from=vppinstall /vpp/VPP_VERSION /VPP_VERSION +WORKDIR /gen/binapi +CMD VPP_VERSION=$(cat /VPP_VERSION) go generate . diff --git a/INFO.yaml b/INFO.yaml new file mode 100644 index 00000000..0808ec88 --- /dev/null +++ b/INFO.yaml @@ -0,0 +1,52 @@ +--- +project: 'govpp' +project_creation_date: '2017-4-27' +project_category: '' +lifecycle_state: 'Incubation' +project_lead: &govpp_ptl + name: 'Ondrej Fabry' + email: 'ondrej@fabry.dev' + id: 'ondrej-fabry' +primary_contact: *govpp_ptl +issue_tracking: + type: 'github' + url: 'https://github.com/FDio/govpp/issues' +mailing_list: + type: 'groups.io' + url: 'https://lists.fd.io/g/govpp-dev' + tag: '<[sub-project_name]>' +realtime_discussion: + type: 'slack' + server: 'fdio-project.slack.com' + channel: 'govpp' +repositories: + - 'govpp' +committers: + - <<: *govpp_ptl + - name: 'Ondrej Fabry' + company: 'cisco' + email: 'ofabry@cisco.com' + id: 'ondrej-fabry' + - name: 'Jan Medved' + company: 'cisco' + email: 'jmedved@cisco.com' + id: 'jmedved' + - name: 'Rastislav Szabo' + company: 'cisco' + email: 'raszabo@cisco.com' + id: 'raszabo' + - name: 'Vladimir Lavor' + company: 'cisco' + email: 'vlavor@cisco.com' + id: 'vlavor' + - name: 'Nathan Skrzypczak' + company: 'cisco' + email: 'nathan.skrzypczak@gmail.com' + id: 'sknat' +tsc: + # yamllint disable rule:line-length + approval: '' + changes: + - type: 'addition' + name: 'Nathan Skrzypczak' + link: 'https://ircbot.wl.linuxfoundation.org/meetings/fdio-meeting/2022/fd_io_tsc/fdio-meeting-fd_io_tsc.2022-06-16-15.01.html' diff --git a/Makefile b/Makefile index 4297746a..dfe29a19 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,35 @@ SHELL := /usr/bin/env bash -o pipefail -VERSION ?= $(shell git describe --always --tags --dirty) -COMMIT ?= $(shell git rev-parse HEAD) -BUILD_STAMP ?= $(shell git log -1 --format="%ct") +PROJECT := govpp + +VERSION ?= $(shell git describe --always --tags --dirty --match='v*') +COMMIT ?= $(shell git rev-parse HEAD) +BUILD_STAMP ?= $(shell git log -1 --format='%ct') BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) BUILD_HOST ?= $(shell hostname) BUILD_USER ?= $(shell id -un) -GO ?= go +GOVPP_PKG := github.com/alkiranet/govpp/internal + +VPP_API_DIR ?= ${VPP_DIR}/build-root/install-vpp-native/vpp/share/vpp/api -GOVPP_PKG := $(shell go list) +VERSION_PKG := $(GOVPP_PKG)/version LDFLAGS = \ - -X ${GOVPP_PKG}/version.version=$(VERSION) \ - -X ${GOVPP_PKG}/version.commitHash=$(COMMIT) \ - -X ${GOVPP_PKG}/version.buildStamp=$(BUILD_STAMP) \ - -X ${GOVPP_PKG}/version.buildBranch=$(BUILD_BRANCH) \ - -X ${GOVPP_PKG}/version.buildUser=$(BUILD_USER) \ - -X ${GOVPP_PKG}/version.buildHost=$(BUILD_HOST) + -X $(VERSION_PKG).version=$(VERSION) \ + -X $(VERSION_PKG).commit=$(COMMIT) \ + -X $(VERSION_PKG).branch=$(BUILD_BRANCH) \ + -X $(VERSION_PKG).buildStamp=$(BUILD_STAMP) \ + -X $(VERSION_PKG).buildUser=$(BUILD_USER) \ + -X $(VERSION_PKG).buildHost=$(BUILD_HOST) + ifeq ($(NOSTRIP),) LDFLAGS += -w -s endif GO_BUILD_TAGS ?= novpp -GO_BUILD_ARGS = -ldflags "${LDFLAGS}" +GO_BUILD_ARGS = -ldflags "$(LDFLAGS)" ifneq ($(GO_BUILD_TAGS),) GO_BUILD_ARGS += -tags="${GO_BUILD_TAGS}" endif @@ -35,82 +40,102 @@ ifeq ($(V),1) GO_BUILD_ARGS += -v endif -VPP_VERSION = $(shell dpkg-query -f '\${Version}' -W vpp) +# Package cloud repo for VPP. +VPP_REPO ?= release +# VPP Docker image to use for api generation (gen-binapi-docker) +VPP_IMG ?= ligato/vpp-base:23.06-release +# Local VPP directory used for binary api generation (gen-binapi-from-code) +VPP_DIR ?= +# Target directory for generated go api bindings +BINAPI_DIR ?= ./binapi +# Binapi generator path +BINAPI_GENERATOR = ./bin/binapi-generator -VPP_IMG ?= ligato/vpp-base:latest -BINAPI_DIR ?= ./examples/binapi +.DEFAULT_GOAL = help -help: - @echo "List of make targets:" - grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' +export CGO_ENABLED=0 -.DEFAULT = help +check-%: + @: $(if $(value $*),,$(error $* is undefined)) bin: - mkdir -p bin + @mkdir -p bin -build: ## Build all - @echo "# building ${VERSION}" - $(GO) build ${GO_BUILD_ARGS} ./... +.PHONY: build +build: cmd examples ## Build all +.PHONY: cmd cmd: bin ## Build commands - $(GO) build ${GO_BUILD_ARGS} -o bin ./cmd/... + @go build ${GO_BUILD_ARGS} -o bin ./cmd/... -examples: bin ## Build examples - $(GO) build ${GO_BUILD_ARGS} -o bin ./examples/... +.PHONY: binapi-generator +binapi-generator: bin ## Build only the binapi generator + @go build ${GO_BUILD_ARGS} -o bin ./cmd/binapi-generator/ -clean: ## Clean all - @echo "# cleaning" - $(GO) clean -v ./... +.PHONY: examples +examples: bin ## Build examples + @go build ${GO_BUILD_ARGS} -o bin ./examples/... +.PHONY: test test: ## Run unit tests @echo "# running tests" - $(GO) test -tags="${GO_BUILD_TAGS}" ./... + go test -tags="${GO_BUILD_TAGS}" ./... -integration: ## Run integration tests +.PHONY: test-integration +test-integration: ## Run integration tests @echo "# running integration tests" - $(GO) test -tags="integration ${GO_BUILD_TAGS}" ./test/integration + VPP_REPO=$(VPP_REPO) ./test/run_integration.sh -lint: ## Run code linter - @echo "# running linter" - @golint ./... +.PHONY: lint ## Run code linter +lint: + @golangci-lint run + @echo "Done" +.PHONY: install install: install-generator install-proxy ## Install all +.PHONY: install-generator install-generator: ## Install binapi-generator @echo "# installing binapi-generator ${VERSION}" - $(GO) install ${GO_BUILD_ARGS} ./cmd/binapi-generator + @go install ${GO_BUILD_ARGS} ./cmd/binapi-generator +.PHONY: install-proxy install-proxy: ## Install vpp-proxy @echo "# installing vpp-proxy ${VERSION}" - $(GO) install ${GO_BUILD_ARGS} ./cmd/vpp-proxy + @go install ${GO_BUILD_ARGS} ./cmd/vpp-proxy -generate: ## Generate all - @echo "# generating code" - $(GO) generate -x ./... +.PHONY: generate +generate: generate-binapi ## Generate all +.PHONY: generate-binapi generate-binapi: install-generator ## Generate binapi code - @echo "# generating binapi VPP $(VPP_VERSION)" - $(GO) generate -x "$(BINAPI_DIR)" - + @echo "# generating binapi" + @go generate -x "$(BINAPI_DIR)" + +.PHONY: gen-binapi-local +gen-binapi-local: binapi-generator check-VPP_DIR ## Generate binapi code (using locally cloned VPP) + @make -C ${VPP_DIR} json-api-files + @find $(BINAPI_DIR)/*/*.ba.go -delete || true + @find $(BINAPI_DIR)/* -type d -delete + @./bin/binapi-generator -input-dir=$(VPP_API_DIR) -output-dir=$(BINAPI_DIR) -gen=rpc + @./bin/binapi-generator -input-dir=$(VPP_API_DIR) -input-file=$(VPP_API_DIR)/core/vpe.api.json -output-dir=$(BINAPI_DIR) -gen=http + @sed -i 's@$(VPP_API_DIR)@/usr/share/vpp/api@g' $(BINAPI_DIR)/*/*.ba.go + +.PHONY: gen-binapi-docker gen-binapi-docker: install-generator ## Generate binapi code (using Docker) @echo "# generating binapi in docker image ${VPP_IMG}" $(eval cmds := $(shell go generate -n $(BINAPI_DIR) 2>&1 | tr "\n" ";")) docker run -t --rm \ + -e DEBUG_GOVPP \ -v "$(shell which binapi-generator):/usr/local/bin/binapi-generator:ro" \ - -v "$(shell pwd):/govpp" -w /govpp \ + -v "$(shell pwd):/govpp" \ + -w /govpp \ -u "$(shell id -u):$(shell id -g)" \ "${VPP_IMG}" \ - sh -xc "cd $(BINAPI_DIR) && $(cmds)" - -extras: - @make -C extras + sh -ec "cd $(BINAPI_DIR) && $(cmds)" +.PHONY: help +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' -.PHONY: help \ - build cmd examples clean \ - lint test integration \ - install install-generator install-proxy \ - generate generate-binapi gen-binapi-docker \ - extras diff --git a/README.md b/README.md index d94714ff..83b62c3f 100644 --- a/README.md +++ b/README.md @@ -1,116 +1,73 @@ -# GoVPP - -The GoVPP projects provides the API for communication with VPP from Go. - -It consists of the following packages: -- [adapter](adapter/): adapter between GoVPP core and the VPP binary/stats API -- [api](api/): API for communication with GoVPP core -- [cmd/binapi-generator](cmd/binapi-generator/): generator for the VPP binary API definitions in JSON format to Go code -- [codec](codec/): handles encoding/decoding of generated messages into binary form -- [core](core/): essential functionality of the GoVPP -- [examples](examples/): examples that use the GoVPP API in real use-cases of VPP management application -- [extras](extras/): contains Go implementation for libmemif library -- [govpp](govpp.go): provides the entry point to GoVPP functionality - -The design with separated GoVPP [API package](api/) and the GoVPP [core package](core/) enables -plugin-based infrastructure, where one entity acts as a master responsible for talking with VPP and multiple -entities act as clients that are using the master for the communication with VPP. -The clients can be built into standalone shared libraries without the need -of linking the GoVPP core and all its dependencies into them. +

+ logo
GoVPP +

-``` - +--------------+ - +--------------+ | | - | | | plugin | - | | | | - | App | +--------------+ - | | +------+ GoVPP API | - | | | +--------------+ - +--------------+ GoVPP | - | | channels | +--------------+ - | GoVPP core +------------+ | | - | | | | plugin | - +------+-------+ | | | - | | +--------------+ - | +------+ GoVPP API | - | binary API +--------------+ - | - +------+-------+ - | | - | VPP process | - | | - +--------------+ -``` +

+ Latest + PkgGoDev + CI + Test +

-## Quick Start +The GoVPP repository contains Go client libraries, code bindings generator and other toolings for VPP. -#### Generate binapi (Go bindings) +--- -Generating Go bindings for VPP binary API from the JSON files located in the -`/usr/share/vpp/api/` directory into the Go packages that will be created -inside of the `binapi` directory: +## Features -``` -binapi-generator --input-dir=/usr/share/vpp/api/ --output-dir=binapi -``` +* 🆕 CLI app for interacting with VPP instance and development of VPP API (see [GoVPP CLI](https://github.com/FDio/govpp/blob/master/docs/GOVPP_CLI.md)) +* 🆕 Extendable code generator supporting custom plugins (see [Enhanced Generator](https://github.com/FDio/govpp/discussions/94)) +* 🆕 Generated RPC client code that handles all boilerplate (see [RPC Services](https://github.com/FDio/govpp/discussions/58)) +* Simple VPP client API that is not dependent on any VPP API semantics (see [Stream API](https://github.com/FDio/govpp/discussions/43)) +* Generator of Go bindings for VPP API schema (see [Binapi Generator](https://github.com/FDio/govpp/blob/master/docs/USER_GUIDE.md#binary-api-generator)) +* Go client library for VPP binary API & Stats API (see [VPP API calls](https://github.com/FDio/govpp/blob/master/docs/USER_GUIDE.md#vpp-api-calls)) +* Pure Go implementation of VPP binary API protocol (see [socketclient](https://github.com/FDio/govpp/blob/master/adapter/socketclient/socketclient.go)) +* Efficient reader of VPP Stats data from shared memory (see [stats client example](https://github.com/FDio/govpp/tree/master/examples/stats-client)) -#### Example Usage +## Quick Start -Here is a usage sample of the generated binapi messages: +Here is a code sample of an effortless way for calling the VPP API services by using a generated RPC client. -```go -func main() { - // Connect to VPP - conn, _ := govpp.Connect() - defer conn.Disconnect() +> **Note** +> For extensive info about using generated RPC client , see [RPC Services](https://github.com/FDio/govpp/discussions/58) - // Open channel - ch, _ := conn.NewAPIChannel() - defer ch.Close() +```go +// Connect to VPP API socket +conn, err := govpp.Connect("/run/vpp/api.sock") +if err != nil { + // handle err +} +defer conn.Disconnect() - // Prepare messages - req := &vpe.ShowVersion{} - reply := &vpe.ShowVersionReply{} +// Initialize VPP API service client +client := vpe.NewServiceClient(conn) - // Send the request - err := ch.SendRequest(req).ReceiveReply(reply) +// Call VPP API service method +reply, err := client.ShowVersion(context.Background(), &vpe.ShowVersion{}) +if err != nil { + // handle err } +log.Print("Version: ", reply.Version) ``` -The example above uses GoVPP API to communicate over underlying go channels, -see [example client](examples/simple-client/simple_client.go) -for more examples, including the example on how to use the Go channels directly. +See complete code for the example above: [examples/rpc-service](examples/rpc-service). -## Build & Install +### Examples -### Using pure Go adapters (recommended) +For complete code examples demonstrating vrious GoVPP features, please refer to the [examples](examples) directory. -GoVPP now supports pure Go implementation for VPP binary API. This does -not depend on CGo or any VPP library and can be easily compiled. +## Documentation -There are two packages providing pure Go implementations in GoVPP: -- [`socketclient`](adapter/socketclient) - for VPP binary API (via unix socket) -- [`statsclient`](adapter/statsclient) - for VPP stats API (via shared memory) +Refer to [User Guide](docs/USER_GUIDE.md) document for info about how to use GoVPP. +If you run into any issues or need some help with debugging GoVPP, read our [Troubleshooting](docs/TROUBLESHOOTING.md) document. -### Using vppapiclient library wrapper (requires CGo) +Go reference docs are available at [pkg.go.dev](https://pkg.go.dev/github.com/alkiranet/govpp). -GoVPP also provides vppapiclient package which actually uses -`vppapiclient.so` library from VPP codebase to communicate with VPP API. -To build GoVPP, `vpp-dev` package must be installed, -either [from packages][from-packages] or [from sources][from-sources]. +For other documentation refer to [docs](docs) directory. -To build & install `vpp-dev` from sources: +## How to contribute? -```sh -git clone https://gerrit.fd.io/r/vpp -cd vpp -make install-dep -make pkg-deb -cd build-root -sudo dpkg -i vpp*.deb -``` - -To build & install GoVPP: +Anyone insterested in GoVPP development is welcome to join our bi-weekly [📣 GoVPP Community Meeting](https://github.com/FDio/govpp/discussions/46), where we accept inputs from projects using GoVPP and have technical discussions about actual development. ```sh go get -u github.com/alkiranet/govpp @@ -119,27 +76,26 @@ make test make install ``` -## Generating Go bindings with binapi-generator - -Once you have `binapi-generator` installed, you can use it to generate Go bindings for VPP binary API -using VPP APIs in JSON format. The JSON input can be specified as a single file (`input-file` argument), or -as a directory that will be scanned for all `.json` files (`input-dir`). The generated Go bindings will -be placed into `output-dir` (by default current working directory), where each Go package will be placed into -a separated directory, e.g.: - -```sh -binapi-generator --input-file=acl.api.json --output-dir=binapi -binapi-generator --input-dir=/usr/share/vpp/api/core --output-dir=binapi -``` - -In Go, [go generate](https://blog.golang.org/generate) tool can be leveraged to ease the code generation -process. It allows to specify generator instructions in any one of the regular (non-generated) `.go` files -that are dependent on generated code using special comments, e.g. the one from -[example client](examples/simple-client/simple_client.go): - -```go -//go:generate binapi-generator --input-dir=bin_api --output-dir=bin_api -``` - -[from-packages]: https://wiki.fd.io/view/VPP/Installing_VPP_binaries_from_packages -[from-sources]: https://wiki.fd.io/view/VPP/Build,_install,_and_test_images#Build_A_VPP_Package +## Repository Structure + +Here is a brief overview of the repository structure. + +- [govpp](govpp.go) - the entry point for the GoVPP client + - [adapter](adapter) - VPP binary & stats API interface + - [mock](adapter/mock) - Mock adapter used for testing + - [socketclient](adapter/socketclient) - Go implementation of VPP API client for unix socket + - [statsclient](adapter/statsclient) - Go implementation of VPP Stats client for shared memory + - [api](api) - GoVPP client API + - [binapi](binapi) - generated Go bindings for the latest VPP release + - [binapigen](binapigen) - library for generating code from VPP API + - [vppapi](binapigen/vppapi) - VPP API parser + - [cmd](cmd) + - [binapi-generator](cmd/binapi-generator) - VPP binary API generator + - [vpp-proxy](cmd/vpp-proxy) - VPP proxy for remote access + - [codec](codec) - handles encoding/decoding of generated messages into binary form + - [core](core) - implementation of the GoVPP client + - [docs](docs) - user & developer documentation + - [examples](examples) - examples demonstrating GoVPP functionality + - [proxy](proxy) - contains client/server implementation for proxy + - [test](test) - integration tests, benchmarks and performance tests + diff --git a/adapter/mock/mock_stats_adapter.go b/adapter/mock/mock_stats_adapter.go index 7d6a4963..69d171c0 100644 --- a/adapter/mock/mock_stats_adapter.go +++ b/adapter/mock/mock_stats_adapter.go @@ -46,10 +46,13 @@ func (a *StatsAdapter) Disconnect() error { } // ListStats mocks name listing for all stats. -func (a *StatsAdapter) ListStats(patterns ...string) ([]string, error) { - var statNames []string +func (a *StatsAdapter) ListStats(patterns ...string) ([]adapter.StatIdentifier, error) { + var statNames []adapter.StatIdentifier for _, stat := range a.entries { - statNames = append(statNames, string(stat.Name)) + statNames = append(statNames, adapter.StatIdentifier{ + Name: stat.Name, + Index: stat.Index, + }) } return statNames, nil } @@ -63,6 +66,10 @@ func (a *StatsAdapter) PrepareDir(prefixes ...string) (*adapter.StatDir, error) return a.dir, nil } +func (a *StatsAdapter) PrepareDirOnIndex(indexes ...uint32) (*adapter.StatDir, error) { + return a.dir, nil +} + func (a *StatsAdapter) UpdateDir(dir *adapter.StatDir) error { *dir = *a.dir return nil diff --git a/adapter/mock/mock_vpp_adapter.go b/adapter/mock/mock_vpp_adapter.go index 3dd4e3f4..8ec59170 100644 --- a/adapter/mock/mock_vpp_adapter.go +++ b/adapter/mock/mock_vpp_adapter.go @@ -17,7 +17,7 @@ package mock import ( - "bytes" + "encoding/binary" "log" "reflect" "sync" @@ -26,7 +26,6 @@ import ( "github.com/alkiranet/govpp/adapter/mock/binapi" "github.com/alkiranet/govpp/api" "github.com/alkiranet/govpp/codec" - "github.com/lunixbochs/struc" ) type replyMode int @@ -45,12 +44,16 @@ type VppAdapter struct { access sync.RWMutex msgNameToIds map[string]uint16 msgIDsToName map[uint16]string - binAPITypes map[string]reflect.Type + binAPITypes map[string]map[string]reflect.Type repliesLock sync.Mutex // mutex for the queue replies []reply // FIFO queue of messages replyHandlers []ReplyHandler // callbacks that are able to calculate mock responses mode replyMode // mode in which the mock operates + + connectError error // error to be returned in Connect() + connectCallback func() // callback to be called in Connect() + disconnectCallback func() // callback to be called in Disconnect() } // defaultReply is a default reply message that mock adapter returns for a request. @@ -58,6 +61,38 @@ type defaultReply struct { Retval int32 } +func (*defaultReply) GetMessageName() string { return "mock_default_reply" } +func (*defaultReply) GetCrcString() string { return "xxxxxxxx" } +func (*defaultReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} +func (m *defaultReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *defaultReply) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + // field[1] m.Retval + buf.EncodeUint32(uint32(m.Retval)) + return buf.Bytes(), nil +} +func (m *defaultReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + // field[1] m.Retval + m.Retval = int32(buf.DecodeUint32()) + return nil +} + // MessageDTO is a structure used for propagating information to ReplyHandlers. type MessageDTO struct { MsgID uint16 @@ -95,7 +130,7 @@ func NewVppAdapter() *VppAdapter { msgIDSeq: 1000, msgIDsToName: make(map[uint16]string), msgNameToIds: make(map[string]uint16), - binAPITypes: make(map[string]reflect.Type), + binAPITypes: make(map[string]map[string]reflect.Type), } a.registerBinAPITypes() return a @@ -103,11 +138,17 @@ func NewVppAdapter() *VppAdapter { // Connect emulates connecting the process to VPP. func (a *VppAdapter) Connect() error { - return nil + if a.connectCallback != nil { + a.connectCallback() + } + return a.connectError } // Disconnect emulates disconnecting the process from VPP. func (a *VppAdapter) Disconnect() error { + if a.disconnectCallback != nil { + a.disconnectCallback() + } return nil } @@ -134,19 +175,25 @@ func (a *VppAdapter) GetMsgNameByID(msgID uint16) (string, bool) { func (a *VppAdapter) registerBinAPITypes() { a.access.Lock() defer a.access.Unlock() - for _, msg := range api.GetRegisteredMessages() { - a.binAPITypes[msg.GetMessageName()] = reflect.TypeOf(msg).Elem() + for pkg, msgs := range api.GetRegisteredMessages() { + msgMap := make(map[string]reflect.Type) + for _, msg := range msgs { + msgMap[msg.GetMessageName()] = reflect.TypeOf(msg).Elem() + } + a.binAPITypes[pkg] = msgMap } } // ReplyTypeFor returns reply message type for given request message name. -func (a *VppAdapter) ReplyTypeFor(requestMsgName string) (reflect.Type, uint16, bool) { +func (a *VppAdapter) ReplyTypeFor(pkg, requestMsgName string) (reflect.Type, uint16, bool) { replyName, foundName := binapi.ReplyNameFor(requestMsgName) if foundName { - if reply, found := a.binAPITypes[replyName]; found { - msgID, err := a.GetMsgID(replyName, "") - if err == nil { - return reply, msgID, found + if messages, found := a.binAPITypes[pkg]; found { + if reply, found := messages[replyName]; found { + msgID, err := a.GetMsgID(replyName, "") + if err == nil { + return reply, msgID, found + } } } } @@ -155,8 +202,8 @@ func (a *VppAdapter) ReplyTypeFor(requestMsgName string) (reflect.Type, uint16, } // ReplyFor returns reply message for given request message name. -func (a *VppAdapter) ReplyFor(requestMsgName string) (api.Message, uint16, bool) { - replType, msgID, foundReplType := a.ReplyTypeFor(requestMsgName) +func (a *VppAdapter) ReplyFor(pkg, requestMsgName string) (api.Message, uint16, bool) { + replType, msgID, foundReplType := a.ReplyTypeFor(pkg, requestMsgName) if foundReplType { msgVal := reflect.New(replType) if msg, ok := msgVal.Interface().(api.Message); ok { @@ -178,19 +225,16 @@ func (a *VppAdapter) ReplyBytes(request MessageDTO, reply api.Message) ([]byte, } log.Println("ReplyBytes ", replyMsgID, " ", reply.GetMessageName(), " clientId: ", request.ClientID) - buf := new(bytes.Buffer) - err = struc.Pack(buf, &codec.VppReplyHeader{ - VlMsgID: replyMsgID, - Context: request.ClientID, - }) + data, err := codec.DefaultCodec.EncodeMsg(reply, replyMsgID) if err != nil { return nil, err } - if err = struc.Pack(buf, reply); err != nil { - return nil, err + if reply.GetMessageType() == api.ReplyMessage { + binary.BigEndian.PutUint32(data[2:6], request.ClientID) + } else if reply.GetMessageType() == api.RequestMessage { + binary.BigEndian.PutUint32(data[6:10], request.ClientID) } - - return buf.Bytes(), nil + return data, nil } // GetMsgID returns mocked message ID for the given message name and CRC. @@ -224,21 +268,22 @@ func (a *VppAdapter) GetMsgID(msgName string, msgCrc string) (uint16, error) { // SendMsg emulates sending a binary-encoded message to VPP. func (a *VppAdapter) SendMsg(clientID uint32, data []byte) error { - switch a.mode { + a.repliesLock.Lock() + mode := a.mode + a.repliesLock.Unlock() + switch mode { case useReplyHandlers: for i := len(a.replyHandlers) - 1; i >= 0; i-- { replyHandler := a.replyHandlers[i] - buf := bytes.NewReader(data) - reqHeader := codec.VppRequestHeader{} - struc.Unpack(buf, &reqHeader) + msgID := binary.BigEndian.Uint16(data[0:2]) a.access.Lock() - reqMsgName := a.msgIDsToName[reqHeader.VlMsgID] + reqMsgName := a.msgIDsToName[msgID] a.access.Unlock() reply, msgID, finished := replyHandler(MessageDTO{ - MsgID: reqHeader.VlMsgID, + MsgID: msgID, MsgName: reqMsgName, ClientID: clientID, Data: data, @@ -259,23 +304,21 @@ func (a *VppAdapter) SendMsg(clientID uint32, data []byte) error { reply := a.replies[0] for _, msg := range reply.msgs { msgID, _ := a.GetMsgID(msg.Msg.GetMessageName(), msg.Msg.GetCrcString()) - buf := new(bytes.Buffer) context := clientID if msg.hasCtx { context = setMultipart(context, msg.Multipart) context = setSeqNum(context, msg.SeqNum) } + data, err := codec.DefaultCodec.EncodeMsg(msg.Msg, msgID) + if err != nil { + panic(err) + } if msg.Msg.GetMessageType() == api.ReplyMessage { - struc.Pack(buf, &codec.VppReplyHeader{VlMsgID: msgID, Context: context}) + binary.BigEndian.PutUint32(data[2:6], context) } else if msg.Msg.GetMessageType() == api.RequestMessage { - struc.Pack(buf, &codec.VppRequestHeader{VlMsgID: msgID, Context: context}) - } else if msg.Msg.GetMessageType() == api.EventMessage { - struc.Pack(buf, &codec.VppEventHeader{VlMsgID: msgID}) - } else { - struc.Pack(buf, &codec.VppOtherHeader{VlMsgID: msgID}) + binary.BigEndian.PutUint32(data[6:10], context) } - struc.Pack(buf, msg.Msg) - a.callback(msgID, buf.Bytes()) + a.callback(msgID, data) } a.replies = a.replies[1:] @@ -290,11 +333,13 @@ func (a *VppAdapter) SendMsg(clientID uint32, data []byte) error { //fallthrough default: // return default reply - buf := new(bytes.Buffer) msgID := uint16(defaultReplyMsgID) - struc.Pack(buf, &codec.VppReplyHeader{VlMsgID: msgID, Context: clientID}) - struc.Pack(buf, &defaultReply{}) - a.callback(msgID, buf.Bytes()) + data, err := codec.DefaultCodec.EncodeMsg(&defaultReply{}, msgID) + if err != nil { + panic(err) + } + binary.BigEndian.PutUint32(data[2:6], clientID) + a.callback(msgID, data) } return nil } @@ -321,17 +366,17 @@ func (a *VppAdapter) WaitReady() error { // exactly two calls of this method. // For example: // -// mockVpp.MockReply( // push multipart messages all at once -// &interfaces.SwInterfaceDetails{SwIfIndex:1}, -// &interfaces.SwInterfaceDetails{SwIfIndex:2}, -// &interfaces.SwInterfaceDetails{SwIfIndex:3}, -// ) -// mockVpp.MockReply(&vpe.ControlPingReply{}) +// mockVpp.MockReply( // push multipart messages all at once +// &interfaces.SwInterfaceDetails{SwIfIndex:1}, +// &interfaces.SwInterfaceDetails{SwIfIndex:2}, +// &interfaces.SwInterfaceDetails{SwIfIndex:3}, +// ) +// mockVpp.MockReply(&vpe.ControlPingReply{}) // // Even if the multipart request has no replies, MockReply has to be called twice: // -// mockVpp.MockReply() // zero multipart messages -// mockVpp.MockReply(&vpe.ControlPingReply{}) +// mockVpp.MockReply() // zero multipart messages +// mockVpp.MockReply(&vpe.ControlPingReply{}) func (a *VppAdapter) MockReply(msgs ...api.Message) { a.repliesLock.Lock() defer a.repliesLock.Unlock() @@ -395,3 +440,18 @@ func setMultipart(context uint32, isMultipart bool) (newContext uint32) { } return context } + +// MockConnectError sets an error to be returned in Connect() +func (a *VppAdapter) MockConnectError(err error) { + a.connectError = err +} + +// SetConnectCallback sets a callback to be called in Connect() +func (a *VppAdapter) SetConnectCallback(cb func()) { + a.connectCallback = cb +} + +// SetDisconnectCallback sets a callback to be called in Disconnect() +func (a *VppAdapter) SetDisconnectCallback(cb func()) { + a.disconnectCallback = cb +} diff --git a/adapter/socketclient/binapi.go b/adapter/socketclient/binapi.go deleted file mode 100644 index 2a719ee3..00000000 --- a/adapter/socketclient/binapi.go +++ /dev/null @@ -1,120 +0,0 @@ -package socketclient - -import ( - "github.com/alkiranet/govpp/api" -) - -// 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" -} - -// SockclntCreate represents VPP binary API message 'sockclnt_create'. -type SockclntCreate struct { - Name string `struc:"[64]byte"` -} - -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 (*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 (*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 (*SockclntDeleteReply) GetMessageName() string { - return "sockclnt_delete_reply" -} -func (*SockclntDeleteReply) GetCrcString() string { - return "8f38b1ee" -} -func (*SockclntDeleteReply) GetMessageType() api.MessageType { - return api.ReplyMessage -} - -// 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 (*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 (*APIVersionsReply) GetMessageName() string { - return "api_versions_reply" -} -func (*APIVersionsReply) GetCrcString() string { - return "5f0d99d6" -} -func (*APIVersionsReply) GetMessageType() api.MessageType { - return api.ReplyMessage -} diff --git a/adapter/socketclient/doc.go b/adapter/socketclient/doc.go index 0f93c56a..9c483086 100644 --- a/adapter/socketclient/doc.go +++ b/adapter/socketclient/doc.go @@ -18,16 +18,19 @@ // The current implementation only supports VPP binary API, the VPP stats API // is not supported and clients still have to use vppapiclient for retrieving stats. // +// # Requirements // -// Requirements +// The socketclient connects to unix domain socket defined in VPP configuration. // -// The socketclient will connect to /run/vpp-api.sock by default. However this -// is not enabled in VPP configuration by default. -// -// To enable the socket in VPP, add following section to VPP config. +// It is enabled by default at /run/vpp/api.sock by the following config section: // // socksvr { -// default +// socket-name default // } // +// If you want to use custom socket path: +// +// socksvr { +// socket-name /run/vpp/api.sock +// } package socketclient diff --git a/adapter/socketclient/socketclient.go b/adapter/socketclient/socketclient.go index 0b34917b..35be004e 100644 --- a/adapter/socketclient/socketclient.go +++ b/adapter/socketclient/socketclient.go @@ -16,9 +16,11 @@ package socketclient import ( "bufio" - "bytes" + "encoding/binary" + "errors" "fmt" "io" + "io/fs" "net" "os" "path/filepath" @@ -27,73 +29,54 @@ import ( "time" "github.com/fsnotify/fsnotify" - "github.com/lunixbochs/struc" - logger "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/alkiranet/govpp/adapter" + "github.com/alkiranet/govpp/binapi/memclnt" "github.com/alkiranet/govpp/codec" ) const ( // DefaultSocketName is default VPP API socket file path. - DefaultSocketName = adapter.DefaultBinapiSocket - legacySocketName = "/run/vpp-api.sock" + DefaultSocketName = "/run/vpp/api.sock" + // DefaultClientName is used for identifying client in socket registration + DefaultClientName = "govppsock" ) var ( + // DefaultConnectTimeout is default timeout for connecting DefaultConnectTimeout = time.Second * 3 // DefaultDisconnectTimeout is default timeout for discconnecting DefaultDisconnectTimeout = time.Millisecond * 100 - // MaxWaitReady defines maximum duration before waiting for socket file - // times out - MaxWaitReady = time.Second * 10 - // ClientName is used for identifying client in socket registration - ClientName = "govppsock" + // MaxWaitReady defines maximum duration of waiting for socket file + MaxWaitReady = time.Second * 3 ) var ( - // Debug is global variable that determines debug mode - Debug = os.Getenv("DEBUG_GOVPP_SOCK") != "" - // DebugMsgIds is global variable that determines debug mode for msg ids - DebugMsgIds = os.Getenv("DEBUG_GOVPP_SOCKMSG") != "" + debug = strings.Contains(os.Getenv("DEBUG_GOVPP"), "socketclient") + debugMsgIds = strings.Contains(os.Getenv("DEBUG_GOVPP"), "msgtable") - // Log is global logger - Log = logger.New() + log logrus.FieldLogger ) -// init initializes global logger, which logs debug level messages to stdout. -func init() { - Log.Out = os.Stdout - if Debug { - Log.Level = logger.DebugLevel - Log.Debug("govpp/socketclient: enabled debug mode") - } +// SetLogger sets global logger. +func SetLogger(logger logrus.FieldLogger) { + log = logger } -const socketMissing = ` ------------------------------------------------------------- - No socket file found at: %s - VPP binary API socket file is missing! - - - is VPP running with socket for binapi enabled? - - is the correct socket name configured? - - To enable it add following section to your VPP config: - socksvr { - default - } ------------------------------------------------------------- -` - -var warnOnce sync.Once - -func (c *vppClient) printMissingSocketMsg() { - fmt.Fprintf(os.Stderr, socketMissing, c.sockAddr) +func init() { + logger := logrus.New() + if debug { + logger.Level = logrus.DebugLevel + logger.Debug("govpp: debug level enabled for socketclient") + } + log = logger.WithField("logger", "govpp/socketclient") } -type vppClient struct { - sockAddr string +type Client struct { + socketPath string + clientName string conn *net.UnixConn reader *bufio.Reader @@ -102,78 +85,85 @@ type vppClient struct { connectTimeout time.Duration disconnectTimeout time.Duration - cb adapter.MsgCallback + msgCallback adapter.MsgCallback clientIndex uint32 msgTable map[string]uint16 + msgTableMu sync.RWMutex sockDelMsgId uint16 writeMu sync.Mutex + headerPool *sync.Pool + quit chan struct{} wg sync.WaitGroup } -func NewVppClient(sockAddr string) *vppClient { - if sockAddr == "" { - sockAddr = DefaultSocketName +// NewVppClient returns a new Client using socket. +// If socket is empty string DefaultSocketName is used. +func NewVppClient(socket string) *Client { + if socket == "" { + socket = DefaultSocketName } - return &vppClient{ - sockAddr: sockAddr, + return &Client{ + socketPath: socket, + clientName: DefaultClientName, connectTimeout: DefaultConnectTimeout, disconnectTimeout: DefaultDisconnectTimeout, - cb: func(msgID uint16, data []byte) { - Log.Warnf("no callback set, dropping message: ID=%v len=%d", msgID, len(data)) + headerPool: &sync.Pool{New: func() interface{} { + x := make([]byte, 16) + return &x + }}, + msgCallback: func(msgID uint16, data []byte) { + log.Debugf("no callback set, dropping message: ID=%v len=%d", msgID, len(data)) }, } } +// SetClientName sets a client name used for identification. +func (c *Client) SetClientName(name string) { + c.clientName = name +} + // SetConnectTimeout sets timeout used during connecting. -func (c *vppClient) SetConnectTimeout(t time.Duration) { +func (c *Client) SetConnectTimeout(t time.Duration) { c.connectTimeout = t } // SetDisconnectTimeout sets timeout used during disconnecting. -func (c *vppClient) SetDisconnectTimeout(t time.Duration) { +func (c *Client) SetDisconnectTimeout(t time.Duration) { c.disconnectTimeout = t } -func (c *vppClient) SetMsgCallback(cb adapter.MsgCallback) { - Log.Debug("SetMsgCallback") - c.cb = cb +// SetMsgCallback sets the callback for incoming messages. +func (c *Client) SetMsgCallback(cb adapter.MsgCallback) { + log.Debug("SetMsgCallback") + c.msgCallback = cb } -func (c *vppClient) checkLegacySocket() bool { - if c.sockAddr == legacySocketName { - return false - } - Log.Debugf("checking legacy socket: %s", legacySocketName) - // check if socket exists - if _, err := os.Stat(c.sockAddr); err == nil { - return false // socket exists - } else if !os.IsNotExist(err) { - return false // some other error occurred - } - // check if legacy socket exists - if _, err := os.Stat(legacySocketName); err == nil { - // legacy socket exists, update sockAddr - c.sockAddr = legacySocketName - return true +// WaitReady checks if the socket file exists and if it does not exist waits for +// it for the duration defined by MaxWaitReady. +func (c *Client) WaitReady() error { + socketDir, _ := filepath.Split(c.socketPath) + dirChain := strings.Split(filepath.ToSlash(filepath.Clean(socketDir)), "/") + + dir := "/" + for _, dirElem := range dirChain { + dir = filepath.Join(dir, dirElem) + if err := waitForDir(dir); err != nil { + return err + } + log.Debugf("dir ready: %v", dir) } - // no socket socket found - return false -} -// WaitReady checks socket file existence and waits for it if necessary -func (c *vppClient) WaitReady() error { // check if socket already exists - if _, err := os.Stat(c.sockAddr); err == nil { + if _, err := os.Stat(c.socketPath); err == nil { return nil // socket exists, we are ready - } else if !os.IsNotExist(err) { + } else if !errors.Is(err, fs.ErrNotExist) { + log.Debugf("error is: %+v", err) return err // some other error occurred } - if c.checkLegacySocket() { - return nil - } + log.Debugf("waiting for file: %v", c.socketPath) // socket does not exist, watch for it watcher, err := fsnotify.NewWatcher() @@ -182,30 +172,83 @@ func (c *vppClient) WaitReady() error { } defer func() { if err := watcher.Close(); err != nil { - Log.Warnf("failed to close file watcher: %v", err) + log.Debugf("failed to close file watcher: %v", err) } }() // start directory watcher - if err := watcher.Add(filepath.Dir(c.sockAddr)); err != nil { + d := filepath.Dir(c.socketPath) + if err := watcher.Add(d); err != nil { + log.Debugf("watcher add(%v) error: %v", d, err) return err } timeout := time.NewTimer(MaxWaitReady) + defer timeout.Stop() for { select { case <-timeout.C: - if c.checkLegacySocket() { + log.Debugf("watcher timeout after: %v", MaxWaitReady) + return fmt.Errorf("timeout waiting (%s) for socket file: %s", MaxWaitReady, c.socketPath) + + case e := <-watcher.Errors: + log.Debugf("watcher error: %+v", e) + return e + + case ev := <-watcher.Events: + log.Debugf("watcher event: %+v", ev) + if ev.Name == c.socketPath && (ev.Op&fsnotify.Create) == fsnotify.Create { + // socket created, we are ready return nil } - return fmt.Errorf("timeout waiting (%s) for socket file: %s", MaxWaitReady, c.sockAddr) + } + } +} + +func waitForDir(dir string) error { + // check if dir already exists + if _, err := os.Stat(dir); err == nil { + return nil // dir exists, we are ready + } else if !errors.Is(err, fs.ErrNotExist) { + log.Debugf("error is: %+v", err) + return err // some other error occurred + } + + log.Debugf("waiting for dir: %v", dir) + + // dir does not exist, watch for it + watcher, err := fsnotify.NewWatcher() + if err != nil { + return err + } + defer func() { + if err := watcher.Close(); err != nil { + log.Debugf("failed to close file watcher: %v", err) + } + }() + + // start watching directory + d := filepath.Dir(dir) + if err := watcher.Add(d); err != nil { + log.Debugf("watcher add (%v) error: %v", d, err) + return err + } + + timeout := time.NewTimer(MaxWaitReady) + defer timeout.Stop() + for { + select { + case <-timeout.C: + log.Debugf("watcher timeout after: %v", MaxWaitReady) + return fmt.Errorf("timeout waiting (%s) for directory: %s", MaxWaitReady, dir) case e := <-watcher.Errors: + log.Debugf("watcher error: %+v", e) return e case ev := <-watcher.Events: - Log.Debugf("watcher event: %+v", ev) - if ev.Name == c.sockAddr && (ev.Op&fsnotify.Create) == fsnotify.Create { + log.Debugf("watcher event: %+v", ev) + if ev.Name == dir && (ev.Op&fsnotify.Create) == fsnotify.Create { // socket created, we are ready return nil } @@ -213,23 +256,20 @@ func (c *vppClient) WaitReady() error { } } -func (c *vppClient) Connect() error { - c.checkLegacySocket() - +func (c *Client) Connect() error { // check if socket exists - if _, err := os.Stat(c.sockAddr); os.IsNotExist(err) { - warnOnce.Do(c.printMissingSocketMsg) - return fmt.Errorf("VPP API socket file %s does not exist", c.sockAddr) + if _, err := os.Stat(c.socketPath); os.IsNotExist(err) { + return fmt.Errorf("VPP API socket file %s does not exist", c.socketPath) } else if err != nil { return fmt.Errorf("VPP API socket error: %v", err) } - if err := c.connect(c.sockAddr); err != nil { + if err := c.connect(c.socketPath); err != nil { return err } if err := c.open(); err != nil { - c.disconnect() + _ = c.disconnect() return err } @@ -240,25 +280,23 @@ func (c *vppClient) Connect() error { return nil } -func (c *vppClient) Disconnect() error { +func (c *Client) Disconnect() error { if c.conn == nil { return nil } - Log.Debugf("Disconnecting..") + log.Debugf("Disconnecting..") close(c.quit) if err := c.conn.CloseRead(); err != nil { - Log.Debugf("closing read failed: %v", err) + log.Debugf("closing readMsg failed: %v", err) } // wait for readerLoop to return c.wg.Wait() - if err := c.close(); err != nil { - Log.Debugf("closing failed: %v", err) - } - + // Don't bother sending a vl_api_sockclnt_delete_t message, + // just close the socket. if err := c.disconnect(); err != nil { return err } @@ -266,38 +304,44 @@ func (c *vppClient) Disconnect() error { return nil } -func (c *vppClient) connect(sockAddr string) error { +const defaultBufferSize = 4096 + +func (c *Client) connect(sockAddr string) error { addr := &net.UnixAddr{Name: sockAddr, Net: "unix"} - Log.Debugf("Connecting to: %v", c.sockAddr) + log.Debugf("Connecting to: %v", c.socketPath) conn, err := net.DialUnix("unix", nil, addr) if err != nil { // we try different type of socket for backwards compatbility with VPP<=19.04 if strings.Contains(err.Error(), "wrong type for socket") { addr.Net = "unixpacket" - Log.Debugf("%s, retrying connect with type unixpacket", err) + log.Debugf("%s, retrying connect with type unixpacket", err) conn, err = net.DialUnix("unixpacket", nil, addr) } if err != nil { - Log.Debugf("Connecting to socket %s failed: %s", addr, err) + log.Debugf("Connecting to socket %s failed: %s", addr, err) return err } } c.conn = conn - Log.Debugf("Connected to socket (local addr: %v)", c.conn.LocalAddr().(*net.UnixAddr)) + log.Debugf("Connected to socket (local addr: %v)", c.conn.LocalAddr().(*net.UnixAddr)) - c.reader = bufio.NewReader(c.conn) - c.writer = bufio.NewWriter(c.conn) + c.reader = bufio.NewReaderSize(c.conn, defaultBufferSize) + c.writer = bufio.NewWriterSize(c.conn, defaultBufferSize) return nil } -func (c *vppClient) disconnect() error { - Log.Debugf("Closing socket") +func (c *Client) disconnect() error { + log.Debugf("Closing socket") + + // cleanup msg table + c.setMsgTable(make(map[string]uint16), 0) + if err := c.conn.Close(); err != nil { - Log.Debugln("Closing socket failed:", err) + log.Debugln("Closing socket failed:", err) return err } return nil @@ -309,198 +353,182 @@ const ( deleteMsgContext = byte(124) ) -func (c *vppClient) open() error { - msgCodec := new(codec.MsgCodec) +func (c *Client) open() error { + var msgCodec = codec.DefaultCodec - req := &SockclntCreate{Name: ClientName} + // Request socket client create + req := &memclnt.SockclntCreate{ + Name: c.clientName, + } msg, err := msgCodec.EncodeMsg(req, sockCreateMsgId) if err != nil { - Log.Debugln("Encode error:", err) + log.Debugln("Encode error:", err) return err } // set non-0 context msg[5] = createMsgContext - if err := c.write(msg); err != nil { - Log.Debugln("Write error: ", err) - return err - } - - readDeadline := time.Now().Add(c.connectTimeout) - if err := c.conn.SetReadDeadline(readDeadline); err != nil { + if err := c.writeMsg(msg); err != nil { + log.Debugln("Write error: ", err) return err } - msgReply, err := c.read() + msgReply, err := c.readMsgTimeout(nil, c.connectTimeout) if err != nil { - Log.Println("Read error:", err) - return err - } - // reset read deadline - if err := c.conn.SetReadDeadline(time.Time{}); err != nil { + log.Println("Read error:", err) return err } - reply := new(SockclntCreateReply) + reply := new(memclnt.SockclntCreateReply) if err := msgCodec.DecodeMsg(msgReply, reply); err != nil { - Log.Println("Decode error:", err) + log.Println("Decoding sockclnt_create_reply failed:", err) return err + } else if reply.Response != 0 { + return fmt.Errorf("sockclnt_create_reply: response error (%d)", reply.Response) } - Log.Debugf("SockclntCreateReply: Response=%v Index=%v Count=%v", + log.Debugf("SockclntCreateReply: Response=%v Index=%v Count=%v", reply.Response, reply.Index, reply.Count) c.clientIndex = reply.Index - c.msgTable = make(map[string]uint16, reply.Count) + msgTable := make(map[string]uint16, reply.Count) + var sockDelMsgId uint16 for _, x := range reply.MessageTable { msgName := strings.Split(x.Name, "\x00")[0] name := strings.TrimSuffix(msgName, "\x13") - c.msgTable[name] = x.Index + msgTable[name] = x.Index if strings.HasPrefix(name, "sockclnt_delete_") { - c.sockDelMsgId = x.Index + sockDelMsgId = x.Index } - if DebugMsgIds { - Log.Debugf(" - %4d: %q", x.Index, name) + if debugMsgIds { + log.Debugf(" - %4d: %q", x.Index, name) } } + c.setMsgTable(msgTable, sockDelMsgId) return nil } -func (c *vppClient) close() error { - msgCodec := new(codec.MsgCodec) +func (c *Client) setMsgTable(msgTable map[string]uint16, sockDelMsgId uint16) { + c.msgTableMu.Lock() + defer c.msgTableMu.Unlock() + + c.msgTable = msgTable + c.sockDelMsgId = sockDelMsgId +} - req := &SockclntDelete{ - Index: c.clientIndex, +func (c *Client) GetMsgID(msgName string, msgCrc string) (uint16, error) { + c.msgTableMu.RLock() + defer c.msgTableMu.RUnlock() + + if msgID, ok := c.msgTable[msgName+"_"+msgCrc]; ok { + return msgID, nil } - msg, err := msgCodec.EncodeMsg(req, c.sockDelMsgId) - if err != nil { - Log.Debugln("Encode error:", err) - return err + return 0, &adapter.UnknownMsgError{ + MsgName: msgName, + MsgCrc: msgCrc, } - // set non-0 context - msg[5] = deleteMsgContext +} - Log.Debugf("sending socklntDel (%d byes): % 0X", len(msg), msg) - if err := c.write(msg); err != nil { - Log.Debugln("Write error: ", err) - return err +func (c *Client) SendMsg(context uint32, data []byte) error { + if len(data) < 10 { + return fmt.Errorf("invalid message data, length must be at least 10 bytes") } + setMsgRequestHeader(data, c.clientIndex, context) - readDeadline := time.Now().Add(c.disconnectTimeout) - if err := c.conn.SetReadDeadline(readDeadline); err != nil { - return err - } - msgReply, err := c.read() - if err != nil { - Log.Debugln("Read error:", err) - if nerr, ok := err.(net.Error); ok && nerr.Timeout() { - // we accept timeout for reply - return nil - } - return err - } - // reset read deadline - if err := c.conn.SetReadDeadline(time.Time{}); err != nil { - return err + if debug { + log.Debugf("sendMsg (%d) context=%v client=%d: % 02X", len(data), context, c.clientIndex, data) } - reply := new(SockclntDeleteReply) - if err := msgCodec.DecodeMsg(msgReply, reply); err != nil { - Log.Debugln("Decode error:", err) + if err := c.writeMsg(data); err != nil { + log.Debugln("writeMsg error: ", err) return err } - Log.Debugf("SockclntDeleteReply: Response=%v", reply.Response) - return nil } -func (c *vppClient) GetMsgID(msgName string, msgCrc string) (uint16, error) { - msg := msgName + "_" + msgCrc - msgID, ok := c.msgTable[msg] - if !ok { - return 0, &adapter.UnknownMsgError{msgName, msgCrc} - } - return msgID, nil +// setMsgRequestHeader sets client index and context in the message request header +// +// Message request has following structure: +// +// type msgRequestHeader struct { +// MsgID uint16 +// ClientIndex uint32 +// Context uint32 +// } +func setMsgRequestHeader(data []byte, clientIndex, context uint32) { + // message ID is already set + binary.BigEndian.PutUint32(data[2:6], clientIndex) + binary.BigEndian.PutUint32(data[6:10], context) } -type reqHeader struct { - // MsgID uint16 - ClientIndex uint32 - Context uint32 -} +func (c *Client) writeMsg(msg []byte) error { + // we lock to prevent mixing multiple message writes + c.writeMu.Lock() + defer c.writeMu.Unlock() -func (c *vppClient) SendMsg(context uint32, data []byte) error { - h := &reqHeader{ - ClientIndex: c.clientIndex, - Context: context, + header, ok := c.headerPool.Get().(*[]byte) + if !ok { + return fmt.Errorf("failed to get header from pool") } - buf := new(bytes.Buffer) - if err := struc.Pack(buf, h); err != nil { + err := writeMsgHeader(c.writer, *header, len(msg)) + if err != nil { return err } - copy(data[2:], buf.Bytes()) + c.headerPool.Put(header) - Log.Debugf("sendMsg (%d) context=%v client=%d: data: % 02X", len(data), context, c.clientIndex, data) + if err := writeMsgData(c.writer, msg, c.writer.Size()); err != nil { + return err + } - if err := c.write(data); err != nil { - Log.Debugln("write error: ", err) + if err := c.writer.Flush(); err != nil { return err } + log.Debugf(" -- writeMsg done") + return nil } -func (c *vppClient) write(msg []byte) error { - h := &msgheader{ - DataLen: uint32(len(msg)), - } - buf := new(bytes.Buffer) - if err := struc.Pack(buf, h); err != nil { - return err - } - header := buf.Bytes() - - // we lock to prevent mixing multiple message sends - c.writeMu.Lock() - defer c.writeMu.Unlock() +func writeMsgHeader(w io.Writer, header []byte, dataLen int) error { + binary.BigEndian.PutUint32(header[8:12], uint32(dataLen)) - if n, err := c.writer.Write(header); err != nil { + n, err := w.Write(header) + if err != nil { return err - } else { - Log.Debugf(" - header sent (%d/%d): % 0X", n, len(header), header) } + if debug { + log.Debugf(" - header sent (%d/%d): % 0X", n, len(header), header) + } + + return nil +} - writerSize := c.writer.Size() +func writeMsgData(w io.Writer, msg []byte, writerSize int) error { for i := 0; i <= len(msg)/writerSize; i++ { x := i*writerSize + writerSize if x > len(msg) { x = len(msg) } - Log.Debugf(" - x=%v i=%v len=%v mod=%v", x, i, len(msg), len(msg)/writerSize) - if n, err := c.writer.Write(msg[i*writerSize : x]); err != nil { + if debug { + log.Debugf(" - x=%v i=%v len=%v mod=%v", x, i, len(msg), len(msg)/writerSize) + } + n, err := w.Write(msg[i*writerSize : x]) + if err != nil { return err - } else { - Log.Debugf(" - msg sent x=%d (%d/%d): % 0X", x, n, len(msg), msg) + } + if debug { + log.Debugf(" - data sent x=%d (%d/%d): % 0X", x, n, len(msg), msg) } } - if err := c.writer.Flush(); err != nil { - return err - } - - Log.Debugf(" -- write done") - return nil } -type msgHeader struct { - MsgID uint16 - Context uint32 -} - -func (c *vppClient) readerLoop() { +func (c *Client) readerLoop() { defer c.wg.Done() - defer Log.Debugf("reader quit") + defer log.Debugf("reader loop done") + + var buf [8192]byte for { select { @@ -509,72 +537,123 @@ func (c *vppClient) readerLoop() { default: } - msg, err := c.read() + msg, err := c.readMsg(buf[:]) if err != nil { if isClosedError(err) { return } - Log.Debugf("read failed: %v", err) + log.Debugf("readMsg error: %v", err) continue } - h := new(msgHeader) - if err := struc.Unpack(bytes.NewReader(msg), h); err != nil { - Log.Debugf("unpacking header failed: %v", err) - continue + msgID, context := getMsgReplyHeader(msg) + if debug { + log.Debugf("recvMsg (%d) msgID=%d context=%v", len(msg), msgID, context) } - Log.Debugf("recvMsg (%d) msgID=%d context=%v", len(msg), h.MsgID, h.Context) - c.cb(h.MsgID, msg) + c.msgCallback(msgID, msg) } } -type msgheader struct { - Q int `struc:"uint64"` - DataLen uint32 `struc:"uint32"` - GcMarkTimestamp uint32 `struc:"uint32"` +// getMsgReplyHeader gets message ID and context from the message reply header +// +// Message reply has the following structure: +// +// type msgReplyHeader struct { +// MsgID uint16 +// Context uint32 +// } +func getMsgReplyHeader(msg []byte) (msgID uint16, context uint32) { + msgID = binary.BigEndian.Uint16(msg[0:2]) + context = binary.BigEndian.Uint32(msg[2:6]) + return +} + +func (c *Client) readMsgTimeout(buf []byte, timeout time.Duration) ([]byte, error) { + // set read deadline + readDeadline := time.Now().Add(timeout) + if err := c.conn.SetReadDeadline(readDeadline); err != nil { + return nil, err + } + + // read message + msgReply, err := c.readMsg(buf) + if err != nil { + return nil, err + } + + // reset read deadline + if err := c.conn.SetReadDeadline(time.Time{}); err != nil { + return nil, err + } + + return msgReply, nil } -func (c *vppClient) read() ([]byte, error) { - Log.Debug(" reading next msg..") +func (c *Client) readMsg(buf []byte) ([]byte, error) { + log.Debug("reading msg..") - header := make([]byte, 16) + header, ok := c.headerPool.Get().(*[]byte) + if !ok { + return nil, fmt.Errorf("failed to get header from pool") + } + msgLen, err := readMsgHeader(c.reader, *header) + if err != nil { + return nil, err + } + c.headerPool.Put(header) - n, err := io.ReadAtLeast(c.reader, header, 16) + msg, err := readMsgData(c.reader, buf, msgLen) if err != nil { return nil, err } + + log.Debugf(" -- readMsg done (buffered: %d)", c.reader.Buffered()) + + return msg, nil +} + +func readMsgHeader(r io.Reader, header []byte) (int, error) { + n, err := io.ReadAtLeast(r, header, 16) + if err != nil { + return 0, err + } if n == 0 { - Log.Debugln("zero bytes header") - return nil, nil + log.Debugln("zero bytes header") + return 0, nil } else if n != 16 { - Log.Debugf("invalid header data (%d): % 0X", n, header[:n]) - return nil, fmt.Errorf("invalid header (expected 16 bytes, got %d)", n) + log.Debugf("invalid header (%d bytes): % 0X", n, header[:n]) + return 0, fmt.Errorf("invalid header (expected 16 bytes, got %d)", n) } - Log.Debugf(" read header %d bytes: % 0X", n, header) - h := &msgheader{} - if err := struc.Unpack(bytes.NewReader(header[:]), h); err != nil { - return nil, err - } - Log.Debugf(" - decoded header: %+v", h) + dataLen := binary.BigEndian.Uint32(header[8:12]) + + return int(dataLen), nil +} - msgLen := int(h.DataLen) - msg := make([]byte, msgLen) +func readMsgData(r io.Reader, buf []byte, dataLen int) ([]byte, error) { + var msg []byte + if buf == nil || len(buf) < dataLen { + msg = make([]byte, dataLen) + } else { + msg = buf[0:dataLen] + } - n, err = c.reader.Read(msg) + n, err := r.Read(msg) if err != nil { return nil, err } - Log.Debugf(" - read msg %d bytes (%d buffered) % 0X", n, c.reader.Buffered(), msg[:n]) + if debug { + log.Debugf(" - read data (%d bytes): % 0X", n, msg[:n]) + } - if msgLen > n { - remain := msgLen - n - Log.Debugf("continue read for another %d bytes", remain) + if dataLen > n { + remain := dataLen - n + log.Debugf("continue reading remaining %d bytes", remain) view := msg[n:] for remain > 0 { - nbytes, err := c.reader.Read(view) + nbytes, err := r.Read(view) if err != nil { return nil, err } else if nbytes == 0 { @@ -582,19 +661,17 @@ func (c *vppClient) read() ([]byte, error) { } remain -= nbytes - Log.Debugf("another data received: %d bytes (remain: %d)", nbytes, remain) + log.Debugf("another data received: %d bytes (remain: %d)", nbytes, remain) view = view[nbytes:] } } - Log.Debugf(" -- read done (buffered: %d)", c.reader.Buffered()) - return msg, nil } func isClosedError(err error) bool { - if err == io.EOF { + if errors.Is(err, io.EOF) { return true } return strings.HasSuffix(err.Error(), "use of closed network connection") diff --git a/adapter/stats_api.go b/adapter/stats_api.go index 90dbeb39..7dc7dc38 100644 --- a/adapter/stats_api.go +++ b/adapter/stats_api.go @@ -16,7 +16,6 @@ package adapter import ( "errors" - "fmt" ) const ( @@ -27,6 +26,7 @@ const ( var ( ErrStatsDataBusy = errors.New("stats data busy") ErrStatsDirStale = errors.New("stats dir stale") + ErrStatsDisconnected = errors.New("stats disconnected") ErrStatsAccessFailed = errors.New("stats access failed") ) @@ -37,59 +37,53 @@ type StatsAPI interface { // Disconnect terminates client connection. Disconnect() error - // ListStats lists names for stats matching patterns. - ListStats(patterns ...string) (names []string, err error) + // ListStats lists indexed names for stats matching patterns. + ListStats(patterns ...string) (indexes []StatIdentifier, err error) // DumpStats dumps all stat entries. DumpStats(patterns ...string) (entries []StatEntry, err error) // PrepareDir prepares new stat dir for entries that match any of prefixes. PrepareDir(patterns ...string) (*StatDir, error) + // PrepareDirOnIndex prepares new stat dir for entries that match any of indexes. + PrepareDirOnIndex(indexes ...uint32) (*StatDir, error) // UpdateDir updates stat dir and all of their entries. UpdateDir(dir *StatDir) error } // StatType represents type of stat directory and simply // defines what type of stat data is stored in the stat entry. -type StatType int +type StatType string const ( - _ StatType = 0 - ScalarIndex StatType = 1 - SimpleCounterVector StatType = 2 - CombinedCounterVector StatType = 3 - ErrorIndex StatType = 4 - NameVector StatType = 5 + Unknown StatType = "UnknownStatType" + ScalarIndex StatType = "ScalarIndex" + SimpleCounterVector StatType = "SimpleCounterVector" + CombinedCounterVector StatType = "CombinedCounterVector" + ErrorIndex StatType = "ErrorIndex" + NameVector StatType = "NameVector" + Empty StatType = "Empty" + Symlink StatType = "Symlink" ) -func (d StatType) String() string { - switch d { - case ScalarIndex: - return "ScalarIndex" - case SimpleCounterVector: - return "SimpleCounterVector" - case CombinedCounterVector: - return "CombinedCounterVector" - case ErrorIndex: - return "ErrorIndex" - case NameVector: - return "NameVector" - } - return fmt.Sprintf("UnknownStatType(%d)", d) -} - // StatDir defines directory of stats entries created by PrepareDir. type StatDir struct { Epoch int64 - Indexes []uint32 Entries []StatEntry } +// StatIdentifier holds a stat entry name and index +type StatIdentifier struct { + Index uint32 + Name []byte +} + // StatEntry represents single stat entry. The type of stat stored in Data // is defined by Type. type StatEntry struct { - Name []byte - Type StatType - Data Stat + StatIdentifier + Type StatType + Data Stat + Symlink bool } // Counter represents simple counter with single value, which is usually packet count. @@ -99,11 +93,11 @@ type Counter uint64 type CombinedCounter [2]uint64 func (s CombinedCounter) Packets() uint64 { - return uint64(s[0]) + return s[0] } func (s CombinedCounter) Bytes() uint64 { - return uint64(s[1]) + return s[1] } // Name represents string value stored under name vector. @@ -118,6 +112,9 @@ type Stat interface { // IsZero returns true if all of its values equal to zero. IsZero() bool + // Type returns underlying type of a stat + Type() StatType + // isStat is intentionally unexported to limit implementations of interface to this package, isStat() } @@ -125,16 +122,16 @@ type Stat interface { // ScalarStat represents stat for ScalarIndex. type ScalarStat float64 -// ErrorStat represents stat for ErrorIndex. -type ErrorStat Counter +// ErrorStat represents stat for ErrorIndex. The array represents workers. +type ErrorStat []Counter -// SimpleCounterStat represents stat for SimpleCounterVector. +// SimpleCounterStat represents indexed stat for SimpleCounterVector. // The outer array represents workers and the inner array represents interface/node/.. indexes. // Values should be aggregated per interface/node for every worker. // ReduceSimpleCounterStatIndex can be used to reduce specific index. type SimpleCounterStat [][]Counter -// CombinedCounterStat represents stat for CombinedCounterVector. +// CombinedCounterStat represents indexed stat for CombinedCounterVector. // The outer array represents workers and the inner array represents interface/node/.. indexes. // Values should be aggregated per interface/node for every worker. // ReduceCombinedCounterStatIndex can be used to reduce specific index. @@ -143,18 +140,40 @@ type CombinedCounterStat [][]CombinedCounter // NameStat represents stat for NameVector. type NameStat []Name +// EmptyStat represents removed counter directory +type EmptyStat string + func (ScalarStat) isStat() {} func (ErrorStat) isStat() {} func (SimpleCounterStat) isStat() {} func (CombinedCounterStat) isStat() {} func (NameStat) isStat() {} +func (EmptyStat) isStat() {} func (s ScalarStat) IsZero() bool { return s == 0 } + +func (s ScalarStat) Type() StatType { + return ScalarIndex +} + func (s ErrorStat) IsZero() bool { - return s == 0 + if s == nil { + return true + } + for _, ss := range s { + if ss != 0 { + return false + } + } + return true +} + +func (s ErrorStat) Type() StatType { + return ErrorIndex } + func (s SimpleCounterStat) IsZero() bool { if s == nil { return true @@ -168,6 +187,11 @@ func (s SimpleCounterStat) IsZero() bool { } return true } + +func (s SimpleCounterStat) Type() StatType { + return SimpleCounterVector +} + func (s CombinedCounterStat) IsZero() bool { if s == nil { return true @@ -184,6 +208,11 @@ func (s CombinedCounterStat) IsZero() bool { } return true } + +func (s CombinedCounterStat) Type() StatType { + return CombinedCounterVector +} + func (s NameStat) IsZero() bool { if s == nil { return true @@ -196,6 +225,18 @@ func (s NameStat) IsZero() bool { return true } +func (s NameStat) Type() StatType { + return NameVector +} + +func (s EmptyStat) IsZero() bool { + return true +} + +func (s EmptyStat) Type() StatType { + return Empty +} + // ReduceSimpleCounterStatIndex returns reduced SimpleCounterStat s for index i. func ReduceSimpleCounterStatIndex(s SimpleCounterStat, i int) uint64 { var val uint64 @@ -209,8 +250,8 @@ func ReduceSimpleCounterStatIndex(s SimpleCounterStat, i int) uint64 { func ReduceCombinedCounterStatIndex(s CombinedCounterStat, i int) [2]uint64 { var val [2]uint64 for _, w := range s { - val[0] += uint64(w[i][0]) - val[1] += uint64(w[i][1]) + val[0] += w[i][0] + val[1] += w[i][1] } return val } diff --git a/adapter/statsclient/stat_segment.go b/adapter/statsclient/stat_segment.go deleted file mode 100644 index 97b9592b..00000000 --- a/adapter/statsclient/stat_segment.go +++ /dev/null @@ -1,453 +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 statsclient - -import ( - "fmt" - "net" - "syscall" - "unsafe" - - "github.com/ftrvxmtrx/fd" - - "github.com/alkiranet/govpp/adapter" -) - -var ( - ErrStatDataLenIncorrect = fmt.Errorf("stat data length incorrect") -) - -const ( - minVersion = 0 - maxVersion = 1 -) - -func checkVersion(ver uint64) error { - if ver < minVersion { - return fmt.Errorf("stat segment version is too old: %v (minimal version: %v)", ver, minVersion) - } else if ver > maxVersion { - return fmt.Errorf("stat segment version is not supported: %v (minimal version: %v)", ver, maxVersion) - } - return nil -} - -type statSegment struct { - sharedHeader []byte - memorySize int64 - - // legacyVersion represents stat segment version 0 - // and is used as fallback for VPP 19.04 - legacyVersion bool -} - -func (c *statSegment) getHeader() (header sharedHeader) { - if c.legacyVersion { - return loadSharedHeaderLegacy(c.sharedHeader) - } - return loadSharedHeader(c.sharedHeader) -} - -func (c *statSegment) getEpoch() (int64, bool) { - h := c.getHeader() - return h.epoch, h.inProgress != 0 -} - -func (c *statSegment) getOffsets() (dir, err, stat int64) { - h := c.getHeader() - return h.directoryOffset, h.errorOffset, h.statsOffset -} - -func (c *statSegment) connect(sockName string) error { - if c.sharedHeader != nil { - return fmt.Errorf("already connected") - } - - addr := net.UnixAddr{ - Net: "unixpacket", - Name: sockName, - } - Log.Debugf("connecting to: %v", addr) - - conn, err := net.DialUnix(addr.Net, nil, &addr) - if err != nil { - Log.Warnf("connecting to socket %s failed: %s", addr, err) - return err - } - defer func() { - if err := conn.Close(); err != nil { - Log.Warnf("closing socket failed: %v", err) - } - }() - - Log.Debugf("connected to socket") - - files, err := fd.Get(conn, 1, nil) - if err != nil { - return fmt.Errorf("getting file descriptor over socket failed: %v", err) - } - if len(files) == 0 { - return fmt.Errorf("no files received over socket") - } - - file := files[0] - defer func() { - if err := file.Close(); err != nil { - Log.Warnf("closing file failed: %v", err) - } - }() - - info, err := file.Stat() - if err != nil { - return err - } - size := info.Size() - - data, err := syscall.Mmap(int(file.Fd()), 0, int(size), syscall.PROT_READ, syscall.MAP_SHARED) - if err != nil { - Log.Debugf("mapping shared memory failed: %v", err) - return fmt.Errorf("mapping shared memory failed: %v", err) - } - - Log.Debugf("successfuly mmapped shared memory segment (size: %v) %v", size, len(data)) - - c.sharedHeader = data - c.memorySize = size - - hdr := loadSharedHeader(c.sharedHeader) - Log.Debugf("stat segment header: %+v", hdr) - - if hdr.legacyVersion() { - c.legacyVersion = true - hdr = loadSharedHeaderLegacy(c.sharedHeader) - Log.Debugf("falling back to legacy version (VPP <=19.04) of stat segment (header: %+v)", hdr) - } - - if err := checkVersion(hdr.version); err != nil { - return err - } - - return nil -} - -func (c *statSegment) disconnect() error { - if c.sharedHeader == nil { - return nil - } - - if err := syscall.Munmap(c.sharedHeader); err != nil { - Log.Debugf("unmapping shared memory failed: %v", err) - return fmt.Errorf("unmapping shared memory failed: %v", err) - } - c.sharedHeader = nil - - Log.Debugf("successfuly unmapped shared memory") - return nil -} - -type statDirectoryType int32 - -const ( - statDirIllegal = 0 - statDirScalarIndex = 1 - statDirCounterVectorSimple = 2 - statDirCounterVectorCombined = 3 - statDirErrorIndex = 4 - statDirNameVector = 5 - statDirEmpty = 6 -) - -func (t statDirectoryType) String() string { - return adapter.StatType(t).String() -} - -type statSegDirectoryEntry struct { - directoryType statDirectoryType - // unionData can represent: - // - offset - // - index - // - value - unionData uint64 - offsetVector uint64 - name [128]byte -} - -func (c *statSegment) getStatDirVector() unsafe.Pointer { - dirOffset, _, _ := c.getOffsets() - return unsafe.Pointer(&c.sharedHeader[dirOffset]) -} - -func (c *statSegment) getStatDirIndex(p unsafe.Pointer, index uint32) *statSegDirectoryEntry { - return (*statSegDirectoryEntry)(unsafe.Pointer(uintptr(p) + uintptr(index)*unsafe.Sizeof(statSegDirectoryEntry{}))) -} - -func (c *statSegment) copyEntryData(dirEntry *statSegDirectoryEntry) adapter.Stat { - dirType := adapter.StatType(dirEntry.directoryType) - - switch dirType { - case statDirScalarIndex: - return adapter.ScalarStat(dirEntry.unionData) - - case statDirErrorIndex: - if dirEntry.unionData >= uint64(len(c.sharedHeader)) { - debugf("offset out of range for %s", dirEntry.name) - break - } - - _, errOffset, _ := c.getOffsets() - offsetVector := unsafe.Pointer(&c.sharedHeader[errOffset]) - - var errData adapter.Counter - vecLen := uint32(vectorLen(offsetVector)) - - for i := uint32(0); i < vecLen; i++ { - cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) - offset := uintptr(cb) + uintptr(dirEntry.unionData)*unsafe.Sizeof(adapter.Counter(0)) - debugf("error index, cb: %d, offset: %d", cb, offset) - val := *(*adapter.Counter)(statSegPointer(unsafe.Pointer(&c.sharedHeader[0]), offset)) - errData += val - } - return adapter.ErrorStat(errData) - - case statDirCounterVectorSimple: - if dirEntry.unionData == 0 { - debugf("offset invalid for %s", dirEntry.name) - break - } else if dirEntry.unionData >= uint64(len(c.sharedHeader)) { - debugf("offset out of range for %s", dirEntry.name) - break - } - - vecLen := uint32(vectorLen(unsafe.Pointer(&c.sharedHeader[dirEntry.unionData]))) - offsetVector := statSegPointer(unsafe.Pointer(&c.sharedHeader[0]), uintptr(dirEntry.offsetVector)) - - data := make([][]adapter.Counter, vecLen) - for i := uint32(0); i < vecLen; i++ { - cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) - counterVec := unsafe.Pointer(&c.sharedHeader[uintptr(cb)]) - vecLen2 := uint32(vectorLen(counterVec)) - data[i] = make([]adapter.Counter, vecLen2) - for j := uint32(0); j < vecLen2; j++ { - offset := uintptr(j) * unsafe.Sizeof(adapter.Counter(0)) - val := *(*adapter.Counter)(statSegPointer(counterVec, offset)) - data[i][j] = val - } - } - return adapter.SimpleCounterStat(data) - - case statDirCounterVectorCombined: - if dirEntry.unionData == 0 { - debugf("offset invalid for %s", dirEntry.name) - break - } else if dirEntry.unionData >= uint64(len(c.sharedHeader)) { - debugf("offset out of range for %s", dirEntry.name) - break - } - - vecLen := uint32(vectorLen(unsafe.Pointer(&c.sharedHeader[dirEntry.unionData]))) - offsetVector := statSegPointer(unsafe.Pointer(&c.sharedHeader[0]), uintptr(dirEntry.offsetVector)) - - data := make([][]adapter.CombinedCounter, vecLen) - for i := uint32(0); i < vecLen; i++ { - cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) - counterVec := unsafe.Pointer(&c.sharedHeader[uintptr(cb)]) - vecLen2 := uint32(vectorLen(counterVec)) - data[i] = make([]adapter.CombinedCounter, vecLen2) - for j := uint32(0); j < vecLen2; j++ { - offset := uintptr(j) * unsafe.Sizeof(adapter.CombinedCounter{}) - val := *(*adapter.CombinedCounter)(statSegPointer(counterVec, offset)) - data[i][j] = val - } - } - return adapter.CombinedCounterStat(data) - - case statDirNameVector: - if dirEntry.unionData == 0 { - debugf("offset invalid for %s", dirEntry.name) - break - } else if dirEntry.unionData >= uint64(len(c.sharedHeader)) { - debugf("offset out of range for %s", dirEntry.name) - break - } - - vecLen := uint32(vectorLen(unsafe.Pointer(&c.sharedHeader[dirEntry.unionData]))) - offsetVector := statSegPointer(unsafe.Pointer(&c.sharedHeader[0]), uintptr(dirEntry.offsetVector)) - - data := make([]adapter.Name, vecLen) - for i := uint32(0); i < vecLen; i++ { - cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) - if cb == 0 { - debugf("name vector out of range for %s (%v)", dirEntry.name, i) - continue - } - nameVec := unsafe.Pointer(&c.sharedHeader[cb]) - vecLen2 := uint32(vectorLen(nameVec)) - - nameStr := make([]byte, 0, vecLen2) - for j := uint32(0); j < vecLen2; j++ { - offset := uintptr(j) * unsafe.Sizeof(byte(0)) - val := *(*byte)(statSegPointer(nameVec, offset)) - if val > 0 { - nameStr = append(nameStr, val) - } - } - data[i] = adapter.Name(nameStr) - } - return adapter.NameStat(data) - - case statDirEmpty: - // no-op - - default: - // TODO: monitor occurrences with metrics - debugf("Unknown type %d for stat entry: %q", dirEntry.directoryType, dirEntry.name) - } - return nil -} - -func (c *statSegment) updateEntryData(dirEntry *statSegDirectoryEntry, stat *adapter.Stat) error { - switch (*stat).(type) { - case adapter.ScalarStat: - *stat = adapter.ScalarStat(dirEntry.unionData) - - case adapter.ErrorStat: - if dirEntry.unionData == 0 { - debugf("offset invalid for %s", dirEntry.name) - break - } else if dirEntry.unionData >= uint64(len(c.sharedHeader)) { - debugf("offset out of range for %s", dirEntry.name) - break - } - - _, errOffset, _ := c.getOffsets() - offsetVector := unsafe.Pointer(&c.sharedHeader[errOffset]) - - var errData adapter.Counter - vecLen := uint32(vectorLen(unsafe.Pointer(&c.sharedHeader[errOffset]))) - - for i := uint32(0); i < vecLen; i++ { - cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) - offset := uintptr(cb) + uintptr(dirEntry.unionData)*unsafe.Sizeof(adapter.Counter(0)) - val := *(*adapter.Counter)(statSegPointer(unsafe.Pointer(&c.sharedHeader[0]), offset)) - errData += val - } - *stat = adapter.ErrorStat(errData) - - case adapter.SimpleCounterStat: - if dirEntry.unionData == 0 { - debugf("offset invalid for %s", dirEntry.name) - break - } else if dirEntry.unionData >= uint64(len(c.sharedHeader)) { - debugf("offset out of range for %s", dirEntry.name) - break - } - - vecLen := uint32(vectorLen(unsafe.Pointer(&c.sharedHeader[dirEntry.unionData]))) - offsetVector := statSegPointer(unsafe.Pointer(&c.sharedHeader[0]), uintptr(dirEntry.offsetVector)) - - data := (*stat).(adapter.SimpleCounterStat) - if uint32(len(data)) != vecLen { - return ErrStatDataLenIncorrect - } - for i := uint32(0); i < vecLen; i++ { - cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) - counterVec := unsafe.Pointer(&c.sharedHeader[uintptr(cb)]) - vecLen2 := uint32(vectorLen(counterVec)) - simpData := data[i] - if uint32(len(simpData)) != vecLen2 { - return ErrStatDataLenIncorrect - } - for j := uint32(0); j < vecLen2; j++ { - offset := uintptr(j) * unsafe.Sizeof(adapter.Counter(0)) - val := *(*adapter.Counter)(statSegPointer(counterVec, offset)) - simpData[j] = val - } - } - - case adapter.CombinedCounterStat: - if dirEntry.unionData == 0 { - debugf("offset invalid for %s", dirEntry.name) - break - } else if dirEntry.unionData >= uint64(len(c.sharedHeader)) { - debugf("offset out of range for %s", dirEntry.name) - break - } - - vecLen := uint32(vectorLen(unsafe.Pointer(&c.sharedHeader[dirEntry.unionData]))) - offsetVector := statSegPointer(unsafe.Pointer(&c.sharedHeader[0]), uintptr(dirEntry.offsetVector)) - - data := (*stat).(adapter.CombinedCounterStat) - if uint32(len(data)) != vecLen { - return ErrStatDataLenIncorrect - } - for i := uint32(0); i < vecLen; i++ { - cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) - counterVec := unsafe.Pointer(&c.sharedHeader[uintptr(cb)]) - vecLen2 := uint32(vectorLen(counterVec)) - combData := data[i] - if uint32(len(combData)) != vecLen2 { - return ErrStatDataLenIncorrect - } - for j := uint32(0); j < vecLen2; j++ { - offset := uintptr(j) * unsafe.Sizeof(adapter.CombinedCounter{}) - val := *(*adapter.CombinedCounter)(statSegPointer(counterVec, offset)) - combData[j] = val - } - } - - case adapter.NameStat: - if dirEntry.unionData == 0 { - debugf("offset invalid for %s", dirEntry.name) - break - } else if dirEntry.unionData >= uint64(len(c.sharedHeader)) { - debugf("offset out of range for %s", dirEntry.name) - break - } - - vecLen := uint32(vectorLen(unsafe.Pointer(&c.sharedHeader[dirEntry.unionData]))) - offsetVector := statSegPointer(unsafe.Pointer(&c.sharedHeader[0]), uintptr(dirEntry.offsetVector)) - - data := (*stat).(adapter.NameStat) - if uint32(len(data)) != vecLen { - return ErrStatDataLenIncorrect - } - for i := uint32(0); i < vecLen; i++ { - cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) - if cb == 0 { - continue - } - nameVec := unsafe.Pointer(&c.sharedHeader[cb]) - vecLen2 := uint32(vectorLen(nameVec)) - - nameData := data[i] - if uint32(len(nameData))+1 != vecLen2 { - return ErrStatDataLenIncorrect - } - for j := uint32(0); j < vecLen2; j++ { - offset := uintptr(j) * unsafe.Sizeof(byte(0)) - val := *(*byte)(statSegPointer(nameVec, offset)) - if val == 0 { - break - } - nameData[j] = val - } - } - - default: - if Debug { - Log.Debugf("Unrecognized stat type %T for stat entry: %v", stat, dirEntry.name) - } - } - return nil -} diff --git a/adapter/statsclient/stat_segment_api.go b/adapter/statsclient/stat_segment_api.go new file mode 100644 index 00000000..df159db0 --- /dev/null +++ b/adapter/statsclient/stat_segment_api.go @@ -0,0 +1,137 @@ +// 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 statsclient + +import ( + "fmt" + "sync/atomic" + "time" + "unsafe" + + "github.com/alkiranet/govpp/adapter" +) + +var ( + // ErrStatDataLenIncorrect is returned when stat data does not match vector + // length of a respective data directory + ErrStatDataLenIncorrect = fmt.Errorf("stat data length incorrect") +) + +var ( + MaxWaitInProgress = time.Millisecond * 100 + CheckDelayInProgress = time.Microsecond * 10 +) + +const ( + minVersion = 1 + maxVersion = 2 +) + +var dirTypeMapping = map[dirType]adapter.StatType{ + 1: adapter.ScalarIndex, + 2: adapter.SimpleCounterVector, + 3: adapter.CombinedCounterVector, + 4: adapter.NameVector, + 5: adapter.Empty, + 6: adapter.Symlink, +} + +var dirTypeMappingLegacy = map[dirType]adapter.StatType{ + 1: adapter.ScalarIndex, + 2: adapter.SimpleCounterVector, + 3: adapter.CombinedCounterVector, + 4: adapter.ErrorIndex, + 5: adapter.NameVector, + 6: adapter.Empty, + 7: adapter.Symlink, +} + +type ( + dirVector unsafe.Pointer + dirSegment unsafe.Pointer + dirName []byte + dirType int32 +) + +// statSegment represents common API for every stats API version +type statSegment interface { + // GetDirectoryVector returns pointer to memory where the beginning + // of the data directory is located. + GetDirectoryVector() dirVector + + // GetStatDirOnIndex accepts directory vector and particular index. + // Returns pointer to the beginning of the segment. Also the directory + // name as [128]byte and the directory type is returned for easy use + // without needing to know the exact segment version. + // + // Note that if the index is equal to 0, the result pointer points to + // the same memory address as the argument. + GetStatDirOnIndex(v dirVector, index uint32) (dirSegment, dirName, adapter.StatType) + + // GetEpoch re-loads stats header and returns current epoch + //and 'inProgress' value + GetEpoch() (int64, bool) + + // CopyEntryData accepts pointer to a directory segment and returns adapter.Stat + // based on directory type populated with data. The index is an optional parameter + // (used by symlinks) returning stats for item on the given index only. + // Use ^uint32(0) as an empty index (since 0 is a valid value). + CopyEntryData(segment dirSegment, index uint32) adapter.Stat + + // UpdateEntryData accepts pointer to a directory segment with data, and stat + // segment to update + UpdateEntryData(segment dirSegment, s *adapter.Stat) error +} + +// vecHeader represents a vector header +type vecHeader struct { + length uint64 + vectorData [0]uint8 +} + +func getVersion(data []byte) uint64 { + type apiVersion struct { + value uint64 + } + header := (*apiVersion)(unsafe.Pointer(&data[0])) + version := &apiVersion{ + value: atomic.LoadUint64(&header.value), + } + debugf("stats API version loaded: %d", version.value) + return version.value +} + +func vectorLen(v dirVector) dirVector { + vec := *(*vecHeader)(unsafe.Pointer(uintptr(v) - unsafe.Sizeof(uint64(0)))) + return dirVector(&vec.length) +} + +func getStatType(dirTypeNum dirType, useLegacyMapping bool) (dirTyp adapter.StatType) { + var exists bool + if useLegacyMapping { + dirTyp, exists = dirTypeMappingLegacy[dirTypeNum] + } else { + dirTyp, exists = dirTypeMapping[dirTypeNum] + } + if exists { + return dirTyp + } + return adapter.Unknown +} + +//go:nosplit +func statSegPointer(v dirVector, offset uintptr) dirVector { + return dirVector(uintptr(v) + offset) +} diff --git a/adapter/statsclient/statsclient.go b/adapter/statsclient/statsclient.go index 4508160a..d8b07c45 100644 --- a/adapter/statsclient/statsclient.go +++ b/adapter/statsclient/statsclient.go @@ -18,9 +18,17 @@ package statsclient import ( "bytes" "fmt" + "net" "os" + "path/filepath" "regexp" + "sync" + "sync/atomic" + "syscall" + "time" + "github.com/fsnotify/fsnotify" + "github.com/ftrvxmtrx/fd" logger "github.com/sirupsen/logrus" "github.com/alkiranet/govpp/adapter" @@ -29,21 +37,14 @@ import ( const ( // DefaultSocketName is default VPP stats socket file path. DefaultSocketName = adapter.DefaultStatsSocket -) - -const socketMissing = ` ------------------------------------------------------------- - VPP stats socket file %s is missing! - - is VPP running with stats segment enabled? - - is the correct socket name configured? + // DefaultSocketRetryPeriod is the time period after the socket availability + // will be re-checked + DefaultSocketRetryPeriod = 50 * time.Millisecond - To enable it add following section to your VPP config: - statseg { - default - } ------------------------------------------------------------- -` + // DefaultSocketRetryTimeout is the maximum time for the stats socket + DefaultSocketRetryTimeout = 3 * time.Second +) var ( // Debug is global variable that determines debug mode @@ -73,184 +74,504 @@ var _ adapter.StatsAPI = (*StatsClient)(nil) // StatsClient is the pure Go implementation for VPP stats API. type StatsClient struct { - sockAddr string + socket string + retryPeriod time.Duration + retryTimeout time.Duration + + headerData []byte + + // defines the adapter connection state + connected uint32 + // defines the adapter monitoring loop state + monitored uint32 + + // to quit socket monitor + done chan struct{} + + // to protect statseg access from concurrent reconnect + accessLock sync.RWMutex statSegment } -// NewStatsClient returns new VPP stats API client. -func NewStatsClient(sockAddr string) *StatsClient { - if sockAddr == "" { - sockAddr = DefaultSocketName - } - return &StatsClient{ - sockAddr: sockAddr, +// Option is a StatsClient option +type Option func(*StatsClient) + +// SetSocketRetryPeriod is and optional parameter to define a custom +// retry period while waiting for the VPP socket +func SetSocketRetryPeriod(t time.Duration) Option { + return func(c *StatsClient) { + c.retryPeriod = t } } -func (c *StatsClient) Connect() error { - // check if socket exists - if _, err := os.Stat(c.sockAddr); os.IsNotExist(err) { - fmt.Fprintf(os.Stderr, socketMissing, c.sockAddr) - return fmt.Errorf("stats socket file %s does not exist", c.sockAddr) - } else if err != nil { - return fmt.Errorf("stats socket error: %v", err) +// SetSocketRetryTimeout is and optional parameter to define a custom +// timeout while waiting for the VPP socket +func SetSocketRetryTimeout(t time.Duration) Option { + return func(c *StatsClient) { + c.retryTimeout = t } +} - if err := c.statSegment.connect(c.sockAddr); err != nil { - return err +// NewStatsClient returns a new StatsClient using socket. +// If socket is empty string DefaultSocketName is used. +func NewStatsClient(socket string, options ...Option) *StatsClient { + if socket == "" { + socket = DefaultSocketName } - - return nil + s := &StatsClient{ + socket: socket, + } + for _, option := range options { + option(s) + } + if s.retryPeriod == 0 { + s.retryPeriod = DefaultSocketRetryPeriod + } + if s.retryTimeout == 0 { + s.retryTimeout = DefaultSocketRetryTimeout + } + return s } -func (c *StatsClient) Disconnect() error { - if err := c.statSegment.disconnect(); err != nil { +// Connect to validated VPP stats socket and start monitoring +// socket file changes +func (sc *StatsClient) Connect() (err error) { + if err := sc.waitForSocket(); err != nil { return err } + sc.done = make(chan struct{}) + sc.accessLock.Lock() + defer sc.accessLock.Unlock() + if sc.statSegment, err = sc.connect(); err != nil { + return err + } + sc.monitorSocket() return nil } -func (c *StatsClient) ListStats(patterns ...string) (names []string, err error) { - sa := c.accessStart() - if sa.epoch == 0 { - return nil, adapter.ErrStatsAccessFailed +// Disconnect from the socket, unmap shared memory and terminate +// socket monitor +func (sc *StatsClient) Disconnect() error { + if atomic.CompareAndSwapUint32(&sc.monitored, 1, 0) { + close(sc.done) } - indexes, err := c.listIndexes(patterns...) - if err != nil { - return nil, err + if !sc.isConnected() { + return nil } - dirVector := c.getStatDirVector() - vecLen := uint32(vectorLen(dirVector)) + return sc.disconnect() +} - for _, index := range indexes { - if index >= vecLen { - return nil, fmt.Errorf("stat entry index %d out of dir vector len (%d)", index, vecLen) - } +func (sc *StatsClient) ListStats(patterns ...string) (entries []adapter.StatIdentifier, err error) { + if !sc.isConnected() { + return nil, adapter.ErrStatsDisconnected + } + sc.accessLock.RLock() + defer sc.accessLock.RUnlock() + accessEpoch := sc.accessStart() + if accessEpoch == 0 { + return nil, adapter.ErrStatsAccessFailed + } - dirEntry := c.getStatDirIndex(dirVector, index) - var name []byte - for n := 0; n < len(dirEntry.name); n++ { - if dirEntry.name[n] == 0 { - name = dirEntry.name[:n] - break - } - } - names = append(names, string(name)) + entries, err = sc.getIdentifierEntries(patterns...) + if err != nil { + return nil, err } - if !c.accessEnd(&sa) { + if !sc.accessEnd(accessEpoch) { return nil, adapter.ErrStatsDataBusy } - - return names, nil + return entries, nil } -func (c *StatsClient) DumpStats(patterns ...string) (entries []adapter.StatEntry, err error) { - sa := c.accessStart() - if sa.epoch == 0 { +func (sc *StatsClient) DumpStats(patterns ...string) (entries []adapter.StatEntry, err error) { + if !sc.isConnected() { + return nil, adapter.ErrStatsDisconnected + } + + sc.accessLock.RLock() + defer sc.accessLock.RUnlock() + accessEpoch := sc.accessStart() + if accessEpoch == 0 { return nil, adapter.ErrStatsAccessFailed } - indexes, err := c.listIndexes(patterns...) + entries, err = sc.getStatEntries(patterns...) if err != nil { return nil, err } - if entries, err = c.dumpEntries(indexes); err != nil { - return nil, err - } - if !c.accessEnd(&sa) { + if !sc.accessEnd(accessEpoch) { return nil, adapter.ErrStatsDataBusy } - return entries, nil } -func (c *StatsClient) PrepareDir(patterns ...string) (*adapter.StatDir, error) { - dir := new(adapter.StatDir) +func (sc *StatsClient) PrepareDir(patterns ...string) (*adapter.StatDir, error) { + if !sc.isConnected() { + return nil, adapter.ErrStatsDisconnected + } - sa := c.accessStart() - if sa.epoch == 0 { + sc.accessLock.RLock() + defer sc.accessLock.RUnlock() + accessEpoch := sc.accessStart() + if accessEpoch == 0 { return nil, adapter.ErrStatsAccessFailed } - indexes, err := c.listIndexes(patterns...) + entries, err := sc.getStatEntries(patterns...) if err != nil { return nil, err } - dir.Indexes = indexes - entries, err := c.dumpEntries(indexes) + if !sc.accessEnd(accessEpoch) { + return nil, adapter.ErrStatsDataBusy + } + + dir := &adapter.StatDir{ + Epoch: accessEpoch, + Entries: entries, + } + + return dir, nil +} + +func (sc *StatsClient) PrepareDirOnIndex(indexes ...uint32) (*adapter.StatDir, error) { + if !sc.isConnected() { + return nil, adapter.ErrStatsDisconnected + } + + sc.accessLock.RLock() + defer sc.accessLock.RUnlock() + accessEpoch := sc.accessStart() + if accessEpoch == 0 { + return nil, adapter.ErrStatsAccessFailed + } + vector := sc.GetDirectoryVector() + if vector == nil { + return nil, fmt.Errorf("failed to prepare dir on index: directory vector is nil") + } + entries, err := sc.getStatEntriesOnIndex(vector, indexes...) if err != nil { return nil, err } - dir.Entries = entries - if !c.accessEnd(&sa) { + if !sc.accessEnd(accessEpoch) { return nil, adapter.ErrStatsDataBusy } - dir.Epoch = sa.epoch + + dir := &adapter.StatDir{ + Epoch: accessEpoch, + Entries: entries, + } return dir, nil } -func (c *StatsClient) UpdateDir(dir *adapter.StatDir) (err error) { - epoch, _ := c.getEpoch() +// UpdateDir refreshes directory data for all counters +func (sc *StatsClient) UpdateDir(dir *adapter.StatDir) (err error) { + if !sc.isConnected() { + return adapter.ErrStatsDisconnected + } + + sc.accessLock.RLock() + defer sc.accessLock.RUnlock() + epoch, _ := sc.GetEpoch() if dir.Epoch != epoch { return adapter.ErrStatsDirStale } - sa := c.accessStart() - if sa.epoch == 0 { + accessEpoch := sc.accessStart() + if accessEpoch == 0 { return adapter.ErrStatsAccessFailed } + dirVector := sc.GetDirectoryVector() + if dirVector == nil { + return err + } + for i := 0; i < len(dir.Entries); i++ { + if err := sc.updateStatOnIndex(&dir.Entries[i], dirVector); err != nil { + return err + } + } + if !sc.accessEnd(accessEpoch) { + return adapter.ErrStatsDataBusy + } + return nil +} - dirVector := c.getStatDirVector() - - for i, index := range dir.Indexes { - dirEntry := c.getStatDirIndex(dirVector, index) - - var name []byte - for n := 0; n < len(dirEntry.name); n++ { - if dirEntry.name[n] == 0 { - name = dirEntry.name[:n] - break +// checks the socket existence and waits for it for the designated +// time if it is not available immediately +func (sc *StatsClient) waitForSocket() error { + if _, err := os.Stat(sc.socket); err != nil { + if os.IsNotExist(err) { + n := time.Now() + ticker := time.NewTicker(sc.retryPeriod) + timeout := time.After(sc.retryTimeout) + for { + select { + case <-ticker.C: + if _, err := os.Stat(sc.socket); err == nil { + return nil + } + case <-timeout: + return fmt.Errorf("stats socket file %s is not ready within timeout (after %.2f s) ", + sc.socket, time.Since(n).Seconds()) + } } + } else { + return fmt.Errorf("stats socket error: %v", err) } - if len(name) == 0 { - continue + } + return nil +} + +// connect to the socket and map it into the memory. According to the +// header version info, an appropriate segment handler is returned +func (sc *StatsClient) connect() (ss statSegment, err error) { + addr := net.UnixAddr{ + Net: "unixpacket", + Name: sc.socket, + } + Log.Debugf("connecting to: %v", addr) + + conn, err := net.DialUnix(addr.Net, nil, &addr) + if err != nil { + Log.Warnf("connecting to socket %s failed: %s", addr, err) + return nil, err + } + defer func() { + if err := conn.Close(); err != nil { + Log.Warnf("closing socket failed: %v", err) } + }() + Log.Debugf("connected to socket") - entry := &dir.Entries[i] - if !bytes.Equal(name, entry.Name) { - continue + files, err := fd.Get(conn, 1, nil) + if err != nil { + return nil, fmt.Errorf("getting file descriptor over socket failed: %v", err) + } + if len(files) == 0 { + return nil, fmt.Errorf("no files received over socket") + } + + file := files[0] + defer func() { + if err := file.Close(); err != nil { + Log.Warnf("closing file failed: %v", err) } - if adapter.StatType(dirEntry.directoryType) != entry.Type { - continue + }() + + info, err := file.Stat() + if err != nil { + return nil, err + } + size := info.Size() + + sc.headerData, err = syscall.Mmap(int(file.Fd()), 0, int(size), syscall.PROT_READ, syscall.MAP_SHARED) + if err != nil { + Log.Debugf("mapping shared memory failed: %v", err) + return nil, fmt.Errorf("mapping shared memory failed: %v", err) + } + Log.Debugf("successfully mmapped shared memory segment (size: %v) %v", size, len(sc.headerData)) + + version := getVersion(sc.headerData) + switch version { + case 1: + ss = newStatSegmentV1(sc.headerData, size) + case 2: + ss = newStatSegmentV2(sc.headerData, size) + default: + if err = syscall.Munmap(sc.headerData); err != nil { + Log.Debugf("unmapping shared memory failed: %v", err) } - if entry.Data == nil { - continue + return nil, fmt.Errorf("stat segment version is not supported: %v (min: %v, max: %v)", + version, minVersion, maxVersion) + } + + // set connected + atomic.CompareAndSwapUint32(&sc.connected, 0, 1) + + return ss, nil +} + +// reconnect disconnects from the socket, re-validates it and +// connects again +func (sc *StatsClient) reconnect() (err error) { + sc.accessLock.Lock() + defer sc.accessLock.Unlock() + if err = sc.disconnect(); err != nil { + return fmt.Errorf("error disconnecting socket: %v", err) + } + if err = sc.waitForSocket(); err != nil { + return fmt.Errorf("error while waiting on socket: %v", err) + } + if sc.statSegment, err = sc.connect(); err != nil { + return fmt.Errorf("error connecting socket: %v", err) + } + return nil +} + +// disconnect unmaps socket data from the memory and resets the header +func (sc *StatsClient) disconnect() error { + + if !atomic.CompareAndSwapUint32(&sc.connected, 1, 0) { + return fmt.Errorf("stats client is already disconnected") + } + if sc.headerData == nil { + return nil + } + if err := syscall.Munmap(sc.headerData); err != nil { + Log.Debugf("unmapping shared memory failed: %v", err) + return fmt.Errorf("unmapping shared memory failed: %v", err) + } + sc.headerData = nil + + Log.Debugf("successfully unmapped shared memory") + return nil +} + +func (sc *StatsClient) monitorSocket() { + watcher, err := fsnotify.NewWatcher() + if err != nil { + Log.Errorf("error starting socket monitor: %v", err) + return + } + + atomic.StoreUint32(&sc.monitored, 1) + + go func() { + for { + select { + case event := <-watcher.Events: + if event.Op == fsnotify.Remove && event.Name == sc.socket { + if err := sc.reconnect(); err != nil { + Log.Errorf("error occurred during socket reconnect: %v", err) + } + } + case err := <-watcher.Errors: + Log.Errorf("socket monitor delivered error event: %v", err) + case <-sc.done: + err := watcher.Close() + Log.Debugf("socket monitor closed (error: %v)", err) + return + } } - if err := c.updateEntryData(dirEntry, &entry.Data); err != nil { - return fmt.Errorf("updating stat data for entry %s failed: %v", name, err) + }() + + if err := watcher.Add(filepath.Dir(sc.socket)); err != nil { + Log.Errorf("failed to add socket address to the watcher: %v", err) + } +} + +// Starts monitoring 'inProgress' field. Returns stats segment +// access epoch when completed, or zero value if not finished +// within MaxWaitInProgress +func (sc *StatsClient) accessStart() (epoch int64) { + t := time.Now() + + epoch, inProg := sc.GetEpoch() + for inProg { + if time.Since(t) > MaxWaitInProgress { + return int64(0) } + time.Sleep(CheckDelayInProgress) + epoch, inProg = sc.GetEpoch() + } + return epoch +} +// AccessEnd returns true if stats data reading was finished, false +// otherwise +func (sc *StatsClient) accessEnd(accessEpoch int64) bool { + epoch, inProgress := sc.GetEpoch() + if accessEpoch != epoch || inProgress { + return false } + return true +} - if !c.accessEnd(&sa) { - return adapter.ErrStatsDataBusy +// getStatEntries retrieves all stats matching desired patterns, or all stats if no pattern is provided. +func (sc *StatsClient) getStatEntries(patterns ...string) (entries []adapter.StatEntry, err error) { + vector := sc.GetDirectoryVector() + if vector == nil { + return nil, fmt.Errorf("failed to get stat entries: directory vector is nil") + } + indexes, err := sc.listIndexes(vector, patterns...) + if err != nil { + return nil, err } + return sc.getStatEntriesOnIndex(vector, indexes...) +} - return nil +// getIdentifierEntries retrieves all identifiers matching desired patterns, or all identifiers +// if no pattern is provided. +func (sc *StatsClient) getIdentifierEntries(patterns ...string) (identifiers []adapter.StatIdentifier, err error) { + vector := sc.GetDirectoryVector() + if vector == nil { + return nil, fmt.Errorf("failed to get identifier entries: directory vector is nil") + } + indexes, err := sc.listIndexes(vector, patterns...) + if err != nil { + return nil, err + } + return sc.getIdentifierEntriesOnIndex(vector, indexes...) +} + +// getStatEntriesOnIndex retrieves stats on indexes, or all stats if indexes are not defined. +func (sc *StatsClient) getStatEntriesOnIndex(vector dirVector, indexes ...uint32) (entries []adapter.StatEntry, err error) { + dirLen := *(*uint32)(vectorLen(vector)) + for _, index := range indexes { + if index >= dirLen { + return nil, fmt.Errorf("stat entry index %d out of dir vector length (%d)", index, dirLen) + } + dirPtr, dirName, dirType := sc.GetStatDirOnIndex(vector, index) + if len(dirName) == 0 { + return + } + var t adapter.StatType + d := sc.CopyEntryData(dirPtr, ^uint32(0)) + if d != nil { + t = d.Type() + } + entries = append(entries, adapter.StatEntry{ + StatIdentifier: adapter.StatIdentifier{ + Index: index, + Name: dirName, + }, + Type: t, + Data: d, + Symlink: dirType == adapter.Symlink, + }) + } + return entries, nil +} + +// getIdentifierEntriesOnIndex retrieves identifiers on indexes, or all identifiers if indexes are not defined. +func (sc *StatsClient) getIdentifierEntriesOnIndex(vector dirVector, indexes ...uint32) (identifiers []adapter.StatIdentifier, err error) { + dirLen := *(*uint32)(vectorLen(vector)) + for _, index := range indexes { + if index >= dirLen { + return nil, fmt.Errorf("stat entry index %d out of dir vector length (%d)", index, dirLen) + } + _, dirName, _ := sc.GetStatDirOnIndex(vector, index) + if len(dirName) == 0 { + return + } + identifiers = append(identifiers, adapter.StatIdentifier{ + Index: index, + Name: dirName, + }) + } + return identifiers, nil } // listIndexes lists indexes for all stat entries that match any of the regex patterns. -func (c *StatsClient) listIndexes(patterns ...string) (indexes []uint32, err error) { +func (sc *StatsClient) listIndexes(vector dirVector, patterns ...string) (indexes []uint32, err error) { if len(patterns) == 0 { - return c.listIndexesFunc(nil) + return sc.listIndexesFunc(vector, nil) } var regexes = make([]*regexp.Regexp, len(patterns)) for i, pattern := range patterns { @@ -260,7 +581,7 @@ func (c *StatsClient) listIndexes(patterns ...string) (indexes []uint32, err err } regexes[i] = r } - nameMatches := func(name []byte) bool { + nameMatches := func(name dirName) bool { for _, r := range regexes { if r.Match(name) { return true @@ -268,31 +589,22 @@ func (c *StatsClient) listIndexes(patterns ...string) (indexes []uint32, err err } return false } - return c.listIndexesFunc(nameMatches) + return sc.listIndexesFunc(vector, nameMatches) } -func (c *StatsClient) listIndexesFunc(f func(name []byte) bool) (indexes []uint32, err error) { +// listIndexesFunc lists stats indexes. The optional function +// argument filters returned values or returns all if empty +func (sc *StatsClient) listIndexesFunc(vector dirVector, f func(name dirName) bool) (indexes []uint32, err error) { if f == nil { // there is around ~3157 stats, so to avoid too many allocations // we set capacity to 3200 when listing all stats indexes = make([]uint32, 0, 3200) } - - dirVector := c.getStatDirVector() - vecLen := uint32(vectorLen(dirVector)) - + vecLen := *(*uint32)(vectorLen(vector)) for i := uint32(0); i < vecLen; i++ { - dirEntry := c.getStatDirIndex(dirVector, i) - + _, dirName, _ := sc.GetStatDirOnIndex(vector, i) if f != nil { - var name []byte - for n := 0; n < len(dirEntry.name); n++ { - if dirEntry.name[n] == 0 { - name = dirEntry.name[:n] - break - } - } - if len(name) == 0 || !f(name) { + if len(dirName) == 0 || !f(dirName) { continue } } @@ -302,44 +614,25 @@ func (c *StatsClient) listIndexesFunc(f func(name []byte) bool) (indexes []uint3 return indexes, nil } -func (c *StatsClient) dumpEntries(indexes []uint32) (entries []adapter.StatEntry, err error) { - dirVector := c.getStatDirVector() - dirLen := uint32(vectorLen(dirVector)) - - debugf("dumping entres for %d indexes", len(indexes)) - - entries = make([]adapter.StatEntry, 0, len(indexes)) - for _, index := range indexes { - if index >= dirLen { - return nil, fmt.Errorf("stat entry index %d out of dir vector length (%d)", index, dirLen) - } - - dirEntry := c.getStatDirIndex(dirVector, index) - - var name []byte - for n := 0; n < len(dirEntry.name); n++ { - if dirEntry.name[n] == 0 { - name = dirEntry.name[:n] - break - } - } - - if Debug { - debugf(" - %3d. dir: %q type: %v offset: %d union: %d", index, name, - adapter.StatType(dirEntry.directoryType), dirEntry.offsetVector, dirEntry.unionData) - } - - if len(name) == 0 { - continue - } +func (sc *StatsClient) isConnected() bool { + return atomic.LoadUint32(&sc.connected) == 1 +} - entry := adapter.StatEntry{ - Name: append([]byte(nil), name...), - Type: adapter.StatType(dirEntry.directoryType), - Data: c.copyEntryData(dirEntry), - } - entries = append(entries, entry) +// updateStatOnIndex refreshes the entry data. +func (sc *StatsClient) updateStatOnIndex(entry *adapter.StatEntry, vector dirVector) (err error) { + dirLen := *(*uint32)(vectorLen(vector)) + if entry.Index >= dirLen { + return fmt.Errorf("stat entry index %d out of dir vector length (%d)", entry.Index, dirLen) } - - return entries, nil + dirPtr, dirName, dirType := sc.GetStatDirOnIndex(vector, entry.Index) + if len(dirName) == 0 || + !bytes.Equal(dirName, entry.Name) || + dirType != entry.Type || + entry.Data == nil { + return nil + } + if err := sc.UpdateEntryData(dirPtr, &entry.Data); err != nil { + return fmt.Errorf("updating stat data for entry %s failed: %v", dirName, err) + } + return } diff --git a/adapter/statsclient/statseg.go b/adapter/statsclient/statseg.go deleted file mode 100644 index 42ab3de6..00000000 --- a/adapter/statsclient/statseg.go +++ /dev/null @@ -1,104 +0,0 @@ -package statsclient - -import ( - "sync/atomic" - "time" - "unsafe" -) - -var ( - MaxWaitInProgress = time.Millisecond * 100 - CheckDelayInProgress = time.Microsecond * 10 -) - -type sharedHeaderBase struct { - epoch int64 - inProgress int64 - directoryOffset int64 - errorOffset int64 - statsOffset int64 -} - -type sharedHeaderV0 struct { - sharedHeaderBase -} - -type sharedHeader struct { - version uint64 - sharedHeaderBase -} - -func (h *sharedHeader) legacyVersion() bool { - // older VPP (<=19.04) did not have version in stat segment header - // we try to provide fallback support by skipping it in header - if h.version > maxVersion && h.inProgress > 1 && h.epoch == 0 { - return true - } - return false -} - -func loadSharedHeader(b []byte) (header sharedHeader) { - h := (*sharedHeader)(unsafe.Pointer(&b[0])) - header.version = atomic.LoadUint64(&h.version) - header.epoch = atomic.LoadInt64(&h.epoch) - header.inProgress = atomic.LoadInt64(&h.inProgress) - header.directoryOffset = atomic.LoadInt64(&h.directoryOffset) - header.errorOffset = atomic.LoadInt64(&h.errorOffset) - header.statsOffset = atomic.LoadInt64(&h.statsOffset) - return -} - -func loadSharedHeaderLegacy(b []byte) (header sharedHeader) { - h := (*sharedHeaderV0)(unsafe.Pointer(&b[0])) - header.version = 0 - header.epoch = atomic.LoadInt64(&h.epoch) - header.inProgress = atomic.LoadInt64(&h.inProgress) - header.directoryOffset = atomic.LoadInt64(&h.directoryOffset) - header.errorOffset = atomic.LoadInt64(&h.errorOffset) - header.statsOffset = atomic.LoadInt64(&h.statsOffset) - return -} - -type statSegAccess struct { - epoch int64 -} - -func (c *statSegment) accessStart() statSegAccess { - t := time.Now() - - epoch, inprog := c.getEpoch() - for inprog { - if time.Since(t) > MaxWaitInProgress { - return statSegAccess{} - } else { - time.Sleep(CheckDelayInProgress) - } - epoch, inprog = c.getEpoch() - } - return statSegAccess{ - epoch: epoch, - } -} - -func (c *statSegment) accessEnd(acc *statSegAccess) bool { - epoch, inprog := c.getEpoch() - if acc.epoch != epoch || inprog { - return false - } - return true -} - -type vecHeader struct { - length uint64 - vectorData [0]uint8 -} - -func vectorLen(v unsafe.Pointer) uint64 { - vec := *(*vecHeader)(unsafe.Pointer(uintptr(v) - unsafe.Sizeof(uint64(0)))) - return vec.length -} - -//go:nosplit -func statSegPointer(p unsafe.Pointer, offset uintptr) unsafe.Pointer { - return unsafe.Pointer(uintptr(p) + offset) -} diff --git a/adapter/statsclient/statseg_v1.go b/adapter/statsclient/statseg_v1.go new file mode 100644 index 00000000..72487512 --- /dev/null +++ b/adapter/statsclient/statseg_v1.go @@ -0,0 +1,360 @@ +// 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 statsclient + +import ( + "sync/atomic" + "unsafe" + + "github.com/alkiranet/govpp/adapter" +) + +type statSegmentV1 struct { + sharedHeader []byte + memorySize int64 +} + +type sharedHeaderV1 struct { + version uint64 + epoch int64 + inProgress int64 + directoryOffset int64 + errorOffset int64 + statsOffset int64 +} + +type statSegDirectoryEntryV1 struct { + directoryType dirType + // unionData can represent: + // - offset + // - index + // - value + unionData uint64 + offsetVector uint64 + name [128]byte +} + +func newStatSegmentV1(data []byte, size int64) *statSegmentV1 { + return &statSegmentV1{ + sharedHeader: data, + memorySize: size, + } +} + +func (ss *statSegmentV1) loadSharedHeader(b []byte) (header sharedHeaderV1) { + h := (*sharedHeaderV1)(unsafe.Pointer(&b[0])) + return sharedHeaderV1{ + version: atomic.LoadUint64(&h.version), + epoch: atomic.LoadInt64(&h.epoch), + inProgress: atomic.LoadInt64(&h.inProgress), + directoryOffset: atomic.LoadInt64(&h.directoryOffset), + errorOffset: atomic.LoadInt64(&h.errorOffset), + statsOffset: atomic.LoadInt64(&h.statsOffset), + } +} + +func (ss *statSegmentV1) GetDirectoryVector() dirVector { + dirOffset, _, _ := ss.getOffsets() + return dirVector(&ss.sharedHeader[dirOffset]) +} + +func (ss *statSegmentV1) GetStatDirOnIndex(v dirVector, index uint32) (dirSegment, dirName, adapter.StatType) { + statSegDir := dirSegment(uintptr(v) + uintptr(index)*unsafe.Sizeof(statSegDirectoryEntryV1{})) + dir := (*statSegDirectoryEntryV1)(statSegDir) + var name []byte + for n := 0; n < len(dir.name); n++ { + if dir.name[n] == 0 { + name = dir.name[:n] + break + } + } + return statSegDir, name, getStatType(dir.directoryType, true) +} + +func (ss *statSegmentV1) GetEpoch() (int64, bool) { + sh := ss.loadSharedHeader(ss.sharedHeader) + return sh.epoch, sh.inProgress != 0 +} + +func (ss *statSegmentV1) CopyEntryData(segment dirSegment, _ uint32) adapter.Stat { + dirEntry := (*statSegDirectoryEntryV1)(segment) + typ := getStatType(dirEntry.directoryType, true) + + switch typ { + case adapter.ScalarIndex: + return adapter.ScalarStat(dirEntry.unionData) + + case adapter.ErrorIndex: + if dirEntry.unionData >= uint64(len(ss.sharedHeader)) { + debugf("offset out of range for %s", dirEntry.name) + break + } + + _, errOffset, _ := ss.getOffsets() + offsetVector := dirVector(&ss.sharedHeader[errOffset]) + + var errData []adapter.Counter + + vecLen := *(*uint32)(vectorLen(offsetVector)) + for i := uint32(0); i < vecLen; i++ { + cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) + offset := uintptr(cb) + uintptr(dirEntry.unionData)*unsafe.Sizeof(adapter.Counter(0)) + debugf("error index, cb: %d, offset: %d", cb, offset) + val := *(*adapter.Counter)(statSegPointer(dirVector(&ss.sharedHeader[0]), offset)) + errData = append(errData, val) + } + return adapter.ErrorStat(errData) + + case adapter.SimpleCounterVector: + if dirEntry.unionData == 0 { + debugf("offset invalid for %s", dirEntry.name) + break + } else if dirEntry.unionData >= uint64(len(ss.sharedHeader)) { + debugf("offset out of range for %s", dirEntry.name) + break + } + + vecLen := *(*uint32)(vectorLen(dirVector(&ss.sharedHeader[dirEntry.unionData]))) + offsetVector := statSegPointer(dirVector(&ss.sharedHeader[0]), uintptr(dirEntry.offsetVector)) + + data := make([][]adapter.Counter, vecLen) + for i := uint32(0); i < vecLen; i++ { + cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) + counterVec := dirVector(&ss.sharedHeader[uintptr(cb)]) + vecLen2 := *(*uint32)(vectorLen(counterVec)) + data[i] = make([]adapter.Counter, vecLen2) + for j := uint32(0); j < vecLen2; j++ { + offset := uintptr(j) * unsafe.Sizeof(adapter.Counter(0)) + val := *(*adapter.Counter)(statSegPointer(counterVec, offset)) + data[i][j] = val + } + } + return adapter.SimpleCounterStat(data) + + case adapter.CombinedCounterVector: + if dirEntry.unionData == 0 { + debugf("offset invalid for %s", dirEntry.name) + break + } else if dirEntry.unionData >= uint64(len(ss.sharedHeader)) { + debugf("offset out of range for %s", dirEntry.name) + break + } + + vecLen := *(*uint32)(vectorLen(dirVector(&ss.sharedHeader[dirEntry.unionData]))) + offsetVector := statSegPointer(dirVector(&ss.sharedHeader[0]), uintptr(dirEntry.offsetVector)) + + data := make([][]adapter.CombinedCounter, vecLen) + for i := uint32(0); i < vecLen; i++ { + cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) + counterVec := dirVector(&ss.sharedHeader[uintptr(cb)]) + vecLen2 := *(*uint32)(vectorLen(counterVec)) + data[i] = make([]adapter.CombinedCounter, vecLen2) + for j := uint32(0); j < vecLen2; j++ { + offset := uintptr(j) * unsafe.Sizeof(adapter.CombinedCounter{}) + val := *(*adapter.CombinedCounter)(statSegPointer(counterVec, offset)) + data[i][j] = val + } + } + return adapter.CombinedCounterStat(data) + + case adapter.NameVector: + if dirEntry.unionData == 0 { + debugf("offset invalid for %s", dirEntry.name) + break + } else if dirEntry.unionData >= uint64(len(ss.sharedHeader)) { + debugf("offset out of range for %s", dirEntry.name) + break + } + + vecLen := *(*uint32)(vectorLen(dirVector(&ss.sharedHeader[dirEntry.unionData]))) + offsetVector := statSegPointer(dirVector(&ss.sharedHeader[0]), uintptr(dirEntry.offsetVector)) + + data := make([]adapter.Name, vecLen) + for i := uint32(0); i < vecLen; i++ { + cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) + if cb == 0 { + debugf("name vector out of range for %s (%v)", dirEntry.name, i) + continue + } + nameVec := dirVector(&ss.sharedHeader[cb]) + vecLen2 := *(*uint32)(vectorLen(nameVec)) + + nameStr := make([]byte, 0, vecLen2) + for j := uint32(0); j < vecLen2; j++ { + offset := uintptr(j) * unsafe.Sizeof(byte(0)) + val := *(*byte)(statSegPointer(nameVec, offset)) + if val > 0 { + nameStr = append(nameStr, val) + } + } + data[i] = nameStr + } + return adapter.NameStat(data) + + case adapter.Empty: + // no-op + + case adapter.Symlink: + debugf("Symlinks are not supported for stats v1") + + default: + // TODO: monitor occurrences with metrics + debugf("Unknown type %d for stat entry: %q", dirEntry.directoryType, dirEntry.name) + } + return nil +} + +func (ss *statSegmentV1) UpdateEntryData(segment dirSegment, stat *adapter.Stat) error { + dirEntry := (*statSegDirectoryEntryV1)(segment) + switch (*stat).(type) { + case adapter.ScalarStat: + *stat = adapter.ScalarStat(dirEntry.unionData) + + case adapter.ErrorStat: + if dirEntry.unionData == 0 { + debugf("offset invalid for %s", dirEntry.name) + break + } else if dirEntry.unionData >= uint64(len(ss.sharedHeader)) { + debugf("offset out of range for %s", dirEntry.name) + break + } + + _, errOffset, _ := ss.getOffsets() + offsetVector := dirVector(&ss.sharedHeader[errOffset]) + + var errData []adapter.Counter + + vecLen := *(*uint32)(vectorLen(dirVector(&ss.sharedHeader[errOffset]))) + for i := uint32(0); i < vecLen; i++ { + cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) + offset := uintptr(cb) + uintptr(dirEntry.unionData)*unsafe.Sizeof(adapter.Counter(0)) + val := *(*adapter.Counter)(statSegPointer(dirVector(&ss.sharedHeader[0]), offset)) + errData = append(errData, val) + } + *stat = adapter.ErrorStat(errData) + + case adapter.SimpleCounterStat: + if dirEntry.unionData == 0 { + debugf("offset invalid for %s", dirEntry.name) + break + } else if dirEntry.unionData >= uint64(len(ss.sharedHeader)) { + debugf("offset out of range for %s", dirEntry.name) + break + } + + vecLen := *(*uint32)(vectorLen(dirVector(&ss.sharedHeader[dirEntry.unionData]))) + offsetVector := statSegPointer(dirVector(&ss.sharedHeader[0]), uintptr(dirEntry.offsetVector)) + + data := (*stat).(adapter.SimpleCounterStat) + if uint32(len(data)) != vecLen { + return ErrStatDataLenIncorrect + } + for i := uint32(0); i < vecLen; i++ { + cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) + counterVec := dirVector(&ss.sharedHeader[uintptr(cb)]) + vecLen2 := *(*uint32)(vectorLen(counterVec)) + simpleData := data[i] + if uint32(len(simpleData)) != vecLen2 { + return ErrStatDataLenIncorrect + } + for j := uint32(0); j < vecLen2; j++ { + offset := uintptr(j) * unsafe.Sizeof(adapter.Counter(0)) + val := *(*adapter.Counter)(statSegPointer(counterVec, offset)) + simpleData[j] = val + } + } + + case adapter.CombinedCounterStat: + if dirEntry.unionData == 0 { + debugf("offset invalid for %s", dirEntry.name) + break + } else if dirEntry.unionData >= uint64(len(ss.sharedHeader)) { + debugf("offset out of range for %s", dirEntry.name) + break + } + + vecLen := *(*uint32)(vectorLen(dirVector(&ss.sharedHeader[dirEntry.unionData]))) + offsetVector := statSegPointer(dirVector(&ss.sharedHeader[0]), uintptr(dirEntry.offsetVector)) + + data := (*stat).(adapter.CombinedCounterStat) + if uint32(len(data)) != vecLen { + return ErrStatDataLenIncorrect + } + for i := uint32(0); i < vecLen; i++ { + cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) + counterVec := dirVector(&ss.sharedHeader[uintptr(cb)]) + vecLen2 := *(*uint32)(vectorLen(counterVec)) + combData := data[i] + if uint32(len(combData)) != vecLen2 { + return ErrStatDataLenIncorrect + } + for j := uint32(0); j < vecLen2; j++ { + offset := uintptr(j) * unsafe.Sizeof(adapter.CombinedCounter{}) + val := *(*adapter.CombinedCounter)(statSegPointer(counterVec, offset)) + combData[j] = val + } + } + + case adapter.NameStat: + if dirEntry.unionData == 0 { + debugf("offset invalid for %s", dirEntry.name) + break + } else if dirEntry.unionData >= uint64(len(ss.sharedHeader)) { + debugf("offset out of range for %s", dirEntry.name) + break + } + + vecLen := *(*uint32)(vectorLen(dirVector(&ss.sharedHeader[dirEntry.unionData]))) + offsetVector := statSegPointer(dirVector(&ss.sharedHeader[0]), uintptr(dirEntry.offsetVector)) + + data := (*stat).(adapter.NameStat) + if uint32(len(data)) != vecLen { + return ErrStatDataLenIncorrect + } + for i := uint32(0); i < vecLen; i++ { + cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) + if cb == 0 { + continue + } + nameVec := dirVector(&ss.sharedHeader[cb]) + vecLen2 := *(*uint32)(vectorLen(nameVec)) + + nameData := data[i] + if uint32(len(nameData))+1 != vecLen2 { + return ErrStatDataLenIncorrect + } + for j := uint32(0); j < vecLen2; j++ { + offset := uintptr(j) * unsafe.Sizeof(byte(0)) + val := *(*byte)(statSegPointer(nameVec, offset)) + if val == 0 { + break + } + nameData[j] = val + } + } + + default: + if Debug { + Log.Debugf("Unrecognized stat type %T for stat entry: %v", stat, dirEntry.name) + } + } + return nil +} + +// Get offsets for various types of data +func (ss *statSegmentV1) getOffsets() (dir, err, stat int64) { + sh := ss.loadSharedHeader(ss.sharedHeader) + return sh.directoryOffset, sh.errorOffset, sh.statsOffset +} diff --git a/adapter/statsclient/statseg_v2.go b/adapter/statsclient/statseg_v2.go new file mode 100644 index 00000000..ab3cd10e --- /dev/null +++ b/adapter/statsclient/statseg_v2.go @@ -0,0 +1,411 @@ +// 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 statsclient + +import ( + "bytes" + "encoding/binary" + "sync/atomic" + "unsafe" + + "github.com/alkiranet/govpp/adapter" +) + +type statSegmentV2 struct { + sharedHeader []byte + memorySize int64 +} + +type sharedHeaderV2 struct { + version uint64 + base unsafe.Pointer + epoch int64 + inProgress int64 + dirVector unsafe.Pointer + errorVector unsafe.Pointer +} + +type statSegDirectoryEntryV2 struct { + directoryType dirType + // unionData can represent: + // - symlink indexes + // - index + // - value + // - pointer to data + unionData uint64 + name [128]byte +} + +func newStatSegmentV2(data []byte, size int64) *statSegmentV2 { + return &statSegmentV2{ + sharedHeader: data, + memorySize: size, + } +} + +func (ss *statSegmentV2) loadSharedHeader(b []byte) (header sharedHeaderV2) { + h := (*sharedHeaderV2)(unsafe.Pointer(&b[0])) + return sharedHeaderV2{ + version: atomic.LoadUint64(&h.version), + base: atomic.LoadPointer(&h.base), + epoch: atomic.LoadInt64(&h.epoch), + inProgress: atomic.LoadInt64(&h.inProgress), + dirVector: atomic.LoadPointer(&h.dirVector), + errorVector: atomic.LoadPointer(&h.errorVector), + } +} + +func (ss *statSegmentV2) GetDirectoryVector() dirVector { + header := ss.loadSharedHeader(ss.sharedHeader) + return ss.adjust(dirVector(&header.dirVector)) +} + +func (ss *statSegmentV2) GetStatDirOnIndex(v dirVector, index uint32) (dirSegment, dirName, adapter.StatType) { + statSegDir := dirSegment(uintptr(v) + uintptr(index)*unsafe.Sizeof(statSegDirectoryEntryV2{})) + dir := (*statSegDirectoryEntryV2)(statSegDir) + var name []byte + for n := 0; n < len(dir.name); n++ { + if dir.name[n] == 0 { + name = dir.name[:n] + break + } + } + return statSegDir, name, getStatType(dir.directoryType, ss.getErrorVector() != nil) +} + +func (ss *statSegmentV2) GetEpoch() (int64, bool) { + sh := ss.loadSharedHeader(ss.sharedHeader) + return sh.epoch, sh.inProgress != 0 +} + +func (ss *statSegmentV2) CopyEntryData(segment dirSegment, index uint32) adapter.Stat { + dirEntry := (*statSegDirectoryEntryV2)(segment) + typ := getStatType(dirEntry.directoryType, ss.getErrorVector() != nil) + // skip zero pointer value + if typ != adapter.ScalarIndex && typ != adapter.Empty && typ != adapter.ErrorIndex && dirEntry.unionData == 0 { + debugf("data pointer not defined for %s", dirEntry.name) + return nil + } + + switch typ { + case adapter.ScalarIndex: + return adapter.ScalarStat(dirEntry.unionData) + + case adapter.ErrorIndex: + dirVector := ss.getErrorVector() + if dirVector == nil { + debugf("error vector pointer is out of range for %s", dirEntry.name) + return nil + } + vecLen := *(*uint32)(vectorLen(dirVector)) + var errData []adapter.Counter + for i := uint32(0); i < vecLen; i++ { + cb := statSegPointer(dirVector, uintptr(i+1)*unsafe.Sizeof(uint64(0))) + cbVal := ss.adjust(vectorLen(cb)) + if cbVal == nil { + debugf("error counter pointer out of range") + continue + } + offset := uintptr(dirEntry.unionData) * unsafe.Sizeof(adapter.Counter(0)) + val := *(*adapter.Counter)(statSegPointer(cbVal, offset)) + errData = append(errData, val) + } + return adapter.ErrorStat(errData) + + case adapter.SimpleCounterVector: + dirVector := ss.adjust(dirVector(&dirEntry.unionData)) + if dirVector == nil { + debugf("data vector pointer is out of range for %s", dirEntry.name) + return nil + } + vecLen := *(*uint32)(vectorLen(dirVector)) + data := make([][]adapter.Counter, vecLen) + for i := uint32(0); i < vecLen; i++ { + counterVectorOffset := statSegPointer(dirVector, uintptr(i+1)*unsafe.Sizeof(uint64(0))) + counterVector := ss.adjust(vectorLen(counterVectorOffset)) + if counterVector == nil { + debugf("counter (vector simple) pointer out of range") + continue + } + counterVectorLength := *(*uint32)(vectorLen(counterVector)) + if index == ^uint32(0) { + data[i] = make([]adapter.Counter, counterVectorLength) + for j := uint32(0); j < counterVectorLength; j++ { + offset := uintptr(j) * unsafe.Sizeof(adapter.Counter(0)) + data[i][j] = *(*adapter.Counter)(statSegPointer(counterVector, offset)) + } + } else { + data[i] = make([]adapter.Counter, 1) // expect single value + for j := uint32(0); j < counterVectorLength; j++ { + offset := uintptr(j) * unsafe.Sizeof(adapter.Counter(0)) + if index == j { + data[i][0] = *(*adapter.Counter)(statSegPointer(counterVector, offset)) + break + } + } + } + } + return adapter.SimpleCounterStat(data) + + case adapter.CombinedCounterVector: + dirVector := ss.adjust(dirVector(&dirEntry.unionData)) + if dirVector == nil { + debugf("data vector pointer is out of range for %s", dirEntry.name) + return nil + } + vecLen := *(*uint32)(vectorLen(dirVector)) + data := make([][]adapter.CombinedCounter, vecLen) + for i := uint32(0); i < vecLen; i++ { + counterVectorOffset := statSegPointer(dirVector, uintptr(i+1)*unsafe.Sizeof(uint64(0))) + counterVector := ss.adjust(vectorLen(counterVectorOffset)) + if counterVector == nil { + debugf("counter (vector combined) pointer out of range") + continue + } + counterVectorLength := *(*uint32)(vectorLen(counterVector)) + if index == ^uint32(0) { + data[i] = make([]adapter.CombinedCounter, counterVectorLength) + for j := uint32(0); j < counterVectorLength; j++ { + offset := uintptr(j) * unsafe.Sizeof(adapter.CombinedCounter{}) + data[i][j] = *(*adapter.CombinedCounter)(statSegPointer(counterVector, offset)) + } + } else { + data[i] = make([]adapter.CombinedCounter, 1) // expect single value pair + for j := uint32(0); j < counterVectorLength; j++ { + offset := uintptr(j) * unsafe.Sizeof(adapter.CombinedCounter{}) + if index == j { + data[i][0] = *(*adapter.CombinedCounter)(statSegPointer(counterVector, offset)) + break + } + } + } + } + return adapter.CombinedCounterStat(data) + + case adapter.NameVector: + dirVector := ss.adjust(dirVector(&dirEntry.unionData)) + if dirVector == nil { + debugf("data vector pointer is out of range for %s", dirEntry.name) + return nil + } + vecLen := *(*uint32)(vectorLen(dirVector)) + data := make([]adapter.Name, vecLen) + for i := uint32(0); i < vecLen; i++ { + nameVectorOffset := statSegPointer(dirVector, uintptr(i+1)*unsafe.Sizeof(uint64(0))) + if uintptr(nameVectorOffset) == 0 { + debugf("name vector out of range for %s (%v)", dirEntry.name, i) + continue + } + nameVector := ss.adjust(vectorLen(nameVectorOffset)) + if nameVector == nil { + debugf("name data pointer out of range") + continue + } + nameVectorLen := *(*uint32)(vectorLen(nameVector)) + name := make([]byte, 0, nameVectorLen) + for j := uint32(0); j < nameVectorLen; j++ { + offset := uintptr(j) * unsafe.Sizeof(byte(0)) + value := *(*byte)(statSegPointer(nameVector, offset)) + if value > 0 { + name = append(name, value) + } + } + data[i] = name + } + return adapter.NameStat(data) + + case adapter.Empty: + return adapter.EmptyStat("") + // no-op + + case adapter.Symlink: + // prevent recursion loops + if index != ^uint32(0) { + debugf("received symlink with defined item index") + return nil + } + i1, i2 := ss.getSymlinkIndexes(dirEntry) + // use first index to get the stats directory the symlink points to + header := ss.loadSharedHeader(ss.sharedHeader) + dirVector := ss.adjust(dirVector(&header.dirVector)) + statSegDir2 := dirSegment(uintptr(dirVector) + uintptr(i1)*unsafe.Sizeof(statSegDirectoryEntryV2{})) + + // retry with actual stats segment and use second index to get + // stats for the required item + return ss.CopyEntryData(statSegDir2, i2) + + default: + // TODO: monitor occurrences with metrics + debugf("Unknown type %d for stat entry: %q", dirEntry.directoryType, dirEntry.name) + } + return nil +} + +func (ss *statSegmentV2) UpdateEntryData(segment dirSegment, stat *adapter.Stat) error { + dirEntry := (*statSegDirectoryEntryV2)(segment) + switch (*stat).(type) { + case adapter.ScalarStat: + *stat = adapter.ScalarStat(dirEntry.unionData) + + case adapter.ErrorStat: + dirVector := ss.getErrorVector() + if dirVector == nil { + debugf("error vector pointer is out of range for %s", dirEntry.name) + return nil + } + vecLen := *(*uint32)(vectorLen(dirVector)) + var errData []adapter.Counter + for i := uint32(0); i < vecLen; i++ { + cb := statSegPointer(dirVector, uintptr(i+1)*unsafe.Sizeof(uint64(0))) + cbVal := ss.adjust(vectorLen(cb)) + if cbVal == nil { + debugf("error counter pointer out of range") + continue + } + offset := uintptr(dirEntry.unionData) * unsafe.Sizeof(adapter.Counter(0)) + val := *(*adapter.Counter)(statSegPointer(cbVal, offset)) + errData = append(errData, val) + } + *stat = adapter.ErrorStat(errData) + + case adapter.SimpleCounterStat: + dirVector := ss.adjust(dirVector(&dirEntry.unionData)) + if dirVector == nil { + debugf("data vector pointer is out of range for %s", dirEntry.name) + return nil + } + vecLen := *(*uint32)(vectorLen(dirVector)) + data := (*stat).(adapter.SimpleCounterStat) + if uint32(len(data)) != vecLen { + return ErrStatDataLenIncorrect + } + for i := uint32(0); i < vecLen; i++ { + counterVectorOffset := statSegPointer(dirVector, uintptr(i+1)*unsafe.Sizeof(uint64(0))) + counterVector := ss.adjust(vectorLen(counterVectorOffset)) + if counterVector == nil { + debugf("counter (vector simple) pointer out of range") + continue + } + counterVectorLength := *(*uint32)(vectorLen(counterVector)) + data[i] = make([]adapter.Counter, counterVectorLength) + for j := uint32(0); j < counterVectorLength; j++ { + offset := uintptr(j) * unsafe.Sizeof(adapter.Counter(0)) + val := *(*adapter.Counter)(statSegPointer(counterVector, offset)) + data[i][j] = val + } + } + + case adapter.CombinedCounterStat: + dirVector := ss.adjust(dirVector(&dirEntry.unionData)) + if dirVector == nil { + debugf("data vector pointer is out of range for %s", dirEntry.name) + return nil + } + vecLen := *(*uint32)(vectorLen(dirVector)) + data := (*stat).(adapter.CombinedCounterStat) + for i := uint32(0); i < vecLen; i++ { + counterVectorOffset := statSegPointer(dirVector, uintptr(i+1)*unsafe.Sizeof(uint64(0))) + counterVector := ss.adjust(vectorLen(counterVectorOffset)) + if counterVector == nil { + debugf("counter (vector combined) pointer out of range") + continue + } + counterVectorLength := *(*uint32)(vectorLen(counterVector)) + data[i] = make([]adapter.CombinedCounter, counterVectorLength) + for j := uint32(0); j < counterVectorLength; j++ { + offset := uintptr(j) * unsafe.Sizeof(adapter.CombinedCounter{}) + val := *(*adapter.CombinedCounter)(statSegPointer(counterVector, offset)) + data[i][j] = val + } + } + + case adapter.NameStat: + dirVector := ss.adjust(dirVector(&dirEntry.unionData)) + if dirVector == nil { + debugf("data vector pointer is out of range for %s", dirEntry.name) + return nil + } + vecLen := *(*uint32)(vectorLen(dirVector)) + data := (*stat).(adapter.NameStat) + for i := uint32(0); i < vecLen; i++ { + nameVectorOffset := statSegPointer(dirVector, uintptr(i+1)*unsafe.Sizeof(uint64(0))) + if uintptr(nameVectorOffset) == 0 { + debugf("name vector out of range for %s (%v)", dirEntry.name, i) + continue + } + nameVector := ss.adjust(vectorLen(nameVectorOffset)) + if nameVector == nil { + debugf("name data pointer out of range") + continue + } + nameVectorLen := *(*uint32)(vectorLen(nameVector)) + nameData := data[i] + if uint32(len(nameData))+1 != nameVectorLen { + return ErrStatDataLenIncorrect + } + for j := uint32(0); j < nameVectorLen; j++ { + offset := uintptr(j) * unsafe.Sizeof(byte(0)) + value := *(*byte)(statSegPointer(nameVector, offset)) + if value == 0 { + break + } + nameData[j] = value + } + } + + default: + if Debug { + Log.Debugf("Unrecognized stat type %T for stat entry: %v", stat, dirEntry.name) + } + } + return nil +} + +// Adjust data pointer using shared header and base and return +// the pointer to a data segment +func (ss *statSegmentV2) adjust(data dirVector) dirVector { + header := ss.loadSharedHeader(ss.sharedHeader) + adjusted := dirVector(uintptr(unsafe.Pointer(&ss.sharedHeader[0])) + + uintptr(*(*uint64)(data)) - uintptr(*(*uint64)(unsafe.Pointer(&header.base)))) + if uintptr(unsafe.Pointer(&ss.sharedHeader[len(ss.sharedHeader)-1])) <= uintptr(adjusted) || + uintptr(unsafe.Pointer(&ss.sharedHeader[0])) >= uintptr(adjusted) { + return nil + } + return adjusted +} + +func (ss *statSegmentV2) getErrorVector() dirVector { + header := ss.loadSharedHeader(ss.sharedHeader) + return ss.adjust(dirVector(&header.errorVector)) +} + +func (ss *statSegmentV2) getSymlinkIndexes(dirEntry *statSegDirectoryEntryV2) (index1, index2 uint32) { + var b bytes.Buffer + if err := binary.Write(&b, binary.LittleEndian, dirEntry.unionData); err != nil { + debugf("error getting symlink indexes for %s: %v", dirEntry.name, err) + return + } + if len(b.Bytes()) != 8 { + debugf("incorrect symlink union data length for %s: expected 8, got %d", dirEntry.name, len(b.Bytes())) + return + } + for i := range b.Bytes()[:4] { + index1 += uint32(b.Bytes()[i]) << (uint32(i) * 8) + } + for i := range b.Bytes()[4:] { + index2 += uint32(b.Bytes()[i+4]) << (uint32(i) * 8) + } + return +} diff --git a/adapter/vppapiclient/stat_client.go b/adapter/vppapiclient/stat_client.go deleted file mode 100644 index d2298b49..00000000 --- a/adapter/vppapiclient/stat_client.go +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright (c) 2018 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. - -//go:build !windows && !darwin && !novpp && !beyond18.10 -// +build !windows,!darwin,!novpp,!beyond18.10 - -package vppapiclient - -/* -#cgo CFLAGS: -DPNG_DEBUG=1 -#cgo LDFLAGS: -lvppapiclient - -#include "stat_client_wrapper.h" -*/ -import "C" - -import ( - "fmt" - "os" - "unsafe" - - "github.com/alkiranet/govpp/adapter" -) - -// global VPP stats API client, library vppapiclient only supports -// single connection at a time -var globalStatClient *statClient - -// statClient is the default implementation of StatsAPI. -type statClient struct { - socketName string -} - -// NewStatClient returns new VPP stats API client. -func NewStatClient(socketName string) adapter.StatsAPI { - return &statClient{ - socketName: socketName, - } -} - -func (c *statClient) Connect() error { - if globalStatClient != nil { - return fmt.Errorf("already connected to stats API, disconnect first") - } - - var sockName string - if c.socketName == "" { - sockName = adapter.DefaultStatsSocket - } else { - sockName = c.socketName - } - - if _, err := os.Stat(sockName); err != nil { - if os.IsNotExist(err) { - return fmt.Errorf("stats socket file %q does not exists, ensure that VPP is running with `statseg { ... }` section in config", sockName) - } - return fmt.Errorf("stats socket file error: %v", err) - } - - rc := C.govpp_stat_connect(C.CString(sockName)) - if rc != 0 { - return fmt.Errorf("connecting to VPP stats API failed (rc=%v)", rc) - } - - globalStatClient = c - return nil -} - -func (c *statClient) Disconnect() error { - globalStatClient = nil - - C.govpp_stat_disconnect() - return nil -} - -func (c *statClient) ListStats(patterns ...string) (stats []string, err error) { - dir := C.govpp_stat_segment_ls(convertStringSlice(patterns)) - if dir == nil { - return nil, adapter.ErrStatsDataBusy - } - defer C.govpp_stat_segment_vec_free(unsafe.Pointer(dir)) - - l := C.govpp_stat_segment_vec_len(unsafe.Pointer(dir)) - for i := 0; i < int(l); i++ { - nameChar := C.govpp_stat_segment_dir_index_to_name(dir, C.uint32_t(i)) - stats = append(stats, C.GoString(nameChar)) - C.free(unsafe.Pointer(nameChar)) - } - - return stats, nil -} - -func (c *statClient) DumpStats(patterns ...string) (stats []adapter.StatEntry, err error) { - dir := C.govpp_stat_segment_ls(convertStringSlice(patterns)) - if dir == nil { - return nil, adapter.ErrStatsDataBusy - } - defer C.govpp_stat_segment_vec_free(unsafe.Pointer(dir)) - - dump := C.govpp_stat_segment_dump(dir) - if dump == nil { - return nil, adapter.ErrStatsDataBusy - } - defer C.govpp_stat_segment_data_free(dump) - - l := C.govpp_stat_segment_vec_len(unsafe.Pointer(dump)) - for i := 0; i < int(l); i++ { - v := C.govpp_stat_segment_dump_index(dump, C.int(i)) - nameChar := v.name - name := C.GoString(nameChar) - typ := adapter.StatType(C.govpp_stat_segment_data_type(&v)) - - stat := adapter.StatEntry{ - Name: []byte(name), - Type: typ, - } - - switch typ { - case adapter.ScalarIndex: - stat.Data = adapter.ScalarStat(C.govpp_stat_segment_data_get_scalar_value(&v)) - - case adapter.ErrorIndex: - stat.Data = adapter.ErrorStat(C.govpp_stat_segment_data_get_error_value(&v)) - - case adapter.SimpleCounterVector: - length := int(C.govpp_stat_segment_vec_len(unsafe.Pointer(C.govpp_stat_segment_data_get_simple_counter(&v)))) - vector := make([][]adapter.Counter, length) - for k := 0; k < length; k++ { - for j := 0; j < int(C.govpp_stat_segment_vec_len(unsafe.Pointer(C.govpp_stat_segment_data_get_simple_counter_index(&v, C.int(k))))); j++ { - vector[k] = append(vector[k], adapter.Counter(C.govpp_stat_segment_data_get_simple_counter_index_value(&v, C.int(k), C.int(j)))) - } - } - stat.Data = adapter.SimpleCounterStat(vector) - - case adapter.CombinedCounterVector: - length := int(C.govpp_stat_segment_vec_len(unsafe.Pointer(C.govpp_stat_segment_data_get_combined_counter(&v)))) - vector := make([][]adapter.CombinedCounter, length) - for k := 0; k < length; k++ { - for j := 0; j < int(C.govpp_stat_segment_vec_len(unsafe.Pointer(C.govpp_stat_segment_data_get_combined_counter_index(&v, C.int(k))))); j++ { - vector[k] = append(vector[k], adapter.CombinedCounter([2]uint64{ - uint64(C.govpp_stat_segment_data_get_combined_counter_index_packets(&v, C.int(k), C.int(j))), - uint64(C.govpp_stat_segment_data_get_combined_counter_index_bytes(&v, C.int(k), C.int(j))), - })) - } - } - stat.Data = adapter.CombinedCounterStat(vector) - - case adapter.NameVector: - length := int(C.govpp_stat_segment_vec_len(unsafe.Pointer(C.govpp_stat_segment_data_get_name_vector(&v)))) - var vector []adapter.Name - for k := 0; k < length; k++ { - s := C.govpp_stat_segment_data_get_name_vector_index(&v, C.int(k)) - var name adapter.Name - if s != nil { - name = adapter.Name(C.GoString(s)) - } - vector = append(vector, name) - } - stat.Data = adapter.NameStat(vector) - - default: - fmt.Fprintf(os.Stderr, "invalid stat type: %v (%v)\n", typ, name) - continue - - } - - stats = append(stats, stat) - } - - return stats, nil -} - -func (c *statClient) PrepareDir(prefixes ...string) (*adapter.StatDir, error) { - return nil, adapter.ErrNotImplemented -} - -func (c *statClient) UpdateDir(dir *adapter.StatDir) error { - return adapter.ErrNotImplemented -} - -func convertStringSlice(strs []string) **C.uint8_t { - var arr **C.uint8_t - for _, str := range strs { - arr = C.govpp_stat_segment_string_vector(arr, C.CString(str)) - } - return arr -} diff --git a/adapter/vppapiclient/stat_client_stub.go b/adapter/vppapiclient/stat_client_stub.go deleted file mode 100644 index 632f0fd5..00000000 --- a/adapter/vppapiclient/stat_client_stub.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2018 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. - -//go:build windows || darwin || novpp -// +build windows darwin novpp - -package vppapiclient - -import ( - "github.com/alkiranet/govpp/adapter" -) - -// stubStatClient is just an stub adapter that does nothing. It builds only on Windows and OSX, where the real -// VPP stats API client adapter does not build. Its sole purpose is to make the compiler happy on Windows and OSX. -type stubStatClient struct{} - -func NewStatClient(socketName string) adapter.StatsAPI { - return new(stubStatClient) -} - -func (*stubStatClient) Connect() error { - return adapter.ErrNotImplemented -} - -func (*stubStatClient) Disconnect() error { - return nil -} - -func (*stubStatClient) ListStats(patterns ...string) (statNames []string, err error) { - return nil, adapter.ErrNotImplemented -} - -func (*stubStatClient) DumpStats(patterns ...string) ([]adapter.StatEntry, error) { - return nil, adapter.ErrNotImplemented -} - -func (*stubStatClient) PrepareDir(prefixes ...string) (*adapter.StatDir, error) { - return nil, adapter.ErrNotImplemented -} - -func (*stubStatClient) UpdateDir(dir *adapter.StatDir) error { - return adapter.ErrNotImplemented -} diff --git a/adapter/vppapiclient/stat_client_wrapper.h b/adapter/vppapiclient/stat_client_wrapper.h deleted file mode 100644 index 3fe0460e..00000000 --- a/adapter/vppapiclient/stat_client_wrapper.h +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright (c) 2018 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. - -#ifndef included_stat_client_wrapper_h -#define included_stat_client_wrapper_h - -#include -#include -#include -#include - -#include // VPP has to be installed! - -// The stat_client.h defines its version using two macros: -// STAT_VERSION_MAJOR - for major version -// STAT_VERSION_MINOR - for minor version -// both were introduced in VPP 19.04 (not on release, later on stable/1904) -// https://github.com/FDio/vpp/commit/1cb333cdf5ce26557233c5bdb5a18738cb6e1e2c - -// Name vector directory type was introduced in VPP 19.04 -#if STAT_VERSION_MAJOR >= 1 && STAT_VERSION_MINOR >= 1 - #define SUPPORTS_NAME_VECTOR // VPP 19.04 is required! -#endif -// Error value was changed into vector in VPP 19.08 -#if STAT_VERSION_MAJOR >= 1 && STAT_VERSION_MINOR >= 2 - #define SUPPORTS_ERROR_VECTOR // VPP 19.08 is required! -#endif - -static int -govpp_stat_connect(char *socket_name) -{ - return stat_segment_connect(socket_name); -} - -static void -govpp_stat_disconnect() -{ - stat_segment_disconnect(); -} - -static uint32_t* -govpp_stat_segment_ls(uint8_t **pattern) -{ - return stat_segment_ls(pattern); -} - -static int -govpp_stat_segment_vec_len(void *vec) -{ - return stat_segment_vec_len(vec); -} - -static void -govpp_stat_segment_vec_free(void *vec) -{ - stat_segment_vec_free(vec); -} - -static char* -govpp_stat_segment_dir_index_to_name(uint32_t *dir, uint32_t index) -{ - return stat_segment_index_to_name(dir[index]); -} - -static stat_segment_data_t* -govpp_stat_segment_dump(uint32_t *counter_vec) -{ - return stat_segment_dump(counter_vec); -} - -static stat_segment_data_t -govpp_stat_segment_dump_index(stat_segment_data_t *data, int index) -{ - return data[index]; -} - -static int -govpp_stat_segment_data_type(stat_segment_data_t *data) -{ - return data->type; -} - -static double -govpp_stat_segment_data_get_scalar_value(stat_segment_data_t *data) -{ - return data->scalar_value; -} - -static counter_t -govpp_stat_segment_data_get_error_value(stat_segment_data_t *data) -{ -#ifdef SUPPORTS_ERROR_VECTOR - counter_t value = 0; - int j; - for (j = 0; j < stat_segment_vec_len(data->error_vector); j++) // VPP 19.08+ is required! - value += data->error_vector[j]; - return value; -#else - return data->error_value; // VPP <19.08 -#endif -} - -static uint64_t** -govpp_stat_segment_data_get_simple_counter(stat_segment_data_t *data) -{ - return data->simple_counter_vec; -} - -static uint64_t* -govpp_stat_segment_data_get_simple_counter_index(stat_segment_data_t *data, int index) -{ - return data->simple_counter_vec[index]; -} - -static uint64_t -govpp_stat_segment_data_get_simple_counter_index_value(stat_segment_data_t *data, int index, int index2) -{ - return data->simple_counter_vec[index][index2]; -} - -static vlib_counter_t** -govpp_stat_segment_data_get_combined_counter(stat_segment_data_t *data) -{ - return data->combined_counter_vec; -} - -static vlib_counter_t* -govpp_stat_segment_data_get_combined_counter_index(stat_segment_data_t *data, int index) -{ - return data->combined_counter_vec[index]; -} - -static uint64_t -govpp_stat_segment_data_get_combined_counter_index_packets(stat_segment_data_t *data, int index, int index2) -{ - return data->combined_counter_vec[index][index2].packets; -} - -static uint64_t -govpp_stat_segment_data_get_combined_counter_index_bytes(stat_segment_data_t *data, int index, int index2) -{ - return data->combined_counter_vec[index][index2].bytes; -} - -static uint8_t** -govpp_stat_segment_data_get_name_vector(stat_segment_data_t *data) -{ -#ifdef SUPPORTS_NAME_VECTOR - return data->name_vector; // VPP 19.04 is required! -#else - return 0; -#endif -} - -static char* -govpp_stat_segment_data_get_name_vector_index(stat_segment_data_t *data, int index) -{ -#ifdef SUPPORTS_NAME_VECTOR - return data->name_vector[index]; // VPP 19.04 is required! -#else - return 0; -#endif -} - -static void -govpp_stat_segment_data_free(stat_segment_data_t *data) -{ - stat_segment_data_free(data); -} - -static uint8_t** -govpp_stat_segment_string_vector(uint8_t **string_vec, char *s) -{ - return stat_segment_string_vector(string_vec, s); -} - -#endif /* included_stat_client_wrapper_h */ diff --git a/adapter/vppapiclient/vppapiclient.go b/adapter/vppapiclient/vppapiclient.go deleted file mode 100644 index 52b64ec9..00000000 --- a/adapter/vppapiclient/vppapiclient.go +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright (c) 2017 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. - -//go:build !windows && !darwin && !novpp -// +build !windows,!darwin,!novpp - -package vppapiclient - -/* -#cgo CFLAGS: -DPNG_DEBUG=1 -#cgo LDFLAGS: -lvppapiclient - -#include "vppapiclient_wrapper.h" -*/ -import "C" - -import ( - "fmt" - "os" - "path/filepath" - "reflect" - "time" - "unsafe" - - "github.com/fsnotify/fsnotify" - - "github.com/alkiranet/govpp/adapter" -) - -var ( - // MaxWaitReady defines maximum duration before waiting for shared memory - // segment times out - MaxWaitReady = time.Second * 10 -) - -const ( - // shmDir is a directory where shared memory is supposed to be created. - shmDir = "/dev/shm/" - // vppShmFile is a default name of the file in the shmDir. - vppShmFile = "vpe-api" -) - -// global VPP binary API client, library vppapiclient only supports -// single connection at a time -var globalVppClient *vppClient - -// stubVppClient is the default implementation of the VppAPI. -type vppClient struct { - shmPrefix string - msgCallback adapter.MsgCallback - inputQueueSize uint16 -} - -// NewVppClient returns a new VPP binary API client. -func NewVppClient(shmPrefix string) adapter.VppAPI { - return NewVppClientWithInputQueueSize(shmPrefix, 32) -} - -// NewVppClientWithInputQueueSize returns a new VPP binary API client with a custom input queue size. -func NewVppClientWithInputQueueSize(shmPrefix string, inputQueueSize uint16) adapter.VppAPI { - return &vppClient{ - shmPrefix: shmPrefix, - inputQueueSize: inputQueueSize, - } -} - -// Connect connects the process to VPP. -func (a *vppClient) Connect() error { - if globalVppClient != nil { - return fmt.Errorf("already connected to binary API, disconnect first") - } - - rxQlen := C.int(a.inputQueueSize) - var rc C.int - if a.shmPrefix == "" { - rc = C.govpp_connect(nil, rxQlen) - } else { - shm := C.CString(a.shmPrefix) - rc = C.govpp_connect(shm, rxQlen) - } - if rc != 0 { - return fmt.Errorf("connecting to VPP binary API failed (rc=%v)", rc) - } - - globalVppClient = a - return nil -} - -// Disconnect disconnects the process from VPP. -func (a *vppClient) Disconnect() error { - globalVppClient = nil - - rc := C.govpp_disconnect() - if rc != 0 { - return fmt.Errorf("disconnecting from VPP binary API failed (rc=%v)", rc) - } - - return nil -} - -// GetMsgID returns a runtime message ID for the given message name and CRC. -func (a *vppClient) GetMsgID(msgName string, msgCrc string) (uint16, error) { - nameAndCrc := C.CString(msgName + "_" + msgCrc) - defer C.free(unsafe.Pointer(nameAndCrc)) - - msgID := uint16(C.govpp_get_msg_index(nameAndCrc)) - if msgID == ^uint16(0) { - // VPP does not know this message - return msgID, &adapter.UnknownMsgError{msgName, msgCrc} - } - - return msgID, nil -} - -// SendMsg sends a binary-encoded message to VPP. -func (a *vppClient) SendMsg(context uint32, data []byte) error { - rc := C.govpp_send(C.uint32_t(context), unsafe.Pointer(&data[0]), C.size_t(len(data))) - if rc != 0 { - return fmt.Errorf("unable to send the message (rc=%v)", rc) - } - return nil -} - -// SetMsgCallback sets a callback function that will be called by the adapter -// whenever a message comes from VPP. -func (a *vppClient) SetMsgCallback(cb adapter.MsgCallback) { - a.msgCallback = cb -} - -// WaitReady blocks until shared memory for sending -// binary api calls is present on the file system. -func (a *vppClient) WaitReady() error { - // join the path to the shared memory segment - var path string - if a.shmPrefix == "" { - path = filepath.Join(shmDir, vppShmFile) - } else { - path = filepath.Join(shmDir, a.shmPrefix+"-"+vppShmFile) - } - - // check if file already exists - if _, err := os.Stat(path); err == nil { - return nil // file exists, we are ready - } else if !os.IsNotExist(err) { - return err // some other error occurred - } - - // file does not exist, start watching folder - watcher, err := fsnotify.NewWatcher() - if err != nil { - return err - } - defer watcher.Close() - - // start watching directory - if err := watcher.Add(shmDir); err != nil { - return err - } - - timeout := time.NewTimer(MaxWaitReady) - for { - select { - case <-timeout.C: - return fmt.Errorf("timeout waiting (%s) for shm file: %s", MaxWaitReady, path) - - case e := <-watcher.Errors: - return e - - case ev := <-watcher.Events: - if ev.Name == path && (ev.Op&fsnotify.Create) == fsnotify.Create { - // file created, we are ready - return nil - } - } - } -} - -//export go_msg_callback -func go_msg_callback(msgID C.uint16_t, data unsafe.Pointer, size C.size_t) { - // convert unsafe.Pointer to byte slice - sliceHeader := &reflect.SliceHeader{Data: uintptr(data), Len: int(size), Cap: int(size)} - byteSlice := *(*[]byte)(unsafe.Pointer(sliceHeader)) - - globalVppClient.msgCallback(uint16(msgID), byteSlice) -} diff --git a/adapter/vppapiclient/vppapiclient_stub.go b/adapter/vppapiclient/vppapiclient_stub.go deleted file mode 100644 index a85d90e7..00000000 --- a/adapter/vppapiclient/vppapiclient_stub.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2017 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. - -//go:build windows || darwin || novpp -// +build windows darwin novpp - -package vppapiclient - -import ( - "github.com/alkiranet/govpp/adapter" -) - -// stubVppClient is just an stub adapter that does nothing. It builds only on Windows and OSX, where the real -// VPP binary API client adapter does not build. Its sole purpose is to make the compiler happy on Windows and OSX. -type stubVppClient struct{} - -func NewVppClient(string) adapter.VppAPI { - return &stubVppClient{} -} - -func NewVppClientWithInputQueueSize(string, uint16) adapter.VppAPI { - return &stubVppClient{} -} - -func (a *stubVppClient) Connect() error { - return adapter.ErrNotImplemented -} - -func (a *stubVppClient) Disconnect() error { - return nil -} - -func (a *stubVppClient) GetMsgID(msgName string, msgCrc string) (uint16, error) { - return 0, nil -} - -func (a *stubVppClient) SendMsg(clientID uint32, data []byte) error { - return nil -} - -func (a *stubVppClient) SetMsgCallback(cb adapter.MsgCallback) { - // no op -} - -func (a *stubVppClient) WaitReady() error { - return adapter.ErrNotImplemented -} diff --git a/adapter/vppapiclient/vppapiclient_wrapper.h b/adapter/vppapiclient/vppapiclient_wrapper.h deleted file mode 100644 index 691c7829..00000000 --- a/adapter/vppapiclient/vppapiclient_wrapper.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2018 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. - -#ifndef included_vppapiclient_wrapper_h -#define included_vppapiclient_wrapper_h - -#include -#include -#include -#include - -#include // VPP has to be installed! - -// function go_msg_callback is defined in vppapiclient.go -extern void go_msg_callback(uint16_t msg_id, void* data, size_t size); - -typedef struct __attribute__((__packed__)) _req_header { - uint16_t msg_id; - uint32_t client_index; - uint32_t context; -} req_header_t; - -typedef struct __attribute__((__packed__)) _reply_header { - uint16_t msg_id; -} reply_header_t; - -static void -govpp_msg_callback(unsigned char *data, int size) -{ - reply_header_t *header = ((reply_header_t *)data); - go_msg_callback(ntohs(header->msg_id), data, size); -} - -static int -govpp_send(uint32_t context, void *data, size_t size) -{ - req_header_t *header = ((req_header_t *)data); - header->context = htonl(context); - return vac_write(data, size); -} - -static int -govpp_connect(char *shm, int rx_qlen) -{ - return vac_connect("govpp", shm, govpp_msg_callback, rx_qlen); -} - -static int -govpp_disconnect() -{ - return vac_disconnect(); -} - -static uint32_t -govpp_get_msg_index(char *name_and_crc) -{ - return vac_get_msg_index(name_and_crc); -} - -#endif /* included_vppapiclient_wrapper_h */ diff --git a/api/api.go b/api/api.go new file mode 100644 index 00000000..08a72130 --- /dev/null +++ b/api/api.go @@ -0,0 +1,144 @@ +// 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. +// 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 api + +import ( + "context" + "time" +) + +// Connection represents the client connection to VPP API. +// +// NOTE: This API is EXPERIMENTAL. +type Connection interface { + // NewStream creates a new stream for sending and receiving messages. + // Context can be used to close the stream using cancel or timeout. + NewStream(ctx context.Context, options ...StreamOption) (Stream, error) + + // Invoke can be used for a simple request-reply RPC. + // It creates stream and calls SendMsg with req and RecvMsg which returns + // reply. + Invoke(ctx context.Context, req Message, reply Message) error + + // WatchEvent creates a new watcher for watching events of type specified by + // event parameter. Context can be used to close the watcher. + WatchEvent(ctx context.Context, event Message) (Watcher, error) +} + +// Watcher provides access to watched event messages. It can be created by calling Connection.WatchEvent. +// +// NOTE: This API is EXPERIMENTAL. +type Watcher interface { + // Events returns a channel where events are sent. The channel is closed when + // watcher context is canceled or when Close is called. + Events() <-chan Message + + // Close closes the watcher along with the events channel. + Close() +} + +// Stream provides low-level access for sending and receiving messages. +// Users should handle correct type and ordering of messages. +// +// It is not safe to call these methods on the same stream in different +// goroutines. +// +// NOTE: This API is EXPERIMENTAL. +type Stream interface { + // Context returns the context for this stream. + Context() context.Context + + // SendMsg sends a message to the client. + // It blocks until message is sent to the transport. + SendMsg(Message) error + + // RecvMsg blocks until a message is received or error occurs. + RecvMsg() (Message, error) + + // Close closes the stream. Calling SendMsg and RecvMsg will return error + // after closing stream. + Close() error +} + +// StreamOption allows customizing a Stream. +type StreamOption func(Stream) + +// ChannelProvider provides the communication channel with govpp core. +type ChannelProvider interface { + // NewAPIChannel returns a new channel for communication with VPP via govpp core. + // It uses default buffer sizes for the request and reply Go channels. + NewAPIChannel() (Channel, error) + + // NewAPIChannelBuffered returns a new channel for communication with VPP via govpp core. + // It allows to specify custom buffer sizes for the request and reply Go channels. + NewAPIChannelBuffered(reqChanBufSize, replyChanBufSize int) (Channel, error) +} + +// Channel provides methods for direct communication with VPP channel. +type Channel interface { + // SendRequest asynchronously sends a request to VPP. Returns a request context, that can be used to call ReceiveReply. + // In case of any errors by sending, the error will be delivered to ReplyChan (and returned by ReceiveReply). + SendRequest(msg Message) RequestCtx + + // SendMultiRequest asynchronously sends a multipart request (request to which multiple responses are expected) to VPP. + // Returns a multipart request context, that can be used to call ReceiveReply. + // In case of any errors by sending, the error will be delivered to ReplyChan (and returned by ReceiveReply). + SendMultiRequest(msg Message) MultiRequestCtx + + // SubscribeNotification subscribes for receiving of the specified notification messages via provided Go channel. + // Note that the caller is responsible for creating the Go channel with preferred buffer size. If the channel's + // buffer is full, the notifications will not be delivered into it. + SubscribeNotification(notifChan chan Message, event Message) (SubscriptionCtx, error) + + // SetReplyTimeout sets the timeout for replies from VPP. It represents the maximum time the client waits for a reply + // from VPP before returning a timeout error. Setting the reply timeout to 0 disables it. The initial reply timeout is + //set to the value of core.DefaultReplyTimeout. + SetReplyTimeout(timeout time.Duration) + + // CheckCompatibility checks the compatiblity for the given messages. + // It will return an error if any of the given messages are not compatible. + CheckCompatiblity(msgs ...Message) error + + // Close closes the API channel and releases all API channel-related resources + // in the ChannelProvider. + Close() +} + +// RequestCtx is helper interface which allows to receive reply on request. +type RequestCtx interface { + // ReceiveReply receives a reply from VPP (blocks until a reply is delivered + // from VPP, or until an error occurs). The reply will be decoded into the msg + // argument. Error will be returned if the response cannot be received or decoded. + ReceiveReply(msg Message) error +} + +// MultiRequestCtx is helper interface which allows to receive reply on multi-request. +type MultiRequestCtx interface { + // ReceiveReply receives a reply from VPP (blocks until a reply is delivered + // from VPP, or until an error occurs).The reply will be decoded into the msg + // argument. If the last reply has been already consumed, lastReplyReceived is + // set to true. Do not use the message itself if lastReplyReceived is + // true - it won't be filled with actual data.Error will be returned if the + // response cannot be received or decoded. + ReceiveReply(msg Message) (lastReplyReceived bool, err error) +} + +// SubscriptionCtx is helper interface which allows to control subscription for +// notification events. +type SubscriptionCtx interface { + // Unsubscribe unsubscribes from receiving the notifications tied to the + // subscription context. + Unsubscribe() error +} diff --git a/api/binapi.go b/api/binapi.go index d9336128..1b07a7e0 100644 --- a/api/binapi.go +++ b/api/binapi.go @@ -15,16 +15,18 @@ package api import ( - "fmt" + "path" "reflect" - "time" ) -// MessageType represents the type of a VPP message. -// Note: this is currently derived from the message header (fields), -// and in many cases it does not represent the actual type of VPP message. -// This means that some replies can be identified as requests, etc. -// TODO: use services to identify type of message +// GoVppAPIPackageIsVersionX is referenced from generated binapi files +// to assert that that code is compatible with this version of the GoVPP api package. +const ( + GoVppAPIPackageIsVersion1 = true + GoVppAPIPackageIsVersion2 = true +) + +// MessageType represents the type of a VPP message derived from message header fields. type MessageType int const ( @@ -56,105 +58,28 @@ type DataType interface { GetTypeName() string } -// ChannelProvider provides the communication channel with govpp core. -type ChannelProvider interface { - // NewAPIChannel returns a new channel for communication with VPP via govpp core. - // It uses default buffer sizes for the request and reply Go channels. - NewAPIChannel() (Channel, error) - - // NewAPIChannelBuffered returns a new channel for communication with VPP via govpp core. - // It allows to specify custom buffer sizes for the request and reply Go channels. - NewAPIChannelBuffered(reqChanBufSize, replyChanBufSize int) (Channel, error) -} - -// Channel provides methods for direct communication with VPP channel. -type Channel interface { - // SendRequest asynchronously sends a request to VPP. Returns a request context, that can be used to call ReceiveReply. - // In case of any errors by sending, the error will be delivered to ReplyChan (and returned by ReceiveReply). - SendRequest(msg Message) RequestCtx - - // SendMultiRequest asynchronously sends a multipart request (request to which multiple responses are expected) to VPP. - // Returns a multipart request context, that can be used to call ReceiveReply. - // In case of any errors by sending, the error will be delivered to ReplyChan (and returned by ReceiveReply). - SendMultiRequest(msg Message) MultiRequestCtx - - // SubscribeNotification subscribes for receiving of the specified notification messages via provided Go channel. - // Note that the caller is responsible for creating the Go channel with preferred buffer size. If the channel's - // buffer is full, the notifications will not be delivered into it. - SubscribeNotification(notifChan chan Message, event Message) (SubscriptionCtx, error) - - // SetReplyTimeout sets the timeout for replies from VPP. It represents the maximum time the API waits for a reply - // from VPP before returning an error. - SetReplyTimeout(timeout time.Duration) - - // CheckCompatibility checks the compatiblity for the given messages. - // It will return an error if any of the given messages are not compatible. - CheckCompatiblity(msgs ...Message) error - - // Close closes the API channel and releases all API channel-related resources in the ChannelProvider. - Close() -} - -// RequestCtx is helper interface which allows to receive reply on request. -type RequestCtx interface { - // ReceiveReply receives a reply from VPP (blocks until a reply is delivered from VPP, or until an error occurs). - // The reply will be decoded into the msg argument. Error will be returned if the response cannot be received or decoded. - ReceiveReply(msg Message) error -} - -// MultiRequestCtx is helper interface which allows to receive reply on multi-request. -type MultiRequestCtx interface { - // ReceiveReply receives a reply from VPP (blocks until a reply is delivered from VPP, or until an error occurs). - // The reply will be decoded into the msg argument. If the last reply has been already consumed, lastReplyReceived is - // set to true. Do not use the message itself if lastReplyReceived is true - it won't be filled with actual data. - // Error will be returned if the response cannot be received or decoded. - ReceiveReply(msg Message) (lastReplyReceived bool, err error) -} - -// SubscriptionCtx is helper interface which allows to control subscription for notification events. -type SubscriptionCtx interface { - // Unsubscribe unsubscribes from receiving the notifications tied to the subscription context. - Unsubscribe() error -} - -// CompatibilityError is the error type usually returned by CheckCompatibility -// method of Channel. It describes all of the incompatible messages. -type CompatibilityError struct { - // IncompatibleMessages is the list of all messages - // that failed compatibility check. - IncompatibleMessages []string -} - -func (c *CompatibilityError) Error() string { - return fmt.Sprintf("%d incompatible messages: %v", len(c.IncompatibleMessages), c.IncompatibleMessages) -} - var ( - registeredMessageTypes = make(map[reflect.Type]string) - registeredMessages = make(map[string]Message) + registeredMessages = make(map[string]map[string]Message) + registeredMessageTypes = make(map[string]map[reflect.Type]string) ) // RegisterMessage is called from generated code to register message. func RegisterMessage(x Message, name string) { - typ := reflect.TypeOf(x) - namecrc := x.GetMessageName() + "_" + x.GetCrcString() - if _, ok := registeredMessageTypes[typ]; ok { - panic(fmt.Errorf("govpp: message type %v already registered as %s (%s)", typ, name, namecrc)) + binapiPath := path.Dir(reflect.TypeOf(x).Elem().PkgPath()) + if _, ok := registeredMessages[binapiPath]; !ok { + registeredMessages[binapiPath] = make(map[string]Message) + registeredMessageTypes[binapiPath] = make(map[reflect.Type]string) } - registeredMessages[namecrc] = x - registeredMessageTypes[typ] = name + registeredMessages[binapiPath][x.GetMessageName()+"_"+x.GetCrcString()] = x + registeredMessageTypes[binapiPath][reflect.TypeOf(x)] = name } // GetRegisteredMessages returns list of all registered messages. -func GetRegisteredMessages() map[string]Message { +func GetRegisteredMessages() map[string]map[string]Message { return registeredMessages } // GetRegisteredMessageTypes returns list of all registered message types. -func GetRegisteredMessageTypes() map[reflect.Type]string { +func GetRegisteredMessageTypes() map[string]map[reflect.Type]string { return registeredMessageTypes } - -// GoVppAPIPackageIsVersion1 is referenced from generated binapi files -// to assert that that code is compatible with this version of the GoVPP api package. -const GoVppAPIPackageIsVersion1 = true diff --git a/api/errors.go b/api/errors.go new file mode 100644 index 00000000..1c6e3c2f --- /dev/null +++ b/api/errors.go @@ -0,0 +1,331 @@ +package api + +import ( + "fmt" + "strconv" +) + +// CompatibilityError is the error type usually returned by CheckCompatibility +// method of Channel. It contains list of all the compatible/incompatible messages. +type CompatibilityError struct { + CompatibleMessages []string + IncompatibleMessages []string +} + +func (c *CompatibilityError) Error() string { + return fmt.Sprintf("%d/%d messages incompatible", len(c.IncompatibleMessages), len(c.CompatibleMessages)+len(c.IncompatibleMessages)) +} + +// RetvalToVPPApiError returns error for retval value. +// Retval 0 returns nil error. +func RetvalToVPPApiError(retval int32) error { + if retval == 0 { + return nil + } + return VPPApiError(retval) +} + +// VPPApiError represents VPP's vnet API error that is usually +// returned as Retval field in replies from VPP binary API. +type VPPApiError int32 + +func (e VPPApiError) Error() string { + errid := int64(e) + var errstr string + if s, ok := vppApiErrors[e]; ok { + errstr = fmt.Sprintf("%s (%d)", s, errid) + } else { + errstr = strconv.FormatInt(errid, 10) + } + return fmt.Sprintf("VPPApiError: %s", errstr) +} + +// definitions from: vpp/src/vnet/api_errno.h +const ( + _ VPPApiError = 0 + UNSPECIFIED VPPApiError = -1 + INVALID_SW_IF_INDEX VPPApiError = -2 + NO_SUCH_FIB VPPApiError = -3 + NO_SUCH_INNER_FIB VPPApiError = -4 + NO_SUCH_LABEL VPPApiError = -5 + NO_SUCH_ENTRY VPPApiError = -6 + INVALID_VALUE VPPApiError = -7 + INVALID_VALUE_2 VPPApiError = -8 + UNIMPLEMENTED VPPApiError = -9 + INVALID_SW_IF_INDEX_2 VPPApiError = -10 + SYSCALL_ERROR_1 VPPApiError = -11 + SYSCALL_ERROR_2 VPPApiError = -12 + SYSCALL_ERROR_3 VPPApiError = -13 + SYSCALL_ERROR_4 VPPApiError = -14 + SYSCALL_ERROR_5 VPPApiError = -15 + SYSCALL_ERROR_6 VPPApiError = -16 + SYSCALL_ERROR_7 VPPApiError = -17 + SYSCALL_ERROR_8 VPPApiError = -18 + SYSCALL_ERROR_9 VPPApiError = -19 + SYSCALL_ERROR_10 VPPApiError = -20 + FEATURE_DISABLED VPPApiError = -30 + INVALID_REGISTRATION VPPApiError = -31 + NEXT_HOP_NOT_IN_FIB VPPApiError = -50 + UNKNOWN_DESTINATION VPPApiError = -51 + PREFIX_MATCHES_NEXT_HOP VPPApiError = -52 + NEXT_HOP_NOT_FOUND_MP VPPApiError = -53 + NO_MATCHING_INTERFACE VPPApiError = -54 + INVALID_VLAN VPPApiError = -55 + VLAN_ALREADY_EXISTS VPPApiError = -56 + INVALID_SRC_ADDRESS VPPApiError = -57 + INVALID_DST_ADDRESS VPPApiError = -58 + ADDRESS_LENGTH_MISMATCH VPPApiError = -59 + ADDRESS_NOT_FOUND_FOR_INTERFACE VPPApiError = -60 + ADDRESS_NOT_DELETABLE VPPApiError = -61 + IP6_NOT_ENABLED VPPApiError = -62 + IN_PROGRESS VPPApiError = 10 + NO_SUCH_NODE VPPApiError = -63 + NO_SUCH_NODE2 VPPApiError = -64 + NO_SUCH_TABLE VPPApiError = -65 + NO_SUCH_TABLE2 VPPApiError = -66 + NO_SUCH_TABLE3 VPPApiError = -67 + SUBIF_ALREADY_EXISTS VPPApiError = -68 + SUBIF_CREATE_FAILED VPPApiError = -69 + INVALID_MEMORY_SIZE VPPApiError = -70 + INVALID_INTERFACE VPPApiError = -71 + INVALID_VLAN_TAG_COUNT VPPApiError = -72 + INVALID_ARGUMENT VPPApiError = -73 + UNEXPECTED_INTF_STATE VPPApiError = -74 + TUNNEL_EXIST VPPApiError = -75 + INVALID_DECAP_NEXT VPPApiError = -76 + RESPONSE_NOT_READY VPPApiError = -77 + NOT_CONNECTED VPPApiError = -78 + IF_ALREADY_EXISTS VPPApiError = -79 + BOND_SLAVE_NOT_ALLOWED VPPApiError = -80 + VALUE_EXIST VPPApiError = -81 + SAME_SRC_DST VPPApiError = -82 + IP6_MULTICAST_ADDRESS_NOT_PRESENT VPPApiError = -83 + SR_POLICY_NAME_NOT_PRESENT VPPApiError = -84 + NOT_RUNNING_AS_ROOT VPPApiError = -85 + ALREADY_CONNECTED VPPApiError = -86 + UNSUPPORTED_JNI_VERSION VPPApiError = -87 + FAILED_TO_ATTACH_TO_JAVA_THREAD VPPApiError = -88 + INVALID_WORKER VPPApiError = -89 + LISP_DISABLED VPPApiError = -90 + CLASSIFY_TABLE_NOT_FOUND VPPApiError = -91 + INVALID_EID_TYPE VPPApiError = -92 + CANNOT_CREATE_PCAP_FILE VPPApiError = -93 + INCORRECT_ADJACENCY_TYPE VPPApiError = -94 + EXCEEDED_NUMBER_OF_RANGES_CAPACITY VPPApiError = -95 + EXCEEDED_NUMBER_OF_PORTS_CAPACITY VPPApiError = -96 + INVALID_ADDRESS_FAMILY VPPApiError = -97 + INVALID_SUB_SW_IF_INDEX VPPApiError = -98 + TABLE_TOO_BIG VPPApiError = -99 + CANNOT_ENABLE_DISABLE_FEATURE VPPApiError = -100 + BFD_EEXIST VPPApiError = -101 + BFD_ENOENT VPPApiError = -102 + BFD_EINUSE VPPApiError = -103 + BFD_NOTSUPP VPPApiError = -104 + ADDRESS_IN_USE VPPApiError = -105 + ADDRESS_NOT_IN_USE VPPApiError = -106 + QUEUE_FULL VPPApiError = -107 + APP_UNSUPPORTED_CFG VPPApiError = -108 + URI_FIFO_CREATE_FAILED VPPApiError = -109 + LISP_RLOC_LOCAL VPPApiError = -110 + BFD_EAGAIN VPPApiError = -111 + INVALID_GPE_MODE VPPApiError = -112 + LISP_GPE_ENTRIES_PRESENT VPPApiError = -113 + ADDRESS_FOUND_FOR_INTERFACE VPPApiError = -114 + SESSION_CONNECT VPPApiError = -115 + ENTRY_ALREADY_EXISTS VPPApiError = -116 + SVM_SEGMENT_CREATE_FAIL VPPApiError = -117 + APPLICATION_NOT_ATTACHED VPPApiError = -118 + BD_ALREADY_EXISTS VPPApiError = -119 + BD_IN_USE VPPApiError = -120 + BD_NOT_MODIFIABLE VPPApiError = -121 + BD_ID_EXCEED_MAX VPPApiError = -122 + SUBIF_DOESNT_EXIST VPPApiError = -123 + L2_MACS_EVENT_CLINET_PRESENT VPPApiError = -124 + INVALID_QUEUE VPPApiError = -125 + UNSUPPORTED VPPApiError = -126 + DUPLICATE_IF_ADDRESS VPPApiError = -127 + APP_INVALID_NS VPPApiError = -128 + APP_WRONG_NS_SECRET VPPApiError = -129 + APP_CONNECT_SCOPE VPPApiError = -130 + APP_ALREADY_ATTACHED VPPApiError = -131 + SESSION_REDIRECT VPPApiError = -132 + ILLEGAL_NAME VPPApiError = -133 + NO_NAME_SERVERS VPPApiError = -134 + NAME_SERVER_NOT_FOUND VPPApiError = -135 + NAME_RESOLUTION_NOT_ENABLED VPPApiError = -136 + NAME_SERVER_FORMAT_ERROR VPPApiError = -137 + NAME_SERVER_NO_SUCH_NAME VPPApiError = -138 + NAME_SERVER_NO_ADDRESSES VPPApiError = -139 + NAME_SERVER_NEXT_SERVER VPPApiError = -140 + APP_CONNECT_FILTERED VPPApiError = -141 + ACL_IN_USE_INBOUND VPPApiError = -142 + ACL_IN_USE_OUTBOUND VPPApiError = -143 + INIT_FAILED VPPApiError = -144 + NETLINK_ERROR VPPApiError = -145 + BIER_BSL_UNSUP VPPApiError = -146 + INSTANCE_IN_USE VPPApiError = -147 + INVALID_SESSION_ID VPPApiError = -148 + ACL_IN_USE_BY_LOOKUP_CONTEXT VPPApiError = -149 + INVALID_VALUE_3 VPPApiError = -150 + NON_ETHERNET VPPApiError = -151 + BD_ALREADY_HAS_BVI VPPApiError = -152 + INVALID_PROTOCOL VPPApiError = -153 + INVALID_ALGORITHM VPPApiError = -154 + RSRC_IN_USE VPPApiError = -155 + KEY_LENGTH VPPApiError = -156 + FIB_PATH_UNSUPPORTED_NH_PROTO VPPApiError = -157 + API_ENDIAN_FAILED VPPApiError = -159 + NO_CHANGE VPPApiError = -160 + MISSING_CERT_KEY VPPApiError = -161 + LIMIT_EXCEEDED VPPApiError = -162 + IKE_NO_PORT VPPApiError = -163 + UDP_PORT_TAKEN VPPApiError = -164 + EAGAIN VPPApiError = -165 + INVALID_VALUE_4 VPPApiError = -166 + BUSY VPPApiError = -167 + BUG VPPApiError = -168 +) + +var vppApiErrors = map[VPPApiError]string{ + UNSPECIFIED: "Unspecified Error", + INVALID_SW_IF_INDEX: "Invalid sw_if_index", + NO_SUCH_FIB: "No such FIB / VRF", + NO_SUCH_INNER_FIB: "No such inner FIB / VRF", + NO_SUCH_LABEL: "No such label", + NO_SUCH_ENTRY: "No such entry", + INVALID_VALUE: "Invalid value", + INVALID_VALUE_2: "Invalid value #2", + UNIMPLEMENTED: "Unimplemented", + INVALID_SW_IF_INDEX_2: "Invalid sw_if_index #2", + SYSCALL_ERROR_1: "System call error #1", + SYSCALL_ERROR_2: "System call error #2", + SYSCALL_ERROR_3: "System call error #3", + SYSCALL_ERROR_4: "System call error #4", + SYSCALL_ERROR_5: "System call error #5", + SYSCALL_ERROR_6: "System call error #6", + SYSCALL_ERROR_7: "System call error #7", + SYSCALL_ERROR_8: "System call error #8", + SYSCALL_ERROR_9: "System call error #9", + SYSCALL_ERROR_10: "System call error #10", + FEATURE_DISABLED: "Feature disabled by configuration", + INVALID_REGISTRATION: "Invalid registration", + NEXT_HOP_NOT_IN_FIB: "Next hop not in FIB", + UNKNOWN_DESTINATION: "Unknown destination", + PREFIX_MATCHES_NEXT_HOP: "Prefix matches next hop", + NEXT_HOP_NOT_FOUND_MP: "Next hop not found (multipath)", + NO_MATCHING_INTERFACE: "No matching interface for probe", + INVALID_VLAN: "Invalid VLAN", + VLAN_ALREADY_EXISTS: "VLAN subif already exists", + INVALID_SRC_ADDRESS: "Invalid src address", + INVALID_DST_ADDRESS: "Invalid dst address", + ADDRESS_LENGTH_MISMATCH: "Address length mismatch", + ADDRESS_NOT_FOUND_FOR_INTERFACE: "Address not found for interface", + ADDRESS_NOT_DELETABLE: "Address not deletable", + IP6_NOT_ENABLED: "ip6 not enabled", + IN_PROGRESS: "Operation in progress", + NO_SUCH_NODE: "No such graph node", + NO_SUCH_NODE2: "No such graph node #2", + NO_SUCH_TABLE: "No such table", + NO_SUCH_TABLE2: "No such table #2", + NO_SUCH_TABLE3: "No such table #3", + SUBIF_ALREADY_EXISTS: "Subinterface already exists", + SUBIF_CREATE_FAILED: "Subinterface creation failed", + INVALID_MEMORY_SIZE: "Invalid memory size requested", + INVALID_INTERFACE: "Invalid interface", + INVALID_VLAN_TAG_COUNT: "Invalid number of tags for requested operation", + INVALID_ARGUMENT: "Invalid argument", + UNEXPECTED_INTF_STATE: "Unexpected interface state", + TUNNEL_EXIST: "Tunnel already exists", + INVALID_DECAP_NEXT: "Invalid decap-next", + RESPONSE_NOT_READY: "Response not ready", + NOT_CONNECTED: "Not connected to the data plane", + IF_ALREADY_EXISTS: "Interface already exists", + BOND_SLAVE_NOT_ALLOWED: "Operation not allowed on slave of BondEthernet", + VALUE_EXIST: "Value already exists", + SAME_SRC_DST: "Source and destination are the same", + IP6_MULTICAST_ADDRESS_NOT_PRESENT: "IP6 multicast address required", + SR_POLICY_NAME_NOT_PRESENT: "Segement routing policy name required", + NOT_RUNNING_AS_ROOT: "Not running as root", + ALREADY_CONNECTED: "Connection to the data plane already exists", + UNSUPPORTED_JNI_VERSION: "Unsupported JNI version", + FAILED_TO_ATTACH_TO_JAVA_THREAD: "Failed to attach to Java thread", + INVALID_WORKER: "Invalid worker thread", + LISP_DISABLED: "LISP is disabled", + CLASSIFY_TABLE_NOT_FOUND: "Classify table not found", + INVALID_EID_TYPE: "Unsupported LSIP EID type", + CANNOT_CREATE_PCAP_FILE: "Cannot create pcap file", + INCORRECT_ADJACENCY_TYPE: "Invalid adjacency type for this operation", + EXCEEDED_NUMBER_OF_RANGES_CAPACITY: "Operation would exceed configured capacity of ranges", + EXCEEDED_NUMBER_OF_PORTS_CAPACITY: "Operation would exceed capacity of number of ports", + INVALID_ADDRESS_FAMILY: "Invalid address family", + INVALID_SUB_SW_IF_INDEX: "Invalid sub-interface sw_if_index", + TABLE_TOO_BIG: "Table too big", + CANNOT_ENABLE_DISABLE_FEATURE: "Cannot enable/disable feature", + BFD_EEXIST: "Duplicate BFD object", + BFD_ENOENT: "No such BFD object", + BFD_EINUSE: "BFD object in use", + BFD_NOTSUPP: "BFD feature not supported", + ADDRESS_IN_USE: "Address in use", + ADDRESS_NOT_IN_USE: "Address not in use", + QUEUE_FULL: "Queue full", + APP_UNSUPPORTED_CFG: "Unsupported application config", + URI_FIFO_CREATE_FAILED: "URI FIFO segment create failed", + LISP_RLOC_LOCAL: "RLOC address is local", + BFD_EAGAIN: "BFD object cannot be manipulated at this time", + INVALID_GPE_MODE: "Invalid GPE mode", + LISP_GPE_ENTRIES_PRESENT: "LISP GPE entries are present", + ADDRESS_FOUND_FOR_INTERFACE: "Address found for interface", + SESSION_CONNECT: "Session failed to connect", + ENTRY_ALREADY_EXISTS: "Entry already exists", + SVM_SEGMENT_CREATE_FAIL: "svm segment create fail", + APPLICATION_NOT_ATTACHED: "application not attached", + BD_ALREADY_EXISTS: "Bridge domain already exists", + BD_IN_USE: "Bridge domain has member interfaces", + BD_NOT_MODIFIABLE: "Bridge domain 0 can't be deleted/modified", + BD_ID_EXCEED_MAX: "Bridge domain ID exceed 16M limit", + SUBIF_DOESNT_EXIST: "Subinterface doesn't exist", + L2_MACS_EVENT_CLINET_PRESENT: "Client already exist for L2 MACs events", + INVALID_QUEUE: "Invalid queue", + UNSUPPORTED: "Unsupported", + DUPLICATE_IF_ADDRESS: "Address already present on another interface", + APP_INVALID_NS: "Invalid application namespace", + APP_WRONG_NS_SECRET: "Wrong app namespace secret", + APP_CONNECT_SCOPE: "Connect scope", + APP_ALREADY_ATTACHED: "App already attached", + SESSION_REDIRECT: "Redirect failed", + ILLEGAL_NAME: "Illegal name", + NO_NAME_SERVERS: "No name servers configured", + NAME_SERVER_NOT_FOUND: "Name server not found", + NAME_RESOLUTION_NOT_ENABLED: "Name resolution not enabled", + NAME_SERVER_FORMAT_ERROR: "Server format error (bug!)", + NAME_SERVER_NO_SUCH_NAME: "No such name", + NAME_SERVER_NO_ADDRESSES: "No addresses available", + NAME_SERVER_NEXT_SERVER: "Retry with new server", + APP_CONNECT_FILTERED: "Connect was filtered", + ACL_IN_USE_INBOUND: "Inbound ACL in use", + ACL_IN_USE_OUTBOUND: "Outbound ACL in use", + INIT_FAILED: "Initialization Failed", + NETLINK_ERROR: "netlink error", + BIER_BSL_UNSUP: "BIER bit-string-length unsupported", + INSTANCE_IN_USE: "Instance in use", + INVALID_SESSION_ID: "session ID out of range", + ACL_IN_USE_BY_LOOKUP_CONTEXT: "ACL in use by a lookup context", + INVALID_VALUE_3: "Invalid value #3", + NON_ETHERNET: "Interface is not an Ethernet interface", + BD_ALREADY_HAS_BVI: "Bridge domain already has a BVI interface", + INVALID_PROTOCOL: "Invalid Protocol", + INVALID_ALGORITHM: "Invalid Algorithm", + RSRC_IN_USE: "Resource In Use", + KEY_LENGTH: "invalid Key Length", + FIB_PATH_UNSUPPORTED_NH_PROTO: "Unsupported FIB Path protocol", + API_ENDIAN_FAILED: "Endian mismatch detected", + NO_CHANGE: "No change in table", + MISSING_CERT_KEY: "Missing certifcate or key", + LIMIT_EXCEEDED: "limit exceeded", + IKE_NO_PORT: "port not managed by IKE", + UDP_PORT_TAKEN: "UDP port already taken", + EAGAIN: "Retry stream call with cursor", + INVALID_VALUE_4: "Invalid value #4", + BUSY: "Busy", + BUG: "Bug", +} diff --git a/api/vppapi_errors_test.go b/api/errors_test.go similarity index 100% rename from api/vppapi_errors_test.go rename to api/errors_test.go diff --git a/api/stats.go b/api/stats.go index 2850b5fb..d5665b77 100644 --- a/api/stats.go +++ b/api/stats.go @@ -21,6 +21,7 @@ type StatsProvider interface { GetInterfaceStats(*InterfaceStats) error GetErrorStats(*ErrorStats) error GetBufferStats(*BufferStats) error + GetMemoryStats(*MemoryStats) error } // SystemStats represents global system statistics. @@ -97,7 +98,7 @@ type ErrorStats struct { type ErrorCounter struct { CounterName string - Value uint64 + Values []uint64 } // BufferStats represents statistics per buffer pool. @@ -113,3 +114,26 @@ type BufferPool struct { Used float64 Available float64 } + +// MemoryStats represents memory stats segment counters. +type MemoryStats struct { + // Deprecated: /mem/statseg total memory directory + Total float64 + // Deprecated: /mem/statseg used memory directory + Used float64 + + // stat/main memory usage per-heap + Stat map[int]MemoryCounters + Main map[int]MemoryCounters +} + +// MemoryCounters represents values of various memory usage +type MemoryCounters struct { + Total uint64 + Used uint64 + Free uint64 + UsedMMap uint64 + TotalAlloc uint64 + FreeChunks uint64 + Releasable uint64 +} diff --git a/api/trace.go b/api/trace.go new file mode 100644 index 00000000..4ff46e82 --- /dev/null +++ b/api/trace.go @@ -0,0 +1,46 @@ +// 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. +// 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 api + +import ( + "time" +) + +// Trace gives access to the API trace tool, capturing outcoming and incoming messages +// to and from GoVPP. +type Trace interface { + // Enable allows to enable or disable API trace for a connection. + Enable(enable bool) + + // GetRecords retrieves all messages collected (from all channels if they are used) + // since the point the trace was enabled or cleared. + GetRecords() []*Record + + // GetRecordsForChannel retrieves messages collected by the given channel since + // the point the trace was enabled or cleared. + GetRecordsForChannel(chId uint16) []*Record + + // Clear erases messages captured so far. + Clear() +} + +// Record contains essential information about traced message, its timestamp and whether +// the message was received or sent +type Record struct { + Message Message + Timestamp time.Time + IsReceived bool + ChannelID uint16 +} diff --git a/api/vppapi_errors.go b/api/vppapi_errors.go deleted file mode 100644 index c9ce3a38..00000000 --- a/api/vppapi_errors.go +++ /dev/null @@ -1,290 +0,0 @@ -package api - -import ( - "fmt" - "strconv" -) - -// RetvalToVPPApiError returns error for retval value. -// Retval 0 returns nil error. -func RetvalToVPPApiError(retval int32) error { - if retval == 0 { - return nil - } - return VPPApiError(retval) -} - -// VPPApiError represents VPP's vnet API error that is usually -// returned as Retval field in replies from VPP binary API. -type VPPApiError int32 - -func (e VPPApiError) Error() string { - errid := int64(e) - var errstr string - if s, ok := vppApiErrors[e]; ok { - errstr = fmt.Sprintf("%s (%d)", s, errid) - } else { - errstr = strconv.FormatInt(errid, 10) - } - return fmt.Sprintf("VPPApiError: %s", errstr) -} - -// definitions from: vpp/src/vnet/api_errno.h -const ( - _ VPPApiError = 0 - UNSPECIFIED = -1 - INVALID_SW_IF_INDEX = -2 - NO_SUCH_FIB = -3 - NO_SUCH_INNER_FIB = -4 - NO_SUCH_LABEL = -5 - NO_SUCH_ENTRY = -6 - INVALID_VALUE = -7 - INVALID_VALUE_2 = -8 - UNIMPLEMENTED = -9 - INVALID_SW_IF_INDEX_2 = -10 - SYSCALL_ERROR_1 = -11 - SYSCALL_ERROR_2 = -12 - SYSCALL_ERROR_3 = -13 - SYSCALL_ERROR_4 = -14 - SYSCALL_ERROR_5 = -15 - SYSCALL_ERROR_6 = -16 - SYSCALL_ERROR_7 = -17 - SYSCALL_ERROR_8 = -18 - SYSCALL_ERROR_9 = -19 - SYSCALL_ERROR_10 = -20 - FEATURE_DISABLED = -30 - INVALID_REGISTRATION = -31 - NEXT_HOP_NOT_IN_FIB = -50 - UNKNOWN_DESTINATION = -51 - PREFIX_MATCHES_NEXT_HOP = -52 - NEXT_HOP_NOT_FOUND_MP = -53 - NO_MATCHING_INTERFACE = -54 - INVALID_VLAN = -55 - VLAN_ALREADY_EXISTS = -56 - INVALID_SRC_ADDRESS = -57 - INVALID_DST_ADDRESS = -58 - ADDRESS_LENGTH_MISMATCH = -59 - ADDRESS_NOT_FOUND_FOR_INTERFACE = -60 - ADDRESS_NOT_DELETABLE = -61 - IP6_NOT_ENABLED = -62 - IN_PROGRESS = 10 - NO_SUCH_NODE = -63 - NO_SUCH_NODE2 = -64 - NO_SUCH_TABLE = -65 - NO_SUCH_TABLE2 = -66 - NO_SUCH_TABLE3 = -67 - SUBIF_ALREADY_EXISTS = -68 - SUBIF_CREATE_FAILED = -69 - INVALID_MEMORY_SIZE = -70 - INVALID_INTERFACE = -71 - INVALID_VLAN_TAG_COUNT = -72 - INVALID_ARGUMENT = -73 - UNEXPECTED_INTF_STATE = -74 - TUNNEL_EXIST = -75 - INVALID_DECAP_NEXT = -76 - RESPONSE_NOT_READY = -77 - NOT_CONNECTED = -78 - IF_ALREADY_EXISTS = -79 - BOND_SLAVE_NOT_ALLOWED = -80 - VALUE_EXIST = -81 - SAME_SRC_DST = -82 - IP6_MULTICAST_ADDRESS_NOT_PRESENT = -83 - SR_POLICY_NAME_NOT_PRESENT = -84 - NOT_RUNNING_AS_ROOT = -85 - ALREADY_CONNECTED = -86 - UNSUPPORTED_JNI_VERSION = -87 - FAILED_TO_ATTACH_TO_JAVA_THREAD = -88 - INVALID_WORKER = -89 - LISP_DISABLED = -90 - CLASSIFY_TABLE_NOT_FOUND = -91 - INVALID_EID_TYPE = -92 - CANNOT_CREATE_PCAP_FILE = -93 - INCORRECT_ADJACENCY_TYPE = -94 - EXCEEDED_NUMBER_OF_RANGES_CAPACITY = -95 - EXCEEDED_NUMBER_OF_PORTS_CAPACITY = -96 - INVALID_ADDRESS_FAMILY = -97 - INVALID_SUB_SW_IF_INDEX = -98 - TABLE_TOO_BIG = -99 - CANNOT_ENABLE_DISABLE_FEATURE = -100 - BFD_EEXIST = -101 - BFD_ENOENT = -102 - BFD_EINUSE = -103 - BFD_NOTSUPP = -104 - ADDRESS_IN_USE = -105 - ADDRESS_NOT_IN_USE = -106 - QUEUE_FULL = -107 - APP_UNSUPPORTED_CFG = -108 - URI_FIFO_CREATE_FAILED = -109 - LISP_RLOC_LOCAL = -110 - BFD_EAGAIN = -111 - INVALID_GPE_MODE = -112 - LISP_GPE_ENTRIES_PRESENT = -113 - ADDRESS_FOUND_FOR_INTERFACE = -114 - SESSION_CONNECT = -115 - ENTRY_ALREADY_EXISTS = -116 - SVM_SEGMENT_CREATE_FAIL = -117 - APPLICATION_NOT_ATTACHED = -118 - BD_ALREADY_EXISTS = -119 - BD_IN_USE = -120 - BD_NOT_MODIFIABLE = -121 - BD_ID_EXCEED_MAX = -122 - SUBIF_DOESNT_EXIST = -123 - L2_MACS_EVENT_CLINET_PRESENT = -124 - INVALID_QUEUE = -125 - UNSUPPORTED = -126 - DUPLICATE_IF_ADDRESS = -127 - APP_INVALID_NS = -128 - APP_WRONG_NS_SECRET = -129 - APP_CONNECT_SCOPE = -130 - APP_ALREADY_ATTACHED = -131 - SESSION_REDIRECT = -132 - ILLEGAL_NAME = -133 - NO_NAME_SERVERS = -134 - NAME_SERVER_NOT_FOUND = -135 - NAME_RESOLUTION_NOT_ENABLED = -136 - NAME_SERVER_FORMAT_ERROR = -137 - NAME_SERVER_NO_SUCH_NAME = -138 - NAME_SERVER_NO_ADDRESSES = -139 - NAME_SERVER_NEXT_SERVER = -140 - APP_CONNECT_FILTERED = -141 - ACL_IN_USE_INBOUND = -142 - ACL_IN_USE_OUTBOUND = -143 - INIT_FAILED = -144 - NETLINK_ERROR = -145 - BIER_BSL_UNSUP = -146 - INSTANCE_IN_USE = -147 - INVALID_SESSION_ID = -148 - ACL_IN_USE_BY_LOOKUP_CONTEXT = -149 - INVALID_VALUE_3 = -150 - NON_ETHERNET = -151 - BD_ALREADY_HAS_BVI = -152 -) - -var vppApiErrors = map[VPPApiError]string{ - UNSPECIFIED: "Unspecified Error", - INVALID_SW_IF_INDEX: "Invalid sw_if_index", - NO_SUCH_FIB: "No such FIB / VRF", - NO_SUCH_INNER_FIB: "No such inner FIB / VRF", - NO_SUCH_LABEL: "No such label", - NO_SUCH_ENTRY: "No such entry", - INVALID_VALUE: "Invalid value", - INVALID_VALUE_2: "Invalid value #2", - UNIMPLEMENTED: "Unimplemented", - INVALID_SW_IF_INDEX_2: "Invalid sw_if_index #2", - SYSCALL_ERROR_1: "System call error #1", - SYSCALL_ERROR_2: "System call error #2", - SYSCALL_ERROR_3: "System call error #3", - SYSCALL_ERROR_4: "System call error #4", - SYSCALL_ERROR_5: "System call error #5", - SYSCALL_ERROR_6: "System call error #6", - SYSCALL_ERROR_7: "System call error #7", - SYSCALL_ERROR_8: "System call error #8", - SYSCALL_ERROR_9: "System call error #9", - SYSCALL_ERROR_10: "System call error #10", - FEATURE_DISABLED: "Feature disabled by configuration", - INVALID_REGISTRATION: "Invalid registration", - NEXT_HOP_NOT_IN_FIB: "Next hop not in FIB", - UNKNOWN_DESTINATION: "Unknown destination", - PREFIX_MATCHES_NEXT_HOP: "Prefix matches next hop", - NEXT_HOP_NOT_FOUND_MP: "Next hop not found (multipath)", - NO_MATCHING_INTERFACE: "No matching interface for probe", - INVALID_VLAN: "Invalid VLAN", - VLAN_ALREADY_EXISTS: "VLAN subif already exists", - INVALID_SRC_ADDRESS: "Invalid src address", - INVALID_DST_ADDRESS: "Invalid dst address", - ADDRESS_LENGTH_MISMATCH: "Address length mismatch", - ADDRESS_NOT_FOUND_FOR_INTERFACE: "Address not found for interface", - ADDRESS_NOT_DELETABLE: "Address not deletable", - IP6_NOT_ENABLED: "ip6 not enabled", - IN_PROGRESS: "Operation in progress", - NO_SUCH_NODE: "No such graph node", - NO_SUCH_NODE2: "No such graph node #2", - NO_SUCH_TABLE: "No such table", - NO_SUCH_TABLE2: "No such table #2", - NO_SUCH_TABLE3: "No such table #3", - SUBIF_ALREADY_EXISTS: "Subinterface already exists", - SUBIF_CREATE_FAILED: "Subinterface creation failed", - INVALID_MEMORY_SIZE: "Invalid memory size requested", - INVALID_INTERFACE: "Invalid interface", - INVALID_VLAN_TAG_COUNT: "Invalid number of tags for requested operation", - INVALID_ARGUMENT: "Invalid argument", - UNEXPECTED_INTF_STATE: "Unexpected interface state", - TUNNEL_EXIST: "Tunnel already exists", - INVALID_DECAP_NEXT: "Invalid decap-next", - RESPONSE_NOT_READY: "Response not ready", - NOT_CONNECTED: "Not connected to the data plane", - IF_ALREADY_EXISTS: "Interface already exists", - BOND_SLAVE_NOT_ALLOWED: "Operation not allowed on slave of BondEthernet", - VALUE_EXIST: "Value already exists", - SAME_SRC_DST: "Source and destination are the same", - IP6_MULTICAST_ADDRESS_NOT_PRESENT: "IP6 multicast address required", - SR_POLICY_NAME_NOT_PRESENT: "Segement routing policy name required", - NOT_RUNNING_AS_ROOT: "Not running as root", - ALREADY_CONNECTED: "Connection to the data plane already exists", - UNSUPPORTED_JNI_VERSION: "Unsupported JNI version", - FAILED_TO_ATTACH_TO_JAVA_THREAD: "Failed to attach to Java thread", - INVALID_WORKER: "Invalid worker thread", - LISP_DISABLED: "LISP is disabled", - CLASSIFY_TABLE_NOT_FOUND: "Classify table not found", - INVALID_EID_TYPE: "Unsupported LSIP EID type", - CANNOT_CREATE_PCAP_FILE: "Cannot create pcap file", - INCORRECT_ADJACENCY_TYPE: "Invalid adjacency type for this operation", - EXCEEDED_NUMBER_OF_RANGES_CAPACITY: "Operation would exceed configured capacity of ranges", - EXCEEDED_NUMBER_OF_PORTS_CAPACITY: "Operation would exceed capacity of number of ports", - INVALID_ADDRESS_FAMILY: "Invalid address family", - INVALID_SUB_SW_IF_INDEX: "Invalid sub-interface sw_if_index", - TABLE_TOO_BIG: "Table too big", - CANNOT_ENABLE_DISABLE_FEATURE: "Cannot enable/disable feature", - BFD_EEXIST: "Duplicate BFD object", - BFD_ENOENT: "No such BFD object", - BFD_EINUSE: "BFD object in use", - BFD_NOTSUPP: "BFD feature not supported", - ADDRESS_IN_USE: "Address in use", - ADDRESS_NOT_IN_USE: "Address not in use", - QUEUE_FULL: "Queue full", - APP_UNSUPPORTED_CFG: "Unsupported application config", - URI_FIFO_CREATE_FAILED: "URI FIFO segment create failed", - LISP_RLOC_LOCAL: "RLOC address is local", - BFD_EAGAIN: "BFD object cannot be manipulated at this time", - INVALID_GPE_MODE: "Invalid GPE mode", - LISP_GPE_ENTRIES_PRESENT: "LISP GPE entries are present", - ADDRESS_FOUND_FOR_INTERFACE: "Address found for interface", - SESSION_CONNECT: "Session failed to connect", - ENTRY_ALREADY_EXISTS: "Entry already exists", - SVM_SEGMENT_CREATE_FAIL: "svm segment create fail", - APPLICATION_NOT_ATTACHED: "application not attached", - BD_ALREADY_EXISTS: "Bridge domain already exists", - BD_IN_USE: "Bridge domain has member interfaces", - BD_NOT_MODIFIABLE: "Bridge domain 0 can't be deleted/modified", - BD_ID_EXCEED_MAX: "Bridge domain ID exceed 16M limit", - SUBIF_DOESNT_EXIST: "Subinterface doesn't exist", - L2_MACS_EVENT_CLINET_PRESENT: "Client already exist for L2 MACs events", - INVALID_QUEUE: "Invalid queue", - UNSUPPORTED: "Unsupported", - DUPLICATE_IF_ADDRESS: "Address already present on another interface", - APP_INVALID_NS: "Invalid application namespace", - APP_WRONG_NS_SECRET: "Wrong app namespace secret", - APP_CONNECT_SCOPE: "Connect scope", - APP_ALREADY_ATTACHED: "App already attached", - SESSION_REDIRECT: "Redirect failed", - ILLEGAL_NAME: "Illegal name", - NO_NAME_SERVERS: "No name servers configured", - NAME_SERVER_NOT_FOUND: "Name server not found", - NAME_RESOLUTION_NOT_ENABLED: "Name resolution not enabled", - NAME_SERVER_FORMAT_ERROR: "Server format error (bug!)", - NAME_SERVER_NO_SUCH_NAME: "No such name", - NAME_SERVER_NO_ADDRESSES: "No addresses available", - NAME_SERVER_NEXT_SERVER: "Retry with new server", - APP_CONNECT_FILTERED: "Connect was filtered", - ACL_IN_USE_INBOUND: "Inbound ACL in use", - ACL_IN_USE_OUTBOUND: "Outbound ACL in use", - INIT_FAILED: "Initialization Failed", - NETLINK_ERROR: "netlink error", - BIER_BSL_UNSUP: "BIER bit-string-length unsupported", - INSTANCE_IN_USE: "Instance in use", - INVALID_SESSION_ID: "session ID out of range", - ACL_IN_USE_BY_LOOKUP_CONTEXT: "ACL in use by a lookup context", - INVALID_VALUE_3: "Invalid value #3", - NON_ETHERNET: "Interface is not an Ethernet interface", - BD_ALREADY_HAS_BVI: "Bridge domain already has a BVI interface", -} diff --git a/binapi/abf/abf.ba.go b/binapi/abf/abf.ba.go new file mode 100644 index 00000000..2cee570c --- /dev/null +++ b/binapi/abf/abf.ba.go @@ -0,0 +1,604 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/abf.api.json + +// Package abf contains generated bindings for API file abf.api. +// +// Contents: +// - 2 structs +// - 10 messages +package abf + +import ( + api "github.com/alkiranet/govpp/api" + fib_types "github.com/alkiranet/govpp/binapi/fib_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + _ "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "abf" + APIVersion = "1.0.0" + VersionCrc = 0xf2367b47 +) + +// AbfItfAttach defines type 'abf_itf_attach'. +type AbfItfAttach struct { + PolicyID uint32 `binapi:"u32,name=policy_id" json:"policy_id,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Priority uint32 `binapi:"u32,name=priority" json:"priority,omitempty"` + IsIPv6 bool `binapi:"bool,name=is_ipv6" json:"is_ipv6,omitempty"` +} + +// AbfPolicy defines type 'abf_policy'. +type AbfPolicy struct { + PolicyID uint32 `binapi:"u32,name=policy_id" json:"policy_id,omitempty"` + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + NPaths uint8 `binapi:"u8,name=n_paths" json:"-"` + Paths []fib_types.FibPath `binapi:"fib_path[n_paths],name=paths" json:"paths,omitempty"` +} + +// Add or delete a policy attachment to an interface +// AbfItfAttachAddDel defines message 'abf_itf_attach_add_del'. +// InProgress: the message form may change in the future versions +type AbfItfAttachAddDel struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + Attach AbfItfAttach `binapi:"abf_itf_attach,name=attach" json:"attach,omitempty"` +} + +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 +} + +func (m *AbfItfAttachAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Attach.PolicyID + size += 4 // m.Attach.SwIfIndex + size += 4 // m.Attach.Priority + size += 1 // m.Attach.IsIPv6 + return size +} +func (m *AbfItfAttachAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.Attach.PolicyID) + buf.EncodeUint32(uint32(m.Attach.SwIfIndex)) + buf.EncodeUint32(m.Attach.Priority) + buf.EncodeBool(m.Attach.IsIPv6) + return buf.Bytes(), nil +} +func (m *AbfItfAttachAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Attach.PolicyID = buf.DecodeUint32() + m.Attach.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Attach.Priority = buf.DecodeUint32() + m.Attach.IsIPv6 = buf.DecodeBool() + return nil +} + +// AbfItfAttachAddDelReply defines message 'abf_itf_attach_add_del_reply'. +// InProgress: the message form may change in the future versions +type AbfItfAttachAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *AbfItfAttachAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *AbfItfAttachAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *AbfItfAttachAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Attachment details from a dump +// AbfItfAttachDetails defines message 'abf_itf_attach_details'. +// InProgress: the message form may change in the future versions +type AbfItfAttachDetails struct { + Attach AbfItfAttach `binapi:"abf_itf_attach,name=attach" json:"attach,omitempty"` +} + +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 +} + +func (m *AbfItfAttachDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Attach.PolicyID + size += 4 // m.Attach.SwIfIndex + size += 4 // m.Attach.Priority + size += 1 // m.Attach.IsIPv6 + return size +} +func (m *AbfItfAttachDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Attach.PolicyID) + buf.EncodeUint32(uint32(m.Attach.SwIfIndex)) + buf.EncodeUint32(m.Attach.Priority) + buf.EncodeBool(m.Attach.IsIPv6) + return buf.Bytes(), nil +} +func (m *AbfItfAttachDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Attach.PolicyID = buf.DecodeUint32() + m.Attach.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Attach.Priority = buf.DecodeUint32() + m.Attach.IsIPv6 = buf.DecodeBool() + return nil +} + +// Dump all the policy attachments +// AbfItfAttachDump defines message 'abf_itf_attach_dump'. +// InProgress: the message form may change in the future versions +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 +} + +func (m *AbfItfAttachDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *AbfItfAttachDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *AbfItfAttachDump) Unmarshal(b []byte) error { + return nil +} + +// Get the plugin version +// AbfPluginGetVersion defines message 'abf_plugin_get_version'. +// InProgress: the message form may change in the future versions +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 +} + +func (m *AbfPluginGetVersion) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *AbfPluginGetVersion) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *AbfPluginGetVersion) Unmarshal(b []byte) error { + return nil +} + +// Reply to get the plugin version +// - major - Incremented every time a known breaking behavior change is introduced +// - minor - Incremented with small changes, may be used to avoid buggy versions +// +// AbfPluginGetVersionReply defines message 'abf_plugin_get_version_reply'. +// InProgress: the message form may change in the future versions +type AbfPluginGetVersionReply struct { + Major uint32 `binapi:"u32,name=major" json:"major,omitempty"` + Minor uint32 `binapi:"u32,name=minor" json:"minor,omitempty"` +} + +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 +} + +func (m *AbfPluginGetVersionReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Major + size += 4 // m.Minor + return size +} +func (m *AbfPluginGetVersionReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Major) + buf.EncodeUint32(m.Minor) + return buf.Bytes(), nil +} +func (m *AbfPluginGetVersionReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Major = buf.DecodeUint32() + m.Minor = buf.DecodeUint32() + return nil +} + +// A description of an ABF policy +// - is_add Is this the addition or removal of paths from the policy +// If the policy does not exist it is created. If the last path +// Is being removed, the policy is deleted +// - policy The policy +// +// AbfPolicyAddDel defines message 'abf_policy_add_del'. +// InProgress: the message form may change in the future versions +type AbfPolicyAddDel struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + Policy AbfPolicy `binapi:"abf_policy,name=policy" json:"policy,omitempty"` +} + +func (m *AbfPolicyAddDel) Reset() { *m = AbfPolicyAddDel{} } +func (*AbfPolicyAddDel) GetMessageName() string { return "abf_policy_add_del" } +func (*AbfPolicyAddDel) GetCrcString() string { return "c6131197" } +func (*AbfPolicyAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *AbfPolicyAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Policy.PolicyID + size += 4 // m.Policy.ACLIndex + size += 1 // m.Policy.NPaths + for j2 := 0; j2 < len(m.Policy.Paths); j2++ { + var s2 fib_types.FibPath + _ = s2 + if j2 < len(m.Policy.Paths) { + s2 = m.Policy.Paths[j2] + } + size += 4 // s2.SwIfIndex + size += 4 // s2.TableID + size += 4 // s2.RpfID + size += 1 // s2.Weight + size += 1 // s2.Preference + size += 4 // s2.Type + size += 4 // s2.Flags + size += 4 // s2.Proto + size += 1 * 16 // s2.Nh.Address + size += 4 // s2.Nh.ViaLabel + size += 4 // s2.Nh.ObjID + size += 4 // s2.Nh.ClassifyTableIndex + size += 1 // s2.NLabels + for j3 := 0; j3 < 16; j3++ { + size += 1 // s2.LabelStack[j3].IsUniform + size += 4 // s2.LabelStack[j3].Label + size += 1 // s2.LabelStack[j3].TTL + size += 1 // s2.LabelStack[j3].Exp + } + } + return size +} +func (m *AbfPolicyAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.Policy.PolicyID) + buf.EncodeUint32(m.Policy.ACLIndex) + buf.EncodeUint8(uint8(len(m.Policy.Paths))) + for j1 := 0; j1 < len(m.Policy.Paths); j1++ { + var v1 fib_types.FibPath // Paths + if j1 < len(m.Policy.Paths) { + v1 = m.Policy.Paths[j1] + } + buf.EncodeUint32(v1.SwIfIndex) + buf.EncodeUint32(v1.TableID) + buf.EncodeUint32(v1.RpfID) + buf.EncodeUint8(v1.Weight) + buf.EncodeUint8(v1.Preference) + buf.EncodeUint32(uint32(v1.Type)) + buf.EncodeUint32(uint32(v1.Flags)) + buf.EncodeUint32(uint32(v1.Proto)) + buf.EncodeBytes(v1.Nh.Address.XXX_UnionData[:], 16) + buf.EncodeUint32(v1.Nh.ViaLabel) + buf.EncodeUint32(v1.Nh.ObjID) + buf.EncodeUint32(v1.Nh.ClassifyTableIndex) + buf.EncodeUint8(v1.NLabels) + for j2 := 0; j2 < 16; j2++ { + buf.EncodeUint8(v1.LabelStack[j2].IsUniform) + buf.EncodeUint32(v1.LabelStack[j2].Label) + buf.EncodeUint8(v1.LabelStack[j2].TTL) + buf.EncodeUint8(v1.LabelStack[j2].Exp) + } + } + return buf.Bytes(), nil +} +func (m *AbfPolicyAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Policy.PolicyID = buf.DecodeUint32() + m.Policy.ACLIndex = buf.DecodeUint32() + m.Policy.NPaths = buf.DecodeUint8() + m.Policy.Paths = make([]fib_types.FibPath, m.Policy.NPaths) + for j1 := 0; j1 < len(m.Policy.Paths); j1++ { + m.Policy.Paths[j1].SwIfIndex = buf.DecodeUint32() + m.Policy.Paths[j1].TableID = buf.DecodeUint32() + m.Policy.Paths[j1].RpfID = buf.DecodeUint32() + m.Policy.Paths[j1].Weight = buf.DecodeUint8() + m.Policy.Paths[j1].Preference = buf.DecodeUint8() + m.Policy.Paths[j1].Type = fib_types.FibPathType(buf.DecodeUint32()) + m.Policy.Paths[j1].Flags = fib_types.FibPathFlags(buf.DecodeUint32()) + m.Policy.Paths[j1].Proto = fib_types.FibPathNhProto(buf.DecodeUint32()) + copy(m.Policy.Paths[j1].Nh.Address.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Policy.Paths[j1].Nh.ViaLabel = buf.DecodeUint32() + m.Policy.Paths[j1].Nh.ObjID = buf.DecodeUint32() + m.Policy.Paths[j1].Nh.ClassifyTableIndex = buf.DecodeUint32() + m.Policy.Paths[j1].NLabels = buf.DecodeUint8() + for j2 := 0; j2 < 16; j2++ { + m.Policy.Paths[j1].LabelStack[j2].IsUniform = buf.DecodeUint8() + m.Policy.Paths[j1].LabelStack[j2].Label = buf.DecodeUint32() + m.Policy.Paths[j1].LabelStack[j2].TTL = buf.DecodeUint8() + m.Policy.Paths[j1].LabelStack[j2].Exp = buf.DecodeUint8() + } + } + return nil +} + +// AbfPolicyAddDelReply defines message 'abf_policy_add_del_reply'. +// InProgress: the message form may change in the future versions +type AbfPolicyAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *AbfPolicyAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *AbfPolicyAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *AbfPolicyAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Policy description returned in the dump +// AbfPolicyDetails defines message 'abf_policy_details'. +// InProgress: the message form may change in the future versions +type AbfPolicyDetails struct { + Policy AbfPolicy `binapi:"abf_policy,name=policy" json:"policy,omitempty"` +} + +func (m *AbfPolicyDetails) Reset() { *m = AbfPolicyDetails{} } +func (*AbfPolicyDetails) GetMessageName() string { return "abf_policy_details" } +func (*AbfPolicyDetails) GetCrcString() string { return "b7487fa4" } +func (*AbfPolicyDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *AbfPolicyDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Policy.PolicyID + size += 4 // m.Policy.ACLIndex + size += 1 // m.Policy.NPaths + for j2 := 0; j2 < len(m.Policy.Paths); j2++ { + var s2 fib_types.FibPath + _ = s2 + if j2 < len(m.Policy.Paths) { + s2 = m.Policy.Paths[j2] + } + size += 4 // s2.SwIfIndex + size += 4 // s2.TableID + size += 4 // s2.RpfID + size += 1 // s2.Weight + size += 1 // s2.Preference + size += 4 // s2.Type + size += 4 // s2.Flags + size += 4 // s2.Proto + size += 1 * 16 // s2.Nh.Address + size += 4 // s2.Nh.ViaLabel + size += 4 // s2.Nh.ObjID + size += 4 // s2.Nh.ClassifyTableIndex + size += 1 // s2.NLabels + for j3 := 0; j3 < 16; j3++ { + size += 1 // s2.LabelStack[j3].IsUniform + size += 4 // s2.LabelStack[j3].Label + size += 1 // s2.LabelStack[j3].TTL + size += 1 // s2.LabelStack[j3].Exp + } + } + return size +} +func (m *AbfPolicyDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Policy.PolicyID) + buf.EncodeUint32(m.Policy.ACLIndex) + buf.EncodeUint8(uint8(len(m.Policy.Paths))) + for j1 := 0; j1 < len(m.Policy.Paths); j1++ { + var v1 fib_types.FibPath // Paths + if j1 < len(m.Policy.Paths) { + v1 = m.Policy.Paths[j1] + } + buf.EncodeUint32(v1.SwIfIndex) + buf.EncodeUint32(v1.TableID) + buf.EncodeUint32(v1.RpfID) + buf.EncodeUint8(v1.Weight) + buf.EncodeUint8(v1.Preference) + buf.EncodeUint32(uint32(v1.Type)) + buf.EncodeUint32(uint32(v1.Flags)) + buf.EncodeUint32(uint32(v1.Proto)) + buf.EncodeBytes(v1.Nh.Address.XXX_UnionData[:], 16) + buf.EncodeUint32(v1.Nh.ViaLabel) + buf.EncodeUint32(v1.Nh.ObjID) + buf.EncodeUint32(v1.Nh.ClassifyTableIndex) + buf.EncodeUint8(v1.NLabels) + for j2 := 0; j2 < 16; j2++ { + buf.EncodeUint8(v1.LabelStack[j2].IsUniform) + buf.EncodeUint32(v1.LabelStack[j2].Label) + buf.EncodeUint8(v1.LabelStack[j2].TTL) + buf.EncodeUint8(v1.LabelStack[j2].Exp) + } + } + return buf.Bytes(), nil +} +func (m *AbfPolicyDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Policy.PolicyID = buf.DecodeUint32() + m.Policy.ACLIndex = buf.DecodeUint32() + m.Policy.NPaths = buf.DecodeUint8() + m.Policy.Paths = make([]fib_types.FibPath, m.Policy.NPaths) + for j1 := 0; j1 < len(m.Policy.Paths); j1++ { + m.Policy.Paths[j1].SwIfIndex = buf.DecodeUint32() + m.Policy.Paths[j1].TableID = buf.DecodeUint32() + m.Policy.Paths[j1].RpfID = buf.DecodeUint32() + m.Policy.Paths[j1].Weight = buf.DecodeUint8() + m.Policy.Paths[j1].Preference = buf.DecodeUint8() + m.Policy.Paths[j1].Type = fib_types.FibPathType(buf.DecodeUint32()) + m.Policy.Paths[j1].Flags = fib_types.FibPathFlags(buf.DecodeUint32()) + m.Policy.Paths[j1].Proto = fib_types.FibPathNhProto(buf.DecodeUint32()) + copy(m.Policy.Paths[j1].Nh.Address.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Policy.Paths[j1].Nh.ViaLabel = buf.DecodeUint32() + m.Policy.Paths[j1].Nh.ObjID = buf.DecodeUint32() + m.Policy.Paths[j1].Nh.ClassifyTableIndex = buf.DecodeUint32() + m.Policy.Paths[j1].NLabels = buf.DecodeUint8() + for j2 := 0; j2 < 16; j2++ { + m.Policy.Paths[j1].LabelStack[j2].IsUniform = buf.DecodeUint8() + m.Policy.Paths[j1].LabelStack[j2].Label = buf.DecodeUint32() + m.Policy.Paths[j1].LabelStack[j2].TTL = buf.DecodeUint8() + m.Policy.Paths[j1].LabelStack[j2].Exp = buf.DecodeUint8() + } + } + return nil +} + +// Dump all ABF policies +// AbfPolicyDump defines message 'abf_policy_dump'. +// InProgress: the message form may change in the future versions +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 (m *AbfPolicyDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *AbfPolicyDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *AbfPolicyDump) Unmarshal(b []byte) error { + return nil +} + +func init() { file_abf_binapi_init() } +func file_abf_binapi_init() { + api.RegisterMessage((*AbfItfAttachAddDel)(nil), "abf_itf_attach_add_del_25c8621b") + api.RegisterMessage((*AbfItfAttachAddDelReply)(nil), "abf_itf_attach_add_del_reply_e8d4e804") + api.RegisterMessage((*AbfItfAttachDetails)(nil), "abf_itf_attach_details_7819523e") + api.RegisterMessage((*AbfItfAttachDump)(nil), "abf_itf_attach_dump_51077d14") + api.RegisterMessage((*AbfPluginGetVersion)(nil), "abf_plugin_get_version_51077d14") + api.RegisterMessage((*AbfPluginGetVersionReply)(nil), "abf_plugin_get_version_reply_9b32cf86") + api.RegisterMessage((*AbfPolicyAddDel)(nil), "abf_policy_add_del_c6131197") + api.RegisterMessage((*AbfPolicyAddDelReply)(nil), "abf_policy_add_del_reply_e8d4e804") + api.RegisterMessage((*AbfPolicyDetails)(nil), "abf_policy_details_b7487fa4") + api.RegisterMessage((*AbfPolicyDump)(nil), "abf_policy_dump_51077d14") +} + +// 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), + } +} diff --git a/binapi/abf/abf_rpc.ba.go b/binapi/abf/abf_rpc.ba.go new file mode 100644 index 00000000..7948846d --- /dev/null +++ b/binapi/abf/abf_rpc.ba.go @@ -0,0 +1,142 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package abf + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service abf. +type RPCService interface { + AbfItfAttachAddDel(ctx context.Context, in *AbfItfAttachAddDel) (*AbfItfAttachAddDelReply, error) + AbfItfAttachDump(ctx context.Context, in *AbfItfAttachDump) (RPCService_AbfItfAttachDumpClient, error) + AbfPluginGetVersion(ctx context.Context, in *AbfPluginGetVersion) (*AbfPluginGetVersionReply, error) + AbfPolicyAddDel(ctx context.Context, in *AbfPolicyAddDel) (*AbfPolicyAddDelReply, error) + AbfPolicyDump(ctx context.Context, in *AbfPolicyDump) (RPCService_AbfPolicyDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) AbfItfAttachAddDel(ctx context.Context, in *AbfItfAttachAddDel) (*AbfItfAttachAddDelReply, error) { + out := new(AbfItfAttachAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) AbfItfAttachDump(ctx context.Context, in *AbfItfAttachDump) (RPCService_AbfItfAttachDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_AbfItfAttachDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_AbfItfAttachDumpClient interface { + Recv() (*AbfItfAttachDetails, error) + api.Stream +} + +type serviceClient_AbfItfAttachDumpClient struct { + api.Stream +} + +func (c *serviceClient_AbfItfAttachDumpClient) Recv() (*AbfItfAttachDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *AbfItfAttachDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) AbfPluginGetVersion(ctx context.Context, in *AbfPluginGetVersion) (*AbfPluginGetVersionReply, error) { + out := new(AbfPluginGetVersionReply) + err := c.conn.Invoke(ctx, in, 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.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) AbfPolicyDump(ctx context.Context, in *AbfPolicyDump) (RPCService_AbfPolicyDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_AbfPolicyDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_AbfPolicyDumpClient interface { + Recv() (*AbfPolicyDetails, error) + api.Stream +} + +type serviceClient_AbfPolicyDumpClient struct { + api.Stream +} + +func (c *serviceClient_AbfPolicyDumpClient) Recv() (*AbfPolicyDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *AbfPolicyDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/acl/acl.ba.go b/binapi/acl/acl.ba.go new file mode 100644 index 00000000..8ae7f3ff --- /dev/null +++ b/binapi/acl/acl.ba.go @@ -0,0 +1,2060 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/acl.api.json + +// Package acl contains generated bindings for API file acl.api. +// +// Contents: +// - 42 messages +package acl + +import ( + api "github.com/alkiranet/govpp/api" + acl_types "github.com/alkiranet/govpp/binapi/acl_types" + _ "github.com/alkiranet/govpp/binapi/ethernet_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "acl" + APIVersion = "2.0.1" + VersionCrc = 0x5133bba0 +) + +// Replace an existing ACL in-place or create a new ACL +// - acl_index - an existing ACL entry (0..0xfffffffe) to replace, or 0xffffffff to make new ACL +// - tag - a string value stored along with the ACL, for descriptive purposes +// - count - number of ACL rules +// @r - Rules for this access-list +// +// ACLAddReplace defines message 'acl_add_replace'. +type ACLAddReplace struct { + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + R []acl_types.ACLRule `binapi:"acl_rule[count],name=r" json:"r,omitempty"` +} + +func (m *ACLAddReplace) Reset() { *m = ACLAddReplace{} } +func (*ACLAddReplace) GetMessageName() string { return "acl_add_replace" } +func (*ACLAddReplace) GetCrcString() string { return "ee5c2f18" } +func (*ACLAddReplace) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ACLAddReplace) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ACLIndex + size += 64 // m.Tag + size += 4 // m.Count + for j1 := 0; j1 < len(m.R); j1++ { + var s1 acl_types.ACLRule + _ = s1 + if j1 < len(m.R) { + s1 = m.R[j1] + } + size += 1 // s1.IsPermit + size += 1 // s1.SrcPrefix.Address.Af + size += 1 * 16 // s1.SrcPrefix.Address.Un + size += 1 // s1.SrcPrefix.Len + size += 1 // s1.DstPrefix.Address.Af + size += 1 * 16 // s1.DstPrefix.Address.Un + size += 1 // s1.DstPrefix.Len + size += 1 // s1.Proto + size += 2 // s1.SrcportOrIcmptypeFirst + size += 2 // s1.SrcportOrIcmptypeLast + size += 2 // s1.DstportOrIcmpcodeFirst + size += 2 // s1.DstportOrIcmpcodeLast + size += 1 // s1.TCPFlagsMask + size += 1 // s1.TCPFlagsValue + } + return size +} +func (m *ACLAddReplace) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.ACLIndex) + buf.EncodeString(m.Tag, 64) + buf.EncodeUint32(uint32(len(m.R))) + for j0 := 0; j0 < len(m.R); j0++ { + var v0 acl_types.ACLRule // R + if j0 < len(m.R) { + v0 = m.R[j0] + } + buf.EncodeUint8(uint8(v0.IsPermit)) + buf.EncodeUint8(uint8(v0.SrcPrefix.Address.Af)) + buf.EncodeBytes(v0.SrcPrefix.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(v0.SrcPrefix.Len) + buf.EncodeUint8(uint8(v0.DstPrefix.Address.Af)) + buf.EncodeBytes(v0.DstPrefix.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(v0.DstPrefix.Len) + buf.EncodeUint8(uint8(v0.Proto)) + buf.EncodeUint16(v0.SrcportOrIcmptypeFirst) + buf.EncodeUint16(v0.SrcportOrIcmptypeLast) + buf.EncodeUint16(v0.DstportOrIcmpcodeFirst) + buf.EncodeUint16(v0.DstportOrIcmpcodeLast) + buf.EncodeUint8(v0.TCPFlagsMask) + buf.EncodeUint8(v0.TCPFlagsValue) + } + return buf.Bytes(), nil +} +func (m *ACLAddReplace) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ACLIndex = buf.DecodeUint32() + m.Tag = buf.DecodeString(64) + m.Count = buf.DecodeUint32() + m.R = make([]acl_types.ACLRule, m.Count) + for j0 := 0; j0 < len(m.R); j0++ { + m.R[j0].IsPermit = acl_types.ACLAction(buf.DecodeUint8()) + m.R[j0].SrcPrefix.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.R[j0].SrcPrefix.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.R[j0].SrcPrefix.Len = buf.DecodeUint8() + m.R[j0].DstPrefix.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.R[j0].DstPrefix.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.R[j0].DstPrefix.Len = buf.DecodeUint8() + m.R[j0].Proto = ip_types.IPProto(buf.DecodeUint8()) + m.R[j0].SrcportOrIcmptypeFirst = buf.DecodeUint16() + m.R[j0].SrcportOrIcmptypeLast = buf.DecodeUint16() + m.R[j0].DstportOrIcmpcodeFirst = buf.DecodeUint16() + m.R[j0].DstportOrIcmpcodeLast = buf.DecodeUint16() + m.R[j0].TCPFlagsMask = buf.DecodeUint8() + m.R[j0].TCPFlagsValue = buf.DecodeUint8() + } + return nil +} + +// Reply to add/replace ACL +// - acl_index - index of the updated or newly created ACL +// - retval 0 - no error +// +// ACLAddReplaceReply defines message 'acl_add_replace_reply'. +type ACLAddReplaceReply struct { + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *ACLAddReplaceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ACLIndex + size += 4 // m.Retval + return size +} +func (m *ACLAddReplaceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.ACLIndex) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *ACLAddReplaceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ACLIndex = buf.DecodeUint32() + m.Retval = buf.DecodeInt32() + return nil +} + +// Delete an ACL +// - acl_index - ACL index to delete +// +// ACLDel defines message 'acl_del'. +type ACLDel struct { + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` +} + +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 +} + +func (m *ACLDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ACLIndex + return size +} +func (m *ACLDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.ACLIndex) + return buf.Bytes(), nil +} +func (m *ACLDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ACLIndex = buf.DecodeUint32() + return nil +} + +// ACLDelReply defines message 'acl_del_reply'. +type ACLDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *ACLDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *ACLDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *ACLDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Details about a single ACL contents +// - acl_index - ACL index whose contents are being sent in this message +// - tag - Descriptive tag value which was supplied at ACL creation +// - count - Number of rules in this ACL +// - r - Array of rules within this ACL +// +// ACLDetails defines message 'acl_details'. +type ACLDetails struct { + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + R []acl_types.ACLRule `binapi:"acl_rule[count],name=r" json:"r,omitempty"` +} + +func (m *ACLDetails) Reset() { *m = ACLDetails{} } +func (*ACLDetails) GetMessageName() string { return "acl_details" } +func (*ACLDetails) GetCrcString() string { return "95babae0" } +func (*ACLDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ACLDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ACLIndex + size += 64 // m.Tag + size += 4 // m.Count + for j1 := 0; j1 < len(m.R); j1++ { + var s1 acl_types.ACLRule + _ = s1 + if j1 < len(m.R) { + s1 = m.R[j1] + } + size += 1 // s1.IsPermit + size += 1 // s1.SrcPrefix.Address.Af + size += 1 * 16 // s1.SrcPrefix.Address.Un + size += 1 // s1.SrcPrefix.Len + size += 1 // s1.DstPrefix.Address.Af + size += 1 * 16 // s1.DstPrefix.Address.Un + size += 1 // s1.DstPrefix.Len + size += 1 // s1.Proto + size += 2 // s1.SrcportOrIcmptypeFirst + size += 2 // s1.SrcportOrIcmptypeLast + size += 2 // s1.DstportOrIcmpcodeFirst + size += 2 // s1.DstportOrIcmpcodeLast + size += 1 // s1.TCPFlagsMask + size += 1 // s1.TCPFlagsValue + } + return size +} +func (m *ACLDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.ACLIndex) + buf.EncodeString(m.Tag, 64) + buf.EncodeUint32(uint32(len(m.R))) + for j0 := 0; j0 < len(m.R); j0++ { + var v0 acl_types.ACLRule // R + if j0 < len(m.R) { + v0 = m.R[j0] + } + buf.EncodeUint8(uint8(v0.IsPermit)) + buf.EncodeUint8(uint8(v0.SrcPrefix.Address.Af)) + buf.EncodeBytes(v0.SrcPrefix.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(v0.SrcPrefix.Len) + buf.EncodeUint8(uint8(v0.DstPrefix.Address.Af)) + buf.EncodeBytes(v0.DstPrefix.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(v0.DstPrefix.Len) + buf.EncodeUint8(uint8(v0.Proto)) + buf.EncodeUint16(v0.SrcportOrIcmptypeFirst) + buf.EncodeUint16(v0.SrcportOrIcmptypeLast) + buf.EncodeUint16(v0.DstportOrIcmpcodeFirst) + buf.EncodeUint16(v0.DstportOrIcmpcodeLast) + buf.EncodeUint8(v0.TCPFlagsMask) + buf.EncodeUint8(v0.TCPFlagsValue) + } + return buf.Bytes(), nil +} +func (m *ACLDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ACLIndex = buf.DecodeUint32() + m.Tag = buf.DecodeString(64) + m.Count = buf.DecodeUint32() + m.R = make([]acl_types.ACLRule, m.Count) + for j0 := 0; j0 < len(m.R); j0++ { + m.R[j0].IsPermit = acl_types.ACLAction(buf.DecodeUint8()) + m.R[j0].SrcPrefix.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.R[j0].SrcPrefix.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.R[j0].SrcPrefix.Len = buf.DecodeUint8() + m.R[j0].DstPrefix.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.R[j0].DstPrefix.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.R[j0].DstPrefix.Len = buf.DecodeUint8() + m.R[j0].Proto = ip_types.IPProto(buf.DecodeUint8()) + m.R[j0].SrcportOrIcmptypeFirst = buf.DecodeUint16() + m.R[j0].SrcportOrIcmptypeLast = buf.DecodeUint16() + m.R[j0].DstportOrIcmpcodeFirst = buf.DecodeUint16() + m.R[j0].DstportOrIcmpcodeLast = buf.DecodeUint16() + m.R[j0].TCPFlagsMask = buf.DecodeUint8() + m.R[j0].TCPFlagsValue = buf.DecodeUint8() + } + return nil +} + +// Dump the specific ACL contents or all of the ACLs' contents +// - acl_index - ACL index to dump, ~0 to dump all ACLs +// +// ACLDump defines message 'acl_dump'. +type ACLDump struct { + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` +} + +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 +} + +func (m *ACLDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ACLIndex + return size +} +func (m *ACLDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.ACLIndex) + return buf.Bytes(), nil +} +func (m *ACLDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ACLIndex = buf.DecodeUint32() + return nil +} + +// Use acl_interface_set_acl_list instead +// +// Append/remove an ACL index to/from the list of ACLs checked for an interface +// - is_add - add or delete the ACL index from the list +// - is_input - check the ACL on input (1) or output (0) +// - sw_if_index - the interface to alter the list of ACLs on +// - acl_index - index of ACL for the operation +// +// ACLInterfaceAddDel defines message 'acl_interface_add_del'. +type ACLInterfaceAddDel struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + IsInput bool `binapi:"bool,name=is_input" json:"is_input,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` +} + +func (m *ACLInterfaceAddDel) Reset() { *m = ACLInterfaceAddDel{} } +func (*ACLInterfaceAddDel) GetMessageName() string { return "acl_interface_add_del" } +func (*ACLInterfaceAddDel) GetCrcString() string { return "4b54bebd" } +func (*ACLInterfaceAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ACLInterfaceAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.IsInput + size += 4 // m.SwIfIndex + size += 4 // m.ACLIndex + return size +} +func (m *ACLInterfaceAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeBool(m.IsInput) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.ACLIndex) + return buf.Bytes(), nil +} +func (m *ACLInterfaceAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.IsInput = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.ACLIndex = buf.DecodeUint32() + return nil +} + +// ACLInterfaceAddDelReply defines message 'acl_interface_add_del_reply'. +type ACLInterfaceAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *ACLInterfaceAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *ACLInterfaceAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *ACLInterfaceAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Details about ethertype whitelist on a single interface +// - sw_if_index - interface for which the list of MACIP ACLs is applied +// - count - total number of whitelisted ethertypes in the vector +// - n_input - this many first elements correspond to input whitelisted ethertypes, the rest - output +// - whitelist - vector of whitelisted ethertypes +// +// ACLInterfaceEtypeWhitelistDetails defines message 'acl_interface_etype_whitelist_details'. +type ACLInterfaceEtypeWhitelistDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Count uint8 `binapi:"u8,name=count" json:"-"` + NInput uint8 `binapi:"u8,name=n_input" json:"n_input,omitempty"` + Whitelist []uint16 `binapi:"u16[count],name=whitelist" json:"whitelist,omitempty"` +} + +func (m *ACLInterfaceEtypeWhitelistDetails) Reset() { *m = ACLInterfaceEtypeWhitelistDetails{} } +func (*ACLInterfaceEtypeWhitelistDetails) GetMessageName() string { + return "acl_interface_etype_whitelist_details" +} +func (*ACLInterfaceEtypeWhitelistDetails) GetCrcString() string { return "cc2bfded" } +func (*ACLInterfaceEtypeWhitelistDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ACLInterfaceEtypeWhitelistDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.Count + size += 1 // m.NInput + size += 2 * len(m.Whitelist) // m.Whitelist + return size +} +func (m *ACLInterfaceEtypeWhitelistDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(uint8(len(m.Whitelist))) + buf.EncodeUint8(m.NInput) + for i := 0; i < len(m.Whitelist); i++ { + var x uint16 + if i < len(m.Whitelist) { + x = uint16(m.Whitelist[i]) + } + buf.EncodeUint16(x) + } + return buf.Bytes(), nil +} +func (m *ACLInterfaceEtypeWhitelistDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Count = buf.DecodeUint8() + m.NInput = buf.DecodeUint8() + m.Whitelist = make([]uint16, m.Count) + for i := 0; i < len(m.Whitelist); i++ { + m.Whitelist[i] = buf.DecodeUint16() + } + return nil +} + +// Dump the list(s) of Ethertype whitelists applied to specific or all interfaces +// - sw_if_index - interface to dump the ethertype whitelist for +// +// ACLInterfaceEtypeWhitelistDump defines message 'acl_interface_etype_whitelist_dump'. +type ACLInterfaceEtypeWhitelistDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *ACLInterfaceEtypeWhitelistDump) Reset() { *m = ACLInterfaceEtypeWhitelistDump{} } +func (*ACLInterfaceEtypeWhitelistDump) GetMessageName() string { + return "acl_interface_etype_whitelist_dump" +} +func (*ACLInterfaceEtypeWhitelistDump) GetCrcString() string { return "f9e6675e" } +func (*ACLInterfaceEtypeWhitelistDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ACLInterfaceEtypeWhitelistDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *ACLInterfaceEtypeWhitelistDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *ACLInterfaceEtypeWhitelistDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Details about a single ACL contents +// - sw_if_index - interface for which the list of ACLs is applied +// - count - total length of acl indices vector +// - n_input - this many of indices in the beginning are input ACLs, the rest - output +// - acls - the vector of ACL indices +// +// ACLInterfaceListDetails defines message 'acl_interface_list_details'. +type ACLInterfaceListDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Count uint8 `binapi:"u8,name=count" json:"-"` + NInput uint8 `binapi:"u8,name=n_input" json:"n_input,omitempty"` + Acls []uint32 `binapi:"u32[count],name=acls" json:"acls,omitempty"` +} + +func (m *ACLInterfaceListDetails) Reset() { *m = ACLInterfaceListDetails{} } +func (*ACLInterfaceListDetails) GetMessageName() string { return "acl_interface_list_details" } +func (*ACLInterfaceListDetails) GetCrcString() string { return "e695d256" } +func (*ACLInterfaceListDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ACLInterfaceListDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.Count + size += 1 // m.NInput + size += 4 * len(m.Acls) // m.Acls + return size +} +func (m *ACLInterfaceListDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(uint8(len(m.Acls))) + buf.EncodeUint8(m.NInput) + for i := 0; i < len(m.Acls); i++ { + var x uint32 + if i < len(m.Acls) { + x = uint32(m.Acls[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *ACLInterfaceListDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Count = buf.DecodeUint8() + m.NInput = buf.DecodeUint8() + m.Acls = make([]uint32, m.Count) + for i := 0; i < len(m.Acls); i++ { + m.Acls[i] = buf.DecodeUint32() + } + return nil +} + +// Dump the list(s) of ACL applied to specific or all interfaces +// - sw_if_index - interface for which to dump the ACL list. Default: 0xffffffff (All interfaces) +// +// ACLInterfaceListDump defines message 'acl_interface_list_dump'. +type ACLInterfaceListDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` +} + +func (m *ACLInterfaceListDump) Reset() { *m = ACLInterfaceListDump{} } +func (*ACLInterfaceListDump) GetMessageName() string { return "acl_interface_list_dump" } +func (*ACLInterfaceListDump) GetCrcString() string { return "f9e6675e" } +func (*ACLInterfaceListDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ACLInterfaceListDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *ACLInterfaceListDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *ACLInterfaceListDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Set the vector of input/output ACLs checked for an interface +// - sw_if_index - the interface to alter the list of ACLs on +// - count - total number of ACL indices in the vector +// - n_input - this many first elements correspond to input ACLs, the rest - output +// - acls - vector of ACL indices +// +// ACLInterfaceSetACLList defines message 'acl_interface_set_acl_list'. +type ACLInterfaceSetACLList struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Count uint8 `binapi:"u8,name=count" json:"-"` + NInput uint8 `binapi:"u8,name=n_input" json:"n_input,omitempty"` + Acls []uint32 `binapi:"u32[count],name=acls" json:"acls,omitempty"` +} + +func (m *ACLInterfaceSetACLList) Reset() { *m = ACLInterfaceSetACLList{} } +func (*ACLInterfaceSetACLList) GetMessageName() string { return "acl_interface_set_acl_list" } +func (*ACLInterfaceSetACLList) GetCrcString() string { return "473982bd" } +func (*ACLInterfaceSetACLList) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ACLInterfaceSetACLList) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.Count + size += 1 // m.NInput + size += 4 * len(m.Acls) // m.Acls + return size +} +func (m *ACLInterfaceSetACLList) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(uint8(len(m.Acls))) + buf.EncodeUint8(m.NInput) + for i := 0; i < len(m.Acls); i++ { + var x uint32 + if i < len(m.Acls) { + x = uint32(m.Acls[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *ACLInterfaceSetACLList) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Count = buf.DecodeUint8() + m.NInput = buf.DecodeUint8() + m.Acls = make([]uint32, m.Count) + for i := 0; i < len(m.Acls); i++ { + m.Acls[i] = buf.DecodeUint32() + } + return nil +} + +// ACLInterfaceSetACLListReply defines message 'acl_interface_set_acl_list_reply'. +type ACLInterfaceSetACLListReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *ACLInterfaceSetACLListReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *ACLInterfaceSetACLListReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *ACLInterfaceSetACLListReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set the ethertype whitelists on an interface. Takes effect when applying ACLs on the interface, so must be given prior. +// - sw_if_index - the interface to alter the list of ACLs on +// - count - total number of whitelisted ethertypes in the vector +// - n_input - this many first elements correspond to input whitelisted ethertypes, the rest - output +// - whitelist - vector of whitelisted ethertypes +// +// ACLInterfaceSetEtypeWhitelist defines message 'acl_interface_set_etype_whitelist'. +type ACLInterfaceSetEtypeWhitelist struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Count uint8 `binapi:"u8,name=count" json:"-"` + NInput uint8 `binapi:"u8,name=n_input" json:"n_input,omitempty"` + Whitelist []uint16 `binapi:"u16[count],name=whitelist" json:"whitelist,omitempty"` +} + +func (m *ACLInterfaceSetEtypeWhitelist) Reset() { *m = ACLInterfaceSetEtypeWhitelist{} } +func (*ACLInterfaceSetEtypeWhitelist) GetMessageName() string { + return "acl_interface_set_etype_whitelist" +} +func (*ACLInterfaceSetEtypeWhitelist) GetCrcString() string { return "3f5c2d2d" } +func (*ACLInterfaceSetEtypeWhitelist) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ACLInterfaceSetEtypeWhitelist) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.Count + size += 1 // m.NInput + size += 2 * len(m.Whitelist) // m.Whitelist + return size +} +func (m *ACLInterfaceSetEtypeWhitelist) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(uint8(len(m.Whitelist))) + buf.EncodeUint8(m.NInput) + for i := 0; i < len(m.Whitelist); i++ { + var x uint16 + if i < len(m.Whitelist) { + x = uint16(m.Whitelist[i]) + } + buf.EncodeUint16(x) + } + return buf.Bytes(), nil +} +func (m *ACLInterfaceSetEtypeWhitelist) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Count = buf.DecodeUint8() + m.NInput = buf.DecodeUint8() + m.Whitelist = make([]uint16, m.Count) + for i := 0; i < len(m.Whitelist); i++ { + m.Whitelist[i] = buf.DecodeUint16() + } + return nil +} + +// ACLInterfaceSetEtypeWhitelistReply defines message 'acl_interface_set_etype_whitelist_reply'. +type ACLInterfaceSetEtypeWhitelistReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *ACLInterfaceSetEtypeWhitelistReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *ACLInterfaceSetEtypeWhitelistReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *ACLInterfaceSetEtypeWhitelistReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Control ping from client to api server request +// ACLPluginControlPing defines 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 +} + +func (m *ACLPluginControlPing) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ACLPluginControlPing) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ACLPluginControlPing) Unmarshal(b []byte) error { + return nil +} + +// Control ping from the client to the server response +// - retval - return code for the request +// - vpe_pid - the pid of the vpe, returned by the server +// +// ACLPluginControlPingReply defines message 'acl_plugin_control_ping_reply'. +type ACLPluginControlPingReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + ClientIndex uint32 `binapi:"u32,name=client_index" json:"client_index,omitempty"` + VpePID uint32 `binapi:"u32,name=vpe_pid" json:"vpe_pid,omitempty"` +} + +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 +} + +func (m *ACLPluginControlPingReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.ClientIndex + size += 4 // m.VpePID + return size +} +func (m *ACLPluginControlPingReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.ClientIndex) + buf.EncodeUint32(m.VpePID) + return buf.Bytes(), nil +} +func (m *ACLPluginControlPingReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.ClientIndex = buf.DecodeUint32() + m.VpePID = buf.DecodeUint32() + return nil +} + +// Get Connection table max entries +// ACLPluginGetConnTableMaxEntries defines 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 +} + +func (m *ACLPluginGetConnTableMaxEntries) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ACLPluginGetConnTableMaxEntries) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ACLPluginGetConnTableMaxEntries) Unmarshal(b []byte) error { + return nil +} + +// Reply to get connection table max entries +// - conn_table_max_entries - the value of maximum entries of connection table +// +// ACLPluginGetConnTableMaxEntriesReply defines message 'acl_plugin_get_conn_table_max_entries_reply'. +type ACLPluginGetConnTableMaxEntriesReply struct { + ConnTableMaxEntries uint64 `binapi:"u64,name=conn_table_max_entries" json:"conn_table_max_entries,omitempty"` +} + +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 +} + +func (m *ACLPluginGetConnTableMaxEntriesReply) Size() (size int) { + if m == nil { + return 0 + } + size += 8 // m.ConnTableMaxEntries + return size +} +func (m *ACLPluginGetConnTableMaxEntriesReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint64(m.ConnTableMaxEntries) + return buf.Bytes(), nil +} +func (m *ACLPluginGetConnTableMaxEntriesReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ConnTableMaxEntries = buf.DecodeUint64() + return nil +} + +// Get the plugin version +// ACLPluginGetVersion defines 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 +} + +func (m *ACLPluginGetVersion) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ACLPluginGetVersion) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ACLPluginGetVersion) Unmarshal(b []byte) error { + return nil +} + +// Reply to get the plugin version +// - major - Incremented every time a known breaking behavior change is introduced +// - minor - Incremented with small changes, may be used to avoid buggy versions +// +// ACLPluginGetVersionReply defines message 'acl_plugin_get_version_reply'. +type ACLPluginGetVersionReply struct { + Major uint32 `binapi:"u32,name=major" json:"major,omitempty"` + Minor uint32 `binapi:"u32,name=minor" json:"minor,omitempty"` +} + +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 +} + +func (m *ACLPluginGetVersionReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Major + size += 4 // m.Minor + return size +} +func (m *ACLPluginGetVersionReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Major) + buf.EncodeUint32(m.Minor) + return buf.Bytes(), nil +} +func (m *ACLPluginGetVersionReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Major = buf.DecodeUint32() + m.Minor = buf.DecodeUint32() + return nil +} + +// Get if the hash-based ACL lookups are enabled (default) or not (use linear search) +// ACLPluginUseHashLookupGet defines message 'acl_plugin_use_hash_lookup_get'. +// InProgress: the message form may change in the future versions +type ACLPluginUseHashLookupGet struct{} + +func (m *ACLPluginUseHashLookupGet) Reset() { *m = ACLPluginUseHashLookupGet{} } +func (*ACLPluginUseHashLookupGet) GetMessageName() string { return "acl_plugin_use_hash_lookup_get" } +func (*ACLPluginUseHashLookupGet) GetCrcString() string { return "51077d14" } +func (*ACLPluginUseHashLookupGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ACLPluginUseHashLookupGet) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ACLPluginUseHashLookupGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ACLPluginUseHashLookupGet) Unmarshal(b []byte) error { + return nil +} + +// Reply with the previous state of the hash lookup +// - prev_enable - previous state of the hash lookup use +// +// ACLPluginUseHashLookupGetReply defines message 'acl_plugin_use_hash_lookup_get_reply'. +// InProgress: the message form may change in the future versions +type ACLPluginUseHashLookupGetReply struct { + Enable bool `binapi:"bool,name=enable" json:"enable,omitempty"` +} + +func (m *ACLPluginUseHashLookupGetReply) Reset() { *m = ACLPluginUseHashLookupGetReply{} } +func (*ACLPluginUseHashLookupGetReply) GetMessageName() string { + return "acl_plugin_use_hash_lookup_get_reply" +} +func (*ACLPluginUseHashLookupGetReply) GetCrcString() string { return "5392ad31" } +func (*ACLPluginUseHashLookupGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ACLPluginUseHashLookupGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Enable + return size +} +func (m *ACLPluginUseHashLookupGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.Enable) + return buf.Bytes(), nil +} +func (m *ACLPluginUseHashLookupGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Enable = buf.DecodeBool() + return nil +} + +// Enable hash-based ACL lookups (default) or disable them (use linear search) +// - enable - whether to enable or disable the usage of hash lookup algorithm +// +// ACLPluginUseHashLookupSet defines message 'acl_plugin_use_hash_lookup_set'. +// InProgress: the message form may change in the future versions +type ACLPluginUseHashLookupSet struct { + Enable bool `binapi:"bool,name=enable" json:"enable,omitempty"` +} + +func (m *ACLPluginUseHashLookupSet) Reset() { *m = ACLPluginUseHashLookupSet{} } +func (*ACLPluginUseHashLookupSet) GetMessageName() string { return "acl_plugin_use_hash_lookup_set" } +func (*ACLPluginUseHashLookupSet) GetCrcString() string { return "b3e225d2" } +func (*ACLPluginUseHashLookupSet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ACLPluginUseHashLookupSet) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Enable + return size +} +func (m *ACLPluginUseHashLookupSet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.Enable) + return buf.Bytes(), nil +} +func (m *ACLPluginUseHashLookupSet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Enable = buf.DecodeBool() + return nil +} + +// ACLPluginUseHashLookupSetReply defines message 'acl_plugin_use_hash_lookup_set_reply'. +// InProgress: the message form may change in the future versions +type ACLPluginUseHashLookupSetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *ACLPluginUseHashLookupSetReply) Reset() { *m = ACLPluginUseHashLookupSetReply{} } +func (*ACLPluginUseHashLookupSetReply) GetMessageName() string { + return "acl_plugin_use_hash_lookup_set_reply" +} +func (*ACLPluginUseHashLookupSetReply) GetCrcString() string { return "e8d4e804" } +func (*ACLPluginUseHashLookupSetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ACLPluginUseHashLookupSetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *ACLPluginUseHashLookupSetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *ACLPluginUseHashLookupSetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Enable or disable incrementing ACL counters in stats segment by interface processing +// - enable - whether to enable or disable incrementing the counters +// +// ACLStatsIntfCountersEnable defines message 'acl_stats_intf_counters_enable'. +type ACLStatsIntfCountersEnable struct { + Enable bool `binapi:"bool,name=enable" json:"enable,omitempty"` +} + +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 +} + +func (m *ACLStatsIntfCountersEnable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Enable + return size +} +func (m *ACLStatsIntfCountersEnable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.Enable) + return buf.Bytes(), nil +} +func (m *ACLStatsIntfCountersEnable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Enable = buf.DecodeBool() + return nil +} + +// ACLStatsIntfCountersEnableReply defines message 'acl_stats_intf_counters_enable_reply'. +type ACLStatsIntfCountersEnableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *ACLStatsIntfCountersEnableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *ACLStatsIntfCountersEnableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *ACLStatsIntfCountersEnableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add a MACIP ACL +// - tag - descriptive value for this MACIP ACL +// - count - number of rules in this MACIP ACL +// - r - vector of MACIP ACL rules +// +// MacipACLAdd defines message 'macip_acl_add'. +type MacipACLAdd struct { + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + R []acl_types.MacipACLRule `binapi:"macip_acl_rule[count],name=r" json:"r,omitempty"` +} + +func (m *MacipACLAdd) Reset() { *m = MacipACLAdd{} } +func (*MacipACLAdd) GetMessageName() string { return "macip_acl_add" } +func (*MacipACLAdd) GetCrcString() string { return "ce6fbad0" } +func (*MacipACLAdd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MacipACLAdd) Size() (size int) { + if m == nil { + return 0 + } + size += 64 // m.Tag + size += 4 // m.Count + for j1 := 0; j1 < len(m.R); j1++ { + var s1 acl_types.MacipACLRule + _ = s1 + if j1 < len(m.R) { + s1 = m.R[j1] + } + size += 1 // s1.IsPermit + size += 1 * 6 // s1.SrcMac + size += 1 * 6 // s1.SrcMacMask + size += 1 // s1.SrcPrefix.Address.Af + size += 1 * 16 // s1.SrcPrefix.Address.Un + size += 1 // s1.SrcPrefix.Len + } + return size +} +func (m *MacipACLAdd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.Tag, 64) + buf.EncodeUint32(uint32(len(m.R))) + for j0 := 0; j0 < len(m.R); j0++ { + var v0 acl_types.MacipACLRule // R + if j0 < len(m.R) { + v0 = m.R[j0] + } + buf.EncodeUint8(uint8(v0.IsPermit)) + buf.EncodeBytes(v0.SrcMac[:], 6) + buf.EncodeBytes(v0.SrcMacMask[:], 6) + buf.EncodeUint8(uint8(v0.SrcPrefix.Address.Af)) + buf.EncodeBytes(v0.SrcPrefix.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(v0.SrcPrefix.Len) + } + return buf.Bytes(), nil +} +func (m *MacipACLAdd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Tag = buf.DecodeString(64) + m.Count = buf.DecodeUint32() + m.R = make([]acl_types.MacipACLRule, m.Count) + for j0 := 0; j0 < len(m.R); j0++ { + m.R[j0].IsPermit = acl_types.ACLAction(buf.DecodeUint8()) + copy(m.R[j0].SrcMac[:], buf.DecodeBytes(6)) + copy(m.R[j0].SrcMacMask[:], buf.DecodeBytes(6)) + m.R[j0].SrcPrefix.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.R[j0].SrcPrefix.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.R[j0].SrcPrefix.Len = buf.DecodeUint8() + } + return nil +} + +// Add/Replace a MACIP ACL +// - acl_index - an existing MACIP ACL entry (0..0xfffffffe) to replace, or 0xffffffff to make new MACIP ACL Default: 0xffffffff +// - tag - descriptive value for this MACIP ACL +// - count - number of rules in this MACIP ACL +// - r - vector of MACIP ACL rules +// +// MacipACLAddReplace defines message 'macip_acl_add_replace'. +type MacipACLAddReplace struct { + ACLIndex uint32 `binapi:"u32,name=acl_index,default=4294967295" json:"acl_index,omitempty"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + R []acl_types.MacipACLRule `binapi:"macip_acl_rule[count],name=r" json:"r,omitempty"` +} + +func (m *MacipACLAddReplace) Reset() { *m = MacipACLAddReplace{} } +func (*MacipACLAddReplace) GetMessageName() string { return "macip_acl_add_replace" } +func (*MacipACLAddReplace) GetCrcString() string { return "2a461dd4" } +func (*MacipACLAddReplace) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MacipACLAddReplace) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ACLIndex + size += 64 // m.Tag + size += 4 // m.Count + for j1 := 0; j1 < len(m.R); j1++ { + var s1 acl_types.MacipACLRule + _ = s1 + if j1 < len(m.R) { + s1 = m.R[j1] + } + size += 1 // s1.IsPermit + size += 1 * 6 // s1.SrcMac + size += 1 * 6 // s1.SrcMacMask + size += 1 // s1.SrcPrefix.Address.Af + size += 1 * 16 // s1.SrcPrefix.Address.Un + size += 1 // s1.SrcPrefix.Len + } + return size +} +func (m *MacipACLAddReplace) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.ACLIndex) + buf.EncodeString(m.Tag, 64) + buf.EncodeUint32(uint32(len(m.R))) + for j0 := 0; j0 < len(m.R); j0++ { + var v0 acl_types.MacipACLRule // R + if j0 < len(m.R) { + v0 = m.R[j0] + } + buf.EncodeUint8(uint8(v0.IsPermit)) + buf.EncodeBytes(v0.SrcMac[:], 6) + buf.EncodeBytes(v0.SrcMacMask[:], 6) + buf.EncodeUint8(uint8(v0.SrcPrefix.Address.Af)) + buf.EncodeBytes(v0.SrcPrefix.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(v0.SrcPrefix.Len) + } + return buf.Bytes(), nil +} +func (m *MacipACLAddReplace) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ACLIndex = buf.DecodeUint32() + m.Tag = buf.DecodeString(64) + m.Count = buf.DecodeUint32() + m.R = make([]acl_types.MacipACLRule, m.Count) + for j0 := 0; j0 < len(m.R); j0++ { + m.R[j0].IsPermit = acl_types.ACLAction(buf.DecodeUint8()) + copy(m.R[j0].SrcMac[:], buf.DecodeBytes(6)) + copy(m.R[j0].SrcMacMask[:], buf.DecodeBytes(6)) + m.R[j0].SrcPrefix.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.R[j0].SrcPrefix.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.R[j0].SrcPrefix.Len = buf.DecodeUint8() + } + return nil +} + +// Reply to add/replace MACIP ACL +// - acl_index - index of the newly created MACIP ACL +// - retval 0 - no error +// +// MacipACLAddReplaceReply defines message 'macip_acl_add_replace_reply'. +type MacipACLAddReplaceReply struct { + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *MacipACLAddReplaceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ACLIndex + size += 4 // m.Retval + return size +} +func (m *MacipACLAddReplaceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.ACLIndex) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MacipACLAddReplaceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ACLIndex = buf.DecodeUint32() + m.Retval = buf.DecodeInt32() + return nil +} + +// Reply to add MACIP ACL +// - acl_index - index of the newly created MACIP ACL +// - retval 0 - no error +// +// MacipACLAddReply defines message 'macip_acl_add_reply'. +type MacipACLAddReply struct { + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *MacipACLAddReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ACLIndex + size += 4 // m.Retval + return size +} +func (m *MacipACLAddReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.ACLIndex) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MacipACLAddReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ACLIndex = buf.DecodeUint32() + m.Retval = buf.DecodeInt32() + return nil +} + +// Delete a MACIP ACL +// - acl_index - MACIP ACL index to delete +// +// MacipACLDel defines message 'macip_acl_del'. +type MacipACLDel struct { + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` +} + +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 +} + +func (m *MacipACLDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ACLIndex + return size +} +func (m *MacipACLDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.ACLIndex) + return buf.Bytes(), nil +} +func (m *MacipACLDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ACLIndex = buf.DecodeUint32() + return nil +} + +// MacipACLDelReply defines message 'macip_acl_del_reply'. +type MacipACLDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *MacipACLDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MacipACLDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MacipACLDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Details about one MACIP ACL +// - acl_index - index of this MACIP ACL +// - tag - descriptive tag which was supplied during the creation +// - count - length of the vector of MACIP ACL rules +// - r - rules comprising this MACIP ACL +// +// MacipACLDetails defines message 'macip_acl_details'. +type MacipACLDetails struct { + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + R []acl_types.MacipACLRule `binapi:"macip_acl_rule[count],name=r" json:"r,omitempty"` +} + +func (m *MacipACLDetails) Reset() { *m = MacipACLDetails{} } +func (*MacipACLDetails) GetMessageName() string { return "macip_acl_details" } +func (*MacipACLDetails) GetCrcString() string { return "27135b59" } +func (*MacipACLDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MacipACLDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ACLIndex + size += 64 // m.Tag + size += 4 // m.Count + for j1 := 0; j1 < len(m.R); j1++ { + var s1 acl_types.MacipACLRule + _ = s1 + if j1 < len(m.R) { + s1 = m.R[j1] + } + size += 1 // s1.IsPermit + size += 1 * 6 // s1.SrcMac + size += 1 * 6 // s1.SrcMacMask + size += 1 // s1.SrcPrefix.Address.Af + size += 1 * 16 // s1.SrcPrefix.Address.Un + size += 1 // s1.SrcPrefix.Len + } + return size +} +func (m *MacipACLDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.ACLIndex) + buf.EncodeString(m.Tag, 64) + buf.EncodeUint32(uint32(len(m.R))) + for j0 := 0; j0 < len(m.R); j0++ { + var v0 acl_types.MacipACLRule // R + if j0 < len(m.R) { + v0 = m.R[j0] + } + buf.EncodeUint8(uint8(v0.IsPermit)) + buf.EncodeBytes(v0.SrcMac[:], 6) + buf.EncodeBytes(v0.SrcMacMask[:], 6) + buf.EncodeUint8(uint8(v0.SrcPrefix.Address.Af)) + buf.EncodeBytes(v0.SrcPrefix.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(v0.SrcPrefix.Len) + } + return buf.Bytes(), nil +} +func (m *MacipACLDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ACLIndex = buf.DecodeUint32() + m.Tag = buf.DecodeString(64) + m.Count = buf.DecodeUint32() + m.R = make([]acl_types.MacipACLRule, m.Count) + for j0 := 0; j0 < len(m.R); j0++ { + m.R[j0].IsPermit = acl_types.ACLAction(buf.DecodeUint8()) + copy(m.R[j0].SrcMac[:], buf.DecodeBytes(6)) + copy(m.R[j0].SrcMacMask[:], buf.DecodeBytes(6)) + m.R[j0].SrcPrefix.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.R[j0].SrcPrefix.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.R[j0].SrcPrefix.Len = buf.DecodeUint8() + } + return nil +} + +// Dump one or all defined MACIP ACLs +// - acl_index - MACIP ACL index or ~0 to dump all MACIP ACLs Default: 0xffffffff +// +// MacipACLDump defines message 'macip_acl_dump'. +type MacipACLDump struct { + ACLIndex uint32 `binapi:"u32,name=acl_index,default=4294967295" json:"acl_index,omitempty"` +} + +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 +} + +func (m *MacipACLDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ACLIndex + return size +} +func (m *MacipACLDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.ACLIndex) + return buf.Bytes(), nil +} +func (m *MacipACLDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ACLIndex = buf.DecodeUint32() + return nil +} + +// Add or delete a MACIP ACL to/from interface +// - is_add - add (1) or delete (0) MACIP ACL from being used on an interface +// - sw_if_index - interface to apply the action to +// - acl_index - MACIP ACL index +// +// MacipACLInterfaceAddDel defines message 'macip_acl_interface_add_del'. +type MacipACLInterfaceAddDel struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` +} + +func (m *MacipACLInterfaceAddDel) Reset() { *m = MacipACLInterfaceAddDel{} } +func (*MacipACLInterfaceAddDel) GetMessageName() string { return "macip_acl_interface_add_del" } +func (*MacipACLInterfaceAddDel) GetCrcString() string { return "4b8690b1" } +func (*MacipACLInterfaceAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MacipACLInterfaceAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.SwIfIndex + size += 4 // m.ACLIndex + return size +} +func (m *MacipACLInterfaceAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.ACLIndex) + return buf.Bytes(), nil +} +func (m *MacipACLInterfaceAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.ACLIndex = buf.DecodeUint32() + return nil +} + +// MacipACLInterfaceAddDelReply defines message 'macip_acl_interface_add_del_reply'. +type MacipACLInterfaceAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *MacipACLInterfaceAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MacipACLInterfaceAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MacipACLInterfaceAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Get the vector of MACIP ACL IDs applied to the interfaces +// MacipACLInterfaceGet defines 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 +} + +func (m *MacipACLInterfaceGet) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *MacipACLInterfaceGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *MacipACLInterfaceGet) Unmarshal(b []byte) error { + return nil +} + +// Reply with the vector of MACIP ACLs by sw_if_index +// - count - total number of elements in the vector +// - acls - the vector of active MACIP ACL indices per sw_if_index +// +// MacipACLInterfaceGetReply defines message 'macip_acl_interface_get_reply'. +type MacipACLInterfaceGetReply struct { + Count uint32 `binapi:"u32,name=count" json:"-"` + Acls []uint32 `binapi:"u32[count],name=acls" json:"acls,omitempty"` +} + +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 +} + +func (m *MacipACLInterfaceGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Count + size += 4 * len(m.Acls) // m.Acls + return size +} +func (m *MacipACLInterfaceGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(len(m.Acls))) + for i := 0; i < len(m.Acls); i++ { + var x uint32 + if i < len(m.Acls) { + x = uint32(m.Acls[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *MacipACLInterfaceGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Count = buf.DecodeUint32() + m.Acls = make([]uint32, m.Count) + for i := 0; i < len(m.Acls); i++ { + m.Acls[i] = buf.DecodeUint32() + } + return nil +} + +// Details about a single MACIP ACL contents +// - sw_if_index - interface for which the list of MACIP ACLs is applied +// - count - total length of acl indices vector +// - acls - the vector of MACIP ACL indices +// +// MacipACLInterfaceListDetails defines message 'macip_acl_interface_list_details'. +type MacipACLInterfaceListDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Count uint8 `binapi:"u8,name=count" json:"-"` + Acls []uint32 `binapi:"u32[count],name=acls" json:"acls,omitempty"` +} + +func (m *MacipACLInterfaceListDetails) Reset() { *m = MacipACLInterfaceListDetails{} } +func (*MacipACLInterfaceListDetails) GetMessageName() string { + return "macip_acl_interface_list_details" +} +func (*MacipACLInterfaceListDetails) GetCrcString() string { return "a0c5d56d" } +func (*MacipACLInterfaceListDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MacipACLInterfaceListDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.Count + size += 4 * len(m.Acls) // m.Acls + return size +} +func (m *MacipACLInterfaceListDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(uint8(len(m.Acls))) + for i := 0; i < len(m.Acls); i++ { + var x uint32 + if i < len(m.Acls) { + x = uint32(m.Acls[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *MacipACLInterfaceListDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Count = buf.DecodeUint8() + m.Acls = make([]uint32, m.Count) + for i := 0; i < len(m.Acls); i++ { + m.Acls[i] = buf.DecodeUint32() + } + return nil +} + +// Dump the list(s) of MACIP ACLs applied to specific or all interfaces +// - sw_if_index - interface to dump the MACIP ACL list for +// +// MacipACLInterfaceListDump defines message 'macip_acl_interface_list_dump'. +type MacipACLInterfaceListDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *MacipACLInterfaceListDump) Reset() { *m = MacipACLInterfaceListDump{} } +func (*MacipACLInterfaceListDump) GetMessageName() string { return "macip_acl_interface_list_dump" } +func (*MacipACLInterfaceListDump) GetCrcString() string { return "f9e6675e" } +func (*MacipACLInterfaceListDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MacipACLInterfaceListDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *MacipACLInterfaceListDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *MacipACLInterfaceListDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +func init() { file_acl_binapi_init() } +func file_acl_binapi_init() { + api.RegisterMessage((*ACLAddReplace)(nil), "acl_add_replace_ee5c2f18") + api.RegisterMessage((*ACLAddReplaceReply)(nil), "acl_add_replace_reply_ac407b0c") + api.RegisterMessage((*ACLDel)(nil), "acl_del_ef34fea4") + api.RegisterMessage((*ACLDelReply)(nil), "acl_del_reply_e8d4e804") + api.RegisterMessage((*ACLDetails)(nil), "acl_details_95babae0") + api.RegisterMessage((*ACLDump)(nil), "acl_dump_ef34fea4") + api.RegisterMessage((*ACLInterfaceAddDel)(nil), "acl_interface_add_del_4b54bebd") + api.RegisterMessage((*ACLInterfaceAddDelReply)(nil), "acl_interface_add_del_reply_e8d4e804") + api.RegisterMessage((*ACLInterfaceEtypeWhitelistDetails)(nil), "acl_interface_etype_whitelist_details_cc2bfded") + api.RegisterMessage((*ACLInterfaceEtypeWhitelistDump)(nil), "acl_interface_etype_whitelist_dump_f9e6675e") + api.RegisterMessage((*ACLInterfaceListDetails)(nil), "acl_interface_list_details_e695d256") + api.RegisterMessage((*ACLInterfaceListDump)(nil), "acl_interface_list_dump_f9e6675e") + api.RegisterMessage((*ACLInterfaceSetACLList)(nil), "acl_interface_set_acl_list_473982bd") + api.RegisterMessage((*ACLInterfaceSetACLListReply)(nil), "acl_interface_set_acl_list_reply_e8d4e804") + api.RegisterMessage((*ACLInterfaceSetEtypeWhitelist)(nil), "acl_interface_set_etype_whitelist_3f5c2d2d") + api.RegisterMessage((*ACLInterfaceSetEtypeWhitelistReply)(nil), "acl_interface_set_etype_whitelist_reply_e8d4e804") + api.RegisterMessage((*ACLPluginControlPing)(nil), "acl_plugin_control_ping_51077d14") + api.RegisterMessage((*ACLPluginControlPingReply)(nil), "acl_plugin_control_ping_reply_f6b0b8ca") + api.RegisterMessage((*ACLPluginGetConnTableMaxEntries)(nil), "acl_plugin_get_conn_table_max_entries_51077d14") + api.RegisterMessage((*ACLPluginGetConnTableMaxEntriesReply)(nil), "acl_plugin_get_conn_table_max_entries_reply_7a096d3d") + api.RegisterMessage((*ACLPluginGetVersion)(nil), "acl_plugin_get_version_51077d14") + api.RegisterMessage((*ACLPluginGetVersionReply)(nil), "acl_plugin_get_version_reply_9b32cf86") + api.RegisterMessage((*ACLPluginUseHashLookupGet)(nil), "acl_plugin_use_hash_lookup_get_51077d14") + api.RegisterMessage((*ACLPluginUseHashLookupGetReply)(nil), "acl_plugin_use_hash_lookup_get_reply_5392ad31") + api.RegisterMessage((*ACLPluginUseHashLookupSet)(nil), "acl_plugin_use_hash_lookup_set_b3e225d2") + api.RegisterMessage((*ACLPluginUseHashLookupSetReply)(nil), "acl_plugin_use_hash_lookup_set_reply_e8d4e804") + api.RegisterMessage((*ACLStatsIntfCountersEnable)(nil), "acl_stats_intf_counters_enable_b3e225d2") + api.RegisterMessage((*ACLStatsIntfCountersEnableReply)(nil), "acl_stats_intf_counters_enable_reply_e8d4e804") + api.RegisterMessage((*MacipACLAdd)(nil), "macip_acl_add_ce6fbad0") + api.RegisterMessage((*MacipACLAddReplace)(nil), "macip_acl_add_replace_2a461dd4") + api.RegisterMessage((*MacipACLAddReplaceReply)(nil), "macip_acl_add_replace_reply_ac407b0c") + api.RegisterMessage((*MacipACLAddReply)(nil), "macip_acl_add_reply_ac407b0c") + api.RegisterMessage((*MacipACLDel)(nil), "macip_acl_del_ef34fea4") + api.RegisterMessage((*MacipACLDelReply)(nil), "macip_acl_del_reply_e8d4e804") + api.RegisterMessage((*MacipACLDetails)(nil), "macip_acl_details_27135b59") + api.RegisterMessage((*MacipACLDump)(nil), "macip_acl_dump_ef34fea4") + api.RegisterMessage((*MacipACLInterfaceAddDel)(nil), "macip_acl_interface_add_del_4b8690b1") + api.RegisterMessage((*MacipACLInterfaceAddDelReply)(nil), "macip_acl_interface_add_del_reply_e8d4e804") + api.RegisterMessage((*MacipACLInterfaceGet)(nil), "macip_acl_interface_get_51077d14") + api.RegisterMessage((*MacipACLInterfaceGetReply)(nil), "macip_acl_interface_get_reply_accf9b05") + api.RegisterMessage((*MacipACLInterfaceListDetails)(nil), "macip_acl_interface_list_details_a0c5d56d") + api.RegisterMessage((*MacipACLInterfaceListDump)(nil), "macip_acl_interface_list_dump_f9e6675e") +} + +// 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), + (*ACLPluginUseHashLookupGet)(nil), + (*ACLPluginUseHashLookupGetReply)(nil), + (*ACLPluginUseHashLookupSet)(nil), + (*ACLPluginUseHashLookupSetReply)(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), + } +} diff --git a/binapi/acl/acl_rpc.ba.go b/binapi/acl/acl_rpc.ba.go new file mode 100644 index 00000000..77ac3050 --- /dev/null +++ b/binapi/acl/acl_rpc.ba.go @@ -0,0 +1,404 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package acl + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service acl. +type RPCService interface { + ACLAddReplace(ctx context.Context, in *ACLAddReplace) (*ACLAddReplaceReply, error) + ACLDel(ctx context.Context, in *ACLDel) (*ACLDelReply, error) + ACLDump(ctx context.Context, in *ACLDump) (RPCService_ACLDumpClient, error) + ACLInterfaceAddDel(ctx context.Context, in *ACLInterfaceAddDel) (*ACLInterfaceAddDelReply, error) + ACLInterfaceEtypeWhitelistDump(ctx context.Context, in *ACLInterfaceEtypeWhitelistDump) (RPCService_ACLInterfaceEtypeWhitelistDumpClient, error) + ACLInterfaceListDump(ctx context.Context, in *ACLInterfaceListDump) (RPCService_ACLInterfaceListDumpClient, 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) + ACLPluginUseHashLookupGet(ctx context.Context, in *ACLPluginUseHashLookupGet) (*ACLPluginUseHashLookupGetReply, error) + ACLPluginUseHashLookupSet(ctx context.Context, in *ACLPluginUseHashLookupSet) (*ACLPluginUseHashLookupSetReply, 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) + MacipACLDump(ctx context.Context, in *MacipACLDump) (RPCService_MacipACLDumpClient, error) + MacipACLInterfaceAddDel(ctx context.Context, in *MacipACLInterfaceAddDel) (*MacipACLInterfaceAddDelReply, error) + MacipACLInterfaceGet(ctx context.Context, in *MacipACLInterfaceGet) (*MacipACLInterfaceGetReply, error) + MacipACLInterfaceListDump(ctx context.Context, in *MacipACLInterfaceListDump) (RPCService_MacipACLInterfaceListDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) ACLAddReplace(ctx context.Context, in *ACLAddReplace) (*ACLAddReplaceReply, error) { + out := new(ACLAddReplaceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ACLDel(ctx context.Context, in *ACLDel) (*ACLDelReply, error) { + out := new(ACLDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ACLDump(ctx context.Context, in *ACLDump) (RPCService_ACLDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_ACLDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_ACLDumpClient interface { + Recv() (*ACLDetails, error) + api.Stream +} + +type serviceClient_ACLDumpClient struct { + api.Stream +} + +func (c *serviceClient_ACLDumpClient) Recv() (*ACLDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *ACLDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) ACLInterfaceAddDel(ctx context.Context, in *ACLInterfaceAddDel) (*ACLInterfaceAddDelReply, error) { + out := new(ACLInterfaceAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ACLInterfaceEtypeWhitelistDump(ctx context.Context, in *ACLInterfaceEtypeWhitelistDump) (RPCService_ACLInterfaceEtypeWhitelistDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_ACLInterfaceEtypeWhitelistDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_ACLInterfaceEtypeWhitelistDumpClient interface { + Recv() (*ACLInterfaceEtypeWhitelistDetails, error) + api.Stream +} + +type serviceClient_ACLInterfaceEtypeWhitelistDumpClient struct { + api.Stream +} + +func (c *serviceClient_ACLInterfaceEtypeWhitelistDumpClient) Recv() (*ACLInterfaceEtypeWhitelistDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *ACLInterfaceEtypeWhitelistDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) ACLInterfaceListDump(ctx context.Context, in *ACLInterfaceListDump) (RPCService_ACLInterfaceListDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_ACLInterfaceListDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_ACLInterfaceListDumpClient interface { + Recv() (*ACLInterfaceListDetails, error) + api.Stream +} + +type serviceClient_ACLInterfaceListDumpClient struct { + api.Stream +} + +func (c *serviceClient_ACLInterfaceListDumpClient) Recv() (*ACLInterfaceListDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *ACLInterfaceListDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) ACLInterfaceSetACLList(ctx context.Context, in *ACLInterfaceSetACLList) (*ACLInterfaceSetACLListReply, error) { + out := new(ACLInterfaceSetACLListReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ACLInterfaceSetEtypeWhitelist(ctx context.Context, in *ACLInterfaceSetEtypeWhitelist) (*ACLInterfaceSetEtypeWhitelistReply, error) { + out := new(ACLInterfaceSetEtypeWhitelistReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ACLPluginControlPing(ctx context.Context, in *ACLPluginControlPing) (*ACLPluginControlPingReply, error) { + out := new(ACLPluginControlPingReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ACLPluginGetConnTableMaxEntries(ctx context.Context, in *ACLPluginGetConnTableMaxEntries) (*ACLPluginGetConnTableMaxEntriesReply, error) { + out := new(ACLPluginGetConnTableMaxEntriesReply) + err := c.conn.Invoke(ctx, in, 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.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) ACLPluginUseHashLookupGet(ctx context.Context, in *ACLPluginUseHashLookupGet) (*ACLPluginUseHashLookupGetReply, error) { + out := new(ACLPluginUseHashLookupGetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) ACLPluginUseHashLookupSet(ctx context.Context, in *ACLPluginUseHashLookupSet) (*ACLPluginUseHashLookupSetReply, error) { + out := new(ACLPluginUseHashLookupSetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ACLStatsIntfCountersEnable(ctx context.Context, in *ACLStatsIntfCountersEnable) (*ACLStatsIntfCountersEnableReply, error) { + out := new(ACLStatsIntfCountersEnableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MacipACLAdd(ctx context.Context, in *MacipACLAdd) (*MacipACLAddReply, error) { + out := new(MacipACLAddReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MacipACLAddReplace(ctx context.Context, in *MacipACLAddReplace) (*MacipACLAddReplaceReply, error) { + out := new(MacipACLAddReplaceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MacipACLDel(ctx context.Context, in *MacipACLDel) (*MacipACLDelReply, error) { + out := new(MacipACLDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MacipACLDump(ctx context.Context, in *MacipACLDump) (RPCService_MacipACLDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_MacipACLDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_MacipACLDumpClient interface { + Recv() (*MacipACLDetails, error) + api.Stream +} + +type serviceClient_MacipACLDumpClient struct { + api.Stream +} + +func (c *serviceClient_MacipACLDumpClient) Recv() (*MacipACLDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *MacipACLDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) MacipACLInterfaceAddDel(ctx context.Context, in *MacipACLInterfaceAddDel) (*MacipACLInterfaceAddDelReply, error) { + out := new(MacipACLInterfaceAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MacipACLInterfaceGet(ctx context.Context, in *MacipACLInterfaceGet) (*MacipACLInterfaceGetReply, error) { + out := new(MacipACLInterfaceGetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) MacipACLInterfaceListDump(ctx context.Context, in *MacipACLInterfaceListDump) (RPCService_MacipACLInterfaceListDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_MacipACLInterfaceListDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_MacipACLInterfaceListDumpClient interface { + Recv() (*MacipACLInterfaceListDetails, error) + api.Stream +} + +type serviceClient_MacipACLInterfaceListDumpClient struct { + api.Stream +} + +func (c *serviceClient_MacipACLInterfaceListDumpClient) Recv() (*MacipACLInterfaceListDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *MacipACLInterfaceListDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/acl_types/acl_types.ba.go b/binapi/acl_types/acl_types.ba.go new file mode 100644 index 00000000..31d0d51d --- /dev/null +++ b/binapi/acl_types/acl_types.ba.go @@ -0,0 +1,84 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/acl_types.api.json + +// Package acl_types contains generated bindings for API file acl_types.api. +// +// Contents: +// - 1 enum +// - 2 structs +package acl_types + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + ethernet_types "github.com/alkiranet/govpp/binapi/ethernet_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "acl_types" + APIVersion = "1.0.0" + VersionCrc = 0x878da4fa +) + +// ACLAction defines enum 'acl_action'. +type ACLAction uint8 + +const ( + ACL_ACTION_API_DENY ACLAction = 0 + ACL_ACTION_API_PERMIT ACLAction = 1 + ACL_ACTION_API_PERMIT_REFLECT ACLAction = 2 +) + +var ( + ACLAction_name = map[uint8]string{ + 0: "ACL_ACTION_API_DENY", + 1: "ACL_ACTION_API_PERMIT", + 2: "ACL_ACTION_API_PERMIT_REFLECT", + } + ACLAction_value = map[string]uint8{ + "ACL_ACTION_API_DENY": 0, + "ACL_ACTION_API_PERMIT": 1, + "ACL_ACTION_API_PERMIT_REFLECT": 2, + } +) + +func (x ACLAction) String() string { + s, ok := ACLAction_name[uint8(x)] + if ok { + return s + } + return "ACLAction(" + strconv.Itoa(int(x)) + ")" +} + +// ACLRule defines type 'acl_rule'. +type ACLRule struct { + IsPermit ACLAction `binapi:"acl_action,name=is_permit" json:"is_permit,omitempty"` + SrcPrefix ip_types.Prefix `binapi:"prefix,name=src_prefix" json:"src_prefix,omitempty"` + DstPrefix ip_types.Prefix `binapi:"prefix,name=dst_prefix" json:"dst_prefix,omitempty"` + Proto ip_types.IPProto `binapi:"ip_proto,name=proto" json:"proto,omitempty"` + SrcportOrIcmptypeFirst uint16 `binapi:"u16,name=srcport_or_icmptype_first" json:"srcport_or_icmptype_first,omitempty"` + SrcportOrIcmptypeLast uint16 `binapi:"u16,name=srcport_or_icmptype_last" json:"srcport_or_icmptype_last,omitempty"` + DstportOrIcmpcodeFirst uint16 `binapi:"u16,name=dstport_or_icmpcode_first" json:"dstport_or_icmpcode_first,omitempty"` + DstportOrIcmpcodeLast uint16 `binapi:"u16,name=dstport_or_icmpcode_last" json:"dstport_or_icmpcode_last,omitempty"` + TCPFlagsMask uint8 `binapi:"u8,name=tcp_flags_mask" json:"tcp_flags_mask,omitempty"` + TCPFlagsValue uint8 `binapi:"u8,name=tcp_flags_value" json:"tcp_flags_value,omitempty"` +} + +// MacipACLRule defines type 'macip_acl_rule'. +type MacipACLRule struct { + IsPermit ACLAction `binapi:"acl_action,name=is_permit" json:"is_permit,omitempty"` + SrcMac ethernet_types.MacAddress `binapi:"mac_address,name=src_mac" json:"src_mac,omitempty"` + SrcMacMask ethernet_types.MacAddress `binapi:"mac_address,name=src_mac_mask" json:"src_mac_mask,omitempty"` + SrcPrefix ip_types.Prefix `binapi:"prefix,name=src_prefix" json:"src_prefix,omitempty"` +} diff --git a/binapi/adl/adl.ba.go b/binapi/adl/adl.ba.go new file mode 100644 index 00000000..46fc6edb --- /dev/null +++ b/binapi/adl/adl.ba.go @@ -0,0 +1,217 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/adl.api.json + +// Package adl contains generated bindings for API file adl.api. +// +// Contents: +// - 4 messages +package adl + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "adl" + APIVersion = "0.0.1" + VersionCrc = 0xb752b7a2 +) + +// adl: enable/disable allow list filtration features on an interface +// +// Note: the supplied fib_id must match in order to remove the feature! +// - sw_if_index - interface handle, physical interfaces only +// - fib_id - fib identifier for the allow/deny fib +// - ip4 - 1 => enable ip4 filtration, 0=> disable ip4 filtration +// - ip6 - 1 => enable ip6 filtration, 0=> disable ip6 filtration +// - default_adl - 1 => enable non-ip4, non-ip6 filtration +// 0 => disable it +// +// AdlAllowlistEnableDisable defines message 'adl_allowlist_enable_disable'. +type AdlAllowlistEnableDisable struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + FibID uint32 `binapi:"u32,name=fib_id" json:"fib_id,omitempty"` + IP4 bool `binapi:"bool,name=ip4" json:"ip4,omitempty"` + IP6 bool `binapi:"bool,name=ip6" json:"ip6,omitempty"` + DefaultAdl bool `binapi:"bool,name=default_adl" json:"default_adl,omitempty"` +} + +func (m *AdlAllowlistEnableDisable) Reset() { *m = AdlAllowlistEnableDisable{} } +func (*AdlAllowlistEnableDisable) GetMessageName() string { return "adl_allowlist_enable_disable" } +func (*AdlAllowlistEnableDisable) GetCrcString() string { return "ea88828d" } +func (*AdlAllowlistEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *AdlAllowlistEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.FibID + size += 1 // m.IP4 + size += 1 // m.IP6 + size += 1 // m.DefaultAdl + return size +} +func (m *AdlAllowlistEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.FibID) + buf.EncodeBool(m.IP4) + buf.EncodeBool(m.IP6) + buf.EncodeBool(m.DefaultAdl) + return buf.Bytes(), nil +} +func (m *AdlAllowlistEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.FibID = buf.DecodeUint32() + m.IP4 = buf.DecodeBool() + m.IP6 = buf.DecodeBool() + m.DefaultAdl = buf.DecodeBool() + return nil +} + +// AdlAllowlistEnableDisableReply defines message 'adl_allowlist_enable_disable_reply'. +type AdlAllowlistEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *AdlAllowlistEnableDisableReply) Reset() { *m = AdlAllowlistEnableDisableReply{} } +func (*AdlAllowlistEnableDisableReply) GetMessageName() string { + return "adl_allowlist_enable_disable_reply" +} +func (*AdlAllowlistEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*AdlAllowlistEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *AdlAllowlistEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *AdlAllowlistEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *AdlAllowlistEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// adl: enable/disable filtration features on an interface +// - sw_if_inded - desired interface +// - enable_disable - 1 => enable, 0 => disable +// +// AdlInterfaceEnableDisable defines message 'adl_interface_enable_disable'. +type AdlInterfaceEnableDisable struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + EnableDisable bool `binapi:"bool,name=enable_disable" json:"enable_disable,omitempty"` +} + +func (m *AdlInterfaceEnableDisable) Reset() { *m = AdlInterfaceEnableDisable{} } +func (*AdlInterfaceEnableDisable) GetMessageName() string { return "adl_interface_enable_disable" } +func (*AdlInterfaceEnableDisable) GetCrcString() string { return "5501adee" } +func (*AdlInterfaceEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *AdlInterfaceEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.EnableDisable + return size +} +func (m *AdlInterfaceEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.EnableDisable) + return buf.Bytes(), nil +} +func (m *AdlInterfaceEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.EnableDisable = buf.DecodeBool() + return nil +} + +// AdlInterfaceEnableDisableReply defines message 'adl_interface_enable_disable_reply'. +type AdlInterfaceEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *AdlInterfaceEnableDisableReply) Reset() { *m = AdlInterfaceEnableDisableReply{} } +func (*AdlInterfaceEnableDisableReply) GetMessageName() string { + return "adl_interface_enable_disable_reply" +} +func (*AdlInterfaceEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*AdlInterfaceEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *AdlInterfaceEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *AdlInterfaceEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *AdlInterfaceEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_adl_binapi_init() } +func file_adl_binapi_init() { + api.RegisterMessage((*AdlAllowlistEnableDisable)(nil), "adl_allowlist_enable_disable_ea88828d") + api.RegisterMessage((*AdlAllowlistEnableDisableReply)(nil), "adl_allowlist_enable_disable_reply_e8d4e804") + api.RegisterMessage((*AdlInterfaceEnableDisable)(nil), "adl_interface_enable_disable_5501adee") + api.RegisterMessage((*AdlInterfaceEnableDisableReply)(nil), "adl_interface_enable_disable_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*AdlAllowlistEnableDisable)(nil), + (*AdlAllowlistEnableDisableReply)(nil), + (*AdlInterfaceEnableDisable)(nil), + (*AdlInterfaceEnableDisableReply)(nil), + } +} diff --git a/binapi/adl/adl_rpc.ba.go b/binapi/adl/adl_rpc.ba.go new file mode 100644 index 00000000..4b9e1951 --- /dev/null +++ b/binapi/adl/adl_rpc.ba.go @@ -0,0 +1,41 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package adl + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service adl. +type RPCService interface { + AdlAllowlistEnableDisable(ctx context.Context, in *AdlAllowlistEnableDisable) (*AdlAllowlistEnableDisableReply, error) + AdlInterfaceEnableDisable(ctx context.Context, in *AdlInterfaceEnableDisable) (*AdlInterfaceEnableDisableReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) AdlAllowlistEnableDisable(ctx context.Context, in *AdlAllowlistEnableDisable) (*AdlAllowlistEnableDisableReply, error) { + out := new(AdlAllowlistEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) AdlInterfaceEnableDisable(ctx context.Context, in *AdlInterfaceEnableDisable) (*AdlInterfaceEnableDisableReply, error) { + out := new(AdlInterfaceEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/af_packet/af_packet.ba.go b/binapi/af_packet/af_packet.ba.go new file mode 100644 index 00000000..5ea5ac14 --- /dev/null +++ b/binapi/af_packet/af_packet.ba.go @@ -0,0 +1,682 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/af_packet.api.json + +// Package af_packet contains generated bindings for API file af_packet.api. +// +// Contents: +// - 2 enums +// - 12 messages +package af_packet + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + ethernet_types "github.com/alkiranet/govpp/binapi/ethernet_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "af_packet" + APIVersion = "2.0.0" + VersionCrc = 0x5b12de21 +) + +// AfPacketFlags defines enum 'af_packet_flags'. +type AfPacketFlags uint32 + +const ( + AF_PACKET_API_FLAG_QDISC_BYPASS AfPacketFlags = 1 + AF_PACKET_API_FLAG_CKSUM_GSO AfPacketFlags = 2 + AF_PACKET_API_FLAG_VERSION_2 AfPacketFlags = 8 +) + +var ( + AfPacketFlags_name = map[uint32]string{ + 1: "AF_PACKET_API_FLAG_QDISC_BYPASS", + 2: "AF_PACKET_API_FLAG_CKSUM_GSO", + 8: "AF_PACKET_API_FLAG_VERSION_2", + } + AfPacketFlags_value = map[string]uint32{ + "AF_PACKET_API_FLAG_QDISC_BYPASS": 1, + "AF_PACKET_API_FLAG_CKSUM_GSO": 2, + "AF_PACKET_API_FLAG_VERSION_2": 8, + } +) + +func (x AfPacketFlags) String() string { + s, ok := AfPacketFlags_name[uint32(x)] + if ok { + return s + } + str := func(n uint32) string { + s, ok := AfPacketFlags_name[uint32(n)] + if ok { + return s + } + return "AfPacketFlags(" + strconv.Itoa(int(n)) + ")" + } + for i := uint32(0); i <= 32; i++ { + val := uint32(x) + if val&(1< register for events, 0 => cancel registration +// - pid - sender's pid +// +// WantBfdEvents defines message 'want_bfd_events'. +type WantBfdEvents struct { + EnableDisable bool `binapi:"bool,name=enable_disable" json:"enable_disable,omitempty"` + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` +} + +func (m *WantBfdEvents) Reset() { *m = WantBfdEvents{} } +func (*WantBfdEvents) GetMessageName() string { return "want_bfd_events" } +func (*WantBfdEvents) GetCrcString() string { return "c5e2af94" } +func (*WantBfdEvents) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *WantBfdEvents) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.EnableDisable + size += 4 // m.PID + return size +} +func (m *WantBfdEvents) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.EnableDisable) + buf.EncodeUint32(m.PID) + return buf.Bytes(), nil +} +func (m *WantBfdEvents) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EnableDisable = buf.DecodeBool() + m.PID = buf.DecodeUint32() + return nil +} + +// WantBfdEventsReply defines message 'want_bfd_events_reply'. +type WantBfdEventsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *WantBfdEventsReply) Reset() { *m = WantBfdEventsReply{} } +func (*WantBfdEventsReply) GetMessageName() string { return "want_bfd_events_reply" } +func (*WantBfdEventsReply) GetCrcString() string { return "e8d4e804" } +func (*WantBfdEventsReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *WantBfdEventsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *WantBfdEventsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *WantBfdEventsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_bfd_binapi_init() } +func file_bfd_binapi_init() { + api.RegisterMessage((*BfdAuthDelKey)(nil), "bfd_auth_del_key_65310b22") + api.RegisterMessage((*BfdAuthDelKeyReply)(nil), "bfd_auth_del_key_reply_e8d4e804") + api.RegisterMessage((*BfdAuthKeysDetails)(nil), "bfd_auth_keys_details_84130e9f") + api.RegisterMessage((*BfdAuthKeysDump)(nil), "bfd_auth_keys_dump_51077d14") + api.RegisterMessage((*BfdAuthSetKey)(nil), "bfd_auth_set_key_690b8877") + api.RegisterMessage((*BfdAuthSetKeyReply)(nil), "bfd_auth_set_key_reply_e8d4e804") + api.RegisterMessage((*BfdUDPAdd)(nil), "bfd_udp_add_939cd26a") + api.RegisterMessage((*BfdUDPAddReply)(nil), "bfd_udp_add_reply_e8d4e804") + api.RegisterMessage((*BfdUDPAuthActivate)(nil), "bfd_udp_auth_activate_21fd1bdb") + api.RegisterMessage((*BfdUDPAuthActivateReply)(nil), "bfd_udp_auth_activate_reply_e8d4e804") + api.RegisterMessage((*BfdUDPAuthDeactivate)(nil), "bfd_udp_auth_deactivate_9a05e2e0") + api.RegisterMessage((*BfdUDPAuthDeactivateReply)(nil), "bfd_udp_auth_deactivate_reply_e8d4e804") + api.RegisterMessage((*BfdUDPDel)(nil), "bfd_udp_del_dcb13a89") + api.RegisterMessage((*BfdUDPDelEchoSource)(nil), "bfd_udp_del_echo_source_51077d14") + api.RegisterMessage((*BfdUDPDelEchoSourceReply)(nil), "bfd_udp_del_echo_source_reply_e8d4e804") + api.RegisterMessage((*BfdUDPDelReply)(nil), "bfd_udp_del_reply_e8d4e804") + api.RegisterMessage((*BfdUDPGetEchoSource)(nil), "bfd_udp_get_echo_source_51077d14") + api.RegisterMessage((*BfdUDPGetEchoSourceReply)(nil), "bfd_udp_get_echo_source_reply_e3d736a1") + api.RegisterMessage((*BfdUDPMod)(nil), "bfd_udp_mod_913df085") + api.RegisterMessage((*BfdUDPModReply)(nil), "bfd_udp_mod_reply_e8d4e804") + api.RegisterMessage((*BfdUDPSessionDetails)(nil), "bfd_udp_session_details_09fb2f2d") + api.RegisterMessage((*BfdUDPSessionDump)(nil), "bfd_udp_session_dump_51077d14") + api.RegisterMessage((*BfdUDPSessionEvent)(nil), "bfd_udp_session_event_8eaaf062") + api.RegisterMessage((*BfdUDPSessionSetFlags)(nil), "bfd_udp_session_set_flags_04b4bdfd") + api.RegisterMessage((*BfdUDPSessionSetFlagsReply)(nil), "bfd_udp_session_set_flags_reply_e8d4e804") + api.RegisterMessage((*BfdUDPSetEchoSource)(nil), "bfd_udp_set_echo_source_f9e6675e") + api.RegisterMessage((*BfdUDPSetEchoSourceReply)(nil), "bfd_udp_set_echo_source_reply_e8d4e804") + api.RegisterMessage((*BfdUDPUpd)(nil), "bfd_udp_upd_939cd26a") + api.RegisterMessage((*BfdUDPUpdReply)(nil), "bfd_udp_upd_reply_1992deab") + api.RegisterMessage((*WantBfdEvents)(nil), "want_bfd_events_c5e2af94") + api.RegisterMessage((*WantBfdEventsReply)(nil), "want_bfd_events_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*BfdAuthDelKey)(nil), + (*BfdAuthDelKeyReply)(nil), + (*BfdAuthKeysDetails)(nil), + (*BfdAuthKeysDump)(nil), + (*BfdAuthSetKey)(nil), + (*BfdAuthSetKeyReply)(nil), + (*BfdUDPAdd)(nil), + (*BfdUDPAddReply)(nil), + (*BfdUDPAuthActivate)(nil), + (*BfdUDPAuthActivateReply)(nil), + (*BfdUDPAuthDeactivate)(nil), + (*BfdUDPAuthDeactivateReply)(nil), + (*BfdUDPDel)(nil), + (*BfdUDPDelEchoSource)(nil), + (*BfdUDPDelEchoSourceReply)(nil), + (*BfdUDPDelReply)(nil), + (*BfdUDPGetEchoSource)(nil), + (*BfdUDPGetEchoSourceReply)(nil), + (*BfdUDPMod)(nil), + (*BfdUDPModReply)(nil), + (*BfdUDPSessionDetails)(nil), + (*BfdUDPSessionDump)(nil), + (*BfdUDPSessionEvent)(nil), + (*BfdUDPSessionSetFlags)(nil), + (*BfdUDPSessionSetFlagsReply)(nil), + (*BfdUDPSetEchoSource)(nil), + (*BfdUDPSetEchoSourceReply)(nil), + (*BfdUDPUpd)(nil), + (*BfdUDPUpdReply)(nil), + (*WantBfdEvents)(nil), + (*WantBfdEventsReply)(nil), + } +} diff --git a/binapi/bfd/bfd_rpc.ba.go b/binapi/bfd/bfd_rpc.ba.go new file mode 100644 index 00000000..3a4d6b06 --- /dev/null +++ b/binapi/bfd/bfd_rpc.ba.go @@ -0,0 +1,242 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package bfd + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service bfd. +type RPCService interface { + BfdAuthDelKey(ctx context.Context, in *BfdAuthDelKey) (*BfdAuthDelKeyReply, error) + BfdAuthKeysDump(ctx context.Context, in *BfdAuthKeysDump) (RPCService_BfdAuthKeysDumpClient, error) + BfdAuthSetKey(ctx context.Context, in *BfdAuthSetKey) (*BfdAuthSetKeyReply, error) + BfdUDPAdd(ctx context.Context, in *BfdUDPAdd) (*BfdUDPAddReply, error) + BfdUDPAuthActivate(ctx context.Context, in *BfdUDPAuthActivate) (*BfdUDPAuthActivateReply, error) + BfdUDPAuthDeactivate(ctx context.Context, in *BfdUDPAuthDeactivate) (*BfdUDPAuthDeactivateReply, error) + BfdUDPDel(ctx context.Context, in *BfdUDPDel) (*BfdUDPDelReply, error) + BfdUDPDelEchoSource(ctx context.Context, in *BfdUDPDelEchoSource) (*BfdUDPDelEchoSourceReply, error) + BfdUDPGetEchoSource(ctx context.Context, in *BfdUDPGetEchoSource) (*BfdUDPGetEchoSourceReply, error) + BfdUDPMod(ctx context.Context, in *BfdUDPMod) (*BfdUDPModReply, error) + BfdUDPSessionDump(ctx context.Context, in *BfdUDPSessionDump) (RPCService_BfdUDPSessionDumpClient, error) + BfdUDPSessionSetFlags(ctx context.Context, in *BfdUDPSessionSetFlags) (*BfdUDPSessionSetFlagsReply, error) + BfdUDPSetEchoSource(ctx context.Context, in *BfdUDPSetEchoSource) (*BfdUDPSetEchoSourceReply, error) + BfdUDPUpd(ctx context.Context, in *BfdUDPUpd) (*BfdUDPUpdReply, error) + WantBfdEvents(ctx context.Context, in *WantBfdEvents) (*WantBfdEventsReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) BfdAuthDelKey(ctx context.Context, in *BfdAuthDelKey) (*BfdAuthDelKeyReply, error) { + out := new(BfdAuthDelKeyReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BfdAuthKeysDump(ctx context.Context, in *BfdAuthKeysDump) (RPCService_BfdAuthKeysDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_BfdAuthKeysDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_BfdAuthKeysDumpClient interface { + Recv() (*BfdAuthKeysDetails, error) + api.Stream +} + +type serviceClient_BfdAuthKeysDumpClient struct { + api.Stream +} + +func (c *serviceClient_BfdAuthKeysDumpClient) Recv() (*BfdAuthKeysDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *BfdAuthKeysDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) BfdAuthSetKey(ctx context.Context, in *BfdAuthSetKey) (*BfdAuthSetKeyReply, error) { + out := new(BfdAuthSetKeyReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BfdUDPAdd(ctx context.Context, in *BfdUDPAdd) (*BfdUDPAddReply, error) { + out := new(BfdUDPAddReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BfdUDPAuthActivate(ctx context.Context, in *BfdUDPAuthActivate) (*BfdUDPAuthActivateReply, error) { + out := new(BfdUDPAuthActivateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BfdUDPAuthDeactivate(ctx context.Context, in *BfdUDPAuthDeactivate) (*BfdUDPAuthDeactivateReply, error) { + out := new(BfdUDPAuthDeactivateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BfdUDPDel(ctx context.Context, in *BfdUDPDel) (*BfdUDPDelReply, error) { + out := new(BfdUDPDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BfdUDPDelEchoSource(ctx context.Context, in *BfdUDPDelEchoSource) (*BfdUDPDelEchoSourceReply, error) { + out := new(BfdUDPDelEchoSourceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BfdUDPGetEchoSource(ctx context.Context, in *BfdUDPGetEchoSource) (*BfdUDPGetEchoSourceReply, error) { + out := new(BfdUDPGetEchoSourceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BfdUDPMod(ctx context.Context, in *BfdUDPMod) (*BfdUDPModReply, error) { + out := new(BfdUDPModReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BfdUDPSessionDump(ctx context.Context, in *BfdUDPSessionDump) (RPCService_BfdUDPSessionDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_BfdUDPSessionDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_BfdUDPSessionDumpClient interface { + Recv() (*BfdUDPSessionDetails, error) + api.Stream +} + +type serviceClient_BfdUDPSessionDumpClient struct { + api.Stream +} + +func (c *serviceClient_BfdUDPSessionDumpClient) Recv() (*BfdUDPSessionDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *BfdUDPSessionDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) BfdUDPSessionSetFlags(ctx context.Context, in *BfdUDPSessionSetFlags) (*BfdUDPSessionSetFlagsReply, error) { + out := new(BfdUDPSessionSetFlagsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BfdUDPSetEchoSource(ctx context.Context, in *BfdUDPSetEchoSource) (*BfdUDPSetEchoSourceReply, error) { + out := new(BfdUDPSetEchoSourceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BfdUDPUpd(ctx context.Context, in *BfdUDPUpd) (*BfdUDPUpdReply, error) { + out := new(BfdUDPUpdReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WantBfdEvents(ctx context.Context, in *WantBfdEvents) (*WantBfdEventsReply, error) { + out := new(WantBfdEventsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/bier/bier.ba.go b/binapi/bier/bier.ba.go new file mode 100644 index 00000000..2698865d --- /dev/null +++ b/binapi/bier/bier.ba.go @@ -0,0 +1,1289 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/bier.api.json + +// Package bier contains generated bindings for API file bier.api. +// +// Contents: +// - 2 structs +// - 22 messages +package bier + +import ( + api "github.com/alkiranet/govpp/api" + fib_types "github.com/alkiranet/govpp/binapi/fib_types" + _ "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "bier" + APIVersion = "1.2.1" + VersionCrc = 0x8d1cd497 +) + +// BierRoute defines type 'bier_route'. +type BierRoute struct { + BrBp uint32 `binapi:"u32,name=br_bp" json:"br_bp,omitempty"` + BrTblID BierTableID `binapi:"bier_table_id,name=br_tbl_id" json:"br_tbl_id,omitempty"` + BrNPaths uint8 `binapi:"u8,name=br_n_paths" json:"-"` + BrPaths []fib_types.FibPath `binapi:"fib_path[br_n_paths],name=br_paths" json:"br_paths,omitempty"` +} + +// BierTableID defines type 'bier_table_id'. +type BierTableID struct { + BtSet uint8 `binapi:"u8,name=bt_set" json:"bt_set,omitempty"` + BtSubDomain uint8 `binapi:"u8,name=bt_sub_domain" json:"bt_sub_domain,omitempty"` + BtHdrLenID uint8 `binapi:"u8,name=bt_hdr_len_id" json:"bt_hdr_len_id,omitempty"` +} + +// BIER Disposition Entry Add / del +// - bde_bp - The Bit-position value for the entry, i.e. the sender's +// Use 0 for the default (match any source) entry. +// - bde_tbl_id - The BIER disposition table-id the route is added in +// - bde_next_hop_sw_if_index - the next hop interface +// - bde_is_add - Is this a route add or delete +// - bde_payload_proto - The payload protocol for which the next-hop +// is added +// - bde_paths - The outgoing paths for the entry +// +// BierDispEntryAddDel defines message 'bier_disp_entry_add_del'. +type BierDispEntryAddDel struct { + BdeBp uint16 `binapi:"u16,name=bde_bp" json:"bde_bp,omitempty"` + BdeTblID uint32 `binapi:"u32,name=bde_tbl_id" json:"bde_tbl_id,omitempty"` + BdeIsAdd bool `binapi:"bool,name=bde_is_add" json:"bde_is_add,omitempty"` + BdePayloadProto uint8 `binapi:"u8,name=bde_payload_proto" json:"bde_payload_proto,omitempty"` + BdeNPaths uint8 `binapi:"u8,name=bde_n_paths" json:"-"` + BdePaths []fib_types.FibPath `binapi:"fib_path[bde_n_paths],name=bde_paths" json:"bde_paths,omitempty"` +} + +func (m *BierDispEntryAddDel) Reset() { *m = BierDispEntryAddDel{} } +func (*BierDispEntryAddDel) GetMessageName() string { return "bier_disp_entry_add_del" } +func (*BierDispEntryAddDel) GetCrcString() string { return "9eb80cb4" } +func (*BierDispEntryAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BierDispEntryAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 2 // m.BdeBp + size += 4 // m.BdeTblID + size += 1 // m.BdeIsAdd + size += 1 // m.BdePayloadProto + size += 1 // m.BdeNPaths + for j1 := 0; j1 < len(m.BdePaths); j1++ { + var s1 fib_types.FibPath + _ = s1 + if j1 < len(m.BdePaths) { + s1 = m.BdePaths[j1] + } + size += 4 // s1.SwIfIndex + size += 4 // s1.TableID + size += 4 // s1.RpfID + size += 1 // s1.Weight + size += 1 // s1.Preference + size += 4 // s1.Type + size += 4 // s1.Flags + size += 4 // s1.Proto + size += 1 * 16 // s1.Nh.Address + size += 4 // s1.Nh.ViaLabel + size += 4 // s1.Nh.ObjID + size += 4 // s1.Nh.ClassifyTableIndex + size += 1 // s1.NLabels + for j2 := 0; j2 < 16; j2++ { + size += 1 // s1.LabelStack[j2].IsUniform + size += 4 // s1.LabelStack[j2].Label + size += 1 // s1.LabelStack[j2].TTL + size += 1 // s1.LabelStack[j2].Exp + } + } + return size +} +func (m *BierDispEntryAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint16(m.BdeBp) + buf.EncodeUint32(m.BdeTblID) + buf.EncodeBool(m.BdeIsAdd) + buf.EncodeUint8(m.BdePayloadProto) + buf.EncodeUint8(uint8(len(m.BdePaths))) + for j0 := 0; j0 < len(m.BdePaths); j0++ { + var v0 fib_types.FibPath // BdePaths + if j0 < len(m.BdePaths) { + v0 = m.BdePaths[j0] + } + buf.EncodeUint32(v0.SwIfIndex) + buf.EncodeUint32(v0.TableID) + buf.EncodeUint32(v0.RpfID) + buf.EncodeUint8(v0.Weight) + buf.EncodeUint8(v0.Preference) + buf.EncodeUint32(uint32(v0.Type)) + buf.EncodeUint32(uint32(v0.Flags)) + buf.EncodeUint32(uint32(v0.Proto)) + buf.EncodeBytes(v0.Nh.Address.XXX_UnionData[:], 16) + buf.EncodeUint32(v0.Nh.ViaLabel) + buf.EncodeUint32(v0.Nh.ObjID) + buf.EncodeUint32(v0.Nh.ClassifyTableIndex) + buf.EncodeUint8(v0.NLabels) + for j1 := 0; j1 < 16; j1++ { + buf.EncodeUint8(v0.LabelStack[j1].IsUniform) + buf.EncodeUint32(v0.LabelStack[j1].Label) + buf.EncodeUint8(v0.LabelStack[j1].TTL) + buf.EncodeUint8(v0.LabelStack[j1].Exp) + } + } + return buf.Bytes(), nil +} +func (m *BierDispEntryAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BdeBp = buf.DecodeUint16() + m.BdeTblID = buf.DecodeUint32() + m.BdeIsAdd = buf.DecodeBool() + m.BdePayloadProto = buf.DecodeUint8() + m.BdeNPaths = buf.DecodeUint8() + m.BdePaths = make([]fib_types.FibPath, m.BdeNPaths) + for j0 := 0; j0 < len(m.BdePaths); j0++ { + m.BdePaths[j0].SwIfIndex = buf.DecodeUint32() + m.BdePaths[j0].TableID = buf.DecodeUint32() + m.BdePaths[j0].RpfID = buf.DecodeUint32() + m.BdePaths[j0].Weight = buf.DecodeUint8() + m.BdePaths[j0].Preference = buf.DecodeUint8() + m.BdePaths[j0].Type = fib_types.FibPathType(buf.DecodeUint32()) + m.BdePaths[j0].Flags = fib_types.FibPathFlags(buf.DecodeUint32()) + m.BdePaths[j0].Proto = fib_types.FibPathNhProto(buf.DecodeUint32()) + copy(m.BdePaths[j0].Nh.Address.XXX_UnionData[:], buf.DecodeBytes(16)) + m.BdePaths[j0].Nh.ViaLabel = buf.DecodeUint32() + m.BdePaths[j0].Nh.ObjID = buf.DecodeUint32() + m.BdePaths[j0].Nh.ClassifyTableIndex = buf.DecodeUint32() + m.BdePaths[j0].NLabels = buf.DecodeUint8() + for j1 := 0; j1 < 16; j1++ { + m.BdePaths[j0].LabelStack[j1].IsUniform = buf.DecodeUint8() + m.BdePaths[j0].LabelStack[j1].Label = buf.DecodeUint32() + m.BdePaths[j0].LabelStack[j1].TTL = buf.DecodeUint8() + m.BdePaths[j0].LabelStack[j1].Exp = buf.DecodeUint8() + } + } + return nil +} + +// BierDispEntryAddDelReply defines message 'bier_disp_entry_add_del_reply'. +type BierDispEntryAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *BierDispEntryAddDelReply) Reset() { *m = BierDispEntryAddDelReply{} } +func (*BierDispEntryAddDelReply) GetMessageName() string { return "bier_disp_entry_add_del_reply" } +func (*BierDispEntryAddDelReply) GetCrcString() string { return "e8d4e804" } +func (*BierDispEntryAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BierDispEntryAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *BierDispEntryAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *BierDispEntryAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// BierDispEntryDetails defines message 'bier_disp_entry_details'. +type BierDispEntryDetails struct { + BdeBp uint16 `binapi:"u16,name=bde_bp" json:"bde_bp,omitempty"` + BdeTblID uint32 `binapi:"u32,name=bde_tbl_id" json:"bde_tbl_id,omitempty"` + BdeIsAdd bool `binapi:"bool,name=bde_is_add" json:"bde_is_add,omitempty"` + BdePayloadProto uint8 `binapi:"u8,name=bde_payload_proto" json:"bde_payload_proto,omitempty"` + BdeNPaths uint8 `binapi:"u8,name=bde_n_paths" json:"-"` + BdePaths []fib_types.FibPath `binapi:"fib_path[bde_n_paths],name=bde_paths" json:"bde_paths,omitempty"` +} + +func (m *BierDispEntryDetails) Reset() { *m = BierDispEntryDetails{} } +func (*BierDispEntryDetails) GetMessageName() string { return "bier_disp_entry_details" } +func (*BierDispEntryDetails) GetCrcString() string { return "84c218f1" } +func (*BierDispEntryDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BierDispEntryDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 2 // m.BdeBp + size += 4 // m.BdeTblID + size += 1 // m.BdeIsAdd + size += 1 // m.BdePayloadProto + size += 1 // m.BdeNPaths + for j1 := 0; j1 < len(m.BdePaths); j1++ { + var s1 fib_types.FibPath + _ = s1 + if j1 < len(m.BdePaths) { + s1 = m.BdePaths[j1] + } + size += 4 // s1.SwIfIndex + size += 4 // s1.TableID + size += 4 // s1.RpfID + size += 1 // s1.Weight + size += 1 // s1.Preference + size += 4 // s1.Type + size += 4 // s1.Flags + size += 4 // s1.Proto + size += 1 * 16 // s1.Nh.Address + size += 4 // s1.Nh.ViaLabel + size += 4 // s1.Nh.ObjID + size += 4 // s1.Nh.ClassifyTableIndex + size += 1 // s1.NLabels + for j2 := 0; j2 < 16; j2++ { + size += 1 // s1.LabelStack[j2].IsUniform + size += 4 // s1.LabelStack[j2].Label + size += 1 // s1.LabelStack[j2].TTL + size += 1 // s1.LabelStack[j2].Exp + } + } + return size +} +func (m *BierDispEntryDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint16(m.BdeBp) + buf.EncodeUint32(m.BdeTblID) + buf.EncodeBool(m.BdeIsAdd) + buf.EncodeUint8(m.BdePayloadProto) + buf.EncodeUint8(uint8(len(m.BdePaths))) + for j0 := 0; j0 < len(m.BdePaths); j0++ { + var v0 fib_types.FibPath // BdePaths + if j0 < len(m.BdePaths) { + v0 = m.BdePaths[j0] + } + buf.EncodeUint32(v0.SwIfIndex) + buf.EncodeUint32(v0.TableID) + buf.EncodeUint32(v0.RpfID) + buf.EncodeUint8(v0.Weight) + buf.EncodeUint8(v0.Preference) + buf.EncodeUint32(uint32(v0.Type)) + buf.EncodeUint32(uint32(v0.Flags)) + buf.EncodeUint32(uint32(v0.Proto)) + buf.EncodeBytes(v0.Nh.Address.XXX_UnionData[:], 16) + buf.EncodeUint32(v0.Nh.ViaLabel) + buf.EncodeUint32(v0.Nh.ObjID) + buf.EncodeUint32(v0.Nh.ClassifyTableIndex) + buf.EncodeUint8(v0.NLabels) + for j1 := 0; j1 < 16; j1++ { + buf.EncodeUint8(v0.LabelStack[j1].IsUniform) + buf.EncodeUint32(v0.LabelStack[j1].Label) + buf.EncodeUint8(v0.LabelStack[j1].TTL) + buf.EncodeUint8(v0.LabelStack[j1].Exp) + } + } + return buf.Bytes(), nil +} +func (m *BierDispEntryDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BdeBp = buf.DecodeUint16() + m.BdeTblID = buf.DecodeUint32() + m.BdeIsAdd = buf.DecodeBool() + m.BdePayloadProto = buf.DecodeUint8() + m.BdeNPaths = buf.DecodeUint8() + m.BdePaths = make([]fib_types.FibPath, m.BdeNPaths) + for j0 := 0; j0 < len(m.BdePaths); j0++ { + m.BdePaths[j0].SwIfIndex = buf.DecodeUint32() + m.BdePaths[j0].TableID = buf.DecodeUint32() + m.BdePaths[j0].RpfID = buf.DecodeUint32() + m.BdePaths[j0].Weight = buf.DecodeUint8() + m.BdePaths[j0].Preference = buf.DecodeUint8() + m.BdePaths[j0].Type = fib_types.FibPathType(buf.DecodeUint32()) + m.BdePaths[j0].Flags = fib_types.FibPathFlags(buf.DecodeUint32()) + m.BdePaths[j0].Proto = fib_types.FibPathNhProto(buf.DecodeUint32()) + copy(m.BdePaths[j0].Nh.Address.XXX_UnionData[:], buf.DecodeBytes(16)) + m.BdePaths[j0].Nh.ViaLabel = buf.DecodeUint32() + m.BdePaths[j0].Nh.ObjID = buf.DecodeUint32() + m.BdePaths[j0].Nh.ClassifyTableIndex = buf.DecodeUint32() + m.BdePaths[j0].NLabels = buf.DecodeUint8() + for j1 := 0; j1 < 16; j1++ { + m.BdePaths[j0].LabelStack[j1].IsUniform = buf.DecodeUint8() + m.BdePaths[j0].LabelStack[j1].Label = buf.DecodeUint32() + m.BdePaths[j0].LabelStack[j1].TTL = buf.DecodeUint8() + m.BdePaths[j0].LabelStack[j1].Exp = buf.DecodeUint8() + } + } + return nil +} + +// BierDispEntryDump defines message 'bier_disp_entry_dump'. +type BierDispEntryDump struct { + BdeTblID uint32 `binapi:"u32,name=bde_tbl_id" json:"bde_tbl_id,omitempty"` +} + +func (m *BierDispEntryDump) Reset() { *m = BierDispEntryDump{} } +func (*BierDispEntryDump) GetMessageName() string { return "bier_disp_entry_dump" } +func (*BierDispEntryDump) GetCrcString() string { return "b5fa54ad" } +func (*BierDispEntryDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BierDispEntryDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.BdeTblID + return size +} +func (m *BierDispEntryDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.BdeTblID) + return buf.Bytes(), nil +} +func (m *BierDispEntryDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BdeTblID = buf.DecodeUint32() + return nil +} + +// BIER Disposition Table Add / del route +// - bt_tbl_id - The BIER Disposition table-id. +// +// BierDispTableAddDel defines message 'bier_disp_table_add_del'. +type BierDispTableAddDel struct { + BdtTblID uint32 `binapi:"u32,name=bdt_tbl_id" json:"bdt_tbl_id,omitempty"` + BdtIsAdd bool `binapi:"bool,name=bdt_is_add" json:"bdt_is_add,omitempty"` +} + +func (m *BierDispTableAddDel) Reset() { *m = BierDispTableAddDel{} } +func (*BierDispTableAddDel) GetMessageName() string { return "bier_disp_table_add_del" } +func (*BierDispTableAddDel) GetCrcString() string { return "889657ac" } +func (*BierDispTableAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BierDispTableAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.BdtTblID + size += 1 // m.BdtIsAdd + return size +} +func (m *BierDispTableAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.BdtTblID) + buf.EncodeBool(m.BdtIsAdd) + return buf.Bytes(), nil +} +func (m *BierDispTableAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BdtTblID = buf.DecodeUint32() + m.BdtIsAdd = buf.DecodeBool() + return nil +} + +// BierDispTableAddDelReply defines message 'bier_disp_table_add_del_reply'. +type BierDispTableAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *BierDispTableAddDelReply) Reset() { *m = BierDispTableAddDelReply{} } +func (*BierDispTableAddDelReply) GetMessageName() string { return "bier_disp_table_add_del_reply" } +func (*BierDispTableAddDelReply) GetCrcString() string { return "e8d4e804" } +func (*BierDispTableAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BierDispTableAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *BierDispTableAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *BierDispTableAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// BierDispTableDetails defines message 'bier_disp_table_details'. +type BierDispTableDetails struct { + BdtTblID uint32 `binapi:"u32,name=bdt_tbl_id" json:"bdt_tbl_id,omitempty"` +} + +func (m *BierDispTableDetails) Reset() { *m = BierDispTableDetails{} } +func (*BierDispTableDetails) GetMessageName() string { return "bier_disp_table_details" } +func (*BierDispTableDetails) GetCrcString() string { return "d27942c0" } +func (*BierDispTableDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BierDispTableDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.BdtTblID + return size +} +func (m *BierDispTableDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.BdtTblID) + return buf.Bytes(), nil +} +func (m *BierDispTableDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BdtTblID = buf.DecodeUint32() + return nil +} + +// BierDispTableDump defines message 'bier_disp_table_dump'. +type BierDispTableDump struct{} + +func (m *BierDispTableDump) Reset() { *m = BierDispTableDump{} } +func (*BierDispTableDump) GetMessageName() string { return "bier_disp_table_dump" } +func (*BierDispTableDump) GetCrcString() string { return "51077d14" } +func (*BierDispTableDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BierDispTableDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *BierDispTableDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *BierDispTableDump) Unmarshal(b []byte) error { + return nil +} + +// BIER Imposition Add +// - bi_tbl_id - The BIER table-id used to forward post encap +// - bi_src - The source Bit-position in the encap. +// - bi_n_bytes - The number of bytes in the following bit-string. +// VPP only supports BSL of 1024 and less, so this is +// a u8 field. +// - bi_bytes - The bit-string represented as a byte array (MSB first) +// +// BierImpAdd defines message 'bier_imp_add'. +type BierImpAdd struct { + BiTblID BierTableID `binapi:"bier_table_id,name=bi_tbl_id" json:"bi_tbl_id,omitempty"` + BiSrc uint16 `binapi:"u16,name=bi_src" json:"bi_src,omitempty"` + BiNBytes uint8 `binapi:"u8,name=bi_n_bytes" json:"-"` + BiBytes []byte `binapi:"u8[bi_n_bytes],name=bi_bytes" json:"bi_bytes,omitempty"` +} + +func (m *BierImpAdd) Reset() { *m = BierImpAdd{} } +func (*BierImpAdd) GetMessageName() string { return "bier_imp_add" } +func (*BierImpAdd) GetCrcString() string { return "3856dc3d" } +func (*BierImpAdd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BierImpAdd) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.BiTblID.BtSet + size += 1 // m.BiTblID.BtSubDomain + size += 1 // m.BiTblID.BtHdrLenID + size += 2 // m.BiSrc + size += 1 // m.BiNBytes + size += 1 * len(m.BiBytes) // m.BiBytes + return size +} +func (m *BierImpAdd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.BiTblID.BtSet) + buf.EncodeUint8(m.BiTblID.BtSubDomain) + buf.EncodeUint8(m.BiTblID.BtHdrLenID) + buf.EncodeUint16(m.BiSrc) + buf.EncodeUint8(uint8(len(m.BiBytes))) + buf.EncodeBytes(m.BiBytes, 0) + return buf.Bytes(), nil +} +func (m *BierImpAdd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BiTblID.BtSet = buf.DecodeUint8() + m.BiTblID.BtSubDomain = buf.DecodeUint8() + m.BiTblID.BtHdrLenID = buf.DecodeUint8() + m.BiSrc = buf.DecodeUint16() + m.BiNBytes = buf.DecodeUint8() + m.BiBytes = make([]byte, m.BiNBytes) + copy(m.BiBytes, buf.DecodeBytes(len(m.BiBytes))) + return nil +} + +// Reply for BIER route add / del request +// - retval - return code +// - bi_index - The index of the created imposition object. +// +// BierImpAddReply defines message 'bier_imp_add_reply'. +type BierImpAddReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + BiIndex uint32 `binapi:"u32,name=bi_index" json:"bi_index,omitempty"` +} + +func (m *BierImpAddReply) Reset() { *m = BierImpAddReply{} } +func (*BierImpAddReply) GetMessageName() string { return "bier_imp_add_reply" } +func (*BierImpAddReply) GetCrcString() string { return "d49c5793" } +func (*BierImpAddReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BierImpAddReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.BiIndex + return size +} +func (m *BierImpAddReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.BiIndex) + return buf.Bytes(), nil +} +func (m *BierImpAddReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.BiIndex = buf.DecodeUint32() + return nil +} + +// BIER Imposition Del +// - bi_index - The index of the imposition object (as returned +// from the ADD) +// +// BierImpDel defines message 'bier_imp_del'. +type BierImpDel struct { + BiIndex uint32 `binapi:"u32,name=bi_index" json:"bi_index,omitempty"` +} + +func (m *BierImpDel) Reset() { *m = BierImpDel{} } +func (*BierImpDel) GetMessageName() string { return "bier_imp_del" } +func (*BierImpDel) GetCrcString() string { return "7d45edf6" } +func (*BierImpDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BierImpDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.BiIndex + return size +} +func (m *BierImpDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.BiIndex) + return buf.Bytes(), nil +} +func (m *BierImpDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BiIndex = buf.DecodeUint32() + return nil +} + +// BierImpDelReply defines message 'bier_imp_del_reply'. +type BierImpDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *BierImpDelReply) Reset() { *m = BierImpDelReply{} } +func (*BierImpDelReply) GetMessageName() string { return "bier_imp_del_reply" } +func (*BierImpDelReply) GetCrcString() string { return "e8d4e804" } +func (*BierImpDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BierImpDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *BierImpDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *BierImpDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// BierImpDetails defines message 'bier_imp_details'. +type BierImpDetails struct { + BiTblID BierTableID `binapi:"bier_table_id,name=bi_tbl_id" json:"bi_tbl_id,omitempty"` + BiSrc uint16 `binapi:"u16,name=bi_src" json:"bi_src,omitempty"` + BiNBytes uint8 `binapi:"u8,name=bi_n_bytes" json:"-"` + BiBytes []byte `binapi:"u8[bi_n_bytes],name=bi_bytes" json:"bi_bytes,omitempty"` +} + +func (m *BierImpDetails) Reset() { *m = BierImpDetails{} } +func (*BierImpDetails) GetMessageName() string { return "bier_imp_details" } +func (*BierImpDetails) GetCrcString() string { return "b76192df" } +func (*BierImpDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BierImpDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.BiTblID.BtSet + size += 1 // m.BiTblID.BtSubDomain + size += 1 // m.BiTblID.BtHdrLenID + size += 2 // m.BiSrc + size += 1 // m.BiNBytes + size += 1 * len(m.BiBytes) // m.BiBytes + return size +} +func (m *BierImpDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.BiTblID.BtSet) + buf.EncodeUint8(m.BiTblID.BtSubDomain) + buf.EncodeUint8(m.BiTblID.BtHdrLenID) + buf.EncodeUint16(m.BiSrc) + buf.EncodeUint8(uint8(len(m.BiBytes))) + buf.EncodeBytes(m.BiBytes, 0) + return buf.Bytes(), nil +} +func (m *BierImpDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BiTblID.BtSet = buf.DecodeUint8() + m.BiTblID.BtSubDomain = buf.DecodeUint8() + m.BiTblID.BtHdrLenID = buf.DecodeUint8() + m.BiSrc = buf.DecodeUint16() + m.BiNBytes = buf.DecodeUint8() + m.BiBytes = make([]byte, m.BiNBytes) + copy(m.BiBytes, buf.DecodeBytes(len(m.BiBytes))) + return nil +} + +// BierImpDump defines message 'bier_imp_dump'. +type BierImpDump struct{} + +func (m *BierImpDump) Reset() { *m = BierImpDump{} } +func (*BierImpDump) GetMessageName() string { return "bier_imp_dump" } +func (*BierImpDump) GetCrcString() string { return "51077d14" } +func (*BierImpDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BierImpDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *BierImpDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *BierImpDump) Unmarshal(b []byte) error { + return nil +} + +// BIER Route Add / del route +// - br_bp - The Bit-position value +// - br_tbl_id - The BIER table-id the route is added in +// - br_is_add - Is this a route add or delete +// - br_is_replace - Are the paths specified replacing those already +// present or are they to be combined. +// is_replace = 1 and n_paths=0 implies delete the +// route and all paths; +// - br_n_paths - The number of paths +// - br_paths - The array of paths +// +// BierRouteAddDel defines message 'bier_route_add_del'. +type BierRouteAddDel struct { + BrIsAdd bool `binapi:"bool,name=br_is_add" json:"br_is_add,omitempty"` + BrIsReplace bool `binapi:"bool,name=br_is_replace" json:"br_is_replace,omitempty"` + BrRoute BierRoute `binapi:"bier_route,name=br_route" json:"br_route,omitempty"` +} + +func (m *BierRouteAddDel) Reset() { *m = BierRouteAddDel{} } +func (*BierRouteAddDel) GetMessageName() string { return "bier_route_add_del" } +func (*BierRouteAddDel) GetCrcString() string { return "fd02f3ea" } +func (*BierRouteAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BierRouteAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.BrIsAdd + size += 1 // m.BrIsReplace + size += 4 // m.BrRoute.BrBp + size += 1 // m.BrRoute.BrTblID.BtSet + size += 1 // m.BrRoute.BrTblID.BtSubDomain + size += 1 // m.BrRoute.BrTblID.BtHdrLenID + size += 1 // m.BrRoute.BrNPaths + for j2 := 0; j2 < len(m.BrRoute.BrPaths); j2++ { + var s2 fib_types.FibPath + _ = s2 + if j2 < len(m.BrRoute.BrPaths) { + s2 = m.BrRoute.BrPaths[j2] + } + size += 4 // s2.SwIfIndex + size += 4 // s2.TableID + size += 4 // s2.RpfID + size += 1 // s2.Weight + size += 1 // s2.Preference + size += 4 // s2.Type + size += 4 // s2.Flags + size += 4 // s2.Proto + size += 1 * 16 // s2.Nh.Address + size += 4 // s2.Nh.ViaLabel + size += 4 // s2.Nh.ObjID + size += 4 // s2.Nh.ClassifyTableIndex + size += 1 // s2.NLabels + for j3 := 0; j3 < 16; j3++ { + size += 1 // s2.LabelStack[j3].IsUniform + size += 4 // s2.LabelStack[j3].Label + size += 1 // s2.LabelStack[j3].TTL + size += 1 // s2.LabelStack[j3].Exp + } + } + return size +} +func (m *BierRouteAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.BrIsAdd) + buf.EncodeBool(m.BrIsReplace) + buf.EncodeUint32(m.BrRoute.BrBp) + buf.EncodeUint8(m.BrRoute.BrTblID.BtSet) + buf.EncodeUint8(m.BrRoute.BrTblID.BtSubDomain) + buf.EncodeUint8(m.BrRoute.BrTblID.BtHdrLenID) + buf.EncodeUint8(uint8(len(m.BrRoute.BrPaths))) + for j1 := 0; j1 < len(m.BrRoute.BrPaths); j1++ { + var v1 fib_types.FibPath // BrPaths + if j1 < len(m.BrRoute.BrPaths) { + v1 = m.BrRoute.BrPaths[j1] + } + buf.EncodeUint32(v1.SwIfIndex) + buf.EncodeUint32(v1.TableID) + buf.EncodeUint32(v1.RpfID) + buf.EncodeUint8(v1.Weight) + buf.EncodeUint8(v1.Preference) + buf.EncodeUint32(uint32(v1.Type)) + buf.EncodeUint32(uint32(v1.Flags)) + buf.EncodeUint32(uint32(v1.Proto)) + buf.EncodeBytes(v1.Nh.Address.XXX_UnionData[:], 16) + buf.EncodeUint32(v1.Nh.ViaLabel) + buf.EncodeUint32(v1.Nh.ObjID) + buf.EncodeUint32(v1.Nh.ClassifyTableIndex) + buf.EncodeUint8(v1.NLabels) + for j2 := 0; j2 < 16; j2++ { + buf.EncodeUint8(v1.LabelStack[j2].IsUniform) + buf.EncodeUint32(v1.LabelStack[j2].Label) + buf.EncodeUint8(v1.LabelStack[j2].TTL) + buf.EncodeUint8(v1.LabelStack[j2].Exp) + } + } + return buf.Bytes(), nil +} +func (m *BierRouteAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BrIsAdd = buf.DecodeBool() + m.BrIsReplace = buf.DecodeBool() + m.BrRoute.BrBp = buf.DecodeUint32() + m.BrRoute.BrTblID.BtSet = buf.DecodeUint8() + m.BrRoute.BrTblID.BtSubDomain = buf.DecodeUint8() + m.BrRoute.BrTblID.BtHdrLenID = buf.DecodeUint8() + m.BrRoute.BrNPaths = buf.DecodeUint8() + m.BrRoute.BrPaths = make([]fib_types.FibPath, m.BrRoute.BrNPaths) + for j1 := 0; j1 < len(m.BrRoute.BrPaths); j1++ { + m.BrRoute.BrPaths[j1].SwIfIndex = buf.DecodeUint32() + m.BrRoute.BrPaths[j1].TableID = buf.DecodeUint32() + m.BrRoute.BrPaths[j1].RpfID = buf.DecodeUint32() + m.BrRoute.BrPaths[j1].Weight = buf.DecodeUint8() + m.BrRoute.BrPaths[j1].Preference = buf.DecodeUint8() + m.BrRoute.BrPaths[j1].Type = fib_types.FibPathType(buf.DecodeUint32()) + m.BrRoute.BrPaths[j1].Flags = fib_types.FibPathFlags(buf.DecodeUint32()) + m.BrRoute.BrPaths[j1].Proto = fib_types.FibPathNhProto(buf.DecodeUint32()) + copy(m.BrRoute.BrPaths[j1].Nh.Address.XXX_UnionData[:], buf.DecodeBytes(16)) + m.BrRoute.BrPaths[j1].Nh.ViaLabel = buf.DecodeUint32() + m.BrRoute.BrPaths[j1].Nh.ObjID = buf.DecodeUint32() + m.BrRoute.BrPaths[j1].Nh.ClassifyTableIndex = buf.DecodeUint32() + m.BrRoute.BrPaths[j1].NLabels = buf.DecodeUint8() + for j2 := 0; j2 < 16; j2++ { + m.BrRoute.BrPaths[j1].LabelStack[j2].IsUniform = buf.DecodeUint8() + m.BrRoute.BrPaths[j1].LabelStack[j2].Label = buf.DecodeUint32() + m.BrRoute.BrPaths[j1].LabelStack[j2].TTL = buf.DecodeUint8() + m.BrRoute.BrPaths[j1].LabelStack[j2].Exp = buf.DecodeUint8() + } + } + return nil +} + +// BierRouteAddDelReply defines message 'bier_route_add_del_reply'. +type BierRouteAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *BierRouteAddDelReply) Reset() { *m = BierRouteAddDelReply{} } +func (*BierRouteAddDelReply) GetMessageName() string { return "bier_route_add_del_reply" } +func (*BierRouteAddDelReply) GetCrcString() string { return "e8d4e804" } +func (*BierRouteAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BierRouteAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *BierRouteAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *BierRouteAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// BierRouteDetails defines message 'bier_route_details'. +type BierRouteDetails struct { + BrRoute BierRoute `binapi:"bier_route,name=br_route" json:"br_route,omitempty"` +} + +func (m *BierRouteDetails) Reset() { *m = BierRouteDetails{} } +func (*BierRouteDetails) GetMessageName() string { return "bier_route_details" } +func (*BierRouteDetails) GetCrcString() string { return "4008caee" } +func (*BierRouteDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BierRouteDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.BrRoute.BrBp + size += 1 // m.BrRoute.BrTblID.BtSet + size += 1 // m.BrRoute.BrTblID.BtSubDomain + size += 1 // m.BrRoute.BrTblID.BtHdrLenID + size += 1 // m.BrRoute.BrNPaths + for j2 := 0; j2 < len(m.BrRoute.BrPaths); j2++ { + var s2 fib_types.FibPath + _ = s2 + if j2 < len(m.BrRoute.BrPaths) { + s2 = m.BrRoute.BrPaths[j2] + } + size += 4 // s2.SwIfIndex + size += 4 // s2.TableID + size += 4 // s2.RpfID + size += 1 // s2.Weight + size += 1 // s2.Preference + size += 4 // s2.Type + size += 4 // s2.Flags + size += 4 // s2.Proto + size += 1 * 16 // s2.Nh.Address + size += 4 // s2.Nh.ViaLabel + size += 4 // s2.Nh.ObjID + size += 4 // s2.Nh.ClassifyTableIndex + size += 1 // s2.NLabels + for j3 := 0; j3 < 16; j3++ { + size += 1 // s2.LabelStack[j3].IsUniform + size += 4 // s2.LabelStack[j3].Label + size += 1 // s2.LabelStack[j3].TTL + size += 1 // s2.LabelStack[j3].Exp + } + } + return size +} +func (m *BierRouteDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.BrRoute.BrBp) + buf.EncodeUint8(m.BrRoute.BrTblID.BtSet) + buf.EncodeUint8(m.BrRoute.BrTblID.BtSubDomain) + buf.EncodeUint8(m.BrRoute.BrTblID.BtHdrLenID) + buf.EncodeUint8(uint8(len(m.BrRoute.BrPaths))) + for j1 := 0; j1 < len(m.BrRoute.BrPaths); j1++ { + var v1 fib_types.FibPath // BrPaths + if j1 < len(m.BrRoute.BrPaths) { + v1 = m.BrRoute.BrPaths[j1] + } + buf.EncodeUint32(v1.SwIfIndex) + buf.EncodeUint32(v1.TableID) + buf.EncodeUint32(v1.RpfID) + buf.EncodeUint8(v1.Weight) + buf.EncodeUint8(v1.Preference) + buf.EncodeUint32(uint32(v1.Type)) + buf.EncodeUint32(uint32(v1.Flags)) + buf.EncodeUint32(uint32(v1.Proto)) + buf.EncodeBytes(v1.Nh.Address.XXX_UnionData[:], 16) + buf.EncodeUint32(v1.Nh.ViaLabel) + buf.EncodeUint32(v1.Nh.ObjID) + buf.EncodeUint32(v1.Nh.ClassifyTableIndex) + buf.EncodeUint8(v1.NLabels) + for j2 := 0; j2 < 16; j2++ { + buf.EncodeUint8(v1.LabelStack[j2].IsUniform) + buf.EncodeUint32(v1.LabelStack[j2].Label) + buf.EncodeUint8(v1.LabelStack[j2].TTL) + buf.EncodeUint8(v1.LabelStack[j2].Exp) + } + } + return buf.Bytes(), nil +} +func (m *BierRouteDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BrRoute.BrBp = buf.DecodeUint32() + m.BrRoute.BrTblID.BtSet = buf.DecodeUint8() + m.BrRoute.BrTblID.BtSubDomain = buf.DecodeUint8() + m.BrRoute.BrTblID.BtHdrLenID = buf.DecodeUint8() + m.BrRoute.BrNPaths = buf.DecodeUint8() + m.BrRoute.BrPaths = make([]fib_types.FibPath, m.BrRoute.BrNPaths) + for j1 := 0; j1 < len(m.BrRoute.BrPaths); j1++ { + m.BrRoute.BrPaths[j1].SwIfIndex = buf.DecodeUint32() + m.BrRoute.BrPaths[j1].TableID = buf.DecodeUint32() + m.BrRoute.BrPaths[j1].RpfID = buf.DecodeUint32() + m.BrRoute.BrPaths[j1].Weight = buf.DecodeUint8() + m.BrRoute.BrPaths[j1].Preference = buf.DecodeUint8() + m.BrRoute.BrPaths[j1].Type = fib_types.FibPathType(buf.DecodeUint32()) + m.BrRoute.BrPaths[j1].Flags = fib_types.FibPathFlags(buf.DecodeUint32()) + m.BrRoute.BrPaths[j1].Proto = fib_types.FibPathNhProto(buf.DecodeUint32()) + copy(m.BrRoute.BrPaths[j1].Nh.Address.XXX_UnionData[:], buf.DecodeBytes(16)) + m.BrRoute.BrPaths[j1].Nh.ViaLabel = buf.DecodeUint32() + m.BrRoute.BrPaths[j1].Nh.ObjID = buf.DecodeUint32() + m.BrRoute.BrPaths[j1].Nh.ClassifyTableIndex = buf.DecodeUint32() + m.BrRoute.BrPaths[j1].NLabels = buf.DecodeUint8() + for j2 := 0; j2 < 16; j2++ { + m.BrRoute.BrPaths[j1].LabelStack[j2].IsUniform = buf.DecodeUint8() + m.BrRoute.BrPaths[j1].LabelStack[j2].Label = buf.DecodeUint32() + m.BrRoute.BrPaths[j1].LabelStack[j2].TTL = buf.DecodeUint8() + m.BrRoute.BrPaths[j1].LabelStack[j2].Exp = buf.DecodeUint8() + } + } + return nil +} + +// BierRouteDump defines message 'bier_route_dump'. +type BierRouteDump struct { + BrTblID BierTableID `binapi:"bier_table_id,name=br_tbl_id" json:"br_tbl_id,omitempty"` +} + +func (m *BierRouteDump) Reset() { *m = BierRouteDump{} } +func (*BierRouteDump) GetMessageName() string { return "bier_route_dump" } +func (*BierRouteDump) GetCrcString() string { return "38339846" } +func (*BierRouteDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BierRouteDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.BrTblID.BtSet + size += 1 // m.BrTblID.BtSubDomain + size += 1 // m.BrTblID.BtHdrLenID + return size +} +func (m *BierRouteDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.BrTblID.BtSet) + buf.EncodeUint8(m.BrTblID.BtSubDomain) + buf.EncodeUint8(m.BrTblID.BtHdrLenID) + return buf.Bytes(), nil +} +func (m *BierRouteDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BrTblID.BtSet = buf.DecodeUint8() + m.BrTblID.BtSubDomain = buf.DecodeUint8() + m.BrTblID.BtHdrLenID = buf.DecodeUint8() + return nil +} + +// BIER Table Add / del route +// - bt_tbl_id - The BIER table-id the route is added in +// - bt_label - The MPLS label for the table (0 or all ones means not set) +// If the label is not set, then it is assumed that non-MPLS +// encoding is used. +// - bt_is_add - Is this a route add or delete +// +// BierTableAddDel defines message 'bier_table_add_del'. +type BierTableAddDel struct { + BtTblID BierTableID `binapi:"bier_table_id,name=bt_tbl_id" json:"bt_tbl_id,omitempty"` + BtLabel uint32 `binapi:"u32,name=bt_label" json:"bt_label,omitempty"` + BtIsAdd bool `binapi:"bool,name=bt_is_add" json:"bt_is_add,omitempty"` +} + +func (m *BierTableAddDel) Reset() { *m = BierTableAddDel{} } +func (*BierTableAddDel) GetMessageName() string { return "bier_table_add_del" } +func (*BierTableAddDel) GetCrcString() string { return "35e59209" } +func (*BierTableAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BierTableAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.BtTblID.BtSet + size += 1 // m.BtTblID.BtSubDomain + size += 1 // m.BtTblID.BtHdrLenID + size += 4 // m.BtLabel + size += 1 // m.BtIsAdd + return size +} +func (m *BierTableAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.BtTblID.BtSet) + buf.EncodeUint8(m.BtTblID.BtSubDomain) + buf.EncodeUint8(m.BtTblID.BtHdrLenID) + buf.EncodeUint32(m.BtLabel) + buf.EncodeBool(m.BtIsAdd) + return buf.Bytes(), nil +} +func (m *BierTableAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BtTblID.BtSet = buf.DecodeUint8() + m.BtTblID.BtSubDomain = buf.DecodeUint8() + m.BtTblID.BtHdrLenID = buf.DecodeUint8() + m.BtLabel = buf.DecodeUint32() + m.BtIsAdd = buf.DecodeBool() + return nil +} + +// BierTableAddDelReply defines message 'bier_table_add_del_reply'. +type BierTableAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *BierTableAddDelReply) Reset() { *m = BierTableAddDelReply{} } +func (*BierTableAddDelReply) GetMessageName() string { return "bier_table_add_del_reply" } +func (*BierTableAddDelReply) GetCrcString() string { return "e8d4e804" } +func (*BierTableAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BierTableAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *BierTableAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *BierTableAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// BierTableDetails defines message 'bier_table_details'. +type BierTableDetails struct { + BtLabel uint32 `binapi:"u32,name=bt_label" json:"bt_label,omitempty"` + BtTblID BierTableID `binapi:"bier_table_id,name=bt_tbl_id" json:"bt_tbl_id,omitempty"` +} + +func (m *BierTableDetails) Reset() { *m = BierTableDetails{} } +func (*BierTableDetails) GetMessageName() string { return "bier_table_details" } +func (*BierTableDetails) GetCrcString() string { return "fc44a9dd" } +func (*BierTableDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BierTableDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.BtLabel + size += 1 // m.BtTblID.BtSet + size += 1 // m.BtTblID.BtSubDomain + size += 1 // m.BtTblID.BtHdrLenID + return size +} +func (m *BierTableDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.BtLabel) + buf.EncodeUint8(m.BtTblID.BtSet) + buf.EncodeUint8(m.BtTblID.BtSubDomain) + buf.EncodeUint8(m.BtTblID.BtHdrLenID) + return buf.Bytes(), nil +} +func (m *BierTableDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BtLabel = buf.DecodeUint32() + m.BtTblID.BtSet = buf.DecodeUint8() + m.BtTblID.BtSubDomain = buf.DecodeUint8() + m.BtTblID.BtHdrLenID = buf.DecodeUint8() + return nil +} + +// BierTableDump defines message 'bier_table_dump'. +type BierTableDump struct{} + +func (m *BierTableDump) Reset() { *m = BierTableDump{} } +func (*BierTableDump) GetMessageName() string { return "bier_table_dump" } +func (*BierTableDump) GetCrcString() string { return "51077d14" } +func (*BierTableDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BierTableDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *BierTableDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *BierTableDump) Unmarshal(b []byte) error { + return nil +} + +func init() { file_bier_binapi_init() } +func file_bier_binapi_init() { + api.RegisterMessage((*BierDispEntryAddDel)(nil), "bier_disp_entry_add_del_9eb80cb4") + api.RegisterMessage((*BierDispEntryAddDelReply)(nil), "bier_disp_entry_add_del_reply_e8d4e804") + api.RegisterMessage((*BierDispEntryDetails)(nil), "bier_disp_entry_details_84c218f1") + api.RegisterMessage((*BierDispEntryDump)(nil), "bier_disp_entry_dump_b5fa54ad") + api.RegisterMessage((*BierDispTableAddDel)(nil), "bier_disp_table_add_del_889657ac") + api.RegisterMessage((*BierDispTableAddDelReply)(nil), "bier_disp_table_add_del_reply_e8d4e804") + api.RegisterMessage((*BierDispTableDetails)(nil), "bier_disp_table_details_d27942c0") + api.RegisterMessage((*BierDispTableDump)(nil), "bier_disp_table_dump_51077d14") + api.RegisterMessage((*BierImpAdd)(nil), "bier_imp_add_3856dc3d") + api.RegisterMessage((*BierImpAddReply)(nil), "bier_imp_add_reply_d49c5793") + api.RegisterMessage((*BierImpDel)(nil), "bier_imp_del_7d45edf6") + api.RegisterMessage((*BierImpDelReply)(nil), "bier_imp_del_reply_e8d4e804") + api.RegisterMessage((*BierImpDetails)(nil), "bier_imp_details_b76192df") + api.RegisterMessage((*BierImpDump)(nil), "bier_imp_dump_51077d14") + api.RegisterMessage((*BierRouteAddDel)(nil), "bier_route_add_del_fd02f3ea") + api.RegisterMessage((*BierRouteAddDelReply)(nil), "bier_route_add_del_reply_e8d4e804") + api.RegisterMessage((*BierRouteDetails)(nil), "bier_route_details_4008caee") + api.RegisterMessage((*BierRouteDump)(nil), "bier_route_dump_38339846") + api.RegisterMessage((*BierTableAddDel)(nil), "bier_table_add_del_35e59209") + api.RegisterMessage((*BierTableAddDelReply)(nil), "bier_table_add_del_reply_e8d4e804") + api.RegisterMessage((*BierTableDetails)(nil), "bier_table_details_fc44a9dd") + api.RegisterMessage((*BierTableDump)(nil), "bier_table_dump_51077d14") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*BierDispEntryAddDel)(nil), + (*BierDispEntryAddDelReply)(nil), + (*BierDispEntryDetails)(nil), + (*BierDispEntryDump)(nil), + (*BierDispTableAddDel)(nil), + (*BierDispTableAddDelReply)(nil), + (*BierDispTableDetails)(nil), + (*BierDispTableDump)(nil), + (*BierImpAdd)(nil), + (*BierImpAddReply)(nil), + (*BierImpDel)(nil), + (*BierImpDelReply)(nil), + (*BierImpDetails)(nil), + (*BierImpDump)(nil), + (*BierRouteAddDel)(nil), + (*BierRouteAddDelReply)(nil), + (*BierRouteDetails)(nil), + (*BierRouteDump)(nil), + (*BierTableAddDel)(nil), + (*BierTableAddDelReply)(nil), + (*BierTableDetails)(nil), + (*BierTableDump)(nil), + } +} diff --git a/binapi/bier/bier_rpc.ba.go b/binapi/bier/bier_rpc.ba.go new file mode 100644 index 00000000..a839d46a --- /dev/null +++ b/binapi/bier/bier_rpc.ba.go @@ -0,0 +1,304 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package bier + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service bier. +type RPCService interface { + BierDispEntryAddDel(ctx context.Context, in *BierDispEntryAddDel) (*BierDispEntryAddDelReply, error) + BierDispEntryDump(ctx context.Context, in *BierDispEntryDump) (RPCService_BierDispEntryDumpClient, error) + BierDispTableAddDel(ctx context.Context, in *BierDispTableAddDel) (*BierDispTableAddDelReply, error) + BierDispTableDump(ctx context.Context, in *BierDispTableDump) (RPCService_BierDispTableDumpClient, error) + BierImpAdd(ctx context.Context, in *BierImpAdd) (*BierImpAddReply, error) + BierImpDel(ctx context.Context, in *BierImpDel) (*BierImpDelReply, error) + BierImpDump(ctx context.Context, in *BierImpDump) (RPCService_BierImpDumpClient, error) + BierRouteAddDel(ctx context.Context, in *BierRouteAddDel) (*BierRouteAddDelReply, error) + BierRouteDump(ctx context.Context, in *BierRouteDump) (RPCService_BierRouteDumpClient, error) + BierTableAddDel(ctx context.Context, in *BierTableAddDel) (*BierTableAddDelReply, error) + BierTableDump(ctx context.Context, in *BierTableDump) (RPCService_BierTableDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) BierDispEntryAddDel(ctx context.Context, in *BierDispEntryAddDel) (*BierDispEntryAddDelReply, error) { + out := new(BierDispEntryAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BierDispEntryDump(ctx context.Context, in *BierDispEntryDump) (RPCService_BierDispEntryDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_BierDispEntryDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_BierDispEntryDumpClient interface { + Recv() (*BierDispEntryDetails, error) + api.Stream +} + +type serviceClient_BierDispEntryDumpClient struct { + api.Stream +} + +func (c *serviceClient_BierDispEntryDumpClient) Recv() (*BierDispEntryDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *BierDispEntryDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) BierDispTableAddDel(ctx context.Context, in *BierDispTableAddDel) (*BierDispTableAddDelReply, error) { + out := new(BierDispTableAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BierDispTableDump(ctx context.Context, in *BierDispTableDump) (RPCService_BierDispTableDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_BierDispTableDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_BierDispTableDumpClient interface { + Recv() (*BierDispTableDetails, error) + api.Stream +} + +type serviceClient_BierDispTableDumpClient struct { + api.Stream +} + +func (c *serviceClient_BierDispTableDumpClient) Recv() (*BierDispTableDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *BierDispTableDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) BierImpAdd(ctx context.Context, in *BierImpAdd) (*BierImpAddReply, error) { + out := new(BierImpAddReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BierImpDel(ctx context.Context, in *BierImpDel) (*BierImpDelReply, error) { + out := new(BierImpDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BierImpDump(ctx context.Context, in *BierImpDump) (RPCService_BierImpDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_BierImpDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_BierImpDumpClient interface { + Recv() (*BierImpDetails, error) + api.Stream +} + +type serviceClient_BierImpDumpClient struct { + api.Stream +} + +func (c *serviceClient_BierImpDumpClient) Recv() (*BierImpDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *BierImpDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) BierRouteAddDel(ctx context.Context, in *BierRouteAddDel) (*BierRouteAddDelReply, error) { + out := new(BierRouteAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BierRouteDump(ctx context.Context, in *BierRouteDump) (RPCService_BierRouteDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_BierRouteDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_BierRouteDumpClient interface { + Recv() (*BierRouteDetails, error) + api.Stream +} + +type serviceClient_BierRouteDumpClient struct { + api.Stream +} + +func (c *serviceClient_BierRouteDumpClient) Recv() (*BierRouteDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *BierRouteDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) BierTableAddDel(ctx context.Context, in *BierTableAddDel) (*BierTableAddDelReply, error) { + out := new(BierTableAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BierTableDump(ctx context.Context, in *BierTableDump) (RPCService_BierTableDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_BierTableDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_BierTableDumpClient interface { + Recv() (*BierTableDetails, error) + api.Stream +} + +type serviceClient_BierTableDumpClient struct { + api.Stream +} + +func (c *serviceClient_BierTableDumpClient) Recv() (*BierTableDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *BierTableDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/bond/bond.ba.go b/binapi/bond/bond.ba.go new file mode 100644 index 00000000..8e62c8e2 --- /dev/null +++ b/binapi/bond/bond.ba.go @@ -0,0 +1,1236 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/bond.api.json + +// Package bond contains generated bindings for API file bond.api. +// +// Contents: +// - 2 enums +// - 24 messages +package bond + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + ethernet_types "github.com/alkiranet/govpp/binapi/ethernet_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "bond" + APIVersion = "2.1.0" + VersionCrc = 0xa03f5330 +) + +// BondLbAlgo defines 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", + } + 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 "BondLbAlgo(" + strconv.Itoa(int(x)) + ")" +} + +// BondMode defines 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", + } + 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 "BondMode(" + strconv.Itoa(int(x)) + ")" +} + +// Initialize a new bond interface with the given paramters +// - sw_if_index - member sw_if_index +// - bond_sw_if_index - bond sw_if_index +// - is_passive - interface does not initiate the lacp protocol, remote must be active speaker +// - is_long_timeout - 90 seconds vs default 3 seconds neighbor timeout +// +// BondAddMember defines message 'bond_add_member'. +type BondAddMember struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + BondSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=bond_sw_if_index" json:"bond_sw_if_index,omitempty"` + IsPassive bool `binapi:"bool,name=is_passive" json:"is_passive,omitempty"` + IsLongTimeout bool `binapi:"bool,name=is_long_timeout" json:"is_long_timeout,omitempty"` +} + +func (m *BondAddMember) Reset() { *m = BondAddMember{} } +func (*BondAddMember) GetMessageName() string { return "bond_add_member" } +func (*BondAddMember) GetCrcString() string { return "e7d14948" } +func (*BondAddMember) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BondAddMember) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.BondSwIfIndex + size += 1 // m.IsPassive + size += 1 // m.IsLongTimeout + return size +} +func (m *BondAddMember) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(uint32(m.BondSwIfIndex)) + buf.EncodeBool(m.IsPassive) + buf.EncodeBool(m.IsLongTimeout) + return buf.Bytes(), nil +} +func (m *BondAddMember) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.BondSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsPassive = buf.DecodeBool() + m.IsLongTimeout = buf.DecodeBool() + return nil +} + +// Reply for bond add_member reply +// - retval - return code +// +// BondAddMemberReply defines message 'bond_add_member_reply'. +type BondAddMemberReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *BondAddMemberReply) Reset() { *m = BondAddMemberReply{} } +func (*BondAddMemberReply) GetMessageName() string { return "bond_add_member_reply" } +func (*BondAddMemberReply) GetCrcString() string { return "e8d4e804" } +func (*BondAddMemberReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BondAddMemberReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *BondAddMemberReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *BondAddMemberReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Initialize a new bond interface with the given paramters +// - id - if non-~0, specifies a custom interface ID +// - use_custom_mac - if set, mac_address is valid +// - mac_address - mac addr to assign to the interface if use_custom_mac is set +// - mode - mode, required (1=round-robin, 2=active-backup, 3=xor, 4=broadcast, 5=lacp) +// - lb - load balance, optional (0=l2, 1=l34, 2=l23) valid for xor and lacp modes. Otherwise ignored +// - numa_only - if numa_only is set, pkts will be transmitted by LAG members on local numa node only if have at least one, otherwise it works as usual. +// +// BondCreate defines message 'bond_create'. +// Deprecated: the message will be removed in the future versions +type BondCreate struct { + ID uint32 `binapi:"u32,name=id,default=4294967295" json:"id,omitempty"` + UseCustomMac bool `binapi:"bool,name=use_custom_mac" json:"use_custom_mac,omitempty"` + MacAddress ethernet_types.MacAddress `binapi:"mac_address,name=mac_address" json:"mac_address,omitempty"` + Mode BondMode `binapi:"bond_mode,name=mode" json:"mode,omitempty"` + Lb BondLbAlgo `binapi:"bond_lb_algo,name=lb" json:"lb,omitempty"` + NumaOnly bool `binapi:"bool,name=numa_only" json:"numa_only,omitempty"` +} + +func (m *BondCreate) Reset() { *m = BondCreate{} } +func (*BondCreate) GetMessageName() string { return "bond_create" } +func (*BondCreate) GetCrcString() string { return "f1dbd4ff" } +func (*BondCreate) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BondCreate) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ID + size += 1 // m.UseCustomMac + size += 1 * 6 // m.MacAddress + size += 4 // m.Mode + size += 4 // m.Lb + size += 1 // m.NumaOnly + return size +} +func (m *BondCreate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.ID) + buf.EncodeBool(m.UseCustomMac) + buf.EncodeBytes(m.MacAddress[:], 6) + buf.EncodeUint32(uint32(m.Mode)) + buf.EncodeUint32(uint32(m.Lb)) + buf.EncodeBool(m.NumaOnly) + return buf.Bytes(), nil +} +func (m *BondCreate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ID = buf.DecodeUint32() + m.UseCustomMac = buf.DecodeBool() + copy(m.MacAddress[:], buf.DecodeBytes(6)) + m.Mode = BondMode(buf.DecodeUint32()) + m.Lb = BondLbAlgo(buf.DecodeUint32()) + m.NumaOnly = buf.DecodeBool() + return nil +} + +// Initialize a new bond interface with the given paramters +// - mode - mode, required (1=round-robin, 2=active-backup, 3=xor, 4=broadcast, 5=lacp) +// - lb - load balance, optional (0=l2, 1=l34, 2=l23) valid for xor and lacp modes. Otherwise ignored (default=l2) +// - numa_only - if numa_only is set, pkts will be transmitted by LAG members on local numa node only if have at least one, otherwise it works as usual. +// - enable_gso - enable gso support (default 0) +// - use_custom_mac - if set, mac_address is valid +// - mac_address - mac addr to assign to the interface if use_custom_mac is set +// - id - if non-~0, specifies a custom interface ID (default=0xFFFFFFFF) +// +// BondCreate2 defines message 'bond_create2'. +type BondCreate2 struct { + Mode BondMode `binapi:"bond_mode,name=mode" json:"mode,omitempty"` + Lb BondLbAlgo `binapi:"bond_lb_algo,name=lb" json:"lb,omitempty"` + NumaOnly bool `binapi:"bool,name=numa_only" json:"numa_only,omitempty"` + EnableGso bool `binapi:"bool,name=enable_gso" json:"enable_gso,omitempty"` + UseCustomMac bool `binapi:"bool,name=use_custom_mac" json:"use_custom_mac,omitempty"` + MacAddress ethernet_types.MacAddress `binapi:"mac_address,name=mac_address" json:"mac_address,omitempty"` + ID uint32 `binapi:"u32,name=id,default=4294967295" json:"id,omitempty"` +} + +func (m *BondCreate2) Reset() { *m = BondCreate2{} } +func (*BondCreate2) GetMessageName() string { return "bond_create2" } +func (*BondCreate2) GetCrcString() string { return "912fda76" } +func (*BondCreate2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BondCreate2) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Mode + size += 4 // m.Lb + size += 1 // m.NumaOnly + size += 1 // m.EnableGso + size += 1 // m.UseCustomMac + size += 1 * 6 // m.MacAddress + size += 4 // m.ID + return size +} +func (m *BondCreate2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Mode)) + buf.EncodeUint32(uint32(m.Lb)) + buf.EncodeBool(m.NumaOnly) + buf.EncodeBool(m.EnableGso) + buf.EncodeBool(m.UseCustomMac) + buf.EncodeBytes(m.MacAddress[:], 6) + buf.EncodeUint32(m.ID) + return buf.Bytes(), nil +} +func (m *BondCreate2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Mode = BondMode(buf.DecodeUint32()) + m.Lb = BondLbAlgo(buf.DecodeUint32()) + m.NumaOnly = buf.DecodeBool() + m.EnableGso = buf.DecodeBool() + m.UseCustomMac = buf.DecodeBool() + copy(m.MacAddress[:], buf.DecodeBytes(6)) + m.ID = buf.DecodeUint32() + return nil +} + +// Reply for bond create2 reply +// - retval - return code +// - sw_if_index - software index allocated for the new tap interface +// +// BondCreate2Reply defines message 'bond_create2_reply'. +type BondCreate2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *BondCreate2Reply) Reset() { *m = BondCreate2Reply{} } +func (*BondCreate2Reply) GetMessageName() string { return "bond_create2_reply" } +func (*BondCreate2Reply) GetCrcString() string { return "5383d31f" } +func (*BondCreate2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BondCreate2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *BondCreate2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *BondCreate2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Reply for bond create reply +// - retval - return code +// - sw_if_index - software index allocated for the new tap interface +// +// BondCreateReply defines message 'bond_create_reply'. +type BondCreateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *BondCreateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *BondCreateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *BondCreateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Delete bond interface +// - sw_if_index - interface index of member interface +// +// BondDelete defines message 'bond_delete'. +type BondDelete struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *BondDelete) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *BondDelete) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *BondDelete) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// BondDeleteReply defines message 'bond_delete_reply'. +type BondDeleteReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *BondDeleteReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *BondDeleteReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *BondDeleteReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// bond detach member +// - sw_if_index - interface index of member interface +// +// BondDetachMember defines message 'bond_detach_member'. +type BondDetachMember struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *BondDetachMember) Reset() { *m = BondDetachMember{} } +func (*BondDetachMember) GetMessageName() string { return "bond_detach_member" } +func (*BondDetachMember) GetCrcString() string { return "f9e6675e" } +func (*BondDetachMember) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BondDetachMember) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *BondDetachMember) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *BondDetachMember) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// BondDetachMemberReply defines message 'bond_detach_member_reply'. +type BondDetachMemberReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *BondDetachMemberReply) Reset() { *m = BondDetachMemberReply{} } +func (*BondDetachMemberReply) GetMessageName() string { return "bond_detach_member_reply" } +func (*BondDetachMemberReply) GetCrcString() string { return "e8d4e804" } +func (*BondDetachMemberReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BondDetachMemberReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *BondDetachMemberReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *BondDetachMemberReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// bond detach slave +// - sw_if_index - interface index of member interface +// +// BondDetachSlave defines message 'bond_detach_slave'. +// Deprecated: the message will be removed in the future versions +type BondDetachSlave struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *BondDetachSlave) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *BondDetachSlave) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *BondDetachSlave) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// BondDetachSlaveReply defines message 'bond_detach_slave_reply'. +// Deprecated: the message will be removed in the future versions +type BondDetachSlaveReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *BondDetachSlaveReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *BondDetachSlaveReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *BondDetachSlaveReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Initialize a new bond interface with the given paramters +// - sw_if_index - slave sw_if_index +// - bond_sw_if_index - bond sw_if_index +// - is_passive - interface does not initiate the lacp protocol, remote must be active speaker +// - is_long_timeout - 90 seconds vs default 3 seconds neighbor timeout +// +// BondEnslave defines message 'bond_enslave'. +// Deprecated: the message will be removed in the future versions +type BondEnslave struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + BondSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=bond_sw_if_index" json:"bond_sw_if_index,omitempty"` + IsPassive bool `binapi:"bool,name=is_passive" json:"is_passive,omitempty"` + IsLongTimeout bool `binapi:"bool,name=is_long_timeout" json:"is_long_timeout,omitempty"` +} + +func (m *BondEnslave) Reset() { *m = BondEnslave{} } +func (*BondEnslave) GetMessageName() string { return "bond_enslave" } +func (*BondEnslave) GetCrcString() string { return "e7d14948" } +func (*BondEnslave) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BondEnslave) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.BondSwIfIndex + size += 1 // m.IsPassive + size += 1 // m.IsLongTimeout + return size +} +func (m *BondEnslave) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(uint32(m.BondSwIfIndex)) + buf.EncodeBool(m.IsPassive) + buf.EncodeBool(m.IsLongTimeout) + return buf.Bytes(), nil +} +func (m *BondEnslave) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.BondSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsPassive = buf.DecodeBool() + m.IsLongTimeout = buf.DecodeBool() + return nil +} + +// Reply for bond enslave reply +// - retval - return code +// +// BondEnslaveReply defines message 'bond_enslave_reply'. +type BondEnslaveReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *BondEnslaveReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *BondEnslaveReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *BondEnslaveReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Reply for bond dump request +// - sw_if_index - software index of bond interface +// - id - ID of interface +// - mode - bonding mode +// - lb - load balance algo +// - numa_only - enable local numa TX for lacp mode +// - active_members - active members count +// - members - config member count +// - interface_name - name of interface +// +// SwBondInterfaceDetails defines message 'sw_bond_interface_details'. +type SwBondInterfaceDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + ID uint32 `binapi:"u32,name=id" json:"id,omitempty"` + Mode BondMode `binapi:"bond_mode,name=mode" json:"mode,omitempty"` + Lb BondLbAlgo `binapi:"bond_lb_algo,name=lb" json:"lb,omitempty"` + NumaOnly bool `binapi:"bool,name=numa_only" json:"numa_only,omitempty"` + ActiveMembers uint32 `binapi:"u32,name=active_members" json:"active_members,omitempty"` + Members uint32 `binapi:"u32,name=members" json:"members,omitempty"` + InterfaceName string `binapi:"string[64],name=interface_name" json:"interface_name,omitempty"` +} + +func (m *SwBondInterfaceDetails) Reset() { *m = SwBondInterfaceDetails{} } +func (*SwBondInterfaceDetails) GetMessageName() string { return "sw_bond_interface_details" } +func (*SwBondInterfaceDetails) GetCrcString() string { return "9428a69c" } +func (*SwBondInterfaceDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwBondInterfaceDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.ID + size += 4 // m.Mode + size += 4 // m.Lb + size += 1 // m.NumaOnly + size += 4 // m.ActiveMembers + size += 4 // m.Members + size += 64 // m.InterfaceName + return size +} +func (m *SwBondInterfaceDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.ID) + buf.EncodeUint32(uint32(m.Mode)) + buf.EncodeUint32(uint32(m.Lb)) + buf.EncodeBool(m.NumaOnly) + buf.EncodeUint32(m.ActiveMembers) + buf.EncodeUint32(m.Members) + buf.EncodeString(m.InterfaceName, 64) + return buf.Bytes(), nil +} +func (m *SwBondInterfaceDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.ID = buf.DecodeUint32() + m.Mode = BondMode(buf.DecodeUint32()) + m.Lb = BondLbAlgo(buf.DecodeUint32()) + m.NumaOnly = buf.DecodeBool() + m.ActiveMembers = buf.DecodeUint32() + m.Members = buf.DecodeUint32() + m.InterfaceName = buf.DecodeString(64) + return nil +} + +// Dump bond interfaces request +// SwBondInterfaceDump defines message 'sw_bond_interface_dump'. +type SwBondInterfaceDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` +} + +func (m *SwBondInterfaceDump) Reset() { *m = SwBondInterfaceDump{} } +func (*SwBondInterfaceDump) GetMessageName() string { return "sw_bond_interface_dump" } +func (*SwBondInterfaceDump) GetCrcString() string { return "f9e6675e" } +func (*SwBondInterfaceDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwBondInterfaceDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *SwBondInterfaceDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *SwBondInterfaceDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Reply for bond dump request +// - sw_if_index - software index of bond interface +// - id - ID of interface +// - interface_name - name of interface +// - mode - bonding mode +// - lb - load balance algo +// - numa_only - enable local numa TX for lacp mode +// - active_slaves - active member count +// - slaves - config member count +// +// SwInterfaceBondDetails defines message 'sw_interface_bond_details'. +type SwInterfaceBondDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + ID uint32 `binapi:"u32,name=id" json:"id,omitempty"` + Mode BondMode `binapi:"bond_mode,name=mode" json:"mode,omitempty"` + Lb BondLbAlgo `binapi:"bond_lb_algo,name=lb" json:"lb,omitempty"` + NumaOnly bool `binapi:"bool,name=numa_only" json:"numa_only,omitempty"` + ActiveSlaves uint32 `binapi:"u32,name=active_slaves" json:"active_slaves,omitempty"` + Slaves uint32 `binapi:"u32,name=slaves" json:"slaves,omitempty"` + InterfaceName string `binapi:"string[64],name=interface_name" json:"interface_name,omitempty"` +} + +func (m *SwInterfaceBondDetails) Reset() { *m = SwInterfaceBondDetails{} } +func (*SwInterfaceBondDetails) GetMessageName() string { return "sw_interface_bond_details" } +func (*SwInterfaceBondDetails) GetCrcString() string { return "bb7c929b" } +func (*SwInterfaceBondDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwInterfaceBondDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.ID + size += 4 // m.Mode + size += 4 // m.Lb + size += 1 // m.NumaOnly + size += 4 // m.ActiveSlaves + size += 4 // m.Slaves + size += 64 // m.InterfaceName + return size +} +func (m *SwInterfaceBondDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.ID) + buf.EncodeUint32(uint32(m.Mode)) + buf.EncodeUint32(uint32(m.Lb)) + buf.EncodeBool(m.NumaOnly) + buf.EncodeUint32(m.ActiveSlaves) + buf.EncodeUint32(m.Slaves) + buf.EncodeString(m.InterfaceName, 64) + return buf.Bytes(), nil +} +func (m *SwInterfaceBondDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.ID = buf.DecodeUint32() + m.Mode = BondMode(buf.DecodeUint32()) + m.Lb = BondLbAlgo(buf.DecodeUint32()) + m.NumaOnly = buf.DecodeBool() + m.ActiveSlaves = buf.DecodeUint32() + m.Slaves = buf.DecodeUint32() + m.InterfaceName = buf.DecodeString(64) + return nil +} + +// Dump bond interfaces request +// SwInterfaceBondDump defines message 'sw_interface_bond_dump'. +// Deprecated: the message will be removed in the future versions +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 +} + +func (m *SwInterfaceBondDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SwInterfaceBondDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SwInterfaceBondDump) Unmarshal(b []byte) error { + return nil +} + +// Interface set bond weight +// - sw_if_index - member interface for which to set the weight +// - weight - weight value to be set for the member interface +// +// SwInterfaceSetBondWeight defines message 'sw_interface_set_bond_weight'. +type SwInterfaceSetBondWeight struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetBondWeight) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.Weight + return size +} +func (m *SwInterfaceSetBondWeight) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.Weight) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetBondWeight) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Weight = buf.DecodeUint32() + return nil +} + +// SwInterfaceSetBondWeightReply defines message 'sw_interface_set_bond_weight_reply'. +type SwInterfaceSetBondWeightReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetBondWeightReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetBondWeightReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetBondWeightReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Reply for slave dump request +// - sw_if_index - software index of slave interface +// - interface_name - name of interface +// - is_passve - interface does not initiate the lacp protocol, remote must be active speaker +// - is_long_timeout - 90 seconds vs default 3 seconds neighbor timeout +// - is_local_numa - the slave interface is local numa +// - weight - the weight for the slave interface (active-backup mode only) +// +// SwInterfaceSlaveDetails defines message 'sw_interface_slave_details'. +type SwInterfaceSlaveDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + InterfaceName string `binapi:"string[64],name=interface_name" json:"interface_name,omitempty"` + IsPassive bool `binapi:"bool,name=is_passive" json:"is_passive,omitempty"` + IsLongTimeout bool `binapi:"bool,name=is_long_timeout" json:"is_long_timeout,omitempty"` + IsLocalNuma bool `binapi:"bool,name=is_local_numa" json:"is_local_numa,omitempty"` + Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` +} + +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 +} + +func (m *SwInterfaceSlaveDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 64 // m.InterfaceName + size += 1 // m.IsPassive + size += 1 // m.IsLongTimeout + size += 1 // m.IsLocalNuma + size += 4 // m.Weight + return size +} +func (m *SwInterfaceSlaveDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeString(m.InterfaceName, 64) + buf.EncodeBool(m.IsPassive) + buf.EncodeBool(m.IsLongTimeout) + buf.EncodeBool(m.IsLocalNuma) + buf.EncodeUint32(m.Weight) + return buf.Bytes(), nil +} +func (m *SwInterfaceSlaveDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.InterfaceName = buf.DecodeString(64) + m.IsPassive = buf.DecodeBool() + m.IsLongTimeout = buf.DecodeBool() + m.IsLocalNuma = buf.DecodeBool() + m.Weight = buf.DecodeUint32() + return nil +} + +// bond slave dump +// - sw_if_index - interface index of bond interface +// +// SwInterfaceSlaveDump defines message 'sw_interface_slave_dump'. +// Deprecated: the message will be removed in the future versions +type SwInterfaceSlaveDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 (m *SwInterfaceSlaveDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *SwInterfaceSlaveDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *SwInterfaceSlaveDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Reply for member dump request +// - sw_if_index - software index of member interface +// - interface_name - name of interface +// - is_passve - interface does not initiate the lacp protocol, remote must be active speaker +// - is_long_timeout - 90 seconds vs default 3 seconds neighbor timeout +// - is_local_numa - the member interface is local numa +// - weight - the weight for the member interface (active-backup mode only) +// +// SwMemberInterfaceDetails defines message 'sw_member_interface_details'. +type SwMemberInterfaceDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + InterfaceName string `binapi:"string[64],name=interface_name" json:"interface_name,omitempty"` + IsPassive bool `binapi:"bool,name=is_passive" json:"is_passive,omitempty"` + IsLongTimeout bool `binapi:"bool,name=is_long_timeout" json:"is_long_timeout,omitempty"` + IsLocalNuma bool `binapi:"bool,name=is_local_numa" json:"is_local_numa,omitempty"` + Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` +} + +func (m *SwMemberInterfaceDetails) Reset() { *m = SwMemberInterfaceDetails{} } +func (*SwMemberInterfaceDetails) GetMessageName() string { return "sw_member_interface_details" } +func (*SwMemberInterfaceDetails) GetCrcString() string { return "3c4a0e23" } +func (*SwMemberInterfaceDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwMemberInterfaceDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 64 // m.InterfaceName + size += 1 // m.IsPassive + size += 1 // m.IsLongTimeout + size += 1 // m.IsLocalNuma + size += 4 // m.Weight + return size +} +func (m *SwMemberInterfaceDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeString(m.InterfaceName, 64) + buf.EncodeBool(m.IsPassive) + buf.EncodeBool(m.IsLongTimeout) + buf.EncodeBool(m.IsLocalNuma) + buf.EncodeUint32(m.Weight) + return buf.Bytes(), nil +} +func (m *SwMemberInterfaceDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.InterfaceName = buf.DecodeString(64) + m.IsPassive = buf.DecodeBool() + m.IsLongTimeout = buf.DecodeBool() + m.IsLocalNuma = buf.DecodeBool() + m.Weight = buf.DecodeUint32() + return nil +} + +// bond member dump +// - sw_if_index - interface index of bond interface +// +// SwMemberInterfaceDump defines message 'sw_member_interface_dump'. +type SwMemberInterfaceDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *SwMemberInterfaceDump) Reset() { *m = SwMemberInterfaceDump{} } +func (*SwMemberInterfaceDump) GetMessageName() string { return "sw_member_interface_dump" } +func (*SwMemberInterfaceDump) GetCrcString() string { return "f9e6675e" } +func (*SwMemberInterfaceDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwMemberInterfaceDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *SwMemberInterfaceDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *SwMemberInterfaceDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +func init() { file_bond_binapi_init() } +func file_bond_binapi_init() { + api.RegisterMessage((*BondAddMember)(nil), "bond_add_member_e7d14948") + api.RegisterMessage((*BondAddMemberReply)(nil), "bond_add_member_reply_e8d4e804") + api.RegisterMessage((*BondCreate)(nil), "bond_create_f1dbd4ff") + api.RegisterMessage((*BondCreate2)(nil), "bond_create2_912fda76") + api.RegisterMessage((*BondCreate2Reply)(nil), "bond_create2_reply_5383d31f") + api.RegisterMessage((*BondCreateReply)(nil), "bond_create_reply_5383d31f") + api.RegisterMessage((*BondDelete)(nil), "bond_delete_f9e6675e") + api.RegisterMessage((*BondDeleteReply)(nil), "bond_delete_reply_e8d4e804") + api.RegisterMessage((*BondDetachMember)(nil), "bond_detach_member_f9e6675e") + api.RegisterMessage((*BondDetachMemberReply)(nil), "bond_detach_member_reply_e8d4e804") + api.RegisterMessage((*BondDetachSlave)(nil), "bond_detach_slave_f9e6675e") + api.RegisterMessage((*BondDetachSlaveReply)(nil), "bond_detach_slave_reply_e8d4e804") + api.RegisterMessage((*BondEnslave)(nil), "bond_enslave_e7d14948") + api.RegisterMessage((*BondEnslaveReply)(nil), "bond_enslave_reply_e8d4e804") + api.RegisterMessage((*SwBondInterfaceDetails)(nil), "sw_bond_interface_details_9428a69c") + api.RegisterMessage((*SwBondInterfaceDump)(nil), "sw_bond_interface_dump_f9e6675e") + api.RegisterMessage((*SwInterfaceBondDetails)(nil), "sw_interface_bond_details_bb7c929b") + api.RegisterMessage((*SwInterfaceBondDump)(nil), "sw_interface_bond_dump_51077d14") + api.RegisterMessage((*SwInterfaceSetBondWeight)(nil), "sw_interface_set_bond_weight_deb510a0") + api.RegisterMessage((*SwInterfaceSetBondWeightReply)(nil), "sw_interface_set_bond_weight_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceSlaveDetails)(nil), "sw_interface_slave_details_3c4a0e23") + api.RegisterMessage((*SwInterfaceSlaveDump)(nil), "sw_interface_slave_dump_f9e6675e") + api.RegisterMessage((*SwMemberInterfaceDetails)(nil), "sw_member_interface_details_3c4a0e23") + api.RegisterMessage((*SwMemberInterfaceDump)(nil), "sw_member_interface_dump_f9e6675e") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*BondAddMember)(nil), + (*BondAddMemberReply)(nil), + (*BondCreate)(nil), + (*BondCreate2)(nil), + (*BondCreate2Reply)(nil), + (*BondCreateReply)(nil), + (*BondDelete)(nil), + (*BondDeleteReply)(nil), + (*BondDetachMember)(nil), + (*BondDetachMemberReply)(nil), + (*BondDetachSlave)(nil), + (*BondDetachSlaveReply)(nil), + (*BondEnslave)(nil), + (*BondEnslaveReply)(nil), + (*SwBondInterfaceDetails)(nil), + (*SwBondInterfaceDump)(nil), + (*SwInterfaceBondDetails)(nil), + (*SwInterfaceBondDump)(nil), + (*SwInterfaceSetBondWeight)(nil), + (*SwInterfaceSetBondWeightReply)(nil), + (*SwInterfaceSlaveDetails)(nil), + (*SwInterfaceSlaveDump)(nil), + (*SwMemberInterfaceDetails)(nil), + (*SwMemberInterfaceDump)(nil), + } +} diff --git a/binapi/bond/bond_rpc.ba.go b/binapi/bond/bond_rpc.ba.go new file mode 100644 index 00000000..b8b8b848 --- /dev/null +++ b/binapi/bond/bond_rpc.ba.go @@ -0,0 +1,280 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package bond + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service bond. +type RPCService interface { + BondAddMember(ctx context.Context, in *BondAddMember) (*BondAddMemberReply, error) + BondCreate(ctx context.Context, in *BondCreate) (*BondCreateReply, error) + BondCreate2(ctx context.Context, in *BondCreate2) (*BondCreate2Reply, error) + BondDelete(ctx context.Context, in *BondDelete) (*BondDeleteReply, error) + BondDetachMember(ctx context.Context, in *BondDetachMember) (*BondDetachMemberReply, error) + BondDetachSlave(ctx context.Context, in *BondDetachSlave) (*BondDetachSlaveReply, error) + BondEnslave(ctx context.Context, in *BondEnslave) (*BondEnslaveReply, error) + SwBondInterfaceDump(ctx context.Context, in *SwBondInterfaceDump) (RPCService_SwBondInterfaceDumpClient, error) + SwInterfaceBondDump(ctx context.Context, in *SwInterfaceBondDump) (RPCService_SwInterfaceBondDumpClient, error) + SwInterfaceSetBondWeight(ctx context.Context, in *SwInterfaceSetBondWeight) (*SwInterfaceSetBondWeightReply, error) + SwInterfaceSlaveDump(ctx context.Context, in *SwInterfaceSlaveDump) (RPCService_SwInterfaceSlaveDumpClient, error) + SwMemberInterfaceDump(ctx context.Context, in *SwMemberInterfaceDump) (RPCService_SwMemberInterfaceDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) BondAddMember(ctx context.Context, in *BondAddMember) (*BondAddMemberReply, error) { + out := new(BondAddMemberReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BondCreate(ctx context.Context, in *BondCreate) (*BondCreateReply, error) { + out := new(BondCreateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BondCreate2(ctx context.Context, in *BondCreate2) (*BondCreate2Reply, error) { + out := new(BondCreate2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BondDelete(ctx context.Context, in *BondDelete) (*BondDeleteReply, error) { + out := new(BondDeleteReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BondDetachMember(ctx context.Context, in *BondDetachMember) (*BondDetachMemberReply, error) { + out := new(BondDetachMemberReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BondDetachSlave(ctx context.Context, in *BondDetachSlave) (*BondDetachSlaveReply, error) { + out := new(BondDetachSlaveReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BondEnslave(ctx context.Context, in *BondEnslave) (*BondEnslaveReply, error) { + out := new(BondEnslaveReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwBondInterfaceDump(ctx context.Context, in *SwBondInterfaceDump) (RPCService_SwBondInterfaceDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SwBondInterfaceDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SwBondInterfaceDumpClient interface { + Recv() (*SwBondInterfaceDetails, error) + api.Stream +} + +type serviceClient_SwBondInterfaceDumpClient struct { + api.Stream +} + +func (c *serviceClient_SwBondInterfaceDumpClient) Recv() (*SwBondInterfaceDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SwBondInterfaceDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) SwInterfaceBondDump(ctx context.Context, in *SwInterfaceBondDump) (RPCService_SwInterfaceBondDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SwInterfaceBondDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SwInterfaceBondDumpClient interface { + Recv() (*SwInterfaceBondDetails, error) + api.Stream +} + +type serviceClient_SwInterfaceBondDumpClient struct { + api.Stream +} + +func (c *serviceClient_SwInterfaceBondDumpClient) Recv() (*SwInterfaceBondDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SwInterfaceBondDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) SwInterfaceSetBondWeight(ctx context.Context, in *SwInterfaceSetBondWeight) (*SwInterfaceSetBondWeightReply, error) { + out := new(SwInterfaceSetBondWeightReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceSlaveDump(ctx context.Context, in *SwInterfaceSlaveDump) (RPCService_SwInterfaceSlaveDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SwInterfaceSlaveDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SwInterfaceSlaveDumpClient interface { + Recv() (*SwInterfaceSlaveDetails, error) + api.Stream +} + +type serviceClient_SwInterfaceSlaveDumpClient struct { + api.Stream +} + +func (c *serviceClient_SwInterfaceSlaveDumpClient) Recv() (*SwInterfaceSlaveDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SwInterfaceSlaveDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) SwMemberInterfaceDump(ctx context.Context, in *SwMemberInterfaceDump) (RPCService_SwMemberInterfaceDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SwMemberInterfaceDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SwMemberInterfaceDumpClient interface { + Recv() (*SwMemberInterfaceDetails, error) + api.Stream +} + +type serviceClient_SwMemberInterfaceDumpClient struct { + api.Stream +} + +func (c *serviceClient_SwMemberInterfaceDumpClient) Recv() (*SwMemberInterfaceDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SwMemberInterfaceDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/builtinurl/builtinurl.ba.go b/binapi/builtinurl/builtinurl.ba.go new file mode 100644 index 00000000..38ad7972 --- /dev/null +++ b/binapi/builtinurl/builtinurl.ba.go @@ -0,0 +1,106 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/builtinurl.api.json + +// Package builtinurl contains generated bindings for API file builtinurl.api. +// +// Contents: +// - 2 messages +package builtinurl + +import ( + api "github.com/alkiranet/govpp/api" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "builtinurl" + APIVersion = "1.0.0" + VersionCrc = 0x25045d63 +) + +// @brief API to enable / disable builtinurl on an interface +// - enable_disable - 1 to enable, 0 to disable the feature +// - sw_if_index - interface handle +// +// BuiltinurlEnable defines message 'builtinurl_enable'. +type BuiltinurlEnable struct{} + +func (m *BuiltinurlEnable) Reset() { *m = BuiltinurlEnable{} } +func (*BuiltinurlEnable) GetMessageName() string { return "builtinurl_enable" } +func (*BuiltinurlEnable) GetCrcString() string { return "51077d14" } +func (*BuiltinurlEnable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BuiltinurlEnable) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *BuiltinurlEnable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *BuiltinurlEnable) Unmarshal(b []byte) error { + return nil +} + +// BuiltinurlEnableReply defines message 'builtinurl_enable_reply'. +type BuiltinurlEnableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *BuiltinurlEnableReply) Reset() { *m = BuiltinurlEnableReply{} } +func (*BuiltinurlEnableReply) GetMessageName() string { return "builtinurl_enable_reply" } +func (*BuiltinurlEnableReply) GetCrcString() string { return "e8d4e804" } +func (*BuiltinurlEnableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BuiltinurlEnableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *BuiltinurlEnableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *BuiltinurlEnableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_builtinurl_binapi_init() } +func file_builtinurl_binapi_init() { + api.RegisterMessage((*BuiltinurlEnable)(nil), "builtinurl_enable_51077d14") + api.RegisterMessage((*BuiltinurlEnableReply)(nil), "builtinurl_enable_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*BuiltinurlEnable)(nil), + (*BuiltinurlEnableReply)(nil), + } +} diff --git a/binapi/builtinurl/builtinurl_rpc.ba.go b/binapi/builtinurl/builtinurl_rpc.ba.go new file mode 100644 index 00000000..a225f58e --- /dev/null +++ b/binapi/builtinurl/builtinurl_rpc.ba.go @@ -0,0 +1,31 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package builtinurl + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service builtinurl. +type RPCService interface { + BuiltinurlEnable(ctx context.Context, in *BuiltinurlEnable) (*BuiltinurlEnableReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) BuiltinurlEnable(ctx context.Context, in *BuiltinurlEnable) (*BuiltinurlEnableReply, error) { + out := new(BuiltinurlEnableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/cdp/cdp.ba.go b/binapi/cdp/cdp.ba.go new file mode 100644 index 00000000..65a6fb61 --- /dev/null +++ b/binapi/cdp/cdp.ba.go @@ -0,0 +1,124 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/cdp.api.json + +// Package cdp contains generated bindings for API file cdp.api. +// +// Contents: +// - 2 messages +package cdp + +import ( + api "github.com/alkiranet/govpp/api" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "cdp" + APIVersion = "1.0.0" + VersionCrc = 0x8cfa825e +) + +// /* +// - Simple enable/disable API for the cdp protocol +// * +// - Copyright (c) 2011-2018 by 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. +// +// CdpEnableDisable defines message 'cdp_enable_disable'. +type CdpEnableDisable struct { + EnableDisable bool `binapi:"bool,name=enable_disable" json:"enable_disable,omitempty"` +} + +func (m *CdpEnableDisable) Reset() { *m = CdpEnableDisable{} } +func (*CdpEnableDisable) GetMessageName() string { return "cdp_enable_disable" } +func (*CdpEnableDisable) GetCrcString() string { return "2e7b47df" } +func (*CdpEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *CdpEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.EnableDisable + return size +} +func (m *CdpEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.EnableDisable) + return buf.Bytes(), nil +} +func (m *CdpEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EnableDisable = buf.DecodeBool() + return nil +} + +// CdpEnableDisableReply defines message 'cdp_enable_disable_reply'. +type CdpEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *CdpEnableDisableReply) Reset() { *m = CdpEnableDisableReply{} } +func (*CdpEnableDisableReply) GetMessageName() string { return "cdp_enable_disable_reply" } +func (*CdpEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*CdpEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *CdpEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *CdpEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *CdpEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_cdp_binapi_init() } +func file_cdp_binapi_init() { + api.RegisterMessage((*CdpEnableDisable)(nil), "cdp_enable_disable_2e7b47df") + api.RegisterMessage((*CdpEnableDisableReply)(nil), "cdp_enable_disable_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*CdpEnableDisable)(nil), + (*CdpEnableDisableReply)(nil), + } +} diff --git a/binapi/cdp/cdp_rpc.ba.go b/binapi/cdp/cdp_rpc.ba.go new file mode 100644 index 00000000..299456f3 --- /dev/null +++ b/binapi/cdp/cdp_rpc.ba.go @@ -0,0 +1,31 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package cdp + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service cdp. +type RPCService interface { + CdpEnableDisable(ctx context.Context, in *CdpEnableDisable) (*CdpEnableDisableReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) CdpEnableDisable(ctx context.Context, in *CdpEnableDisable) (*CdpEnableDisableReply, error) { + out := new(CdpEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/classify/classify.ba.go b/binapi/classify/classify.ba.go new file mode 100644 index 00000000..448e0e20 --- /dev/null +++ b/binapi/classify/classify.ba.go @@ -0,0 +1,2289 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/classify.api.json + +// Package classify contains generated bindings for API file classify.api. +// +// Contents: +// - 3 enums +// - 44 messages +package classify + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "classify" + APIVersion = "3.1.0" + VersionCrc = 0x92a4f2c8 +) + +// ClassifyAction defines enum 'classify_action'. +type ClassifyAction uint8 + +const ( + CLASSIFY_API_ACTION_NONE ClassifyAction = 0 + CLASSIFY_API_ACTION_SET_IP4_FIB_INDEX ClassifyAction = 1 + CLASSIFY_API_ACTION_SET_IP6_FIB_INDEX ClassifyAction = 2 + CLASSIFY_API_ACTION_SET_METADATA ClassifyAction = 3 +) + +var ( + ClassifyAction_name = map[uint8]string{ + 0: "CLASSIFY_API_ACTION_NONE", + 1: "CLASSIFY_API_ACTION_SET_IP4_FIB_INDEX", + 2: "CLASSIFY_API_ACTION_SET_IP6_FIB_INDEX", + 3: "CLASSIFY_API_ACTION_SET_METADATA", + } + ClassifyAction_value = map[string]uint8{ + "CLASSIFY_API_ACTION_NONE": 0, + "CLASSIFY_API_ACTION_SET_IP4_FIB_INDEX": 1, + "CLASSIFY_API_ACTION_SET_IP6_FIB_INDEX": 2, + "CLASSIFY_API_ACTION_SET_METADATA": 3, + } +) + +func (x ClassifyAction) String() string { + s, ok := ClassifyAction_name[uint8(x)] + if ok { + return s + } + return "ClassifyAction(" + strconv.Itoa(int(x)) + ")" +} + +// FlowClassifyTable defines enum 'flow_classify_table'. +type FlowClassifyTable uint8 + +const ( + FLOW_CLASSIFY_API_TABLE_IP4 FlowClassifyTable = 0 + FLOW_CLASSIFY_API_TABLE_IP6 FlowClassifyTable = 1 +) + +var ( + FlowClassifyTable_name = map[uint8]string{ + 0: "FLOW_CLASSIFY_API_TABLE_IP4", + 1: "FLOW_CLASSIFY_API_TABLE_IP6", + } + FlowClassifyTable_value = map[string]uint8{ + "FLOW_CLASSIFY_API_TABLE_IP4": 0, + "FLOW_CLASSIFY_API_TABLE_IP6": 1, + } +) + +func (x FlowClassifyTable) String() string { + s, ok := FlowClassifyTable_name[uint8(x)] + if ok { + return s + } + return "FlowClassifyTable(" + strconv.Itoa(int(x)) + ")" +} + +// PolicerClassifyTable defines enum 'policer_classify_table'. +type PolicerClassifyTable uint8 + +const ( + POLICER_CLASSIFY_API_TABLE_IP4 PolicerClassifyTable = 0 + POLICER_CLASSIFY_API_TABLE_IP6 PolicerClassifyTable = 1 + POLICER_CLASSIFY_API_TABLE_L2 PolicerClassifyTable = 2 +) + +var ( + PolicerClassifyTable_name = map[uint8]string{ + 0: "POLICER_CLASSIFY_API_TABLE_IP4", + 1: "POLICER_CLASSIFY_API_TABLE_IP6", + 2: "POLICER_CLASSIFY_API_TABLE_L2", + } + PolicerClassifyTable_value = map[string]uint8{ + "POLICER_CLASSIFY_API_TABLE_IP4": 0, + "POLICER_CLASSIFY_API_TABLE_IP6": 1, + "POLICER_CLASSIFY_API_TABLE_L2": 2, + } +) + +func (x PolicerClassifyTable) String() string { + s, ok := PolicerClassifyTable_name[uint8(x)] + if ok { + return s + } + return "PolicerClassifyTable(" + strconv.Itoa(int(x)) + ")" +} + +// Classify add / del session request +// - is_add - add session if non-zero, else delete +// - table_index - index of the table to add/del the session, required +// - hit_next_index - for add, hit_next_index of new session, required +// - opaque_index - for add, opaque_index of new session +// - advance -for add, advance value for session +// - action - +// 0: no action (by default) +// metadata is not used. +// 1: Classified IP packets will be looked up from the +// specified ipv4 fib table (configured by metadata as VRF id). +// Only valid for L3 input ACL node +// 2: Classified IP packets will be looked up from the +// specified ipv6 fib table (configured by metadata as VRF id). +// Only valid for L3 input ACL node +// 3: Classified packet will be steered to source routing policy +// of given index (in metadata). +// This is only valid for IPv6 packets redirected to a source +// routing node. +// - metadata - valid only if action != 0 +// VRF id if action is 1 or 2. +// sr policy index if action is 3. +// - match_len - length of match, should be equal to skip_n_vectors plus match_n_vectors +// of target table times sizeof (u32x4) +// - match - for add, match value for session, required, +// needs to include bytes in front +// with length of skip_n_vectors of target table times sizeof (u32x4) +// (values of those bytes will be ignored) +// +// ClassifyAddDelSession defines message 'classify_add_del_session'. +type ClassifyAddDelSession struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` + HitNextIndex uint32 `binapi:"u32,name=hit_next_index,default=4294967295" json:"hit_next_index,omitempty"` + OpaqueIndex uint32 `binapi:"u32,name=opaque_index,default=4294967295" json:"opaque_index,omitempty"` + Advance int32 `binapi:"i32,name=advance,default=0" json:"advance,omitempty"` + Action ClassifyAction `binapi:"classify_action,name=action,default=0" json:"action,omitempty"` + Metadata uint32 `binapi:"u32,name=metadata,default=0" json:"metadata,omitempty"` + MatchLen uint32 `binapi:"u32,name=match_len" json:"-"` + Match []byte `binapi:"u8[match_len],name=match" json:"match,omitempty"` +} + +func (m *ClassifyAddDelSession) Reset() { *m = ClassifyAddDelSession{} } +func (*ClassifyAddDelSession) GetMessageName() string { return "classify_add_del_session" } +func (*ClassifyAddDelSession) GetCrcString() string { return "f20879f0" } +func (*ClassifyAddDelSession) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyAddDelSession) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.TableIndex + size += 4 // m.HitNextIndex + size += 4 // m.OpaqueIndex + size += 4 // m.Advance + size += 1 // m.Action + size += 4 // m.Metadata + size += 4 // m.MatchLen + size += 1 * len(m.Match) // m.Match + return size +} +func (m *ClassifyAddDelSession) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.TableIndex) + buf.EncodeUint32(m.HitNextIndex) + buf.EncodeUint32(m.OpaqueIndex) + buf.EncodeInt32(m.Advance) + buf.EncodeUint8(uint8(m.Action)) + buf.EncodeUint32(m.Metadata) + buf.EncodeUint32(uint32(len(m.Match))) + buf.EncodeBytes(m.Match, 0) + return buf.Bytes(), nil +} +func (m *ClassifyAddDelSession) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.TableIndex = buf.DecodeUint32() + m.HitNextIndex = buf.DecodeUint32() + m.OpaqueIndex = buf.DecodeUint32() + m.Advance = buf.DecodeInt32() + m.Action = ClassifyAction(buf.DecodeUint8()) + m.Metadata = buf.DecodeUint32() + m.MatchLen = buf.DecodeUint32() + m.Match = make([]byte, m.MatchLen) + copy(m.Match, buf.DecodeBytes(len(m.Match))) + return nil +} + +// ClassifyAddDelSessionReply defines message 'classify_add_del_session_reply'. +type ClassifyAddDelSessionReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *ClassifyAddDelSessionReply) Reset() { *m = ClassifyAddDelSessionReply{} } +func (*ClassifyAddDelSessionReply) GetMessageName() string { return "classify_add_del_session_reply" } +func (*ClassifyAddDelSessionReply) GetCrcString() string { return "e8d4e804" } +func (*ClassifyAddDelSessionReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyAddDelSessionReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *ClassifyAddDelSessionReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *ClassifyAddDelSessionReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add/Delete classification table request +// - is_add- if non-zero add the table, else delete it +// - del_chain - if non-zero delete the whole chain of tables +// - table_index - if add, returns index of the created table, else specifies the table to delete +// - nbuckets - number of buckets when adding a table +// - memory_size - memory size when adding a table +// - match_n_vectors - number of match vectors +// - next_table_index - index of next table +// - miss_next_index - index of miss table +// - current_data_flag - option to use current node's packet payload +// as the starting point from where packets are classified, +// This option is only valid for L2/L3 input ACL for now. +// 0: by default, classify data from the buffer's start location +// 1: classify packets from VPP node’s current data pointer +// - current_data_offset - a signed value to shift the start location of +// the packet to be classified +// For example, if input IP ACL node is used, L2 header’s first byte +// can be accessible by configuring current_data_offset to -14 +// if there is no vlan tag. +// This is valid only if current_data_flag is set to 1. +// - mask_len - length of match mask, should be equal to match_n_vectors * sizeof (u32x4) +// - mask - match mask +// +// ClassifyAddDelTable defines message 'classify_add_del_table'. +type ClassifyAddDelTable struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + DelChain bool `binapi:"bool,name=del_chain" json:"del_chain,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index,default=4294967295" json:"table_index,omitempty"` + Nbuckets uint32 `binapi:"u32,name=nbuckets,default=2" json:"nbuckets,omitempty"` + MemorySize uint32 `binapi:"u32,name=memory_size,default=2097152" json:"memory_size,omitempty"` + SkipNVectors uint32 `binapi:"u32,name=skip_n_vectors,default=0" json:"skip_n_vectors,omitempty"` + MatchNVectors uint32 `binapi:"u32,name=match_n_vectors,default=1" json:"match_n_vectors,omitempty"` + NextTableIndex uint32 `binapi:"u32,name=next_table_index,default=4294967295" json:"next_table_index,omitempty"` + MissNextIndex uint32 `binapi:"u32,name=miss_next_index,default=4294967295" json:"miss_next_index,omitempty"` + CurrentDataFlag uint8 `binapi:"u8,name=current_data_flag,default=0" json:"current_data_flag,omitempty"` + CurrentDataOffset int16 `binapi:"i16,name=current_data_offset,default=0" json:"current_data_offset,omitempty"` + MaskLen uint32 `binapi:"u32,name=mask_len" json:"-"` + Mask []byte `binapi:"u8[mask_len],name=mask" json:"mask,omitempty"` +} + +func (m *ClassifyAddDelTable) Reset() { *m = ClassifyAddDelTable{} } +func (*ClassifyAddDelTable) GetMessageName() string { return "classify_add_del_table" } +func (*ClassifyAddDelTable) GetCrcString() string { return "6849e39e" } +func (*ClassifyAddDelTable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyAddDelTable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.DelChain + size += 4 // m.TableIndex + size += 4 // m.Nbuckets + size += 4 // m.MemorySize + size += 4 // m.SkipNVectors + size += 4 // m.MatchNVectors + size += 4 // m.NextTableIndex + size += 4 // m.MissNextIndex + size += 1 // m.CurrentDataFlag + size += 2 // m.CurrentDataOffset + size += 4 // m.MaskLen + size += 1 * len(m.Mask) // m.Mask + return size +} +func (m *ClassifyAddDelTable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeBool(m.DelChain) + buf.EncodeUint32(m.TableIndex) + buf.EncodeUint32(m.Nbuckets) + buf.EncodeUint32(m.MemorySize) + buf.EncodeUint32(m.SkipNVectors) + buf.EncodeUint32(m.MatchNVectors) + buf.EncodeUint32(m.NextTableIndex) + buf.EncodeUint32(m.MissNextIndex) + buf.EncodeUint8(m.CurrentDataFlag) + buf.EncodeInt16(m.CurrentDataOffset) + buf.EncodeUint32(uint32(len(m.Mask))) + buf.EncodeBytes(m.Mask, 0) + return buf.Bytes(), nil +} +func (m *ClassifyAddDelTable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.DelChain = buf.DecodeBool() + m.TableIndex = buf.DecodeUint32() + m.Nbuckets = buf.DecodeUint32() + m.MemorySize = buf.DecodeUint32() + m.SkipNVectors = buf.DecodeUint32() + m.MatchNVectors = buf.DecodeUint32() + m.NextTableIndex = buf.DecodeUint32() + m.MissNextIndex = buf.DecodeUint32() + m.CurrentDataFlag = buf.DecodeUint8() + m.CurrentDataOffset = buf.DecodeInt16() + m.MaskLen = buf.DecodeUint32() + m.Mask = make([]byte, m.MaskLen) + copy(m.Mask, buf.DecodeBytes(len(m.Mask))) + return nil +} + +// Add/Delete classification table response +// - retval - return code for the table add/del request +// - new_table_index - for add, returned index of the new table +// - skip_n_vectors - for add, returned value of skip_n_vectors in table +// - match_n_vectors -for add, returned value of match_n_vectors in table +// +// ClassifyAddDelTableReply defines message 'classify_add_del_table_reply'. +type ClassifyAddDelTableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + NewTableIndex uint32 `binapi:"u32,name=new_table_index" json:"new_table_index,omitempty"` + SkipNVectors uint32 `binapi:"u32,name=skip_n_vectors" json:"skip_n_vectors,omitempty"` + MatchNVectors uint32 `binapi:"u32,name=match_n_vectors" json:"match_n_vectors,omitempty"` +} + +func (m *ClassifyAddDelTableReply) Reset() { *m = ClassifyAddDelTableReply{} } +func (*ClassifyAddDelTableReply) GetMessageName() string { return "classify_add_del_table_reply" } +func (*ClassifyAddDelTableReply) GetCrcString() string { return "05486349" } +func (*ClassifyAddDelTableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyAddDelTableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.NewTableIndex + size += 4 // m.SkipNVectors + size += 4 // m.MatchNVectors + return size +} +func (m *ClassifyAddDelTableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.NewTableIndex) + buf.EncodeUint32(m.SkipNVectors) + buf.EncodeUint32(m.MatchNVectors) + return buf.Bytes(), nil +} +func (m *ClassifyAddDelTableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.NewTableIndex = buf.DecodeUint32() + m.SkipNVectors = buf.DecodeUint32() + m.MatchNVectors = buf.DecodeUint32() + return nil +} + +// Classify get the PCAP table indices for an interface +// ClassifyPcapGetTables defines message 'classify_pcap_get_tables'. +type ClassifyPcapGetTables struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *ClassifyPcapGetTables) Reset() { *m = ClassifyPcapGetTables{} } +func (*ClassifyPcapGetTables) GetMessageName() string { return "classify_pcap_get_tables" } +func (*ClassifyPcapGetTables) GetCrcString() string { return "f9e6675e" } +func (*ClassifyPcapGetTables) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyPcapGetTables) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *ClassifyPcapGetTables) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *ClassifyPcapGetTables) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Classify get a PCAP tables response +// - retval - return code for the request +// - count - number of ids returned in response +// - indices - array of classify table indices +// +// ClassifyPcapGetTablesReply defines message 'classify_pcap_get_tables_reply'. +type ClassifyPcapGetTablesReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + Indices []uint32 `binapi:"u32[count],name=indices" json:"indices,omitempty"` +} + +func (m *ClassifyPcapGetTablesReply) Reset() { *m = ClassifyPcapGetTablesReply{} } +func (*ClassifyPcapGetTablesReply) GetMessageName() string { return "classify_pcap_get_tables_reply" } +func (*ClassifyPcapGetTablesReply) GetCrcString() string { return "5f5bc9e6" } +func (*ClassifyPcapGetTablesReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyPcapGetTablesReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + size += 4 * len(m.Indices) // m.Indices + return size +} +func (m *ClassifyPcapGetTablesReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.Indices))) + for i := 0; i < len(m.Indices); i++ { + var x uint32 + if i < len(m.Indices) { + x = uint32(m.Indices[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *ClassifyPcapGetTablesReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.Indices = make([]uint32, m.Count) + for i := 0; i < len(m.Indices); i++ { + m.Indices[i] = buf.DecodeUint32() + } + return nil +} + +// Find a compatible Classify table in a PCAP chain +// - sw_if_index - interface whose chain will be searched, 0==system-wide +// - skip_n_vectors - number of u32x4 skip vectors +// - match_n_vectors - number of u32x4 vectors, 1..5 +// - mask_len - length of mask, match_n_vectors * sizeof(u32x4) +// - mask - match mask +// +// ClassifyPcapLookupTable defines message 'classify_pcap_lookup_table'. +type ClassifyPcapLookupTable struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` + SkipNVectors uint32 `binapi:"u32,name=skip_n_vectors,default=0" json:"skip_n_vectors,omitempty"` + MatchNVectors uint32 `binapi:"u32,name=match_n_vectors,default=1" json:"match_n_vectors,omitempty"` + MaskLen uint32 `binapi:"u32,name=mask_len" json:"-"` + Mask []byte `binapi:"u8[mask_len],name=mask" json:"mask,omitempty"` +} + +func (m *ClassifyPcapLookupTable) Reset() { *m = ClassifyPcapLookupTable{} } +func (*ClassifyPcapLookupTable) GetMessageName() string { return "classify_pcap_lookup_table" } +func (*ClassifyPcapLookupTable) GetCrcString() string { return "e1b4cc6b" } +func (*ClassifyPcapLookupTable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyPcapLookupTable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.SkipNVectors + size += 4 // m.MatchNVectors + size += 4 // m.MaskLen + size += 1 * len(m.Mask) // m.Mask + return size +} +func (m *ClassifyPcapLookupTable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.SkipNVectors) + buf.EncodeUint32(m.MatchNVectors) + buf.EncodeUint32(uint32(len(m.Mask))) + buf.EncodeBytes(m.Mask, 0) + return buf.Bytes(), nil +} +func (m *ClassifyPcapLookupTable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.SkipNVectors = buf.DecodeUint32() + m.MatchNVectors = buf.DecodeUint32() + m.MaskLen = buf.DecodeUint32() + m.Mask = make([]byte, m.MaskLen) + copy(m.Mask, buf.DecodeBytes(len(m.Mask))) + return nil +} + +// Classify pcap table lookup response +// - retval - return code for the table lookup request +// - table_index - returned index of the found table, or ~0 +// +// ClassifyPcapLookupTableReply defines message 'classify_pcap_lookup_table_reply'. +type ClassifyPcapLookupTableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` +} + +func (m *ClassifyPcapLookupTableReply) Reset() { *m = ClassifyPcapLookupTableReply{} } +func (*ClassifyPcapLookupTableReply) GetMessageName() string { + return "classify_pcap_lookup_table_reply" +} +func (*ClassifyPcapLookupTableReply) GetCrcString() string { return "9c6c6773" } +func (*ClassifyPcapLookupTableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyPcapLookupTableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.TableIndex + return size +} +func (m *ClassifyPcapLookupTableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.TableIndex) + return buf.Bytes(), nil +} +func (m *ClassifyPcapLookupTableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.TableIndex = buf.DecodeUint32() + return nil +} + +// Add a Classify table into a PCAP chain on an interface +// - sw_if_index - interface whose chain will be searched, 0==system-wide +// - table_index - Classify table to be added +// - sort_masks - 1=sort masks into most-to-least specific order +// +// ClassifyPcapSetTable defines message 'classify_pcap_set_table'. +type ClassifyPcapSetTable struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index,default=4294967295" json:"table_index,omitempty"` + SortMasks bool `binapi:"bool,name=sort_masks,default=0" json:"sort_masks,omitempty"` +} + +func (m *ClassifyPcapSetTable) Reset() { *m = ClassifyPcapSetTable{} } +func (*ClassifyPcapSetTable) GetMessageName() string { return "classify_pcap_set_table" } +func (*ClassifyPcapSetTable) GetCrcString() string { return "006051b3" } +func (*ClassifyPcapSetTable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyPcapSetTable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.TableIndex + size += 1 // m.SortMasks + return size +} +func (m *ClassifyPcapSetTable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.TableIndex) + buf.EncodeBool(m.SortMasks) + return buf.Bytes(), nil +} +func (m *ClassifyPcapSetTable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.TableIndex = buf.DecodeUint32() + m.SortMasks = buf.DecodeBool() + return nil +} + +// Classify pcap table lookup response +// - retval - return code for the table lookup request +// - table_index - returned index of the sorted table chain +// +// ClassifyPcapSetTableReply defines message 'classify_pcap_set_table_reply'. +type ClassifyPcapSetTableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` +} + +func (m *ClassifyPcapSetTableReply) Reset() { *m = ClassifyPcapSetTableReply{} } +func (*ClassifyPcapSetTableReply) GetMessageName() string { return "classify_pcap_set_table_reply" } +func (*ClassifyPcapSetTableReply) GetCrcString() string { return "9c6c6773" } +func (*ClassifyPcapSetTableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyPcapSetTableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.TableIndex + return size +} +func (m *ClassifyPcapSetTableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.TableIndex) + return buf.Bytes(), nil +} +func (m *ClassifyPcapSetTableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.TableIndex = buf.DecodeUint32() + return nil +} + +// Reply for classify table session dump request +// - count - number of ids returned in response +// - table_id - classify table index +// - hit_next_index - hit_next_index of session +// - opaque_index - for add, opaque_index of session +// - advance - advance value of session +// - match[] - match value for session +// +// ClassifySessionDetails defines message 'classify_session_details'. +type ClassifySessionDetails struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + HitNextIndex uint32 `binapi:"u32,name=hit_next_index" json:"hit_next_index,omitempty"` + Advance int32 `binapi:"i32,name=advance" json:"advance,omitempty"` + OpaqueIndex uint32 `binapi:"u32,name=opaque_index" json:"opaque_index,omitempty"` + MatchLength uint32 `binapi:"u32,name=match_length" json:"-"` + Match []byte `binapi:"u8[match_length],name=match" json:"match,omitempty"` +} + +func (m *ClassifySessionDetails) Reset() { *m = ClassifySessionDetails{} } +func (*ClassifySessionDetails) GetMessageName() string { return "classify_session_details" } +func (*ClassifySessionDetails) GetCrcString() string { return "60e3ef94" } +func (*ClassifySessionDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifySessionDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.TableID + size += 4 // m.HitNextIndex + size += 4 // m.Advance + size += 4 // m.OpaqueIndex + size += 4 // m.MatchLength + size += 1 * len(m.Match) // m.Match + return size +} +func (m *ClassifySessionDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.TableID) + buf.EncodeUint32(m.HitNextIndex) + buf.EncodeInt32(m.Advance) + buf.EncodeUint32(m.OpaqueIndex) + buf.EncodeUint32(uint32(len(m.Match))) + buf.EncodeBytes(m.Match, 0) + return buf.Bytes(), nil +} +func (m *ClassifySessionDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.TableID = buf.DecodeUint32() + m.HitNextIndex = buf.DecodeUint32() + m.Advance = buf.DecodeInt32() + m.OpaqueIndex = buf.DecodeUint32() + m.MatchLength = buf.DecodeUint32() + m.Match = make([]byte, m.MatchLength) + copy(m.Match, buf.DecodeBytes(len(m.Match))) + return nil +} + +// Classify sessions dump request +// - table_id - classify table index +// +// ClassifySessionDump defines message 'classify_session_dump'. +type ClassifySessionDump struct { + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` +} + +func (m *ClassifySessionDump) Reset() { *m = ClassifySessionDump{} } +func (*ClassifySessionDump) GetMessageName() string { return "classify_session_dump" } +func (*ClassifySessionDump) GetCrcString() string { return "0cca2cd9" } +func (*ClassifySessionDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifySessionDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TableID + return size +} +func (m *ClassifySessionDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TableID) + return buf.Bytes(), nil +} +func (m *ClassifySessionDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TableID = buf.DecodeUint32() + return nil +} + +// Set/unset the classification table for an interface request +// - is_ipv6 - ipv6 if non-zero, else ipv4 +// - sw_if_index - interface to associate with the table +// - table_index - index of the table, if ~0 unset the table +// +// ClassifySetInterfaceIPTable defines message 'classify_set_interface_ip_table'. +type ClassifySetInterfaceIPTable struct { + IsIPv6 bool `binapi:"bool,name=is_ipv6" json:"is_ipv6,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` +} + +func (m *ClassifySetInterfaceIPTable) Reset() { *m = ClassifySetInterfaceIPTable{} } +func (*ClassifySetInterfaceIPTable) GetMessageName() string { return "classify_set_interface_ip_table" } +func (*ClassifySetInterfaceIPTable) GetCrcString() string { return "e0b097c7" } +func (*ClassifySetInterfaceIPTable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifySetInterfaceIPTable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsIPv6 + size += 4 // m.SwIfIndex + size += 4 // m.TableIndex + return size +} +func (m *ClassifySetInterfaceIPTable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsIPv6) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.TableIndex) + return buf.Bytes(), nil +} +func (m *ClassifySetInterfaceIPTable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsIPv6 = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.TableIndex = buf.DecodeUint32() + return nil +} + +// ClassifySetInterfaceIPTableReply defines message 'classify_set_interface_ip_table_reply'. +type ClassifySetInterfaceIPTableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *ClassifySetInterfaceIPTableReply) Reset() { *m = ClassifySetInterfaceIPTableReply{} } +func (*ClassifySetInterfaceIPTableReply) GetMessageName() string { + return "classify_set_interface_ip_table_reply" +} +func (*ClassifySetInterfaceIPTableReply) GetCrcString() string { return "e8d4e804" } +func (*ClassifySetInterfaceIPTableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifySetInterfaceIPTableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *ClassifySetInterfaceIPTableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *ClassifySetInterfaceIPTableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set/unset l2 classification tables for an interface request +// - sw_if_index - interface to set/unset tables for +// - ip4_table_index - ip4 index, use ~0 for all 3 indexes to unset +// - ip6_table_index - ip6 index +// - other_table_index - other index +// +// ClassifySetInterfaceL2Tables defines message 'classify_set_interface_l2_tables'. +type ClassifySetInterfaceL2Tables struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IP4TableIndex uint32 `binapi:"u32,name=ip4_table_index" json:"ip4_table_index,omitempty"` + IP6TableIndex uint32 `binapi:"u32,name=ip6_table_index" json:"ip6_table_index,omitempty"` + OtherTableIndex uint32 `binapi:"u32,name=other_table_index" json:"other_table_index,omitempty"` + IsInput bool `binapi:"bool,name=is_input" json:"is_input,omitempty"` +} + +func (m *ClassifySetInterfaceL2Tables) Reset() { *m = ClassifySetInterfaceL2Tables{} } +func (*ClassifySetInterfaceL2Tables) GetMessageName() string { + return "classify_set_interface_l2_tables" +} +func (*ClassifySetInterfaceL2Tables) GetCrcString() string { return "5a6ddf65" } +func (*ClassifySetInterfaceL2Tables) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifySetInterfaceL2Tables) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.IP4TableIndex + size += 4 // m.IP6TableIndex + size += 4 // m.OtherTableIndex + size += 1 // m.IsInput + return size +} +func (m *ClassifySetInterfaceL2Tables) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.IP4TableIndex) + buf.EncodeUint32(m.IP6TableIndex) + buf.EncodeUint32(m.OtherTableIndex) + buf.EncodeBool(m.IsInput) + return buf.Bytes(), nil +} +func (m *ClassifySetInterfaceL2Tables) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IP4TableIndex = buf.DecodeUint32() + m.IP6TableIndex = buf.DecodeUint32() + m.OtherTableIndex = buf.DecodeUint32() + m.IsInput = buf.DecodeBool() + return nil +} + +// ClassifySetInterfaceL2TablesReply defines message 'classify_set_interface_l2_tables_reply'. +type ClassifySetInterfaceL2TablesReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *ClassifySetInterfaceL2TablesReply) Reset() { *m = ClassifySetInterfaceL2TablesReply{} } +func (*ClassifySetInterfaceL2TablesReply) GetMessageName() string { + return "classify_set_interface_l2_tables_reply" +} +func (*ClassifySetInterfaceL2TablesReply) GetCrcString() string { return "e8d4e804" } +func (*ClassifySetInterfaceL2TablesReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifySetInterfaceL2TablesReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *ClassifySetInterfaceL2TablesReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *ClassifySetInterfaceL2TablesReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Classify table ids by interface index request +// - sw_if_index - index of the interface +// +// ClassifyTableByInterface defines message 'classify_table_by_interface'. +type ClassifyTableByInterface struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *ClassifyTableByInterface) Reset() { *m = ClassifyTableByInterface{} } +func (*ClassifyTableByInterface) GetMessageName() string { return "classify_table_by_interface" } +func (*ClassifyTableByInterface) GetCrcString() string { return "f9e6675e" } +func (*ClassifyTableByInterface) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyTableByInterface) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *ClassifyTableByInterface) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *ClassifyTableByInterface) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Reply for classify table id by interface index request +// - count - number of ids returned in response +// - sw_if_index - index of the interface +// - l2_table_id - l2 classify table index +// - ip4_table_id - ip4 classify table index +// - ip6_table_id - ip6 classify table index +// +// ClassifyTableByInterfaceReply defines message 'classify_table_by_interface_reply'. +type ClassifyTableByInterfaceReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + L2TableID uint32 `binapi:"u32,name=l2_table_id" json:"l2_table_id,omitempty"` + IP4TableID uint32 `binapi:"u32,name=ip4_table_id" json:"ip4_table_id,omitempty"` + IP6TableID uint32 `binapi:"u32,name=ip6_table_id" json:"ip6_table_id,omitempty"` +} + +func (m *ClassifyTableByInterfaceReply) Reset() { *m = ClassifyTableByInterfaceReply{} } +func (*ClassifyTableByInterfaceReply) GetMessageName() string { + return "classify_table_by_interface_reply" +} +func (*ClassifyTableByInterfaceReply) GetCrcString() string { return "ed4197db" } +func (*ClassifyTableByInterfaceReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyTableByInterfaceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + size += 4 // m.L2TableID + size += 4 // m.IP4TableID + size += 4 // m.IP6TableID + return size +} +func (m *ClassifyTableByInterfaceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.L2TableID) + buf.EncodeUint32(m.IP4TableID) + buf.EncodeUint32(m.IP6TableID) + return buf.Bytes(), nil +} +func (m *ClassifyTableByInterfaceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.L2TableID = buf.DecodeUint32() + m.IP4TableID = buf.DecodeUint32() + m.IP6TableID = buf.DecodeUint32() + return nil +} + +// Classify get table IDs request +// ClassifyTableIds defines message 'classify_table_ids'. +type ClassifyTableIds struct{} + +func (m *ClassifyTableIds) Reset() { *m = ClassifyTableIds{} } +func (*ClassifyTableIds) GetMessageName() string { return "classify_table_ids" } +func (*ClassifyTableIds) GetCrcString() string { return "51077d14" } +func (*ClassifyTableIds) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyTableIds) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ClassifyTableIds) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ClassifyTableIds) Unmarshal(b []byte) error { + return nil +} + +// Reply for classify get table IDs request +// - count - number of ids returned in response +// - ids - array of classify table ids +// +// ClassifyTableIdsReply defines message 'classify_table_ids_reply'. +type ClassifyTableIdsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + Ids []uint32 `binapi:"u32[count],name=ids" json:"ids,omitempty"` +} + +func (m *ClassifyTableIdsReply) Reset() { *m = ClassifyTableIdsReply{} } +func (*ClassifyTableIdsReply) GetMessageName() string { return "classify_table_ids_reply" } +func (*ClassifyTableIdsReply) GetCrcString() string { return "d1d20e1d" } +func (*ClassifyTableIdsReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyTableIdsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + size += 4 * len(m.Ids) // m.Ids + return size +} +func (m *ClassifyTableIdsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.Ids))) + for i := 0; i < len(m.Ids); i++ { + var x uint32 + if i < len(m.Ids) { + x = uint32(m.Ids[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *ClassifyTableIdsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.Ids = make([]uint32, m.Count) + for i := 0; i < len(m.Ids); i++ { + m.Ids[i] = buf.DecodeUint32() + } + return nil +} + +// Classify table info +// - table_id - classify table index +// +// ClassifyTableInfo defines message 'classify_table_info'. +type ClassifyTableInfo struct { + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` +} + +func (m *ClassifyTableInfo) Reset() { *m = ClassifyTableInfo{} } +func (*ClassifyTableInfo) GetMessageName() string { return "classify_table_info" } +func (*ClassifyTableInfo) GetCrcString() string { return "0cca2cd9" } +func (*ClassifyTableInfo) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyTableInfo) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TableID + return size +} +func (m *ClassifyTableInfo) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TableID) + return buf.Bytes(), nil +} +func (m *ClassifyTableInfo) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TableID = buf.DecodeUint32() + return nil +} + +// Reply for classify table info request +// - count - number of ids returned in response +// - table_id - classify table index +// - nbuckets - number of buckets when adding a table +// - match_n_vectors - number of match vectors +// - skip_n_vectors - number of skip_n_vectors +// - active_sessions - number of sessions (active entries) +// - next_table_index - index of next table +// - miss_next_index - index of miss table +// - mask[] - match mask +// +// ClassifyTableInfoReply defines message 'classify_table_info_reply'. +type ClassifyTableInfoReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + Nbuckets uint32 `binapi:"u32,name=nbuckets" json:"nbuckets,omitempty"` + MatchNVectors uint32 `binapi:"u32,name=match_n_vectors" json:"match_n_vectors,omitempty"` + SkipNVectors uint32 `binapi:"u32,name=skip_n_vectors" json:"skip_n_vectors,omitempty"` + ActiveSessions uint32 `binapi:"u32,name=active_sessions" json:"active_sessions,omitempty"` + NextTableIndex uint32 `binapi:"u32,name=next_table_index" json:"next_table_index,omitempty"` + MissNextIndex uint32 `binapi:"u32,name=miss_next_index" json:"miss_next_index,omitempty"` + MaskLength uint32 `binapi:"u32,name=mask_length" json:"-"` + Mask []byte `binapi:"u8[mask_length],name=mask" json:"mask,omitempty"` +} + +func (m *ClassifyTableInfoReply) Reset() { *m = ClassifyTableInfoReply{} } +func (*ClassifyTableInfoReply) GetMessageName() string { return "classify_table_info_reply" } +func (*ClassifyTableInfoReply) GetCrcString() string { return "4a573c0e" } +func (*ClassifyTableInfoReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyTableInfoReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.TableID + size += 4 // m.Nbuckets + size += 4 // m.MatchNVectors + size += 4 // m.SkipNVectors + size += 4 // m.ActiveSessions + size += 4 // m.NextTableIndex + size += 4 // m.MissNextIndex + size += 4 // m.MaskLength + size += 1 * len(m.Mask) // m.Mask + return size +} +func (m *ClassifyTableInfoReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.TableID) + buf.EncodeUint32(m.Nbuckets) + buf.EncodeUint32(m.MatchNVectors) + buf.EncodeUint32(m.SkipNVectors) + buf.EncodeUint32(m.ActiveSessions) + buf.EncodeUint32(m.NextTableIndex) + buf.EncodeUint32(m.MissNextIndex) + buf.EncodeUint32(uint32(len(m.Mask))) + buf.EncodeBytes(m.Mask, 0) + return buf.Bytes(), nil +} +func (m *ClassifyTableInfoReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.TableID = buf.DecodeUint32() + m.Nbuckets = buf.DecodeUint32() + m.MatchNVectors = buf.DecodeUint32() + m.SkipNVectors = buf.DecodeUint32() + m.ActiveSessions = buf.DecodeUint32() + m.NextTableIndex = buf.DecodeUint32() + m.MissNextIndex = buf.DecodeUint32() + m.MaskLength = buf.DecodeUint32() + m.Mask = make([]byte, m.MaskLength) + copy(m.Mask, buf.DecodeBytes(len(m.Mask))) + return nil +} + +// Classify get the Trace table indices +// ClassifyTraceGetTables defines message 'classify_trace_get_tables'. +type ClassifyTraceGetTables struct{} + +func (m *ClassifyTraceGetTables) Reset() { *m = ClassifyTraceGetTables{} } +func (*ClassifyTraceGetTables) GetMessageName() string { return "classify_trace_get_tables" } +func (*ClassifyTraceGetTables) GetCrcString() string { return "51077d14" } +func (*ClassifyTraceGetTables) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyTraceGetTables) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ClassifyTraceGetTables) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ClassifyTraceGetTables) Unmarshal(b []byte) error { + return nil +} + +// Classify get the Trace tables response +// - retval - return code for the request +// - count - number of ids returned in response +// - indices - array of classify table indices +// +// ClassifyTraceGetTablesReply defines message 'classify_trace_get_tables_reply'. +type ClassifyTraceGetTablesReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + Indices []uint32 `binapi:"u32[count],name=indices" json:"indices,omitempty"` +} + +func (m *ClassifyTraceGetTablesReply) Reset() { *m = ClassifyTraceGetTablesReply{} } +func (*ClassifyTraceGetTablesReply) GetMessageName() string { return "classify_trace_get_tables_reply" } +func (*ClassifyTraceGetTablesReply) GetCrcString() string { return "5f5bc9e6" } +func (*ClassifyTraceGetTablesReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyTraceGetTablesReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + size += 4 * len(m.Indices) // m.Indices + return size +} +func (m *ClassifyTraceGetTablesReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.Indices))) + for i := 0; i < len(m.Indices); i++ { + var x uint32 + if i < len(m.Indices) { + x = uint32(m.Indices[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *ClassifyTraceGetTablesReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.Indices = make([]uint32, m.Count) + for i := 0; i < len(m.Indices); i++ { + m.Indices[i] = buf.DecodeUint32() + } + return nil +} + +// Find a mask-compatible Classify table in the Trace chain +// - skip_n_vectors - number of u32x4 skip vectors +// - match_n_vectors - number of u32x4 vectors, 1..5 +// - mask_len - length of mask, match_n_vectors * sizeof(u32x4) +// - mask - match mask +// +// ClassifyTraceLookupTable defines message 'classify_trace_lookup_table'. +type ClassifyTraceLookupTable struct { + SkipNVectors uint32 `binapi:"u32,name=skip_n_vectors,default=0" json:"skip_n_vectors,omitempty"` + MatchNVectors uint32 `binapi:"u32,name=match_n_vectors,default=1" json:"match_n_vectors,omitempty"` + MaskLen uint32 `binapi:"u32,name=mask_len" json:"-"` + Mask []byte `binapi:"u8[mask_len],name=mask" json:"mask,omitempty"` +} + +func (m *ClassifyTraceLookupTable) Reset() { *m = ClassifyTraceLookupTable{} } +func (*ClassifyTraceLookupTable) GetMessageName() string { return "classify_trace_lookup_table" } +func (*ClassifyTraceLookupTable) GetCrcString() string { return "3f7b72e4" } +func (*ClassifyTraceLookupTable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyTraceLookupTable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SkipNVectors + size += 4 // m.MatchNVectors + size += 4 // m.MaskLen + size += 1 * len(m.Mask) // m.Mask + return size +} +func (m *ClassifyTraceLookupTable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.SkipNVectors) + buf.EncodeUint32(m.MatchNVectors) + buf.EncodeUint32(uint32(len(m.Mask))) + buf.EncodeBytes(m.Mask, 0) + return buf.Bytes(), nil +} +func (m *ClassifyTraceLookupTable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SkipNVectors = buf.DecodeUint32() + m.MatchNVectors = buf.DecodeUint32() + m.MaskLen = buf.DecodeUint32() + m.Mask = make([]byte, m.MaskLen) + copy(m.Mask, buf.DecodeBytes(len(m.Mask))) + return nil +} + +// Classify trace table lookup response +// - retval - return code for the table lookup request +// - table_index - returned index of the found table, or ~0 +// +// ClassifyTraceLookupTableReply defines message 'classify_trace_lookup_table_reply'. +type ClassifyTraceLookupTableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` +} + +func (m *ClassifyTraceLookupTableReply) Reset() { *m = ClassifyTraceLookupTableReply{} } +func (*ClassifyTraceLookupTableReply) GetMessageName() string { + return "classify_trace_lookup_table_reply" +} +func (*ClassifyTraceLookupTableReply) GetCrcString() string { return "9c6c6773" } +func (*ClassifyTraceLookupTableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyTraceLookupTableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.TableIndex + return size +} +func (m *ClassifyTraceLookupTableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.TableIndex) + return buf.Bytes(), nil +} +func (m *ClassifyTraceLookupTableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.TableIndex = buf.DecodeUint32() + return nil +} + +// Add a Classify table into the Trace chain +// - table_index - Classify table to be added +// - sort_masks - 1=sort masks into most-to-least specific order +// +// ClassifyTraceSetTable defines message 'classify_trace_set_table'. +type ClassifyTraceSetTable struct { + TableIndex uint32 `binapi:"u32,name=table_index,default=4294967295" json:"table_index,omitempty"` + SortMasks bool `binapi:"bool,name=sort_masks,default=0" json:"sort_masks,omitempty"` +} + +func (m *ClassifyTraceSetTable) Reset() { *m = ClassifyTraceSetTable{} } +func (*ClassifyTraceSetTable) GetMessageName() string { return "classify_trace_set_table" } +func (*ClassifyTraceSetTable) GetCrcString() string { return "3909b55a" } +func (*ClassifyTraceSetTable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyTraceSetTable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TableIndex + size += 1 // m.SortMasks + return size +} +func (m *ClassifyTraceSetTable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TableIndex) + buf.EncodeBool(m.SortMasks) + return buf.Bytes(), nil +} +func (m *ClassifyTraceSetTable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TableIndex = buf.DecodeUint32() + m.SortMasks = buf.DecodeBool() + return nil +} + +// Classify Trace table lookup response +// - retval - return code for the table lookup request +// - table_index - returned index of the sorted table chain +// +// ClassifyTraceSetTableReply defines message 'classify_trace_set_table_reply'. +type ClassifyTraceSetTableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` +} + +func (m *ClassifyTraceSetTableReply) Reset() { *m = ClassifyTraceSetTableReply{} } +func (*ClassifyTraceSetTableReply) GetMessageName() string { return "classify_trace_set_table_reply" } +func (*ClassifyTraceSetTableReply) GetCrcString() string { return "9c6c6773" } +func (*ClassifyTraceSetTableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyTraceSetTableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.TableIndex + return size +} +func (m *ClassifyTraceSetTableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.TableIndex) + return buf.Bytes(), nil +} +func (m *ClassifyTraceSetTableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.TableIndex = buf.DecodeUint32() + return nil +} + +// Flow classify operational state response. +// - sw_if_index - software interface index +// - table_index - classify table index +// +// FlowClassifyDetails defines message 'flow_classify_details'. +type FlowClassifyDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` +} + +func (m *FlowClassifyDetails) Reset() { *m = FlowClassifyDetails{} } +func (*FlowClassifyDetails) GetMessageName() string { return "flow_classify_details" } +func (*FlowClassifyDetails) GetCrcString() string { return "dfd08765" } +func (*FlowClassifyDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *FlowClassifyDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.TableIndex + return size +} +func (m *FlowClassifyDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.TableIndex) + return buf.Bytes(), nil +} +func (m *FlowClassifyDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.TableIndex = buf.DecodeUint32() + return nil +} + +// Get list of flow classify interfaces and tables +// - type - flow classify table type +// - sw_if_index - filter on sw_if_index +// +// FlowClassifyDump defines message 'flow_classify_dump'. +type FlowClassifyDump struct { + Type FlowClassifyTable `binapi:"flow_classify_table,name=type" json:"type,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *FlowClassifyDump) Reset() { *m = FlowClassifyDump{} } +func (*FlowClassifyDump) GetMessageName() string { return "flow_classify_dump" } +func (*FlowClassifyDump) GetCrcString() string { return "25dd3e4c" } +func (*FlowClassifyDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *FlowClassifyDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Type + size += 4 // m.SwIfIndex + return size +} +func (m *FlowClassifyDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Type)) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *FlowClassifyDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Type = FlowClassifyTable(buf.DecodeUint8()) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Set/unset flow classify interface +// - sw_if_index - interface to set/unset flow classify +// - ip4_table_index - ip4 classify table index (~0 for skip) +// - ip6_table_index - ip6 classify table index (~0 for skip) +// - l2_table_index - l2 classify table index (~0 for skip) +// - is_add - Set if non-zero, else unset +// Note: User is recommended to use just one valid table_index per call. +// (ip4_table_index, ip6_table_index, or l2_table_index) +// +// FlowClassifySetInterface defines message 'flow_classify_set_interface'. +type FlowClassifySetInterface struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IP4TableIndex uint32 `binapi:"u32,name=ip4_table_index" json:"ip4_table_index,omitempty"` + IP6TableIndex uint32 `binapi:"u32,name=ip6_table_index" json:"ip6_table_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` +} + +func (m *FlowClassifySetInterface) Reset() { *m = FlowClassifySetInterface{} } +func (*FlowClassifySetInterface) GetMessageName() string { return "flow_classify_set_interface" } +func (*FlowClassifySetInterface) GetCrcString() string { return "b6192f1c" } +func (*FlowClassifySetInterface) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *FlowClassifySetInterface) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.IP4TableIndex + size += 4 // m.IP6TableIndex + size += 1 // m.IsAdd + return size +} +func (m *FlowClassifySetInterface) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.IP4TableIndex) + buf.EncodeUint32(m.IP6TableIndex) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *FlowClassifySetInterface) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IP4TableIndex = buf.DecodeUint32() + m.IP6TableIndex = buf.DecodeUint32() + m.IsAdd = buf.DecodeBool() + return nil +} + +// FlowClassifySetInterfaceReply defines message 'flow_classify_set_interface_reply'. +type FlowClassifySetInterfaceReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *FlowClassifySetInterfaceReply) Reset() { *m = FlowClassifySetInterfaceReply{} } +func (*FlowClassifySetInterfaceReply) GetMessageName() string { + return "flow_classify_set_interface_reply" +} +func (*FlowClassifySetInterfaceReply) GetCrcString() string { return "e8d4e804" } +func (*FlowClassifySetInterfaceReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *FlowClassifySetInterfaceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *FlowClassifySetInterfaceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *FlowClassifySetInterfaceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set/unset input ACL interface +// - sw_if_index - interface to set/unset input ACL +// - ip4_table_index - ip4 classify table index (~0 for skip) +// - ip6_table_index - ip6 classify table index (~0 for skip) +// - l2_table_index - l2 classify table index (~0 for skip) +// - is_add - Set input ACL if non-zero, else unset +// Note: User is recommended to use just one valid table_index per call. +// (ip4_table_index, ip6_table_index, or l2_table_index) +// +// InputACLSetInterface defines message 'input_acl_set_interface'. +type InputACLSetInterface struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IP4TableIndex uint32 `binapi:"u32,name=ip4_table_index" json:"ip4_table_index,omitempty"` + IP6TableIndex uint32 `binapi:"u32,name=ip6_table_index" json:"ip6_table_index,omitempty"` + L2TableIndex uint32 `binapi:"u32,name=l2_table_index" json:"l2_table_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` +} + +func (m *InputACLSetInterface) Reset() { *m = InputACLSetInterface{} } +func (*InputACLSetInterface) GetMessageName() string { return "input_acl_set_interface" } +func (*InputACLSetInterface) GetCrcString() string { return "de7ad708" } +func (*InputACLSetInterface) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *InputACLSetInterface) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.IP4TableIndex + size += 4 // m.IP6TableIndex + size += 4 // m.L2TableIndex + size += 1 // m.IsAdd + return size +} +func (m *InputACLSetInterface) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.IP4TableIndex) + buf.EncodeUint32(m.IP6TableIndex) + buf.EncodeUint32(m.L2TableIndex) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *InputACLSetInterface) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IP4TableIndex = buf.DecodeUint32() + m.IP6TableIndex = buf.DecodeUint32() + m.L2TableIndex = buf.DecodeUint32() + m.IsAdd = buf.DecodeBool() + return nil +} + +// InputACLSetInterfaceReply defines message 'input_acl_set_interface_reply'. +type InputACLSetInterfaceReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *InputACLSetInterfaceReply) Reset() { *m = InputACLSetInterfaceReply{} } +func (*InputACLSetInterfaceReply) GetMessageName() string { return "input_acl_set_interface_reply" } +func (*InputACLSetInterfaceReply) GetCrcString() string { return "e8d4e804" } +func (*InputACLSetInterfaceReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *InputACLSetInterfaceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *InputACLSetInterfaceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *InputACLSetInterfaceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set/unset output ACL interface +// - sw_if_index - interface to set/unset output ACL +// - ip4_table_index - ip4 classify table index (~0 for skip) +// - ip6_table_index - ip6 classify table index (~0 for skip) +// - l2_table_index - l2 classify table index (~0 for skip) +// - is_add - Set output ACL if non-zero, else unset +// Note: User is recommended to use just one valid table_index per call. +// (ip4_table_index, ip6_table_index, or l2_table_index) +// +// OutputACLSetInterface defines message 'output_acl_set_interface'. +type OutputACLSetInterface struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IP4TableIndex uint32 `binapi:"u32,name=ip4_table_index" json:"ip4_table_index,omitempty"` + IP6TableIndex uint32 `binapi:"u32,name=ip6_table_index" json:"ip6_table_index,omitempty"` + L2TableIndex uint32 `binapi:"u32,name=l2_table_index" json:"l2_table_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` +} + +func (m *OutputACLSetInterface) Reset() { *m = OutputACLSetInterface{} } +func (*OutputACLSetInterface) GetMessageName() string { return "output_acl_set_interface" } +func (*OutputACLSetInterface) GetCrcString() string { return "de7ad708" } +func (*OutputACLSetInterface) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OutputACLSetInterface) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.IP4TableIndex + size += 4 // m.IP6TableIndex + size += 4 // m.L2TableIndex + size += 1 // m.IsAdd + return size +} +func (m *OutputACLSetInterface) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.IP4TableIndex) + buf.EncodeUint32(m.IP6TableIndex) + buf.EncodeUint32(m.L2TableIndex) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *OutputACLSetInterface) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IP4TableIndex = buf.DecodeUint32() + m.IP6TableIndex = buf.DecodeUint32() + m.L2TableIndex = buf.DecodeUint32() + m.IsAdd = buf.DecodeBool() + return nil +} + +// OutputACLSetInterfaceReply defines message 'output_acl_set_interface_reply'. +type OutputACLSetInterfaceReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OutputACLSetInterfaceReply) Reset() { *m = OutputACLSetInterfaceReply{} } +func (*OutputACLSetInterfaceReply) GetMessageName() string { return "output_acl_set_interface_reply" } +func (*OutputACLSetInterfaceReply) GetCrcString() string { return "e8d4e804" } +func (*OutputACLSetInterfaceReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OutputACLSetInterfaceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OutputACLSetInterfaceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OutputACLSetInterfaceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Policer classify operational state response. +// - sw_if_index - software interface index +// - table_index - classify table index +// +// PolicerClassifyDetails defines message 'policer_classify_details'. +type PolicerClassifyDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` +} + +func (m *PolicerClassifyDetails) Reset() { *m = PolicerClassifyDetails{} } +func (*PolicerClassifyDetails) GetMessageName() string { return "policer_classify_details" } +func (*PolicerClassifyDetails) GetCrcString() string { return "dfd08765" } +func (*PolicerClassifyDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerClassifyDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.TableIndex + return size +} +func (m *PolicerClassifyDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.TableIndex) + return buf.Bytes(), nil +} +func (m *PolicerClassifyDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.TableIndex = buf.DecodeUint32() + return nil +} + +// Get list of policer classify interfaces and tables +// - type - classify table type +// - sw_if_index - filter on sw_if_index +// +// PolicerClassifyDump defines message 'policer_classify_dump'. +type PolicerClassifyDump struct { + Type PolicerClassifyTable `binapi:"policer_classify_table,name=type" json:"type,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *PolicerClassifyDump) Reset() { *m = PolicerClassifyDump{} } +func (*PolicerClassifyDump) GetMessageName() string { return "policer_classify_dump" } +func (*PolicerClassifyDump) GetCrcString() string { return "56cbb5fb" } +func (*PolicerClassifyDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerClassifyDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Type + size += 4 // m.SwIfIndex + return size +} +func (m *PolicerClassifyDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Type)) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *PolicerClassifyDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Type = PolicerClassifyTable(buf.DecodeUint8()) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Set/unset policer classify interface +// - sw_if_index - interface to set/unset policer classify +// - ip4_table_index - ip4 classify table index (~0 for skip) +// - ip6_table_index - ip6 classify table index (~0 for skip) +// - l2_table_index - l2 classify table index (~0 for skip) +// - is_add - Set if non-zero, else unset +// Note: User is recommended to use just one valid table_index per call. +// (ip4_table_index, ip6_table_index, or l2_table_index) +// +// PolicerClassifySetInterface defines message 'policer_classify_set_interface'. +type PolicerClassifySetInterface struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IP4TableIndex uint32 `binapi:"u32,name=ip4_table_index" json:"ip4_table_index,omitempty"` + IP6TableIndex uint32 `binapi:"u32,name=ip6_table_index" json:"ip6_table_index,omitempty"` + L2TableIndex uint32 `binapi:"u32,name=l2_table_index" json:"l2_table_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` +} + +func (m *PolicerClassifySetInterface) Reset() { *m = PolicerClassifySetInterface{} } +func (*PolicerClassifySetInterface) GetMessageName() string { return "policer_classify_set_interface" } +func (*PolicerClassifySetInterface) GetCrcString() string { return "de7ad708" } +func (*PolicerClassifySetInterface) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerClassifySetInterface) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.IP4TableIndex + size += 4 // m.IP6TableIndex + size += 4 // m.L2TableIndex + size += 1 // m.IsAdd + return size +} +func (m *PolicerClassifySetInterface) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.IP4TableIndex) + buf.EncodeUint32(m.IP6TableIndex) + buf.EncodeUint32(m.L2TableIndex) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *PolicerClassifySetInterface) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IP4TableIndex = buf.DecodeUint32() + m.IP6TableIndex = buf.DecodeUint32() + m.L2TableIndex = buf.DecodeUint32() + m.IsAdd = buf.DecodeBool() + return nil +} + +// PolicerClassifySetInterfaceReply defines message 'policer_classify_set_interface_reply'. +type PolicerClassifySetInterfaceReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PolicerClassifySetInterfaceReply) Reset() { *m = PolicerClassifySetInterfaceReply{} } +func (*PolicerClassifySetInterfaceReply) GetMessageName() string { + return "policer_classify_set_interface_reply" +} +func (*PolicerClassifySetInterfaceReply) GetCrcString() string { return "e8d4e804" } +func (*PolicerClassifySetInterfaceReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerClassifySetInterfaceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PolicerClassifySetInterfaceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PolicerClassifySetInterfaceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add/del punt ACL +// - ip4_table_index - ip4 punt classify table index (~0 for skip) +// - ip6_table_index - ip6 punt classify table index (~0 for skip) +// - is_add - add punt ACL if non-zero, else delete +// +// PuntACLAddDel defines message 'punt_acl_add_del'. +type PuntACLAddDel struct { + IP4TableIndex uint32 `binapi:"u32,name=ip4_table_index,default=4294967295" json:"ip4_table_index,omitempty"` + IP6TableIndex uint32 `binapi:"u32,name=ip6_table_index,default=4294967295" json:"ip6_table_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` +} + +func (m *PuntACLAddDel) Reset() { *m = PuntACLAddDel{} } +func (*PuntACLAddDel) GetMessageName() string { return "punt_acl_add_del" } +func (*PuntACLAddDel) GetCrcString() string { return "a93bf3a0" } +func (*PuntACLAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PuntACLAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.IP4TableIndex + size += 4 // m.IP6TableIndex + size += 1 // m.IsAdd + return size +} +func (m *PuntACLAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.IP4TableIndex) + buf.EncodeUint32(m.IP6TableIndex) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *PuntACLAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IP4TableIndex = buf.DecodeUint32() + m.IP6TableIndex = buf.DecodeUint32() + m.IsAdd = buf.DecodeBool() + return nil +} + +// PuntACLAddDelReply defines message 'punt_acl_add_del_reply'. +type PuntACLAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PuntACLAddDelReply) Reset() { *m = PuntACLAddDelReply{} } +func (*PuntACLAddDelReply) GetMessageName() string { return "punt_acl_add_del_reply" } +func (*PuntACLAddDelReply) GetCrcString() string { return "e8d4e804" } +func (*PuntACLAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PuntACLAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PuntACLAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PuntACLAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Get classify table ids configured for punt ACL +// PuntACLGet defines message 'punt_acl_get'. +type PuntACLGet struct{} + +func (m *PuntACLGet) Reset() { *m = PuntACLGet{} } +func (*PuntACLGet) GetMessageName() string { return "punt_acl_get" } +func (*PuntACLGet) GetCrcString() string { return "51077d14" } +func (*PuntACLGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PuntACLGet) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *PuntACLGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *PuntACLGet) Unmarshal(b []byte) error { + return nil +} + +// Reply for punt_acl_get +// - retval - return value (0 for success) +// - ip4_table_index - ip4 punt classify table index (~0 for none) +// - ip6_table_index - ip6 punt classify table index (~0 for none) +// +// PuntACLGetReply defines message 'punt_acl_get_reply'. +type PuntACLGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IP4TableIndex uint32 `binapi:"u32,name=ip4_table_index" json:"ip4_table_index,omitempty"` + IP6TableIndex uint32 `binapi:"u32,name=ip6_table_index" json:"ip6_table_index,omitempty"` +} + +func (m *PuntACLGetReply) Reset() { *m = PuntACLGetReply{} } +func (*PuntACLGetReply) GetMessageName() string { return "punt_acl_get_reply" } +func (*PuntACLGetReply) GetCrcString() string { return "8409b9dd" } +func (*PuntACLGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PuntACLGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.IP4TableIndex + size += 4 // m.IP6TableIndex + return size +} +func (m *PuntACLGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.IP4TableIndex) + buf.EncodeUint32(m.IP6TableIndex) + return buf.Bytes(), nil +} +func (m *PuntACLGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IP4TableIndex = buf.DecodeUint32() + m.IP6TableIndex = buf.DecodeUint32() + return nil +} + +func init() { file_classify_binapi_init() } +func file_classify_binapi_init() { + api.RegisterMessage((*ClassifyAddDelSession)(nil), "classify_add_del_session_f20879f0") + api.RegisterMessage((*ClassifyAddDelSessionReply)(nil), "classify_add_del_session_reply_e8d4e804") + api.RegisterMessage((*ClassifyAddDelTable)(nil), "classify_add_del_table_6849e39e") + api.RegisterMessage((*ClassifyAddDelTableReply)(nil), "classify_add_del_table_reply_05486349") + api.RegisterMessage((*ClassifyPcapGetTables)(nil), "classify_pcap_get_tables_f9e6675e") + api.RegisterMessage((*ClassifyPcapGetTablesReply)(nil), "classify_pcap_get_tables_reply_5f5bc9e6") + api.RegisterMessage((*ClassifyPcapLookupTable)(nil), "classify_pcap_lookup_table_e1b4cc6b") + api.RegisterMessage((*ClassifyPcapLookupTableReply)(nil), "classify_pcap_lookup_table_reply_9c6c6773") + api.RegisterMessage((*ClassifyPcapSetTable)(nil), "classify_pcap_set_table_006051b3") + api.RegisterMessage((*ClassifyPcapSetTableReply)(nil), "classify_pcap_set_table_reply_9c6c6773") + api.RegisterMessage((*ClassifySessionDetails)(nil), "classify_session_details_60e3ef94") + api.RegisterMessage((*ClassifySessionDump)(nil), "classify_session_dump_0cca2cd9") + api.RegisterMessage((*ClassifySetInterfaceIPTable)(nil), "classify_set_interface_ip_table_e0b097c7") + api.RegisterMessage((*ClassifySetInterfaceIPTableReply)(nil), "classify_set_interface_ip_table_reply_e8d4e804") + api.RegisterMessage((*ClassifySetInterfaceL2Tables)(nil), "classify_set_interface_l2_tables_5a6ddf65") + api.RegisterMessage((*ClassifySetInterfaceL2TablesReply)(nil), "classify_set_interface_l2_tables_reply_e8d4e804") + api.RegisterMessage((*ClassifyTableByInterface)(nil), "classify_table_by_interface_f9e6675e") + api.RegisterMessage((*ClassifyTableByInterfaceReply)(nil), "classify_table_by_interface_reply_ed4197db") + api.RegisterMessage((*ClassifyTableIds)(nil), "classify_table_ids_51077d14") + api.RegisterMessage((*ClassifyTableIdsReply)(nil), "classify_table_ids_reply_d1d20e1d") + api.RegisterMessage((*ClassifyTableInfo)(nil), "classify_table_info_0cca2cd9") + api.RegisterMessage((*ClassifyTableInfoReply)(nil), "classify_table_info_reply_4a573c0e") + api.RegisterMessage((*ClassifyTraceGetTables)(nil), "classify_trace_get_tables_51077d14") + api.RegisterMessage((*ClassifyTraceGetTablesReply)(nil), "classify_trace_get_tables_reply_5f5bc9e6") + api.RegisterMessage((*ClassifyTraceLookupTable)(nil), "classify_trace_lookup_table_3f7b72e4") + api.RegisterMessage((*ClassifyTraceLookupTableReply)(nil), "classify_trace_lookup_table_reply_9c6c6773") + api.RegisterMessage((*ClassifyTraceSetTable)(nil), "classify_trace_set_table_3909b55a") + api.RegisterMessage((*ClassifyTraceSetTableReply)(nil), "classify_trace_set_table_reply_9c6c6773") + api.RegisterMessage((*FlowClassifyDetails)(nil), "flow_classify_details_dfd08765") + api.RegisterMessage((*FlowClassifyDump)(nil), "flow_classify_dump_25dd3e4c") + api.RegisterMessage((*FlowClassifySetInterface)(nil), "flow_classify_set_interface_b6192f1c") + api.RegisterMessage((*FlowClassifySetInterfaceReply)(nil), "flow_classify_set_interface_reply_e8d4e804") + api.RegisterMessage((*InputACLSetInterface)(nil), "input_acl_set_interface_de7ad708") + api.RegisterMessage((*InputACLSetInterfaceReply)(nil), "input_acl_set_interface_reply_e8d4e804") + api.RegisterMessage((*OutputACLSetInterface)(nil), "output_acl_set_interface_de7ad708") + api.RegisterMessage((*OutputACLSetInterfaceReply)(nil), "output_acl_set_interface_reply_e8d4e804") + api.RegisterMessage((*PolicerClassifyDetails)(nil), "policer_classify_details_dfd08765") + api.RegisterMessage((*PolicerClassifyDump)(nil), "policer_classify_dump_56cbb5fb") + api.RegisterMessage((*PolicerClassifySetInterface)(nil), "policer_classify_set_interface_de7ad708") + api.RegisterMessage((*PolicerClassifySetInterfaceReply)(nil), "policer_classify_set_interface_reply_e8d4e804") + api.RegisterMessage((*PuntACLAddDel)(nil), "punt_acl_add_del_a93bf3a0") + api.RegisterMessage((*PuntACLAddDelReply)(nil), "punt_acl_add_del_reply_e8d4e804") + api.RegisterMessage((*PuntACLGet)(nil), "punt_acl_get_51077d14") + api.RegisterMessage((*PuntACLGetReply)(nil), "punt_acl_get_reply_8409b9dd") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*ClassifyAddDelSession)(nil), + (*ClassifyAddDelSessionReply)(nil), + (*ClassifyAddDelTable)(nil), + (*ClassifyAddDelTableReply)(nil), + (*ClassifyPcapGetTables)(nil), + (*ClassifyPcapGetTablesReply)(nil), + (*ClassifyPcapLookupTable)(nil), + (*ClassifyPcapLookupTableReply)(nil), + (*ClassifyPcapSetTable)(nil), + (*ClassifyPcapSetTableReply)(nil), + (*ClassifySessionDetails)(nil), + (*ClassifySessionDump)(nil), + (*ClassifySetInterfaceIPTable)(nil), + (*ClassifySetInterfaceIPTableReply)(nil), + (*ClassifySetInterfaceL2Tables)(nil), + (*ClassifySetInterfaceL2TablesReply)(nil), + (*ClassifyTableByInterface)(nil), + (*ClassifyTableByInterfaceReply)(nil), + (*ClassifyTableIds)(nil), + (*ClassifyTableIdsReply)(nil), + (*ClassifyTableInfo)(nil), + (*ClassifyTableInfoReply)(nil), + (*ClassifyTraceGetTables)(nil), + (*ClassifyTraceGetTablesReply)(nil), + (*ClassifyTraceLookupTable)(nil), + (*ClassifyTraceLookupTableReply)(nil), + (*ClassifyTraceSetTable)(nil), + (*ClassifyTraceSetTableReply)(nil), + (*FlowClassifyDetails)(nil), + (*FlowClassifyDump)(nil), + (*FlowClassifySetInterface)(nil), + (*FlowClassifySetInterfaceReply)(nil), + (*InputACLSetInterface)(nil), + (*InputACLSetInterfaceReply)(nil), + (*OutputACLSetInterface)(nil), + (*OutputACLSetInterfaceReply)(nil), + (*PolicerClassifyDetails)(nil), + (*PolicerClassifyDump)(nil), + (*PolicerClassifySetInterface)(nil), + (*PolicerClassifySetInterfaceReply)(nil), + (*PuntACLAddDel)(nil), + (*PuntACLAddDelReply)(nil), + (*PuntACLGet)(nil), + (*PuntACLGetReply)(nil), + } +} diff --git a/binapi/classify/classify_rpc.ba.go b/binapi/classify/classify_rpc.ba.go new file mode 100644 index 00000000..d3520cb4 --- /dev/null +++ b/binapi/classify/classify_rpc.ba.go @@ -0,0 +1,346 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package classify + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service classify. +type RPCService interface { + ClassifyAddDelSession(ctx context.Context, in *ClassifyAddDelSession) (*ClassifyAddDelSessionReply, error) + ClassifyAddDelTable(ctx context.Context, in *ClassifyAddDelTable) (*ClassifyAddDelTableReply, error) + ClassifyPcapGetTables(ctx context.Context, in *ClassifyPcapGetTables) (*ClassifyPcapGetTablesReply, error) + ClassifyPcapLookupTable(ctx context.Context, in *ClassifyPcapLookupTable) (*ClassifyPcapLookupTableReply, error) + ClassifyPcapSetTable(ctx context.Context, in *ClassifyPcapSetTable) (*ClassifyPcapSetTableReply, error) + ClassifySessionDump(ctx context.Context, in *ClassifySessionDump) (RPCService_ClassifySessionDumpClient, error) + ClassifySetInterfaceIPTable(ctx context.Context, in *ClassifySetInterfaceIPTable) (*ClassifySetInterfaceIPTableReply, error) + ClassifySetInterfaceL2Tables(ctx context.Context, in *ClassifySetInterfaceL2Tables) (*ClassifySetInterfaceL2TablesReply, error) + ClassifyTableByInterface(ctx context.Context, in *ClassifyTableByInterface) (*ClassifyTableByInterfaceReply, error) + ClassifyTableIds(ctx context.Context, in *ClassifyTableIds) (*ClassifyTableIdsReply, error) + ClassifyTableInfo(ctx context.Context, in *ClassifyTableInfo) (*ClassifyTableInfoReply, error) + ClassifyTraceGetTables(ctx context.Context, in *ClassifyTraceGetTables) (*ClassifyTraceGetTablesReply, error) + ClassifyTraceLookupTable(ctx context.Context, in *ClassifyTraceLookupTable) (*ClassifyTraceLookupTableReply, error) + ClassifyTraceSetTable(ctx context.Context, in *ClassifyTraceSetTable) (*ClassifyTraceSetTableReply, error) + FlowClassifyDump(ctx context.Context, in *FlowClassifyDump) (RPCService_FlowClassifyDumpClient, error) + FlowClassifySetInterface(ctx context.Context, in *FlowClassifySetInterface) (*FlowClassifySetInterfaceReply, error) + InputACLSetInterface(ctx context.Context, in *InputACLSetInterface) (*InputACLSetInterfaceReply, error) + OutputACLSetInterface(ctx context.Context, in *OutputACLSetInterface) (*OutputACLSetInterfaceReply, error) + PolicerClassifyDump(ctx context.Context, in *PolicerClassifyDump) (RPCService_PolicerClassifyDumpClient, error) + PolicerClassifySetInterface(ctx context.Context, in *PolicerClassifySetInterface) (*PolicerClassifySetInterfaceReply, error) + PuntACLAddDel(ctx context.Context, in *PuntACLAddDel) (*PuntACLAddDelReply, error) + PuntACLGet(ctx context.Context, in *PuntACLGet) (*PuntACLGetReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) ClassifyAddDelSession(ctx context.Context, in *ClassifyAddDelSession) (*ClassifyAddDelSessionReply, error) { + out := new(ClassifyAddDelSessionReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyAddDelTable(ctx context.Context, in *ClassifyAddDelTable) (*ClassifyAddDelTableReply, error) { + out := new(ClassifyAddDelTableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyPcapGetTables(ctx context.Context, in *ClassifyPcapGetTables) (*ClassifyPcapGetTablesReply, error) { + out := new(ClassifyPcapGetTablesReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyPcapLookupTable(ctx context.Context, in *ClassifyPcapLookupTable) (*ClassifyPcapLookupTableReply, error) { + out := new(ClassifyPcapLookupTableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyPcapSetTable(ctx context.Context, in *ClassifyPcapSetTable) (*ClassifyPcapSetTableReply, error) { + out := new(ClassifyPcapSetTableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifySessionDump(ctx context.Context, in *ClassifySessionDump) (RPCService_ClassifySessionDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_ClassifySessionDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_ClassifySessionDumpClient interface { + Recv() (*ClassifySessionDetails, error) + api.Stream +} + +type serviceClient_ClassifySessionDumpClient struct { + api.Stream +} + +func (c *serviceClient_ClassifySessionDumpClient) Recv() (*ClassifySessionDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *ClassifySessionDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) ClassifySetInterfaceIPTable(ctx context.Context, in *ClassifySetInterfaceIPTable) (*ClassifySetInterfaceIPTableReply, error) { + out := new(ClassifySetInterfaceIPTableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifySetInterfaceL2Tables(ctx context.Context, in *ClassifySetInterfaceL2Tables) (*ClassifySetInterfaceL2TablesReply, error) { + out := new(ClassifySetInterfaceL2TablesReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyTableByInterface(ctx context.Context, in *ClassifyTableByInterface) (*ClassifyTableByInterfaceReply, error) { + out := new(ClassifyTableByInterfaceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyTableIds(ctx context.Context, in *ClassifyTableIds) (*ClassifyTableIdsReply, error) { + out := new(ClassifyTableIdsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyTableInfo(ctx context.Context, in *ClassifyTableInfo) (*ClassifyTableInfoReply, error) { + out := new(ClassifyTableInfoReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyTraceGetTables(ctx context.Context, in *ClassifyTraceGetTables) (*ClassifyTraceGetTablesReply, error) { + out := new(ClassifyTraceGetTablesReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyTraceLookupTable(ctx context.Context, in *ClassifyTraceLookupTable) (*ClassifyTraceLookupTableReply, error) { + out := new(ClassifyTraceLookupTableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyTraceSetTable(ctx context.Context, in *ClassifyTraceSetTable) (*ClassifyTraceSetTableReply, error) { + out := new(ClassifyTraceSetTableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) FlowClassifyDump(ctx context.Context, in *FlowClassifyDump) (RPCService_FlowClassifyDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_FlowClassifyDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_FlowClassifyDumpClient interface { + Recv() (*FlowClassifyDetails, error) + api.Stream +} + +type serviceClient_FlowClassifyDumpClient struct { + api.Stream +} + +func (c *serviceClient_FlowClassifyDumpClient) Recv() (*FlowClassifyDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *FlowClassifyDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) FlowClassifySetInterface(ctx context.Context, in *FlowClassifySetInterface) (*FlowClassifySetInterfaceReply, error) { + out := new(FlowClassifySetInterfaceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) InputACLSetInterface(ctx context.Context, in *InputACLSetInterface) (*InputACLSetInterfaceReply, error) { + out := new(InputACLSetInterfaceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OutputACLSetInterface(ctx context.Context, in *OutputACLSetInterface) (*OutputACLSetInterfaceReply, error) { + out := new(OutputACLSetInterfaceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PolicerClassifyDump(ctx context.Context, in *PolicerClassifyDump) (RPCService_PolicerClassifyDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_PolicerClassifyDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_PolicerClassifyDumpClient interface { + Recv() (*PolicerClassifyDetails, error) + api.Stream +} + +type serviceClient_PolicerClassifyDumpClient struct { + api.Stream +} + +func (c *serviceClient_PolicerClassifyDumpClient) Recv() (*PolicerClassifyDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *PolicerClassifyDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) PolicerClassifySetInterface(ctx context.Context, in *PolicerClassifySetInterface) (*PolicerClassifySetInterfaceReply, error) { + out := new(PolicerClassifySetInterfaceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PuntACLAddDel(ctx context.Context, in *PuntACLAddDel) (*PuntACLAddDelReply, error) { + out := new(PuntACLAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PuntACLGet(ctx context.Context, in *PuntACLGet) (*PuntACLGetReply, error) { + out := new(PuntACLGetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/cnat/cnat.ba.go b/binapi/cnat/cnat.ba.go new file mode 100644 index 00000000..1804ef40 --- /dev/null +++ b/binapi/cnat/cnat.ba.go @@ -0,0 +1,1197 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/cnat.api.json + +// Package cnat contains generated bindings for API file cnat.api. +// +// Contents: +// - 5 enums +// - 4 structs +// - 20 messages +package cnat + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + _ "github.com/alkiranet/govpp/binapi/fib_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "cnat" + APIVersion = "0.2.0" + VersionCrc = 0xfd05573b +) + +// CnatEndpointTupleFlags defines enum 'cnat_endpoint_tuple_flags'. +type CnatEndpointTupleFlags uint8 + +const ( + CNAT_EPT_NO_NAT CnatEndpointTupleFlags = 1 +) + +var ( + CnatEndpointTupleFlags_name = map[uint8]string{ + 1: "CNAT_EPT_NO_NAT", + } + CnatEndpointTupleFlags_value = map[string]uint8{ + "CNAT_EPT_NO_NAT": 1, + } +) + +func (x CnatEndpointTupleFlags) String() string { + s, ok := CnatEndpointTupleFlags_name[uint8(x)] + if ok { + return s + } + str := func(n uint8) string { + s, ok := CnatEndpointTupleFlags_name[uint8(n)] + if ok { + return s + } + return "CnatEndpointTupleFlags(" + strconv.Itoa(int(n)) + ")" + } + for i := uint8(0); i <= 8; i++ { + val := uint8(x) + if val&(1< register for events, 0 => cancel registration +// - pid - sender's pid +// +// WantDHCP6PdReplyEvents defines message 'want_dhcp6_pd_reply_events'. +type WantDHCP6PdReplyEvents struct { + EnableDisable bool `binapi:"bool,name=enable_disable" json:"enable_disable,omitempty"` + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` +} + +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 +} + +func (m *WantDHCP6PdReplyEvents) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.EnableDisable + size += 4 // m.PID + return size +} +func (m *WantDHCP6PdReplyEvents) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.EnableDisable) + buf.EncodeUint32(m.PID) + return buf.Bytes(), nil +} +func (m *WantDHCP6PdReplyEvents) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EnableDisable = buf.DecodeBool() + m.PID = buf.DecodeUint32() + return nil +} + +// WantDHCP6PdReplyEventsReply defines message 'want_dhcp6_pd_reply_events_reply'. +type WantDHCP6PdReplyEventsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *WantDHCP6PdReplyEventsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *WantDHCP6PdReplyEventsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *WantDHCP6PdReplyEventsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Register for DHCPv6 reply events +// - enable_disable - 1 => register for events, 0 => cancel registration +// - pid - sender's pid +// +// WantDHCP6ReplyEvents defines message 'want_dhcp6_reply_events'. +type WantDHCP6ReplyEvents struct { + EnableDisable uint8 `binapi:"u8,name=enable_disable" json:"enable_disable,omitempty"` + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` +} + +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 +} + +func (m *WantDHCP6ReplyEvents) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.EnableDisable + size += 4 // m.PID + return size +} +func (m *WantDHCP6ReplyEvents) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.EnableDisable) + buf.EncodeUint32(m.PID) + return buf.Bytes(), nil +} +func (m *WantDHCP6ReplyEvents) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EnableDisable = buf.DecodeUint8() + m.PID = buf.DecodeUint32() + return nil +} + +// WantDHCP6ReplyEventsReply defines message 'want_dhcp6_reply_events_reply'. +type WantDHCP6ReplyEventsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 (m *WantDHCP6ReplyEventsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *WantDHCP6ReplyEventsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *WantDHCP6ReplyEventsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_dhcp_binapi_init() } +func file_dhcp_binapi_init() { + api.RegisterMessage((*DHCP6ClientsEnableDisable)(nil), "dhcp6_clients_enable_disable_b3e225d2") + api.RegisterMessage((*DHCP6ClientsEnableDisableReply)(nil), "dhcp6_clients_enable_disable_reply_e8d4e804") + api.RegisterMessage((*DHCP6DuidLlSet)(nil), "dhcp6_duid_ll_set_0f6ca323") + api.RegisterMessage((*DHCP6DuidLlSetReply)(nil), "dhcp6_duid_ll_set_reply_e8d4e804") + api.RegisterMessage((*DHCP6PdReplyEvent)(nil), "dhcp6_pd_reply_event_5e878029") + api.RegisterMessage((*DHCP6PdSendClientMessage)(nil), "dhcp6_pd_send_client_message_3739fd8d") + api.RegisterMessage((*DHCP6PdSendClientMessageReply)(nil), "dhcp6_pd_send_client_message_reply_e8d4e804") + api.RegisterMessage((*DHCP6ReplyEvent)(nil), "dhcp6_reply_event_85b7b17e") + api.RegisterMessage((*DHCP6SendClientMessage)(nil), "dhcp6_send_client_message_f8222476") + api.RegisterMessage((*DHCP6SendClientMessageReply)(nil), "dhcp6_send_client_message_reply_e8d4e804") + api.RegisterMessage((*DHCPClientConfig)(nil), "dhcp_client_config_1af013ea") + api.RegisterMessage((*DHCPClientConfigReply)(nil), "dhcp_client_config_reply_e8d4e804") + api.RegisterMessage((*DHCPClientDetails)(nil), "dhcp_client_details_8897b2d8") + api.RegisterMessage((*DHCPClientDump)(nil), "dhcp_client_dump_51077d14") + api.RegisterMessage((*DHCPComplEvent)(nil), "dhcp_compl_event_e18124b7") + api.RegisterMessage((*DHCPPluginControlPing)(nil), "dhcp_plugin_control_ping_51077d14") + api.RegisterMessage((*DHCPPluginControlPingReply)(nil), "dhcp_plugin_control_ping_reply_f6b0b8ca") + api.RegisterMessage((*DHCPPluginGetVersion)(nil), "dhcp_plugin_get_version_51077d14") + api.RegisterMessage((*DHCPPluginGetVersionReply)(nil), "dhcp_plugin_get_version_reply_9b32cf86") + api.RegisterMessage((*DHCPProxyConfig)(nil), "dhcp_proxy_config_4058a689") + api.RegisterMessage((*DHCPProxyConfigReply)(nil), "dhcp_proxy_config_reply_e8d4e804") + api.RegisterMessage((*DHCPProxyDetails)(nil), "dhcp_proxy_details_dcbaf540") + api.RegisterMessage((*DHCPProxyDump)(nil), "dhcp_proxy_dump_5c5b063f") + api.RegisterMessage((*DHCPProxySetVss)(nil), "dhcp_proxy_set_vss_50537301") + api.RegisterMessage((*DHCPProxySetVssReply)(nil), "dhcp_proxy_set_vss_reply_e8d4e804") + api.RegisterMessage((*WantDHCP6PdReplyEvents)(nil), "want_dhcp6_pd_reply_events_c5e2af94") + api.RegisterMessage((*WantDHCP6PdReplyEventsReply)(nil), "want_dhcp6_pd_reply_events_reply_e8d4e804") + api.RegisterMessage((*WantDHCP6ReplyEvents)(nil), "want_dhcp6_reply_events_05b454b5") + api.RegisterMessage((*WantDHCP6ReplyEventsReply)(nil), "want_dhcp6_reply_events_reply_e8d4e804") +} + +// 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), + } +} diff --git a/binapi/dhcp/dhcp_rpc.ba.go b/binapi/dhcp/dhcp_rpc.ba.go new file mode 100644 index 00000000..8813afa6 --- /dev/null +++ b/binapi/dhcp/dhcp_rpc.ba.go @@ -0,0 +1,222 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package dhcp + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service dhcp. +type RPCService interface { + 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) + DHCPClientDump(ctx context.Context, in *DHCPClientDump) (RPCService_DHCPClientDumpClient, 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) + DHCPProxyDump(ctx context.Context, in *DHCPProxyDump) (RPCService_DHCPProxyDumpClient, 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 { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) DHCP6ClientsEnableDisable(ctx context.Context, in *DHCP6ClientsEnableDisable) (*DHCP6ClientsEnableDisableReply, error) { + out := new(DHCP6ClientsEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DHCP6DuidLlSet(ctx context.Context, in *DHCP6DuidLlSet) (*DHCP6DuidLlSetReply, error) { + out := new(DHCP6DuidLlSetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DHCP6PdSendClientMessage(ctx context.Context, in *DHCP6PdSendClientMessage) (*DHCP6PdSendClientMessageReply, error) { + out := new(DHCP6PdSendClientMessageReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DHCP6SendClientMessage(ctx context.Context, in *DHCP6SendClientMessage) (*DHCP6SendClientMessageReply, error) { + out := new(DHCP6SendClientMessageReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DHCPClientConfig(ctx context.Context, in *DHCPClientConfig) (*DHCPClientConfigReply, error) { + out := new(DHCPClientConfigReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DHCPClientDump(ctx context.Context, in *DHCPClientDump) (RPCService_DHCPClientDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_DHCPClientDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_DHCPClientDumpClient interface { + Recv() (*DHCPClientDetails, error) + api.Stream +} + +type serviceClient_DHCPClientDumpClient struct { + api.Stream +} + +func (c *serviceClient_DHCPClientDumpClient) Recv() (*DHCPClientDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *DHCPClientDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) DHCPPluginControlPing(ctx context.Context, in *DHCPPluginControlPing) (*DHCPPluginControlPingReply, error) { + out := new(DHCPPluginControlPingReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DHCPPluginGetVersion(ctx context.Context, in *DHCPPluginGetVersion) (*DHCPPluginGetVersionReply, error) { + out := new(DHCPPluginGetVersionReply) + err := c.conn.Invoke(ctx, in, 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.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DHCPProxyDump(ctx context.Context, in *DHCPProxyDump) (RPCService_DHCPProxyDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_DHCPProxyDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_DHCPProxyDumpClient interface { + Recv() (*DHCPProxyDetails, error) + api.Stream +} + +type serviceClient_DHCPProxyDumpClient struct { + api.Stream +} + +func (c *serviceClient_DHCPProxyDumpClient) Recv() (*DHCPProxyDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *DHCPProxyDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) DHCPProxySetVss(ctx context.Context, in *DHCPProxySetVss) (*DHCPProxySetVssReply, error) { + out := new(DHCPProxySetVssReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WantDHCP6PdReplyEvents(ctx context.Context, in *WantDHCP6PdReplyEvents) (*WantDHCP6PdReplyEventsReply, error) { + out := new(WantDHCP6PdReplyEventsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WantDHCP6ReplyEvents(ctx context.Context, in *WantDHCP6ReplyEvents) (*WantDHCP6ReplyEventsReply, error) { + out := new(WantDHCP6ReplyEventsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/dhcp6_ia_na_client_cp/dhcp6_ia_na_client_cp.ba.go b/binapi/dhcp6_ia_na_client_cp/dhcp6_ia_na_client_cp.ba.go new file mode 100644 index 00000000..17f6d87d --- /dev/null +++ b/binapi/dhcp6_ia_na_client_cp/dhcp6_ia_na_client_cp.ba.go @@ -0,0 +1,119 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/dhcp6_ia_na_client_cp.api.json + +// Package dhcp6_ia_na_client_cp contains generated bindings for API file dhcp6_ia_na_client_cp.api. +// +// Contents: +// - 2 messages +package dhcp6_ia_na_client_cp + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "dhcp6_ia_na_client_cp" + APIVersion = "1.0.1" + VersionCrc = 0x6e8abdfb +) + +// Enable/disable DHCPv6 client on interface +// - sw_if_index - interface to enable/disable client on +// - enable - 1 to enable, 0 to disable +// +// DHCP6ClientEnableDisable defines message 'dhcp6_client_enable_disable'. +type DHCP6ClientEnableDisable struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Enable bool `binapi:"bool,name=enable" json:"enable,omitempty"` +} + +func (m *DHCP6ClientEnableDisable) Reset() { *m = DHCP6ClientEnableDisable{} } +func (*DHCP6ClientEnableDisable) GetMessageName() string { return "dhcp6_client_enable_disable" } +func (*DHCP6ClientEnableDisable) GetCrcString() string { return "ae6cfcfb" } +func (*DHCP6ClientEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *DHCP6ClientEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.Enable + return size +} +func (m *DHCP6ClientEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.Enable) + return buf.Bytes(), nil +} +func (m *DHCP6ClientEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Enable = buf.DecodeBool() + return nil +} + +// DHCP6ClientEnableDisableReply defines message 'dhcp6_client_enable_disable_reply'. +type DHCP6ClientEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *DHCP6ClientEnableDisableReply) Reset() { *m = DHCP6ClientEnableDisableReply{} } +func (*DHCP6ClientEnableDisableReply) GetMessageName() string { + return "dhcp6_client_enable_disable_reply" +} +func (*DHCP6ClientEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*DHCP6ClientEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *DHCP6ClientEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *DHCP6ClientEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *DHCP6ClientEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_dhcp6_ia_na_client_cp_binapi_init() } +func file_dhcp6_ia_na_client_cp_binapi_init() { + api.RegisterMessage((*DHCP6ClientEnableDisable)(nil), "dhcp6_client_enable_disable_ae6cfcfb") + api.RegisterMessage((*DHCP6ClientEnableDisableReply)(nil), "dhcp6_client_enable_disable_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*DHCP6ClientEnableDisable)(nil), + (*DHCP6ClientEnableDisableReply)(nil), + } +} diff --git a/binapi/dhcp6_ia_na_client_cp/dhcp6_ia_na_client_cp_rpc.ba.go b/binapi/dhcp6_ia_na_client_cp/dhcp6_ia_na_client_cp_rpc.ba.go new file mode 100644 index 00000000..c7447d34 --- /dev/null +++ b/binapi/dhcp6_ia_na_client_cp/dhcp6_ia_na_client_cp_rpc.ba.go @@ -0,0 +1,31 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package dhcp6_ia_na_client_cp + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service dhcp6_ia_na_client_cp. +type RPCService interface { + DHCP6ClientEnableDisable(ctx context.Context, in *DHCP6ClientEnableDisable) (*DHCP6ClientEnableDisableReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) DHCP6ClientEnableDisable(ctx context.Context, in *DHCP6ClientEnableDisable) (*DHCP6ClientEnableDisableReply, error) { + out := new(DHCP6ClientEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/dhcp6_pd_client_cp/dhcp6_pd_client_cp.ba.go b/binapi/dhcp6_pd_client_cp/dhcp6_pd_client_cp.ba.go new file mode 100644 index 00000000..3e1cecbc --- /dev/null +++ b/binapi/dhcp6_pd_client_cp/dhcp6_pd_client_cp.ba.go @@ -0,0 +1,224 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/dhcp6_pd_client_cp.api.json + +// Package dhcp6_pd_client_cp contains generated bindings for API file dhcp6_pd_client_cp.api. +// +// Contents: +// - 4 messages +package dhcp6_pd_client_cp + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "dhcp6_pd_client_cp" + APIVersion = "2.0.0" + VersionCrc = 0xd4418668 +) + +// Enable/disable DHCPv6 PD client on interface +// - sw_if_index - interface to enable/disable client on +// - prefix_group - name of prefix group (relevant when 'enable' is 1) +// - enable - 1 to enable, 0 to disable +// +// DHCP6PdClientEnableDisable defines message 'dhcp6_pd_client_enable_disable'. +type DHCP6PdClientEnableDisable struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + PrefixGroup string `binapi:"string[64],name=prefix_group" json:"prefix_group,omitempty"` + Enable bool `binapi:"bool,name=enable" json:"enable,omitempty"` +} + +func (m *DHCP6PdClientEnableDisable) Reset() { *m = DHCP6PdClientEnableDisable{} } +func (*DHCP6PdClientEnableDisable) GetMessageName() string { return "dhcp6_pd_client_enable_disable" } +func (*DHCP6PdClientEnableDisable) GetCrcString() string { return "a75a0772" } +func (*DHCP6PdClientEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *DHCP6PdClientEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 64 // m.PrefixGroup + size += 1 // m.Enable + return size +} +func (m *DHCP6PdClientEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeString(m.PrefixGroup, 64) + buf.EncodeBool(m.Enable) + return buf.Bytes(), nil +} +func (m *DHCP6PdClientEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.PrefixGroup = buf.DecodeString(64) + m.Enable = buf.DecodeBool() + return nil +} + +// DHCP6PdClientEnableDisableReply defines message 'dhcp6_pd_client_enable_disable_reply'. +type DHCP6PdClientEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *DHCP6PdClientEnableDisableReply) Reset() { *m = DHCP6PdClientEnableDisableReply{} } +func (*DHCP6PdClientEnableDisableReply) GetMessageName() string { + return "dhcp6_pd_client_enable_disable_reply" +} +func (*DHCP6PdClientEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*DHCP6PdClientEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *DHCP6PdClientEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *DHCP6PdClientEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *DHCP6PdClientEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add/delete IPv6 address optionally using available prefix +// - sw_if_index - software interface index of interface +// to add/delete address to/from +// - prefix_group - name of prefix group, +// prefix_group[0] == '\0' means no prefix should be used +// - address - address or suffix to be used with a prefix +// from selected group +// - prefix_length - subnet prefix for the address +// - is_add - 1 for add, 0 for remove +// +// IP6AddDelAddressUsingPrefix defines message 'ip6_add_del_address_using_prefix'. +type IP6AddDelAddressUsingPrefix struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + PrefixGroup string `binapi:"string[64],name=prefix_group" json:"prefix_group,omitempty"` + AddressWithPrefix ip_types.IP6AddressWithPrefix `binapi:"ip6_address_with_prefix,name=address_with_prefix" json:"address_with_prefix,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` +} + +func (m *IP6AddDelAddressUsingPrefix) Reset() { *m = IP6AddDelAddressUsingPrefix{} } +func (*IP6AddDelAddressUsingPrefix) GetMessageName() string { + return "ip6_add_del_address_using_prefix" +} +func (*IP6AddDelAddressUsingPrefix) GetCrcString() string { return "3982f30a" } +func (*IP6AddDelAddressUsingPrefix) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IP6AddDelAddressUsingPrefix) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 64 // m.PrefixGroup + size += 1 * 16 // m.AddressWithPrefix.Address + size += 1 // m.AddressWithPrefix.Len + size += 1 // m.IsAdd + return size +} +func (m *IP6AddDelAddressUsingPrefix) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeString(m.PrefixGroup, 64) + buf.EncodeBytes(m.AddressWithPrefix.Address[:], 16) + buf.EncodeUint8(m.AddressWithPrefix.Len) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *IP6AddDelAddressUsingPrefix) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.PrefixGroup = buf.DecodeString(64) + copy(m.AddressWithPrefix.Address[:], buf.DecodeBytes(16)) + m.AddressWithPrefix.Len = buf.DecodeUint8() + m.IsAdd = buf.DecodeBool() + return nil +} + +// IP6AddDelAddressUsingPrefixReply defines message 'ip6_add_del_address_using_prefix_reply'. +type IP6AddDelAddressUsingPrefixReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IP6AddDelAddressUsingPrefixReply) Reset() { *m = IP6AddDelAddressUsingPrefixReply{} } +func (*IP6AddDelAddressUsingPrefixReply) GetMessageName() string { + return "ip6_add_del_address_using_prefix_reply" +} +func (*IP6AddDelAddressUsingPrefixReply) GetCrcString() string { return "e8d4e804" } +func (*IP6AddDelAddressUsingPrefixReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IP6AddDelAddressUsingPrefixReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IP6AddDelAddressUsingPrefixReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IP6AddDelAddressUsingPrefixReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_dhcp6_pd_client_cp_binapi_init() } +func file_dhcp6_pd_client_cp_binapi_init() { + api.RegisterMessage((*DHCP6PdClientEnableDisable)(nil), "dhcp6_pd_client_enable_disable_a75a0772") + api.RegisterMessage((*DHCP6PdClientEnableDisableReply)(nil), "dhcp6_pd_client_enable_disable_reply_e8d4e804") + api.RegisterMessage((*IP6AddDelAddressUsingPrefix)(nil), "ip6_add_del_address_using_prefix_3982f30a") + api.RegisterMessage((*IP6AddDelAddressUsingPrefixReply)(nil), "ip6_add_del_address_using_prefix_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*DHCP6PdClientEnableDisable)(nil), + (*DHCP6PdClientEnableDisableReply)(nil), + (*IP6AddDelAddressUsingPrefix)(nil), + (*IP6AddDelAddressUsingPrefixReply)(nil), + } +} diff --git a/binapi/dhcp6_pd_client_cp/dhcp6_pd_client_cp_rpc.ba.go b/binapi/dhcp6_pd_client_cp/dhcp6_pd_client_cp_rpc.ba.go new file mode 100644 index 00000000..3752e03b --- /dev/null +++ b/binapi/dhcp6_pd_client_cp/dhcp6_pd_client_cp_rpc.ba.go @@ -0,0 +1,41 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package dhcp6_pd_client_cp + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service dhcp6_pd_client_cp. +type RPCService interface { + DHCP6PdClientEnableDisable(ctx context.Context, in *DHCP6PdClientEnableDisable) (*DHCP6PdClientEnableDisableReply, error) + IP6AddDelAddressUsingPrefix(ctx context.Context, in *IP6AddDelAddressUsingPrefix) (*IP6AddDelAddressUsingPrefixReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) DHCP6PdClientEnableDisable(ctx context.Context, in *DHCP6PdClientEnableDisable) (*DHCP6PdClientEnableDisableReply, error) { + out := new(DHCP6PdClientEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IP6AddDelAddressUsingPrefix(ctx context.Context, in *IP6AddDelAddressUsingPrefix) (*IP6AddDelAddressUsingPrefixReply, error) { + out := new(IP6AddDelAddressUsingPrefixReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/dns/dns.ba.go b/binapi/dns/dns.ba.go new file mode 100644 index 00000000..8782405c --- /dev/null +++ b/binapi/dns/dns.ba.go @@ -0,0 +1,382 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/dns.api.json + +// Package dns contains generated bindings for API file dns.api. +// +// Contents: +// - 8 messages +package dns + +import ( + api "github.com/alkiranet/govpp/api" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "dns" + APIVersion = "1.0.0" + VersionCrc = 0x269575cd +) + +// enable/disable name resolution +// - is_enable - 1 = enable, 0 = disable +// +// DNSEnableDisable defines message 'dns_enable_disable'. +type DNSEnableDisable struct { + Enable uint8 `binapi:"u8,name=enable" json:"enable,omitempty"` +} + +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 +} + +func (m *DNSEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Enable + return size +} +func (m *DNSEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.Enable) + return buf.Bytes(), nil +} +func (m *DNSEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Enable = buf.DecodeUint8() + return nil +} + +// DNSEnableDisableReply defines message 'dns_enable_disable_reply'. +type DNSEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *DNSEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *DNSEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *DNSEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// add or delete an upstream name server +// - is_ip6 - an ip6 name server +// - is_add - add = 1, delete = 0 +// - server_address - server ip address +// +// DNSNameServerAddDel defines message 'dns_name_server_add_del'. +type DNSNameServerAddDel struct { + IsIP6 uint8 `binapi:"u8,name=is_ip6" json:"is_ip6,omitempty"` + IsAdd uint8 `binapi:"u8,name=is_add" json:"is_add,omitempty"` + ServerAddress []byte `binapi:"u8[16],name=server_address" json:"server_address,omitempty"` +} + +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 +} + +func (m *DNSNameServerAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsIP6 + size += 1 // m.IsAdd + size += 1 * 16 // m.ServerAddress + return size +} +func (m *DNSNameServerAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.IsIP6) + buf.EncodeUint8(m.IsAdd) + buf.EncodeBytes(m.ServerAddress, 16) + return buf.Bytes(), nil +} +func (m *DNSNameServerAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsIP6 = buf.DecodeUint8() + m.IsAdd = buf.DecodeUint8() + m.ServerAddress = make([]byte, 16) + copy(m.ServerAddress, buf.DecodeBytes(len(m.ServerAddress))) + return nil +} + +// DNSNameServerAddDelReply defines message 'dns_name_server_add_del_reply'. +type DNSNameServerAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *DNSNameServerAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *DNSNameServerAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *DNSNameServerAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// DNS IP -> name resolution request +// - is_ip6 - set if the reverse-DNS request is an ip6 address +// - address - the address to map to a name +// +// DNSResolveIP defines message 'dns_resolve_ip'. +type DNSResolveIP struct { + IsIP6 uint8 `binapi:"u8,name=is_ip6" json:"is_ip6,omitempty"` + Address []byte `binapi:"u8[16],name=address" json:"address,omitempty"` +} + +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 +} + +func (m *DNSResolveIP) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsIP6 + size += 1 * 16 // m.Address + return size +} +func (m *DNSResolveIP) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.IsIP6) + buf.EncodeBytes(m.Address, 16) + return buf.Bytes(), nil +} +func (m *DNSResolveIP) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsIP6 = buf.DecodeUint8() + m.Address = make([]byte, 16) + copy(m.Address, buf.DecodeBytes(len(m.Address))) + return nil +} + +// DNS ip->name resolution reply +// - retval - return value, 0 => success +// - name - canonical name for the indicated IP address +// +// DNSResolveIPReply defines message 'dns_resolve_ip_reply'. +type DNSResolveIPReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Name []byte `binapi:"u8[256],name=name" json:"name,omitempty"` +} + +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 +} + +func (m *DNSResolveIPReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 * 256 // m.Name + return size +} +func (m *DNSResolveIPReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBytes(m.Name, 256) + return buf.Bytes(), nil +} +func (m *DNSResolveIPReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Name = make([]byte, 256) + copy(m.Name, buf.DecodeBytes(len(m.Name))) + return nil +} + +// DNS name resolution request +// - name - the name to resolve +// +// DNSResolveName defines message 'dns_resolve_name'. +type DNSResolveName struct { + Name []byte `binapi:"u8[256],name=name" json:"name,omitempty"` +} + +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 +} + +func (m *DNSResolveName) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 256 // m.Name + return size +} +func (m *DNSResolveName) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.Name, 256) + return buf.Bytes(), nil +} +func (m *DNSResolveName) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Name = make([]byte, 256) + copy(m.Name, buf.DecodeBytes(len(m.Name))) + return nil +} + +// DNS name resolution reply +// - retval - return value, 0 => success +// - ip4_set - indicates that the ip4 address is valid +// - ip6_set - indicates that the ip6 address is valid +// - ip4_address - the ip4 name resolution reply +// - ip6_address - the ip6 name resolution reply +// +// DNSResolveNameReply defines message 'dns_resolve_name_reply'. +type DNSResolveNameReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IP4Set uint8 `binapi:"u8,name=ip4_set" json:"ip4_set,omitempty"` + IP6Set uint8 `binapi:"u8,name=ip6_set" json:"ip6_set,omitempty"` + IP4Address []byte `binapi:"u8[4],name=ip4_address" json:"ip4_address,omitempty"` + IP6Address []byte `binapi:"u8[16],name=ip6_address" json:"ip6_address,omitempty"` +} + +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 (m *DNSResolveNameReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.IP4Set + size += 1 // m.IP6Set + size += 1 * 4 // m.IP4Address + size += 1 * 16 // m.IP6Address + return size +} +func (m *DNSResolveNameReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint8(m.IP4Set) + buf.EncodeUint8(m.IP6Set) + buf.EncodeBytes(m.IP4Address, 4) + buf.EncodeBytes(m.IP6Address, 16) + return buf.Bytes(), nil +} +func (m *DNSResolveNameReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IP4Set = buf.DecodeUint8() + m.IP6Set = buf.DecodeUint8() + m.IP4Address = make([]byte, 4) + copy(m.IP4Address, buf.DecodeBytes(len(m.IP4Address))) + m.IP6Address = make([]byte, 16) + copy(m.IP6Address, buf.DecodeBytes(len(m.IP6Address))) + return nil +} + +func init() { file_dns_binapi_init() } +func file_dns_binapi_init() { + api.RegisterMessage((*DNSEnableDisable)(nil), "dns_enable_disable_8050327d") + api.RegisterMessage((*DNSEnableDisableReply)(nil), "dns_enable_disable_reply_e8d4e804") + api.RegisterMessage((*DNSNameServerAddDel)(nil), "dns_name_server_add_del_3bb05d8c") + api.RegisterMessage((*DNSNameServerAddDelReply)(nil), "dns_name_server_add_del_reply_e8d4e804") + api.RegisterMessage((*DNSResolveIP)(nil), "dns_resolve_ip_ae96a1a3") + api.RegisterMessage((*DNSResolveIPReply)(nil), "dns_resolve_ip_reply_49ed78d6") + api.RegisterMessage((*DNSResolveName)(nil), "dns_resolve_name_c6566676") + api.RegisterMessage((*DNSResolveNameReply)(nil), "dns_resolve_name_reply_c2d758c3") +} + +// 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), + } +} diff --git a/binapi/dns/dns_rpc.ba.go b/binapi/dns/dns_rpc.ba.go new file mode 100644 index 00000000..a7d5d3e0 --- /dev/null +++ b/binapi/dns/dns_rpc.ba.go @@ -0,0 +1,61 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package dns + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service dns. +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 { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) DNSEnableDisable(ctx context.Context, in *DNSEnableDisable) (*DNSEnableDisableReply, error) { + out := new(DNSEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DNSNameServerAddDel(ctx context.Context, in *DNSNameServerAddDel) (*DNSNameServerAddDelReply, error) { + out := new(DNSNameServerAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DNSResolveIP(ctx context.Context, in *DNSResolveIP) (*DNSResolveIPReply, error) { + out := new(DNSResolveIPReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DNSResolveName(ctx context.Context, in *DNSResolveName) (*DNSResolveNameReply, error) { + out := new(DNSResolveNameReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/dslite/dslite.ba.go b/binapi/dslite/dslite.ba.go new file mode 100644 index 00000000..56c3602c --- /dev/null +++ b/binapi/dslite/dslite.ba.go @@ -0,0 +1,505 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/dslite.api.json + +// Package dslite contains generated bindings for API file dslite.api. +// +// Contents: +// - 12 messages +package dslite + +import ( + api "github.com/alkiranet/govpp/api" + _ "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "dslite" + APIVersion = "1.0.0" + VersionCrc = 0x1afa049b +) + +// Add/delete address range to DS-Lite pool +// - start_addr - start IPv4 address of the range +// - end_addr - end IPv4 address of the range +// - is_add - true if add, false if delete +// +// DsliteAddDelPoolAddrRange defines message 'dslite_add_del_pool_addr_range'. +type DsliteAddDelPoolAddrRange struct { + StartAddr ip_types.IP4Address `binapi:"ip4_address,name=start_addr" json:"start_addr,omitempty"` + EndAddr ip_types.IP4Address `binapi:"ip4_address,name=end_addr" json:"end_addr,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` +} + +func (m *DsliteAddDelPoolAddrRange) Reset() { *m = DsliteAddDelPoolAddrRange{} } +func (*DsliteAddDelPoolAddrRange) GetMessageName() string { return "dslite_add_del_pool_addr_range" } +func (*DsliteAddDelPoolAddrRange) GetCrcString() string { return "de2a5b02" } +func (*DsliteAddDelPoolAddrRange) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *DsliteAddDelPoolAddrRange) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 4 // m.StartAddr + size += 1 * 4 // m.EndAddr + size += 1 // m.IsAdd + return size +} +func (m *DsliteAddDelPoolAddrRange) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.StartAddr[:], 4) + buf.EncodeBytes(m.EndAddr[:], 4) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *DsliteAddDelPoolAddrRange) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.StartAddr[:], buf.DecodeBytes(4)) + copy(m.EndAddr[:], buf.DecodeBytes(4)) + m.IsAdd = buf.DecodeBool() + return nil +} + +// DsliteAddDelPoolAddrRangeReply defines message 'dslite_add_del_pool_addr_range_reply'. +type DsliteAddDelPoolAddrRangeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *DsliteAddDelPoolAddrRangeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *DsliteAddDelPoolAddrRangeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *DsliteAddDelPoolAddrRangeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// DS-Lite address details response +// - ip_address - IPv4 address +// +// DsliteAddressDetails defines message 'dslite_address_details'. +type DsliteAddressDetails struct { + IPAddress ip_types.IP4Address `binapi:"ip4_address,name=ip_address" json:"ip_address,omitempty"` +} + +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 +} + +func (m *DsliteAddressDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 4 // m.IPAddress + return size +} +func (m *DsliteAddressDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.IPAddress[:], 4) + return buf.Bytes(), nil +} +func (m *DsliteAddressDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.IPAddress[:], buf.DecodeBytes(4)) + return nil +} + +// Dump DS-Lite addresses +// DsliteAddressDump defines 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 +} + +func (m *DsliteAddressDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *DsliteAddressDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *DsliteAddressDump) Unmarshal(b []byte) error { + return nil +} + +// Get AFTR IPv6 and IPv4 addresses +// DsliteGetAftrAddr defines 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 +} + +func (m *DsliteGetAftrAddr) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *DsliteGetAftrAddr) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *DsliteGetAftrAddr) Unmarshal(b []byte) error { + return nil +} + +// Response to get AFTR IPv6 and IPv4 addresses +// - retval - return code +// - ip4_addr - IPv4 address +// - ip6_addr - IPv6 address +// +// DsliteGetAftrAddrReply defines message 'dslite_get_aftr_addr_reply'. +type DsliteGetAftrAddrReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IP4Addr ip_types.IP4Address `binapi:"ip4_address,name=ip4_addr" json:"ip4_addr,omitempty"` + IP6Addr ip_types.IP6Address `binapi:"ip6_address,name=ip6_addr" json:"ip6_addr,omitempty"` +} + +func (m *DsliteGetAftrAddrReply) Reset() { *m = DsliteGetAftrAddrReply{} } +func (*DsliteGetAftrAddrReply) GetMessageName() string { return "dslite_get_aftr_addr_reply" } +func (*DsliteGetAftrAddrReply) GetCrcString() string { return "8e23608e" } +func (*DsliteGetAftrAddrReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *DsliteGetAftrAddrReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 * 4 // m.IP4Addr + size += 1 * 16 // m.IP6Addr + return size +} +func (m *DsliteGetAftrAddrReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBytes(m.IP4Addr[:], 4) + buf.EncodeBytes(m.IP6Addr[:], 16) + return buf.Bytes(), nil +} +func (m *DsliteGetAftrAddrReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + copy(m.IP4Addr[:], buf.DecodeBytes(4)) + copy(m.IP6Addr[:], buf.DecodeBytes(16)) + return nil +} + +// Get B4 IPv6 and IPv4 addresses +// DsliteGetB4Addr defines 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 +} + +func (m *DsliteGetB4Addr) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *DsliteGetB4Addr) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *DsliteGetB4Addr) Unmarshal(b []byte) error { + return nil +} + +// Response to get B4 IPv6 and IPv4 addresses +// - retval - return code +// - ip4_addr - IPv4 address +// - ip6_addr - IPv6 address +// +// DsliteGetB4AddrReply defines message 'dslite_get_b4_addr_reply'. +type DsliteGetB4AddrReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IP4Addr ip_types.IP4Address `binapi:"ip4_address,name=ip4_addr" json:"ip4_addr,omitempty"` + IP6Addr ip_types.IP6Address `binapi:"ip6_address,name=ip6_addr" json:"ip6_addr,omitempty"` +} + +func (m *DsliteGetB4AddrReply) Reset() { *m = DsliteGetB4AddrReply{} } +func (*DsliteGetB4AddrReply) GetMessageName() string { return "dslite_get_b4_addr_reply" } +func (*DsliteGetB4AddrReply) GetCrcString() string { return "8e23608e" } +func (*DsliteGetB4AddrReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *DsliteGetB4AddrReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 * 4 // m.IP4Addr + size += 1 * 16 // m.IP6Addr + return size +} +func (m *DsliteGetB4AddrReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBytes(m.IP4Addr[:], 4) + buf.EncodeBytes(m.IP6Addr[:], 16) + return buf.Bytes(), nil +} +func (m *DsliteGetB4AddrReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + copy(m.IP4Addr[:], buf.DecodeBytes(4)) + copy(m.IP6Addr[:], buf.DecodeBytes(16)) + return nil +} + +// Set AFTR IPv6 and IPv4 addresses +// - ip4_addr - IPv4 address +// - ip6_addr - IPv6 address +// +// DsliteSetAftrAddr defines message 'dslite_set_aftr_addr'. +type DsliteSetAftrAddr struct { + IP4Addr ip_types.IP4Address `binapi:"ip4_address,name=ip4_addr" json:"ip4_addr,omitempty"` + IP6Addr ip_types.IP6Address `binapi:"ip6_address,name=ip6_addr" json:"ip6_addr,omitempty"` +} + +func (m *DsliteSetAftrAddr) Reset() { *m = DsliteSetAftrAddr{} } +func (*DsliteSetAftrAddr) GetMessageName() string { return "dslite_set_aftr_addr" } +func (*DsliteSetAftrAddr) GetCrcString() string { return "78b50fdf" } +func (*DsliteSetAftrAddr) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *DsliteSetAftrAddr) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 4 // m.IP4Addr + size += 1 * 16 // m.IP6Addr + return size +} +func (m *DsliteSetAftrAddr) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.IP4Addr[:], 4) + buf.EncodeBytes(m.IP6Addr[:], 16) + return buf.Bytes(), nil +} +func (m *DsliteSetAftrAddr) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.IP4Addr[:], buf.DecodeBytes(4)) + copy(m.IP6Addr[:], buf.DecodeBytes(16)) + return nil +} + +// DsliteSetAftrAddrReply defines message 'dslite_set_aftr_addr_reply'. +type DsliteSetAftrAddrReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *DsliteSetAftrAddrReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *DsliteSetAftrAddrReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *DsliteSetAftrAddrReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set B4 IPv6 and IPv4 addresses +// - ip4_addr - IPv4 address +// - ip6_addr - IPv6 address +// +// DsliteSetB4Addr defines message 'dslite_set_b4_addr'. +type DsliteSetB4Addr struct { + IP4Addr ip_types.IP4Address `binapi:"ip4_address,name=ip4_addr" json:"ip4_addr,omitempty"` + IP6Addr ip_types.IP6Address `binapi:"ip6_address,name=ip6_addr" json:"ip6_addr,omitempty"` +} + +func (m *DsliteSetB4Addr) Reset() { *m = DsliteSetB4Addr{} } +func (*DsliteSetB4Addr) GetMessageName() string { return "dslite_set_b4_addr" } +func (*DsliteSetB4Addr) GetCrcString() string { return "78b50fdf" } +func (*DsliteSetB4Addr) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *DsliteSetB4Addr) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 4 // m.IP4Addr + size += 1 * 16 // m.IP6Addr + return size +} +func (m *DsliteSetB4Addr) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.IP4Addr[:], 4) + buf.EncodeBytes(m.IP6Addr[:], 16) + return buf.Bytes(), nil +} +func (m *DsliteSetB4Addr) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.IP4Addr[:], buf.DecodeBytes(4)) + copy(m.IP6Addr[:], buf.DecodeBytes(16)) + return nil +} + +// DsliteSetB4AddrReply defines message 'dslite_set_b4_addr_reply'. +type DsliteSetB4AddrReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *DsliteSetB4AddrReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *DsliteSetB4AddrReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *DsliteSetB4AddrReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_dslite_binapi_init() } +func file_dslite_binapi_init() { + api.RegisterMessage((*DsliteAddDelPoolAddrRange)(nil), "dslite_add_del_pool_addr_range_de2a5b02") + api.RegisterMessage((*DsliteAddDelPoolAddrRangeReply)(nil), "dslite_add_del_pool_addr_range_reply_e8d4e804") + api.RegisterMessage((*DsliteAddressDetails)(nil), "dslite_address_details_ec26d648") + api.RegisterMessage((*DsliteAddressDump)(nil), "dslite_address_dump_51077d14") + api.RegisterMessage((*DsliteGetAftrAddr)(nil), "dslite_get_aftr_addr_51077d14") + api.RegisterMessage((*DsliteGetAftrAddrReply)(nil), "dslite_get_aftr_addr_reply_8e23608e") + api.RegisterMessage((*DsliteGetB4Addr)(nil), "dslite_get_b4_addr_51077d14") + api.RegisterMessage((*DsliteGetB4AddrReply)(nil), "dslite_get_b4_addr_reply_8e23608e") + api.RegisterMessage((*DsliteSetAftrAddr)(nil), "dslite_set_aftr_addr_78b50fdf") + api.RegisterMessage((*DsliteSetAftrAddrReply)(nil), "dslite_set_aftr_addr_reply_e8d4e804") + api.RegisterMessage((*DsliteSetB4Addr)(nil), "dslite_set_b4_addr_78b50fdf") + api.RegisterMessage((*DsliteSetB4AddrReply)(nil), "dslite_set_b4_addr_reply_e8d4e804") +} + +// 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), + } +} diff --git a/binapi/dslite/dslite_rpc.ba.go b/binapi/dslite/dslite_rpc.ba.go new file mode 100644 index 00000000..f7333a8c --- /dev/null +++ b/binapi/dslite/dslite_rpc.ba.go @@ -0,0 +1,118 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package dslite + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service dslite. +type RPCService interface { + DsliteAddDelPoolAddrRange(ctx context.Context, in *DsliteAddDelPoolAddrRange) (*DsliteAddDelPoolAddrRangeReply, error) + DsliteAddressDump(ctx context.Context, in *DsliteAddressDump) (RPCService_DsliteAddressDumpClient, 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) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) DsliteAddDelPoolAddrRange(ctx context.Context, in *DsliteAddDelPoolAddrRange) (*DsliteAddDelPoolAddrRangeReply, error) { + out := new(DsliteAddDelPoolAddrRangeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DsliteAddressDump(ctx context.Context, in *DsliteAddressDump) (RPCService_DsliteAddressDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_DsliteAddressDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_DsliteAddressDumpClient interface { + Recv() (*DsliteAddressDetails, error) + api.Stream +} + +type serviceClient_DsliteAddressDumpClient struct { + api.Stream +} + +func (c *serviceClient_DsliteAddressDumpClient) Recv() (*DsliteAddressDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *DsliteAddressDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) DsliteGetAftrAddr(ctx context.Context, in *DsliteGetAftrAddr) (*DsliteGetAftrAddrReply, error) { + out := new(DsliteGetAftrAddrReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DsliteGetB4Addr(ctx context.Context, in *DsliteGetB4Addr) (*DsliteGetB4AddrReply, error) { + out := new(DsliteGetB4AddrReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DsliteSetAftrAddr(ctx context.Context, in *DsliteSetAftrAddr) (*DsliteSetAftrAddrReply, error) { + out := new(DsliteSetAftrAddrReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DsliteSetB4Addr(ctx context.Context, in *DsliteSetB4Addr) (*DsliteSetB4AddrReply, error) { + out := new(DsliteSetB4AddrReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/ethernet_types/ethernet_types.ba.go b/binapi/ethernet_types/ethernet_types.ba.go new file mode 100644 index 00000000..c3cb9ed6 --- /dev/null +++ b/binapi/ethernet_types/ethernet_types.ba.go @@ -0,0 +1,69 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/ethernet_types.api.json + +// Package ethernet_types contains generated bindings for API file ethernet_types.api. +// +// Contents: +// - 1 alias +package ethernet_types + +import ( + "net" + + api "github.com/alkiranet/govpp/api" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "ethernet_types" + APIVersion = "1.0.0" + VersionCrc = 0xf24103d6 +) + +// MacAddress defines alias 'mac_address'. +type MacAddress [6]uint8 + +func NewMacAddress(mac net.HardwareAddr) MacAddress { + var macaddr MacAddress + copy(macaddr[:], mac[:]) + return macaddr +} + +func ParseMacAddress(s string) (MacAddress, error) { + var macaddr MacAddress + mac, err := net.ParseMAC(s) + if err != nil { + return macaddr, err + } + copy(macaddr[:], mac[:]) + return macaddr, nil +} + +func (x MacAddress) ToMAC() net.HardwareAddr { + return net.HardwareAddr(x[:]) +} + +func (x MacAddress) String() string { + return x.ToMAC().String() +} + +func (x *MacAddress) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +func (x *MacAddress) UnmarshalText(text []byte) error { + mac, err := ParseMacAddress(string(text)) + if err != nil { + return err + } + *x = mac + return nil +} diff --git a/binapi/feature/feature.ba.go b/binapi/feature/feature.ba.go new file mode 100644 index 00000000..bdd2c851 --- /dev/null +++ b/binapi/feature/feature.ba.go @@ -0,0 +1,125 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/feature.api.json + +// Package feature contains generated bindings for API file feature.api. +// +// Contents: +// - 2 messages +package feature + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "feature" + APIVersion = "1.0.2" + VersionCrc = 0x8a6e6da1 +) + +// Feature path enable/disable request +// - sw_if_index - the interface +// - enable - 1 = on, 0 = off +// +// FeatureEnableDisable defines message 'feature_enable_disable'. +type FeatureEnableDisable struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Enable bool `binapi:"bool,name=enable" json:"enable,omitempty"` + ArcName string `binapi:"string[64],name=arc_name" json:"arc_name,omitempty"` + FeatureName string `binapi:"string[64],name=feature_name" json:"feature_name,omitempty"` +} + +func (m *FeatureEnableDisable) Reset() { *m = FeatureEnableDisable{} } +func (*FeatureEnableDisable) GetMessageName() string { return "feature_enable_disable" } +func (*FeatureEnableDisable) GetCrcString() string { return "7531c862" } +func (*FeatureEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *FeatureEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.Enable + size += 64 // m.ArcName + size += 64 // m.FeatureName + return size +} +func (m *FeatureEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.Enable) + buf.EncodeString(m.ArcName, 64) + buf.EncodeString(m.FeatureName, 64) + return buf.Bytes(), nil +} +func (m *FeatureEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Enable = buf.DecodeBool() + m.ArcName = buf.DecodeString(64) + m.FeatureName = buf.DecodeString(64) + return nil +} + +// FeatureEnableDisableReply defines message 'feature_enable_disable_reply'. +type FeatureEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *FeatureEnableDisableReply) Reset() { *m = FeatureEnableDisableReply{} } +func (*FeatureEnableDisableReply) GetMessageName() string { return "feature_enable_disable_reply" } +func (*FeatureEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*FeatureEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *FeatureEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *FeatureEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *FeatureEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_feature_binapi_init() } +func file_feature_binapi_init() { + api.RegisterMessage((*FeatureEnableDisable)(nil), "feature_enable_disable_7531c862") + api.RegisterMessage((*FeatureEnableDisableReply)(nil), "feature_enable_disable_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*FeatureEnableDisable)(nil), + (*FeatureEnableDisableReply)(nil), + } +} diff --git a/binapi/feature/feature_rpc.ba.go b/binapi/feature/feature_rpc.ba.go new file mode 100644 index 00000000..635de1ba --- /dev/null +++ b/binapi/feature/feature_rpc.ba.go @@ -0,0 +1,31 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package feature + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service feature. +type RPCService interface { + FeatureEnableDisable(ctx context.Context, in *FeatureEnableDisable) (*FeatureEnableDisableReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) FeatureEnableDisable(ctx context.Context, in *FeatureEnableDisable) (*FeatureEnableDisableReply, error) { + out := new(FeatureEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/fib/fib.ba.go b/binapi/fib/fib.ba.go new file mode 100644 index 00000000..5793ddcd --- /dev/null +++ b/binapi/fib/fib.ba.go @@ -0,0 +1,212 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/fib.api.json + +// Package fib contains generated bindings for API file fib.api. +// +// Contents: +// - 1 struct +// - 4 messages +package fib + +import ( + api "github.com/alkiranet/govpp/api" + _ "github.com/alkiranet/govpp/binapi/fib_types" + _ "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "fib" + APIVersion = "1.0.0" + VersionCrc = 0x4ef4abc1 +) + +// FibSource defines type 'fib_source'. +type FibSource struct { + Priority uint8 `binapi:"u8,name=priority" json:"priority,omitempty"` + ID uint8 `binapi:"u8,name=id" json:"id,omitempty"` + Name string `binapi:"string[64],name=name" json:"name,omitempty"` +} + +// /* +// - Copyright (c) 2018 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. +// +// FibSourceAdd defines message 'fib_source_add'. +type FibSourceAdd struct { + Src FibSource `binapi:"fib_source,name=src" json:"src,omitempty"` +} + +func (m *FibSourceAdd) Reset() { *m = FibSourceAdd{} } +func (*FibSourceAdd) GetMessageName() string { return "fib_source_add" } +func (*FibSourceAdd) GetCrcString() string { return "b3ac2aec" } +func (*FibSourceAdd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *FibSourceAdd) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Src.Priority + size += 1 // m.Src.ID + size += 64 // m.Src.Name + return size +} +func (m *FibSourceAdd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.Src.Priority) + buf.EncodeUint8(m.Src.ID) + buf.EncodeString(m.Src.Name, 64) + return buf.Bytes(), nil +} +func (m *FibSourceAdd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Src.Priority = buf.DecodeUint8() + m.Src.ID = buf.DecodeUint8() + m.Src.Name = buf.DecodeString(64) + return nil +} + +// FibSourceAddReply defines message 'fib_source_add_reply'. +type FibSourceAddReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + ID uint8 `binapi:"u8,name=id" json:"id,omitempty"` +} + +func (m *FibSourceAddReply) Reset() { *m = FibSourceAddReply{} } +func (*FibSourceAddReply) GetMessageName() string { return "fib_source_add_reply" } +func (*FibSourceAddReply) GetCrcString() string { return "604fd6f1" } +func (*FibSourceAddReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *FibSourceAddReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.ID + return size +} +func (m *FibSourceAddReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint8(m.ID) + return buf.Bytes(), nil +} +func (m *FibSourceAddReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.ID = buf.DecodeUint8() + return nil +} + +// FibSourceDetails defines message 'fib_source_details'. +type FibSourceDetails struct { + Src FibSource `binapi:"fib_source,name=src" json:"src,omitempty"` +} + +func (m *FibSourceDetails) Reset() { *m = FibSourceDetails{} } +func (*FibSourceDetails) GetMessageName() string { return "fib_source_details" } +func (*FibSourceDetails) GetCrcString() string { return "8668acdb" } +func (*FibSourceDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *FibSourceDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Src.Priority + size += 1 // m.Src.ID + size += 64 // m.Src.Name + return size +} +func (m *FibSourceDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.Src.Priority) + buf.EncodeUint8(m.Src.ID) + buf.EncodeString(m.Src.Name, 64) + return buf.Bytes(), nil +} +func (m *FibSourceDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Src.Priority = buf.DecodeUint8() + m.Src.ID = buf.DecodeUint8() + m.Src.Name = buf.DecodeString(64) + return nil +} + +// FibSourceDump defines message 'fib_source_dump'. +type FibSourceDump struct{} + +func (m *FibSourceDump) Reset() { *m = FibSourceDump{} } +func (*FibSourceDump) GetMessageName() string { return "fib_source_dump" } +func (*FibSourceDump) GetCrcString() string { return "51077d14" } +func (*FibSourceDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *FibSourceDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *FibSourceDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *FibSourceDump) Unmarshal(b []byte) error { + return nil +} + +func init() { file_fib_binapi_init() } +func file_fib_binapi_init() { + api.RegisterMessage((*FibSourceAdd)(nil), "fib_source_add_b3ac2aec") + api.RegisterMessage((*FibSourceAddReply)(nil), "fib_source_add_reply_604fd6f1") + api.RegisterMessage((*FibSourceDetails)(nil), "fib_source_details_8668acdb") + api.RegisterMessage((*FibSourceDump)(nil), "fib_source_dump_51077d14") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*FibSourceAdd)(nil), + (*FibSourceAddReply)(nil), + (*FibSourceDetails)(nil), + (*FibSourceDump)(nil), + } +} diff --git a/binapi/fib/fib_rpc.ba.go b/binapi/fib/fib_rpc.ba.go new file mode 100644 index 00000000..e85c91d6 --- /dev/null +++ b/binapi/fib/fib_rpc.ba.go @@ -0,0 +1,78 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package fib + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service fib. +type RPCService interface { + FibSourceAdd(ctx context.Context, in *FibSourceAdd) (*FibSourceAddReply, error) + FibSourceDump(ctx context.Context, in *FibSourceDump) (RPCService_FibSourceDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) FibSourceAdd(ctx context.Context, in *FibSourceAdd) (*FibSourceAddReply, error) { + out := new(FibSourceAddReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) FibSourceDump(ctx context.Context, in *FibSourceDump) (RPCService_FibSourceDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_FibSourceDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_FibSourceDumpClient interface { + Recv() (*FibSourceDetails, error) + api.Stream +} + +type serviceClient_FibSourceDumpClient struct { + api.Stream +} + +func (c *serviceClient_FibSourceDumpClient) Recv() (*FibSourceDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *FibSourceDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/fib_types/fib_types.ba.go b/binapi/fib_types/fib_types.ba.go new file mode 100644 index 00000000..7009022d --- /dev/null +++ b/binapi/fib_types/fib_types.ba.go @@ -0,0 +1,204 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/fib_types.api.json + +// Package fib_types contains generated bindings for API file fib_types.api. +// +// Contents: +// - 3 enums +// - 3 structs +package fib_types + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "fib_types" + APIVersion = "2.0.1" + VersionCrc = 0x21fd785b +) + +// FibPathFlags defines 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", + } + 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 + } + str := func(n uint32) string { + s, ok := FibPathFlags_name[uint32(n)] + if ok { + return s + } + return "FibPathFlags(" + strconv.Itoa(int(n)) + ")" + } + for i := uint32(0); i <= 32; i++ { + val := uint32(x) + if val&(1< dynamically allocate +// +// CreateLoopbackInstance defines message 'create_loopback_instance'. +type CreateLoopbackInstance struct { + MacAddress ethernet_types.MacAddress `binapi:"mac_address,name=mac_address" json:"mac_address,omitempty"` + IsSpecified bool `binapi:"bool,name=is_specified" json:"is_specified,omitempty"` + UserInstance uint32 `binapi:"u32,name=user_instance" json:"user_instance,omitempty"` +} + +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 +} + +func (m *CreateLoopbackInstance) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 6 // m.MacAddress + size += 1 // m.IsSpecified + size += 4 // m.UserInstance + return size +} +func (m *CreateLoopbackInstance) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.MacAddress[:], 6) + buf.EncodeBool(m.IsSpecified) + buf.EncodeUint32(m.UserInstance) + return buf.Bytes(), nil +} +func (m *CreateLoopbackInstance) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.MacAddress[:], buf.DecodeBytes(6)) + m.IsSpecified = buf.DecodeBool() + m.UserInstance = buf.DecodeUint32() + return nil +} + +// Create loopback interface instance response +// - sw_if_index - sw index of the interface that was created +// - retval - return code for the request +// +// CreateLoopbackInstanceReply defines message 'create_loopback_instance_reply'. +type CreateLoopbackInstanceReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *CreateLoopbackInstanceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *CreateLoopbackInstanceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *CreateLoopbackInstanceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Create loopback interface response +// - sw_if_index - sw index of the interface that was created +// - retval - return code for the request +// +// CreateLoopbackReply defines message 'create_loopback_reply'. +type CreateLoopbackReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *CreateLoopbackReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *CreateLoopbackReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *CreateLoopbackReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// CreateSubif defines message 'create_subif'. +type CreateSubif struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + SubID uint32 `binapi:"u32,name=sub_id" json:"sub_id,omitempty"` + SubIfFlags interface_types.SubIfFlags `binapi:"sub_if_flags,name=sub_if_flags" json:"sub_if_flags,omitempty"` + OuterVlanID uint16 `binapi:"u16,name=outer_vlan_id" json:"outer_vlan_id,omitempty"` + InnerVlanID uint16 `binapi:"u16,name=inner_vlan_id" json:"inner_vlan_id,omitempty"` +} + +func (m *CreateSubif) Reset() { *m = CreateSubif{} } +func (*CreateSubif) GetMessageName() string { return "create_subif" } +func (*CreateSubif) GetCrcString() string { return "790ca755" } +func (*CreateSubif) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *CreateSubif) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.SubID + size += 4 // m.SubIfFlags + size += 2 // m.OuterVlanID + size += 2 // m.InnerVlanID + return size +} +func (m *CreateSubif) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.SubID) + buf.EncodeUint32(uint32(m.SubIfFlags)) + buf.EncodeUint16(m.OuterVlanID) + buf.EncodeUint16(m.InnerVlanID) + return buf.Bytes(), nil +} +func (m *CreateSubif) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.SubID = buf.DecodeUint32() + m.SubIfFlags = interface_types.SubIfFlags(buf.DecodeUint32()) + m.OuterVlanID = buf.DecodeUint16() + m.InnerVlanID = buf.DecodeUint16() + return nil +} + +// CreateSubifReply defines message 'create_subif_reply'. +type CreateSubifReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *CreateSubifReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *CreateSubifReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *CreateSubifReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Create a new subinterface with the given vlan id +// - sw_if_index - software index of the new vlan's parent interface +// - vlan_id - vlan tag of the new interface +// +// CreateVlanSubif defines message 'create_vlan_subif'. +type CreateVlanSubif struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + VlanID uint32 `binapi:"u32,name=vlan_id" json:"vlan_id,omitempty"` +} + +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 +} + +func (m *CreateVlanSubif) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.VlanID + return size +} +func (m *CreateVlanSubif) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.VlanID) + return buf.Bytes(), nil +} +func (m *CreateVlanSubif) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.VlanID = buf.DecodeUint32() + return nil +} + +// Reply for the vlan subinterface create request +// - retval - return code +// - sw_if_index - software index allocated for the new subinterface +// +// CreateVlanSubifReply defines message 'create_vlan_subif_reply'. +type CreateVlanSubifReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *CreateVlanSubifReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *CreateVlanSubifReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *CreateVlanSubifReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Delete loopback interface request +// - sw_if_index - sw index of the interface that was created +// +// DeleteLoopback defines message 'delete_loopback'. +type DeleteLoopback struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *DeleteLoopback) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *DeleteLoopback) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *DeleteLoopback) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// DeleteLoopbackReply defines message 'delete_loopback_reply'. +type DeleteLoopbackReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *DeleteLoopbackReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *DeleteLoopbackReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *DeleteLoopbackReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Delete sub interface request +// - sw_if_index - sw index of the interface that was created by create_subif +// +// DeleteSubif defines message 'delete_subif'. +type DeleteSubif struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *DeleteSubif) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *DeleteSubif) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *DeleteSubif) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// DeleteSubifReply defines message 'delete_subif_reply'. +type DeleteSubifReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *DeleteSubifReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *DeleteSubifReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *DeleteSubifReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set interface physical MTU +// - sw_if_index - index of the interface to set MTU on +// - mtu - MTU +// +// HwInterfaceSetMtu defines message 'hw_interface_set_mtu'. +type HwInterfaceSetMtu struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Mtu uint16 `binapi:"u16,name=mtu" json:"mtu,omitempty"` +} + +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 +} + +func (m *HwInterfaceSetMtu) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 2 // m.Mtu + return size +} +func (m *HwInterfaceSetMtu) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint16(m.Mtu) + return buf.Bytes(), nil +} +func (m *HwInterfaceSetMtu) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Mtu = buf.DecodeUint16() + return nil +} + +// HwInterfaceSetMtuReply defines message 'hw_interface_set_mtu_reply'. +type HwInterfaceSetMtuReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *HwInterfaceSetMtuReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *HwInterfaceSetMtuReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *HwInterfaceSetMtuReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// /* Gross kludge, DGMS +// InterfaceNameRenumber defines message 'interface_name_renumber'. +type InterfaceNameRenumber struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + NewShowDevInstance uint32 `binapi:"u32,name=new_show_dev_instance" json:"new_show_dev_instance,omitempty"` +} + +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 +} + +func (m *InterfaceNameRenumber) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.NewShowDevInstance + return size +} +func (m *InterfaceNameRenumber) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.NewShowDevInstance) + return buf.Bytes(), nil +} +func (m *InterfaceNameRenumber) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.NewShowDevInstance = buf.DecodeUint32() + return nil +} + +// InterfaceNameRenumberReply defines message 'interface_name_renumber_reply'. +type InterfaceNameRenumberReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *InterfaceNameRenumberReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *InterfaceNameRenumberReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *InterfaceNameRenumberReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// PcapTraceOff defines message 'pcap_trace_off'. +type PcapTraceOff struct{} + +func (m *PcapTraceOff) Reset() { *m = PcapTraceOff{} } +func (*PcapTraceOff) GetMessageName() string { return "pcap_trace_off" } +func (*PcapTraceOff) GetCrcString() string { return "51077d14" } +func (*PcapTraceOff) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PcapTraceOff) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *PcapTraceOff) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *PcapTraceOff) Unmarshal(b []byte) error { + return nil +} + +// PcapTraceOffReply defines message 'pcap_trace_off_reply'. +type PcapTraceOffReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PcapTraceOffReply) Reset() { *m = PcapTraceOffReply{} } +func (*PcapTraceOffReply) GetMessageName() string { return "pcap_trace_off_reply" } +func (*PcapTraceOffReply) GetCrcString() string { return "e8d4e804" } +func (*PcapTraceOffReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PcapTraceOffReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PcapTraceOffReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PcapTraceOffReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// pcap_trace_on +// - capture_rx - capture received packets +// - capture_tx - capture transmitted packets +// - capture_drop - capture dropped packets +// - filter - is a filter is being used on this capture +// - preallocate_data - preallocate the data buffer +// - free_data - free the data buffer +// - max_packets - depth of local buffer +// - max_bytes_per_packet - maximum number of bytes to capture +// for each packet +// - sw_if_index - specify a given interface, or 0 for any +// - error - filter packets based on a specific error. +// - filename - output filename, will be placed in /tmp +// +// PcapTraceOn defines message 'pcap_trace_on'. +type PcapTraceOn struct { + CaptureRx bool `binapi:"bool,name=capture_rx" json:"capture_rx,omitempty"` + CaptureTx bool `binapi:"bool,name=capture_tx" json:"capture_tx,omitempty"` + CaptureDrop bool `binapi:"bool,name=capture_drop" json:"capture_drop,omitempty"` + Filter bool `binapi:"bool,name=filter" json:"filter,omitempty"` + PreallocateData bool `binapi:"bool,name=preallocate_data" json:"preallocate_data,omitempty"` + FreeData bool `binapi:"bool,name=free_data" json:"free_data,omitempty"` + MaxPackets uint32 `binapi:"u32,name=max_packets,default=1000" json:"max_packets,omitempty"` + MaxBytesPerPacket uint32 `binapi:"u32,name=max_bytes_per_packet,default=512" json:"max_bytes_per_packet,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Error string `binapi:"string[128],name=error" json:"error,omitempty"` + Filename string `binapi:"string[64],name=filename" json:"filename,omitempty"` +} + +func (m *PcapTraceOn) Reset() { *m = PcapTraceOn{} } +func (*PcapTraceOn) GetMessageName() string { return "pcap_trace_on" } +func (*PcapTraceOn) GetCrcString() string { return "cb39e968" } +func (*PcapTraceOn) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PcapTraceOn) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.CaptureRx + size += 1 // m.CaptureTx + size += 1 // m.CaptureDrop + size += 1 // m.Filter + size += 1 // m.PreallocateData + size += 1 // m.FreeData + size += 4 // m.MaxPackets + size += 4 // m.MaxBytesPerPacket + size += 4 // m.SwIfIndex + size += 128 // m.Error + size += 64 // m.Filename + return size +} +func (m *PcapTraceOn) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.CaptureRx) + buf.EncodeBool(m.CaptureTx) + buf.EncodeBool(m.CaptureDrop) + buf.EncodeBool(m.Filter) + buf.EncodeBool(m.PreallocateData) + buf.EncodeBool(m.FreeData) + buf.EncodeUint32(m.MaxPackets) + buf.EncodeUint32(m.MaxBytesPerPacket) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeString(m.Error, 128) + buf.EncodeString(m.Filename, 64) + return buf.Bytes(), nil +} +func (m *PcapTraceOn) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.CaptureRx = buf.DecodeBool() + m.CaptureTx = buf.DecodeBool() + m.CaptureDrop = buf.DecodeBool() + m.Filter = buf.DecodeBool() + m.PreallocateData = buf.DecodeBool() + m.FreeData = buf.DecodeBool() + m.MaxPackets = buf.DecodeUint32() + m.MaxBytesPerPacket = buf.DecodeUint32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Error = buf.DecodeString(128) + m.Filename = buf.DecodeString(64) + return nil +} + +// PcapTraceOnReply defines message 'pcap_trace_on_reply'. +type PcapTraceOnReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PcapTraceOnReply) Reset() { *m = PcapTraceOnReply{} } +func (*PcapTraceOnReply) GetMessageName() string { return "pcap_trace_on_reply" } +func (*PcapTraceOnReply) GetCrcString() string { return "e8d4e804" } +func (*PcapTraceOnReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PcapTraceOnReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PcapTraceOnReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PcapTraceOnReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set or delete one or all ip addresses on a specified interface +// - sw_if_index - index of the interface to add/del addresses +// - is_add - add address if non-zero, else delete +// - del_all - if non-zero delete all addresses on the interface +// - prefix - address + a prefix length for the implied connected route +// +// SwInterfaceAddDelAddress defines message 'sw_interface_add_del_address'. +type SwInterfaceAddDelAddress struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + DelAll bool `binapi:"bool,name=del_all" json:"del_all,omitempty"` + Prefix ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=prefix" json:"prefix,omitempty"` +} + +func (m *SwInterfaceAddDelAddress) Reset() { *m = SwInterfaceAddDelAddress{} } +func (*SwInterfaceAddDelAddress) GetMessageName() string { return "sw_interface_add_del_address" } +func (*SwInterfaceAddDelAddress) GetCrcString() string { return "5463d73b" } +func (*SwInterfaceAddDelAddress) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceAddDelAddress) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.IsAdd + size += 1 // m.DelAll + size += 1 // m.Prefix.Address.Af + size += 1 * 16 // m.Prefix.Address.Un + size += 1 // m.Prefix.Len + return size +} +func (m *SwInterfaceAddDelAddress) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.IsAdd) + buf.EncodeBool(m.DelAll) + buf.EncodeUint8(uint8(m.Prefix.Address.Af)) + buf.EncodeBytes(m.Prefix.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Prefix.Len) + return buf.Bytes(), nil +} +func (m *SwInterfaceAddDelAddress) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsAdd = buf.DecodeBool() + m.DelAll = buf.DecodeBool() + m.Prefix.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Prefix.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Prefix.Len = buf.DecodeUint8() + return nil +} + +// SwInterfaceAddDelAddressReply defines message 'sw_interface_add_del_address_reply'. +type SwInterfaceAddDelAddressReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceAddDelAddressReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceAddDelAddressReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceAddDelAddressReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add or delete a secondary MAC address on an interface +// - sw_if_index - the interface whose MAC will be set +// - mac_addr - the new MAC address +// - is_add - 0 to delete, != 0 to add +// +// SwInterfaceAddDelMacAddress defines message 'sw_interface_add_del_mac_address'. +type SwInterfaceAddDelMacAddress struct { + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + Addr ethernet_types.MacAddress `binapi:"mac_address,name=addr" json:"addr,omitempty"` + IsAdd uint8 `binapi:"u8,name=is_add" json:"is_add,omitempty"` +} + +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 +} + +func (m *SwInterfaceAddDelMacAddress) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 * 6 // m.Addr + size += 1 // m.IsAdd + return size +} +func (m *SwInterfaceAddDelMacAddress) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.SwIfIndex) + buf.EncodeBytes(m.Addr[:], 6) + buf.EncodeUint8(m.IsAdd) + return buf.Bytes(), nil +} +func (m *SwInterfaceAddDelMacAddress) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = buf.DecodeUint32() + copy(m.Addr[:], buf.DecodeBytes(6)) + m.IsAdd = buf.DecodeUint8() + return nil +} + +// SwInterfaceAddDelMacAddressReply defines message 'sw_interface_add_del_mac_address_reply'. +type SwInterfaceAddDelMacAddressReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceAddDelMacAddressReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceAddDelMacAddressReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceAddDelMacAddressReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IP interface address replace begin +// +// The use-case is that, for some unspecified reason, the control plane +// has a different set of interface addresses than VPP +// currently has. The CP would thus like to 'replace' VPP's set +// only by specifying what the new set shall be, i.e. it is not +// going to delete anything that already eixts, rather, is wants any +// unspecified interface addresses to be deleted implicitly. +// The CP declares the start of this procedure with this replace_begin +// API Call, and when it has populated all addresses it wants, it calls +// the below replace_end API. From this point on it is of course free +// to add and delete interface addresses as usual. +// The underlying mechanism by which VPP implements this replace is +// intentionally left unspecified. +// +// SwInterfaceAddressReplaceBegin defines message 'sw_interface_address_replace_begin'. +type SwInterfaceAddressReplaceBegin struct{} + +func (m *SwInterfaceAddressReplaceBegin) Reset() { *m = SwInterfaceAddressReplaceBegin{} } +func (*SwInterfaceAddressReplaceBegin) GetMessageName() string { + return "sw_interface_address_replace_begin" +} +func (*SwInterfaceAddressReplaceBegin) GetCrcString() string { return "51077d14" } +func (*SwInterfaceAddressReplaceBegin) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceAddressReplaceBegin) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SwInterfaceAddressReplaceBegin) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SwInterfaceAddressReplaceBegin) Unmarshal(b []byte) error { + return nil +} + +// SwInterfaceAddressReplaceBeginReply defines message 'sw_interface_address_replace_begin_reply'. +type SwInterfaceAddressReplaceBeginReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SwInterfaceAddressReplaceBeginReply) Reset() { *m = SwInterfaceAddressReplaceBeginReply{} } +func (*SwInterfaceAddressReplaceBeginReply) GetMessageName() string { + return "sw_interface_address_replace_begin_reply" +} +func (*SwInterfaceAddressReplaceBeginReply) GetCrcString() string { return "e8d4e804" } +func (*SwInterfaceAddressReplaceBeginReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwInterfaceAddressReplaceBeginReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceAddressReplaceBeginReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceAddressReplaceBeginReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IP interface address replace end +// +// see ip_interface_address_replace_begin description. +// +// SwInterfaceAddressReplaceEnd defines message 'sw_interface_address_replace_end'. +type SwInterfaceAddressReplaceEnd struct{} + +func (m *SwInterfaceAddressReplaceEnd) Reset() { *m = SwInterfaceAddressReplaceEnd{} } +func (*SwInterfaceAddressReplaceEnd) GetMessageName() string { + return "sw_interface_address_replace_end" +} +func (*SwInterfaceAddressReplaceEnd) GetCrcString() string { return "51077d14" } +func (*SwInterfaceAddressReplaceEnd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceAddressReplaceEnd) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SwInterfaceAddressReplaceEnd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SwInterfaceAddressReplaceEnd) Unmarshal(b []byte) error { + return nil +} + +// SwInterfaceAddressReplaceEndReply defines message 'sw_interface_address_replace_end_reply'. +type SwInterfaceAddressReplaceEndReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SwInterfaceAddressReplaceEndReply) Reset() { *m = SwInterfaceAddressReplaceEndReply{} } +func (*SwInterfaceAddressReplaceEndReply) GetMessageName() string { + return "sw_interface_address_replace_end_reply" +} +func (*SwInterfaceAddressReplaceEndReply) GetCrcString() string { return "e8d4e804" } +func (*SwInterfaceAddressReplaceEndReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwInterfaceAddressReplaceEndReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceAddressReplaceEndReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceAddressReplaceEndReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Clear interface statistics +// - sw_if_index - index of the interface to clear statistics +// +// SwInterfaceClearStats defines message 'sw_interface_clear_stats'. +type SwInterfaceClearStats struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *SwInterfaceClearStats) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *SwInterfaceClearStats) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *SwInterfaceClearStats) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// SwInterfaceClearStatsReply defines message 'sw_interface_clear_stats_reply'. +type SwInterfaceClearStatsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceClearStatsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceClearStatsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceClearStatsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Interface details structure (fix this) +// - sw_if_index - index of the interface +// - sup_sw_if_index - index of parent interface if any, else same as sw_if_index +// - l2_address - the interface's l2 address +// - flags - interface_status flags +// - type - interface type +// - link_duplex - 1 if half duplex, 2 if full duplex +// - link_speed - value in kbps +// - link_MTU - max. transmission unit +// - sub_id - A number 0-N to uniquely identify this subif on super if +// - sub_number_of_tags - Number of tags (0 - 2) +// - sub_outer_vlan_id +// - sub_inner_vlan_id +// - sub_if_flags - sub interface flags +// - vtr_op - vlan tag rewrite operation +// - vtr_push_dot1q +// - vtr_tag1 +// - vtr_tag2 +// - pbb_outer_tag - translate pbb s-tag +// - pbb_b_dmac[6] - B-tag remote mac address +// - pbb_b_smac[6] - B-tag local mac address +// - pbb_b_vlanid - B-tag vlanid +// - pbb_i_sid - I-tag service id +// - interface_name - name of the interface +// - interface_dev_type - device type of the interface +// - tag - an ascii tag +// +// SwInterfaceDetails defines message 'sw_interface_details'. +type SwInterfaceDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + SupSwIfIndex uint32 `binapi:"u32,name=sup_sw_if_index" json:"sup_sw_if_index,omitempty"` + L2Address ethernet_types.MacAddress `binapi:"mac_address,name=l2_address" json:"l2_address,omitempty"` + Flags interface_types.IfStatusFlags `binapi:"if_status_flags,name=flags" json:"flags,omitempty"` + Type interface_types.IfType `binapi:"if_type,name=type" json:"type,omitempty"` + LinkDuplex interface_types.LinkDuplex `binapi:"link_duplex,name=link_duplex" json:"link_duplex,omitempty"` + LinkSpeed uint32 `binapi:"u32,name=link_speed" json:"link_speed,omitempty"` + LinkMtu uint16 `binapi:"u16,name=link_mtu" json:"link_mtu,omitempty"` + Mtu []uint32 `binapi:"u32[4],name=mtu" json:"mtu,omitempty"` + SubID uint32 `binapi:"u32,name=sub_id" json:"sub_id,omitempty"` + SubNumberOfTags uint8 `binapi:"u8,name=sub_number_of_tags" json:"sub_number_of_tags,omitempty"` + SubOuterVlanID uint16 `binapi:"u16,name=sub_outer_vlan_id" json:"sub_outer_vlan_id,omitempty"` + SubInnerVlanID uint16 `binapi:"u16,name=sub_inner_vlan_id" json:"sub_inner_vlan_id,omitempty"` + SubIfFlags interface_types.SubIfFlags `binapi:"sub_if_flags,name=sub_if_flags" json:"sub_if_flags,omitempty"` + VtrOp uint32 `binapi:"u32,name=vtr_op" json:"vtr_op,omitempty"` + VtrPushDot1q uint32 `binapi:"u32,name=vtr_push_dot1q" json:"vtr_push_dot1q,omitempty"` + VtrTag1 uint32 `binapi:"u32,name=vtr_tag1" json:"vtr_tag1,omitempty"` + VtrTag2 uint32 `binapi:"u32,name=vtr_tag2" json:"vtr_tag2,omitempty"` + OuterTag uint16 `binapi:"u16,name=outer_tag" json:"outer_tag,omitempty"` + BDmac ethernet_types.MacAddress `binapi:"mac_address,name=b_dmac" json:"b_dmac,omitempty"` + BSmac ethernet_types.MacAddress `binapi:"mac_address,name=b_smac" json:"b_smac,omitempty"` + BVlanid uint16 `binapi:"u16,name=b_vlanid" json:"b_vlanid,omitempty"` + ISid uint32 `binapi:"u32,name=i_sid" json:"i_sid,omitempty"` + InterfaceName string `binapi:"string[64],name=interface_name" json:"interface_name,omitempty"` + InterfaceDevType string `binapi:"string[64],name=interface_dev_type" json:"interface_dev_type,omitempty"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty"` +} + +func (m *SwInterfaceDetails) Reset() { *m = SwInterfaceDetails{} } +func (*SwInterfaceDetails) GetMessageName() string { return "sw_interface_details" } +func (*SwInterfaceDetails) GetCrcString() string { return "6c221fc7" } +func (*SwInterfaceDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwInterfaceDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.SupSwIfIndex + size += 1 * 6 // m.L2Address + size += 4 // m.Flags + size += 4 // m.Type + size += 4 // m.LinkDuplex + size += 4 // m.LinkSpeed + size += 2 // m.LinkMtu + size += 4 * 4 // m.Mtu + size += 4 // m.SubID + size += 1 // m.SubNumberOfTags + size += 2 // m.SubOuterVlanID + size += 2 // m.SubInnerVlanID + size += 4 // m.SubIfFlags + size += 4 // m.VtrOp + size += 4 // m.VtrPushDot1q + size += 4 // m.VtrTag1 + size += 4 // m.VtrTag2 + size += 2 // m.OuterTag + size += 1 * 6 // m.BDmac + size += 1 * 6 // m.BSmac + size += 2 // m.BVlanid + size += 4 // m.ISid + size += 64 // m.InterfaceName + size += 64 // m.InterfaceDevType + size += 64 // m.Tag + return size +} +func (m *SwInterfaceDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.SupSwIfIndex) + buf.EncodeBytes(m.L2Address[:], 6) + buf.EncodeUint32(uint32(m.Flags)) + buf.EncodeUint32(uint32(m.Type)) + buf.EncodeUint32(uint32(m.LinkDuplex)) + buf.EncodeUint32(m.LinkSpeed) + buf.EncodeUint16(m.LinkMtu) + for i := 0; i < 4; i++ { + var x uint32 + if i < len(m.Mtu) { + x = uint32(m.Mtu[i]) + } + buf.EncodeUint32(x) + } + buf.EncodeUint32(m.SubID) + buf.EncodeUint8(m.SubNumberOfTags) + buf.EncodeUint16(m.SubOuterVlanID) + buf.EncodeUint16(m.SubInnerVlanID) + buf.EncodeUint32(uint32(m.SubIfFlags)) + buf.EncodeUint32(m.VtrOp) + buf.EncodeUint32(m.VtrPushDot1q) + buf.EncodeUint32(m.VtrTag1) + buf.EncodeUint32(m.VtrTag2) + buf.EncodeUint16(m.OuterTag) + buf.EncodeBytes(m.BDmac[:], 6) + buf.EncodeBytes(m.BSmac[:], 6) + buf.EncodeUint16(m.BVlanid) + buf.EncodeUint32(m.ISid) + buf.EncodeString(m.InterfaceName, 64) + buf.EncodeString(m.InterfaceDevType, 64) + buf.EncodeString(m.Tag, 64) + return buf.Bytes(), nil +} +func (m *SwInterfaceDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.SupSwIfIndex = buf.DecodeUint32() + copy(m.L2Address[:], buf.DecodeBytes(6)) + m.Flags = interface_types.IfStatusFlags(buf.DecodeUint32()) + m.Type = interface_types.IfType(buf.DecodeUint32()) + m.LinkDuplex = interface_types.LinkDuplex(buf.DecodeUint32()) + m.LinkSpeed = buf.DecodeUint32() + m.LinkMtu = buf.DecodeUint16() + m.Mtu = make([]uint32, 4) + for i := 0; i < len(m.Mtu); i++ { + m.Mtu[i] = buf.DecodeUint32() + } + m.SubID = buf.DecodeUint32() + m.SubNumberOfTags = buf.DecodeUint8() + m.SubOuterVlanID = buf.DecodeUint16() + m.SubInnerVlanID = buf.DecodeUint16() + m.SubIfFlags = interface_types.SubIfFlags(buf.DecodeUint32()) + m.VtrOp = buf.DecodeUint32() + m.VtrPushDot1q = buf.DecodeUint32() + m.VtrTag1 = buf.DecodeUint32() + m.VtrTag2 = buf.DecodeUint32() + m.OuterTag = buf.DecodeUint16() + copy(m.BDmac[:], buf.DecodeBytes(6)) + copy(m.BSmac[:], buf.DecodeBytes(6)) + m.BVlanid = buf.DecodeUint16() + m.ISid = buf.DecodeUint32() + m.InterfaceName = buf.DecodeString(64) + m.InterfaceDevType = buf.DecodeString(64) + m.Tag = buf.DecodeString(64) + return nil +} + +// Request all or filtered subset of sw_interface_details +// - sw_if_index - index of the interface to dump info on, 0 or ~0 if on all +// TODO: Support selecting only index==0 when CSIT is ready. +// - name_filter_valid - 1 if requesting a filtered subset of records else 0 +// if name filter is set as valid, sw_if_index value is ignored and all interfaces are examined +// - name_filter - interface name substring filter. Eg. loop1 returns [loop1, loop10] +// +// SwInterfaceDump defines message 'sw_interface_dump'. +type SwInterfaceDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` + NameFilterValid bool `binapi:"bool,name=name_filter_valid" json:"name_filter_valid,omitempty"` + NameFilter string `binapi:"string[],name=name_filter" json:"name_filter,omitempty"` +} + +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 +} + +func (m *SwInterfaceDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.NameFilterValid + size += 4 + len(m.NameFilter) // m.NameFilter + return size +} +func (m *SwInterfaceDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.NameFilterValid) + buf.EncodeString(m.NameFilter, 0) + return buf.Bytes(), nil +} +func (m *SwInterfaceDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.NameFilterValid = buf.DecodeBool() + m.NameFilter = buf.DecodeString(0) + return nil +} + +// Interface Event generated by want_interface_events +// - pid - client pid registered to receive notification +// - sw_if_index - index of the interface of the event +// - flags - interface_status flags +// - deleted - interface was deleted +// +// SwInterfaceEvent defines message 'sw_interface_event'. +type SwInterfaceEvent struct { + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Flags interface_types.IfStatusFlags `binapi:"if_status_flags,name=flags" json:"flags,omitempty"` + Deleted bool `binapi:"bool,name=deleted" json:"deleted,omitempty"` +} + +func (m *SwInterfaceEvent) Reset() { *m = SwInterfaceEvent{} } +func (*SwInterfaceEvent) GetMessageName() string { return "sw_interface_event" } +func (*SwInterfaceEvent) GetCrcString() string { return "2d3d95a7" } +func (*SwInterfaceEvent) GetMessageType() api.MessageType { + return api.EventMessage +} + +func (m *SwInterfaceEvent) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PID + size += 4 // m.SwIfIndex + size += 4 // m.Flags + size += 1 // m.Deleted + return size +} +func (m *SwInterfaceEvent) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PID) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(uint32(m.Flags)) + buf.EncodeBool(m.Deleted) + return buf.Bytes(), nil +} +func (m *SwInterfaceEvent) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PID = buf.DecodeUint32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Flags = interface_types.IfStatusFlags(buf.DecodeUint32()) + m.Deleted = buf.DecodeBool() + return nil +} + +// Get interface's MAC address +// - sw_if_index - the interface whose MAC will be returned +// +// SwInterfaceGetMacAddress defines message 'sw_interface_get_mac_address'. +type SwInterfaceGetMacAddress struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *SwInterfaceGetMacAddress) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *SwInterfaceGetMacAddress) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *SwInterfaceGetMacAddress) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Reply for get interface's MAC address request +// - retval - return code +// - mac_addr - returned interface's MAC address +// +// SwInterfaceGetMacAddressReply defines message 'sw_interface_get_mac_address_reply'. +type SwInterfaceGetMacAddressReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + MacAddress ethernet_types.MacAddress `binapi:"mac_address,name=mac_address" json:"mac_address,omitempty"` +} + +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 +} + +func (m *SwInterfaceGetMacAddressReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 * 6 // m.MacAddress + return size +} +func (m *SwInterfaceGetMacAddressReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBytes(m.MacAddress[:], 6) + return buf.Bytes(), nil +} +func (m *SwInterfaceGetMacAddressReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + copy(m.MacAddress[:], buf.DecodeBytes(6)) + return nil +} + +// Get VRF id assigned to interface +// - sw_if_index - index of the interface +// +// SwInterfaceGetTable defines message 'sw_interface_get_table'. +type SwInterfaceGetTable struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IsIPv6 bool `binapi:"bool,name=is_ipv6" json:"is_ipv6,omitempty"` +} + +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 +} + +func (m *SwInterfaceGetTable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.IsIPv6 + return size +} +func (m *SwInterfaceGetTable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.IsIPv6) + return buf.Bytes(), nil +} +func (m *SwInterfaceGetTable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsIPv6 = buf.DecodeBool() + return nil +} + +// Reply to get_sw_interface_vrf +// - vrf_id - VRF id assigned to the interface +// +// SwInterfaceGetTableReply defines message 'sw_interface_get_table_reply'. +type SwInterfaceGetTableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + VrfID uint32 `binapi:"u32,name=vrf_id" json:"vrf_id,omitempty"` +} + +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 +} + +func (m *SwInterfaceGetTableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.VrfID + return size +} +func (m *SwInterfaceGetTableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.VrfID) + return buf.Bytes(), nil +} +func (m *SwInterfaceGetTableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.VrfID = buf.DecodeUint32() + return nil +} + +// show the interface's queue - thread placement +// +// This api is used to display the interface and queue worker +// thread placement. One message per rx-queue per interface will +// be sent to client. +// Each message will contain information about rx-queue id of an +// interface, interface index, thread on which this rx-queue is +// placed and mode of rx-queue. +// - sw_if_index - the interface whose rx-placement will be dumped +// - queue_id - the queue id +// - worker_id - the worker id on which queue_id is placed, +// worker_id = 0 means main thread. +// - mode - polling=1, interrupt=2, adaptive=3 +// +// SwInterfaceRxPlacementDetails defines message 'sw_interface_rx_placement_details'. +type SwInterfaceRxPlacementDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + QueueID uint32 `binapi:"u32,name=queue_id" json:"queue_id,omitempty"` + WorkerID uint32 `binapi:"u32,name=worker_id" json:"worker_id,omitempty"` + Mode interface_types.RxMode `binapi:"rx_mode,name=mode" json:"mode,omitempty"` +} + +func (m *SwInterfaceRxPlacementDetails) Reset() { *m = SwInterfaceRxPlacementDetails{} } +func (*SwInterfaceRxPlacementDetails) GetMessageName() string { + return "sw_interface_rx_placement_details" +} +func (*SwInterfaceRxPlacementDetails) GetCrcString() string { return "9e44a7ce" } +func (*SwInterfaceRxPlacementDetails) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceRxPlacementDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.QueueID + size += 4 // m.WorkerID + size += 4 // m.Mode + return size +} +func (m *SwInterfaceRxPlacementDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.QueueID) + buf.EncodeUint32(m.WorkerID) + buf.EncodeUint32(uint32(m.Mode)) + return buf.Bytes(), nil +} +func (m *SwInterfaceRxPlacementDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.QueueID = buf.DecodeUint32() + m.WorkerID = buf.DecodeUint32() + m.Mode = interface_types.RxMode(buf.DecodeUint32()) + return nil +} + +// dump the rx queue placement of interface(s) +// - sw_if_index - optional interface index for which queue placement to +// be requested. sw_if_index = ~0 will dump placement information for all +// interfaces. It will not dump information related to sub-interfaces, p2p +// and pipe interfaces. +// +// SwInterfaceRxPlacementDump defines message 'sw_interface_rx_placement_dump'. +type SwInterfaceRxPlacementDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *SwInterfaceRxPlacementDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *SwInterfaceRxPlacementDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *SwInterfaceRxPlacementDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Set flags on the interface +// - sw_if_index - index of the interface to set flags on +// - flags - interface_status flags +// (only IF_STATUS_API_FLAG_ADMIN_UP used in config) +// +// SwInterfaceSetFlags defines message 'sw_interface_set_flags'. +type SwInterfaceSetFlags struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Flags interface_types.IfStatusFlags `binapi:"if_status_flags,name=flags" json:"flags,omitempty"` +} + +func (m *SwInterfaceSetFlags) Reset() { *m = SwInterfaceSetFlags{} } +func (*SwInterfaceSetFlags) GetMessageName() string { return "sw_interface_set_flags" } +func (*SwInterfaceSetFlags) GetCrcString() string { return "f5aec1b8" } +func (*SwInterfaceSetFlags) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSetFlags) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.Flags + return size +} +func (m *SwInterfaceSetFlags) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(uint32(m.Flags)) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetFlags) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Flags = interface_types.IfStatusFlags(buf.DecodeUint32()) + return nil +} + +// SwInterfaceSetFlagsReply defines message 'sw_interface_set_flags_reply'. +type SwInterfaceSetFlagsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetFlagsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetFlagsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetFlagsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set custom interface name +// +// Set custom interface name for the interface. +// - sw_if_index - the interface whose name will be set +// - name - the custom interface name to be set +// +// k +// SwInterfaceSetInterfaceName defines message 'sw_interface_set_interface_name'. +type SwInterfaceSetInterfaceName struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Name string `binapi:"string[64],name=name" json:"name,omitempty"` +} + +func (m *SwInterfaceSetInterfaceName) Reset() { *m = SwInterfaceSetInterfaceName{} } +func (*SwInterfaceSetInterfaceName) GetMessageName() string { return "sw_interface_set_interface_name" } +func (*SwInterfaceSetInterfaceName) GetCrcString() string { return "45a1d548" } +func (*SwInterfaceSetInterfaceName) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSetInterfaceName) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 64 // m.Name + return size +} +func (m *SwInterfaceSetInterfaceName) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeString(m.Name, 64) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetInterfaceName) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Name = buf.DecodeString(64) + return nil +} + +// SwInterfaceSetInterfaceNameReply defines message 'sw_interface_set_interface_name_reply'. +type SwInterfaceSetInterfaceNameReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SwInterfaceSetInterfaceNameReply) Reset() { *m = SwInterfaceSetInterfaceNameReply{} } +func (*SwInterfaceSetInterfaceNameReply) GetMessageName() string { + return "sw_interface_set_interface_name_reply" +} +func (*SwInterfaceSetInterfaceNameReply) GetCrcString() string { return "e8d4e804" } +func (*SwInterfaceSetInterfaceNameReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwInterfaceSetInterfaceNameReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetInterfaceNameReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetInterfaceNameReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set IP4 directed broadcast +// +// The directed broadcast enabled a packet sent to the interface's +// subnet address will be broadcast on the interface +// - sw_if_index +// - enable +// +// SwInterfaceSetIPDirectedBroadcast defines message 'sw_interface_set_ip_directed_broadcast'. +type SwInterfaceSetIPDirectedBroadcast struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Enable bool `binapi:"bool,name=enable" json:"enable,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetIPDirectedBroadcast) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.Enable + return size +} +func (m *SwInterfaceSetIPDirectedBroadcast) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.Enable) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetIPDirectedBroadcast) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Enable = buf.DecodeBool() + return nil +} + +// SwInterfaceSetIPDirectedBroadcastReply defines message 'sw_interface_set_ip_directed_broadcast_reply'. +type SwInterfaceSetIPDirectedBroadcastReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetIPDirectedBroadcastReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetIPDirectedBroadcastReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetIPDirectedBroadcastReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set an interface's MAC address +// - sw_if_index - the interface whose MAC will be set +// - mac_addr - the new MAC address +// +// SwInterfaceSetMacAddress defines message 'sw_interface_set_mac_address'. +type SwInterfaceSetMacAddress struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + MacAddress ethernet_types.MacAddress `binapi:"mac_address,name=mac_address" json:"mac_address,omitempty"` +} + +func (m *SwInterfaceSetMacAddress) Reset() { *m = SwInterfaceSetMacAddress{} } +func (*SwInterfaceSetMacAddress) GetMessageName() string { return "sw_interface_set_mac_address" } +func (*SwInterfaceSetMacAddress) GetCrcString() string { return "c536e7eb" } +func (*SwInterfaceSetMacAddress) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSetMacAddress) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 * 6 // m.MacAddress + return size +} +func (m *SwInterfaceSetMacAddress) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBytes(m.MacAddress[:], 6) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetMacAddress) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + copy(m.MacAddress[:], buf.DecodeBytes(6)) + return nil +} + +// SwInterfaceSetMacAddressReply defines message 'sw_interface_set_mac_address_reply'. +type SwInterfaceSetMacAddressReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetMacAddressReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetMacAddressReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetMacAddressReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set interface L3 MTU +// SwInterfaceSetMtu defines message 'sw_interface_set_mtu'. +type SwInterfaceSetMtu struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Mtu []uint32 `binapi:"u32[4],name=mtu" json:"mtu,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetMtu) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 * 4 // m.Mtu + return size +} +func (m *SwInterfaceSetMtu) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + for i := 0; i < 4; i++ { + var x uint32 + if i < len(m.Mtu) { + x = uint32(m.Mtu[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *SwInterfaceSetMtu) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Mtu = make([]uint32, 4) + for i := 0; i < len(m.Mtu); i++ { + m.Mtu[i] = buf.DecodeUint32() + } + return nil +} + +// SwInterfaceSetMtuReply defines message 'sw_interface_set_mtu_reply'. +type SwInterfaceSetMtuReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetMtuReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetMtuReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetMtuReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set interface promiscuous mode +// - sw_if_index - index of the interface to set flags on +// - promisc_on - promiscuous mode is on ? +// +// SwInterfaceSetPromisc defines message 'sw_interface_set_promisc'. +type SwInterfaceSetPromisc struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + PromiscOn bool `binapi:"bool,name=promisc_on" json:"promisc_on,omitempty"` +} + +func (m *SwInterfaceSetPromisc) Reset() { *m = SwInterfaceSetPromisc{} } +func (*SwInterfaceSetPromisc) GetMessageName() string { return "sw_interface_set_promisc" } +func (*SwInterfaceSetPromisc) GetCrcString() string { return "d40860d4" } +func (*SwInterfaceSetPromisc) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSetPromisc) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.PromiscOn + return size +} +func (m *SwInterfaceSetPromisc) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.PromiscOn) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetPromisc) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.PromiscOn = buf.DecodeBool() + return nil +} + +// SwInterfaceSetPromiscReply defines message 'sw_interface_set_promisc_reply'. +type SwInterfaceSetPromiscReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SwInterfaceSetPromiscReply) Reset() { *m = SwInterfaceSetPromiscReply{} } +func (*SwInterfaceSetPromiscReply) GetMessageName() string { return "sw_interface_set_promisc_reply" } +func (*SwInterfaceSetPromiscReply) GetCrcString() string { return "e8d4e804" } +func (*SwInterfaceSetPromiscReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwInterfaceSetPromiscReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetPromiscReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetPromiscReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set an interface's rx-mode +// - sw_if_index - the interface whose rx-mode will be set +// - queue_id_valid - 1 = the queue_id field is valid. 0 means all +// queue_id's +// - queue_id - the queue number whose rx-mode will be set. Only valid +// if queue_id_valid is 1 +// - mode - polling=1, interrupt=2, adaptive=3 +// +// SwInterfaceSetRxMode defines message 'sw_interface_set_rx_mode'. +type SwInterfaceSetRxMode struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + QueueIDValid bool `binapi:"bool,name=queue_id_valid" json:"queue_id_valid,omitempty"` + QueueID uint32 `binapi:"u32,name=queue_id" json:"queue_id,omitempty"` + Mode interface_types.RxMode `binapi:"rx_mode,name=mode" json:"mode,omitempty"` +} + +func (m *SwInterfaceSetRxMode) Reset() { *m = SwInterfaceSetRxMode{} } +func (*SwInterfaceSetRxMode) GetMessageName() string { return "sw_interface_set_rx_mode" } +func (*SwInterfaceSetRxMode) GetCrcString() string { return "b04d1cfe" } +func (*SwInterfaceSetRxMode) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSetRxMode) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.QueueIDValid + size += 4 // m.QueueID + size += 4 // m.Mode + return size +} +func (m *SwInterfaceSetRxMode) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.QueueIDValid) + buf.EncodeUint32(m.QueueID) + buf.EncodeUint32(uint32(m.Mode)) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetRxMode) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.QueueIDValid = buf.DecodeBool() + m.QueueID = buf.DecodeUint32() + m.Mode = interface_types.RxMode(buf.DecodeUint32()) + return nil +} + +// SwInterfaceSetRxModeReply defines message 'sw_interface_set_rx_mode_reply'. +type SwInterfaceSetRxModeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetRxModeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetRxModeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetRxModeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set an interface's rx-placement +// +// Rx-Queue placement on specific thread is operational for only hardware +// interface. It will not set queue - thread placement for sub-interfaces, +// p2p and pipe interfaces. +// - sw_if_index - the interface whose rx-placement will be set +// - queue_id - the queue number whose rx-placement will be set. +// - worker_id - the worker number whom rx-placement will be at. +// - is_main - flag to set rx-placement to main thread +// +// SwInterfaceSetRxPlacement defines message 'sw_interface_set_rx_placement'. +type SwInterfaceSetRxPlacement struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + QueueID uint32 `binapi:"u32,name=queue_id" json:"queue_id,omitempty"` + WorkerID uint32 `binapi:"u32,name=worker_id" json:"worker_id,omitempty"` + IsMain bool `binapi:"bool,name=is_main" json:"is_main,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetRxPlacement) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.QueueID + size += 4 // m.WorkerID + size += 1 // m.IsMain + return size +} +func (m *SwInterfaceSetRxPlacement) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.QueueID) + buf.EncodeUint32(m.WorkerID) + buf.EncodeBool(m.IsMain) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetRxPlacement) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.QueueID = buf.DecodeUint32() + m.WorkerID = buf.DecodeUint32() + m.IsMain = buf.DecodeBool() + return nil +} + +// SwInterfaceSetRxPlacementReply defines message 'sw_interface_set_rx_placement_reply'. +type SwInterfaceSetRxPlacementReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetRxPlacementReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetRxPlacementReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetRxPlacementReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Associate the specified interface with a fib table +// - sw_if_index - index of the interface +// - is_ipv6 - if non-zero ipv6, else ipv4 +// - vrf_id - fib table/vrf id to associate the interface with +// +// SwInterfaceSetTable defines message 'sw_interface_set_table'. +type SwInterfaceSetTable struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IsIPv6 bool `binapi:"bool,name=is_ipv6" json:"is_ipv6,omitempty"` + VrfID uint32 `binapi:"u32,name=vrf_id" json:"vrf_id,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetTable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.IsIPv6 + size += 4 // m.VrfID + return size +} +func (m *SwInterfaceSetTable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.IsIPv6) + buf.EncodeUint32(m.VrfID) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetTable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsIPv6 = buf.DecodeBool() + m.VrfID = buf.DecodeUint32() + return nil +} + +// SwInterfaceSetTableReply defines message 'sw_interface_set_table_reply'. +type SwInterfaceSetTableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetTableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetTableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetTableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set an interface's tx-placement +// +// Tx-Queue placement on specific thread is operational for only hardware +// interface. It will not set queue - thread placement for sub-interfaces, +// p2p and pipe interfaces. +// - sw_if_index - the interface whose tx-placement will be set +// - queue_id - the queue number whose tx-placement will be set. +// - array_size - the size of the thread indexes array +// - threads - the thread indexes of main and worker(s) threads +// whom tx-placement will be at. +// +// SwInterfaceSetTxPlacement defines message 'sw_interface_set_tx_placement'. +type SwInterfaceSetTxPlacement struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + QueueID uint32 `binapi:"u32,name=queue_id" json:"queue_id,omitempty"` + ArraySize uint32 `binapi:"u32,name=array_size" json:"-"` + Threads []uint32 `binapi:"u32[array_size],name=threads" json:"threads,omitempty"` +} + +func (m *SwInterfaceSetTxPlacement) Reset() { *m = SwInterfaceSetTxPlacement{} } +func (*SwInterfaceSetTxPlacement) GetMessageName() string { return "sw_interface_set_tx_placement" } +func (*SwInterfaceSetTxPlacement) GetCrcString() string { return "4e0cd5ff" } +func (*SwInterfaceSetTxPlacement) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSetTxPlacement) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.QueueID + size += 4 // m.ArraySize + size += 4 * len(m.Threads) // m.Threads + return size +} +func (m *SwInterfaceSetTxPlacement) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.QueueID) + buf.EncodeUint32(uint32(len(m.Threads))) + for i := 0; i < len(m.Threads); i++ { + var x uint32 + if i < len(m.Threads) { + x = uint32(m.Threads[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *SwInterfaceSetTxPlacement) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.QueueID = buf.DecodeUint32() + m.ArraySize = buf.DecodeUint32() + m.Threads = make([]uint32, m.ArraySize) + for i := 0; i < len(m.Threads); i++ { + m.Threads[i] = buf.DecodeUint32() + } + return nil +} + +// SwInterfaceSetTxPlacementReply defines message 'sw_interface_set_tx_placement_reply'. +type SwInterfaceSetTxPlacementReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SwInterfaceSetTxPlacementReply) Reset() { *m = SwInterfaceSetTxPlacementReply{} } +func (*SwInterfaceSetTxPlacementReply) GetMessageName() string { + return "sw_interface_set_tx_placement_reply" +} +func (*SwInterfaceSetTxPlacementReply) GetCrcString() string { return "e8d4e804" } +func (*SwInterfaceSetTxPlacementReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwInterfaceSetTxPlacementReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetTxPlacementReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetTxPlacementReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set unnumbered interface add / del request +// - sw_if_index - interface with an IP address +// - unnumbered_sw_if_index - interface which will use the address +// - is_add - if non-zero set the association, else unset it +// +// SwInterfaceSetUnnumbered defines message 'sw_interface_set_unnumbered'. +type SwInterfaceSetUnnumbered struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + UnnumberedSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=unnumbered_sw_if_index" json:"unnumbered_sw_if_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` +} + +func (m *SwInterfaceSetUnnumbered) Reset() { *m = SwInterfaceSetUnnumbered{} } +func (*SwInterfaceSetUnnumbered) GetMessageName() string { return "sw_interface_set_unnumbered" } +func (*SwInterfaceSetUnnumbered) GetCrcString() string { return "154a6439" } +func (*SwInterfaceSetUnnumbered) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSetUnnumbered) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.UnnumberedSwIfIndex + size += 1 // m.IsAdd + return size +} +func (m *SwInterfaceSetUnnumbered) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(uint32(m.UnnumberedSwIfIndex)) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetUnnumbered) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.UnnumberedSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsAdd = buf.DecodeBool() + return nil +} + +// SwInterfaceSetUnnumberedReply defines message 'sw_interface_set_unnumbered_reply'. +type SwInterfaceSetUnnumberedReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetUnnumberedReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetUnnumberedReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetUnnumberedReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set / clear software interface tag +// - sw_if_index - the interface +// - add_del - 1 = add, 0 = delete +// - tag - an ascii tag +// +// SwInterfaceTagAddDel defines message 'sw_interface_tag_add_del'. +type SwInterfaceTagAddDel struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty"` +} + +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 +} + +func (m *SwInterfaceTagAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.SwIfIndex + size += 64 // m.Tag + return size +} +func (m *SwInterfaceTagAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeString(m.Tag, 64) + return buf.Bytes(), nil +} +func (m *SwInterfaceTagAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Tag = buf.DecodeString(64) + return nil +} + +// SwInterfaceTagAddDelReply defines message 'sw_interface_tag_add_del_reply'. +type SwInterfaceTagAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceTagAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceTagAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceTagAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// show the interface's queue - thread placement +// +// This api is used to display the interface and queue worker +// thread placement. One message per tx-queue per interface will +// be sent to client. +// Each message will contain information about tx-queue id of an +// interface, interface index, thread on which this tx-queue is +// placed and mode of tx-queue. +// - sw_if_index - the interface whose tx-placement will be dumped +// - queue_id - the queue id +// - shared - the queue is shared on other threads +// - array_size - the size of the threads array +// - threads - the main and worker(s) thread index(es) whom tx-placement are at. +// +// SwInterfaceTxPlacementDetails defines message 'sw_interface_tx_placement_details'. +type SwInterfaceTxPlacementDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + QueueID uint32 `binapi:"u32,name=queue_id" json:"queue_id,omitempty"` + Shared uint8 `binapi:"u8,name=shared" json:"shared,omitempty"` + ArraySize uint32 `binapi:"u32,name=array_size" json:"-"` + Threads []uint32 `binapi:"u32[array_size],name=threads" json:"threads,omitempty"` +} + +func (m *SwInterfaceTxPlacementDetails) Reset() { *m = SwInterfaceTxPlacementDetails{} } +func (*SwInterfaceTxPlacementDetails) GetMessageName() string { + return "sw_interface_tx_placement_details" +} +func (*SwInterfaceTxPlacementDetails) GetCrcString() string { return "00381a2e" } +func (*SwInterfaceTxPlacementDetails) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceTxPlacementDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.QueueID + size += 1 // m.Shared + size += 4 // m.ArraySize + size += 4 * len(m.Threads) // m.Threads + return size +} +func (m *SwInterfaceTxPlacementDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.QueueID) + buf.EncodeUint8(m.Shared) + buf.EncodeUint32(uint32(len(m.Threads))) + for i := 0; i < len(m.Threads); i++ { + var x uint32 + if i < len(m.Threads) { + x = uint32(m.Threads[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *SwInterfaceTxPlacementDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.QueueID = buf.DecodeUint32() + m.Shared = buf.DecodeUint8() + m.ArraySize = buf.DecodeUint32() + m.Threads = make([]uint32, m.ArraySize) + for i := 0; i < len(m.Threads); i++ { + m.Threads[i] = buf.DecodeUint32() + } + return nil +} + +// get the tx queue placement of interface(s) +// - cursor - optional, it allows client to continue a dump +// - sw_if_index - optional interface index for which queue placement to +// be requested. sw_if_index = ~0 will get the placement information for all +// interfaces. It will not get information related to sub-interfaces, p2p +// and pipe interfaces. +// +// SwInterfaceTxPlacementGet defines message 'sw_interface_tx_placement_get'. +type SwInterfaceTxPlacementGet struct { + Cursor uint32 `binapi:"u32,name=cursor" json:"cursor,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *SwInterfaceTxPlacementGet) Reset() { *m = SwInterfaceTxPlacementGet{} } +func (*SwInterfaceTxPlacementGet) GetMessageName() string { return "sw_interface_tx_placement_get" } +func (*SwInterfaceTxPlacementGet) GetCrcString() string { return "47250981" } +func (*SwInterfaceTxPlacementGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceTxPlacementGet) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Cursor + size += 4 // m.SwIfIndex + return size +} +func (m *SwInterfaceTxPlacementGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Cursor) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *SwInterfaceTxPlacementGet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Cursor = buf.DecodeUint32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// SwInterfaceTxPlacementGetReply defines message 'sw_interface_tx_placement_get_reply'. +type SwInterfaceTxPlacementGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Cursor uint32 `binapi:"u32,name=cursor" json:"cursor,omitempty"` +} + +func (m *SwInterfaceTxPlacementGetReply) Reset() { *m = SwInterfaceTxPlacementGetReply{} } +func (*SwInterfaceTxPlacementGetReply) GetMessageName() string { + return "sw_interface_tx_placement_get_reply" +} +func (*SwInterfaceTxPlacementGetReply) GetCrcString() string { return "53b48f5d" } +func (*SwInterfaceTxPlacementGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwInterfaceTxPlacementGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Cursor + return size +} +func (m *SwInterfaceTxPlacementGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.Cursor) + return buf.Bytes(), nil +} +func (m *SwInterfaceTxPlacementGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Cursor = buf.DecodeUint32() + return nil +} + +// Register for interface events +// - enable_disable - 1 => register for events, 0 => cancel registration +// - pid - sender's pid +// +// WantInterfaceEvents defines message 'want_interface_events'. +type WantInterfaceEvents struct { + EnableDisable uint32 `binapi:"u32,name=enable_disable" json:"enable_disable,omitempty"` + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` +} + +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 +} + +func (m *WantInterfaceEvents) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.EnableDisable + size += 4 // m.PID + return size +} +func (m *WantInterfaceEvents) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.EnableDisable) + buf.EncodeUint32(m.PID) + return buf.Bytes(), nil +} +func (m *WantInterfaceEvents) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EnableDisable = buf.DecodeUint32() + m.PID = buf.DecodeUint32() + return nil +} + +// WantInterfaceEventsReply defines message 'want_interface_events_reply'. +type WantInterfaceEventsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 (m *WantInterfaceEventsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *WantInterfaceEventsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *WantInterfaceEventsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_interfaces_binapi_init() } +func file_interfaces_binapi_init() { + api.RegisterMessage((*CollectDetailedInterfaceStats)(nil), "collect_detailed_interface_stats_5501adee") + api.RegisterMessage((*CollectDetailedInterfaceStatsReply)(nil), "collect_detailed_interface_stats_reply_e8d4e804") + api.RegisterMessage((*CreateLoopback)(nil), "create_loopback_42bb5d22") + api.RegisterMessage((*CreateLoopbackInstance)(nil), "create_loopback_instance_d36a3ee2") + api.RegisterMessage((*CreateLoopbackInstanceReply)(nil), "create_loopback_instance_reply_5383d31f") + api.RegisterMessage((*CreateLoopbackReply)(nil), "create_loopback_reply_5383d31f") + api.RegisterMessage((*CreateSubif)(nil), "create_subif_790ca755") + api.RegisterMessage((*CreateSubifReply)(nil), "create_subif_reply_5383d31f") + api.RegisterMessage((*CreateVlanSubif)(nil), "create_vlan_subif_af34ac8b") + api.RegisterMessage((*CreateVlanSubifReply)(nil), "create_vlan_subif_reply_5383d31f") + api.RegisterMessage((*DeleteLoopback)(nil), "delete_loopback_f9e6675e") + api.RegisterMessage((*DeleteLoopbackReply)(nil), "delete_loopback_reply_e8d4e804") + api.RegisterMessage((*DeleteSubif)(nil), "delete_subif_f9e6675e") + api.RegisterMessage((*DeleteSubifReply)(nil), "delete_subif_reply_e8d4e804") + api.RegisterMessage((*HwInterfaceSetMtu)(nil), "hw_interface_set_mtu_e6746899") + api.RegisterMessage((*HwInterfaceSetMtuReply)(nil), "hw_interface_set_mtu_reply_e8d4e804") + api.RegisterMessage((*InterfaceNameRenumber)(nil), "interface_name_renumber_2b8858b8") + api.RegisterMessage((*InterfaceNameRenumberReply)(nil), "interface_name_renumber_reply_e8d4e804") + api.RegisterMessage((*PcapTraceOff)(nil), "pcap_trace_off_51077d14") + api.RegisterMessage((*PcapTraceOffReply)(nil), "pcap_trace_off_reply_e8d4e804") + api.RegisterMessage((*PcapTraceOn)(nil), "pcap_trace_on_cb39e968") + api.RegisterMessage((*PcapTraceOnReply)(nil), "pcap_trace_on_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceAddDelAddress)(nil), "sw_interface_add_del_address_5463d73b") + api.RegisterMessage((*SwInterfaceAddDelAddressReply)(nil), "sw_interface_add_del_address_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceAddDelMacAddress)(nil), "sw_interface_add_del_mac_address_638bb9f4") + api.RegisterMessage((*SwInterfaceAddDelMacAddressReply)(nil), "sw_interface_add_del_mac_address_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceAddressReplaceBegin)(nil), "sw_interface_address_replace_begin_51077d14") + api.RegisterMessage((*SwInterfaceAddressReplaceBeginReply)(nil), "sw_interface_address_replace_begin_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceAddressReplaceEnd)(nil), "sw_interface_address_replace_end_51077d14") + api.RegisterMessage((*SwInterfaceAddressReplaceEndReply)(nil), "sw_interface_address_replace_end_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceClearStats)(nil), "sw_interface_clear_stats_f9e6675e") + api.RegisterMessage((*SwInterfaceClearStatsReply)(nil), "sw_interface_clear_stats_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceDetails)(nil), "sw_interface_details_6c221fc7") + api.RegisterMessage((*SwInterfaceDump)(nil), "sw_interface_dump_aa610c27") + api.RegisterMessage((*SwInterfaceEvent)(nil), "sw_interface_event_2d3d95a7") + api.RegisterMessage((*SwInterfaceGetMacAddress)(nil), "sw_interface_get_mac_address_f9e6675e") + api.RegisterMessage((*SwInterfaceGetMacAddressReply)(nil), "sw_interface_get_mac_address_reply_40ef2c08") + api.RegisterMessage((*SwInterfaceGetTable)(nil), "sw_interface_get_table_2d033de4") + api.RegisterMessage((*SwInterfaceGetTableReply)(nil), "sw_interface_get_table_reply_a6eb0109") + api.RegisterMessage((*SwInterfaceRxPlacementDetails)(nil), "sw_interface_rx_placement_details_9e44a7ce") + api.RegisterMessage((*SwInterfaceRxPlacementDump)(nil), "sw_interface_rx_placement_dump_f9e6675e") + api.RegisterMessage((*SwInterfaceSetFlags)(nil), "sw_interface_set_flags_f5aec1b8") + api.RegisterMessage((*SwInterfaceSetFlagsReply)(nil), "sw_interface_set_flags_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceSetInterfaceName)(nil), "sw_interface_set_interface_name_45a1d548") + api.RegisterMessage((*SwInterfaceSetInterfaceNameReply)(nil), "sw_interface_set_interface_name_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceSetIPDirectedBroadcast)(nil), "sw_interface_set_ip_directed_broadcast_ae6cfcfb") + api.RegisterMessage((*SwInterfaceSetIPDirectedBroadcastReply)(nil), "sw_interface_set_ip_directed_broadcast_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceSetMacAddress)(nil), "sw_interface_set_mac_address_c536e7eb") + api.RegisterMessage((*SwInterfaceSetMacAddressReply)(nil), "sw_interface_set_mac_address_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceSetMtu)(nil), "sw_interface_set_mtu_5cbe85e5") + api.RegisterMessage((*SwInterfaceSetMtuReply)(nil), "sw_interface_set_mtu_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceSetPromisc)(nil), "sw_interface_set_promisc_d40860d4") + api.RegisterMessage((*SwInterfaceSetPromiscReply)(nil), "sw_interface_set_promisc_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceSetRxMode)(nil), "sw_interface_set_rx_mode_b04d1cfe") + api.RegisterMessage((*SwInterfaceSetRxModeReply)(nil), "sw_interface_set_rx_mode_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceSetRxPlacement)(nil), "sw_interface_set_rx_placement_db65f3c9") + api.RegisterMessage((*SwInterfaceSetRxPlacementReply)(nil), "sw_interface_set_rx_placement_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceSetTable)(nil), "sw_interface_set_table_df42a577") + api.RegisterMessage((*SwInterfaceSetTableReply)(nil), "sw_interface_set_table_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceSetTxPlacement)(nil), "sw_interface_set_tx_placement_4e0cd5ff") + api.RegisterMessage((*SwInterfaceSetTxPlacementReply)(nil), "sw_interface_set_tx_placement_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceSetUnnumbered)(nil), "sw_interface_set_unnumbered_154a6439") + api.RegisterMessage((*SwInterfaceSetUnnumberedReply)(nil), "sw_interface_set_unnumbered_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceTagAddDel)(nil), "sw_interface_tag_add_del_426f8bc1") + api.RegisterMessage((*SwInterfaceTagAddDelReply)(nil), "sw_interface_tag_add_del_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceTxPlacementDetails)(nil), "sw_interface_tx_placement_details_00381a2e") + api.RegisterMessage((*SwInterfaceTxPlacementGet)(nil), "sw_interface_tx_placement_get_47250981") + api.RegisterMessage((*SwInterfaceTxPlacementGetReply)(nil), "sw_interface_tx_placement_get_reply_53b48f5d") + api.RegisterMessage((*WantInterfaceEvents)(nil), "want_interface_events_476f5a08") + api.RegisterMessage((*WantInterfaceEventsReply)(nil), "want_interface_events_reply_e8d4e804") +} + +// 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), + (*PcapTraceOff)(nil), + (*PcapTraceOffReply)(nil), + (*PcapTraceOn)(nil), + (*PcapTraceOnReply)(nil), + (*SwInterfaceAddDelAddress)(nil), + (*SwInterfaceAddDelAddressReply)(nil), + (*SwInterfaceAddDelMacAddress)(nil), + (*SwInterfaceAddDelMacAddressReply)(nil), + (*SwInterfaceAddressReplaceBegin)(nil), + (*SwInterfaceAddressReplaceBeginReply)(nil), + (*SwInterfaceAddressReplaceEnd)(nil), + (*SwInterfaceAddressReplaceEndReply)(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), + (*SwInterfaceSetInterfaceName)(nil), + (*SwInterfaceSetInterfaceNameReply)(nil), + (*SwInterfaceSetIPDirectedBroadcast)(nil), + (*SwInterfaceSetIPDirectedBroadcastReply)(nil), + (*SwInterfaceSetMacAddress)(nil), + (*SwInterfaceSetMacAddressReply)(nil), + (*SwInterfaceSetMtu)(nil), + (*SwInterfaceSetMtuReply)(nil), + (*SwInterfaceSetPromisc)(nil), + (*SwInterfaceSetPromiscReply)(nil), + (*SwInterfaceSetRxMode)(nil), + (*SwInterfaceSetRxModeReply)(nil), + (*SwInterfaceSetRxPlacement)(nil), + (*SwInterfaceSetRxPlacementReply)(nil), + (*SwInterfaceSetTable)(nil), + (*SwInterfaceSetTableReply)(nil), + (*SwInterfaceSetTxPlacement)(nil), + (*SwInterfaceSetTxPlacementReply)(nil), + (*SwInterfaceSetUnnumbered)(nil), + (*SwInterfaceSetUnnumberedReply)(nil), + (*SwInterfaceTagAddDel)(nil), + (*SwInterfaceTagAddDelReply)(nil), + (*SwInterfaceTxPlacementDetails)(nil), + (*SwInterfaceTxPlacementGet)(nil), + (*SwInterfaceTxPlacementGetReply)(nil), + (*WantInterfaceEvents)(nil), + (*WantInterfaceEventsReply)(nil), + } +} diff --git a/binapi/interface/interface_rpc.ba.go b/binapi/interface/interface_rpc.ba.go new file mode 100644 index 00000000..f6a56ba0 --- /dev/null +++ b/binapi/interface/interface_rpc.ba.go @@ -0,0 +1,466 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package interfaces + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service interface. +type RPCService interface { + 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) + PcapTraceOff(ctx context.Context, in *PcapTraceOff) (*PcapTraceOffReply, error) + PcapTraceOn(ctx context.Context, in *PcapTraceOn) (*PcapTraceOnReply, error) + SwInterfaceAddDelAddress(ctx context.Context, in *SwInterfaceAddDelAddress) (*SwInterfaceAddDelAddressReply, error) + SwInterfaceAddDelMacAddress(ctx context.Context, in *SwInterfaceAddDelMacAddress) (*SwInterfaceAddDelMacAddressReply, error) + SwInterfaceAddressReplaceBegin(ctx context.Context, in *SwInterfaceAddressReplaceBegin) (*SwInterfaceAddressReplaceBeginReply, error) + SwInterfaceAddressReplaceEnd(ctx context.Context, in *SwInterfaceAddressReplaceEnd) (*SwInterfaceAddressReplaceEndReply, error) + SwInterfaceClearStats(ctx context.Context, in *SwInterfaceClearStats) (*SwInterfaceClearStatsReply, error) + SwInterfaceDump(ctx context.Context, in *SwInterfaceDump) (RPCService_SwInterfaceDumpClient, error) + SwInterfaceGetMacAddress(ctx context.Context, in *SwInterfaceGetMacAddress) (*SwInterfaceGetMacAddressReply, error) + SwInterfaceGetTable(ctx context.Context, in *SwInterfaceGetTable) (*SwInterfaceGetTableReply, error) + SwInterfaceRxPlacementDump(ctx context.Context, in *SwInterfaceRxPlacementDump) (RPCService_SwInterfaceRxPlacementDumpClient, error) + SwInterfaceSetFlags(ctx context.Context, in *SwInterfaceSetFlags) (*SwInterfaceSetFlagsReply, error) + SwInterfaceSetInterfaceName(ctx context.Context, in *SwInterfaceSetInterfaceName) (*SwInterfaceSetInterfaceNameReply, 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) + SwInterfaceSetPromisc(ctx context.Context, in *SwInterfaceSetPromisc) (*SwInterfaceSetPromiscReply, 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) + SwInterfaceSetTxPlacement(ctx context.Context, in *SwInterfaceSetTxPlacement) (*SwInterfaceSetTxPlacementReply, error) + SwInterfaceSetUnnumbered(ctx context.Context, in *SwInterfaceSetUnnumbered) (*SwInterfaceSetUnnumberedReply, error) + SwInterfaceTagAddDel(ctx context.Context, in *SwInterfaceTagAddDel) (*SwInterfaceTagAddDelReply, error) + SwInterfaceTxPlacementGet(ctx context.Context, in *SwInterfaceTxPlacementGet) (RPCService_SwInterfaceTxPlacementGetClient, error) + WantInterfaceEvents(ctx context.Context, in *WantInterfaceEvents) (*WantInterfaceEventsReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) CollectDetailedInterfaceStats(ctx context.Context, in *CollectDetailedInterfaceStats) (*CollectDetailedInterfaceStatsReply, error) { + out := new(CollectDetailedInterfaceStatsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) CreateLoopback(ctx context.Context, in *CreateLoopback) (*CreateLoopbackReply, error) { + out := new(CreateLoopbackReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) CreateLoopbackInstance(ctx context.Context, in *CreateLoopbackInstance) (*CreateLoopbackInstanceReply, error) { + out := new(CreateLoopbackInstanceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) CreateSubif(ctx context.Context, in *CreateSubif) (*CreateSubifReply, error) { + out := new(CreateSubifReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) CreateVlanSubif(ctx context.Context, in *CreateVlanSubif) (*CreateVlanSubifReply, error) { + out := new(CreateVlanSubifReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DeleteLoopback(ctx context.Context, in *DeleteLoopback) (*DeleteLoopbackReply, error) { + out := new(DeleteLoopbackReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) DeleteSubif(ctx context.Context, in *DeleteSubif) (*DeleteSubifReply, error) { + out := new(DeleteSubifReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) HwInterfaceSetMtu(ctx context.Context, in *HwInterfaceSetMtu) (*HwInterfaceSetMtuReply, error) { + out := new(HwInterfaceSetMtuReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) InterfaceNameRenumber(ctx context.Context, in *InterfaceNameRenumber) (*InterfaceNameRenumberReply, error) { + out := new(InterfaceNameRenumberReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PcapTraceOff(ctx context.Context, in *PcapTraceOff) (*PcapTraceOffReply, error) { + out := new(PcapTraceOffReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PcapTraceOn(ctx context.Context, in *PcapTraceOn) (*PcapTraceOnReply, error) { + out := new(PcapTraceOnReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceAddDelAddress(ctx context.Context, in *SwInterfaceAddDelAddress) (*SwInterfaceAddDelAddressReply, error) { + out := new(SwInterfaceAddDelAddressReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceAddDelMacAddress(ctx context.Context, in *SwInterfaceAddDelMacAddress) (*SwInterfaceAddDelMacAddressReply, error) { + out := new(SwInterfaceAddDelMacAddressReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceAddressReplaceBegin(ctx context.Context, in *SwInterfaceAddressReplaceBegin) (*SwInterfaceAddressReplaceBeginReply, error) { + out := new(SwInterfaceAddressReplaceBeginReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceAddressReplaceEnd(ctx context.Context, in *SwInterfaceAddressReplaceEnd) (*SwInterfaceAddressReplaceEndReply, error) { + out := new(SwInterfaceAddressReplaceEndReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceClearStats(ctx context.Context, in *SwInterfaceClearStats) (*SwInterfaceClearStatsReply, error) { + out := new(SwInterfaceClearStatsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceDump(ctx context.Context, in *SwInterfaceDump) (RPCService_SwInterfaceDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SwInterfaceDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SwInterfaceDumpClient interface { + Recv() (*SwInterfaceDetails, error) + api.Stream +} + +type serviceClient_SwInterfaceDumpClient struct { + api.Stream +} + +func (c *serviceClient_SwInterfaceDumpClient) Recv() (*SwInterfaceDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SwInterfaceDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) SwInterfaceGetMacAddress(ctx context.Context, in *SwInterfaceGetMacAddress) (*SwInterfaceGetMacAddressReply, error) { + out := new(SwInterfaceGetMacAddressReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceGetTable(ctx context.Context, in *SwInterfaceGetTable) (*SwInterfaceGetTableReply, error) { + out := new(SwInterfaceGetTableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceRxPlacementDump(ctx context.Context, in *SwInterfaceRxPlacementDump) (RPCService_SwInterfaceRxPlacementDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SwInterfaceRxPlacementDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SwInterfaceRxPlacementDumpClient interface { + Recv() (*SwInterfaceRxPlacementDetails, error) + api.Stream +} + +type serviceClient_SwInterfaceRxPlacementDumpClient struct { + api.Stream +} + +func (c *serviceClient_SwInterfaceRxPlacementDumpClient) Recv() (*SwInterfaceRxPlacementDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SwInterfaceRxPlacementDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) SwInterfaceSetFlags(ctx context.Context, in *SwInterfaceSetFlags) (*SwInterfaceSetFlagsReply, error) { + out := new(SwInterfaceSetFlagsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceSetInterfaceName(ctx context.Context, in *SwInterfaceSetInterfaceName) (*SwInterfaceSetInterfaceNameReply, error) { + out := new(SwInterfaceSetInterfaceNameReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceSetIPDirectedBroadcast(ctx context.Context, in *SwInterfaceSetIPDirectedBroadcast) (*SwInterfaceSetIPDirectedBroadcastReply, error) { + out := new(SwInterfaceSetIPDirectedBroadcastReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceSetMacAddress(ctx context.Context, in *SwInterfaceSetMacAddress) (*SwInterfaceSetMacAddressReply, error) { + out := new(SwInterfaceSetMacAddressReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceSetMtu(ctx context.Context, in *SwInterfaceSetMtu) (*SwInterfaceSetMtuReply, error) { + out := new(SwInterfaceSetMtuReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceSetPromisc(ctx context.Context, in *SwInterfaceSetPromisc) (*SwInterfaceSetPromiscReply, error) { + out := new(SwInterfaceSetPromiscReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceSetRxMode(ctx context.Context, in *SwInterfaceSetRxMode) (*SwInterfaceSetRxModeReply, error) { + out := new(SwInterfaceSetRxModeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceSetRxPlacement(ctx context.Context, in *SwInterfaceSetRxPlacement) (*SwInterfaceSetRxPlacementReply, error) { + out := new(SwInterfaceSetRxPlacementReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceSetTable(ctx context.Context, in *SwInterfaceSetTable) (*SwInterfaceSetTableReply, error) { + out := new(SwInterfaceSetTableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceSetTxPlacement(ctx context.Context, in *SwInterfaceSetTxPlacement) (*SwInterfaceSetTxPlacementReply, error) { + out := new(SwInterfaceSetTxPlacementReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceSetUnnumbered(ctx context.Context, in *SwInterfaceSetUnnumbered) (*SwInterfaceSetUnnumberedReply, error) { + out := new(SwInterfaceSetUnnumberedReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceTagAddDel(ctx context.Context, in *SwInterfaceTagAddDel) (*SwInterfaceTagAddDelReply, error) { + out := new(SwInterfaceTagAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceTxPlacementGet(ctx context.Context, in *SwInterfaceTxPlacementGet) (RPCService_SwInterfaceTxPlacementGetClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SwInterfaceTxPlacementGetClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SwInterfaceTxPlacementGetClient interface { + Recv() (*SwInterfaceTxPlacementDetails, *SwInterfaceTxPlacementGetReply, error) + api.Stream +} + +type serviceClient_SwInterfaceTxPlacementGetClient struct { + api.Stream +} + +func (c *serviceClient_SwInterfaceTxPlacementGetClient) Recv() (*SwInterfaceTxPlacementDetails, *SwInterfaceTxPlacementGetReply, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, nil, err + } + switch m := msg.(type) { + case *SwInterfaceTxPlacementDetails: + return m, nil, nil + case *SwInterfaceTxPlacementGetReply: + if err := api.RetvalToVPPApiError(m.Retval); err != nil { + return nil, m, err + } + err = c.Stream.Close() + if err != nil { + return nil, m, err + } + return nil, m, io.EOF + default: + return nil, nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) WantInterfaceEvents(ctx context.Context, in *WantInterfaceEvents) (*WantInterfaceEventsReply, error) { + out := new(WantInterfaceEventsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/interface_types/interface_types.ba.go b/binapi/interface_types/interface_types.ba.go new file mode 100644 index 00000000..ad01b212 --- /dev/null +++ b/binapi/interface_types/interface_types.ba.go @@ -0,0 +1,308 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/interface_types.api.json + +// Package interface_types contains generated bindings for API file interface_types.api. +// +// Contents: +// - 1 alias +// - 7 enums +package interface_types + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "interface_types" + APIVersion = "1.0.0" + VersionCrc = 0x7f2ba79a +) + +// Direction defines enum 'direction'. +type Direction uint8 + +const ( + RX Direction = 0 + TX Direction = 1 +) + +var ( + Direction_name = map[uint8]string{ + 0: "RX", + 1: "TX", + } + Direction_value = map[string]uint8{ + "RX": 0, + "TX": 1, + } +) + +func (x Direction) String() string { + s, ok := Direction_name[uint8(x)] + if ok { + return s + } + return "Direction(" + strconv.Itoa(int(x)) + ")" +} + +// IfStatusFlags defines 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", + } + 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 + } + str := func(n uint32) string { + s, ok := IfStatusFlags_name[uint32(n)] + if ok { + return s + } + return "IfStatusFlags(" + strconv.Itoa(int(n)) + ")" + } + for i := uint32(0); i <= 32; i++ { + val := uint32(x) + if val&(1< register for events, 0 => cancel registration +// - pid - sender's pid +// +// WantIP6RaEvents defines message 'want_ip6_ra_events'. +type WantIP6RaEvents struct { + Enable bool `binapi:"bool,name=enable" json:"enable,omitempty"` + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` +} + +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 +} + +func (m *WantIP6RaEvents) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Enable + size += 4 // m.PID + return size +} +func (m *WantIP6RaEvents) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.Enable) + buf.EncodeUint32(m.PID) + return buf.Bytes(), nil +} +func (m *WantIP6RaEvents) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Enable = buf.DecodeBool() + m.PID = buf.DecodeUint32() + return nil +} + +// WantIP6RaEventsReply defines message 'want_ip6_ra_events_reply'. +type WantIP6RaEventsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 (m *WantIP6RaEventsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *WantIP6RaEventsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *WantIP6RaEventsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_ip6_nd_binapi_init() } +func file_ip6_nd_binapi_init() { + api.RegisterMessage((*IP6RaEvent)(nil), "ip6_ra_event_0364c1c5") + api.RegisterMessage((*IP6ndProxyAddDel)(nil), "ip6nd_proxy_add_del_c2e4a686") + api.RegisterMessage((*IP6ndProxyAddDelReply)(nil), "ip6nd_proxy_add_del_reply_e8d4e804") + api.RegisterMessage((*IP6ndProxyDetails)(nil), "ip6nd_proxy_details_30b9ff4a") + api.RegisterMessage((*IP6ndProxyDump)(nil), "ip6nd_proxy_dump_51077d14") + api.RegisterMessage((*IP6ndProxyEnableDisable)(nil), "ip6nd_proxy_enable_disable_7daa1e3a") + api.RegisterMessage((*IP6ndProxyEnableDisableReply)(nil), "ip6nd_proxy_enable_disable_reply_e8d4e804") + api.RegisterMessage((*IP6ndSendRouterSolicitation)(nil), "ip6nd_send_router_solicitation_e5de609c") + api.RegisterMessage((*IP6ndSendRouterSolicitationReply)(nil), "ip6nd_send_router_solicitation_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceIP6ndRaConfig)(nil), "sw_interface_ip6nd_ra_config_3eb00b1c") + api.RegisterMessage((*SwInterfaceIP6ndRaConfigReply)(nil), "sw_interface_ip6nd_ra_config_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceIP6ndRaDetails)(nil), "sw_interface_ip6nd_ra_details_d3198de5") + api.RegisterMessage((*SwInterfaceIP6ndRaDump)(nil), "sw_interface_ip6nd_ra_dump_f9e6675e") + api.RegisterMessage((*SwInterfaceIP6ndRaPrefix)(nil), "sw_interface_ip6nd_ra_prefix_82cc1b28") + api.RegisterMessage((*SwInterfaceIP6ndRaPrefixReply)(nil), "sw_interface_ip6nd_ra_prefix_reply_e8d4e804") + api.RegisterMessage((*WantIP6RaEvents)(nil), "want_ip6_ra_events_3ec6d6c2") + api.RegisterMessage((*WantIP6RaEventsReply)(nil), "want_ip6_ra_events_reply_e8d4e804") +} + +// 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), + (*IP6ndProxyEnableDisable)(nil), + (*IP6ndProxyEnableDisableReply)(nil), + (*IP6ndSendRouterSolicitation)(nil), + (*IP6ndSendRouterSolicitationReply)(nil), + (*SwInterfaceIP6ndRaConfig)(nil), + (*SwInterfaceIP6ndRaConfigReply)(nil), + (*SwInterfaceIP6ndRaDetails)(nil), + (*SwInterfaceIP6ndRaDump)(nil), + (*SwInterfaceIP6ndRaPrefix)(nil), + (*SwInterfaceIP6ndRaPrefixReply)(nil), + (*WantIP6RaEvents)(nil), + (*WantIP6RaEventsReply)(nil), + } +} diff --git a/binapi/ip6_nd/ip6_nd_rpc.ba.go b/binapi/ip6_nd/ip6_nd_rpc.ba.go new file mode 100644 index 00000000..9a28c87a --- /dev/null +++ b/binapi/ip6_nd/ip6_nd_rpc.ba.go @@ -0,0 +1,172 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package ip6_nd + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service ip6_nd. +type RPCService interface { + IP6ndProxyAddDel(ctx context.Context, in *IP6ndProxyAddDel) (*IP6ndProxyAddDelReply, error) + IP6ndProxyDump(ctx context.Context, in *IP6ndProxyDump) (RPCService_IP6ndProxyDumpClient, error) + IP6ndProxyEnableDisable(ctx context.Context, in *IP6ndProxyEnableDisable) (*IP6ndProxyEnableDisableReply, error) + IP6ndSendRouterSolicitation(ctx context.Context, in *IP6ndSendRouterSolicitation) (*IP6ndSendRouterSolicitationReply, error) + SwInterfaceIP6ndRaConfig(ctx context.Context, in *SwInterfaceIP6ndRaConfig) (*SwInterfaceIP6ndRaConfigReply, error) + SwInterfaceIP6ndRaDump(ctx context.Context, in *SwInterfaceIP6ndRaDump) (RPCService_SwInterfaceIP6ndRaDumpClient, error) + SwInterfaceIP6ndRaPrefix(ctx context.Context, in *SwInterfaceIP6ndRaPrefix) (*SwInterfaceIP6ndRaPrefixReply, error) + WantIP6RaEvents(ctx context.Context, in *WantIP6RaEvents) (*WantIP6RaEventsReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) IP6ndProxyAddDel(ctx context.Context, in *IP6ndProxyAddDel) (*IP6ndProxyAddDelReply, error) { + out := new(IP6ndProxyAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IP6ndProxyDump(ctx context.Context, in *IP6ndProxyDump) (RPCService_IP6ndProxyDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IP6ndProxyDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IP6ndProxyDumpClient interface { + Recv() (*IP6ndProxyDetails, error) + api.Stream +} + +type serviceClient_IP6ndProxyDumpClient struct { + api.Stream +} + +func (c *serviceClient_IP6ndProxyDumpClient) Recv() (*IP6ndProxyDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IP6ndProxyDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IP6ndProxyEnableDisable(ctx context.Context, in *IP6ndProxyEnableDisable) (*IP6ndProxyEnableDisableReply, error) { + out := new(IP6ndProxyEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IP6ndSendRouterSolicitation(ctx context.Context, in *IP6ndSendRouterSolicitation) (*IP6ndSendRouterSolicitationReply, error) { + out := new(IP6ndSendRouterSolicitationReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceIP6ndRaConfig(ctx context.Context, in *SwInterfaceIP6ndRaConfig) (*SwInterfaceIP6ndRaConfigReply, error) { + out := new(SwInterfaceIP6ndRaConfigReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceIP6ndRaDump(ctx context.Context, in *SwInterfaceIP6ndRaDump) (RPCService_SwInterfaceIP6ndRaDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SwInterfaceIP6ndRaDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SwInterfaceIP6ndRaDumpClient interface { + Recv() (*SwInterfaceIP6ndRaDetails, error) + api.Stream +} + +type serviceClient_SwInterfaceIP6ndRaDumpClient struct { + api.Stream +} + +func (c *serviceClient_SwInterfaceIP6ndRaDumpClient) Recv() (*SwInterfaceIP6ndRaDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SwInterfaceIP6ndRaDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) SwInterfaceIP6ndRaPrefix(ctx context.Context, in *SwInterfaceIP6ndRaPrefix) (*SwInterfaceIP6ndRaPrefixReply, error) { + out := new(SwInterfaceIP6ndRaPrefixReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WantIP6RaEvents(ctx context.Context, in *WantIP6RaEvents) (*WantIP6RaEventsReply, error) { + out := new(WantIP6RaEventsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/ip_neighbor/ip_neighbor.ba.go b/binapi/ip_neighbor/ip_neighbor.ba.go new file mode 100644 index 00000000..44c195b6 --- /dev/null +++ b/binapi/ip_neighbor/ip_neighbor.ba.go @@ -0,0 +1,969 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/ip_neighbor.api.json + +// Package ip_neighbor contains generated bindings for API file ip_neighbor.api. +// +// Contents: +// - 2 enums +// - 1 struct +// - 18 messages +package ip_neighbor + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + ethernet_types "github.com/alkiranet/govpp/binapi/ethernet_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "ip_neighbor" + APIVersion = "1.0.0" + VersionCrc = 0xfde4a69a +) + +// IPNeighborEventFlags defines enum 'ip_neighbor_event_flags'. +type IPNeighborEventFlags uint32 + +const ( + IP_NEIGHBOR_API_EVENT_FLAG_ADDED IPNeighborEventFlags = 1 + IP_NEIGHBOR_API_EVENT_FLAG_REMOVED IPNeighborEventFlags = 2 +) + +var ( + IPNeighborEventFlags_name = map[uint32]string{ + 1: "IP_NEIGHBOR_API_EVENT_FLAG_ADDED", + 2: "IP_NEIGHBOR_API_EVENT_FLAG_REMOVED", + } + IPNeighborEventFlags_value = map[string]uint32{ + "IP_NEIGHBOR_API_EVENT_FLAG_ADDED": 1, + "IP_NEIGHBOR_API_EVENT_FLAG_REMOVED": 2, + } +) + +func (x IPNeighborEventFlags) String() string { + s, ok := IPNeighborEventFlags_name[uint32(x)] + if ok { + return s + } + str := func(n uint32) string { + s, ok := IPNeighborEventFlags_name[uint32(n)] + if ok { + return s + } + return "IPNeighborEventFlags(" + strconv.Itoa(int(n)) + ")" + } + for i := uint32(0); i <= 32; i++ { + val := uint32(x) + if val&(1< never +// - recycle - If max_number of neighbours is reached and new ones need +// to be created should the oldest neighbour be 'recycled'. +// +// IPNeighborConfig defines message 'ip_neighbor_config'. +type IPNeighborConfig struct { + Af ip_types.AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` + MaxNumber uint32 `binapi:"u32,name=max_number" json:"max_number,omitempty"` + MaxAge uint32 `binapi:"u32,name=max_age" json:"max_age,omitempty"` + Recycle bool `binapi:"bool,name=recycle" json:"recycle,omitempty"` +} + +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 +} + +func (m *IPNeighborConfig) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Af + size += 4 // m.MaxNumber + size += 4 // m.MaxAge + size += 1 // m.Recycle + return size +} +func (m *IPNeighborConfig) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Af)) + buf.EncodeUint32(m.MaxNumber) + buf.EncodeUint32(m.MaxAge) + buf.EncodeBool(m.Recycle) + return buf.Bytes(), nil +} +func (m *IPNeighborConfig) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Af = ip_types.AddressFamily(buf.DecodeUint8()) + m.MaxNumber = buf.DecodeUint32() + m.MaxAge = buf.DecodeUint32() + m.Recycle = buf.DecodeBool() + return nil +} + +// IPNeighborConfigReply defines message 'ip_neighbor_config_reply'. +type IPNeighborConfigReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *IPNeighborConfigReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IPNeighborConfigReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IPNeighborConfigReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IP neighbors dump response +// - age - time between last update and sending this message, in seconds +// - neighbour - the neighbor +// +// IPNeighborDetails defines message 'ip_neighbor_details'. +type IPNeighborDetails struct { + Age float64 `binapi:"f64,name=age" json:"age,omitempty"` + Neighbor IPNeighbor `binapi:"ip_neighbor,name=neighbor" json:"neighbor,omitempty"` +} + +func (m *IPNeighborDetails) Reset() { *m = IPNeighborDetails{} } +func (*IPNeighborDetails) GetMessageName() string { return "ip_neighbor_details" } +func (*IPNeighborDetails) GetCrcString() string { return "e29d79f0" } +func (*IPNeighborDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPNeighborDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 8 // m.Age + size += 4 // m.Neighbor.SwIfIndex + size += 1 // m.Neighbor.Flags + size += 1 * 6 // m.Neighbor.MacAddress + size += 1 // m.Neighbor.IPAddress.Af + size += 1 * 16 // m.Neighbor.IPAddress.Un + return size +} +func (m *IPNeighborDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeFloat64(m.Age) + buf.EncodeUint32(uint32(m.Neighbor.SwIfIndex)) + buf.EncodeUint8(uint8(m.Neighbor.Flags)) + buf.EncodeBytes(m.Neighbor.MacAddress[:], 6) + buf.EncodeUint8(uint8(m.Neighbor.IPAddress.Af)) + buf.EncodeBytes(m.Neighbor.IPAddress.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *IPNeighborDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Age = buf.DecodeFloat64() + m.Neighbor.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Neighbor.Flags = IPNeighborFlags(buf.DecodeUint8()) + copy(m.Neighbor.MacAddress[:], buf.DecodeBytes(6)) + m.Neighbor.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Neighbor.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// Dump IP neighbors +// - sw_if_index - the interface to dump neighbors, ~0 == all +// - af - address family is ipv[6|4] +// +// IPNeighborDump defines message 'ip_neighbor_dump'. +type IPNeighborDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` + Af ip_types.AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` +} + +func (m *IPNeighborDump) Reset() { *m = IPNeighborDump{} } +func (*IPNeighborDump) GetMessageName() string { return "ip_neighbor_dump" } +func (*IPNeighborDump) GetCrcString() string { return "d817a484" } +func (*IPNeighborDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPNeighborDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.Af + return size +} +func (m *IPNeighborDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(uint8(m.Af)) + return buf.Bytes(), nil +} +func (m *IPNeighborDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Af = ip_types.AddressFamily(buf.DecodeUint8()) + return nil +} + +// Tell client about an IP4 ARP resolution event or +// +// MAC/IP info from ARP requests in L2 BDs +// - pid - client pid registered to receive notification +// - neighbor - new neighbor created +// +// IPNeighborEvent defines message 'ip_neighbor_event'. +// Deprecated: the message will be removed in the future versions +type IPNeighborEvent struct { + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` + Neighbor IPNeighbor `binapi:"ip_neighbor,name=neighbor" json:"neighbor,omitempty"` +} + +func (m *IPNeighborEvent) Reset() { *m = IPNeighborEvent{} } +func (*IPNeighborEvent) GetMessageName() string { return "ip_neighbor_event" } +func (*IPNeighborEvent) GetCrcString() string { return "bdb092b2" } +func (*IPNeighborEvent) GetMessageType() api.MessageType { + return api.EventMessage +} + +func (m *IPNeighborEvent) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PID + size += 4 // m.Neighbor.SwIfIndex + size += 1 // m.Neighbor.Flags + size += 1 * 6 // m.Neighbor.MacAddress + size += 1 // m.Neighbor.IPAddress.Af + size += 1 * 16 // m.Neighbor.IPAddress.Un + return size +} +func (m *IPNeighborEvent) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PID) + buf.EncodeUint32(uint32(m.Neighbor.SwIfIndex)) + buf.EncodeUint8(uint8(m.Neighbor.Flags)) + buf.EncodeBytes(m.Neighbor.MacAddress[:], 6) + buf.EncodeUint8(uint8(m.Neighbor.IPAddress.Af)) + buf.EncodeBytes(m.Neighbor.IPAddress.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *IPNeighborEvent) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PID = buf.DecodeUint32() + m.Neighbor.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Neighbor.Flags = IPNeighborFlags(buf.DecodeUint8()) + copy(m.Neighbor.MacAddress[:], buf.DecodeBytes(6)) + m.Neighbor.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Neighbor.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// Tell client about an IP4 ARP resolution event or +// +// MAC/IP info from ARP requests in L2 BDs +// - pid - client pid registered to receive notification +// - flags - Flags +// - neighbor - neighbor +// +// IPNeighborEventV2 defines message 'ip_neighbor_event_v2'. +type IPNeighborEventV2 struct { + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` + Flags IPNeighborEventFlags `binapi:"ip_neighbor_event_flags,name=flags" json:"flags,omitempty"` + Neighbor IPNeighbor `binapi:"ip_neighbor,name=neighbor" json:"neighbor,omitempty"` +} + +func (m *IPNeighborEventV2) Reset() { *m = IPNeighborEventV2{} } +func (*IPNeighborEventV2) GetMessageName() string { return "ip_neighbor_event_v2" } +func (*IPNeighborEventV2) GetCrcString() string { return "c1d53dc0" } +func (*IPNeighborEventV2) GetMessageType() api.MessageType { + return api.EventMessage +} + +func (m *IPNeighborEventV2) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PID + size += 4 // m.Flags + size += 4 // m.Neighbor.SwIfIndex + size += 1 // m.Neighbor.Flags + size += 1 * 6 // m.Neighbor.MacAddress + size += 1 // m.Neighbor.IPAddress.Af + size += 1 * 16 // m.Neighbor.IPAddress.Un + return size +} +func (m *IPNeighborEventV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PID) + buf.EncodeUint32(uint32(m.Flags)) + buf.EncodeUint32(uint32(m.Neighbor.SwIfIndex)) + buf.EncodeUint8(uint8(m.Neighbor.Flags)) + buf.EncodeBytes(m.Neighbor.MacAddress[:], 6) + buf.EncodeUint8(uint8(m.Neighbor.IPAddress.Af)) + buf.EncodeBytes(m.Neighbor.IPAddress.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *IPNeighborEventV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PID = buf.DecodeUint32() + m.Flags = IPNeighborEventFlags(buf.DecodeUint32()) + m.Neighbor.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Neighbor.Flags = IPNeighborFlags(buf.DecodeUint8()) + copy(m.Neighbor.MacAddress[:], buf.DecodeBytes(6)) + m.Neighbor.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Neighbor.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// IP neighbor flush request - removes *all* neighbours. +// +// dynamic and static from API/CLI and dynamic from data-plane. +// - af - Flush neighbours of this address family +// - sw_if_index - Flush on this interface (~0 => all interfaces) +// +// IPNeighborFlush defines message 'ip_neighbor_flush'. +type IPNeighborFlush struct { + Af ip_types.AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` +} + +func (m *IPNeighborFlush) Reset() { *m = IPNeighborFlush{} } +func (*IPNeighborFlush) GetMessageName() string { return "ip_neighbor_flush" } +func (*IPNeighborFlush) GetCrcString() string { return "16aa35d2" } +func (*IPNeighborFlush) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPNeighborFlush) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Af + size += 4 // m.SwIfIndex + return size +} +func (m *IPNeighborFlush) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Af)) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *IPNeighborFlush) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Af = ip_types.AddressFamily(buf.DecodeUint8()) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// IPNeighborFlushReply defines message 'ip_neighbor_flush_reply'. +type IPNeighborFlushReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IPNeighborFlushReply) Reset() { *m = IPNeighborFlushReply{} } +func (*IPNeighborFlushReply) GetMessageName() string { return "ip_neighbor_flush_reply" } +func (*IPNeighborFlushReply) GetCrcString() string { return "e8d4e804" } +func (*IPNeighborFlushReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPNeighborFlushReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IPNeighborFlushReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IPNeighborFlushReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IP neighbour replace begin +// +// The use-case is that, for some unspecified reason, the control plane +// has a different set of neighbours it than VPP +// currently has. The CP would thus like to 'replace' VPP's set +// only by specifying what the new set shall be, i.e. it is not +// going to delete anything that already exists, rather, it wants any +// unspecified neighbors deleted implicitly. +// The CP declares the start of this procedure with this replace_begin +// API Call, and when it has populated all neighbours it wants, it calls +// the below replace_end API. From this point on it is of course free +// to add and delete neighbours as usual. +// The underlying mechanism by which VPP implements this replace is +// intentionally left unspecified. +// +// IPNeighborReplaceBegin defines message 'ip_neighbor_replace_begin'. +type IPNeighborReplaceBegin struct{} + +func (m *IPNeighborReplaceBegin) Reset() { *m = IPNeighborReplaceBegin{} } +func (*IPNeighborReplaceBegin) GetMessageName() string { return "ip_neighbor_replace_begin" } +func (*IPNeighborReplaceBegin) GetCrcString() string { return "51077d14" } +func (*IPNeighborReplaceBegin) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPNeighborReplaceBegin) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *IPNeighborReplaceBegin) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *IPNeighborReplaceBegin) Unmarshal(b []byte) error { + return nil +} + +// IPNeighborReplaceBeginReply defines message 'ip_neighbor_replace_begin_reply'. +type IPNeighborReplaceBeginReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IPNeighborReplaceBeginReply) Reset() { *m = IPNeighborReplaceBeginReply{} } +func (*IPNeighborReplaceBeginReply) GetMessageName() string { return "ip_neighbor_replace_begin_reply" } +func (*IPNeighborReplaceBeginReply) GetCrcString() string { return "e8d4e804" } +func (*IPNeighborReplaceBeginReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPNeighborReplaceBeginReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IPNeighborReplaceBeginReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IPNeighborReplaceBeginReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IP neighbour replace end +// +// see ip_neighbor_replace_begin description. +// +// IPNeighborReplaceEnd defines message 'ip_neighbor_replace_end'. +type IPNeighborReplaceEnd struct{} + +func (m *IPNeighborReplaceEnd) Reset() { *m = IPNeighborReplaceEnd{} } +func (*IPNeighborReplaceEnd) GetMessageName() string { return "ip_neighbor_replace_end" } +func (*IPNeighborReplaceEnd) GetCrcString() string { return "51077d14" } +func (*IPNeighborReplaceEnd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPNeighborReplaceEnd) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *IPNeighborReplaceEnd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *IPNeighborReplaceEnd) Unmarshal(b []byte) error { + return nil +} + +// IPNeighborReplaceEndReply defines message 'ip_neighbor_replace_end_reply'. +type IPNeighborReplaceEndReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IPNeighborReplaceEndReply) Reset() { *m = IPNeighborReplaceEndReply{} } +func (*IPNeighborReplaceEndReply) GetMessageName() string { return "ip_neighbor_replace_end_reply" } +func (*IPNeighborReplaceEndReply) GetCrcString() string { return "e8d4e804" } +func (*IPNeighborReplaceEndReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPNeighborReplaceEndReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IPNeighborReplaceEndReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IPNeighborReplaceEndReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Register for IP neighbour events creation +// - enable - 1 => register for events, 0 => cancel registration +// - pid - sender's pid +// - ip - exact IP address of interested neighbor resolution event +// - sw_if_index - interface on which the IP address is present. +// +// WantIPNeighborEvents defines message 'want_ip_neighbor_events'. +// Deprecated: the message will be removed in the future versions +type WantIPNeighborEvents struct { + Enable bool `binapi:"bool,name=enable" json:"enable,omitempty"` + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` + IP ip_types.Address `binapi:"address,name=ip" json:"ip,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` +} + +func (m *WantIPNeighborEvents) Reset() { *m = WantIPNeighborEvents{} } +func (*WantIPNeighborEvents) GetMessageName() string { return "want_ip_neighbor_events" } +func (*WantIPNeighborEvents) GetCrcString() string { return "73e70a86" } +func (*WantIPNeighborEvents) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *WantIPNeighborEvents) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Enable + size += 4 // m.PID + size += 1 // m.IP.Af + size += 1 * 16 // m.IP.Un + size += 4 // m.SwIfIndex + return size +} +func (m *WantIPNeighborEvents) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.Enable) + buf.EncodeUint32(m.PID) + buf.EncodeUint8(uint8(m.IP.Af)) + buf.EncodeBytes(m.IP.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *WantIPNeighborEvents) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Enable = buf.DecodeBool() + m.PID = buf.DecodeUint32() + m.IP.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IP.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// WantIPNeighborEventsReply defines message 'want_ip_neighbor_events_reply'. +// Deprecated: the message will be removed in the future versions +type WantIPNeighborEventsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 (m *WantIPNeighborEventsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *WantIPNeighborEventsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *WantIPNeighborEventsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Register for IP neighbour events (creation or deletion) +// - enable - 1 => register for events, 0 => cancel registration +// - pid - sender's pid +// - ip - exact IP address of interested neighbor resolution event +// - sw_if_index - interface on which the IP address is present. +// +// WantIPNeighborEventsV2 defines message 'want_ip_neighbor_events_v2'. +type WantIPNeighborEventsV2 struct { + Enable bool `binapi:"bool,name=enable" json:"enable,omitempty"` + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` + IP ip_types.Address `binapi:"address,name=ip" json:"ip,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` +} + +func (m *WantIPNeighborEventsV2) Reset() { *m = WantIPNeighborEventsV2{} } +func (*WantIPNeighborEventsV2) GetMessageName() string { return "want_ip_neighbor_events_v2" } +func (*WantIPNeighborEventsV2) GetCrcString() string { return "73e70a86" } +func (*WantIPNeighborEventsV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *WantIPNeighborEventsV2) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Enable + size += 4 // m.PID + size += 1 // m.IP.Af + size += 1 * 16 // m.IP.Un + size += 4 // m.SwIfIndex + return size +} +func (m *WantIPNeighborEventsV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.Enable) + buf.EncodeUint32(m.PID) + buf.EncodeUint8(uint8(m.IP.Af)) + buf.EncodeBytes(m.IP.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *WantIPNeighborEventsV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Enable = buf.DecodeBool() + m.PID = buf.DecodeUint32() + m.IP.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IP.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// WantIPNeighborEventsV2Reply defines message 'want_ip_neighbor_events_v2_reply'. +type WantIPNeighborEventsV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *WantIPNeighborEventsV2Reply) Reset() { *m = WantIPNeighborEventsV2Reply{} } +func (*WantIPNeighborEventsV2Reply) GetMessageName() string { + return "want_ip_neighbor_events_v2_reply" +} +func (*WantIPNeighborEventsV2Reply) GetCrcString() string { return "e8d4e804" } +func (*WantIPNeighborEventsV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *WantIPNeighborEventsV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *WantIPNeighborEventsV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *WantIPNeighborEventsV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_ip_neighbor_binapi_init() } +func file_ip_neighbor_binapi_init() { + api.RegisterMessage((*IPNeighborAddDel)(nil), "ip_neighbor_add_del_0607c257") + api.RegisterMessage((*IPNeighborAddDelReply)(nil), "ip_neighbor_add_del_reply_1992deab") + api.RegisterMessage((*IPNeighborConfig)(nil), "ip_neighbor_config_f4a5cf44") + api.RegisterMessage((*IPNeighborConfigReply)(nil), "ip_neighbor_config_reply_e8d4e804") + api.RegisterMessage((*IPNeighborDetails)(nil), "ip_neighbor_details_e29d79f0") + api.RegisterMessage((*IPNeighborDump)(nil), "ip_neighbor_dump_d817a484") + api.RegisterMessage((*IPNeighborEvent)(nil), "ip_neighbor_event_bdb092b2") + api.RegisterMessage((*IPNeighborEventV2)(nil), "ip_neighbor_event_v2_c1d53dc0") + api.RegisterMessage((*IPNeighborFlush)(nil), "ip_neighbor_flush_16aa35d2") + api.RegisterMessage((*IPNeighborFlushReply)(nil), "ip_neighbor_flush_reply_e8d4e804") + api.RegisterMessage((*IPNeighborReplaceBegin)(nil), "ip_neighbor_replace_begin_51077d14") + api.RegisterMessage((*IPNeighborReplaceBeginReply)(nil), "ip_neighbor_replace_begin_reply_e8d4e804") + api.RegisterMessage((*IPNeighborReplaceEnd)(nil), "ip_neighbor_replace_end_51077d14") + api.RegisterMessage((*IPNeighborReplaceEndReply)(nil), "ip_neighbor_replace_end_reply_e8d4e804") + api.RegisterMessage((*WantIPNeighborEvents)(nil), "want_ip_neighbor_events_73e70a86") + api.RegisterMessage((*WantIPNeighborEventsReply)(nil), "want_ip_neighbor_events_reply_e8d4e804") + api.RegisterMessage((*WantIPNeighborEventsV2)(nil), "want_ip_neighbor_events_v2_73e70a86") + api.RegisterMessage((*WantIPNeighborEventsV2Reply)(nil), "want_ip_neighbor_events_v2_reply_e8d4e804") +} + +// 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), + (*IPNeighborEventV2)(nil), + (*IPNeighborFlush)(nil), + (*IPNeighborFlushReply)(nil), + (*IPNeighborReplaceBegin)(nil), + (*IPNeighborReplaceBeginReply)(nil), + (*IPNeighborReplaceEnd)(nil), + (*IPNeighborReplaceEndReply)(nil), + (*WantIPNeighborEvents)(nil), + (*WantIPNeighborEventsReply)(nil), + (*WantIPNeighborEventsV2)(nil), + (*WantIPNeighborEventsV2Reply)(nil), + } +} diff --git a/binapi/ip_neighbor/ip_neighbor_rpc.ba.go b/binapi/ip_neighbor/ip_neighbor_rpc.ba.go new file mode 100644 index 00000000..fcd6d733 --- /dev/null +++ b/binapi/ip_neighbor/ip_neighbor_rpc.ba.go @@ -0,0 +1,138 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package ip_neighbor + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service ip_neighbor. +type RPCService interface { + IPNeighborAddDel(ctx context.Context, in *IPNeighborAddDel) (*IPNeighborAddDelReply, error) + IPNeighborConfig(ctx context.Context, in *IPNeighborConfig) (*IPNeighborConfigReply, error) + IPNeighborDump(ctx context.Context, in *IPNeighborDump) (RPCService_IPNeighborDumpClient, error) + IPNeighborFlush(ctx context.Context, in *IPNeighborFlush) (*IPNeighborFlushReply, error) + IPNeighborReplaceBegin(ctx context.Context, in *IPNeighborReplaceBegin) (*IPNeighborReplaceBeginReply, error) + IPNeighborReplaceEnd(ctx context.Context, in *IPNeighborReplaceEnd) (*IPNeighborReplaceEndReply, error) + WantIPNeighborEvents(ctx context.Context, in *WantIPNeighborEvents) (*WantIPNeighborEventsReply, error) + WantIPNeighborEventsV2(ctx context.Context, in *WantIPNeighborEventsV2) (*WantIPNeighborEventsV2Reply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) IPNeighborAddDel(ctx context.Context, in *IPNeighborAddDel) (*IPNeighborAddDelReply, error) { + out := new(IPNeighborAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IPNeighborConfig(ctx context.Context, in *IPNeighborConfig) (*IPNeighborConfigReply, error) { + out := new(IPNeighborConfigReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IPNeighborDump(ctx context.Context, in *IPNeighborDump) (RPCService_IPNeighborDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IPNeighborDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IPNeighborDumpClient interface { + Recv() (*IPNeighborDetails, error) + api.Stream +} + +type serviceClient_IPNeighborDumpClient struct { + api.Stream +} + +func (c *serviceClient_IPNeighborDumpClient) Recv() (*IPNeighborDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IPNeighborDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IPNeighborFlush(ctx context.Context, in *IPNeighborFlush) (*IPNeighborFlushReply, error) { + out := new(IPNeighborFlushReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IPNeighborReplaceBegin(ctx context.Context, in *IPNeighborReplaceBegin) (*IPNeighborReplaceBeginReply, error) { + out := new(IPNeighborReplaceBeginReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IPNeighborReplaceEnd(ctx context.Context, in *IPNeighborReplaceEnd) (*IPNeighborReplaceEndReply, error) { + out := new(IPNeighborReplaceEndReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WantIPNeighborEvents(ctx context.Context, in *WantIPNeighborEvents) (*WantIPNeighborEventsReply, error) { + out := new(WantIPNeighborEventsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WantIPNeighborEventsV2(ctx context.Context, in *WantIPNeighborEventsV2) (*WantIPNeighborEventsV2Reply, error) { + out := new(WantIPNeighborEventsV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/ip_session_redirect/ip_session_redirect.ba.go b/binapi/ip_session_redirect/ip_session_redirect.ba.go new file mode 100644 index 00000000..66b07a40 --- /dev/null +++ b/binapi/ip_session_redirect/ip_session_redirect.ba.go @@ -0,0 +1,486 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/ip_session_redirect.api.json + +// Package ip_session_redirect contains generated bindings for API file ip_session_redirect.api. +// +// Contents: +// - 6 messages +package ip_session_redirect + +import ( + api "github.com/alkiranet/govpp/api" + fib_types "github.com/alkiranet/govpp/binapi/fib_types" + _ "github.com/alkiranet/govpp/binapi/interface_types" + _ "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "ip_session_redirect" + APIVersion = "0.3.0" + VersionCrc = 0xf174f8ba +) + +// Add or update a session redirection +// - table_index - classifier table index +// - opaque_index - classifier session opaque index +// - match_len - classifier session match length in bytes (max is 80-bytes) +// - match - classifier session match +// - is_punt - true = punted traffic, false = forwarded traffic +// - n_paths - number of paths +// - paths - the paths of the redirect +// +// IPSessionRedirectAdd defines message 'ip_session_redirect_add'. +// Deprecated: the message will be removed in the future versions +type IPSessionRedirectAdd struct { + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` + MatchLen uint8 `binapi:"u8,name=match_len" json:"match_len,omitempty"` + Match []byte `binapi:"u8[80],name=match" json:"match,omitempty"` + OpaqueIndex uint32 `binapi:"u32,name=opaque_index,default=4294967295" json:"opaque_index,omitempty"` + IsPunt bool `binapi:"bool,name=is_punt" json:"is_punt,omitempty"` + NPaths uint8 `binapi:"u8,name=n_paths" json:"-"` + Paths []fib_types.FibPath `binapi:"fib_path[n_paths],name=paths" json:"paths,omitempty"` +} + +func (m *IPSessionRedirectAdd) Reset() { *m = IPSessionRedirectAdd{} } +func (*IPSessionRedirectAdd) GetMessageName() string { return "ip_session_redirect_add" } +func (*IPSessionRedirectAdd) GetCrcString() string { return "2f78ffda" } +func (*IPSessionRedirectAdd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPSessionRedirectAdd) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TableIndex + size += 1 // m.MatchLen + size += 1 * 80 // m.Match + size += 4 // m.OpaqueIndex + size += 1 // m.IsPunt + size += 1 // m.NPaths + for j1 := 0; j1 < len(m.Paths); j1++ { + var s1 fib_types.FibPath + _ = s1 + if j1 < len(m.Paths) { + s1 = m.Paths[j1] + } + size += 4 // s1.SwIfIndex + size += 4 // s1.TableID + size += 4 // s1.RpfID + size += 1 // s1.Weight + size += 1 // s1.Preference + size += 4 // s1.Type + size += 4 // s1.Flags + size += 4 // s1.Proto + size += 1 * 16 // s1.Nh.Address + size += 4 // s1.Nh.ViaLabel + size += 4 // s1.Nh.ObjID + size += 4 // s1.Nh.ClassifyTableIndex + size += 1 // s1.NLabels + for j2 := 0; j2 < 16; j2++ { + size += 1 // s1.LabelStack[j2].IsUniform + size += 4 // s1.LabelStack[j2].Label + size += 1 // s1.LabelStack[j2].TTL + size += 1 // s1.LabelStack[j2].Exp + } + } + return size +} +func (m *IPSessionRedirectAdd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TableIndex) + buf.EncodeUint8(m.MatchLen) + buf.EncodeBytes(m.Match, 80) + buf.EncodeUint32(m.OpaqueIndex) + buf.EncodeBool(m.IsPunt) + buf.EncodeUint8(uint8(len(m.Paths))) + for j0 := 0; j0 < len(m.Paths); j0++ { + var v0 fib_types.FibPath // Paths + if j0 < len(m.Paths) { + v0 = m.Paths[j0] + } + buf.EncodeUint32(v0.SwIfIndex) + buf.EncodeUint32(v0.TableID) + buf.EncodeUint32(v0.RpfID) + buf.EncodeUint8(v0.Weight) + buf.EncodeUint8(v0.Preference) + buf.EncodeUint32(uint32(v0.Type)) + buf.EncodeUint32(uint32(v0.Flags)) + buf.EncodeUint32(uint32(v0.Proto)) + buf.EncodeBytes(v0.Nh.Address.XXX_UnionData[:], 16) + buf.EncodeUint32(v0.Nh.ViaLabel) + buf.EncodeUint32(v0.Nh.ObjID) + buf.EncodeUint32(v0.Nh.ClassifyTableIndex) + buf.EncodeUint8(v0.NLabels) + for j1 := 0; j1 < 16; j1++ { + buf.EncodeUint8(v0.LabelStack[j1].IsUniform) + buf.EncodeUint32(v0.LabelStack[j1].Label) + buf.EncodeUint8(v0.LabelStack[j1].TTL) + buf.EncodeUint8(v0.LabelStack[j1].Exp) + } + } + return buf.Bytes(), nil +} +func (m *IPSessionRedirectAdd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TableIndex = buf.DecodeUint32() + m.MatchLen = buf.DecodeUint8() + m.Match = make([]byte, 80) + copy(m.Match, buf.DecodeBytes(len(m.Match))) + m.OpaqueIndex = buf.DecodeUint32() + m.IsPunt = buf.DecodeBool() + m.NPaths = buf.DecodeUint8() + m.Paths = make([]fib_types.FibPath, m.NPaths) + for j0 := 0; j0 < len(m.Paths); j0++ { + m.Paths[j0].SwIfIndex = buf.DecodeUint32() + m.Paths[j0].TableID = buf.DecodeUint32() + m.Paths[j0].RpfID = buf.DecodeUint32() + m.Paths[j0].Weight = buf.DecodeUint8() + m.Paths[j0].Preference = buf.DecodeUint8() + m.Paths[j0].Type = fib_types.FibPathType(buf.DecodeUint32()) + m.Paths[j0].Flags = fib_types.FibPathFlags(buf.DecodeUint32()) + m.Paths[j0].Proto = fib_types.FibPathNhProto(buf.DecodeUint32()) + copy(m.Paths[j0].Nh.Address.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Paths[j0].Nh.ViaLabel = buf.DecodeUint32() + m.Paths[j0].Nh.ObjID = buf.DecodeUint32() + m.Paths[j0].Nh.ClassifyTableIndex = buf.DecodeUint32() + m.Paths[j0].NLabels = buf.DecodeUint8() + for j1 := 0; j1 < 16; j1++ { + m.Paths[j0].LabelStack[j1].IsUniform = buf.DecodeUint8() + m.Paths[j0].LabelStack[j1].Label = buf.DecodeUint32() + m.Paths[j0].LabelStack[j1].TTL = buf.DecodeUint8() + m.Paths[j0].LabelStack[j1].Exp = buf.DecodeUint8() + } + } + return nil +} + +// IPSessionRedirectAddReply defines message 'ip_session_redirect_add_reply'. +// Deprecated: the message will be removed in the future versions +type IPSessionRedirectAddReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IPSessionRedirectAddReply) Reset() { *m = IPSessionRedirectAddReply{} } +func (*IPSessionRedirectAddReply) GetMessageName() string { return "ip_session_redirect_add_reply" } +func (*IPSessionRedirectAddReply) GetCrcString() string { return "e8d4e804" } +func (*IPSessionRedirectAddReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPSessionRedirectAddReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IPSessionRedirectAddReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IPSessionRedirectAddReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add or update a session redirection - version 2 +// - table_index - classifier table index +// - opaque_index - classifier session opaque index +// - proto - protocol of forwarded packets (default autodetect from path nh) +// - is_punt - true = punted traffic, false = forwarded traffic +// - match_len - classifier session match length in bytes (max is 80-bytes) +// - match - classifier session match +// - n_paths - number of paths +// - paths - the paths of the redirect +// +// IPSessionRedirectAddV2 defines message 'ip_session_redirect_add_v2'. +// InProgress: the message form may change in the future versions +type IPSessionRedirectAddV2 struct { + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` + OpaqueIndex uint32 `binapi:"u32,name=opaque_index,default=4294967295" json:"opaque_index,omitempty"` + Proto fib_types.FibPathNhProto `binapi:"fib_path_nh_proto,name=proto,default=4294967295" json:"proto,omitempty"` + IsPunt bool `binapi:"bool,name=is_punt" json:"is_punt,omitempty"` + MatchLen uint8 `binapi:"u8,name=match_len" json:"match_len,omitempty"` + Match []byte `binapi:"u8[80],name=match" json:"match,omitempty"` + NPaths uint8 `binapi:"u8,name=n_paths" json:"-"` + Paths []fib_types.FibPath `binapi:"fib_path[n_paths],name=paths" json:"paths,omitempty"` +} + +func (m *IPSessionRedirectAddV2) Reset() { *m = IPSessionRedirectAddV2{} } +func (*IPSessionRedirectAddV2) GetMessageName() string { return "ip_session_redirect_add_v2" } +func (*IPSessionRedirectAddV2) GetCrcString() string { return "0765f51f" } +func (*IPSessionRedirectAddV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPSessionRedirectAddV2) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TableIndex + size += 4 // m.OpaqueIndex + size += 4 // m.Proto + size += 1 // m.IsPunt + size += 1 // m.MatchLen + size += 1 * 80 // m.Match + size += 1 // m.NPaths + for j1 := 0; j1 < len(m.Paths); j1++ { + var s1 fib_types.FibPath + _ = s1 + if j1 < len(m.Paths) { + s1 = m.Paths[j1] + } + size += 4 // s1.SwIfIndex + size += 4 // s1.TableID + size += 4 // s1.RpfID + size += 1 // s1.Weight + size += 1 // s1.Preference + size += 4 // s1.Type + size += 4 // s1.Flags + size += 4 // s1.Proto + size += 1 * 16 // s1.Nh.Address + size += 4 // s1.Nh.ViaLabel + size += 4 // s1.Nh.ObjID + size += 4 // s1.Nh.ClassifyTableIndex + size += 1 // s1.NLabels + for j2 := 0; j2 < 16; j2++ { + size += 1 // s1.LabelStack[j2].IsUniform + size += 4 // s1.LabelStack[j2].Label + size += 1 // s1.LabelStack[j2].TTL + size += 1 // s1.LabelStack[j2].Exp + } + } + return size +} +func (m *IPSessionRedirectAddV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TableIndex) + buf.EncodeUint32(m.OpaqueIndex) + buf.EncodeUint32(uint32(m.Proto)) + buf.EncodeBool(m.IsPunt) + buf.EncodeUint8(m.MatchLen) + buf.EncodeBytes(m.Match, 80) + buf.EncodeUint8(uint8(len(m.Paths))) + for j0 := 0; j0 < len(m.Paths); j0++ { + var v0 fib_types.FibPath // Paths + if j0 < len(m.Paths) { + v0 = m.Paths[j0] + } + buf.EncodeUint32(v0.SwIfIndex) + buf.EncodeUint32(v0.TableID) + buf.EncodeUint32(v0.RpfID) + buf.EncodeUint8(v0.Weight) + buf.EncodeUint8(v0.Preference) + buf.EncodeUint32(uint32(v0.Type)) + buf.EncodeUint32(uint32(v0.Flags)) + buf.EncodeUint32(uint32(v0.Proto)) + buf.EncodeBytes(v0.Nh.Address.XXX_UnionData[:], 16) + buf.EncodeUint32(v0.Nh.ViaLabel) + buf.EncodeUint32(v0.Nh.ObjID) + buf.EncodeUint32(v0.Nh.ClassifyTableIndex) + buf.EncodeUint8(v0.NLabels) + for j1 := 0; j1 < 16; j1++ { + buf.EncodeUint8(v0.LabelStack[j1].IsUniform) + buf.EncodeUint32(v0.LabelStack[j1].Label) + buf.EncodeUint8(v0.LabelStack[j1].TTL) + buf.EncodeUint8(v0.LabelStack[j1].Exp) + } + } + return buf.Bytes(), nil +} +func (m *IPSessionRedirectAddV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TableIndex = buf.DecodeUint32() + m.OpaqueIndex = buf.DecodeUint32() + m.Proto = fib_types.FibPathNhProto(buf.DecodeUint32()) + m.IsPunt = buf.DecodeBool() + m.MatchLen = buf.DecodeUint8() + m.Match = make([]byte, 80) + copy(m.Match, buf.DecodeBytes(len(m.Match))) + m.NPaths = buf.DecodeUint8() + m.Paths = make([]fib_types.FibPath, m.NPaths) + for j0 := 0; j0 < len(m.Paths); j0++ { + m.Paths[j0].SwIfIndex = buf.DecodeUint32() + m.Paths[j0].TableID = buf.DecodeUint32() + m.Paths[j0].RpfID = buf.DecodeUint32() + m.Paths[j0].Weight = buf.DecodeUint8() + m.Paths[j0].Preference = buf.DecodeUint8() + m.Paths[j0].Type = fib_types.FibPathType(buf.DecodeUint32()) + m.Paths[j0].Flags = fib_types.FibPathFlags(buf.DecodeUint32()) + m.Paths[j0].Proto = fib_types.FibPathNhProto(buf.DecodeUint32()) + copy(m.Paths[j0].Nh.Address.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Paths[j0].Nh.ViaLabel = buf.DecodeUint32() + m.Paths[j0].Nh.ObjID = buf.DecodeUint32() + m.Paths[j0].Nh.ClassifyTableIndex = buf.DecodeUint32() + m.Paths[j0].NLabels = buf.DecodeUint8() + for j1 := 0; j1 < 16; j1++ { + m.Paths[j0].LabelStack[j1].IsUniform = buf.DecodeUint8() + m.Paths[j0].LabelStack[j1].Label = buf.DecodeUint32() + m.Paths[j0].LabelStack[j1].TTL = buf.DecodeUint8() + m.Paths[j0].LabelStack[j1].Exp = buf.DecodeUint8() + } + } + return nil +} + +// IPSessionRedirectAddV2Reply defines message 'ip_session_redirect_add_v2_reply'. +// InProgress: the message form may change in the future versions +type IPSessionRedirectAddV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IPSessionRedirectAddV2Reply) Reset() { *m = IPSessionRedirectAddV2Reply{} } +func (*IPSessionRedirectAddV2Reply) GetMessageName() string { + return "ip_session_redirect_add_v2_reply" +} +func (*IPSessionRedirectAddV2Reply) GetCrcString() string { return "e8d4e804" } +func (*IPSessionRedirectAddV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPSessionRedirectAddV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IPSessionRedirectAddV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IPSessionRedirectAddV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Delete a session redirection +// - table_index - classifier table index +// - match_len - classifier session match length in bytes (max is 80-bytes) +// - match - classifier session match +// +// IPSessionRedirectDel defines message 'ip_session_redirect_del'. +// InProgress: the message form may change in the future versions +type IPSessionRedirectDel struct { + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` + MatchLen uint8 `binapi:"u8,name=match_len" json:"-"` + Match []byte `binapi:"u8[match_len],name=match" json:"match,omitempty"` +} + +func (m *IPSessionRedirectDel) Reset() { *m = IPSessionRedirectDel{} } +func (*IPSessionRedirectDel) GetMessageName() string { return "ip_session_redirect_del" } +func (*IPSessionRedirectDel) GetCrcString() string { return "fb643388" } +func (*IPSessionRedirectDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPSessionRedirectDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TableIndex + size += 1 // m.MatchLen + size += 1 * len(m.Match) // m.Match + return size +} +func (m *IPSessionRedirectDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TableIndex) + buf.EncodeUint8(uint8(len(m.Match))) + buf.EncodeBytes(m.Match, 0) + return buf.Bytes(), nil +} +func (m *IPSessionRedirectDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TableIndex = buf.DecodeUint32() + m.MatchLen = buf.DecodeUint8() + m.Match = make([]byte, m.MatchLen) + copy(m.Match, buf.DecodeBytes(len(m.Match))) + return nil +} + +// IPSessionRedirectDelReply defines message 'ip_session_redirect_del_reply'. +// InProgress: the message form may change in the future versions +type IPSessionRedirectDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IPSessionRedirectDelReply) Reset() { *m = IPSessionRedirectDelReply{} } +func (*IPSessionRedirectDelReply) GetMessageName() string { return "ip_session_redirect_del_reply" } +func (*IPSessionRedirectDelReply) GetCrcString() string { return "e8d4e804" } +func (*IPSessionRedirectDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPSessionRedirectDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IPSessionRedirectDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IPSessionRedirectDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_ip_session_redirect_binapi_init() } +func file_ip_session_redirect_binapi_init() { + api.RegisterMessage((*IPSessionRedirectAdd)(nil), "ip_session_redirect_add_2f78ffda") + api.RegisterMessage((*IPSessionRedirectAddReply)(nil), "ip_session_redirect_add_reply_e8d4e804") + api.RegisterMessage((*IPSessionRedirectAddV2)(nil), "ip_session_redirect_add_v2_0765f51f") + api.RegisterMessage((*IPSessionRedirectAddV2Reply)(nil), "ip_session_redirect_add_v2_reply_e8d4e804") + api.RegisterMessage((*IPSessionRedirectDel)(nil), "ip_session_redirect_del_fb643388") + api.RegisterMessage((*IPSessionRedirectDelReply)(nil), "ip_session_redirect_del_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*IPSessionRedirectAdd)(nil), + (*IPSessionRedirectAddReply)(nil), + (*IPSessionRedirectAddV2)(nil), + (*IPSessionRedirectAddV2Reply)(nil), + (*IPSessionRedirectDel)(nil), + (*IPSessionRedirectDelReply)(nil), + } +} diff --git a/binapi/ip_session_redirect/ip_session_redirect_rpc.ba.go b/binapi/ip_session_redirect/ip_session_redirect_rpc.ba.go new file mode 100644 index 00000000..b1a0752e --- /dev/null +++ b/binapi/ip_session_redirect/ip_session_redirect_rpc.ba.go @@ -0,0 +1,51 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package ip_session_redirect + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service ip_session_redirect. +type RPCService interface { + IPSessionRedirectAdd(ctx context.Context, in *IPSessionRedirectAdd) (*IPSessionRedirectAddReply, error) + IPSessionRedirectAddV2(ctx context.Context, in *IPSessionRedirectAddV2) (*IPSessionRedirectAddV2Reply, error) + IPSessionRedirectDel(ctx context.Context, in *IPSessionRedirectDel) (*IPSessionRedirectDelReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) IPSessionRedirectAdd(ctx context.Context, in *IPSessionRedirectAdd) (*IPSessionRedirectAddReply, error) { + out := new(IPSessionRedirectAddReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IPSessionRedirectAddV2(ctx context.Context, in *IPSessionRedirectAddV2) (*IPSessionRedirectAddV2Reply, error) { + out := new(IPSessionRedirectAddV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IPSessionRedirectDel(ctx context.Context, in *IPSessionRedirectDel) (*IPSessionRedirectDelReply, error) { + out := new(IPSessionRedirectDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/ip_types/ip_types.ba.go b/binapi/ip_types/ip_types.ba.go new file mode 100644 index 00000000..5c8bcf68 --- /dev/null +++ b/binapi/ip_types/ip_types.ba.go @@ -0,0 +1,721 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/ip_types.api.json + +// Package ip_types contains generated bindings for API file ip_types.api. +// +// Contents: +// - 5 aliases +// - 5 enums +// - 8 structs +// - 1 union +package ip_types + +import ( + "fmt" + "net" + "strconv" + "strings" + + api "github.com/alkiranet/govpp/api" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "ip_types" + APIVersion = "3.0.0" + VersionCrc = 0xfee023ed +) + +// AddressFamily defines enum 'address_family'. +type AddressFamily uint8 + +const ( + ADDRESS_IP4 AddressFamily = 0 + ADDRESS_IP6 AddressFamily = 1 +) + +var ( + AddressFamily_name = map[uint8]string{ + 0: "ADDRESS_IP4", + 1: "ADDRESS_IP6", + } + AddressFamily_value = map[string]uint8{ + "ADDRESS_IP4": 0, + "ADDRESS_IP6": 1, + } +) + +func (x AddressFamily) String() string { + s, ok := AddressFamily_name[uint8(x)] + if ok { + return s + } + return "AddressFamily(" + strconv.Itoa(int(x)) + ")" +} + +// IPDscp defines 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", + } + 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 "IPDscp(" + strconv.Itoa(int(x)) + ")" +} + +// IPEcn defines 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", + } + 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 "IPEcn(" + strconv.Itoa(int(x)) + ")" +} + +// IPFeatureLocation defines enum 'ip_feature_location'. +type IPFeatureLocation uint8 + +const ( + IP_API_FEATURE_INPUT IPFeatureLocation = 0 + IP_API_FEATURE_OUTPUT IPFeatureLocation = 1 + IP_API_FEATURE_LOCAL IPFeatureLocation = 2 + IP_API_FEATURE_PUNT IPFeatureLocation = 3 + IP_API_FEATURE_DROP IPFeatureLocation = 4 +) + +var ( + IPFeatureLocation_name = map[uint8]string{ + 0: "IP_API_FEATURE_INPUT", + 1: "IP_API_FEATURE_OUTPUT", + 2: "IP_API_FEATURE_LOCAL", + 3: "IP_API_FEATURE_PUNT", + 4: "IP_API_FEATURE_DROP", + } + IPFeatureLocation_value = map[string]uint8{ + "IP_API_FEATURE_INPUT": 0, + "IP_API_FEATURE_OUTPUT": 1, + "IP_API_FEATURE_LOCAL": 2, + "IP_API_FEATURE_PUNT": 3, + "IP_API_FEATURE_DROP": 4, + } +) + +func (x IPFeatureLocation) String() string { + s, ok := IPFeatureLocation_name[uint8(x)] + if ok { + return s + } + return "IPFeatureLocation(" + strconv.Itoa(int(x)) + ")" +} + +// IPProto defines enum 'ip_proto'. +type IPProto uint8 + +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_ESP IPProto = 50 + IP_API_PROTO_AH IPProto = 51 + IP_API_PROTO_ICMP6 IPProto = 58 + 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[uint8]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_ESP", + 51: "IP_API_PROTO_AH", + 58: "IP_API_PROTO_ICMP6", + 88: "IP_API_PROTO_EIGRP", + 89: "IP_API_PROTO_OSPF", + 132: "IP_API_PROTO_SCTP", + 255: "IP_API_PROTO_RESERVED", + } + IPProto_value = map[string]uint8{ + "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_ESP": 50, + "IP_API_PROTO_AH": 51, + "IP_API_PROTO_ICMP6": 58, + "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[uint8(x)] + if ok { + return s + } + return "IPProto(" + strconv.Itoa(int(x)) + ")" +} + +// AddressWithPrefix defines alias 'address_with_prefix'. +type AddressWithPrefix Prefix + +func NewAddressWithPrefix(network net.IPNet) AddressWithPrefix { + prefix := NewPrefix(network) + return AddressWithPrefix(prefix) +} + +func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { + prefix, err := ParsePrefix(s) + if err != nil { + return AddressWithPrefix{}, err + } + return AddressWithPrefix(prefix), nil +} + +func (x AddressWithPrefix) ToIPNet() *net.IPNet { + return Prefix(x).ToIPNet() +} + +func (x AddressWithPrefix) String() string { + return Prefix(x).String() +} + +func (x *AddressWithPrefix) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +func (x *AddressWithPrefix) UnmarshalText(text []byte) error { + prefix, err := ParseAddressWithPrefix(string(text)) + if err != nil { + return err + } + *x = prefix + return nil +} + +// IP4Address defines alias 'ip4_address'. +type IP4Address [4]uint8 + +func NewIP4Address(ip net.IP) IP4Address { + var ipaddr IP4Address + copy(ipaddr[:], ip.To4()) + return ipaddr +} + +func ParseIP4Address(s string) (IP4Address, error) { + ip := net.ParseIP(s).To4() + if ip == nil { + return IP4Address{}, fmt.Errorf("invalid IP4 address: %s", s) + } + var ipaddr IP4Address + copy(ipaddr[:], ip.To4()) + return ipaddr, nil +} + +func (x IP4Address) ToIP() net.IP { + return net.IP(x[:]).To4() +} + +func (x IP4Address) String() string { + return x.ToIP().String() +} + +func (x *IP4Address) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +func (x *IP4Address) UnmarshalText(text []byte) error { + ipaddr, err := ParseIP4Address(string(text)) + if err != nil { + return err + } + *x = ipaddr + return nil +} + +// IP4AddressWithPrefix defines alias 'ip4_address_with_prefix'. +type IP4AddressWithPrefix IP4Prefix + +// IP6Address defines alias 'ip6_address'. +type IP6Address [16]uint8 + +func NewIP6Address(ip net.IP) IP6Address { + var ipaddr IP6Address + copy(ipaddr[:], ip.To16()) + return ipaddr +} + +func ParseIP6Address(s string) (IP6Address, error) { + ip := net.ParseIP(s).To16() + if ip == nil { + return IP6Address{}, fmt.Errorf("invalid IP6 address: %s", s) + } + var ipaddr IP6Address + copy(ipaddr[:], ip.To16()) + return ipaddr, nil +} + +func (x IP6Address) ToIP() net.IP { + return net.IP(x[:]).To16() +} + +func (x IP6Address) String() string { + return x.ToIP().String() +} + +func (x *IP6Address) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +func (x *IP6Address) UnmarshalText(text []byte) error { + ipaddr, err := ParseIP6Address(string(text)) + if err != nil { + return err + } + *x = ipaddr + return nil +} + +// IP6AddressWithPrefix defines alias 'ip6_address_with_prefix'. +type IP6AddressWithPrefix IP6Prefix + +// Address defines type 'address'. +type Address struct { + Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` + Un AddressUnion `binapi:"address_union,name=un" json:"un,omitempty"` +} + +func NewAddress(ip net.IP) Address { + var addr Address + if ip.To4() == nil { + addr.Af = ADDRESS_IP6 + var ip6 IP6Address + copy(ip6[:], ip.To16()) + addr.Un.SetIP6(ip6) + } else { + addr.Af = ADDRESS_IP4 + var ip4 IP4Address + copy(ip4[:], ip.To4()) + addr.Un.SetIP4(ip4) + } + return addr +} + +func ParseAddress(s string) (Address, error) { + ip := net.ParseIP(s) + if ip == nil { + return Address{}, fmt.Errorf("invalid IP address: %s", s) + } + return NewAddress(ip), nil +} + +func (x Address) ToIP() net.IP { + if x.Af == ADDRESS_IP6 { + ip6 := x.Un.GetIP6() + return net.IP(ip6[:]).To16() + } else { + ip4 := x.Un.GetIP4() + return net.IP(ip4[:]).To4() + } +} + +func (x Address) String() string { + return x.ToIP().String() +} + +func (x *Address) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +func (x *Address) UnmarshalText(text []byte) error { + addr, err := ParseAddress(string(text)) + if err != nil { + return err + } + *x = addr + return nil +} + +// IP4AddressAndMask defines type 'ip4_address_and_mask'. +type IP4AddressAndMask struct { + Addr IP4Address `binapi:"ip4_address,name=addr" json:"addr,omitempty"` + Mask IP4Address `binapi:"ip4_address,name=mask" json:"mask,omitempty"` +} + +// IP4Prefix defines type 'ip4_prefix'. +type IP4Prefix struct { + Address IP4Address `binapi:"ip4_address,name=address" json:"address,omitempty"` + Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` +} + +func NewIP4Prefix(network net.IPNet) IP4Prefix { + var prefix IP4Prefix + maskSize, _ := network.Mask.Size() + prefix.Len = byte(maskSize) + prefix.Address = NewIP4Address(network.IP) + return prefix +} + +func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { + hasPrefix := strings.Contains(s, "/") + if hasPrefix { + ip, network, err := net.ParseCIDR(s) + if err != nil { + return IP4Prefix{}, fmt.Errorf("invalid IP4 %s: %s", s, err) + } + maskSize, _ := network.Mask.Size() + prefix.Len = byte(maskSize) + prefix.Address, err = ParseIP4Address(ip.String()) + if err != nil { + return IP4Prefix{}, fmt.Errorf("invalid IP4 %s: %s", s, err) + } + } else { + ip := net.ParseIP(s) + defaultMaskSize, _ := net.CIDRMask(32, 32).Size() + if ip.To4() == nil { + defaultMaskSize, _ = net.CIDRMask(128, 128).Size() + } + prefix.Len = byte(defaultMaskSize) + prefix.Address, err = ParseIP4Address(ip.String()) + if err != nil { + return IP4Prefix{}, fmt.Errorf("invalid IP4 %s: %s", s, err) + } + } + return prefix, nil +} + +func (x IP4Prefix) ToIPNet() *net.IPNet { + mask := net.CIDRMask(int(x.Len), 32) + ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask} + return ipnet +} + +func (x IP4Prefix) String() string { + ip := x.Address.String() + return ip + "/" + strconv.Itoa(int(x.Len)) +} + +func (x *IP4Prefix) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +func (x *IP4Prefix) UnmarshalText(text []byte) error { + prefix, err := ParseIP4Prefix(string(text)) + if err != nil { + return err + } + *x = prefix + return nil +} + +// IP6AddressAndMask defines type 'ip6_address_and_mask'. +type IP6AddressAndMask struct { + Addr IP6Address `binapi:"ip6_address,name=addr" json:"addr,omitempty"` + Mask IP6Address `binapi:"ip6_address,name=mask" json:"mask,omitempty"` +} + +// IP6Prefix defines type 'ip6_prefix'. +type IP6Prefix struct { + Address IP6Address `binapi:"ip6_address,name=address" json:"address,omitempty"` + Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` +} + +func NewIP6Prefix(network net.IPNet) IP6Prefix { + var prefix IP6Prefix + maskSize, _ := network.Mask.Size() + prefix.Len = byte(maskSize) + prefix.Address = NewIP6Address(network.IP) + return prefix +} + +func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { + hasPrefix := strings.Contains(s, "/") + if hasPrefix { + ip, network, err := net.ParseCIDR(s) + if err != nil { + return IP6Prefix{}, fmt.Errorf("invalid IP6 %s: %s", s, err) + } + maskSize, _ := network.Mask.Size() + prefix.Len = byte(maskSize) + prefix.Address, err = ParseIP6Address(ip.String()) + if err != nil { + return IP6Prefix{}, fmt.Errorf("invalid IP6 %s: %s", s, err) + } + } else { + ip := net.ParseIP(s) + defaultMaskSize, _ := net.CIDRMask(32, 32).Size() + if ip.To4() == nil { + defaultMaskSize, _ = net.CIDRMask(128, 128).Size() + } + prefix.Len = byte(defaultMaskSize) + prefix.Address, err = ParseIP6Address(ip.String()) + if err != nil { + return IP6Prefix{}, fmt.Errorf("invalid IP6 %s: %s", s, err) + } + } + return prefix, nil +} + +func (x IP6Prefix) ToIPNet() *net.IPNet { + mask := net.CIDRMask(int(x.Len), 128) + ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask} + return ipnet +} + +func (x IP6Prefix) String() string { + ip := x.Address.String() + return ip + "/" + strconv.Itoa(int(x.Len)) +} + +func (x *IP6Prefix) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +func (x *IP6Prefix) UnmarshalText(text []byte) error { + prefix, err := ParseIP6Prefix(string(text)) + if err != nil { + return err + } + *x = prefix + return nil +} + +// Mprefix defines type 'mprefix'. +type Mprefix struct { + Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` + GrpAddressLength uint16 `binapi:"u16,name=grp_address_length" json:"grp_address_length,omitempty"` + GrpAddress AddressUnion `binapi:"address_union,name=grp_address" json:"grp_address,omitempty"` + SrcAddress AddressUnion `binapi:"address_union,name=src_address" json:"src_address,omitempty"` +} + +// Prefix defines type 'prefix'. +type Prefix struct { + Address Address `binapi:"address,name=address" json:"address,omitempty"` + Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` +} + +func NewPrefix(network net.IPNet) Prefix { + var prefix Prefix + maskSize, _ := network.Mask.Size() + prefix.Len = byte(maskSize) + prefix.Address = NewAddress(network.IP) + return prefix +} + +func ParsePrefix(ip string) (prefix Prefix, err error) { + hasPrefix := strings.Contains(ip, "/") + if hasPrefix { + netIP, network, err := net.ParseCIDR(ip) + if err != nil { + return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err) + } + maskSize, _ := network.Mask.Size() + prefix.Len = byte(maskSize) + prefix.Address, err = ParseAddress(netIP.String()) + if err != nil { + return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err) + } + } else { + netIP := net.ParseIP(ip) + defaultMaskSize, _ := net.CIDRMask(32, 32).Size() + if netIP.To4() == nil { + defaultMaskSize, _ = net.CIDRMask(128, 128).Size() + } + prefix.Len = byte(defaultMaskSize) + prefix.Address, err = ParseAddress(netIP.String()) + if err != nil { + return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err) + } + } + return prefix, nil +} + +func (x Prefix) ToIPNet() *net.IPNet { + var mask net.IPMask + if x.Address.Af == ADDRESS_IP4 { + mask = net.CIDRMask(int(x.Len), 32) + } else { + mask = net.CIDRMask(int(x.Len), 128) + } + ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask} + return ipnet +} + +func (x Prefix) String() string { + ip := x.Address.String() + return ip + "/" + strconv.Itoa(int(x.Len)) +} + +func (x *Prefix) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +func (x *Prefix) UnmarshalText(text []byte) error { + prefix, err := ParsePrefix(string(text)) + if err != nil { + return err + } + *x = prefix + return nil +} + +// PrefixMatcher defines type 'prefix_matcher'. +type PrefixMatcher struct { + Le uint8 `binapi:"u8,name=le" json:"le,omitempty"` + Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"` +} + +// AddressUnion defines union 'address_union'. +type AddressUnion struct { + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address + XXX_UnionData [16]byte +} + +func AddressUnionIP4(a IP4Address) (u AddressUnion) { + u.SetIP4(a) + return +} +func (u *AddressUnion) SetIP4(a IP4Address) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + buf.EncodeBytes(a[:], 4) +} +func (u *AddressUnion) GetIP4() (a IP4Address) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + copy(a[:], buf.DecodeBytes(4)) + return +} + +func AddressUnionIP6(a IP6Address) (u AddressUnion) { + u.SetIP6(a) + return +} +func (u *AddressUnion) SetIP6(a IP6Address) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + buf.EncodeBytes(a[:], 16) +} +func (u *AddressUnion) GetIP6() (a IP6Address) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + copy(a[:], buf.DecodeBytes(16)) + return +} diff --git a/binapi/ipfix_export/ipfix_export.ba.go b/binapi/ipfix_export/ipfix_export.ba.go new file mode 100644 index 00000000..f791ef32 --- /dev/null +++ b/binapi/ipfix_export/ipfix_export.ba.go @@ -0,0 +1,903 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/ipfix_export.api.json + +// Package ipfix_export contains generated bindings for API file ipfix_export.api. +// +// Contents: +// - 19 messages +package ipfix_export + +import ( + api "github.com/alkiranet/govpp/api" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "ipfix_export" + APIVersion = "2.0.3" + VersionCrc = 0x63e0810a +) + +// Ipfix meter details in response to the get_meters command +// - name The name of the ipfix meter +// +// IpfixAllExporterDetails defines message 'ipfix_all_exporter_details'. +type IpfixAllExporterDetails struct { + CollectorAddress ip_types.Address `binapi:"address,name=collector_address" json:"collector_address,omitempty"` + CollectorPort uint16 `binapi:"u16,name=collector_port" json:"collector_port,omitempty"` + SrcAddress ip_types.Address `binapi:"address,name=src_address" json:"src_address,omitempty"` + VrfID uint32 `binapi:"u32,name=vrf_id" json:"vrf_id,omitempty"` + PathMtu uint32 `binapi:"u32,name=path_mtu" json:"path_mtu,omitempty"` + TemplateInterval uint32 `binapi:"u32,name=template_interval" json:"template_interval,omitempty"` + UDPChecksum bool `binapi:"bool,name=udp_checksum" json:"udp_checksum,omitempty"` +} + +func (m *IpfixAllExporterDetails) Reset() { *m = IpfixAllExporterDetails{} } +func (*IpfixAllExporterDetails) GetMessageName() string { return "ipfix_all_exporter_details" } +func (*IpfixAllExporterDetails) GetCrcString() string { return "0dedbfe4" } +func (*IpfixAllExporterDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpfixAllExporterDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.CollectorAddress.Af + size += 1 * 16 // m.CollectorAddress.Un + size += 2 // m.CollectorPort + size += 1 // m.SrcAddress.Af + size += 1 * 16 // m.SrcAddress.Un + size += 4 // m.VrfID + size += 4 // m.PathMtu + size += 4 // m.TemplateInterval + size += 1 // m.UDPChecksum + return size +} +func (m *IpfixAllExporterDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.CollectorAddress.Af)) + buf.EncodeBytes(m.CollectorAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint16(m.CollectorPort) + buf.EncodeUint8(uint8(m.SrcAddress.Af)) + buf.EncodeBytes(m.SrcAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.VrfID) + buf.EncodeUint32(m.PathMtu) + buf.EncodeUint32(m.TemplateInterval) + buf.EncodeBool(m.UDPChecksum) + return buf.Bytes(), nil +} +func (m *IpfixAllExporterDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.CollectorAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.CollectorAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.CollectorPort = buf.DecodeUint16() + m.SrcAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.SrcAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.VrfID = buf.DecodeUint32() + m.PathMtu = buf.DecodeUint32() + m.TemplateInterval = buf.DecodeUint32() + m.UDPChecksum = buf.DecodeBool() + return nil +} + +// IpfixAllExporterGet defines message 'ipfix_all_exporter_get'. +type IpfixAllExporterGet struct { + Cursor uint32 `binapi:"u32,name=cursor" json:"cursor,omitempty"` +} + +func (m *IpfixAllExporterGet) Reset() { *m = IpfixAllExporterGet{} } +func (*IpfixAllExporterGet) GetMessageName() string { return "ipfix_all_exporter_get" } +func (*IpfixAllExporterGet) GetCrcString() string { return "f75ba505" } +func (*IpfixAllExporterGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpfixAllExporterGet) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Cursor + return size +} +func (m *IpfixAllExporterGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Cursor) + return buf.Bytes(), nil +} +func (m *IpfixAllExporterGet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Cursor = buf.DecodeUint32() + return nil +} + +// IpfixAllExporterGetReply defines message 'ipfix_all_exporter_get_reply'. +type IpfixAllExporterGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Cursor uint32 `binapi:"u32,name=cursor" json:"cursor,omitempty"` +} + +func (m *IpfixAllExporterGetReply) Reset() { *m = IpfixAllExporterGetReply{} } +func (*IpfixAllExporterGetReply) GetMessageName() string { return "ipfix_all_exporter_get_reply" } +func (*IpfixAllExporterGetReply) GetCrcString() string { return "53b48f5d" } +func (*IpfixAllExporterGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpfixAllExporterGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Cursor + return size +} +func (m *IpfixAllExporterGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.Cursor) + return buf.Bytes(), nil +} +func (m *IpfixAllExporterGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Cursor = buf.DecodeUint32() + return nil +} + +// Reply to IPFIX classify stream dump request +// - domain_id - domain ID reported in IPFIX messages for classify stream +// - src_port - source port of UDP session for classify stream +// +// IpfixClassifyStreamDetails defines message 'ipfix_classify_stream_details'. +type IpfixClassifyStreamDetails struct { + DomainID uint32 `binapi:"u32,name=domain_id" json:"domain_id,omitempty"` + SrcPort uint16 `binapi:"u16,name=src_port" json:"src_port,omitempty"` +} + +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 +} + +func (m *IpfixClassifyStreamDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.DomainID + size += 2 // m.SrcPort + return size +} +func (m *IpfixClassifyStreamDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.DomainID) + buf.EncodeUint16(m.SrcPort) + return buf.Bytes(), nil +} +func (m *IpfixClassifyStreamDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.DomainID = buf.DecodeUint32() + m.SrcPort = buf.DecodeUint16() + return nil +} + +// IPFIX classify stream dump request +// IpfixClassifyStreamDump defines 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 +} + +func (m *IpfixClassifyStreamDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *IpfixClassifyStreamDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *IpfixClassifyStreamDump) Unmarshal(b []byte) error { + return nil +} + +// IPFIX add or delete classifier table request +// - table_id - classifier table ID +// - ip_version - version of IP used in the classifier table +// - transport_protocol - transport protocol used in the classifier table or 255 for unspecified +// +// IpfixClassifyTableAddDel defines message 'ipfix_classify_table_add_del'. +type IpfixClassifyTableAddDel struct { + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + IPVersion ip_types.AddressFamily `binapi:"address_family,name=ip_version" json:"ip_version,omitempty"` + TransportProtocol ip_types.IPProto `binapi:"ip_proto,name=transport_protocol" json:"transport_protocol,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` +} + +func (m *IpfixClassifyTableAddDel) Reset() { *m = IpfixClassifyTableAddDel{} } +func (*IpfixClassifyTableAddDel) GetMessageName() string { return "ipfix_classify_table_add_del" } +func (*IpfixClassifyTableAddDel) GetCrcString() string { return "3e449bb9" } +func (*IpfixClassifyTableAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpfixClassifyTableAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TableID + size += 1 // m.IPVersion + size += 1 // m.TransportProtocol + size += 1 // m.IsAdd + return size +} +func (m *IpfixClassifyTableAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TableID) + buf.EncodeUint8(uint8(m.IPVersion)) + buf.EncodeUint8(uint8(m.TransportProtocol)) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *IpfixClassifyTableAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TableID = buf.DecodeUint32() + m.IPVersion = ip_types.AddressFamily(buf.DecodeUint8()) + m.TransportProtocol = ip_types.IPProto(buf.DecodeUint8()) + m.IsAdd = buf.DecodeBool() + return nil +} + +// IpfixClassifyTableAddDelReply defines message 'ipfix_classify_table_add_del_reply'. +type IpfixClassifyTableAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *IpfixClassifyTableAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IpfixClassifyTableAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IpfixClassifyTableAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Reply to IPFIX classify tables dump request +// - table_id - classifier table ID +// - ip_version - version of IP used in the classifier table +// - transport_protocol - transport protocol used in the classifier table or 255 for unspecified +// +// IpfixClassifyTableDetails defines message 'ipfix_classify_table_details'. +type IpfixClassifyTableDetails struct { + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + IPVersion ip_types.AddressFamily `binapi:"address_family,name=ip_version" json:"ip_version,omitempty"` + TransportProtocol ip_types.IPProto `binapi:"ip_proto,name=transport_protocol" json:"transport_protocol,omitempty"` +} + +func (m *IpfixClassifyTableDetails) Reset() { *m = IpfixClassifyTableDetails{} } +func (*IpfixClassifyTableDetails) GetMessageName() string { return "ipfix_classify_table_details" } +func (*IpfixClassifyTableDetails) GetCrcString() string { return "1af8c28c" } +func (*IpfixClassifyTableDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpfixClassifyTableDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TableID + size += 1 // m.IPVersion + size += 1 // m.TransportProtocol + return size +} +func (m *IpfixClassifyTableDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TableID) + buf.EncodeUint8(uint8(m.IPVersion)) + buf.EncodeUint8(uint8(m.TransportProtocol)) + return buf.Bytes(), nil +} +func (m *IpfixClassifyTableDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TableID = buf.DecodeUint32() + m.IPVersion = ip_types.AddressFamily(buf.DecodeUint8()) + m.TransportProtocol = ip_types.IPProto(buf.DecodeUint8()) + return nil +} + +// IPFIX classify tables dump request +// IpfixClassifyTableDump defines 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 +} + +func (m *IpfixClassifyTableDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *IpfixClassifyTableDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *IpfixClassifyTableDump) Unmarshal(b []byte) error { + return nil +} + +// Configure IPFIX exporter within the exporting process. +// +// The exporting process can contain multiple independent exporters, +// each of which have their own state. The collector_address is the key +// field that identifies a unique exporter. The already existing API +// 'set_ipfix_exporter' is used to modify a single exporter (which will +// always have stat index 0). If more than one exporter is required then +// they can be created and deleted using this API. +// - is_create - True for create, False for delete +// - collector_address - address of IPFIX collector +// - collector_port - port of IPFIX collector +// - src_address - address of IPFIX exporter +// - vrf_id - VRF / fib table ID +// - path_mtu - Path MTU between exporter and collector +// - template_interval - number of seconds after which to resend template +// - udp_checksum - UDP checksum calculation enable flag +// +// IpfixExporterCreateDelete defines message 'ipfix_exporter_create_delete'. +type IpfixExporterCreateDelete struct { + IsCreate bool `binapi:"bool,name=is_create" json:"is_create,omitempty"` + CollectorAddress ip_types.Address `binapi:"address,name=collector_address" json:"collector_address,omitempty"` + CollectorPort uint16 `binapi:"u16,name=collector_port" json:"collector_port,omitempty"` + SrcAddress ip_types.Address `binapi:"address,name=src_address" json:"src_address,omitempty"` + VrfID uint32 `binapi:"u32,name=vrf_id" json:"vrf_id,omitempty"` + PathMtu uint32 `binapi:"u32,name=path_mtu" json:"path_mtu,omitempty"` + TemplateInterval uint32 `binapi:"u32,name=template_interval" json:"template_interval,omitempty"` + UDPChecksum bool `binapi:"bool,name=udp_checksum" json:"udp_checksum,omitempty"` +} + +func (m *IpfixExporterCreateDelete) Reset() { *m = IpfixExporterCreateDelete{} } +func (*IpfixExporterCreateDelete) GetMessageName() string { return "ipfix_exporter_create_delete" } +func (*IpfixExporterCreateDelete) GetCrcString() string { return "0753a768" } +func (*IpfixExporterCreateDelete) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpfixExporterCreateDelete) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsCreate + size += 1 // m.CollectorAddress.Af + size += 1 * 16 // m.CollectorAddress.Un + size += 2 // m.CollectorPort + size += 1 // m.SrcAddress.Af + size += 1 * 16 // m.SrcAddress.Un + size += 4 // m.VrfID + size += 4 // m.PathMtu + size += 4 // m.TemplateInterval + size += 1 // m.UDPChecksum + return size +} +func (m *IpfixExporterCreateDelete) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsCreate) + buf.EncodeUint8(uint8(m.CollectorAddress.Af)) + buf.EncodeBytes(m.CollectorAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint16(m.CollectorPort) + buf.EncodeUint8(uint8(m.SrcAddress.Af)) + buf.EncodeBytes(m.SrcAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.VrfID) + buf.EncodeUint32(m.PathMtu) + buf.EncodeUint32(m.TemplateInterval) + buf.EncodeBool(m.UDPChecksum) + return buf.Bytes(), nil +} +func (m *IpfixExporterCreateDelete) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsCreate = buf.DecodeBool() + m.CollectorAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.CollectorAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.CollectorPort = buf.DecodeUint16() + m.SrcAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.SrcAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.VrfID = buf.DecodeUint32() + m.PathMtu = buf.DecodeUint32() + m.TemplateInterval = buf.DecodeUint32() + m.UDPChecksum = buf.DecodeBool() + return nil +} + +// IpfixExporterCreateDeleteReply defines message 'ipfix_exporter_create_delete_reply'. +type IpfixExporterCreateDeleteReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + StatIndex uint32 `binapi:"u32,name=stat_index" json:"stat_index,omitempty"` +} + +func (m *IpfixExporterCreateDeleteReply) Reset() { *m = IpfixExporterCreateDeleteReply{} } +func (*IpfixExporterCreateDeleteReply) GetMessageName() string { + return "ipfix_exporter_create_delete_reply" +} +func (*IpfixExporterCreateDeleteReply) GetCrcString() string { return "9ffac24b" } +func (*IpfixExporterCreateDeleteReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpfixExporterCreateDeleteReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.StatIndex + return size +} +func (m *IpfixExporterCreateDeleteReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.StatIndex) + return buf.Bytes(), nil +} +func (m *IpfixExporterCreateDeleteReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.StatIndex = buf.DecodeUint32() + return nil +} + +// Reply to IPFIX exporter dump request +// - collector_address - address of IPFIX collector +// - collector_port - port of IPFIX collector +// - src_address - address of IPFIX exporter +// - fib_index - fib table index +// - path_mtu - Path MTU between exporter and collector +// - template_interval - number of seconds after which to resend template +// - udp_checksum - UDP checksum calculation enable flag +// +// IpfixExporterDetails defines message 'ipfix_exporter_details'. +type IpfixExporterDetails struct { + CollectorAddress ip_types.Address `binapi:"address,name=collector_address" json:"collector_address,omitempty"` + CollectorPort uint16 `binapi:"u16,name=collector_port" json:"collector_port,omitempty"` + SrcAddress ip_types.Address `binapi:"address,name=src_address" json:"src_address,omitempty"` + VrfID uint32 `binapi:"u32,name=vrf_id" json:"vrf_id,omitempty"` + PathMtu uint32 `binapi:"u32,name=path_mtu" json:"path_mtu,omitempty"` + TemplateInterval uint32 `binapi:"u32,name=template_interval" json:"template_interval,omitempty"` + UDPChecksum bool `binapi:"bool,name=udp_checksum" json:"udp_checksum,omitempty"` +} + +func (m *IpfixExporterDetails) Reset() { *m = IpfixExporterDetails{} } +func (*IpfixExporterDetails) GetMessageName() string { return "ipfix_exporter_details" } +func (*IpfixExporterDetails) GetCrcString() string { return "0dedbfe4" } +func (*IpfixExporterDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpfixExporterDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.CollectorAddress.Af + size += 1 * 16 // m.CollectorAddress.Un + size += 2 // m.CollectorPort + size += 1 // m.SrcAddress.Af + size += 1 * 16 // m.SrcAddress.Un + size += 4 // m.VrfID + size += 4 // m.PathMtu + size += 4 // m.TemplateInterval + size += 1 // m.UDPChecksum + return size +} +func (m *IpfixExporterDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.CollectorAddress.Af)) + buf.EncodeBytes(m.CollectorAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint16(m.CollectorPort) + buf.EncodeUint8(uint8(m.SrcAddress.Af)) + buf.EncodeBytes(m.SrcAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.VrfID) + buf.EncodeUint32(m.PathMtu) + buf.EncodeUint32(m.TemplateInterval) + buf.EncodeBool(m.UDPChecksum) + return buf.Bytes(), nil +} +func (m *IpfixExporterDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.CollectorAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.CollectorAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.CollectorPort = buf.DecodeUint16() + m.SrcAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.SrcAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.VrfID = buf.DecodeUint32() + m.PathMtu = buf.DecodeUint32() + m.TemplateInterval = buf.DecodeUint32() + m.UDPChecksum = buf.DecodeBool() + return nil +} + +// IPFIX exporter dump request +// IpfixExporterDump defines 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 +} + +func (m *IpfixExporterDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *IpfixExporterDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *IpfixExporterDump) Unmarshal(b []byte) error { + return nil +} + +// IpfixFlush defines 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 +} + +func (m *IpfixFlush) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *IpfixFlush) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *IpfixFlush) Unmarshal(b []byte) error { + return nil +} + +// IpfixFlushReply defines message 'ipfix_flush_reply'. +type IpfixFlushReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *IpfixFlushReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IpfixFlushReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IpfixFlushReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IPFIX classify stream configure request +// - domain_id - domain ID reported in IPFIX messages for classify stream +// - src_port - source port of UDP session for classify stream +// +// SetIpfixClassifyStream defines message 'set_ipfix_classify_stream'. +type SetIpfixClassifyStream struct { + DomainID uint32 `binapi:"u32,name=domain_id" json:"domain_id,omitempty"` + SrcPort uint16 `binapi:"u16,name=src_port" json:"src_port,omitempty"` +} + +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 +} + +func (m *SetIpfixClassifyStream) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.DomainID + size += 2 // m.SrcPort + return size +} +func (m *SetIpfixClassifyStream) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.DomainID) + buf.EncodeUint16(m.SrcPort) + return buf.Bytes(), nil +} +func (m *SetIpfixClassifyStream) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.DomainID = buf.DecodeUint32() + m.SrcPort = buf.DecodeUint16() + return nil +} + +// SetIpfixClassifyStreamReply defines message 'set_ipfix_classify_stream_reply'. +type SetIpfixClassifyStreamReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SetIpfixClassifyStreamReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SetIpfixClassifyStreamReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SetIpfixClassifyStreamReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Configure IPFIX exporter process request +// - collector_address - address of IPFIX collector +// - collector_port - port of IPFIX collector +// - src_address - address of IPFIX exporter +// - vrf_id - VRF / fib table ID +// - path_mtu - Path MTU between exporter and collector +// - template_interval - number of seconds after which to resend template +// - udp_checksum - UDP checksum calculation enable flag +// +// SetIpfixExporter defines message 'set_ipfix_exporter'. +type SetIpfixExporter struct { + CollectorAddress ip_types.Address `binapi:"address,name=collector_address" json:"collector_address,omitempty"` + CollectorPort uint16 `binapi:"u16,name=collector_port" json:"collector_port,omitempty"` + SrcAddress ip_types.Address `binapi:"address,name=src_address" json:"src_address,omitempty"` + VrfID uint32 `binapi:"u32,name=vrf_id" json:"vrf_id,omitempty"` + PathMtu uint32 `binapi:"u32,name=path_mtu" json:"path_mtu,omitempty"` + TemplateInterval uint32 `binapi:"u32,name=template_interval" json:"template_interval,omitempty"` + UDPChecksum bool `binapi:"bool,name=udp_checksum" json:"udp_checksum,omitempty"` +} + +func (m *SetIpfixExporter) Reset() { *m = SetIpfixExporter{} } +func (*SetIpfixExporter) GetMessageName() string { return "set_ipfix_exporter" } +func (*SetIpfixExporter) GetCrcString() string { return "5530c8a0" } +func (*SetIpfixExporter) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SetIpfixExporter) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.CollectorAddress.Af + size += 1 * 16 // m.CollectorAddress.Un + size += 2 // m.CollectorPort + size += 1 // m.SrcAddress.Af + size += 1 * 16 // m.SrcAddress.Un + size += 4 // m.VrfID + size += 4 // m.PathMtu + size += 4 // m.TemplateInterval + size += 1 // m.UDPChecksum + return size +} +func (m *SetIpfixExporter) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.CollectorAddress.Af)) + buf.EncodeBytes(m.CollectorAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint16(m.CollectorPort) + buf.EncodeUint8(uint8(m.SrcAddress.Af)) + buf.EncodeBytes(m.SrcAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.VrfID) + buf.EncodeUint32(m.PathMtu) + buf.EncodeUint32(m.TemplateInterval) + buf.EncodeBool(m.UDPChecksum) + return buf.Bytes(), nil +} +func (m *SetIpfixExporter) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.CollectorAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.CollectorAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.CollectorPort = buf.DecodeUint16() + m.SrcAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.SrcAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.VrfID = buf.DecodeUint32() + m.PathMtu = buf.DecodeUint32() + m.TemplateInterval = buf.DecodeUint32() + m.UDPChecksum = buf.DecodeBool() + return nil +} + +// SetIpfixExporterReply defines message 'set_ipfix_exporter_reply'. +type SetIpfixExporterReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 (m *SetIpfixExporterReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SetIpfixExporterReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SetIpfixExporterReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_ipfix_export_binapi_init() } +func file_ipfix_export_binapi_init() { + api.RegisterMessage((*IpfixAllExporterDetails)(nil), "ipfix_all_exporter_details_0dedbfe4") + api.RegisterMessage((*IpfixAllExporterGet)(nil), "ipfix_all_exporter_get_f75ba505") + api.RegisterMessage((*IpfixAllExporterGetReply)(nil), "ipfix_all_exporter_get_reply_53b48f5d") + api.RegisterMessage((*IpfixClassifyStreamDetails)(nil), "ipfix_classify_stream_details_2903539d") + api.RegisterMessage((*IpfixClassifyStreamDump)(nil), "ipfix_classify_stream_dump_51077d14") + api.RegisterMessage((*IpfixClassifyTableAddDel)(nil), "ipfix_classify_table_add_del_3e449bb9") + api.RegisterMessage((*IpfixClassifyTableAddDelReply)(nil), "ipfix_classify_table_add_del_reply_e8d4e804") + api.RegisterMessage((*IpfixClassifyTableDetails)(nil), "ipfix_classify_table_details_1af8c28c") + api.RegisterMessage((*IpfixClassifyTableDump)(nil), "ipfix_classify_table_dump_51077d14") + api.RegisterMessage((*IpfixExporterCreateDelete)(nil), "ipfix_exporter_create_delete_0753a768") + api.RegisterMessage((*IpfixExporterCreateDeleteReply)(nil), "ipfix_exporter_create_delete_reply_9ffac24b") + api.RegisterMessage((*IpfixExporterDetails)(nil), "ipfix_exporter_details_0dedbfe4") + api.RegisterMessage((*IpfixExporterDump)(nil), "ipfix_exporter_dump_51077d14") + api.RegisterMessage((*IpfixFlush)(nil), "ipfix_flush_51077d14") + api.RegisterMessage((*IpfixFlushReply)(nil), "ipfix_flush_reply_e8d4e804") + api.RegisterMessage((*SetIpfixClassifyStream)(nil), "set_ipfix_classify_stream_c9cbe053") + api.RegisterMessage((*SetIpfixClassifyStreamReply)(nil), "set_ipfix_classify_stream_reply_e8d4e804") + api.RegisterMessage((*SetIpfixExporter)(nil), "set_ipfix_exporter_5530c8a0") + api.RegisterMessage((*SetIpfixExporterReply)(nil), "set_ipfix_exporter_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*IpfixAllExporterDetails)(nil), + (*IpfixAllExporterGet)(nil), + (*IpfixAllExporterGetReply)(nil), + (*IpfixClassifyStreamDetails)(nil), + (*IpfixClassifyStreamDump)(nil), + (*IpfixClassifyTableAddDel)(nil), + (*IpfixClassifyTableAddDelReply)(nil), + (*IpfixClassifyTableDetails)(nil), + (*IpfixClassifyTableDump)(nil), + (*IpfixExporterCreateDelete)(nil), + (*IpfixExporterCreateDeleteReply)(nil), + (*IpfixExporterDetails)(nil), + (*IpfixExporterDump)(nil), + (*IpfixFlush)(nil), + (*IpfixFlushReply)(nil), + (*SetIpfixClassifyStream)(nil), + (*SetIpfixClassifyStreamReply)(nil), + (*SetIpfixExporter)(nil), + (*SetIpfixExporterReply)(nil), + } +} diff --git a/binapi/ipfix_export/ipfix_export_rpc.ba.go b/binapi/ipfix_export/ipfix_export_rpc.ba.go new file mode 100644 index 00000000..c47eb0c1 --- /dev/null +++ b/binapi/ipfix_export/ipfix_export_rpc.ba.go @@ -0,0 +1,250 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package ipfix_export + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service ipfix_export. +type RPCService interface { + IpfixAllExporterGet(ctx context.Context, in *IpfixAllExporterGet) (RPCService_IpfixAllExporterGetClient, error) + IpfixClassifyStreamDump(ctx context.Context, in *IpfixClassifyStreamDump) (RPCService_IpfixClassifyStreamDumpClient, error) + IpfixClassifyTableAddDel(ctx context.Context, in *IpfixClassifyTableAddDel) (*IpfixClassifyTableAddDelReply, error) + IpfixClassifyTableDump(ctx context.Context, in *IpfixClassifyTableDump) (RPCService_IpfixClassifyTableDumpClient, error) + IpfixExporterCreateDelete(ctx context.Context, in *IpfixExporterCreateDelete) (*IpfixExporterCreateDeleteReply, error) + IpfixExporterDump(ctx context.Context, in *IpfixExporterDump) (RPCService_IpfixExporterDumpClient, 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 { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) IpfixAllExporterGet(ctx context.Context, in *IpfixAllExporterGet) (RPCService_IpfixAllExporterGetClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IpfixAllExporterGetClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IpfixAllExporterGetClient interface { + Recv() (*IpfixAllExporterDetails, *IpfixAllExporterGetReply, error) + api.Stream +} + +type serviceClient_IpfixAllExporterGetClient struct { + api.Stream +} + +func (c *serviceClient_IpfixAllExporterGetClient) Recv() (*IpfixAllExporterDetails, *IpfixAllExporterGetReply, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, nil, err + } + switch m := msg.(type) { + case *IpfixAllExporterDetails: + return m, nil, nil + case *IpfixAllExporterGetReply: + if err := api.RetvalToVPPApiError(m.Retval); err != nil { + return nil, m, err + } + err = c.Stream.Close() + if err != nil { + return nil, m, err + } + return nil, m, io.EOF + default: + return nil, nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IpfixClassifyStreamDump(ctx context.Context, in *IpfixClassifyStreamDump) (RPCService_IpfixClassifyStreamDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IpfixClassifyStreamDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IpfixClassifyStreamDumpClient interface { + Recv() (*IpfixClassifyStreamDetails, error) + api.Stream +} + +type serviceClient_IpfixClassifyStreamDumpClient struct { + api.Stream +} + +func (c *serviceClient_IpfixClassifyStreamDumpClient) Recv() (*IpfixClassifyStreamDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IpfixClassifyStreamDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IpfixClassifyTableAddDel(ctx context.Context, in *IpfixClassifyTableAddDel) (*IpfixClassifyTableAddDelReply, error) { + out := new(IpfixClassifyTableAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpfixClassifyTableDump(ctx context.Context, in *IpfixClassifyTableDump) (RPCService_IpfixClassifyTableDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IpfixClassifyTableDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IpfixClassifyTableDumpClient interface { + Recv() (*IpfixClassifyTableDetails, error) + api.Stream +} + +type serviceClient_IpfixClassifyTableDumpClient struct { + api.Stream +} + +func (c *serviceClient_IpfixClassifyTableDumpClient) Recv() (*IpfixClassifyTableDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IpfixClassifyTableDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IpfixExporterCreateDelete(ctx context.Context, in *IpfixExporterCreateDelete) (*IpfixExporterCreateDeleteReply, error) { + out := new(IpfixExporterCreateDeleteReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpfixExporterDump(ctx context.Context, in *IpfixExporterDump) (RPCService_IpfixExporterDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IpfixExporterDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IpfixExporterDumpClient interface { + Recv() (*IpfixExporterDetails, error) + api.Stream +} + +type serviceClient_IpfixExporterDumpClient struct { + api.Stream +} + +func (c *serviceClient_IpfixExporterDumpClient) Recv() (*IpfixExporterDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IpfixExporterDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IpfixFlush(ctx context.Context, in *IpfixFlush) (*IpfixFlushReply, error) { + out := new(IpfixFlushReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SetIpfixClassifyStream(ctx context.Context, in *SetIpfixClassifyStream) (*SetIpfixClassifyStreamReply, error) { + out := new(SetIpfixClassifyStreamReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SetIpfixExporter(ctx context.Context, in *SetIpfixExporter) (*SetIpfixExporterReply, error) { + out := new(SetIpfixExporterReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/ipip/ipip.ba.go b/binapi/ipip/ipip.ba.go new file mode 100644 index 00000000..15f8d519 --- /dev/null +++ b/binapi/ipip/ipip.ba.go @@ -0,0 +1,501 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/ipip.api.json + +// Package ipip contains generated bindings for API file ipip.api. +// +// Contents: +// - 1 struct +// - 10 messages +package ipip + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + tunnel_types "github.com/alkiranet/govpp/binapi/tunnel_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "ipip" + APIVersion = "2.0.2" + VersionCrc = 0x4609caba +) + +// IpipTunnel defines type 'ipip_tunnel'. +type IpipTunnel struct { + Instance uint32 `binapi:"u32,name=instance" json:"instance,omitempty"` + Src ip_types.Address `binapi:"address,name=src" json:"src,omitempty"` + Dst ip_types.Address `binapi:"address,name=dst" json:"dst,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + Flags tunnel_types.TunnelEncapDecapFlags `binapi:"tunnel_encap_decap_flags,name=flags" json:"flags,omitempty"` + Mode tunnel_types.TunnelMode `binapi:"tunnel_mode,name=mode" json:"mode,omitempty"` + Dscp ip_types.IPDscp `binapi:"ip_dscp,name=dscp" json:"dscp,omitempty"` +} + +// * Create an IPv4 over IPv6 automatic tunnel (6RD) +// Ipip6rdAddTunnel defines message 'ipip_6rd_add_tunnel'. +type Ipip6rdAddTunnel struct { + IP6TableID uint32 `binapi:"u32,name=ip6_table_id" json:"ip6_table_id,omitempty"` + IP4TableID uint32 `binapi:"u32,name=ip4_table_id" json:"ip4_table_id,omitempty"` + IP6Prefix ip_types.IP6Prefix `binapi:"ip6_prefix,name=ip6_prefix" json:"ip6_prefix,omitempty"` + IP4Prefix ip_types.IP4Prefix `binapi:"ip4_prefix,name=ip4_prefix" json:"ip4_prefix,omitempty"` + IP4Src ip_types.IP4Address `binapi:"ip4_address,name=ip4_src" json:"ip4_src,omitempty"` + SecurityCheck bool `binapi:"bool,name=security_check" json:"security_check,omitempty"` + TcTos uint8 `binapi:"u8,name=tc_tos" json:"tc_tos,omitempty"` +} + +func (m *Ipip6rdAddTunnel) Reset() { *m = Ipip6rdAddTunnel{} } +func (*Ipip6rdAddTunnel) GetMessageName() string { return "ipip_6rd_add_tunnel" } +func (*Ipip6rdAddTunnel) GetCrcString() string { return "b9ec1863" } +func (*Ipip6rdAddTunnel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *Ipip6rdAddTunnel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.IP6TableID + size += 4 // m.IP4TableID + size += 1 * 16 // m.IP6Prefix.Address + size += 1 // m.IP6Prefix.Len + size += 1 * 4 // m.IP4Prefix.Address + size += 1 // m.IP4Prefix.Len + size += 1 * 4 // m.IP4Src + size += 1 // m.SecurityCheck + size += 1 // m.TcTos + return size +} +func (m *Ipip6rdAddTunnel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.IP6TableID) + buf.EncodeUint32(m.IP4TableID) + buf.EncodeBytes(m.IP6Prefix.Address[:], 16) + buf.EncodeUint8(m.IP6Prefix.Len) + buf.EncodeBytes(m.IP4Prefix.Address[:], 4) + buf.EncodeUint8(m.IP4Prefix.Len) + buf.EncodeBytes(m.IP4Src[:], 4) + buf.EncodeBool(m.SecurityCheck) + buf.EncodeUint8(m.TcTos) + return buf.Bytes(), nil +} +func (m *Ipip6rdAddTunnel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IP6TableID = buf.DecodeUint32() + m.IP4TableID = buf.DecodeUint32() + copy(m.IP6Prefix.Address[:], buf.DecodeBytes(16)) + m.IP6Prefix.Len = buf.DecodeUint8() + copy(m.IP4Prefix.Address[:], buf.DecodeBytes(4)) + m.IP4Prefix.Len = buf.DecodeUint8() + copy(m.IP4Src[:], buf.DecodeBytes(4)) + m.SecurityCheck = buf.DecodeBool() + m.TcTos = buf.DecodeUint8() + return nil +} + +// Ipip6rdAddTunnelReply defines message 'ipip_6rd_add_tunnel_reply'. +type Ipip6rdAddTunnelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *Ipip6rdAddTunnelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *Ipip6rdAddTunnelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *Ipip6rdAddTunnelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// * Delete an IPv4 over IPv6 automatic tunnel (6RD) +// Ipip6rdDelTunnel defines message 'ipip_6rd_del_tunnel'. +type Ipip6rdDelTunnel struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *Ipip6rdDelTunnel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *Ipip6rdDelTunnel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *Ipip6rdDelTunnel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Ipip6rdDelTunnelReply defines message 'ipip_6rd_del_tunnel_reply'. +type Ipip6rdDelTunnelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *Ipip6rdDelTunnelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *Ipip6rdDelTunnelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *Ipip6rdDelTunnelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// * Create an IP{v4,v6} over IP{v4,v6} tunnel. +// IpipAddTunnel defines message 'ipip_add_tunnel'. +type IpipAddTunnel struct { + Tunnel IpipTunnel `binapi:"ipip_tunnel,name=tunnel" json:"tunnel,omitempty"` +} + +func (m *IpipAddTunnel) Reset() { *m = IpipAddTunnel{} } +func (*IpipAddTunnel) GetMessageName() string { return "ipip_add_tunnel" } +func (*IpipAddTunnel) GetCrcString() string { return "2ac399f5" } +func (*IpipAddTunnel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpipAddTunnel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Tunnel.Instance + size += 1 // m.Tunnel.Src.Af + size += 1 * 16 // m.Tunnel.Src.Un + size += 1 // m.Tunnel.Dst.Af + size += 1 * 16 // m.Tunnel.Dst.Un + size += 4 // m.Tunnel.SwIfIndex + size += 4 // m.Tunnel.TableID + size += 1 // m.Tunnel.Flags + size += 1 // m.Tunnel.Mode + size += 1 // m.Tunnel.Dscp + return size +} +func (m *IpipAddTunnel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Tunnel.Instance) + buf.EncodeUint8(uint8(m.Tunnel.Src.Af)) + buf.EncodeBytes(m.Tunnel.Src.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Tunnel.Dst.Af)) + buf.EncodeBytes(m.Tunnel.Dst.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.Tunnel.SwIfIndex)) + buf.EncodeUint32(m.Tunnel.TableID) + buf.EncodeUint8(uint8(m.Tunnel.Flags)) + buf.EncodeUint8(uint8(m.Tunnel.Mode)) + buf.EncodeUint8(uint8(m.Tunnel.Dscp)) + return buf.Bytes(), nil +} +func (m *IpipAddTunnel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Tunnel.Instance = buf.DecodeUint32() + m.Tunnel.Src.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Tunnel.Src.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Tunnel.Dst.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Tunnel.Dst.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Tunnel.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Tunnel.TableID = buf.DecodeUint32() + m.Tunnel.Flags = tunnel_types.TunnelEncapDecapFlags(buf.DecodeUint8()) + m.Tunnel.Mode = tunnel_types.TunnelMode(buf.DecodeUint8()) + m.Tunnel.Dscp = ip_types.IPDscp(buf.DecodeUint8()) + return nil +} + +// IpipAddTunnelReply defines message 'ipip_add_tunnel_reply'. +type IpipAddTunnelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *IpipAddTunnelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *IpipAddTunnelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *IpipAddTunnelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// * Delete an IP{v4,v6} over IP{v4,v6} tunnel. +// IpipDelTunnel defines message 'ipip_del_tunnel'. +type IpipDelTunnel struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *IpipDelTunnel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *IpipDelTunnel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *IpipDelTunnel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// IpipDelTunnelReply defines message 'ipip_del_tunnel_reply'. +type IpipDelTunnelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *IpipDelTunnelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IpipDelTunnelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IpipDelTunnelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IpipTunnelDetails defines message 'ipip_tunnel_details'. +type IpipTunnelDetails struct { + Tunnel IpipTunnel `binapi:"ipip_tunnel,name=tunnel" json:"tunnel,omitempty"` +} + +func (m *IpipTunnelDetails) Reset() { *m = IpipTunnelDetails{} } +func (*IpipTunnelDetails) GetMessageName() string { return "ipip_tunnel_details" } +func (*IpipTunnelDetails) GetCrcString() string { return "d31cb34e" } +func (*IpipTunnelDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpipTunnelDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Tunnel.Instance + size += 1 // m.Tunnel.Src.Af + size += 1 * 16 // m.Tunnel.Src.Un + size += 1 // m.Tunnel.Dst.Af + size += 1 * 16 // m.Tunnel.Dst.Un + size += 4 // m.Tunnel.SwIfIndex + size += 4 // m.Tunnel.TableID + size += 1 // m.Tunnel.Flags + size += 1 // m.Tunnel.Mode + size += 1 // m.Tunnel.Dscp + return size +} +func (m *IpipTunnelDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Tunnel.Instance) + buf.EncodeUint8(uint8(m.Tunnel.Src.Af)) + buf.EncodeBytes(m.Tunnel.Src.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Tunnel.Dst.Af)) + buf.EncodeBytes(m.Tunnel.Dst.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.Tunnel.SwIfIndex)) + buf.EncodeUint32(m.Tunnel.TableID) + buf.EncodeUint8(uint8(m.Tunnel.Flags)) + buf.EncodeUint8(uint8(m.Tunnel.Mode)) + buf.EncodeUint8(uint8(m.Tunnel.Dscp)) + return buf.Bytes(), nil +} +func (m *IpipTunnelDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Tunnel.Instance = buf.DecodeUint32() + m.Tunnel.Src.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Tunnel.Src.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Tunnel.Dst.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Tunnel.Dst.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Tunnel.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Tunnel.TableID = buf.DecodeUint32() + m.Tunnel.Flags = tunnel_types.TunnelEncapDecapFlags(buf.DecodeUint8()) + m.Tunnel.Mode = tunnel_types.TunnelMode(buf.DecodeUint8()) + m.Tunnel.Dscp = ip_types.IPDscp(buf.DecodeUint8()) + return nil +} + +// * List all IPIP tunnels +// IpipTunnelDump defines message 'ipip_tunnel_dump'. +type IpipTunnelDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 (m *IpipTunnelDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *IpipTunnelDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *IpipTunnelDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +func init() { file_ipip_binapi_init() } +func file_ipip_binapi_init() { + api.RegisterMessage((*Ipip6rdAddTunnel)(nil), "ipip_6rd_add_tunnel_b9ec1863") + api.RegisterMessage((*Ipip6rdAddTunnelReply)(nil), "ipip_6rd_add_tunnel_reply_5383d31f") + api.RegisterMessage((*Ipip6rdDelTunnel)(nil), "ipip_6rd_del_tunnel_f9e6675e") + api.RegisterMessage((*Ipip6rdDelTunnelReply)(nil), "ipip_6rd_del_tunnel_reply_e8d4e804") + api.RegisterMessage((*IpipAddTunnel)(nil), "ipip_add_tunnel_2ac399f5") + api.RegisterMessage((*IpipAddTunnelReply)(nil), "ipip_add_tunnel_reply_5383d31f") + api.RegisterMessage((*IpipDelTunnel)(nil), "ipip_del_tunnel_f9e6675e") + api.RegisterMessage((*IpipDelTunnelReply)(nil), "ipip_del_tunnel_reply_e8d4e804") + api.RegisterMessage((*IpipTunnelDetails)(nil), "ipip_tunnel_details_d31cb34e") + api.RegisterMessage((*IpipTunnelDump)(nil), "ipip_tunnel_dump_f9e6675e") +} + +// 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), + } +} diff --git a/binapi/ipip/ipip_rpc.ba.go b/binapi/ipip/ipip_rpc.ba.go new file mode 100644 index 00000000..84bf8da3 --- /dev/null +++ b/binapi/ipip/ipip_rpc.ba.go @@ -0,0 +1,108 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package ipip + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service ipip. +type RPCService interface { + 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) + IpipTunnelDump(ctx context.Context, in *IpipTunnelDump) (RPCService_IpipTunnelDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) Ipip6rdAddTunnel(ctx context.Context, in *Ipip6rdAddTunnel) (*Ipip6rdAddTunnelReply, error) { + out := new(Ipip6rdAddTunnelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) Ipip6rdDelTunnel(ctx context.Context, in *Ipip6rdDelTunnel) (*Ipip6rdDelTunnelReply, error) { + out := new(Ipip6rdDelTunnelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpipAddTunnel(ctx context.Context, in *IpipAddTunnel) (*IpipAddTunnelReply, error) { + out := new(IpipAddTunnelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpipDelTunnel(ctx context.Context, in *IpipDelTunnel) (*IpipDelTunnelReply, error) { + out := new(IpipDelTunnelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpipTunnelDump(ctx context.Context, in *IpipTunnelDump) (RPCService_IpipTunnelDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IpipTunnelDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IpipTunnelDumpClient interface { + Recv() (*IpipTunnelDetails, error) + api.Stream +} + +type serviceClient_IpipTunnelDumpClient struct { + api.Stream +} + +func (c *serviceClient_IpipTunnelDumpClient) Recv() (*IpipTunnelDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IpipTunnelDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/ipsec/ipsec.ba.go b/binapi/ipsec/ipsec.ba.go new file mode 100644 index 00000000..4271f9d2 --- /dev/null +++ b/binapi/ipsec/ipsec.ba.go @@ -0,0 +1,2814 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/ipsec.api.json + +// Package ipsec contains generated bindings for API file ipsec.api. +// +// Contents: +// - 2 structs +// - 50 messages +package ipsec + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + ipsec_types "github.com/alkiranet/govpp/binapi/ipsec_types" + tunnel_types "github.com/alkiranet/govpp/binapi/tunnel_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "ipsec" + APIVersion = "5.0.2" + VersionCrc = 0x9dfdcc71 +) + +// IpsecItf defines type 'ipsec_itf'. +type IpsecItf struct { + UserInstance uint32 `binapi:"u32,name=user_instance,default=4294967295" json:"user_instance,omitempty"` + Mode tunnel_types.TunnelMode `binapi:"tunnel_mode,name=mode" json:"mode,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +// IpsecTunnelProtect defines type 'ipsec_tunnel_protect'. +type IpsecTunnelProtect struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Nh ip_types.Address `binapi:"address,name=nh" json:"nh,omitempty"` + SaOut uint32 `binapi:"u32,name=sa_out" json:"sa_out,omitempty"` + NSaIn uint8 `binapi:"u8,name=n_sa_in" json:"-"` + SaIn []uint32 `binapi:"u32[n_sa_in],name=sa_in" json:"sa_in,omitempty"` +} + +// IPsec backend details +// - name - name of the backend +// - protocol - IPsec protocol (value from ipsec_protocol_t) +// - index - backend index +// - active - set to 1 if the backend is active, otherwise 0 +// +// IpsecBackendDetails defines message 'ipsec_backend_details'. +type IpsecBackendDetails struct { + Name string `binapi:"string[128],name=name" json:"name,omitempty"` + Protocol ipsec_types.IpsecProto `binapi:"ipsec_proto,name=protocol" json:"protocol,omitempty"` + Index uint8 `binapi:"u8,name=index" json:"index,omitempty"` + Active bool `binapi:"bool,name=active" json:"active,omitempty"` +} + +func (m *IpsecBackendDetails) Reset() { *m = IpsecBackendDetails{} } +func (*IpsecBackendDetails) GetMessageName() string { return "ipsec_backend_details" } +func (*IpsecBackendDetails) GetCrcString() string { return "ee601c29" } +func (*IpsecBackendDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecBackendDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 128 // m.Name + size += 4 // m.Protocol + size += 1 // m.Index + size += 1 // m.Active + return size +} +func (m *IpsecBackendDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.Name, 128) + buf.EncodeUint32(uint32(m.Protocol)) + buf.EncodeUint8(m.Index) + buf.EncodeBool(m.Active) + return buf.Bytes(), nil +} +func (m *IpsecBackendDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Name = buf.DecodeString(128) + m.Protocol = ipsec_types.IpsecProto(buf.DecodeUint32()) + m.Index = buf.DecodeUint8() + m.Active = buf.DecodeBool() + return nil +} + +// Dump IPsec backends +// IpsecBackendDump defines 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 +} + +func (m *IpsecBackendDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *IpsecBackendDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *IpsecBackendDump) Unmarshal(b []byte) error { + return nil +} + +// IPsec: Add/delete SPD from interface +// - is_add - add security mode if non-zero, else delete +// - sw_if_index - index of the interface +// - spd_id - SPD instance id to use for lookups +// +// IpsecInterfaceAddDelSpd defines message 'ipsec_interface_add_del_spd'. +type IpsecInterfaceAddDelSpd struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + SpdID uint32 `binapi:"u32,name=spd_id" json:"spd_id,omitempty"` +} + +func (m *IpsecInterfaceAddDelSpd) Reset() { *m = IpsecInterfaceAddDelSpd{} } +func (*IpsecInterfaceAddDelSpd) GetMessageName() string { return "ipsec_interface_add_del_spd" } +func (*IpsecInterfaceAddDelSpd) GetCrcString() string { return "80f80cbb" } +func (*IpsecInterfaceAddDelSpd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecInterfaceAddDelSpd) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.SwIfIndex + size += 4 // m.SpdID + return size +} +func (m *IpsecInterfaceAddDelSpd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.SpdID) + return buf.Bytes(), nil +} +func (m *IpsecInterfaceAddDelSpd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.SpdID = buf.DecodeUint32() + return nil +} + +// IpsecInterfaceAddDelSpdReply defines message 'ipsec_interface_add_del_spd_reply'. +type IpsecInterfaceAddDelSpdReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *IpsecInterfaceAddDelSpdReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IpsecInterfaceAddDelSpdReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IpsecInterfaceAddDelSpdReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Create an IPSec interface +// IpsecItfCreate defines message 'ipsec_itf_create'. +type IpsecItfCreate struct { + Itf IpsecItf `binapi:"ipsec_itf,name=itf" json:"itf,omitempty"` +} + +func (m *IpsecItfCreate) Reset() { *m = IpsecItfCreate{} } +func (*IpsecItfCreate) GetMessageName() string { return "ipsec_itf_create" } +func (*IpsecItfCreate) GetCrcString() string { return "6f50b3bc" } +func (*IpsecItfCreate) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecItfCreate) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Itf.UserInstance + size += 1 // m.Itf.Mode + size += 4 // m.Itf.SwIfIndex + return size +} +func (m *IpsecItfCreate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Itf.UserInstance) + buf.EncodeUint8(uint8(m.Itf.Mode)) + buf.EncodeUint32(uint32(m.Itf.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *IpsecItfCreate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Itf.UserInstance = buf.DecodeUint32() + m.Itf.Mode = tunnel_types.TunnelMode(buf.DecodeUint8()) + m.Itf.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Add IPsec interface interface response +// - retval - return status +// - sw_if_index - sw_if_index of new interface (for successful add) +// +// IpsecItfCreateReply defines message 'ipsec_itf_create_reply'. +type IpsecItfCreateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *IpsecItfCreateReply) Reset() { *m = IpsecItfCreateReply{} } +func (*IpsecItfCreateReply) GetMessageName() string { return "ipsec_itf_create_reply" } +func (*IpsecItfCreateReply) GetCrcString() string { return "5383d31f" } +func (*IpsecItfCreateReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecItfCreateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *IpsecItfCreateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *IpsecItfCreateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// IpsecItfDelete defines message 'ipsec_itf_delete'. +type IpsecItfDelete struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *IpsecItfDelete) Reset() { *m = IpsecItfDelete{} } +func (*IpsecItfDelete) GetMessageName() string { return "ipsec_itf_delete" } +func (*IpsecItfDelete) GetCrcString() string { return "f9e6675e" } +func (*IpsecItfDelete) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecItfDelete) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *IpsecItfDelete) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *IpsecItfDelete) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// IpsecItfDeleteReply defines message 'ipsec_itf_delete_reply'. +type IpsecItfDeleteReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IpsecItfDeleteReply) Reset() { *m = IpsecItfDeleteReply{} } +func (*IpsecItfDeleteReply) GetMessageName() string { return "ipsec_itf_delete_reply" } +func (*IpsecItfDeleteReply) GetCrcString() string { return "e8d4e804" } +func (*IpsecItfDeleteReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecItfDeleteReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IpsecItfDeleteReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IpsecItfDeleteReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IpsecItfDetails defines message 'ipsec_itf_details'. +type IpsecItfDetails struct { + Itf IpsecItf `binapi:"ipsec_itf,name=itf" json:"itf,omitempty"` +} + +func (m *IpsecItfDetails) Reset() { *m = IpsecItfDetails{} } +func (*IpsecItfDetails) GetMessageName() string { return "ipsec_itf_details" } +func (*IpsecItfDetails) GetCrcString() string { return "548a73b8" } +func (*IpsecItfDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecItfDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Itf.UserInstance + size += 1 // m.Itf.Mode + size += 4 // m.Itf.SwIfIndex + return size +} +func (m *IpsecItfDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Itf.UserInstance) + buf.EncodeUint8(uint8(m.Itf.Mode)) + buf.EncodeUint32(uint32(m.Itf.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *IpsecItfDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Itf.UserInstance = buf.DecodeUint32() + m.Itf.Mode = tunnel_types.TunnelMode(buf.DecodeUint8()) + m.Itf.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// IpsecItfDump defines message 'ipsec_itf_dump'. +type IpsecItfDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *IpsecItfDump) Reset() { *m = IpsecItfDump{} } +func (*IpsecItfDump) GetMessageName() string { return "ipsec_itf_dump" } +func (*IpsecItfDump) GetCrcString() string { return "f9e6675e" } +func (*IpsecItfDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecItfDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *IpsecItfDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *IpsecItfDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// IPsec security association database response +// - entry - The SA details +// - sw_if_index - sw_if_index of tunnel interface, policy-based SAs = ~0 +// - salt - 4 byte salt +// - seq - current sequence number for outbound +// - seq_hi - high 32 bits of ESN for outbound +// - last_seq - highest sequence number received inbound +// - last_seq_hi - high 32 bits of highest ESN received inbound +// - replay_window - bit map of seq nums received relative to last_seq if using anti-replay +// - stat_index - index for the SA in the stats segment @ /net/ipsec/sa +// +// IpsecSaDetails defines message 'ipsec_sa_details'. +// Deprecated: the message will be removed in the future versions +type IpsecSaDetails struct { + Entry ipsec_types.IpsecSadEntry `binapi:"ipsec_sad_entry,name=entry" json:"entry,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Salt uint32 `binapi:"u32,name=salt" json:"salt,omitempty"` + SeqOutbound uint64 `binapi:"u64,name=seq_outbound" json:"seq_outbound,omitempty"` + LastSeqInbound uint64 `binapi:"u64,name=last_seq_inbound" json:"last_seq_inbound,omitempty"` + ReplayWindow uint64 `binapi:"u64,name=replay_window" json:"replay_window,omitempty"` + StatIndex uint32 `binapi:"u32,name=stat_index" json:"stat_index,omitempty"` +} + +func (m *IpsecSaDetails) Reset() { *m = IpsecSaDetails{} } +func (*IpsecSaDetails) GetMessageName() string { return "ipsec_sa_details" } +func (*IpsecSaDetails) GetCrcString() string { return "345d14a7" } +func (*IpsecSaDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecSaDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Entry.SadID + size += 4 // m.Entry.Spi + size += 4 // m.Entry.Protocol + size += 4 // m.Entry.CryptoAlgorithm + size += 1 // m.Entry.CryptoKey.Length + size += 1 * 128 // m.Entry.CryptoKey.Data + size += 4 // m.Entry.IntegrityAlgorithm + size += 1 // m.Entry.IntegrityKey.Length + size += 1 * 128 // m.Entry.IntegrityKey.Data + size += 4 // m.Entry.Flags + size += 1 // m.Entry.TunnelSrc.Af + size += 1 * 16 // m.Entry.TunnelSrc.Un + size += 1 // m.Entry.TunnelDst.Af + size += 1 * 16 // m.Entry.TunnelDst.Un + size += 4 // m.Entry.TxTableID + size += 4 // m.Entry.Salt + size += 2 // m.Entry.UDPSrcPort + size += 2 // m.Entry.UDPDstPort + size += 4 // m.SwIfIndex + size += 4 // m.Salt + size += 8 // m.SeqOutbound + size += 8 // m.LastSeqInbound + size += 8 // m.ReplayWindow + size += 4 // m.StatIndex + return size +} +func (m *IpsecSaDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Entry.SadID) + buf.EncodeUint32(m.Entry.Spi) + buf.EncodeUint32(uint32(m.Entry.Protocol)) + buf.EncodeUint32(uint32(m.Entry.CryptoAlgorithm)) + buf.EncodeUint8(m.Entry.CryptoKey.Length) + buf.EncodeBytes(m.Entry.CryptoKey.Data, 128) + buf.EncodeUint32(uint32(m.Entry.IntegrityAlgorithm)) + buf.EncodeUint8(m.Entry.IntegrityKey.Length) + buf.EncodeBytes(m.Entry.IntegrityKey.Data, 128) + buf.EncodeUint32(uint32(m.Entry.Flags)) + buf.EncodeUint8(uint8(m.Entry.TunnelSrc.Af)) + buf.EncodeBytes(m.Entry.TunnelSrc.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.TunnelDst.Af)) + buf.EncodeBytes(m.Entry.TunnelDst.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.Entry.TxTableID) + buf.EncodeUint32(m.Entry.Salt) + buf.EncodeUint16(m.Entry.UDPSrcPort) + buf.EncodeUint16(m.Entry.UDPDstPort) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.Salt) + buf.EncodeUint64(m.SeqOutbound) + buf.EncodeUint64(m.LastSeqInbound) + buf.EncodeUint64(m.ReplayWindow) + buf.EncodeUint32(m.StatIndex) + return buf.Bytes(), nil +} +func (m *IpsecSaDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Entry.SadID = buf.DecodeUint32() + m.Entry.Spi = buf.DecodeUint32() + m.Entry.Protocol = ipsec_types.IpsecProto(buf.DecodeUint32()) + m.Entry.CryptoAlgorithm = ipsec_types.IpsecCryptoAlg(buf.DecodeUint32()) + m.Entry.CryptoKey.Length = buf.DecodeUint8() + m.Entry.CryptoKey.Data = make([]byte, 128) + copy(m.Entry.CryptoKey.Data, buf.DecodeBytes(len(m.Entry.CryptoKey.Data))) + m.Entry.IntegrityAlgorithm = ipsec_types.IpsecIntegAlg(buf.DecodeUint32()) + m.Entry.IntegrityKey.Length = buf.DecodeUint8() + m.Entry.IntegrityKey.Data = make([]byte, 128) + copy(m.Entry.IntegrityKey.Data, buf.DecodeBytes(len(m.Entry.IntegrityKey.Data))) + m.Entry.Flags = ipsec_types.IpsecSadFlags(buf.DecodeUint32()) + m.Entry.TunnelSrc.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.TunnelSrc.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.TunnelDst.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.TunnelDst.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.TxTableID = buf.DecodeUint32() + m.Entry.Salt = buf.DecodeUint32() + m.Entry.UDPSrcPort = buf.DecodeUint16() + m.Entry.UDPDstPort = buf.DecodeUint16() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Salt = buf.DecodeUint32() + m.SeqOutbound = buf.DecodeUint64() + m.LastSeqInbound = buf.DecodeUint64() + m.ReplayWindow = buf.DecodeUint64() + m.StatIndex = buf.DecodeUint32() + return nil +} + +// Dump IPsec security association +// - sa_id - optional ID of an SA to dump, if ~0 dump all SAs in SAD +// +// IpsecSaDump defines message 'ipsec_sa_dump'. +// Deprecated: the message will be removed in the future versions +type IpsecSaDump struct { + SaID uint32 `binapi:"u32,name=sa_id" json:"sa_id,omitempty"` +} + +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 +} + +func (m *IpsecSaDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SaID + return size +} +func (m *IpsecSaDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.SaID) + return buf.Bytes(), nil +} +func (m *IpsecSaDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SaID = buf.DecodeUint32() + return nil +} + +// IpsecSaV2Details defines message 'ipsec_sa_v2_details'. +type IpsecSaV2Details struct { + Entry ipsec_types.IpsecSadEntryV2 `binapi:"ipsec_sad_entry_v2,name=entry" json:"entry,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Salt uint32 `binapi:"u32,name=salt" json:"salt,omitempty"` + SeqOutbound uint64 `binapi:"u64,name=seq_outbound" json:"seq_outbound,omitempty"` + LastSeqInbound uint64 `binapi:"u64,name=last_seq_inbound" json:"last_seq_inbound,omitempty"` + ReplayWindow uint64 `binapi:"u64,name=replay_window" json:"replay_window,omitempty"` + StatIndex uint32 `binapi:"u32,name=stat_index" json:"stat_index,omitempty"` +} + +func (m *IpsecSaV2Details) Reset() { *m = IpsecSaV2Details{} } +func (*IpsecSaV2Details) GetMessageName() string { return "ipsec_sa_v2_details" } +func (*IpsecSaV2Details) GetCrcString() string { return "e2130051" } +func (*IpsecSaV2Details) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecSaV2Details) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Entry.SadID + size += 4 // m.Entry.Spi + size += 4 // m.Entry.Protocol + size += 4 // m.Entry.CryptoAlgorithm + size += 1 // m.Entry.CryptoKey.Length + size += 1 * 128 // m.Entry.CryptoKey.Data + size += 4 // m.Entry.IntegrityAlgorithm + size += 1 // m.Entry.IntegrityKey.Length + size += 1 * 128 // m.Entry.IntegrityKey.Data + size += 4 // m.Entry.Flags + size += 1 // m.Entry.TunnelSrc.Af + size += 1 * 16 // m.Entry.TunnelSrc.Un + size += 1 // m.Entry.TunnelDst.Af + size += 1 * 16 // m.Entry.TunnelDst.Un + size += 1 // m.Entry.TunnelFlags + size += 1 // m.Entry.Dscp + size += 4 // m.Entry.TxTableID + size += 4 // m.Entry.Salt + size += 2 // m.Entry.UDPSrcPort + size += 2 // m.Entry.UDPDstPort + size += 4 // m.SwIfIndex + size += 4 // m.Salt + size += 8 // m.SeqOutbound + size += 8 // m.LastSeqInbound + size += 8 // m.ReplayWindow + size += 4 // m.StatIndex + return size +} +func (m *IpsecSaV2Details) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Entry.SadID) + buf.EncodeUint32(m.Entry.Spi) + buf.EncodeUint32(uint32(m.Entry.Protocol)) + buf.EncodeUint32(uint32(m.Entry.CryptoAlgorithm)) + buf.EncodeUint8(m.Entry.CryptoKey.Length) + buf.EncodeBytes(m.Entry.CryptoKey.Data, 128) + buf.EncodeUint32(uint32(m.Entry.IntegrityAlgorithm)) + buf.EncodeUint8(m.Entry.IntegrityKey.Length) + buf.EncodeBytes(m.Entry.IntegrityKey.Data, 128) + buf.EncodeUint32(uint32(m.Entry.Flags)) + buf.EncodeUint8(uint8(m.Entry.TunnelSrc.Af)) + buf.EncodeBytes(m.Entry.TunnelSrc.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.TunnelDst.Af)) + buf.EncodeBytes(m.Entry.TunnelDst.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.TunnelFlags)) + buf.EncodeUint8(uint8(m.Entry.Dscp)) + buf.EncodeUint32(m.Entry.TxTableID) + buf.EncodeUint32(m.Entry.Salt) + buf.EncodeUint16(m.Entry.UDPSrcPort) + buf.EncodeUint16(m.Entry.UDPDstPort) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.Salt) + buf.EncodeUint64(m.SeqOutbound) + buf.EncodeUint64(m.LastSeqInbound) + buf.EncodeUint64(m.ReplayWindow) + buf.EncodeUint32(m.StatIndex) + return buf.Bytes(), nil +} +func (m *IpsecSaV2Details) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Entry.SadID = buf.DecodeUint32() + m.Entry.Spi = buf.DecodeUint32() + m.Entry.Protocol = ipsec_types.IpsecProto(buf.DecodeUint32()) + m.Entry.CryptoAlgorithm = ipsec_types.IpsecCryptoAlg(buf.DecodeUint32()) + m.Entry.CryptoKey.Length = buf.DecodeUint8() + m.Entry.CryptoKey.Data = make([]byte, 128) + copy(m.Entry.CryptoKey.Data, buf.DecodeBytes(len(m.Entry.CryptoKey.Data))) + m.Entry.IntegrityAlgorithm = ipsec_types.IpsecIntegAlg(buf.DecodeUint32()) + m.Entry.IntegrityKey.Length = buf.DecodeUint8() + m.Entry.IntegrityKey.Data = make([]byte, 128) + copy(m.Entry.IntegrityKey.Data, buf.DecodeBytes(len(m.Entry.IntegrityKey.Data))) + m.Entry.Flags = ipsec_types.IpsecSadFlags(buf.DecodeUint32()) + m.Entry.TunnelSrc.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.TunnelSrc.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.TunnelDst.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.TunnelDst.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.TunnelFlags = tunnel_types.TunnelEncapDecapFlags(buf.DecodeUint8()) + m.Entry.Dscp = ip_types.IPDscp(buf.DecodeUint8()) + m.Entry.TxTableID = buf.DecodeUint32() + m.Entry.Salt = buf.DecodeUint32() + m.Entry.UDPSrcPort = buf.DecodeUint16() + m.Entry.UDPDstPort = buf.DecodeUint16() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Salt = buf.DecodeUint32() + m.SeqOutbound = buf.DecodeUint64() + m.LastSeqInbound = buf.DecodeUint64() + m.ReplayWindow = buf.DecodeUint64() + m.StatIndex = buf.DecodeUint32() + return nil +} + +// IpsecSaV2Dump defines message 'ipsec_sa_v2_dump'. +type IpsecSaV2Dump struct { + SaID uint32 `binapi:"u32,name=sa_id" json:"sa_id,omitempty"` +} + +func (m *IpsecSaV2Dump) Reset() { *m = IpsecSaV2Dump{} } +func (*IpsecSaV2Dump) GetMessageName() string { return "ipsec_sa_v2_dump" } +func (*IpsecSaV2Dump) GetCrcString() string { return "2076c2f4" } +func (*IpsecSaV2Dump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecSaV2Dump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SaID + return size +} +func (m *IpsecSaV2Dump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.SaID) + return buf.Bytes(), nil +} +func (m *IpsecSaV2Dump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SaID = buf.DecodeUint32() + return nil +} + +// IpsecSaV3Details defines message 'ipsec_sa_v3_details'. +type IpsecSaV3Details struct { + Entry ipsec_types.IpsecSadEntryV3 `binapi:"ipsec_sad_entry_v3,name=entry" json:"entry,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + SeqOutbound uint64 `binapi:"u64,name=seq_outbound" json:"seq_outbound,omitempty"` + LastSeqInbound uint64 `binapi:"u64,name=last_seq_inbound" json:"last_seq_inbound,omitempty"` + ReplayWindow uint64 `binapi:"u64,name=replay_window" json:"replay_window,omitempty"` + StatIndex uint32 `binapi:"u32,name=stat_index" json:"stat_index,omitempty"` +} + +func (m *IpsecSaV3Details) Reset() { *m = IpsecSaV3Details{} } +func (*IpsecSaV3Details) GetMessageName() string { return "ipsec_sa_v3_details" } +func (*IpsecSaV3Details) GetCrcString() string { return "2fc991ee" } +func (*IpsecSaV3Details) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecSaV3Details) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Entry.SadID + size += 4 // m.Entry.Spi + size += 4 // m.Entry.Protocol + size += 4 // m.Entry.CryptoAlgorithm + size += 1 // m.Entry.CryptoKey.Length + size += 1 * 128 // m.Entry.CryptoKey.Data + size += 4 // m.Entry.IntegrityAlgorithm + size += 1 // m.Entry.IntegrityKey.Length + size += 1 * 128 // m.Entry.IntegrityKey.Data + size += 4 // m.Entry.Flags + size += 4 // m.Entry.Tunnel.Instance + size += 1 // m.Entry.Tunnel.Src.Af + size += 1 * 16 // m.Entry.Tunnel.Src.Un + size += 1 // m.Entry.Tunnel.Dst.Af + size += 1 * 16 // m.Entry.Tunnel.Dst.Un + size += 4 // m.Entry.Tunnel.SwIfIndex + size += 4 // m.Entry.Tunnel.TableID + size += 1 // m.Entry.Tunnel.EncapDecapFlags + size += 1 // m.Entry.Tunnel.Mode + size += 1 // m.Entry.Tunnel.Flags + size += 1 // m.Entry.Tunnel.Dscp + size += 1 // m.Entry.Tunnel.HopLimit + size += 4 // m.Entry.Salt + size += 2 // m.Entry.UDPSrcPort + size += 2 // m.Entry.UDPDstPort + size += 4 // m.SwIfIndex + size += 8 // m.SeqOutbound + size += 8 // m.LastSeqInbound + size += 8 // m.ReplayWindow + size += 4 // m.StatIndex + return size +} +func (m *IpsecSaV3Details) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Entry.SadID) + buf.EncodeUint32(m.Entry.Spi) + buf.EncodeUint32(uint32(m.Entry.Protocol)) + buf.EncodeUint32(uint32(m.Entry.CryptoAlgorithm)) + buf.EncodeUint8(m.Entry.CryptoKey.Length) + buf.EncodeBytes(m.Entry.CryptoKey.Data, 128) + buf.EncodeUint32(uint32(m.Entry.IntegrityAlgorithm)) + buf.EncodeUint8(m.Entry.IntegrityKey.Length) + buf.EncodeBytes(m.Entry.IntegrityKey.Data, 128) + buf.EncodeUint32(uint32(m.Entry.Flags)) + buf.EncodeUint32(m.Entry.Tunnel.Instance) + buf.EncodeUint8(uint8(m.Entry.Tunnel.Src.Af)) + buf.EncodeBytes(m.Entry.Tunnel.Src.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.Tunnel.Dst.Af)) + buf.EncodeBytes(m.Entry.Tunnel.Dst.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.Entry.Tunnel.SwIfIndex)) + buf.EncodeUint32(m.Entry.Tunnel.TableID) + buf.EncodeUint8(uint8(m.Entry.Tunnel.EncapDecapFlags)) + buf.EncodeUint8(uint8(m.Entry.Tunnel.Mode)) + buf.EncodeUint8(uint8(m.Entry.Tunnel.Flags)) + buf.EncodeUint8(uint8(m.Entry.Tunnel.Dscp)) + buf.EncodeUint8(m.Entry.Tunnel.HopLimit) + buf.EncodeUint32(m.Entry.Salt) + buf.EncodeUint16(m.Entry.UDPSrcPort) + buf.EncodeUint16(m.Entry.UDPDstPort) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint64(m.SeqOutbound) + buf.EncodeUint64(m.LastSeqInbound) + buf.EncodeUint64(m.ReplayWindow) + buf.EncodeUint32(m.StatIndex) + return buf.Bytes(), nil +} +func (m *IpsecSaV3Details) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Entry.SadID = buf.DecodeUint32() + m.Entry.Spi = buf.DecodeUint32() + m.Entry.Protocol = ipsec_types.IpsecProto(buf.DecodeUint32()) + m.Entry.CryptoAlgorithm = ipsec_types.IpsecCryptoAlg(buf.DecodeUint32()) + m.Entry.CryptoKey.Length = buf.DecodeUint8() + m.Entry.CryptoKey.Data = make([]byte, 128) + copy(m.Entry.CryptoKey.Data, buf.DecodeBytes(len(m.Entry.CryptoKey.Data))) + m.Entry.IntegrityAlgorithm = ipsec_types.IpsecIntegAlg(buf.DecodeUint32()) + m.Entry.IntegrityKey.Length = buf.DecodeUint8() + m.Entry.IntegrityKey.Data = make([]byte, 128) + copy(m.Entry.IntegrityKey.Data, buf.DecodeBytes(len(m.Entry.IntegrityKey.Data))) + m.Entry.Flags = ipsec_types.IpsecSadFlags(buf.DecodeUint32()) + m.Entry.Tunnel.Instance = buf.DecodeUint32() + m.Entry.Tunnel.Src.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.Tunnel.Src.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.Tunnel.Dst.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.Tunnel.Dst.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.Tunnel.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Entry.Tunnel.TableID = buf.DecodeUint32() + m.Entry.Tunnel.EncapDecapFlags = tunnel_types.TunnelEncapDecapFlags(buf.DecodeUint8()) + m.Entry.Tunnel.Mode = tunnel_types.TunnelMode(buf.DecodeUint8()) + m.Entry.Tunnel.Flags = tunnel_types.TunnelFlags(buf.DecodeUint8()) + m.Entry.Tunnel.Dscp = ip_types.IPDscp(buf.DecodeUint8()) + m.Entry.Tunnel.HopLimit = buf.DecodeUint8() + m.Entry.Salt = buf.DecodeUint32() + m.Entry.UDPSrcPort = buf.DecodeUint16() + m.Entry.UDPDstPort = buf.DecodeUint16() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.SeqOutbound = buf.DecodeUint64() + m.LastSeqInbound = buf.DecodeUint64() + m.ReplayWindow = buf.DecodeUint64() + m.StatIndex = buf.DecodeUint32() + return nil +} + +// IpsecSaV3Dump defines message 'ipsec_sa_v3_dump'. +type IpsecSaV3Dump struct { + SaID uint32 `binapi:"u32,name=sa_id" json:"sa_id,omitempty"` +} + +func (m *IpsecSaV3Dump) Reset() { *m = IpsecSaV3Dump{} } +func (*IpsecSaV3Dump) GetMessageName() string { return "ipsec_sa_v3_dump" } +func (*IpsecSaV3Dump) GetCrcString() string { return "2076c2f4" } +func (*IpsecSaV3Dump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecSaV3Dump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SaID + return size +} +func (m *IpsecSaV3Dump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.SaID) + return buf.Bytes(), nil +} +func (m *IpsecSaV3Dump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SaID = buf.DecodeUint32() + return nil +} + +// IpsecSadEntryAdd defines message 'ipsec_sad_entry_add'. +type IpsecSadEntryAdd struct { + Entry ipsec_types.IpsecSadEntryV3 `binapi:"ipsec_sad_entry_v3,name=entry" json:"entry,omitempty"` +} + +func (m *IpsecSadEntryAdd) Reset() { *m = IpsecSadEntryAdd{} } +func (*IpsecSadEntryAdd) GetMessageName() string { return "ipsec_sad_entry_add" } +func (*IpsecSadEntryAdd) GetCrcString() string { return "50229353" } +func (*IpsecSadEntryAdd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecSadEntryAdd) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Entry.SadID + size += 4 // m.Entry.Spi + size += 4 // m.Entry.Protocol + size += 4 // m.Entry.CryptoAlgorithm + size += 1 // m.Entry.CryptoKey.Length + size += 1 * 128 // m.Entry.CryptoKey.Data + size += 4 // m.Entry.IntegrityAlgorithm + size += 1 // m.Entry.IntegrityKey.Length + size += 1 * 128 // m.Entry.IntegrityKey.Data + size += 4 // m.Entry.Flags + size += 4 // m.Entry.Tunnel.Instance + size += 1 // m.Entry.Tunnel.Src.Af + size += 1 * 16 // m.Entry.Tunnel.Src.Un + size += 1 // m.Entry.Tunnel.Dst.Af + size += 1 * 16 // m.Entry.Tunnel.Dst.Un + size += 4 // m.Entry.Tunnel.SwIfIndex + size += 4 // m.Entry.Tunnel.TableID + size += 1 // m.Entry.Tunnel.EncapDecapFlags + size += 1 // m.Entry.Tunnel.Mode + size += 1 // m.Entry.Tunnel.Flags + size += 1 // m.Entry.Tunnel.Dscp + size += 1 // m.Entry.Tunnel.HopLimit + size += 4 // m.Entry.Salt + size += 2 // m.Entry.UDPSrcPort + size += 2 // m.Entry.UDPDstPort + return size +} +func (m *IpsecSadEntryAdd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Entry.SadID) + buf.EncodeUint32(m.Entry.Spi) + buf.EncodeUint32(uint32(m.Entry.Protocol)) + buf.EncodeUint32(uint32(m.Entry.CryptoAlgorithm)) + buf.EncodeUint8(m.Entry.CryptoKey.Length) + buf.EncodeBytes(m.Entry.CryptoKey.Data, 128) + buf.EncodeUint32(uint32(m.Entry.IntegrityAlgorithm)) + buf.EncodeUint8(m.Entry.IntegrityKey.Length) + buf.EncodeBytes(m.Entry.IntegrityKey.Data, 128) + buf.EncodeUint32(uint32(m.Entry.Flags)) + buf.EncodeUint32(m.Entry.Tunnel.Instance) + buf.EncodeUint8(uint8(m.Entry.Tunnel.Src.Af)) + buf.EncodeBytes(m.Entry.Tunnel.Src.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.Tunnel.Dst.Af)) + buf.EncodeBytes(m.Entry.Tunnel.Dst.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.Entry.Tunnel.SwIfIndex)) + buf.EncodeUint32(m.Entry.Tunnel.TableID) + buf.EncodeUint8(uint8(m.Entry.Tunnel.EncapDecapFlags)) + buf.EncodeUint8(uint8(m.Entry.Tunnel.Mode)) + buf.EncodeUint8(uint8(m.Entry.Tunnel.Flags)) + buf.EncodeUint8(uint8(m.Entry.Tunnel.Dscp)) + buf.EncodeUint8(m.Entry.Tunnel.HopLimit) + buf.EncodeUint32(m.Entry.Salt) + buf.EncodeUint16(m.Entry.UDPSrcPort) + buf.EncodeUint16(m.Entry.UDPDstPort) + return buf.Bytes(), nil +} +func (m *IpsecSadEntryAdd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Entry.SadID = buf.DecodeUint32() + m.Entry.Spi = buf.DecodeUint32() + m.Entry.Protocol = ipsec_types.IpsecProto(buf.DecodeUint32()) + m.Entry.CryptoAlgorithm = ipsec_types.IpsecCryptoAlg(buf.DecodeUint32()) + m.Entry.CryptoKey.Length = buf.DecodeUint8() + m.Entry.CryptoKey.Data = make([]byte, 128) + copy(m.Entry.CryptoKey.Data, buf.DecodeBytes(len(m.Entry.CryptoKey.Data))) + m.Entry.IntegrityAlgorithm = ipsec_types.IpsecIntegAlg(buf.DecodeUint32()) + m.Entry.IntegrityKey.Length = buf.DecodeUint8() + m.Entry.IntegrityKey.Data = make([]byte, 128) + copy(m.Entry.IntegrityKey.Data, buf.DecodeBytes(len(m.Entry.IntegrityKey.Data))) + m.Entry.Flags = ipsec_types.IpsecSadFlags(buf.DecodeUint32()) + m.Entry.Tunnel.Instance = buf.DecodeUint32() + m.Entry.Tunnel.Src.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.Tunnel.Src.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.Tunnel.Dst.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.Tunnel.Dst.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.Tunnel.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Entry.Tunnel.TableID = buf.DecodeUint32() + m.Entry.Tunnel.EncapDecapFlags = tunnel_types.TunnelEncapDecapFlags(buf.DecodeUint8()) + m.Entry.Tunnel.Mode = tunnel_types.TunnelMode(buf.DecodeUint8()) + m.Entry.Tunnel.Flags = tunnel_types.TunnelFlags(buf.DecodeUint8()) + m.Entry.Tunnel.Dscp = ip_types.IPDscp(buf.DecodeUint8()) + m.Entry.Tunnel.HopLimit = buf.DecodeUint8() + m.Entry.Salt = buf.DecodeUint32() + m.Entry.UDPSrcPort = buf.DecodeUint16() + m.Entry.UDPDstPort = buf.DecodeUint16() + return nil +} + +// IPsec: Add/delete Security Association Database entry +// - entry - Entry to add or delete +// +// IpsecSadEntryAddDel defines message 'ipsec_sad_entry_add_del'. +// Deprecated: the message will be removed in the future versions +type IpsecSadEntryAddDel struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + Entry ipsec_types.IpsecSadEntry `binapi:"ipsec_sad_entry,name=entry" json:"entry,omitempty"` +} + +func (m *IpsecSadEntryAddDel) Reset() { *m = IpsecSadEntryAddDel{} } +func (*IpsecSadEntryAddDel) GetMessageName() string { return "ipsec_sad_entry_add_del" } +func (*IpsecSadEntryAddDel) GetCrcString() string { return "ab64b5c6" } +func (*IpsecSadEntryAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecSadEntryAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Entry.SadID + size += 4 // m.Entry.Spi + size += 4 // m.Entry.Protocol + size += 4 // m.Entry.CryptoAlgorithm + size += 1 // m.Entry.CryptoKey.Length + size += 1 * 128 // m.Entry.CryptoKey.Data + size += 4 // m.Entry.IntegrityAlgorithm + size += 1 // m.Entry.IntegrityKey.Length + size += 1 * 128 // m.Entry.IntegrityKey.Data + size += 4 // m.Entry.Flags + size += 1 // m.Entry.TunnelSrc.Af + size += 1 * 16 // m.Entry.TunnelSrc.Un + size += 1 // m.Entry.TunnelDst.Af + size += 1 * 16 // m.Entry.TunnelDst.Un + size += 4 // m.Entry.TxTableID + size += 4 // m.Entry.Salt + size += 2 // m.Entry.UDPSrcPort + size += 2 // m.Entry.UDPDstPort + return size +} +func (m *IpsecSadEntryAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.Entry.SadID) + buf.EncodeUint32(m.Entry.Spi) + buf.EncodeUint32(uint32(m.Entry.Protocol)) + buf.EncodeUint32(uint32(m.Entry.CryptoAlgorithm)) + buf.EncodeUint8(m.Entry.CryptoKey.Length) + buf.EncodeBytes(m.Entry.CryptoKey.Data, 128) + buf.EncodeUint32(uint32(m.Entry.IntegrityAlgorithm)) + buf.EncodeUint8(m.Entry.IntegrityKey.Length) + buf.EncodeBytes(m.Entry.IntegrityKey.Data, 128) + buf.EncodeUint32(uint32(m.Entry.Flags)) + buf.EncodeUint8(uint8(m.Entry.TunnelSrc.Af)) + buf.EncodeBytes(m.Entry.TunnelSrc.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.TunnelDst.Af)) + buf.EncodeBytes(m.Entry.TunnelDst.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.Entry.TxTableID) + buf.EncodeUint32(m.Entry.Salt) + buf.EncodeUint16(m.Entry.UDPSrcPort) + buf.EncodeUint16(m.Entry.UDPDstPort) + return buf.Bytes(), nil +} +func (m *IpsecSadEntryAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Entry.SadID = buf.DecodeUint32() + m.Entry.Spi = buf.DecodeUint32() + m.Entry.Protocol = ipsec_types.IpsecProto(buf.DecodeUint32()) + m.Entry.CryptoAlgorithm = ipsec_types.IpsecCryptoAlg(buf.DecodeUint32()) + m.Entry.CryptoKey.Length = buf.DecodeUint8() + m.Entry.CryptoKey.Data = make([]byte, 128) + copy(m.Entry.CryptoKey.Data, buf.DecodeBytes(len(m.Entry.CryptoKey.Data))) + m.Entry.IntegrityAlgorithm = ipsec_types.IpsecIntegAlg(buf.DecodeUint32()) + m.Entry.IntegrityKey.Length = buf.DecodeUint8() + m.Entry.IntegrityKey.Data = make([]byte, 128) + copy(m.Entry.IntegrityKey.Data, buf.DecodeBytes(len(m.Entry.IntegrityKey.Data))) + m.Entry.Flags = ipsec_types.IpsecSadFlags(buf.DecodeUint32()) + m.Entry.TunnelSrc.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.TunnelSrc.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.TunnelDst.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.TunnelDst.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.TxTableID = buf.DecodeUint32() + m.Entry.Salt = buf.DecodeUint32() + m.Entry.UDPSrcPort = buf.DecodeUint16() + m.Entry.UDPDstPort = buf.DecodeUint16() + return nil +} + +// IpsecSadEntryAddDelReply defines message 'ipsec_sad_entry_add_del_reply'. +// Deprecated: the message will be removed in the future versions +type IpsecSadEntryAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + StatIndex uint32 `binapi:"u32,name=stat_index" json:"stat_index,omitempty"` +} + +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 +} + +func (m *IpsecSadEntryAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.StatIndex + return size +} +func (m *IpsecSadEntryAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.StatIndex) + return buf.Bytes(), nil +} +func (m *IpsecSadEntryAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.StatIndex = buf.DecodeUint32() + return nil +} + +// IpsecSadEntryAddDelV2 defines message 'ipsec_sad_entry_add_del_v2'. +type IpsecSadEntryAddDelV2 struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + Entry ipsec_types.IpsecSadEntryV2 `binapi:"ipsec_sad_entry_v2,name=entry" json:"entry,omitempty"` +} + +func (m *IpsecSadEntryAddDelV2) Reset() { *m = IpsecSadEntryAddDelV2{} } +func (*IpsecSadEntryAddDelV2) GetMessageName() string { return "ipsec_sad_entry_add_del_v2" } +func (*IpsecSadEntryAddDelV2) GetCrcString() string { return "aca78b27" } +func (*IpsecSadEntryAddDelV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecSadEntryAddDelV2) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Entry.SadID + size += 4 // m.Entry.Spi + size += 4 // m.Entry.Protocol + size += 4 // m.Entry.CryptoAlgorithm + size += 1 // m.Entry.CryptoKey.Length + size += 1 * 128 // m.Entry.CryptoKey.Data + size += 4 // m.Entry.IntegrityAlgorithm + size += 1 // m.Entry.IntegrityKey.Length + size += 1 * 128 // m.Entry.IntegrityKey.Data + size += 4 // m.Entry.Flags + size += 1 // m.Entry.TunnelSrc.Af + size += 1 * 16 // m.Entry.TunnelSrc.Un + size += 1 // m.Entry.TunnelDst.Af + size += 1 * 16 // m.Entry.TunnelDst.Un + size += 1 // m.Entry.TunnelFlags + size += 1 // m.Entry.Dscp + size += 4 // m.Entry.TxTableID + size += 4 // m.Entry.Salt + size += 2 // m.Entry.UDPSrcPort + size += 2 // m.Entry.UDPDstPort + return size +} +func (m *IpsecSadEntryAddDelV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.Entry.SadID) + buf.EncodeUint32(m.Entry.Spi) + buf.EncodeUint32(uint32(m.Entry.Protocol)) + buf.EncodeUint32(uint32(m.Entry.CryptoAlgorithm)) + buf.EncodeUint8(m.Entry.CryptoKey.Length) + buf.EncodeBytes(m.Entry.CryptoKey.Data, 128) + buf.EncodeUint32(uint32(m.Entry.IntegrityAlgorithm)) + buf.EncodeUint8(m.Entry.IntegrityKey.Length) + buf.EncodeBytes(m.Entry.IntegrityKey.Data, 128) + buf.EncodeUint32(uint32(m.Entry.Flags)) + buf.EncodeUint8(uint8(m.Entry.TunnelSrc.Af)) + buf.EncodeBytes(m.Entry.TunnelSrc.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.TunnelDst.Af)) + buf.EncodeBytes(m.Entry.TunnelDst.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.TunnelFlags)) + buf.EncodeUint8(uint8(m.Entry.Dscp)) + buf.EncodeUint32(m.Entry.TxTableID) + buf.EncodeUint32(m.Entry.Salt) + buf.EncodeUint16(m.Entry.UDPSrcPort) + buf.EncodeUint16(m.Entry.UDPDstPort) + return buf.Bytes(), nil +} +func (m *IpsecSadEntryAddDelV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Entry.SadID = buf.DecodeUint32() + m.Entry.Spi = buf.DecodeUint32() + m.Entry.Protocol = ipsec_types.IpsecProto(buf.DecodeUint32()) + m.Entry.CryptoAlgorithm = ipsec_types.IpsecCryptoAlg(buf.DecodeUint32()) + m.Entry.CryptoKey.Length = buf.DecodeUint8() + m.Entry.CryptoKey.Data = make([]byte, 128) + copy(m.Entry.CryptoKey.Data, buf.DecodeBytes(len(m.Entry.CryptoKey.Data))) + m.Entry.IntegrityAlgorithm = ipsec_types.IpsecIntegAlg(buf.DecodeUint32()) + m.Entry.IntegrityKey.Length = buf.DecodeUint8() + m.Entry.IntegrityKey.Data = make([]byte, 128) + copy(m.Entry.IntegrityKey.Data, buf.DecodeBytes(len(m.Entry.IntegrityKey.Data))) + m.Entry.Flags = ipsec_types.IpsecSadFlags(buf.DecodeUint32()) + m.Entry.TunnelSrc.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.TunnelSrc.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.TunnelDst.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.TunnelDst.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.TunnelFlags = tunnel_types.TunnelEncapDecapFlags(buf.DecodeUint8()) + m.Entry.Dscp = ip_types.IPDscp(buf.DecodeUint8()) + m.Entry.TxTableID = buf.DecodeUint32() + m.Entry.Salt = buf.DecodeUint32() + m.Entry.UDPSrcPort = buf.DecodeUint16() + m.Entry.UDPDstPort = buf.DecodeUint16() + return nil +} + +// IpsecSadEntryAddDelV2Reply defines message 'ipsec_sad_entry_add_del_v2_reply'. +type IpsecSadEntryAddDelV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + StatIndex uint32 `binapi:"u32,name=stat_index" json:"stat_index,omitempty"` +} + +func (m *IpsecSadEntryAddDelV2Reply) Reset() { *m = IpsecSadEntryAddDelV2Reply{} } +func (*IpsecSadEntryAddDelV2Reply) GetMessageName() string { return "ipsec_sad_entry_add_del_v2_reply" } +func (*IpsecSadEntryAddDelV2Reply) GetCrcString() string { return "9ffac24b" } +func (*IpsecSadEntryAddDelV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecSadEntryAddDelV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.StatIndex + return size +} +func (m *IpsecSadEntryAddDelV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.StatIndex) + return buf.Bytes(), nil +} +func (m *IpsecSadEntryAddDelV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.StatIndex = buf.DecodeUint32() + return nil +} + +// IpsecSadEntryAddDelV3 defines message 'ipsec_sad_entry_add_del_v3'. +type IpsecSadEntryAddDelV3 struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + Entry ipsec_types.IpsecSadEntryV3 `binapi:"ipsec_sad_entry_v3,name=entry" json:"entry,omitempty"` +} + +func (m *IpsecSadEntryAddDelV3) Reset() { *m = IpsecSadEntryAddDelV3{} } +func (*IpsecSadEntryAddDelV3) GetMessageName() string { return "ipsec_sad_entry_add_del_v3" } +func (*IpsecSadEntryAddDelV3) GetCrcString() string { return "c77ebd92" } +func (*IpsecSadEntryAddDelV3) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecSadEntryAddDelV3) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Entry.SadID + size += 4 // m.Entry.Spi + size += 4 // m.Entry.Protocol + size += 4 // m.Entry.CryptoAlgorithm + size += 1 // m.Entry.CryptoKey.Length + size += 1 * 128 // m.Entry.CryptoKey.Data + size += 4 // m.Entry.IntegrityAlgorithm + size += 1 // m.Entry.IntegrityKey.Length + size += 1 * 128 // m.Entry.IntegrityKey.Data + size += 4 // m.Entry.Flags + size += 4 // m.Entry.Tunnel.Instance + size += 1 // m.Entry.Tunnel.Src.Af + size += 1 * 16 // m.Entry.Tunnel.Src.Un + size += 1 // m.Entry.Tunnel.Dst.Af + size += 1 * 16 // m.Entry.Tunnel.Dst.Un + size += 4 // m.Entry.Tunnel.SwIfIndex + size += 4 // m.Entry.Tunnel.TableID + size += 1 // m.Entry.Tunnel.EncapDecapFlags + size += 1 // m.Entry.Tunnel.Mode + size += 1 // m.Entry.Tunnel.Flags + size += 1 // m.Entry.Tunnel.Dscp + size += 1 // m.Entry.Tunnel.HopLimit + size += 4 // m.Entry.Salt + size += 2 // m.Entry.UDPSrcPort + size += 2 // m.Entry.UDPDstPort + return size +} +func (m *IpsecSadEntryAddDelV3) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.Entry.SadID) + buf.EncodeUint32(m.Entry.Spi) + buf.EncodeUint32(uint32(m.Entry.Protocol)) + buf.EncodeUint32(uint32(m.Entry.CryptoAlgorithm)) + buf.EncodeUint8(m.Entry.CryptoKey.Length) + buf.EncodeBytes(m.Entry.CryptoKey.Data, 128) + buf.EncodeUint32(uint32(m.Entry.IntegrityAlgorithm)) + buf.EncodeUint8(m.Entry.IntegrityKey.Length) + buf.EncodeBytes(m.Entry.IntegrityKey.Data, 128) + buf.EncodeUint32(uint32(m.Entry.Flags)) + buf.EncodeUint32(m.Entry.Tunnel.Instance) + buf.EncodeUint8(uint8(m.Entry.Tunnel.Src.Af)) + buf.EncodeBytes(m.Entry.Tunnel.Src.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.Tunnel.Dst.Af)) + buf.EncodeBytes(m.Entry.Tunnel.Dst.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.Entry.Tunnel.SwIfIndex)) + buf.EncodeUint32(m.Entry.Tunnel.TableID) + buf.EncodeUint8(uint8(m.Entry.Tunnel.EncapDecapFlags)) + buf.EncodeUint8(uint8(m.Entry.Tunnel.Mode)) + buf.EncodeUint8(uint8(m.Entry.Tunnel.Flags)) + buf.EncodeUint8(uint8(m.Entry.Tunnel.Dscp)) + buf.EncodeUint8(m.Entry.Tunnel.HopLimit) + buf.EncodeUint32(m.Entry.Salt) + buf.EncodeUint16(m.Entry.UDPSrcPort) + buf.EncodeUint16(m.Entry.UDPDstPort) + return buf.Bytes(), nil +} +func (m *IpsecSadEntryAddDelV3) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Entry.SadID = buf.DecodeUint32() + m.Entry.Spi = buf.DecodeUint32() + m.Entry.Protocol = ipsec_types.IpsecProto(buf.DecodeUint32()) + m.Entry.CryptoAlgorithm = ipsec_types.IpsecCryptoAlg(buf.DecodeUint32()) + m.Entry.CryptoKey.Length = buf.DecodeUint8() + m.Entry.CryptoKey.Data = make([]byte, 128) + copy(m.Entry.CryptoKey.Data, buf.DecodeBytes(len(m.Entry.CryptoKey.Data))) + m.Entry.IntegrityAlgorithm = ipsec_types.IpsecIntegAlg(buf.DecodeUint32()) + m.Entry.IntegrityKey.Length = buf.DecodeUint8() + m.Entry.IntegrityKey.Data = make([]byte, 128) + copy(m.Entry.IntegrityKey.Data, buf.DecodeBytes(len(m.Entry.IntegrityKey.Data))) + m.Entry.Flags = ipsec_types.IpsecSadFlags(buf.DecodeUint32()) + m.Entry.Tunnel.Instance = buf.DecodeUint32() + m.Entry.Tunnel.Src.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.Tunnel.Src.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.Tunnel.Dst.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.Tunnel.Dst.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.Tunnel.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Entry.Tunnel.TableID = buf.DecodeUint32() + m.Entry.Tunnel.EncapDecapFlags = tunnel_types.TunnelEncapDecapFlags(buf.DecodeUint8()) + m.Entry.Tunnel.Mode = tunnel_types.TunnelMode(buf.DecodeUint8()) + m.Entry.Tunnel.Flags = tunnel_types.TunnelFlags(buf.DecodeUint8()) + m.Entry.Tunnel.Dscp = ip_types.IPDscp(buf.DecodeUint8()) + m.Entry.Tunnel.HopLimit = buf.DecodeUint8() + m.Entry.Salt = buf.DecodeUint32() + m.Entry.UDPSrcPort = buf.DecodeUint16() + m.Entry.UDPDstPort = buf.DecodeUint16() + return nil +} + +// IpsecSadEntryAddDelV3Reply defines message 'ipsec_sad_entry_add_del_v3_reply'. +type IpsecSadEntryAddDelV3Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + StatIndex uint32 `binapi:"u32,name=stat_index" json:"stat_index,omitempty"` +} + +func (m *IpsecSadEntryAddDelV3Reply) Reset() { *m = IpsecSadEntryAddDelV3Reply{} } +func (*IpsecSadEntryAddDelV3Reply) GetMessageName() string { return "ipsec_sad_entry_add_del_v3_reply" } +func (*IpsecSadEntryAddDelV3Reply) GetCrcString() string { return "9ffac24b" } +func (*IpsecSadEntryAddDelV3Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecSadEntryAddDelV3Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.StatIndex + return size +} +func (m *IpsecSadEntryAddDelV3Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.StatIndex) + return buf.Bytes(), nil +} +func (m *IpsecSadEntryAddDelV3Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.StatIndex = buf.DecodeUint32() + return nil +} + +// IpsecSadEntryAddReply defines message 'ipsec_sad_entry_add_reply'. +type IpsecSadEntryAddReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + StatIndex uint32 `binapi:"u32,name=stat_index" json:"stat_index,omitempty"` +} + +func (m *IpsecSadEntryAddReply) Reset() { *m = IpsecSadEntryAddReply{} } +func (*IpsecSadEntryAddReply) GetMessageName() string { return "ipsec_sad_entry_add_reply" } +func (*IpsecSadEntryAddReply) GetCrcString() string { return "9ffac24b" } +func (*IpsecSadEntryAddReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecSadEntryAddReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.StatIndex + return size +} +func (m *IpsecSadEntryAddReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.StatIndex) + return buf.Bytes(), nil +} +func (m *IpsecSadEntryAddReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.StatIndex = buf.DecodeUint32() + return nil +} + +// IpsecSadEntryDel defines message 'ipsec_sad_entry_del'. +type IpsecSadEntryDel struct { + ID uint32 `binapi:"u32,name=id" json:"id,omitempty"` +} + +func (m *IpsecSadEntryDel) Reset() { *m = IpsecSadEntryDel{} } +func (*IpsecSadEntryDel) GetMessageName() string { return "ipsec_sad_entry_del" } +func (*IpsecSadEntryDel) GetCrcString() string { return "3a91bde5" } +func (*IpsecSadEntryDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecSadEntryDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ID + return size +} +func (m *IpsecSadEntryDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.ID) + return buf.Bytes(), nil +} +func (m *IpsecSadEntryDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ID = buf.DecodeUint32() + return nil +} + +// IpsecSadEntryDelReply defines message 'ipsec_sad_entry_del_reply'. +type IpsecSadEntryDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IpsecSadEntryDelReply) Reset() { *m = IpsecSadEntryDelReply{} } +func (*IpsecSadEntryDelReply) GetMessageName() string { return "ipsec_sad_entry_del_reply" } +func (*IpsecSadEntryDelReply) GetCrcString() string { return "e8d4e804" } +func (*IpsecSadEntryDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecSadEntryDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IpsecSadEntryDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IpsecSadEntryDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// An API to update the tunnel parameters and the ports associated with an SA +// +// Used in the NAT-T case when the NAT data changes +// - sa_id - the id of the SA to update +// - is_tun - update the tunnel if non-zero, else update only the ports +// - tunnel - sender context, to match reply w/ request +// - udp_src_port - new src port for NAT-T. Used if different from 0xffff +// - udp_dst_port - new dst port for NAT-T. Used if different from 0xffff +// +// IpsecSadEntryUpdate defines message 'ipsec_sad_entry_update'. +type IpsecSadEntryUpdate struct { + SadID uint32 `binapi:"u32,name=sad_id" json:"sad_id,omitempty"` + IsTun bool `binapi:"bool,name=is_tun" json:"is_tun,omitempty"` + Tunnel tunnel_types.Tunnel `binapi:"tunnel,name=tunnel" json:"tunnel,omitempty"` + UDPSrcPort uint16 `binapi:"u16,name=udp_src_port,default=65535" json:"udp_src_port,omitempty"` + UDPDstPort uint16 `binapi:"u16,name=udp_dst_port,default=65535" json:"udp_dst_port,omitempty"` +} + +func (m *IpsecSadEntryUpdate) Reset() { *m = IpsecSadEntryUpdate{} } +func (*IpsecSadEntryUpdate) GetMessageName() string { return "ipsec_sad_entry_update" } +func (*IpsecSadEntryUpdate) GetCrcString() string { return "1412af86" } +func (*IpsecSadEntryUpdate) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecSadEntryUpdate) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SadID + size += 1 // m.IsTun + size += 4 // m.Tunnel.Instance + size += 1 // m.Tunnel.Src.Af + size += 1 * 16 // m.Tunnel.Src.Un + size += 1 // m.Tunnel.Dst.Af + size += 1 * 16 // m.Tunnel.Dst.Un + size += 4 // m.Tunnel.SwIfIndex + size += 4 // m.Tunnel.TableID + size += 1 // m.Tunnel.EncapDecapFlags + size += 1 // m.Tunnel.Mode + size += 1 // m.Tunnel.Flags + size += 1 // m.Tunnel.Dscp + size += 1 // m.Tunnel.HopLimit + size += 2 // m.UDPSrcPort + size += 2 // m.UDPDstPort + return size +} +func (m *IpsecSadEntryUpdate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.SadID) + buf.EncodeBool(m.IsTun) + buf.EncodeUint32(m.Tunnel.Instance) + buf.EncodeUint8(uint8(m.Tunnel.Src.Af)) + buf.EncodeBytes(m.Tunnel.Src.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Tunnel.Dst.Af)) + buf.EncodeBytes(m.Tunnel.Dst.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.Tunnel.SwIfIndex)) + buf.EncodeUint32(m.Tunnel.TableID) + buf.EncodeUint8(uint8(m.Tunnel.EncapDecapFlags)) + buf.EncodeUint8(uint8(m.Tunnel.Mode)) + buf.EncodeUint8(uint8(m.Tunnel.Flags)) + buf.EncodeUint8(uint8(m.Tunnel.Dscp)) + buf.EncodeUint8(m.Tunnel.HopLimit) + buf.EncodeUint16(m.UDPSrcPort) + buf.EncodeUint16(m.UDPDstPort) + return buf.Bytes(), nil +} +func (m *IpsecSadEntryUpdate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SadID = buf.DecodeUint32() + m.IsTun = buf.DecodeBool() + m.Tunnel.Instance = buf.DecodeUint32() + m.Tunnel.Src.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Tunnel.Src.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Tunnel.Dst.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Tunnel.Dst.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Tunnel.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Tunnel.TableID = buf.DecodeUint32() + m.Tunnel.EncapDecapFlags = tunnel_types.TunnelEncapDecapFlags(buf.DecodeUint8()) + m.Tunnel.Mode = tunnel_types.TunnelMode(buf.DecodeUint8()) + m.Tunnel.Flags = tunnel_types.TunnelFlags(buf.DecodeUint8()) + m.Tunnel.Dscp = ip_types.IPDscp(buf.DecodeUint8()) + m.Tunnel.HopLimit = buf.DecodeUint8() + m.UDPSrcPort = buf.DecodeUint16() + m.UDPDstPort = buf.DecodeUint16() + return nil +} + +// IpsecSadEntryUpdateReply defines message 'ipsec_sad_entry_update_reply'. +type IpsecSadEntryUpdateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IpsecSadEntryUpdateReply) Reset() { *m = IpsecSadEntryUpdateReply{} } +func (*IpsecSadEntryUpdateReply) GetMessageName() string { return "ipsec_sad_entry_update_reply" } +func (*IpsecSadEntryUpdateReply) GetCrcString() string { return "e8d4e804" } +func (*IpsecSadEntryUpdateReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecSadEntryUpdateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IpsecSadEntryUpdateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IpsecSadEntryUpdateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Select IPsec backend +// - protocol - IPsec protocol (value from ipsec_protocol_t) +// - index - backend index +// +// IpsecSelectBackend defines message 'ipsec_select_backend'. +type IpsecSelectBackend struct { + Protocol ipsec_types.IpsecProto `binapi:"ipsec_proto,name=protocol" json:"protocol,omitempty"` + Index uint8 `binapi:"u8,name=index" json:"index,omitempty"` +} + +func (m *IpsecSelectBackend) Reset() { *m = IpsecSelectBackend{} } +func (*IpsecSelectBackend) GetMessageName() string { return "ipsec_select_backend" } +func (*IpsecSelectBackend) GetCrcString() string { return "5bcfd3b7" } +func (*IpsecSelectBackend) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecSelectBackend) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Protocol + size += 1 // m.Index + return size +} +func (m *IpsecSelectBackend) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Protocol)) + buf.EncodeUint8(m.Index) + return buf.Bytes(), nil +} +func (m *IpsecSelectBackend) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Protocol = ipsec_types.IpsecProto(buf.DecodeUint32()) + m.Index = buf.DecodeUint8() + return nil +} + +// IpsecSelectBackendReply defines message 'ipsec_select_backend_reply'. +type IpsecSelectBackendReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *IpsecSelectBackendReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IpsecSelectBackendReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IpsecSelectBackendReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IPsec Set Async mode +// - async_enable - ipsec async mode on or off +// +// IpsecSetAsyncMode defines message 'ipsec_set_async_mode'. +type IpsecSetAsyncMode struct { + AsyncEnable bool `binapi:"bool,name=async_enable" json:"async_enable,omitempty"` +} + +func (m *IpsecSetAsyncMode) Reset() { *m = IpsecSetAsyncMode{} } +func (*IpsecSetAsyncMode) GetMessageName() string { return "ipsec_set_async_mode" } +func (*IpsecSetAsyncMode) GetCrcString() string { return "a6465f7c" } +func (*IpsecSetAsyncMode) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecSetAsyncMode) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.AsyncEnable + return size +} +func (m *IpsecSetAsyncMode) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.AsyncEnable) + return buf.Bytes(), nil +} +func (m *IpsecSetAsyncMode) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.AsyncEnable = buf.DecodeBool() + return nil +} + +// IpsecSetAsyncModeReply defines message 'ipsec_set_async_mode_reply'. +type IpsecSetAsyncModeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IpsecSetAsyncModeReply) Reset() { *m = IpsecSetAsyncModeReply{} } +func (*IpsecSetAsyncModeReply) GetMessageName() string { return "ipsec_set_async_mode_reply" } +func (*IpsecSetAsyncModeReply) GetCrcString() string { return "e8d4e804" } +func (*IpsecSetAsyncModeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecSetAsyncModeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IpsecSetAsyncModeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IpsecSetAsyncModeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IPsec: Add/delete Security Policy Database +// - is_add - add SPD if non-zero, else delete +// - spd_id - SPD instance id (control plane allocated) +// +// IpsecSpdAddDel defines message 'ipsec_spd_add_del'. +type IpsecSpdAddDel struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + SpdID uint32 `binapi:"u32,name=spd_id" json:"spd_id,omitempty"` +} + +func (m *IpsecSpdAddDel) Reset() { *m = IpsecSpdAddDel{} } +func (*IpsecSpdAddDel) GetMessageName() string { return "ipsec_spd_add_del" } +func (*IpsecSpdAddDel) GetCrcString() string { return "20e89a95" } +func (*IpsecSpdAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecSpdAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.SpdID + return size +} +func (m *IpsecSpdAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.SpdID) + return buf.Bytes(), nil +} +func (m *IpsecSpdAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.SpdID = buf.DecodeUint32() + return nil +} + +// IpsecSpdAddDelReply defines message 'ipsec_spd_add_del_reply'. +type IpsecSpdAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *IpsecSpdAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IpsecSpdAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IpsecSpdAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IPsec policy database response +// +// €param entry - The SPD entry. +// - bytes - byte count of packets matching this policy +// - packets - count of packets matching this policy +// +// IpsecSpdDetails defines message 'ipsec_spd_details'. +type IpsecSpdDetails struct { + Entry ipsec_types.IpsecSpdEntry `binapi:"ipsec_spd_entry,name=entry" json:"entry,omitempty"` +} + +func (m *IpsecSpdDetails) Reset() { *m = IpsecSpdDetails{} } +func (*IpsecSpdDetails) GetMessageName() string { return "ipsec_spd_details" } +func (*IpsecSpdDetails) GetCrcString() string { return "5813d7a2" } +func (*IpsecSpdDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecSpdDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Entry.SpdID + size += 4 // m.Entry.Priority + size += 1 // m.Entry.IsOutbound + size += 4 // m.Entry.SaID + size += 4 // m.Entry.Policy + size += 1 // m.Entry.Protocol + size += 1 // m.Entry.RemoteAddressStart.Af + size += 1 * 16 // m.Entry.RemoteAddressStart.Un + size += 1 // m.Entry.RemoteAddressStop.Af + size += 1 * 16 // m.Entry.RemoteAddressStop.Un + size += 1 // m.Entry.LocalAddressStart.Af + size += 1 * 16 // m.Entry.LocalAddressStart.Un + size += 1 // m.Entry.LocalAddressStop.Af + size += 1 * 16 // m.Entry.LocalAddressStop.Un + size += 2 // m.Entry.RemotePortStart + size += 2 // m.Entry.RemotePortStop + size += 2 // m.Entry.LocalPortStart + size += 2 // m.Entry.LocalPortStop + return size +} +func (m *IpsecSpdDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Entry.SpdID) + buf.EncodeInt32(m.Entry.Priority) + buf.EncodeBool(m.Entry.IsOutbound) + buf.EncodeUint32(m.Entry.SaID) + buf.EncodeUint32(uint32(m.Entry.Policy)) + buf.EncodeUint8(m.Entry.Protocol) + buf.EncodeUint8(uint8(m.Entry.RemoteAddressStart.Af)) + buf.EncodeBytes(m.Entry.RemoteAddressStart.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.RemoteAddressStop.Af)) + buf.EncodeBytes(m.Entry.RemoteAddressStop.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.LocalAddressStart.Af)) + buf.EncodeBytes(m.Entry.LocalAddressStart.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.LocalAddressStop.Af)) + buf.EncodeBytes(m.Entry.LocalAddressStop.Un.XXX_UnionData[:], 16) + buf.EncodeUint16(m.Entry.RemotePortStart) + buf.EncodeUint16(m.Entry.RemotePortStop) + buf.EncodeUint16(m.Entry.LocalPortStart) + buf.EncodeUint16(m.Entry.LocalPortStop) + return buf.Bytes(), nil +} +func (m *IpsecSpdDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Entry.SpdID = buf.DecodeUint32() + m.Entry.Priority = buf.DecodeInt32() + m.Entry.IsOutbound = buf.DecodeBool() + m.Entry.SaID = buf.DecodeUint32() + m.Entry.Policy = ipsec_types.IpsecSpdAction(buf.DecodeUint32()) + m.Entry.Protocol = buf.DecodeUint8() + m.Entry.RemoteAddressStart.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.RemoteAddressStart.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.RemoteAddressStop.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.RemoteAddressStop.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.LocalAddressStart.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.LocalAddressStart.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.LocalAddressStop.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.LocalAddressStop.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.RemotePortStart = buf.DecodeUint16() + m.Entry.RemotePortStop = buf.DecodeUint16() + m.Entry.LocalPortStart = buf.DecodeUint16() + m.Entry.LocalPortStop = buf.DecodeUint16() + return nil +} + +// Dump ipsec policy database data +// - spd_id - SPD instance id +// - sa_id - SA id, optional, set to ~0 to see all policies in SPD +// +// IpsecSpdDump defines message 'ipsec_spd_dump'. +type IpsecSpdDump struct { + SpdID uint32 `binapi:"u32,name=spd_id" json:"spd_id,omitempty"` + SaID uint32 `binapi:"u32,name=sa_id" json:"sa_id,omitempty"` +} + +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 +} + +func (m *IpsecSpdDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SpdID + size += 4 // m.SaID + return size +} +func (m *IpsecSpdDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.SpdID) + buf.EncodeUint32(m.SaID) + return buf.Bytes(), nil +} +func (m *IpsecSpdDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SpdID = buf.DecodeUint32() + m.SaID = buf.DecodeUint32() + return nil +} + +// IPsec: Add/delete Security Policy Database entry +// - is_add - add SPD if non-zero, else delete +// - entry - Description of the entry to add/dell +// +// IpsecSpdEntryAddDel defines message 'ipsec_spd_entry_add_del'. +// Deprecated: the message will be removed in the future versions +type IpsecSpdEntryAddDel struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + Entry ipsec_types.IpsecSpdEntry `binapi:"ipsec_spd_entry,name=entry" json:"entry,omitempty"` +} + +func (m *IpsecSpdEntryAddDel) Reset() { *m = IpsecSpdEntryAddDel{} } +func (*IpsecSpdEntryAddDel) GetMessageName() string { return "ipsec_spd_entry_add_del" } +func (*IpsecSpdEntryAddDel) GetCrcString() string { return "338b7411" } +func (*IpsecSpdEntryAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecSpdEntryAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Entry.SpdID + size += 4 // m.Entry.Priority + size += 1 // m.Entry.IsOutbound + size += 4 // m.Entry.SaID + size += 4 // m.Entry.Policy + size += 1 // m.Entry.Protocol + size += 1 // m.Entry.RemoteAddressStart.Af + size += 1 * 16 // m.Entry.RemoteAddressStart.Un + size += 1 // m.Entry.RemoteAddressStop.Af + size += 1 * 16 // m.Entry.RemoteAddressStop.Un + size += 1 // m.Entry.LocalAddressStart.Af + size += 1 * 16 // m.Entry.LocalAddressStart.Un + size += 1 // m.Entry.LocalAddressStop.Af + size += 1 * 16 // m.Entry.LocalAddressStop.Un + size += 2 // m.Entry.RemotePortStart + size += 2 // m.Entry.RemotePortStop + size += 2 // m.Entry.LocalPortStart + size += 2 // m.Entry.LocalPortStop + return size +} +func (m *IpsecSpdEntryAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.Entry.SpdID) + buf.EncodeInt32(m.Entry.Priority) + buf.EncodeBool(m.Entry.IsOutbound) + buf.EncodeUint32(m.Entry.SaID) + buf.EncodeUint32(uint32(m.Entry.Policy)) + buf.EncodeUint8(m.Entry.Protocol) + buf.EncodeUint8(uint8(m.Entry.RemoteAddressStart.Af)) + buf.EncodeBytes(m.Entry.RemoteAddressStart.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.RemoteAddressStop.Af)) + buf.EncodeBytes(m.Entry.RemoteAddressStop.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.LocalAddressStart.Af)) + buf.EncodeBytes(m.Entry.LocalAddressStart.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.LocalAddressStop.Af)) + buf.EncodeBytes(m.Entry.LocalAddressStop.Un.XXX_UnionData[:], 16) + buf.EncodeUint16(m.Entry.RemotePortStart) + buf.EncodeUint16(m.Entry.RemotePortStop) + buf.EncodeUint16(m.Entry.LocalPortStart) + buf.EncodeUint16(m.Entry.LocalPortStop) + return buf.Bytes(), nil +} +func (m *IpsecSpdEntryAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Entry.SpdID = buf.DecodeUint32() + m.Entry.Priority = buf.DecodeInt32() + m.Entry.IsOutbound = buf.DecodeBool() + m.Entry.SaID = buf.DecodeUint32() + m.Entry.Policy = ipsec_types.IpsecSpdAction(buf.DecodeUint32()) + m.Entry.Protocol = buf.DecodeUint8() + m.Entry.RemoteAddressStart.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.RemoteAddressStart.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.RemoteAddressStop.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.RemoteAddressStop.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.LocalAddressStart.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.LocalAddressStart.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.LocalAddressStop.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.LocalAddressStop.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.RemotePortStart = buf.DecodeUint16() + m.Entry.RemotePortStop = buf.DecodeUint16() + m.Entry.LocalPortStart = buf.DecodeUint16() + m.Entry.LocalPortStop = buf.DecodeUint16() + return nil +} + +// IPsec: Reply Add/delete Security Policy Database entry +// - retval - success/fail rutrun code +// - stat_index - An index for the policy in the stats segment @ /net/ipec/policy +// +// IpsecSpdEntryAddDelReply defines message 'ipsec_spd_entry_add_del_reply'. +// Deprecated: the message will be removed in the future versions +type IpsecSpdEntryAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + StatIndex uint32 `binapi:"u32,name=stat_index" json:"stat_index,omitempty"` +} + +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 +} + +func (m *IpsecSpdEntryAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.StatIndex + return size +} +func (m *IpsecSpdEntryAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.StatIndex) + return buf.Bytes(), nil +} +func (m *IpsecSpdEntryAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.StatIndex = buf.DecodeUint32() + return nil +} + +// IPsec: Add/delete Security Policy Database entry v2 +// - is_add - add SPD if non-zero, else delete +// - entry - Description of the entry to add/dell +// +// IpsecSpdEntryAddDelV2 defines message 'ipsec_spd_entry_add_del_v2'. +type IpsecSpdEntryAddDelV2 struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + Entry ipsec_types.IpsecSpdEntryV2 `binapi:"ipsec_spd_entry_v2,name=entry" json:"entry,omitempty"` +} + +func (m *IpsecSpdEntryAddDelV2) Reset() { *m = IpsecSpdEntryAddDelV2{} } +func (*IpsecSpdEntryAddDelV2) GetMessageName() string { return "ipsec_spd_entry_add_del_v2" } +func (*IpsecSpdEntryAddDelV2) GetCrcString() string { return "7bfe69fc" } +func (*IpsecSpdEntryAddDelV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecSpdEntryAddDelV2) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Entry.SpdID + size += 4 // m.Entry.Priority + size += 1 // m.Entry.IsOutbound + size += 4 // m.Entry.SaID + size += 4 // m.Entry.Policy + size += 1 // m.Entry.Protocol + size += 1 // m.Entry.RemoteAddressStart.Af + size += 1 * 16 // m.Entry.RemoteAddressStart.Un + size += 1 // m.Entry.RemoteAddressStop.Af + size += 1 * 16 // m.Entry.RemoteAddressStop.Un + size += 1 // m.Entry.LocalAddressStart.Af + size += 1 * 16 // m.Entry.LocalAddressStart.Un + size += 1 // m.Entry.LocalAddressStop.Af + size += 1 * 16 // m.Entry.LocalAddressStop.Un + size += 2 // m.Entry.RemotePortStart + size += 2 // m.Entry.RemotePortStop + size += 2 // m.Entry.LocalPortStart + size += 2 // m.Entry.LocalPortStop + return size +} +func (m *IpsecSpdEntryAddDelV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.Entry.SpdID) + buf.EncodeInt32(m.Entry.Priority) + buf.EncodeBool(m.Entry.IsOutbound) + buf.EncodeUint32(m.Entry.SaID) + buf.EncodeUint32(uint32(m.Entry.Policy)) + buf.EncodeUint8(m.Entry.Protocol) + buf.EncodeUint8(uint8(m.Entry.RemoteAddressStart.Af)) + buf.EncodeBytes(m.Entry.RemoteAddressStart.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.RemoteAddressStop.Af)) + buf.EncodeBytes(m.Entry.RemoteAddressStop.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.LocalAddressStart.Af)) + buf.EncodeBytes(m.Entry.LocalAddressStart.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Entry.LocalAddressStop.Af)) + buf.EncodeBytes(m.Entry.LocalAddressStop.Un.XXX_UnionData[:], 16) + buf.EncodeUint16(m.Entry.RemotePortStart) + buf.EncodeUint16(m.Entry.RemotePortStop) + buf.EncodeUint16(m.Entry.LocalPortStart) + buf.EncodeUint16(m.Entry.LocalPortStop) + return buf.Bytes(), nil +} +func (m *IpsecSpdEntryAddDelV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Entry.SpdID = buf.DecodeUint32() + m.Entry.Priority = buf.DecodeInt32() + m.Entry.IsOutbound = buf.DecodeBool() + m.Entry.SaID = buf.DecodeUint32() + m.Entry.Policy = ipsec_types.IpsecSpdAction(buf.DecodeUint32()) + m.Entry.Protocol = buf.DecodeUint8() + m.Entry.RemoteAddressStart.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.RemoteAddressStart.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.RemoteAddressStop.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.RemoteAddressStop.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.LocalAddressStart.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.LocalAddressStart.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.LocalAddressStop.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entry.LocalAddressStop.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Entry.RemotePortStart = buf.DecodeUint16() + m.Entry.RemotePortStop = buf.DecodeUint16() + m.Entry.LocalPortStart = buf.DecodeUint16() + m.Entry.LocalPortStop = buf.DecodeUint16() + return nil +} + +// IPsec: Reply Add/delete Security Policy Database entry v2 +// - retval - success/fail rutrun code +// - stat_index - An index for the policy in the stats segment @ /net/ipec/policy +// +// IpsecSpdEntryAddDelV2Reply defines message 'ipsec_spd_entry_add_del_v2_reply'. +type IpsecSpdEntryAddDelV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + StatIndex uint32 `binapi:"u32,name=stat_index" json:"stat_index,omitempty"` +} + +func (m *IpsecSpdEntryAddDelV2Reply) Reset() { *m = IpsecSpdEntryAddDelV2Reply{} } +func (*IpsecSpdEntryAddDelV2Reply) GetMessageName() string { return "ipsec_spd_entry_add_del_v2_reply" } +func (*IpsecSpdEntryAddDelV2Reply) GetCrcString() string { return "9ffac24b" } +func (*IpsecSpdEntryAddDelV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecSpdEntryAddDelV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.StatIndex + return size +} +func (m *IpsecSpdEntryAddDelV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.StatIndex) + return buf.Bytes(), nil +} +func (m *IpsecSpdEntryAddDelV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.StatIndex = buf.DecodeUint32() + return nil +} + +// IPsec: SPD interface response +// - spd_index - SPD index +// - sw_if_index - index of the interface +// +// IpsecSpdInterfaceDetails defines message 'ipsec_spd_interface_details'. +type IpsecSpdInterfaceDetails struct { + SpdIndex uint32 `binapi:"u32,name=spd_index" json:"spd_index,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *IpsecSpdInterfaceDetails) Reset() { *m = IpsecSpdInterfaceDetails{} } +func (*IpsecSpdInterfaceDetails) GetMessageName() string { return "ipsec_spd_interface_details" } +func (*IpsecSpdInterfaceDetails) GetCrcString() string { return "7a0bcf3e" } +func (*IpsecSpdInterfaceDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecSpdInterfaceDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SpdIndex + size += 4 // m.SwIfIndex + return size +} +func (m *IpsecSpdInterfaceDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.SpdIndex) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *IpsecSpdInterfaceDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SpdIndex = buf.DecodeUint32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// IPsec: Get SPD interfaces +// - spd_index - SPD index +// - spd_index_valid - if 1 spd_index is used to filter +// spd_index's, if 0 no filtering is done +// +// IpsecSpdInterfaceDump defines message 'ipsec_spd_interface_dump'. +type IpsecSpdInterfaceDump struct { + SpdIndex uint32 `binapi:"u32,name=spd_index" json:"spd_index,omitempty"` + SpdIndexValid uint8 `binapi:"u8,name=spd_index_valid" json:"spd_index_valid,omitempty"` +} + +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 +} + +func (m *IpsecSpdInterfaceDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SpdIndex + size += 1 // m.SpdIndexValid + return size +} +func (m *IpsecSpdInterfaceDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.SpdIndex) + buf.EncodeUint8(m.SpdIndexValid) + return buf.Bytes(), nil +} +func (m *IpsecSpdInterfaceDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SpdIndex = buf.DecodeUint32() + m.SpdIndexValid = buf.DecodeUint8() + return nil +} + +// Dump IPsec all SPD IDs response +// - spd_id - SPD instance id (control plane allocated) +// - npolicies - number of policies in SPD +// +// IpsecSpdsDetails defines message 'ipsec_spds_details'. +type IpsecSpdsDetails struct { + SpdID uint32 `binapi:"u32,name=spd_id" json:"spd_id,omitempty"` + Npolicies uint32 `binapi:"u32,name=npolicies" json:"npolicies,omitempty"` +} + +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 +} + +func (m *IpsecSpdsDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SpdID + size += 4 // m.Npolicies + return size +} +func (m *IpsecSpdsDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.SpdID) + buf.EncodeUint32(m.Npolicies) + return buf.Bytes(), nil +} +func (m *IpsecSpdsDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SpdID = buf.DecodeUint32() + m.Npolicies = buf.DecodeUint32() + return nil +} + +// Dump IPsec all SPD IDs +// IpsecSpdsDump defines 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 +} + +func (m *IpsecSpdsDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *IpsecSpdsDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *IpsecSpdsDump) Unmarshal(b []byte) error { + return nil +} + +// IpsecTunnelProtectDel defines message 'ipsec_tunnel_protect_del'. +type IpsecTunnelProtectDel struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Nh ip_types.Address `binapi:"address,name=nh" json:"nh,omitempty"` +} + +func (m *IpsecTunnelProtectDel) Reset() { *m = IpsecTunnelProtectDel{} } +func (*IpsecTunnelProtectDel) GetMessageName() string { return "ipsec_tunnel_protect_del" } +func (*IpsecTunnelProtectDel) GetCrcString() string { return "cd239930" } +func (*IpsecTunnelProtectDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecTunnelProtectDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.Nh.Af + size += 1 * 16 // m.Nh.Un + return size +} +func (m *IpsecTunnelProtectDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(uint8(m.Nh.Af)) + buf.EncodeBytes(m.Nh.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *IpsecTunnelProtectDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Nh.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Nh.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// IpsecTunnelProtectDelReply defines message 'ipsec_tunnel_protect_del_reply'. +type IpsecTunnelProtectDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *IpsecTunnelProtectDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IpsecTunnelProtectDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IpsecTunnelProtectDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IpsecTunnelProtectDetails defines message 'ipsec_tunnel_protect_details'. +type IpsecTunnelProtectDetails struct { + Tun IpsecTunnelProtect `binapi:"ipsec_tunnel_protect,name=tun" json:"tun,omitempty"` +} + +func (m *IpsecTunnelProtectDetails) Reset() { *m = IpsecTunnelProtectDetails{} } +func (*IpsecTunnelProtectDetails) GetMessageName() string { return "ipsec_tunnel_protect_details" } +func (*IpsecTunnelProtectDetails) GetCrcString() string { return "21663a50" } +func (*IpsecTunnelProtectDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpsecTunnelProtectDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Tun.SwIfIndex + size += 1 // m.Tun.Nh.Af + size += 1 * 16 // m.Tun.Nh.Un + size += 4 // m.Tun.SaOut + size += 1 // m.Tun.NSaIn + size += 4 * len(m.Tun.SaIn) // m.Tun.SaIn + return size +} +func (m *IpsecTunnelProtectDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Tun.SwIfIndex)) + buf.EncodeUint8(uint8(m.Tun.Nh.Af)) + buf.EncodeBytes(m.Tun.Nh.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.Tun.SaOut) + buf.EncodeUint8(uint8(len(m.Tun.SaIn))) + for i := 0; i < len(m.Tun.SaIn); i++ { + var x uint32 + if i < len(m.Tun.SaIn) { + x = uint32(m.Tun.SaIn[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *IpsecTunnelProtectDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Tun.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Tun.Nh.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Tun.Nh.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Tun.SaOut = buf.DecodeUint32() + m.Tun.NSaIn = buf.DecodeUint8() + m.Tun.SaIn = make([]uint32, m.Tun.NSaIn) + for i := 0; i < len(m.Tun.SaIn); i++ { + m.Tun.SaIn[i] = buf.DecodeUint32() + } + return nil +} + +// * @brief Dump all tunnel protections +// IpsecTunnelProtectDump defines message 'ipsec_tunnel_protect_dump'. +type IpsecTunnelProtectDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *IpsecTunnelProtectDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *IpsecTunnelProtectDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *IpsecTunnelProtectDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Add or Update Protection for a tunnel with IPSEC +// +// Tunnel protection directly associates an SA with all packets +// ingress and egress on the tunnel. This could also be achieved by +// assigning an SPD to the tunnel, but that would incur an unnessccary +// SPD entry lookup. +// For tunnels the ESP acts on the post-encapsulated packet. So if this +// packet: +// +---------+------+ +// | Payload | O-IP | +// +---------+------+ +// where O-IP is the overlay IP addrees that was routed into the tunnel, +// the resulting encapsulated packet will be: +// +---------+------+------+ +// | Payload | O-IP | T-IP | +// +---------+------+------+ +// where T-IP is the tunnel's src.dst IP addresses. +// If the SAs used for protection are in transport mode then the ESP is +// inserted before T-IP, i.e.: +// +---------+------+-----+------+ +// | Payload | O-IP | ESP | T-IP | +// +---------+------+-----+------+ +// If the SAs used for protection are in tunnel mode then another +// encapsulation occurs, i.e.: +// +---------+------+------+-----+------+ +// | Payload | O-IP | T-IP | ESP | C-IP | +// +---------+------+------+-----+------+ +// where C-IP are the crypto endpoint IP addresses defined as the tunnel +// endpoints in the SA. +// The mode for the inbound and outbound SA must be the same. +// - sw_id_index - Tunnel interface to protect +// - nh - The peer/next-hop on the tunnel to which the traffic +// should be protected. For a P2P interface set this to the +// all 0s address. +// - sa_in - The ID [set] of inbound SAs +// - sa_out - The ID of outbound SA +// +// IpsecTunnelProtectUpdate defines message 'ipsec_tunnel_protect_update'. +type IpsecTunnelProtectUpdate struct { + Tunnel IpsecTunnelProtect `binapi:"ipsec_tunnel_protect,name=tunnel" json:"tunnel,omitempty"` +} + +func (m *IpsecTunnelProtectUpdate) Reset() { *m = IpsecTunnelProtectUpdate{} } +func (*IpsecTunnelProtectUpdate) GetMessageName() string { return "ipsec_tunnel_protect_update" } +func (*IpsecTunnelProtectUpdate) GetCrcString() string { return "30d5f133" } +func (*IpsecTunnelProtectUpdate) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpsecTunnelProtectUpdate) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Tunnel.SwIfIndex + size += 1 // m.Tunnel.Nh.Af + size += 1 * 16 // m.Tunnel.Nh.Un + size += 4 // m.Tunnel.SaOut + size += 1 // m.Tunnel.NSaIn + size += 4 * len(m.Tunnel.SaIn) // m.Tunnel.SaIn + return size +} +func (m *IpsecTunnelProtectUpdate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Tunnel.SwIfIndex)) + buf.EncodeUint8(uint8(m.Tunnel.Nh.Af)) + buf.EncodeBytes(m.Tunnel.Nh.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.Tunnel.SaOut) + buf.EncodeUint8(uint8(len(m.Tunnel.SaIn))) + for i := 0; i < len(m.Tunnel.SaIn); i++ { + var x uint32 + if i < len(m.Tunnel.SaIn) { + x = uint32(m.Tunnel.SaIn[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *IpsecTunnelProtectUpdate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Tunnel.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Tunnel.Nh.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Tunnel.Nh.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Tunnel.SaOut = buf.DecodeUint32() + m.Tunnel.NSaIn = buf.DecodeUint8() + m.Tunnel.SaIn = make([]uint32, m.Tunnel.NSaIn) + for i := 0; i < len(m.Tunnel.SaIn); i++ { + m.Tunnel.SaIn[i] = buf.DecodeUint32() + } + return nil +} + +// IpsecTunnelProtectUpdateReply defines message 'ipsec_tunnel_protect_update_reply'. +type IpsecTunnelProtectUpdateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 (m *IpsecTunnelProtectUpdateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IpsecTunnelProtectUpdateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IpsecTunnelProtectUpdateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_ipsec_binapi_init() } +func file_ipsec_binapi_init() { + api.RegisterMessage((*IpsecBackendDetails)(nil), "ipsec_backend_details_ee601c29") + api.RegisterMessage((*IpsecBackendDump)(nil), "ipsec_backend_dump_51077d14") + api.RegisterMessage((*IpsecInterfaceAddDelSpd)(nil), "ipsec_interface_add_del_spd_80f80cbb") + api.RegisterMessage((*IpsecInterfaceAddDelSpdReply)(nil), "ipsec_interface_add_del_spd_reply_e8d4e804") + api.RegisterMessage((*IpsecItfCreate)(nil), "ipsec_itf_create_6f50b3bc") + api.RegisterMessage((*IpsecItfCreateReply)(nil), "ipsec_itf_create_reply_5383d31f") + api.RegisterMessage((*IpsecItfDelete)(nil), "ipsec_itf_delete_f9e6675e") + api.RegisterMessage((*IpsecItfDeleteReply)(nil), "ipsec_itf_delete_reply_e8d4e804") + api.RegisterMessage((*IpsecItfDetails)(nil), "ipsec_itf_details_548a73b8") + api.RegisterMessage((*IpsecItfDump)(nil), "ipsec_itf_dump_f9e6675e") + api.RegisterMessage((*IpsecSaDetails)(nil), "ipsec_sa_details_345d14a7") + api.RegisterMessage((*IpsecSaDump)(nil), "ipsec_sa_dump_2076c2f4") + api.RegisterMessage((*IpsecSaV2Details)(nil), "ipsec_sa_v2_details_e2130051") + api.RegisterMessage((*IpsecSaV2Dump)(nil), "ipsec_sa_v2_dump_2076c2f4") + api.RegisterMessage((*IpsecSaV3Details)(nil), "ipsec_sa_v3_details_2fc991ee") + api.RegisterMessage((*IpsecSaV3Dump)(nil), "ipsec_sa_v3_dump_2076c2f4") + api.RegisterMessage((*IpsecSadEntryAdd)(nil), "ipsec_sad_entry_add_50229353") + api.RegisterMessage((*IpsecSadEntryAddDel)(nil), "ipsec_sad_entry_add_del_ab64b5c6") + api.RegisterMessage((*IpsecSadEntryAddDelReply)(nil), "ipsec_sad_entry_add_del_reply_9ffac24b") + api.RegisterMessage((*IpsecSadEntryAddDelV2)(nil), "ipsec_sad_entry_add_del_v2_aca78b27") + api.RegisterMessage((*IpsecSadEntryAddDelV2Reply)(nil), "ipsec_sad_entry_add_del_v2_reply_9ffac24b") + api.RegisterMessage((*IpsecSadEntryAddDelV3)(nil), "ipsec_sad_entry_add_del_v3_c77ebd92") + api.RegisterMessage((*IpsecSadEntryAddDelV3Reply)(nil), "ipsec_sad_entry_add_del_v3_reply_9ffac24b") + api.RegisterMessage((*IpsecSadEntryAddReply)(nil), "ipsec_sad_entry_add_reply_9ffac24b") + api.RegisterMessage((*IpsecSadEntryDel)(nil), "ipsec_sad_entry_del_3a91bde5") + api.RegisterMessage((*IpsecSadEntryDelReply)(nil), "ipsec_sad_entry_del_reply_e8d4e804") + api.RegisterMessage((*IpsecSadEntryUpdate)(nil), "ipsec_sad_entry_update_1412af86") + api.RegisterMessage((*IpsecSadEntryUpdateReply)(nil), "ipsec_sad_entry_update_reply_e8d4e804") + api.RegisterMessage((*IpsecSelectBackend)(nil), "ipsec_select_backend_5bcfd3b7") + api.RegisterMessage((*IpsecSelectBackendReply)(nil), "ipsec_select_backend_reply_e8d4e804") + api.RegisterMessage((*IpsecSetAsyncMode)(nil), "ipsec_set_async_mode_a6465f7c") + api.RegisterMessage((*IpsecSetAsyncModeReply)(nil), "ipsec_set_async_mode_reply_e8d4e804") + api.RegisterMessage((*IpsecSpdAddDel)(nil), "ipsec_spd_add_del_20e89a95") + api.RegisterMessage((*IpsecSpdAddDelReply)(nil), "ipsec_spd_add_del_reply_e8d4e804") + api.RegisterMessage((*IpsecSpdDetails)(nil), "ipsec_spd_details_5813d7a2") + api.RegisterMessage((*IpsecSpdDump)(nil), "ipsec_spd_dump_afefbf7d") + api.RegisterMessage((*IpsecSpdEntryAddDel)(nil), "ipsec_spd_entry_add_del_338b7411") + api.RegisterMessage((*IpsecSpdEntryAddDelReply)(nil), "ipsec_spd_entry_add_del_reply_9ffac24b") + api.RegisterMessage((*IpsecSpdEntryAddDelV2)(nil), "ipsec_spd_entry_add_del_v2_7bfe69fc") + api.RegisterMessage((*IpsecSpdEntryAddDelV2Reply)(nil), "ipsec_spd_entry_add_del_v2_reply_9ffac24b") + api.RegisterMessage((*IpsecSpdInterfaceDetails)(nil), "ipsec_spd_interface_details_7a0bcf3e") + api.RegisterMessage((*IpsecSpdInterfaceDump)(nil), "ipsec_spd_interface_dump_8971de19") + api.RegisterMessage((*IpsecSpdsDetails)(nil), "ipsec_spds_details_a04bb254") + api.RegisterMessage((*IpsecSpdsDump)(nil), "ipsec_spds_dump_51077d14") + api.RegisterMessage((*IpsecTunnelProtectDel)(nil), "ipsec_tunnel_protect_del_cd239930") + api.RegisterMessage((*IpsecTunnelProtectDelReply)(nil), "ipsec_tunnel_protect_del_reply_e8d4e804") + api.RegisterMessage((*IpsecTunnelProtectDetails)(nil), "ipsec_tunnel_protect_details_21663a50") + api.RegisterMessage((*IpsecTunnelProtectDump)(nil), "ipsec_tunnel_protect_dump_f9e6675e") + api.RegisterMessage((*IpsecTunnelProtectUpdate)(nil), "ipsec_tunnel_protect_update_30d5f133") + api.RegisterMessage((*IpsecTunnelProtectUpdateReply)(nil), "ipsec_tunnel_protect_update_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*IpsecBackendDetails)(nil), + (*IpsecBackendDump)(nil), + (*IpsecInterfaceAddDelSpd)(nil), + (*IpsecInterfaceAddDelSpdReply)(nil), + (*IpsecItfCreate)(nil), + (*IpsecItfCreateReply)(nil), + (*IpsecItfDelete)(nil), + (*IpsecItfDeleteReply)(nil), + (*IpsecItfDetails)(nil), + (*IpsecItfDump)(nil), + (*IpsecSaDetails)(nil), + (*IpsecSaDump)(nil), + (*IpsecSaV2Details)(nil), + (*IpsecSaV2Dump)(nil), + (*IpsecSaV3Details)(nil), + (*IpsecSaV3Dump)(nil), + (*IpsecSadEntryAdd)(nil), + (*IpsecSadEntryAddDel)(nil), + (*IpsecSadEntryAddDelReply)(nil), + (*IpsecSadEntryAddDelV2)(nil), + (*IpsecSadEntryAddDelV2Reply)(nil), + (*IpsecSadEntryAddDelV3)(nil), + (*IpsecSadEntryAddDelV3Reply)(nil), + (*IpsecSadEntryAddReply)(nil), + (*IpsecSadEntryDel)(nil), + (*IpsecSadEntryDelReply)(nil), + (*IpsecSadEntryUpdate)(nil), + (*IpsecSadEntryUpdateReply)(nil), + (*IpsecSelectBackend)(nil), + (*IpsecSelectBackendReply)(nil), + (*IpsecSetAsyncMode)(nil), + (*IpsecSetAsyncModeReply)(nil), + (*IpsecSpdAddDel)(nil), + (*IpsecSpdAddDelReply)(nil), + (*IpsecSpdDetails)(nil), + (*IpsecSpdDump)(nil), + (*IpsecSpdEntryAddDel)(nil), + (*IpsecSpdEntryAddDelReply)(nil), + (*IpsecSpdEntryAddDelV2)(nil), + (*IpsecSpdEntryAddDelV2Reply)(nil), + (*IpsecSpdInterfaceDetails)(nil), + (*IpsecSpdInterfaceDump)(nil), + (*IpsecSpdsDetails)(nil), + (*IpsecSpdsDump)(nil), + (*IpsecTunnelProtectDel)(nil), + (*IpsecTunnelProtectDelReply)(nil), + (*IpsecTunnelProtectDetails)(nil), + (*IpsecTunnelProtectDump)(nil), + (*IpsecTunnelProtectUpdate)(nil), + (*IpsecTunnelProtectUpdateReply)(nil), + } +} diff --git a/binapi/ipsec/ipsec_rpc.ba.go b/binapi/ipsec/ipsec_rpc.ba.go new file mode 100644 index 00000000..6aab5ce3 --- /dev/null +++ b/binapi/ipsec/ipsec_rpc.ba.go @@ -0,0 +1,580 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package ipsec + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service ipsec. +type RPCService interface { + IpsecBackendDump(ctx context.Context, in *IpsecBackendDump) (RPCService_IpsecBackendDumpClient, error) + IpsecInterfaceAddDelSpd(ctx context.Context, in *IpsecInterfaceAddDelSpd) (*IpsecInterfaceAddDelSpdReply, error) + IpsecItfCreate(ctx context.Context, in *IpsecItfCreate) (*IpsecItfCreateReply, error) + IpsecItfDelete(ctx context.Context, in *IpsecItfDelete) (*IpsecItfDeleteReply, error) + IpsecItfDump(ctx context.Context, in *IpsecItfDump) (RPCService_IpsecItfDumpClient, error) + IpsecSaDump(ctx context.Context, in *IpsecSaDump) (RPCService_IpsecSaDumpClient, error) + IpsecSaV2Dump(ctx context.Context, in *IpsecSaV2Dump) (RPCService_IpsecSaV2DumpClient, error) + IpsecSaV3Dump(ctx context.Context, in *IpsecSaV3Dump) (RPCService_IpsecSaV3DumpClient, error) + IpsecSadEntryAdd(ctx context.Context, in *IpsecSadEntryAdd) (*IpsecSadEntryAddReply, error) + IpsecSadEntryAddDel(ctx context.Context, in *IpsecSadEntryAddDel) (*IpsecSadEntryAddDelReply, error) + IpsecSadEntryAddDelV2(ctx context.Context, in *IpsecSadEntryAddDelV2) (*IpsecSadEntryAddDelV2Reply, error) + IpsecSadEntryAddDelV3(ctx context.Context, in *IpsecSadEntryAddDelV3) (*IpsecSadEntryAddDelV3Reply, error) + IpsecSadEntryDel(ctx context.Context, in *IpsecSadEntryDel) (*IpsecSadEntryDelReply, error) + IpsecSadEntryUpdate(ctx context.Context, in *IpsecSadEntryUpdate) (*IpsecSadEntryUpdateReply, error) + IpsecSelectBackend(ctx context.Context, in *IpsecSelectBackend) (*IpsecSelectBackendReply, error) + IpsecSetAsyncMode(ctx context.Context, in *IpsecSetAsyncMode) (*IpsecSetAsyncModeReply, error) + IpsecSpdAddDel(ctx context.Context, in *IpsecSpdAddDel) (*IpsecSpdAddDelReply, error) + IpsecSpdDump(ctx context.Context, in *IpsecSpdDump) (RPCService_IpsecSpdDumpClient, error) + IpsecSpdEntryAddDel(ctx context.Context, in *IpsecSpdEntryAddDel) (*IpsecSpdEntryAddDelReply, error) + IpsecSpdEntryAddDelV2(ctx context.Context, in *IpsecSpdEntryAddDelV2) (*IpsecSpdEntryAddDelV2Reply, error) + IpsecSpdInterfaceDump(ctx context.Context, in *IpsecSpdInterfaceDump) (RPCService_IpsecSpdInterfaceDumpClient, error) + IpsecSpdsDump(ctx context.Context, in *IpsecSpdsDump) (RPCService_IpsecSpdsDumpClient, error) + IpsecTunnelProtectDel(ctx context.Context, in *IpsecTunnelProtectDel) (*IpsecTunnelProtectDelReply, error) + IpsecTunnelProtectDump(ctx context.Context, in *IpsecTunnelProtectDump) (RPCService_IpsecTunnelProtectDumpClient, error) + IpsecTunnelProtectUpdate(ctx context.Context, in *IpsecTunnelProtectUpdate) (*IpsecTunnelProtectUpdateReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) IpsecBackendDump(ctx context.Context, in *IpsecBackendDump) (RPCService_IpsecBackendDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IpsecBackendDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IpsecBackendDumpClient interface { + Recv() (*IpsecBackendDetails, error) + api.Stream +} + +type serviceClient_IpsecBackendDumpClient struct { + api.Stream +} + +func (c *serviceClient_IpsecBackendDumpClient) Recv() (*IpsecBackendDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IpsecBackendDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IpsecInterfaceAddDelSpd(ctx context.Context, in *IpsecInterfaceAddDelSpd) (*IpsecInterfaceAddDelSpdReply, error) { + out := new(IpsecInterfaceAddDelSpdReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpsecItfCreate(ctx context.Context, in *IpsecItfCreate) (*IpsecItfCreateReply, error) { + out := new(IpsecItfCreateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpsecItfDelete(ctx context.Context, in *IpsecItfDelete) (*IpsecItfDeleteReply, error) { + out := new(IpsecItfDeleteReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpsecItfDump(ctx context.Context, in *IpsecItfDump) (RPCService_IpsecItfDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IpsecItfDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IpsecItfDumpClient interface { + Recv() (*IpsecItfDetails, error) + api.Stream +} + +type serviceClient_IpsecItfDumpClient struct { + api.Stream +} + +func (c *serviceClient_IpsecItfDumpClient) Recv() (*IpsecItfDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IpsecItfDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IpsecSaDump(ctx context.Context, in *IpsecSaDump) (RPCService_IpsecSaDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IpsecSaDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IpsecSaDumpClient interface { + Recv() (*IpsecSaDetails, error) + api.Stream +} + +type serviceClient_IpsecSaDumpClient struct { + api.Stream +} + +func (c *serviceClient_IpsecSaDumpClient) Recv() (*IpsecSaDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IpsecSaDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IpsecSaV2Dump(ctx context.Context, in *IpsecSaV2Dump) (RPCService_IpsecSaV2DumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IpsecSaV2DumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IpsecSaV2DumpClient interface { + Recv() (*IpsecSaV2Details, error) + api.Stream +} + +type serviceClient_IpsecSaV2DumpClient struct { + api.Stream +} + +func (c *serviceClient_IpsecSaV2DumpClient) Recv() (*IpsecSaV2Details, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IpsecSaV2Details: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IpsecSaV3Dump(ctx context.Context, in *IpsecSaV3Dump) (RPCService_IpsecSaV3DumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IpsecSaV3DumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IpsecSaV3DumpClient interface { + Recv() (*IpsecSaV3Details, error) + api.Stream +} + +type serviceClient_IpsecSaV3DumpClient struct { + api.Stream +} + +func (c *serviceClient_IpsecSaV3DumpClient) Recv() (*IpsecSaV3Details, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IpsecSaV3Details: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IpsecSadEntryAdd(ctx context.Context, in *IpsecSadEntryAdd) (*IpsecSadEntryAddReply, error) { + out := new(IpsecSadEntryAddReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpsecSadEntryAddDel(ctx context.Context, in *IpsecSadEntryAddDel) (*IpsecSadEntryAddDelReply, error) { + out := new(IpsecSadEntryAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpsecSadEntryAddDelV2(ctx context.Context, in *IpsecSadEntryAddDelV2) (*IpsecSadEntryAddDelV2Reply, error) { + out := new(IpsecSadEntryAddDelV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpsecSadEntryAddDelV3(ctx context.Context, in *IpsecSadEntryAddDelV3) (*IpsecSadEntryAddDelV3Reply, error) { + out := new(IpsecSadEntryAddDelV3Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpsecSadEntryDel(ctx context.Context, in *IpsecSadEntryDel) (*IpsecSadEntryDelReply, error) { + out := new(IpsecSadEntryDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpsecSadEntryUpdate(ctx context.Context, in *IpsecSadEntryUpdate) (*IpsecSadEntryUpdateReply, error) { + out := new(IpsecSadEntryUpdateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpsecSelectBackend(ctx context.Context, in *IpsecSelectBackend) (*IpsecSelectBackendReply, error) { + out := new(IpsecSelectBackendReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpsecSetAsyncMode(ctx context.Context, in *IpsecSetAsyncMode) (*IpsecSetAsyncModeReply, error) { + out := new(IpsecSetAsyncModeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpsecSpdAddDel(ctx context.Context, in *IpsecSpdAddDel) (*IpsecSpdAddDelReply, error) { + out := new(IpsecSpdAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpsecSpdDump(ctx context.Context, in *IpsecSpdDump) (RPCService_IpsecSpdDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IpsecSpdDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IpsecSpdDumpClient interface { + Recv() (*IpsecSpdDetails, error) + api.Stream +} + +type serviceClient_IpsecSpdDumpClient struct { + api.Stream +} + +func (c *serviceClient_IpsecSpdDumpClient) Recv() (*IpsecSpdDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IpsecSpdDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IpsecSpdEntryAddDel(ctx context.Context, in *IpsecSpdEntryAddDel) (*IpsecSpdEntryAddDelReply, error) { + out := new(IpsecSpdEntryAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpsecSpdEntryAddDelV2(ctx context.Context, in *IpsecSpdEntryAddDelV2) (*IpsecSpdEntryAddDelV2Reply, error) { + out := new(IpsecSpdEntryAddDelV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpsecSpdInterfaceDump(ctx context.Context, in *IpsecSpdInterfaceDump) (RPCService_IpsecSpdInterfaceDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IpsecSpdInterfaceDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IpsecSpdInterfaceDumpClient interface { + Recv() (*IpsecSpdInterfaceDetails, error) + api.Stream +} + +type serviceClient_IpsecSpdInterfaceDumpClient struct { + api.Stream +} + +func (c *serviceClient_IpsecSpdInterfaceDumpClient) Recv() (*IpsecSpdInterfaceDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IpsecSpdInterfaceDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IpsecSpdsDump(ctx context.Context, in *IpsecSpdsDump) (RPCService_IpsecSpdsDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IpsecSpdsDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IpsecSpdsDumpClient interface { + Recv() (*IpsecSpdsDetails, error) + api.Stream +} + +type serviceClient_IpsecSpdsDumpClient struct { + api.Stream +} + +func (c *serviceClient_IpsecSpdsDumpClient) Recv() (*IpsecSpdsDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IpsecSpdsDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IpsecTunnelProtectDel(ctx context.Context, in *IpsecTunnelProtectDel) (*IpsecTunnelProtectDelReply, error) { + out := new(IpsecTunnelProtectDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IpsecTunnelProtectDump(ctx context.Context, in *IpsecTunnelProtectDump) (RPCService_IpsecTunnelProtectDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IpsecTunnelProtectDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IpsecTunnelProtectDumpClient interface { + Recv() (*IpsecTunnelProtectDetails, error) + api.Stream +} + +type serviceClient_IpsecTunnelProtectDumpClient struct { + api.Stream +} + +func (c *serviceClient_IpsecTunnelProtectDumpClient) Recv() (*IpsecTunnelProtectDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IpsecTunnelProtectDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IpsecTunnelProtectUpdate(ctx context.Context, in *IpsecTunnelProtectUpdate) (*IpsecTunnelProtectUpdateReply, error) { + out := new(IpsecTunnelProtectUpdateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/ipsec_types/ipsec_types.ba.go b/binapi/ipsec_types/ipsec_types.ba.go new file mode 100644 index 00000000..22e38a20 --- /dev/null +++ b/binapi/ipsec_types/ipsec_types.ba.go @@ -0,0 +1,355 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/ipsec_types.api.json + +// Package ipsec_types contains generated bindings for API file ipsec_types.api. +// +// Contents: +// - 5 enums +// - 6 structs +package ipsec_types + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + _ "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + tunnel_types "github.com/alkiranet/govpp/binapi/tunnel_types" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "ipsec_types" + APIVersion = "3.0.1" + VersionCrc = 0x7892423b +) + +// IpsecCryptoAlg defines 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 + IPSEC_API_CRYPTO_ALG_CHACHA20_POLY1305 IpsecCryptoAlg = 12 +) + +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", + 12: "IPSEC_API_CRYPTO_ALG_CHACHA20_POLY1305", + } + 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, + "IPSEC_API_CRYPTO_ALG_CHACHA20_POLY1305": 12, + } +) + +func (x IpsecCryptoAlg) String() string { + s, ok := IpsecCryptoAlg_name[uint32(x)] + if ok { + return s + } + return "IpsecCryptoAlg(" + strconv.Itoa(int(x)) + ")" +} + +// IpsecIntegAlg defines 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", + } + 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 "IpsecIntegAlg(" + strconv.Itoa(int(x)) + ")" +} + +// IpsecProto defines enum 'ipsec_proto'. +type IpsecProto uint32 + +const ( + IPSEC_API_PROTO_ESP IpsecProto = 50 + IPSEC_API_PROTO_AH IpsecProto = 51 +) + +var ( + IpsecProto_name = map[uint32]string{ + 50: "IPSEC_API_PROTO_ESP", + 51: "IPSEC_API_PROTO_AH", + } + IpsecProto_value = map[string]uint32{ + "IPSEC_API_PROTO_ESP": 50, + "IPSEC_API_PROTO_AH": 51, + } +) + +func (x IpsecProto) String() string { + s, ok := IpsecProto_name[uint32(x)] + if ok { + return s + } + return "IpsecProto(" + strconv.Itoa(int(x)) + ")" +} + +// IpsecSadFlags defines 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 + IPSEC_API_SAD_FLAG_IS_INBOUND IpsecSadFlags = 64 + IPSEC_API_SAD_FLAG_ASYNC IpsecSadFlags = 128 +) + +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", + 64: "IPSEC_API_SAD_FLAG_IS_INBOUND", + 128: "IPSEC_API_SAD_FLAG_ASYNC", + } + 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, + "IPSEC_API_SAD_FLAG_IS_INBOUND": 64, + "IPSEC_API_SAD_FLAG_ASYNC": 128, + } +) + +func (x IpsecSadFlags) String() string { + s, ok := IpsecSadFlags_name[uint32(x)] + if ok { + return s + } + str := func(n uint32) string { + s, ok := IpsecSadFlags_name[uint32(n)] + if ok { + return s + } + return "IpsecSadFlags(" + strconv.Itoa(int(n)) + ")" + } + for i := uint32(0); i <= 32; i++ { + val := uint32(x) + if val&(1< dynamically allocate +// +// BviCreate defines message 'bvi_create'. +type BviCreate struct { + Mac ethernet_types.MacAddress `binapi:"mac_address,name=mac" json:"mac,omitempty"` + UserInstance uint32 `binapi:"u32,name=user_instance,default=4294967295" json:"user_instance,omitempty"` +} + +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 +} + +func (m *BviCreate) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 6 // m.Mac + size += 4 // m.UserInstance + return size +} +func (m *BviCreate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.Mac[:], 6) + buf.EncodeUint32(m.UserInstance) + return buf.Bytes(), nil +} +func (m *BviCreate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.Mac[:], buf.DecodeBytes(6)) + m.UserInstance = buf.DecodeUint32() + return nil +} + +// Create BVI interface instance response +// - sw_if_index - sw index of the interface that was created +// - retval - return code for the request +// +// BviCreateReply defines message 'bvi_create_reply'. +type BviCreateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *BviCreateReply) Reset() { *m = BviCreateReply{} } +func (*BviCreateReply) GetMessageName() string { return "bvi_create_reply" } +func (*BviCreateReply) GetCrcString() string { return "5383d31f" } +func (*BviCreateReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *BviCreateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *BviCreateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *BviCreateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Delete BVI interface request +// - sw_if_index - sw index of the interface that was created +// +// BviDelete defines message 'bvi_delete'. +type BviDelete struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *BviDelete) Reset() { *m = BviDelete{} } +func (*BviDelete) GetMessageName() string { return "bvi_delete" } +func (*BviDelete) GetCrcString() string { return "f9e6675e" } +func (*BviDelete) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *BviDelete) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *BviDelete) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *BviDelete) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// BviDeleteReply defines message 'bvi_delete_reply'. +type BviDeleteReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *BviDeleteReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *BviDeleteReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *BviDeleteReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Tell client about an IP4 ARP resolution event or +// +// MAC/IP info from ARP requests in L2 BDs +// - pid - client pid registered to receive notification +// - ip - IP address of new ARP term entry +// - sw_if_index - interface of new ARP term entry +// - mac - MAC address of new ARP term entry +// +// L2ArpTermEvent defines message 'l2_arp_term_event'. +type L2ArpTermEvent struct { + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` + IP ip_types.Address `binapi:"address,name=ip" json:"ip,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Mac ethernet_types.MacAddress `binapi:"mac_address,name=mac" json:"mac,omitempty"` +} + +func (m *L2ArpTermEvent) Reset() { *m = L2ArpTermEvent{} } +func (*L2ArpTermEvent) GetMessageName() string { return "l2_arp_term_event" } +func (*L2ArpTermEvent) GetCrcString() string { return "6963e07a" } +func (*L2ArpTermEvent) GetMessageType() api.MessageType { + return api.EventMessage +} + +func (m *L2ArpTermEvent) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PID + size += 1 // m.IP.Af + size += 1 * 16 // m.IP.Un + size += 4 // m.SwIfIndex + size += 1 * 6 // m.Mac + return size +} +func (m *L2ArpTermEvent) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PID) + buf.EncodeUint8(uint8(m.IP.Af)) + buf.EncodeBytes(m.IP.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBytes(m.Mac[:], 6) + return buf.Bytes(), nil +} +func (m *L2ArpTermEvent) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PID = buf.DecodeUint32() + m.IP.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IP.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + copy(m.Mac[:], buf.DecodeBytes(6)) + return nil +} + +// L2 fib clear table request, clear all mac entries in the l2 fib +// L2FibClearTable defines 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 +} + +func (m *L2FibClearTable) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *L2FibClearTable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *L2FibClearTable) Unmarshal(b []byte) error { + return nil +} + +// L2FibClearTableReply defines message 'l2_fib_clear_table_reply'. +type L2FibClearTableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *L2FibClearTableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *L2FibClearTableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *L2FibClearTableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// l2 fib table details structure +// - bd_id - the l2 fib / bridge domain table id +// - mac - the entry's mac address +// - sw_if_index - index of the interface +// - static_mac - the entry is statically configured. +// - filter_mac - the entry is a mac filter entry. +// - bvi_mac - the mac address is a bridge virtual interface +// +// L2FibTableDetails defines message 'l2_fib_table_details'. +type L2FibTableDetails struct { + BdID uint32 `binapi:"u32,name=bd_id" json:"bd_id,omitempty"` + Mac ethernet_types.MacAddress `binapi:"mac_address,name=mac" json:"mac,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + StaticMac bool `binapi:"bool,name=static_mac" json:"static_mac,omitempty"` + FilterMac bool `binapi:"bool,name=filter_mac" json:"filter_mac,omitempty"` + BviMac bool `binapi:"bool,name=bvi_mac" json:"bvi_mac,omitempty"` +} + +func (m *L2FibTableDetails) Reset() { *m = L2FibTableDetails{} } +func (*L2FibTableDetails) GetMessageName() string { return "l2_fib_table_details" } +func (*L2FibTableDetails) GetCrcString() string { return "a44ef6b8" } +func (*L2FibTableDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *L2FibTableDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.BdID + size += 1 * 6 // m.Mac + size += 4 // m.SwIfIndex + size += 1 // m.StaticMac + size += 1 // m.FilterMac + size += 1 // m.BviMac + return size +} +func (m *L2FibTableDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.BdID) + buf.EncodeBytes(m.Mac[:], 6) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.StaticMac) + buf.EncodeBool(m.FilterMac) + buf.EncodeBool(m.BviMac) + return buf.Bytes(), nil +} +func (m *L2FibTableDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BdID = buf.DecodeUint32() + copy(m.Mac[:], buf.DecodeBytes(6)) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.StaticMac = buf.DecodeBool() + m.FilterMac = buf.DecodeBool() + m.BviMac = buf.DecodeBool() + return nil +} + +// Dump l2 fib (aka bridge domain) table +// - bd_id - the l2 fib / bridge domain table identifier +// +// L2FibTableDump defines message 'l2_fib_table_dump'. +type L2FibTableDump struct { + BdID uint32 `binapi:"u32,name=bd_id" json:"bd_id,omitempty"` +} + +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 +} + +func (m *L2FibTableDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.BdID + return size +} +func (m *L2FibTableDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.BdID) + return buf.Bytes(), nil +} +func (m *L2FibTableDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BdID = buf.DecodeUint32() + return nil +} + +// Set interface L2 flags (such as L2_LEARN, L2_FWD, +// +// L2_FLOOD, L2_UU_FLOOD, or L2_ARP_TERM bits). This can be used +// to disable one or more of the features represented by the +// flag bits on an interface to override what is set as default +// for all interfaces in the bridge domain +// - sw_if_index - interface +// - is_set - if non-zero, set the bits, else clear them +// - feature_bitmap - non-zero bits (as above) to set or clear +// +// L2Flags defines message 'l2_flags'. +type L2Flags struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IsSet bool `binapi:"bool,name=is_set" json:"is_set,omitempty"` + FeatureBitmap uint32 `binapi:"u32,name=feature_bitmap" json:"feature_bitmap,omitempty"` +} + +func (m *L2Flags) Reset() { *m = L2Flags{} } +func (*L2Flags) GetMessageName() string { return "l2_flags" } +func (*L2Flags) GetCrcString() string { return "fc41cfe8" } +func (*L2Flags) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *L2Flags) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.IsSet + size += 4 // m.FeatureBitmap + return size +} +func (m *L2Flags) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.IsSet) + buf.EncodeUint32(m.FeatureBitmap) + return buf.Bytes(), nil +} +func (m *L2Flags) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsSet = buf.DecodeBool() + m.FeatureBitmap = buf.DecodeUint32() + return nil +} + +// Set interface L2 flags response +// - retval - return code for the set l2 bits request +// - resulting_feature_bitmap - the internal l2 feature bitmap after the request is implemented +// +// L2FlagsReply defines message 'l2_flags_reply'. +type L2FlagsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + ResultingFeatureBitmap uint32 `binapi:"u32,name=resulting_feature_bitmap" json:"resulting_feature_bitmap,omitempty"` +} + +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 +} + +func (m *L2FlagsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.ResultingFeatureBitmap + return size +} +func (m *L2FlagsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.ResultingFeatureBitmap) + return buf.Bytes(), nil +} +func (m *L2FlagsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.ResultingFeatureBitmap = buf.DecodeUint32() + return nil +} + +// L2 interface ethernet flow point filtering enable/disable request +// - sw_if_index - interface to enable/disable filtering on +// - enable_disable - if non-zero enable filtering, else disable +// +// L2InterfaceEfpFilter defines message 'l2_interface_efp_filter'. +type L2InterfaceEfpFilter struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + EnableDisable bool `binapi:"bool,name=enable_disable,default=true" json:"enable_disable,omitempty"` +} + +func (m *L2InterfaceEfpFilter) Reset() { *m = L2InterfaceEfpFilter{} } +func (*L2InterfaceEfpFilter) GetMessageName() string { return "l2_interface_efp_filter" } +func (*L2InterfaceEfpFilter) GetCrcString() string { return "5501adee" } +func (*L2InterfaceEfpFilter) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *L2InterfaceEfpFilter) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.EnableDisable + return size +} +func (m *L2InterfaceEfpFilter) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.EnableDisable) + return buf.Bytes(), nil +} +func (m *L2InterfaceEfpFilter) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.EnableDisable = buf.DecodeBool() + return nil +} + +// L2InterfaceEfpFilterReply defines message 'l2_interface_efp_filter_reply'. +type L2InterfaceEfpFilterReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *L2InterfaceEfpFilterReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *L2InterfaceEfpFilterReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *L2InterfaceEfpFilterReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// L2 interface pbb tag rewrite configure request +// - sw_if_index - interface the operation is applied to +// - vtr_op - Choose from l2_vtr_op_t enum values +// - inner_tag - needed for translate_qinq vtr op only +// - outer_tag - needed for translate_qinq vtr op only +// - b_dmac - B-tag remote mac address, needed for any push or translate_qinq vtr op +// - b_smac - B-tag local mac address, needed for any push or translate qinq vtr op +// - b_vlanid - B-tag vlanid, needed for any push or translate qinq vtr op +// - i_sid - I-tag service id, needed for any push or translate qinq vtr op +// +// L2InterfacePbbTagRewrite defines message 'l2_interface_pbb_tag_rewrite'. +type L2InterfacePbbTagRewrite struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + VtrOp uint32 `binapi:"u32,name=vtr_op" json:"vtr_op,omitempty"` + OuterTag uint16 `binapi:"u16,name=outer_tag" json:"outer_tag,omitempty"` + BDmac ethernet_types.MacAddress `binapi:"mac_address,name=b_dmac" json:"b_dmac,omitempty"` + BSmac ethernet_types.MacAddress `binapi:"mac_address,name=b_smac" json:"b_smac,omitempty"` + BVlanid uint16 `binapi:"u16,name=b_vlanid" json:"b_vlanid,omitempty"` + ISid uint32 `binapi:"u32,name=i_sid" json:"i_sid,omitempty"` +} + +func (m *L2InterfacePbbTagRewrite) Reset() { *m = L2InterfacePbbTagRewrite{} } +func (*L2InterfacePbbTagRewrite) GetMessageName() string { return "l2_interface_pbb_tag_rewrite" } +func (*L2InterfacePbbTagRewrite) GetCrcString() string { return "38e802a8" } +func (*L2InterfacePbbTagRewrite) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *L2InterfacePbbTagRewrite) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.VtrOp + size += 2 // m.OuterTag + size += 1 * 6 // m.BDmac + size += 1 * 6 // m.BSmac + size += 2 // m.BVlanid + size += 4 // m.ISid + return size +} +func (m *L2InterfacePbbTagRewrite) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.VtrOp) + buf.EncodeUint16(m.OuterTag) + buf.EncodeBytes(m.BDmac[:], 6) + buf.EncodeBytes(m.BSmac[:], 6) + buf.EncodeUint16(m.BVlanid) + buf.EncodeUint32(m.ISid) + return buf.Bytes(), nil +} +func (m *L2InterfacePbbTagRewrite) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.VtrOp = buf.DecodeUint32() + m.OuterTag = buf.DecodeUint16() + copy(m.BDmac[:], buf.DecodeBytes(6)) + copy(m.BSmac[:], buf.DecodeBytes(6)) + m.BVlanid = buf.DecodeUint16() + m.ISid = buf.DecodeUint32() + return nil +} + +// L2InterfacePbbTagRewriteReply defines message 'l2_interface_pbb_tag_rewrite_reply'. +type L2InterfacePbbTagRewriteReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *L2InterfacePbbTagRewriteReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *L2InterfacePbbTagRewriteReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *L2InterfacePbbTagRewriteReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// L2 interface vlan tag rewrite configure request +// - sw_if_index - interface the operation is applied to +// - vtr_op - Choose from l2_vtr_op_t enum values +// - push_dot1q - first pushed flag dot1q id set, else dot1ad +// - tag1 - Needed for any push or translate vtr op +// - tag2 - Needed for any push 2 or translate x-2 vtr ops +// +// L2InterfaceVlanTagRewrite defines message 'l2_interface_vlan_tag_rewrite'. +type L2InterfaceVlanTagRewrite struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + VtrOp uint32 `binapi:"u32,name=vtr_op" json:"vtr_op,omitempty"` + PushDot1q uint32 `binapi:"u32,name=push_dot1q" json:"push_dot1q,omitempty"` + Tag1 uint32 `binapi:"u32,name=tag1" json:"tag1,omitempty"` + Tag2 uint32 `binapi:"u32,name=tag2" json:"tag2,omitempty"` +} + +func (m *L2InterfaceVlanTagRewrite) Reset() { *m = L2InterfaceVlanTagRewrite{} } +func (*L2InterfaceVlanTagRewrite) GetMessageName() string { return "l2_interface_vlan_tag_rewrite" } +func (*L2InterfaceVlanTagRewrite) GetCrcString() string { return "62cc0bbc" } +func (*L2InterfaceVlanTagRewrite) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *L2InterfaceVlanTagRewrite) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.VtrOp + size += 4 // m.PushDot1q + size += 4 // m.Tag1 + size += 4 // m.Tag2 + return size +} +func (m *L2InterfaceVlanTagRewrite) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.VtrOp) + buf.EncodeUint32(m.PushDot1q) + buf.EncodeUint32(m.Tag1) + buf.EncodeUint32(m.Tag2) + return buf.Bytes(), nil +} +func (m *L2InterfaceVlanTagRewrite) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.VtrOp = buf.DecodeUint32() + m.PushDot1q = buf.DecodeUint32() + m.Tag1 = buf.DecodeUint32() + m.Tag2 = buf.DecodeUint32() + return nil +} + +// L2InterfaceVlanTagRewriteReply defines message 'l2_interface_vlan_tag_rewrite_reply'. +type L2InterfaceVlanTagRewriteReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *L2InterfaceVlanTagRewriteReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *L2InterfaceVlanTagRewriteReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *L2InterfaceVlanTagRewriteReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// L2 MAC event for a list of learned or aged MACs +// - pid - client pid registered to receive notification +// - n_macs - number of learned/aged MAC entries +// - mac - array of learned/aged MAC entries +// +// L2MacsEvent defines message 'l2_macs_event'. +type L2MacsEvent struct { + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` + NMacs uint32 `binapi:"u32,name=n_macs" json:"-"` + Mac []MacEntry `binapi:"mac_entry[n_macs],name=mac" json:"mac,omitempty"` +} + +func (m *L2MacsEvent) Reset() { *m = L2MacsEvent{} } +func (*L2MacsEvent) GetMessageName() string { return "l2_macs_event" } +func (*L2MacsEvent) GetCrcString() string { return "44b8fd64" } +func (*L2MacsEvent) GetMessageType() api.MessageType { + return api.EventMessage +} + +func (m *L2MacsEvent) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PID + size += 4 // m.NMacs + for j1 := 0; j1 < len(m.Mac); j1++ { + var s1 MacEntry + _ = s1 + if j1 < len(m.Mac) { + s1 = m.Mac[j1] + } + size += 4 // s1.SwIfIndex + size += 1 * 6 // s1.MacAddr + size += 4 // s1.Action + size += 1 // s1.Flags + } + return size +} +func (m *L2MacsEvent) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PID) + buf.EncodeUint32(uint32(len(m.Mac))) + for j0 := 0; j0 < len(m.Mac); j0++ { + var v0 MacEntry // Mac + if j0 < len(m.Mac) { + v0 = m.Mac[j0] + } + buf.EncodeUint32(uint32(v0.SwIfIndex)) + buf.EncodeBytes(v0.MacAddr[:], 6) + buf.EncodeUint32(uint32(v0.Action)) + buf.EncodeUint8(v0.Flags) + } + return buf.Bytes(), nil +} +func (m *L2MacsEvent) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PID = buf.DecodeUint32() + m.NMacs = buf.DecodeUint32() + m.Mac = make([]MacEntry, m.NMacs) + for j0 := 0; j0 < len(m.Mac); j0++ { + m.Mac[j0].SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + copy(m.Mac[j0].MacAddr[:], buf.DecodeBytes(6)) + m.Mac[j0].Action = MacEventAction(buf.DecodeUint32()) + m.Mac[j0].Flags = buf.DecodeUint8() + } + return nil +} + +// L2 interface patch add / del request +// - rx_sw_if_index - receive side interface +// - tx_sw_if_index - transmit side interface +// - is_add - if non-zero set up the interface patch, else remove it +// +// L2PatchAddDel defines message 'l2_patch_add_del'. +type L2PatchAddDel struct { + RxSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=rx_sw_if_index" json:"rx_sw_if_index,omitempty"` + TxSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=tx_sw_if_index" json:"tx_sw_if_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` +} + +func (m *L2PatchAddDel) Reset() { *m = L2PatchAddDel{} } +func (*L2PatchAddDel) GetMessageName() string { return "l2_patch_add_del" } +func (*L2PatchAddDel) GetCrcString() string { return "a1f6a6f3" } +func (*L2PatchAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *L2PatchAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.RxSwIfIndex + size += 4 // m.TxSwIfIndex + size += 1 // m.IsAdd + return size +} +func (m *L2PatchAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.RxSwIfIndex)) + buf.EncodeUint32(uint32(m.TxSwIfIndex)) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *L2PatchAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.RxSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.TxSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsAdd = buf.DecodeBool() + return nil +} + +// L2PatchAddDelReply defines message 'l2_patch_add_del_reply'. +type L2PatchAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *L2PatchAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *L2PatchAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *L2PatchAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Reply to l2_xconnect_dump +// - rx_sw_if_index - Receive interface index +// - tx_sw_if_index - Transmit interface index +// +// L2XconnectDetails defines message 'l2_xconnect_details'. +type L2XconnectDetails struct { + RxSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=rx_sw_if_index" json:"rx_sw_if_index,omitempty"` + TxSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=tx_sw_if_index" json:"tx_sw_if_index,omitempty"` +} + +func (m *L2XconnectDetails) Reset() { *m = L2XconnectDetails{} } +func (*L2XconnectDetails) GetMessageName() string { return "l2_xconnect_details" } +func (*L2XconnectDetails) GetCrcString() string { return "472b6b67" } +func (*L2XconnectDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *L2XconnectDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.RxSwIfIndex + size += 4 // m.TxSwIfIndex + return size +} +func (m *L2XconnectDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.RxSwIfIndex)) + buf.EncodeUint32(uint32(m.TxSwIfIndex)) + return buf.Bytes(), nil +} +func (m *L2XconnectDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.RxSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.TxSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Dump L2 XConnects +// L2XconnectDump defines 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 +} + +func (m *L2XconnectDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *L2XconnectDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *L2XconnectDump) Unmarshal(b []byte) error { + return nil +} + +// L2 FIB add entry request +// - mac - the entry's mac address +// - bd_id - the entry's bridge domain id +// - sw_if_index - the interface +// - is_add - If non zero add the entry, else delete it +// - static_mac - +// - filter_mac - +// - bvi_mac - +// +// L2fibAddDel defines message 'l2fib_add_del'. +type L2fibAddDel struct { + Mac ethernet_types.MacAddress `binapi:"mac_address,name=mac" json:"mac,omitempty"` + BdID uint32 `binapi:"u32,name=bd_id" json:"bd_id,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + StaticMac bool `binapi:"bool,name=static_mac" json:"static_mac,omitempty"` + FilterMac bool `binapi:"bool,name=filter_mac" json:"filter_mac,omitempty"` + BviMac bool `binapi:"bool,name=bvi_mac" json:"bvi_mac,omitempty"` +} + +func (m *L2fibAddDel) Reset() { *m = L2fibAddDel{} } +func (*L2fibAddDel) GetMessageName() string { return "l2fib_add_del" } +func (*L2fibAddDel) GetCrcString() string { return "eddda487" } +func (*L2fibAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *L2fibAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 6 // m.Mac + size += 4 // m.BdID + size += 4 // m.SwIfIndex + size += 1 // m.IsAdd + size += 1 // m.StaticMac + size += 1 // m.FilterMac + size += 1 // m.BviMac + return size +} +func (m *L2fibAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.Mac[:], 6) + buf.EncodeUint32(m.BdID) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.IsAdd) + buf.EncodeBool(m.StaticMac) + buf.EncodeBool(m.FilterMac) + buf.EncodeBool(m.BviMac) + return buf.Bytes(), nil +} +func (m *L2fibAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.Mac[:], buf.DecodeBytes(6)) + m.BdID = buf.DecodeUint32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsAdd = buf.DecodeBool() + m.StaticMac = buf.DecodeBool() + m.FilterMac = buf.DecodeBool() + m.BviMac = buf.DecodeBool() + return nil +} + +// L2fibAddDelReply defines message 'l2fib_add_del_reply'. +type L2fibAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *L2fibAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *L2fibAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *L2fibAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// L2 FIB flush all entries +// L2fibFlushAll defines 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 +} + +func (m *L2fibFlushAll) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *L2fibFlushAll) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *L2fibFlushAll) Unmarshal(b []byte) error { + return nil +} + +// L2fibFlushAllReply defines message 'l2fib_flush_all_reply'. +type L2fibFlushAllReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *L2fibFlushAllReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *L2fibFlushAllReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *L2fibFlushAllReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// L2 FIB flush bridge domain entries +// - bd_id - the entry's bridge domain id +// +// L2fibFlushBd defines message 'l2fib_flush_bd'. +type L2fibFlushBd struct { + BdID uint32 `binapi:"u32,name=bd_id" json:"bd_id,omitempty"` +} + +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 +} + +func (m *L2fibFlushBd) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.BdID + return size +} +func (m *L2fibFlushBd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.BdID) + return buf.Bytes(), nil +} +func (m *L2fibFlushBd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BdID = buf.DecodeUint32() + return nil +} + +// L2fibFlushBdReply defines message 'l2fib_flush_bd_reply'. +type L2fibFlushBdReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *L2fibFlushBdReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *L2fibFlushBdReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *L2fibFlushBdReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// L2 FIB flush interface entries +// - bd_id - the entry's bridge domain id +// +// L2fibFlushInt defines message 'l2fib_flush_int'. +type L2fibFlushInt struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *L2fibFlushInt) Reset() { *m = L2fibFlushInt{} } +func (*L2fibFlushInt) GetMessageName() string { return "l2fib_flush_int" } +func (*L2fibFlushInt) GetCrcString() string { return "f9e6675e" } +func (*L2fibFlushInt) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *L2fibFlushInt) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *L2fibFlushInt) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *L2fibFlushInt) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// L2fibFlushIntReply defines message 'l2fib_flush_int_reply'. +type L2fibFlushIntReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *L2fibFlushIntReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *L2fibFlushIntReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *L2fibFlushIntReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// set l2 table scan delay +// - scan_delay - event scan delay in 10 msec unit +// +// L2fibSetScanDelay defines message 'l2fib_set_scan_delay'. +type L2fibSetScanDelay struct { + ScanDelay uint16 `binapi:"u16,name=scan_delay,default=10" json:"scan_delay,omitempty"` +} + +func (m *L2fibSetScanDelay) Reset() { *m = L2fibSetScanDelay{} } +func (*L2fibSetScanDelay) GetMessageName() string { return "l2fib_set_scan_delay" } +func (*L2fibSetScanDelay) GetCrcString() string { return "a3b968a4" } +func (*L2fibSetScanDelay) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *L2fibSetScanDelay) Size() (size int) { + if m == nil { + return 0 + } + size += 2 // m.ScanDelay + return size +} +func (m *L2fibSetScanDelay) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint16(m.ScanDelay) + return buf.Bytes(), nil +} +func (m *L2fibSetScanDelay) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ScanDelay = buf.DecodeUint16() + return nil +} + +// L2fibSetScanDelayReply defines message 'l2fib_set_scan_delay_reply'. +type L2fibSetScanDelayReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *L2fibSetScanDelayReply) Reset() { *m = L2fibSetScanDelayReply{} } +func (*L2fibSetScanDelayReply) GetMessageName() string { return "l2fib_set_scan_delay_reply" } +func (*L2fibSetScanDelayReply) GetCrcString() string { return "e8d4e804" } +func (*L2fibSetScanDelayReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *L2fibSetScanDelayReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *L2fibSetScanDelayReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *L2fibSetScanDelayReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Interface bridge mode request +// - rx_sw_if_index - the interface +// - bd_id - bridge domain id +// - port_type - port_mode, see #l2_port_type +// - shg - Split horizon group, for bridge mode only +// - enable - Enable beige mode if not 0, else set to L3 mode +// +// SwInterfaceSetL2Bridge defines message 'sw_interface_set_l2_bridge'. +type SwInterfaceSetL2Bridge struct { + RxSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=rx_sw_if_index" json:"rx_sw_if_index,omitempty"` + BdID uint32 `binapi:"u32,name=bd_id" json:"bd_id,omitempty"` + PortType L2PortType `binapi:"l2_port_type,name=port_type" json:"port_type,omitempty"` + Shg uint8 `binapi:"u8,name=shg" json:"shg,omitempty"` + Enable bool `binapi:"bool,name=enable,default=true" json:"enable,omitempty"` +} + +func (m *SwInterfaceSetL2Bridge) Reset() { *m = SwInterfaceSetL2Bridge{} } +func (*SwInterfaceSetL2Bridge) GetMessageName() string { return "sw_interface_set_l2_bridge" } +func (*SwInterfaceSetL2Bridge) GetCrcString() string { return "d0678b13" } +func (*SwInterfaceSetL2Bridge) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSetL2Bridge) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.RxSwIfIndex + size += 4 // m.BdID + size += 4 // m.PortType + size += 1 // m.Shg + size += 1 // m.Enable + return size +} +func (m *SwInterfaceSetL2Bridge) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.RxSwIfIndex)) + buf.EncodeUint32(m.BdID) + buf.EncodeUint32(uint32(m.PortType)) + buf.EncodeUint8(m.Shg) + buf.EncodeBool(m.Enable) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetL2Bridge) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.RxSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.BdID = buf.DecodeUint32() + m.PortType = L2PortType(buf.DecodeUint32()) + m.Shg = buf.DecodeUint8() + m.Enable = buf.DecodeBool() + return nil +} + +// SwInterfaceSetL2BridgeReply defines message 'sw_interface_set_l2_bridge_reply'. +type SwInterfaceSetL2BridgeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetL2BridgeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetL2BridgeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetL2BridgeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set L2 XConnect between two interfaces request +// - rx_sw_if_index - Receive interface index +// - tx_sw_if_index - Transmit interface index +// - enable - enable xconnect if not 0, else set to L3 mode +// +// SwInterfaceSetL2Xconnect defines message 'sw_interface_set_l2_xconnect'. +type SwInterfaceSetL2Xconnect struct { + RxSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=rx_sw_if_index" json:"rx_sw_if_index,omitempty"` + TxSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=tx_sw_if_index" json:"tx_sw_if_index,omitempty"` + Enable bool `binapi:"bool,name=enable,default=true" json:"enable,omitempty"` +} + +func (m *SwInterfaceSetL2Xconnect) Reset() { *m = SwInterfaceSetL2Xconnect{} } +func (*SwInterfaceSetL2Xconnect) GetMessageName() string { return "sw_interface_set_l2_xconnect" } +func (*SwInterfaceSetL2Xconnect) GetCrcString() string { return "4fa28a85" } +func (*SwInterfaceSetL2Xconnect) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSetL2Xconnect) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.RxSwIfIndex + size += 4 // m.TxSwIfIndex + size += 1 // m.Enable + return size +} +func (m *SwInterfaceSetL2Xconnect) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.RxSwIfIndex)) + buf.EncodeUint32(uint32(m.TxSwIfIndex)) + buf.EncodeBool(m.Enable) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetL2Xconnect) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.RxSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.TxSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Enable = buf.DecodeBool() + return nil +} + +// SwInterfaceSetL2XconnectReply defines message 'sw_interface_set_l2_xconnect_reply'. +type SwInterfaceSetL2XconnectReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetL2XconnectReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetL2XconnectReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetL2XconnectReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Interface set vpath request +// - sw_if_index - interface used to reach neighbor +// - enable - if non-zero enable, else disable +// +// SwInterfaceSetVpath defines message 'sw_interface_set_vpath'. +type SwInterfaceSetVpath struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Enable bool `binapi:"bool,name=enable,default=4.294967295e+09" json:"enable,omitempty"` +} + +func (m *SwInterfaceSetVpath) Reset() { *m = SwInterfaceSetVpath{} } +func (*SwInterfaceSetVpath) GetMessageName() string { return "sw_interface_set_vpath" } +func (*SwInterfaceSetVpath) GetCrcString() string { return "ae6cfcfb" } +func (*SwInterfaceSetVpath) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSetVpath) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.Enable + return size +} +func (m *SwInterfaceSetVpath) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.Enable) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetVpath) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Enable = buf.DecodeBool() + return nil +} + +// SwInterfaceSetVpathReply defines message 'sw_interface_set_vpath_reply'. +type SwInterfaceSetVpathReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetVpathReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetVpathReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetVpathReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Register for IP4 ARP resolution event on receiving ARP reply or +// +// MAC/IP info from ARP requests in L2 BDs +// - enable - 1 => register for events, 0 => cancel registration +// - pid - sender's pid +// +// WantL2ArpTermEvents defines message 'want_l2_arp_term_events'. +type WantL2ArpTermEvents struct { + Enable bool `binapi:"bool,name=enable" json:"enable,omitempty"` + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` +} + +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 +} + +func (m *WantL2ArpTermEvents) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Enable + size += 4 // m.PID + return size +} +func (m *WantL2ArpTermEvents) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.Enable) + buf.EncodeUint32(m.PID) + return buf.Bytes(), nil +} +func (m *WantL2ArpTermEvents) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Enable = buf.DecodeBool() + m.PID = buf.DecodeUint32() + return nil +} + +// WantL2ArpTermEventsReply defines message 'want_l2_arp_term_events_reply'. +type WantL2ArpTermEventsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *WantL2ArpTermEventsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *WantL2ArpTermEventsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *WantL2ArpTermEventsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Register to receive L2 MAC events for learned and aged MAC +// - learn_limit - MAC learn limit +// - scan_delay - event scan delay in 10 msec unit +// - max_macs_in_event - in units of 10 mac entries +// - enable_disable - 1 => register for MAC events, 0 => cancel registration +// - pid - sender's pid +// +// WantL2MacsEvents defines message 'want_l2_macs_events'. +// Deprecated: the message will be removed in the future versions +type WantL2MacsEvents struct { + LearnLimit uint32 `binapi:"u32,name=learn_limit,default=1000" json:"learn_limit,omitempty"` + ScanDelay uint8 `binapi:"u8,name=scan_delay,default=10" json:"scan_delay,omitempty"` + MaxMacsInEvent uint8 `binapi:"u8,name=max_macs_in_event,default=10" json:"max_macs_in_event,omitempty"` + EnableDisable bool `binapi:"bool,name=enable_disable,default=true" json:"enable_disable,omitempty"` + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` +} + +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 +} + +func (m *WantL2MacsEvents) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.LearnLimit + size += 1 // m.ScanDelay + size += 1 // m.MaxMacsInEvent + size += 1 // m.EnableDisable + size += 4 // m.PID + return size +} +func (m *WantL2MacsEvents) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.LearnLimit) + buf.EncodeUint8(m.ScanDelay) + buf.EncodeUint8(m.MaxMacsInEvent) + buf.EncodeBool(m.EnableDisable) + buf.EncodeUint32(m.PID) + return buf.Bytes(), nil +} +func (m *WantL2MacsEvents) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.LearnLimit = buf.DecodeUint32() + m.ScanDelay = buf.DecodeUint8() + m.MaxMacsInEvent = buf.DecodeUint8() + m.EnableDisable = buf.DecodeBool() + m.PID = buf.DecodeUint32() + return nil +} + +// Register to receive L2 MAC events for learned and aged MAC +// - max_macs_in_event - in units of 10 mac entries +// - enable_disable - 1 => register for MAC events, 0 => cancel registration +// - pid - sender's pid +// +// WantL2MacsEvents2 defines message 'want_l2_macs_events2'. +type WantL2MacsEvents2 struct { + MaxMacsInEvent uint8 `binapi:"u8,name=max_macs_in_event,default=10" json:"max_macs_in_event,omitempty"` + EnableDisable bool `binapi:"bool,name=enable_disable,default=true" json:"enable_disable,omitempty"` + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` +} + +func (m *WantL2MacsEvents2) Reset() { *m = WantL2MacsEvents2{} } +func (*WantL2MacsEvents2) GetMessageName() string { return "want_l2_macs_events2" } +func (*WantL2MacsEvents2) GetCrcString() string { return "cc1377b0" } +func (*WantL2MacsEvents2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *WantL2MacsEvents2) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.MaxMacsInEvent + size += 1 // m.EnableDisable + size += 4 // m.PID + return size +} +func (m *WantL2MacsEvents2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.MaxMacsInEvent) + buf.EncodeBool(m.EnableDisable) + buf.EncodeUint32(m.PID) + return buf.Bytes(), nil +} +func (m *WantL2MacsEvents2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.MaxMacsInEvent = buf.DecodeUint8() + m.EnableDisable = buf.DecodeBool() + m.PID = buf.DecodeUint32() + return nil +} + +// WantL2MacsEvents2Reply defines message 'want_l2_macs_events2_reply'. +type WantL2MacsEvents2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *WantL2MacsEvents2Reply) Reset() { *m = WantL2MacsEvents2Reply{} } +func (*WantL2MacsEvents2Reply) GetMessageName() string { return "want_l2_macs_events2_reply" } +func (*WantL2MacsEvents2Reply) GetCrcString() string { return "e8d4e804" } +func (*WantL2MacsEvents2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *WantL2MacsEvents2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *WantL2MacsEvents2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *WantL2MacsEvents2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// WantL2MacsEventsReply defines message 'want_l2_macs_events_reply'. +// Deprecated: the message will be removed in the future versions +type WantL2MacsEventsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 (m *WantL2MacsEventsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *WantL2MacsEventsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *WantL2MacsEventsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_l2_binapi_init() } +func file_l2_binapi_init() { + api.RegisterMessage((*BdIPMacAddDel)(nil), "bd_ip_mac_add_del_0257c869") + api.RegisterMessage((*BdIPMacAddDelReply)(nil), "bd_ip_mac_add_del_reply_e8d4e804") + api.RegisterMessage((*BdIPMacDetails)(nil), "bd_ip_mac_details_545af86a") + api.RegisterMessage((*BdIPMacDump)(nil), "bd_ip_mac_dump_c25fdce6") + api.RegisterMessage((*BdIPMacFlush)(nil), "bd_ip_mac_flush_c25fdce6") + api.RegisterMessage((*BdIPMacFlushReply)(nil), "bd_ip_mac_flush_reply_e8d4e804") + api.RegisterMessage((*BridgeDomainAddDel)(nil), "bridge_domain_add_del_600b7170") + api.RegisterMessage((*BridgeDomainAddDelReply)(nil), "bridge_domain_add_del_reply_e8d4e804") + api.RegisterMessage((*BridgeDomainAddDelV2)(nil), "bridge_domain_add_del_v2_600b7170") + api.RegisterMessage((*BridgeDomainAddDelV2Reply)(nil), "bridge_domain_add_del_v2_reply_fcb1e980") + api.RegisterMessage((*BridgeDomainDetails)(nil), "bridge_domain_details_0fa506fd") + api.RegisterMessage((*BridgeDomainDump)(nil), "bridge_domain_dump_74396a43") + api.RegisterMessage((*BridgeDomainSetDefaultLearnLimit)(nil), "bridge_domain_set_default_learn_limit_f097ffce") + api.RegisterMessage((*BridgeDomainSetDefaultLearnLimitReply)(nil), "bridge_domain_set_default_learn_limit_reply_e8d4e804") + api.RegisterMessage((*BridgeDomainSetLearnLimit)(nil), "bridge_domain_set_learn_limit_89c52b5f") + api.RegisterMessage((*BridgeDomainSetLearnLimitReply)(nil), "bridge_domain_set_learn_limit_reply_e8d4e804") + api.RegisterMessage((*BridgeDomainSetMacAge)(nil), "bridge_domain_set_mac_age_b537ad7b") + api.RegisterMessage((*BridgeDomainSetMacAgeReply)(nil), "bridge_domain_set_mac_age_reply_e8d4e804") + api.RegisterMessage((*BridgeFlags)(nil), "bridge_flags_1b0c5fbd") + api.RegisterMessage((*BridgeFlagsReply)(nil), "bridge_flags_reply_29b2a2b3") + api.RegisterMessage((*BviCreate)(nil), "bvi_create_f5398559") + api.RegisterMessage((*BviCreateReply)(nil), "bvi_create_reply_5383d31f") + api.RegisterMessage((*BviDelete)(nil), "bvi_delete_f9e6675e") + api.RegisterMessage((*BviDeleteReply)(nil), "bvi_delete_reply_e8d4e804") + api.RegisterMessage((*L2ArpTermEvent)(nil), "l2_arp_term_event_6963e07a") + api.RegisterMessage((*L2FibClearTable)(nil), "l2_fib_clear_table_51077d14") + api.RegisterMessage((*L2FibClearTableReply)(nil), "l2_fib_clear_table_reply_e8d4e804") + api.RegisterMessage((*L2FibTableDetails)(nil), "l2_fib_table_details_a44ef6b8") + api.RegisterMessage((*L2FibTableDump)(nil), "l2_fib_table_dump_c25fdce6") + api.RegisterMessage((*L2Flags)(nil), "l2_flags_fc41cfe8") + api.RegisterMessage((*L2FlagsReply)(nil), "l2_flags_reply_29b2a2b3") + api.RegisterMessage((*L2InterfaceEfpFilter)(nil), "l2_interface_efp_filter_5501adee") + api.RegisterMessage((*L2InterfaceEfpFilterReply)(nil), "l2_interface_efp_filter_reply_e8d4e804") + api.RegisterMessage((*L2InterfacePbbTagRewrite)(nil), "l2_interface_pbb_tag_rewrite_38e802a8") + api.RegisterMessage((*L2InterfacePbbTagRewriteReply)(nil), "l2_interface_pbb_tag_rewrite_reply_e8d4e804") + api.RegisterMessage((*L2InterfaceVlanTagRewrite)(nil), "l2_interface_vlan_tag_rewrite_62cc0bbc") + api.RegisterMessage((*L2InterfaceVlanTagRewriteReply)(nil), "l2_interface_vlan_tag_rewrite_reply_e8d4e804") + api.RegisterMessage((*L2MacsEvent)(nil), "l2_macs_event_44b8fd64") + api.RegisterMessage((*L2PatchAddDel)(nil), "l2_patch_add_del_a1f6a6f3") + api.RegisterMessage((*L2PatchAddDelReply)(nil), "l2_patch_add_del_reply_e8d4e804") + api.RegisterMessage((*L2XconnectDetails)(nil), "l2_xconnect_details_472b6b67") + api.RegisterMessage((*L2XconnectDump)(nil), "l2_xconnect_dump_51077d14") + api.RegisterMessage((*L2fibAddDel)(nil), "l2fib_add_del_eddda487") + api.RegisterMessage((*L2fibAddDelReply)(nil), "l2fib_add_del_reply_e8d4e804") + api.RegisterMessage((*L2fibFlushAll)(nil), "l2fib_flush_all_51077d14") + api.RegisterMessage((*L2fibFlushAllReply)(nil), "l2fib_flush_all_reply_e8d4e804") + api.RegisterMessage((*L2fibFlushBd)(nil), "l2fib_flush_bd_c25fdce6") + api.RegisterMessage((*L2fibFlushBdReply)(nil), "l2fib_flush_bd_reply_e8d4e804") + api.RegisterMessage((*L2fibFlushInt)(nil), "l2fib_flush_int_f9e6675e") + api.RegisterMessage((*L2fibFlushIntReply)(nil), "l2fib_flush_int_reply_e8d4e804") + api.RegisterMessage((*L2fibSetScanDelay)(nil), "l2fib_set_scan_delay_a3b968a4") + api.RegisterMessage((*L2fibSetScanDelayReply)(nil), "l2fib_set_scan_delay_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceSetL2Bridge)(nil), "sw_interface_set_l2_bridge_d0678b13") + api.RegisterMessage((*SwInterfaceSetL2BridgeReply)(nil), "sw_interface_set_l2_bridge_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceSetL2Xconnect)(nil), "sw_interface_set_l2_xconnect_4fa28a85") + api.RegisterMessage((*SwInterfaceSetL2XconnectReply)(nil), "sw_interface_set_l2_xconnect_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceSetVpath)(nil), "sw_interface_set_vpath_ae6cfcfb") + api.RegisterMessage((*SwInterfaceSetVpathReply)(nil), "sw_interface_set_vpath_reply_e8d4e804") + api.RegisterMessage((*WantL2ArpTermEvents)(nil), "want_l2_arp_term_events_3ec6d6c2") + api.RegisterMessage((*WantL2ArpTermEventsReply)(nil), "want_l2_arp_term_events_reply_e8d4e804") + api.RegisterMessage((*WantL2MacsEvents)(nil), "want_l2_macs_events_9aabdfde") + api.RegisterMessage((*WantL2MacsEvents2)(nil), "want_l2_macs_events2_cc1377b0") + api.RegisterMessage((*WantL2MacsEvents2Reply)(nil), "want_l2_macs_events2_reply_e8d4e804") + api.RegisterMessage((*WantL2MacsEventsReply)(nil), "want_l2_macs_events_reply_e8d4e804") +} + +// 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), + (*BridgeDomainAddDelV2)(nil), + (*BridgeDomainAddDelV2Reply)(nil), + (*BridgeDomainDetails)(nil), + (*BridgeDomainDump)(nil), + (*BridgeDomainSetDefaultLearnLimit)(nil), + (*BridgeDomainSetDefaultLearnLimitReply)(nil), + (*BridgeDomainSetLearnLimit)(nil), + (*BridgeDomainSetLearnLimitReply)(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), + (*L2fibSetScanDelay)(nil), + (*L2fibSetScanDelayReply)(nil), + (*SwInterfaceSetL2Bridge)(nil), + (*SwInterfaceSetL2BridgeReply)(nil), + (*SwInterfaceSetL2Xconnect)(nil), + (*SwInterfaceSetL2XconnectReply)(nil), + (*SwInterfaceSetVpath)(nil), + (*SwInterfaceSetVpathReply)(nil), + (*WantL2ArpTermEvents)(nil), + (*WantL2ArpTermEventsReply)(nil), + (*WantL2MacsEvents)(nil), + (*WantL2MacsEvents2)(nil), + (*WantL2MacsEvents2Reply)(nil), + (*WantL2MacsEventsReply)(nil), + } +} diff --git a/binapi/l2/l2_rpc.ba.go b/binapi/l2/l2_rpc.ba.go new file mode 100644 index 00000000..262db13f --- /dev/null +++ b/binapi/l2/l2_rpc.ba.go @@ -0,0 +1,470 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package l2 + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service l2. +type RPCService interface { + BdIPMacAddDel(ctx context.Context, in *BdIPMacAddDel) (*BdIPMacAddDelReply, error) + BdIPMacDump(ctx context.Context, in *BdIPMacDump) (RPCService_BdIPMacDumpClient, error) + BdIPMacFlush(ctx context.Context, in *BdIPMacFlush) (*BdIPMacFlushReply, error) + BridgeDomainAddDel(ctx context.Context, in *BridgeDomainAddDel) (*BridgeDomainAddDelReply, error) + BridgeDomainAddDelV2(ctx context.Context, in *BridgeDomainAddDelV2) (*BridgeDomainAddDelV2Reply, error) + BridgeDomainDump(ctx context.Context, in *BridgeDomainDump) (RPCService_BridgeDomainDumpClient, error) + BridgeDomainSetDefaultLearnLimit(ctx context.Context, in *BridgeDomainSetDefaultLearnLimit) (*BridgeDomainSetDefaultLearnLimitReply, error) + BridgeDomainSetLearnLimit(ctx context.Context, in *BridgeDomainSetLearnLimit) (*BridgeDomainSetLearnLimitReply, 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) + L2FibTableDump(ctx context.Context, in *L2FibTableDump) (RPCService_L2FibTableDumpClient, 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) + L2XconnectDump(ctx context.Context, in *L2XconnectDump) (RPCService_L2XconnectDumpClient, 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) + L2fibSetScanDelay(ctx context.Context, in *L2fibSetScanDelay) (*L2fibSetScanDelayReply, 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) + WantL2MacsEvents2(ctx context.Context, in *WantL2MacsEvents2) (*WantL2MacsEvents2Reply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) BdIPMacAddDel(ctx context.Context, in *BdIPMacAddDel) (*BdIPMacAddDelReply, error) { + out := new(BdIPMacAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BdIPMacDump(ctx context.Context, in *BdIPMacDump) (RPCService_BdIPMacDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_BdIPMacDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_BdIPMacDumpClient interface { + Recv() (*BdIPMacDetails, error) + api.Stream +} + +type serviceClient_BdIPMacDumpClient struct { + api.Stream +} + +func (c *serviceClient_BdIPMacDumpClient) Recv() (*BdIPMacDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *BdIPMacDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) BdIPMacFlush(ctx context.Context, in *BdIPMacFlush) (*BdIPMacFlushReply, error) { + out := new(BdIPMacFlushReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BridgeDomainAddDel(ctx context.Context, in *BridgeDomainAddDel) (*BridgeDomainAddDelReply, error) { + out := new(BridgeDomainAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BridgeDomainAddDelV2(ctx context.Context, in *BridgeDomainAddDelV2) (*BridgeDomainAddDelV2Reply, error) { + out := new(BridgeDomainAddDelV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BridgeDomainDump(ctx context.Context, in *BridgeDomainDump) (RPCService_BridgeDomainDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_BridgeDomainDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_BridgeDomainDumpClient interface { + Recv() (*BridgeDomainDetails, error) + api.Stream +} + +type serviceClient_BridgeDomainDumpClient struct { + api.Stream +} + +func (c *serviceClient_BridgeDomainDumpClient) Recv() (*BridgeDomainDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *BridgeDomainDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) BridgeDomainSetDefaultLearnLimit(ctx context.Context, in *BridgeDomainSetDefaultLearnLimit) (*BridgeDomainSetDefaultLearnLimitReply, error) { + out := new(BridgeDomainSetDefaultLearnLimitReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BridgeDomainSetLearnLimit(ctx context.Context, in *BridgeDomainSetLearnLimit) (*BridgeDomainSetLearnLimitReply, error) { + out := new(BridgeDomainSetLearnLimitReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BridgeDomainSetMacAge(ctx context.Context, in *BridgeDomainSetMacAge) (*BridgeDomainSetMacAgeReply, error) { + out := new(BridgeDomainSetMacAgeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BridgeFlags(ctx context.Context, in *BridgeFlags) (*BridgeFlagsReply, error) { + out := new(BridgeFlagsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BviCreate(ctx context.Context, in *BviCreate) (*BviCreateReply, error) { + out := new(BviCreateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) BviDelete(ctx context.Context, in *BviDelete) (*BviDeleteReply, error) { + out := new(BviDeleteReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) L2FibClearTable(ctx context.Context, in *L2FibClearTable) (*L2FibClearTableReply, error) { + out := new(L2FibClearTableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) L2FibTableDump(ctx context.Context, in *L2FibTableDump) (RPCService_L2FibTableDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_L2FibTableDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_L2FibTableDumpClient interface { + Recv() (*L2FibTableDetails, error) + api.Stream +} + +type serviceClient_L2FibTableDumpClient struct { + api.Stream +} + +func (c *serviceClient_L2FibTableDumpClient) Recv() (*L2FibTableDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *L2FibTableDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) L2Flags(ctx context.Context, in *L2Flags) (*L2FlagsReply, error) { + out := new(L2FlagsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) L2InterfaceEfpFilter(ctx context.Context, in *L2InterfaceEfpFilter) (*L2InterfaceEfpFilterReply, error) { + out := new(L2InterfaceEfpFilterReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) L2InterfacePbbTagRewrite(ctx context.Context, in *L2InterfacePbbTagRewrite) (*L2InterfacePbbTagRewriteReply, error) { + out := new(L2InterfacePbbTagRewriteReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) L2InterfaceVlanTagRewrite(ctx context.Context, in *L2InterfaceVlanTagRewrite) (*L2InterfaceVlanTagRewriteReply, error) { + out := new(L2InterfaceVlanTagRewriteReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) L2PatchAddDel(ctx context.Context, in *L2PatchAddDel) (*L2PatchAddDelReply, error) { + out := new(L2PatchAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) L2XconnectDump(ctx context.Context, in *L2XconnectDump) (RPCService_L2XconnectDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_L2XconnectDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_L2XconnectDumpClient interface { + Recv() (*L2XconnectDetails, error) + api.Stream +} + +type serviceClient_L2XconnectDumpClient struct { + api.Stream +} + +func (c *serviceClient_L2XconnectDumpClient) Recv() (*L2XconnectDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *L2XconnectDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) L2fibAddDel(ctx context.Context, in *L2fibAddDel) (*L2fibAddDelReply, error) { + out := new(L2fibAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) L2fibFlushAll(ctx context.Context, in *L2fibFlushAll) (*L2fibFlushAllReply, error) { + out := new(L2fibFlushAllReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) L2fibFlushBd(ctx context.Context, in *L2fibFlushBd) (*L2fibFlushBdReply, error) { + out := new(L2fibFlushBdReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) L2fibFlushInt(ctx context.Context, in *L2fibFlushInt) (*L2fibFlushIntReply, error) { + out := new(L2fibFlushIntReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) L2fibSetScanDelay(ctx context.Context, in *L2fibSetScanDelay) (*L2fibSetScanDelayReply, error) { + out := new(L2fibSetScanDelayReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceSetL2Bridge(ctx context.Context, in *SwInterfaceSetL2Bridge) (*SwInterfaceSetL2BridgeReply, error) { + out := new(SwInterfaceSetL2BridgeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceSetL2Xconnect(ctx context.Context, in *SwInterfaceSetL2Xconnect) (*SwInterfaceSetL2XconnectReply, error) { + out := new(SwInterfaceSetL2XconnectReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceSetVpath(ctx context.Context, in *SwInterfaceSetVpath) (*SwInterfaceSetVpathReply, error) { + out := new(SwInterfaceSetVpathReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WantL2ArpTermEvents(ctx context.Context, in *WantL2ArpTermEvents) (*WantL2ArpTermEventsReply, error) { + out := new(WantL2ArpTermEventsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WantL2MacsEvents(ctx context.Context, in *WantL2MacsEvents) (*WantL2MacsEventsReply, error) { + out := new(WantL2MacsEventsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WantL2MacsEvents2(ctx context.Context, in *WantL2MacsEvents2) (*WantL2MacsEvents2Reply, error) { + out := new(WantL2MacsEvents2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/l2tp/l2tp.ba.go b/binapi/l2tp/l2tp.ba.go new file mode 100644 index 00000000..34ac00ba --- /dev/null +++ b/binapi/l2tp/l2tp.ba.go @@ -0,0 +1,533 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/l2tp.api.json + +// Package l2tp contains generated bindings for API file l2tp.api. +// +// Contents: +// - 1 enum +// - 10 messages +package l2tp + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + _ "github.com/alkiranet/govpp/binapi/ethernet_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "l2tp" + APIVersion = "2.0.0" + VersionCrc = 0x256cef81 +) + +// L2tLookupKey defines enum 'l2t_lookup_key'. +type L2tLookupKey uint8 + +const ( + L2T_LOOKUP_KEY_API_SRC_ADDR L2tLookupKey = 0 + L2T_LOOKUP_KEY_API_DST_ADDR L2tLookupKey = 1 + L2T_LOOKUP_KEY_API_SESSION_ID L2tLookupKey = 2 +) + +var ( + L2tLookupKey_name = map[uint8]string{ + 0: "L2T_LOOKUP_KEY_API_SRC_ADDR", + 1: "L2T_LOOKUP_KEY_API_DST_ADDR", + 2: "L2T_LOOKUP_KEY_API_SESSION_ID", + } + L2tLookupKey_value = map[string]uint8{ + "L2T_LOOKUP_KEY_API_SRC_ADDR": 0, + "L2T_LOOKUP_KEY_API_DST_ADDR": 1, + "L2T_LOOKUP_KEY_API_SESSION_ID": 2, + } +) + +func (x L2tLookupKey) String() string { + s, ok := L2tLookupKey_name[uint8(x)] + if ok { + return s + } + return "L2tLookupKey(" + strconv.Itoa(int(x)) + ")" +} + +// l2tpv3 tunnel interface create request +// - client_address - remote client tunnel ip address +// - client_address - local tunnel ip address +// - is_ipv6 - ipv6 if non-zero, else ipv4 +// - local_session_id - local tunnel session id +// - remote_session_id - remote tunnel session id +// - local_cookie - local tunnel cookie +// - l2_sublayer_present - l2 sublayer is present in packets if non-zero +// - encap_vrf_id - fib identifier used for outgoing encapsulated packets +// +// L2tpv3CreateTunnel defines message 'l2tpv3_create_tunnel'. +type L2tpv3CreateTunnel struct { + ClientAddress ip_types.Address `binapi:"address,name=client_address" json:"client_address,omitempty"` + OurAddress ip_types.Address `binapi:"address,name=our_address" json:"our_address,omitempty"` + LocalSessionID uint32 `binapi:"u32,name=local_session_id" json:"local_session_id,omitempty"` + RemoteSessionID uint32 `binapi:"u32,name=remote_session_id" json:"remote_session_id,omitempty"` + LocalCookie uint64 `binapi:"u64,name=local_cookie" json:"local_cookie,omitempty"` + RemoteCookie uint64 `binapi:"u64,name=remote_cookie" json:"remote_cookie,omitempty"` + L2SublayerPresent bool `binapi:"bool,name=l2_sublayer_present" json:"l2_sublayer_present,omitempty"` + EncapVrfID uint32 `binapi:"u32,name=encap_vrf_id" json:"encap_vrf_id,omitempty"` +} + +func (m *L2tpv3CreateTunnel) Reset() { *m = L2tpv3CreateTunnel{} } +func (*L2tpv3CreateTunnel) GetMessageName() string { return "l2tpv3_create_tunnel" } +func (*L2tpv3CreateTunnel) GetCrcString() string { return "15bed0c2" } +func (*L2tpv3CreateTunnel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *L2tpv3CreateTunnel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.ClientAddress.Af + size += 1 * 16 // m.ClientAddress.Un + size += 1 // m.OurAddress.Af + size += 1 * 16 // m.OurAddress.Un + size += 4 // m.LocalSessionID + size += 4 // m.RemoteSessionID + size += 8 // m.LocalCookie + size += 8 // m.RemoteCookie + size += 1 // m.L2SublayerPresent + size += 4 // m.EncapVrfID + return size +} +func (m *L2tpv3CreateTunnel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.ClientAddress.Af)) + buf.EncodeBytes(m.ClientAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.OurAddress.Af)) + buf.EncodeBytes(m.OurAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.LocalSessionID) + buf.EncodeUint32(m.RemoteSessionID) + buf.EncodeUint64(m.LocalCookie) + buf.EncodeUint64(m.RemoteCookie) + buf.EncodeBool(m.L2SublayerPresent) + buf.EncodeUint32(m.EncapVrfID) + return buf.Bytes(), nil +} +func (m *L2tpv3CreateTunnel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ClientAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.ClientAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.OurAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.OurAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.LocalSessionID = buf.DecodeUint32() + m.RemoteSessionID = buf.DecodeUint32() + m.LocalCookie = buf.DecodeUint64() + m.RemoteCookie = buf.DecodeUint64() + m.L2SublayerPresent = buf.DecodeBool() + m.EncapVrfID = buf.DecodeUint32() + return nil +} + +// l2tpv3 tunnel interface create response +// - retval - return code for the request +// - sw_if_index - index of the new tunnel interface +// +// L2tpv3CreateTunnelReply defines message 'l2tpv3_create_tunnel_reply'. +type L2tpv3CreateTunnelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *L2tpv3CreateTunnelReply) Reset() { *m = L2tpv3CreateTunnelReply{} } +func (*L2tpv3CreateTunnelReply) GetMessageName() string { return "l2tpv3_create_tunnel_reply" } +func (*L2tpv3CreateTunnelReply) GetCrcString() string { return "5383d31f" } +func (*L2tpv3CreateTunnelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *L2tpv3CreateTunnelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *L2tpv3CreateTunnelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *L2tpv3CreateTunnelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// L2tpv3InterfaceEnableDisable defines message 'l2tpv3_interface_enable_disable'. +type L2tpv3InterfaceEnableDisable struct { + EnableDisable bool `binapi:"bool,name=enable_disable" json:"enable_disable,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *L2tpv3InterfaceEnableDisable) Reset() { *m = L2tpv3InterfaceEnableDisable{} } +func (*L2tpv3InterfaceEnableDisable) GetMessageName() string { + return "l2tpv3_interface_enable_disable" +} +func (*L2tpv3InterfaceEnableDisable) GetCrcString() string { return "3865946c" } +func (*L2tpv3InterfaceEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *L2tpv3InterfaceEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.EnableDisable + size += 4 // m.SwIfIndex + return size +} +func (m *L2tpv3InterfaceEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.EnableDisable) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *L2tpv3InterfaceEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EnableDisable = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// L2tpv3InterfaceEnableDisableReply defines message 'l2tpv3_interface_enable_disable_reply'. +type L2tpv3InterfaceEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *L2tpv3InterfaceEnableDisableReply) Reset() { *m = L2tpv3InterfaceEnableDisableReply{} } +func (*L2tpv3InterfaceEnableDisableReply) GetMessageName() string { + return "l2tpv3_interface_enable_disable_reply" +} +func (*L2tpv3InterfaceEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*L2tpv3InterfaceEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *L2tpv3InterfaceEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *L2tpv3InterfaceEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *L2tpv3InterfaceEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// L2tpv3SetLookupKey defines message 'l2tpv3_set_lookup_key'. +type L2tpv3SetLookupKey struct { + Key L2tLookupKey `binapi:"l2t_lookup_key,name=key" json:"key,omitempty"` +} + +func (m *L2tpv3SetLookupKey) Reset() { *m = L2tpv3SetLookupKey{} } +func (*L2tpv3SetLookupKey) GetMessageName() string { return "l2tpv3_set_lookup_key" } +func (*L2tpv3SetLookupKey) GetCrcString() string { return "c9892c86" } +func (*L2tpv3SetLookupKey) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *L2tpv3SetLookupKey) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Key + return size +} +func (m *L2tpv3SetLookupKey) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Key)) + return buf.Bytes(), nil +} +func (m *L2tpv3SetLookupKey) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Key = L2tLookupKey(buf.DecodeUint8()) + return nil +} + +// L2tpv3SetLookupKeyReply defines message 'l2tpv3_set_lookup_key_reply'. +type L2tpv3SetLookupKeyReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *L2tpv3SetLookupKeyReply) Reset() { *m = L2tpv3SetLookupKeyReply{} } +func (*L2tpv3SetLookupKeyReply) GetMessageName() string { return "l2tpv3_set_lookup_key_reply" } +func (*L2tpv3SetLookupKeyReply) GetCrcString() string { return "e8d4e804" } +func (*L2tpv3SetLookupKeyReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *L2tpv3SetLookupKeyReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *L2tpv3SetLookupKeyReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *L2tpv3SetLookupKeyReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// L2tpv3SetTunnelCookies defines message 'l2tpv3_set_tunnel_cookies'. +type L2tpv3SetTunnelCookies struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + NewLocalCookie uint64 `binapi:"u64,name=new_local_cookie" json:"new_local_cookie,omitempty"` + NewRemoteCookie uint64 `binapi:"u64,name=new_remote_cookie" json:"new_remote_cookie,omitempty"` +} + +func (m *L2tpv3SetTunnelCookies) Reset() { *m = L2tpv3SetTunnelCookies{} } +func (*L2tpv3SetTunnelCookies) GetMessageName() string { return "l2tpv3_set_tunnel_cookies" } +func (*L2tpv3SetTunnelCookies) GetCrcString() string { return "b3f4faf7" } +func (*L2tpv3SetTunnelCookies) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *L2tpv3SetTunnelCookies) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 8 // m.NewLocalCookie + size += 8 // m.NewRemoteCookie + return size +} +func (m *L2tpv3SetTunnelCookies) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint64(m.NewLocalCookie) + buf.EncodeUint64(m.NewRemoteCookie) + return buf.Bytes(), nil +} +func (m *L2tpv3SetTunnelCookies) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.NewLocalCookie = buf.DecodeUint64() + m.NewRemoteCookie = buf.DecodeUint64() + return nil +} + +// L2tpv3SetTunnelCookiesReply defines message 'l2tpv3_set_tunnel_cookies_reply'. +type L2tpv3SetTunnelCookiesReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *L2tpv3SetTunnelCookiesReply) Reset() { *m = L2tpv3SetTunnelCookiesReply{} } +func (*L2tpv3SetTunnelCookiesReply) GetMessageName() string { return "l2tpv3_set_tunnel_cookies_reply" } +func (*L2tpv3SetTunnelCookiesReply) GetCrcString() string { return "e8d4e804" } +func (*L2tpv3SetTunnelCookiesReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *L2tpv3SetTunnelCookiesReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *L2tpv3SetTunnelCookiesReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *L2tpv3SetTunnelCookiesReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// SwIfL2tpv3TunnelDetails defines message 'sw_if_l2tpv3_tunnel_details'. +type SwIfL2tpv3TunnelDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + InterfaceName string `binapi:"string[64],name=interface_name" json:"interface_name,omitempty"` + ClientAddress ip_types.Address `binapi:"address,name=client_address" json:"client_address,omitempty"` + OurAddress ip_types.Address `binapi:"address,name=our_address" json:"our_address,omitempty"` + LocalSessionID uint32 `binapi:"u32,name=local_session_id" json:"local_session_id,omitempty"` + RemoteSessionID uint32 `binapi:"u32,name=remote_session_id" json:"remote_session_id,omitempty"` + LocalCookie []uint64 `binapi:"u64[2],name=local_cookie" json:"local_cookie,omitempty"` + RemoteCookie uint64 `binapi:"u64,name=remote_cookie" json:"remote_cookie,omitempty"` + L2SublayerPresent bool `binapi:"bool,name=l2_sublayer_present" json:"l2_sublayer_present,omitempty"` +} + +func (m *SwIfL2tpv3TunnelDetails) Reset() { *m = SwIfL2tpv3TunnelDetails{} } +func (*SwIfL2tpv3TunnelDetails) GetMessageName() string { return "sw_if_l2tpv3_tunnel_details" } +func (*SwIfL2tpv3TunnelDetails) GetCrcString() string { return "50b88993" } +func (*SwIfL2tpv3TunnelDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwIfL2tpv3TunnelDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 64 // m.InterfaceName + size += 1 // m.ClientAddress.Af + size += 1 * 16 // m.ClientAddress.Un + size += 1 // m.OurAddress.Af + size += 1 * 16 // m.OurAddress.Un + size += 4 // m.LocalSessionID + size += 4 // m.RemoteSessionID + size += 8 * 2 // m.LocalCookie + size += 8 // m.RemoteCookie + size += 1 // m.L2SublayerPresent + return size +} +func (m *SwIfL2tpv3TunnelDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeString(m.InterfaceName, 64) + buf.EncodeUint8(uint8(m.ClientAddress.Af)) + buf.EncodeBytes(m.ClientAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.OurAddress.Af)) + buf.EncodeBytes(m.OurAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.LocalSessionID) + buf.EncodeUint32(m.RemoteSessionID) + for i := 0; i < 2; i++ { + var x uint64 + if i < len(m.LocalCookie) { + x = uint64(m.LocalCookie[i]) + } + buf.EncodeUint64(x) + } + buf.EncodeUint64(m.RemoteCookie) + buf.EncodeBool(m.L2SublayerPresent) + return buf.Bytes(), nil +} +func (m *SwIfL2tpv3TunnelDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.InterfaceName = buf.DecodeString(64) + m.ClientAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.ClientAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.OurAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.OurAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.LocalSessionID = buf.DecodeUint32() + m.RemoteSessionID = buf.DecodeUint32() + m.LocalCookie = make([]uint64, 2) + for i := 0; i < len(m.LocalCookie); i++ { + m.LocalCookie[i] = buf.DecodeUint64() + } + m.RemoteCookie = buf.DecodeUint64() + m.L2SublayerPresent = buf.DecodeBool() + return nil +} + +// SwIfL2tpv3TunnelDump defines message 'sw_if_l2tpv3_tunnel_dump'. +type SwIfL2tpv3TunnelDump struct{} + +func (m *SwIfL2tpv3TunnelDump) Reset() { *m = SwIfL2tpv3TunnelDump{} } +func (*SwIfL2tpv3TunnelDump) GetMessageName() string { return "sw_if_l2tpv3_tunnel_dump" } +func (*SwIfL2tpv3TunnelDump) GetCrcString() string { return "51077d14" } +func (*SwIfL2tpv3TunnelDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwIfL2tpv3TunnelDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SwIfL2tpv3TunnelDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SwIfL2tpv3TunnelDump) Unmarshal(b []byte) error { + return nil +} + +func init() { file_l2tp_binapi_init() } +func file_l2tp_binapi_init() { + api.RegisterMessage((*L2tpv3CreateTunnel)(nil), "l2tpv3_create_tunnel_15bed0c2") + api.RegisterMessage((*L2tpv3CreateTunnelReply)(nil), "l2tpv3_create_tunnel_reply_5383d31f") + api.RegisterMessage((*L2tpv3InterfaceEnableDisable)(nil), "l2tpv3_interface_enable_disable_3865946c") + api.RegisterMessage((*L2tpv3InterfaceEnableDisableReply)(nil), "l2tpv3_interface_enable_disable_reply_e8d4e804") + api.RegisterMessage((*L2tpv3SetLookupKey)(nil), "l2tpv3_set_lookup_key_c9892c86") + api.RegisterMessage((*L2tpv3SetLookupKeyReply)(nil), "l2tpv3_set_lookup_key_reply_e8d4e804") + api.RegisterMessage((*L2tpv3SetTunnelCookies)(nil), "l2tpv3_set_tunnel_cookies_b3f4faf7") + api.RegisterMessage((*L2tpv3SetTunnelCookiesReply)(nil), "l2tpv3_set_tunnel_cookies_reply_e8d4e804") + api.RegisterMessage((*SwIfL2tpv3TunnelDetails)(nil), "sw_if_l2tpv3_tunnel_details_50b88993") + api.RegisterMessage((*SwIfL2tpv3TunnelDump)(nil), "sw_if_l2tpv3_tunnel_dump_51077d14") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*L2tpv3CreateTunnel)(nil), + (*L2tpv3CreateTunnelReply)(nil), + (*L2tpv3InterfaceEnableDisable)(nil), + (*L2tpv3InterfaceEnableDisableReply)(nil), + (*L2tpv3SetLookupKey)(nil), + (*L2tpv3SetLookupKeyReply)(nil), + (*L2tpv3SetTunnelCookies)(nil), + (*L2tpv3SetTunnelCookiesReply)(nil), + (*SwIfL2tpv3TunnelDetails)(nil), + (*SwIfL2tpv3TunnelDump)(nil), + } +} diff --git a/binapi/l2tp/l2tp_rpc.ba.go b/binapi/l2tp/l2tp_rpc.ba.go new file mode 100644 index 00000000..5b99521e --- /dev/null +++ b/binapi/l2tp/l2tp_rpc.ba.go @@ -0,0 +1,108 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package l2tp + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service l2tp. +type RPCService interface { + L2tpv3CreateTunnel(ctx context.Context, in *L2tpv3CreateTunnel) (*L2tpv3CreateTunnelReply, error) + L2tpv3InterfaceEnableDisable(ctx context.Context, in *L2tpv3InterfaceEnableDisable) (*L2tpv3InterfaceEnableDisableReply, error) + L2tpv3SetLookupKey(ctx context.Context, in *L2tpv3SetLookupKey) (*L2tpv3SetLookupKeyReply, error) + L2tpv3SetTunnelCookies(ctx context.Context, in *L2tpv3SetTunnelCookies) (*L2tpv3SetTunnelCookiesReply, error) + SwIfL2tpv3TunnelDump(ctx context.Context, in *SwIfL2tpv3TunnelDump) (RPCService_SwIfL2tpv3TunnelDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) L2tpv3CreateTunnel(ctx context.Context, in *L2tpv3CreateTunnel) (*L2tpv3CreateTunnelReply, error) { + out := new(L2tpv3CreateTunnelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) L2tpv3InterfaceEnableDisable(ctx context.Context, in *L2tpv3InterfaceEnableDisable) (*L2tpv3InterfaceEnableDisableReply, error) { + out := new(L2tpv3InterfaceEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) L2tpv3SetLookupKey(ctx context.Context, in *L2tpv3SetLookupKey) (*L2tpv3SetLookupKeyReply, error) { + out := new(L2tpv3SetLookupKeyReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) L2tpv3SetTunnelCookies(ctx context.Context, in *L2tpv3SetTunnelCookies) (*L2tpv3SetTunnelCookiesReply, error) { + out := new(L2tpv3SetTunnelCookiesReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwIfL2tpv3TunnelDump(ctx context.Context, in *SwIfL2tpv3TunnelDump) (RPCService_SwIfL2tpv3TunnelDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SwIfL2tpv3TunnelDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SwIfL2tpv3TunnelDumpClient interface { + Recv() (*SwIfL2tpv3TunnelDetails, error) + api.Stream +} + +type serviceClient_SwIfL2tpv3TunnelDumpClient struct { + api.Stream +} + +func (c *serviceClient_SwIfL2tpv3TunnelDumpClient) Recv() (*SwIfL2tpv3TunnelDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SwIfL2tpv3TunnelDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/l3xc/l3xc.ba.go b/binapi/l3xc/l3xc.ba.go new file mode 100644 index 00000000..5aacc779 --- /dev/null +++ b/binapi/l3xc/l3xc.ba.go @@ -0,0 +1,506 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/l3xc.api.json + +// Package l3xc contains generated bindings for API file l3xc.api. +// +// Contents: +// - 1 struct +// - 8 messages +package l3xc + +import ( + api "github.com/alkiranet/govpp/api" + fib_types "github.com/alkiranet/govpp/binapi/fib_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + _ "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "l3xc" + APIVersion = "1.0.1" + VersionCrc = 0x520bfc6e +) + +// L3xc defines type 'l3xc'. +type L3xc struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IsIP6 bool `binapi:"bool,name=is_ip6" json:"is_ip6,omitempty"` + NPaths uint8 `binapi:"u8,name=n_paths" json:"-"` + Paths []fib_types.FibPath `binapi:"fib_path[n_paths],name=paths" json:"paths,omitempty"` +} + +// L3xcDel defines message 'l3xc_del'. +type L3xcDel struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IsIP6 bool `binapi:"bool,name=is_ip6" json:"is_ip6,omitempty"` +} + +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 +} + +func (m *L3xcDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.IsIP6 + return size +} +func (m *L3xcDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.IsIP6) + return buf.Bytes(), nil +} +func (m *L3xcDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsIP6 = buf.DecodeBool() + return nil +} + +// L3xcDelReply defines message 'l3xc_del_reply'. +type L3xcDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *L3xcDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *L3xcDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *L3xcDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// description returned in the dump +// L3xcDetails defines message 'l3xc_details'. +type L3xcDetails struct { + L3xc L3xc `binapi:"l3xc,name=l3xc" json:"l3xc,omitempty"` +} + +func (m *L3xcDetails) Reset() { *m = L3xcDetails{} } +func (*L3xcDetails) GetMessageName() string { return "l3xc_details" } +func (*L3xcDetails) GetCrcString() string { return "bc5bf852" } +func (*L3xcDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *L3xcDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.L3xc.SwIfIndex + size += 1 // m.L3xc.IsIP6 + size += 1 // m.L3xc.NPaths + for j2 := 0; j2 < len(m.L3xc.Paths); j2++ { + var s2 fib_types.FibPath + _ = s2 + if j2 < len(m.L3xc.Paths) { + s2 = m.L3xc.Paths[j2] + } + size += 4 // s2.SwIfIndex + size += 4 // s2.TableID + size += 4 // s2.RpfID + size += 1 // s2.Weight + size += 1 // s2.Preference + size += 4 // s2.Type + size += 4 // s2.Flags + size += 4 // s2.Proto + size += 1 * 16 // s2.Nh.Address + size += 4 // s2.Nh.ViaLabel + size += 4 // s2.Nh.ObjID + size += 4 // s2.Nh.ClassifyTableIndex + size += 1 // s2.NLabels + for j3 := 0; j3 < 16; j3++ { + size += 1 // s2.LabelStack[j3].IsUniform + size += 4 // s2.LabelStack[j3].Label + size += 1 // s2.LabelStack[j3].TTL + size += 1 // s2.LabelStack[j3].Exp + } + } + return size +} +func (m *L3xcDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.L3xc.SwIfIndex)) + buf.EncodeBool(m.L3xc.IsIP6) + buf.EncodeUint8(uint8(len(m.L3xc.Paths))) + for j1 := 0; j1 < len(m.L3xc.Paths); j1++ { + var v1 fib_types.FibPath // Paths + if j1 < len(m.L3xc.Paths) { + v1 = m.L3xc.Paths[j1] + } + buf.EncodeUint32(v1.SwIfIndex) + buf.EncodeUint32(v1.TableID) + buf.EncodeUint32(v1.RpfID) + buf.EncodeUint8(v1.Weight) + buf.EncodeUint8(v1.Preference) + buf.EncodeUint32(uint32(v1.Type)) + buf.EncodeUint32(uint32(v1.Flags)) + buf.EncodeUint32(uint32(v1.Proto)) + buf.EncodeBytes(v1.Nh.Address.XXX_UnionData[:], 16) + buf.EncodeUint32(v1.Nh.ViaLabel) + buf.EncodeUint32(v1.Nh.ObjID) + buf.EncodeUint32(v1.Nh.ClassifyTableIndex) + buf.EncodeUint8(v1.NLabels) + for j2 := 0; j2 < 16; j2++ { + buf.EncodeUint8(v1.LabelStack[j2].IsUniform) + buf.EncodeUint32(v1.LabelStack[j2].Label) + buf.EncodeUint8(v1.LabelStack[j2].TTL) + buf.EncodeUint8(v1.LabelStack[j2].Exp) + } + } + return buf.Bytes(), nil +} +func (m *L3xcDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.L3xc.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.L3xc.IsIP6 = buf.DecodeBool() + m.L3xc.NPaths = buf.DecodeUint8() + m.L3xc.Paths = make([]fib_types.FibPath, m.L3xc.NPaths) + for j1 := 0; j1 < len(m.L3xc.Paths); j1++ { + m.L3xc.Paths[j1].SwIfIndex = buf.DecodeUint32() + m.L3xc.Paths[j1].TableID = buf.DecodeUint32() + m.L3xc.Paths[j1].RpfID = buf.DecodeUint32() + m.L3xc.Paths[j1].Weight = buf.DecodeUint8() + m.L3xc.Paths[j1].Preference = buf.DecodeUint8() + m.L3xc.Paths[j1].Type = fib_types.FibPathType(buf.DecodeUint32()) + m.L3xc.Paths[j1].Flags = fib_types.FibPathFlags(buf.DecodeUint32()) + m.L3xc.Paths[j1].Proto = fib_types.FibPathNhProto(buf.DecodeUint32()) + copy(m.L3xc.Paths[j1].Nh.Address.XXX_UnionData[:], buf.DecodeBytes(16)) + m.L3xc.Paths[j1].Nh.ViaLabel = buf.DecodeUint32() + m.L3xc.Paths[j1].Nh.ObjID = buf.DecodeUint32() + m.L3xc.Paths[j1].Nh.ClassifyTableIndex = buf.DecodeUint32() + m.L3xc.Paths[j1].NLabels = buf.DecodeUint8() + for j2 := 0; j2 < 16; j2++ { + m.L3xc.Paths[j1].LabelStack[j2].IsUniform = buf.DecodeUint8() + m.L3xc.Paths[j1].LabelStack[j2].Label = buf.DecodeUint32() + m.L3xc.Paths[j1].LabelStack[j2].TTL = buf.DecodeUint8() + m.L3xc.Paths[j1].LabelStack[j2].Exp = buf.DecodeUint8() + } + } + return nil +} + +// Dump all L3XC policies +// L3xcDump defines message 'l3xc_dump'. +type L3xcDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *L3xcDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *L3xcDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *L3xcDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Get the plugin version +// L3xcPluginGetVersion defines 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 +} + +func (m *L3xcPluginGetVersion) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *L3xcPluginGetVersion) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *L3xcPluginGetVersion) Unmarshal(b []byte) error { + return nil +} + +// Reply to get the plugin version +// - major - Incremented every time a known breaking behavior change is introduced +// - minor - Incremented with small changes, may be used to avoid buggy versions +// +// L3xcPluginGetVersionReply defines message 'l3xc_plugin_get_version_reply'. +type L3xcPluginGetVersionReply struct { + Major uint32 `binapi:"u32,name=major" json:"major,omitempty"` + Minor uint32 `binapi:"u32,name=minor" json:"minor,omitempty"` +} + +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 +} + +func (m *L3xcPluginGetVersionReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Major + size += 4 // m.Minor + return size +} +func (m *L3xcPluginGetVersionReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Major) + buf.EncodeUint32(m.Minor) + return buf.Bytes(), nil +} +func (m *L3xcPluginGetVersionReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Major = buf.DecodeUint32() + m.Minor = buf.DecodeUint32() + return nil +} + +// A description of an L3XC policy +// - input interface of the x-connect +// - n_paths Number of paths +// - paths The set of forwarding paths. +// +// L3xcUpdate defines message 'l3xc_update'. +type L3xcUpdate struct { + L3xc L3xc `binapi:"l3xc,name=l3xc" json:"l3xc,omitempty"` +} + +func (m *L3xcUpdate) Reset() { *m = L3xcUpdate{} } +func (*L3xcUpdate) GetMessageName() string { return "l3xc_update" } +func (*L3xcUpdate) GetCrcString() string { return "e96aabdf" } +func (*L3xcUpdate) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *L3xcUpdate) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.L3xc.SwIfIndex + size += 1 // m.L3xc.IsIP6 + size += 1 // m.L3xc.NPaths + for j2 := 0; j2 < len(m.L3xc.Paths); j2++ { + var s2 fib_types.FibPath + _ = s2 + if j2 < len(m.L3xc.Paths) { + s2 = m.L3xc.Paths[j2] + } + size += 4 // s2.SwIfIndex + size += 4 // s2.TableID + size += 4 // s2.RpfID + size += 1 // s2.Weight + size += 1 // s2.Preference + size += 4 // s2.Type + size += 4 // s2.Flags + size += 4 // s2.Proto + size += 1 * 16 // s2.Nh.Address + size += 4 // s2.Nh.ViaLabel + size += 4 // s2.Nh.ObjID + size += 4 // s2.Nh.ClassifyTableIndex + size += 1 // s2.NLabels + for j3 := 0; j3 < 16; j3++ { + size += 1 // s2.LabelStack[j3].IsUniform + size += 4 // s2.LabelStack[j3].Label + size += 1 // s2.LabelStack[j3].TTL + size += 1 // s2.LabelStack[j3].Exp + } + } + return size +} +func (m *L3xcUpdate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.L3xc.SwIfIndex)) + buf.EncodeBool(m.L3xc.IsIP6) + buf.EncodeUint8(uint8(len(m.L3xc.Paths))) + for j1 := 0; j1 < len(m.L3xc.Paths); j1++ { + var v1 fib_types.FibPath // Paths + if j1 < len(m.L3xc.Paths) { + v1 = m.L3xc.Paths[j1] + } + buf.EncodeUint32(v1.SwIfIndex) + buf.EncodeUint32(v1.TableID) + buf.EncodeUint32(v1.RpfID) + buf.EncodeUint8(v1.Weight) + buf.EncodeUint8(v1.Preference) + buf.EncodeUint32(uint32(v1.Type)) + buf.EncodeUint32(uint32(v1.Flags)) + buf.EncodeUint32(uint32(v1.Proto)) + buf.EncodeBytes(v1.Nh.Address.XXX_UnionData[:], 16) + buf.EncodeUint32(v1.Nh.ViaLabel) + buf.EncodeUint32(v1.Nh.ObjID) + buf.EncodeUint32(v1.Nh.ClassifyTableIndex) + buf.EncodeUint8(v1.NLabels) + for j2 := 0; j2 < 16; j2++ { + buf.EncodeUint8(v1.LabelStack[j2].IsUniform) + buf.EncodeUint32(v1.LabelStack[j2].Label) + buf.EncodeUint8(v1.LabelStack[j2].TTL) + buf.EncodeUint8(v1.LabelStack[j2].Exp) + } + } + return buf.Bytes(), nil +} +func (m *L3xcUpdate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.L3xc.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.L3xc.IsIP6 = buf.DecodeBool() + m.L3xc.NPaths = buf.DecodeUint8() + m.L3xc.Paths = make([]fib_types.FibPath, m.L3xc.NPaths) + for j1 := 0; j1 < len(m.L3xc.Paths); j1++ { + m.L3xc.Paths[j1].SwIfIndex = buf.DecodeUint32() + m.L3xc.Paths[j1].TableID = buf.DecodeUint32() + m.L3xc.Paths[j1].RpfID = buf.DecodeUint32() + m.L3xc.Paths[j1].Weight = buf.DecodeUint8() + m.L3xc.Paths[j1].Preference = buf.DecodeUint8() + m.L3xc.Paths[j1].Type = fib_types.FibPathType(buf.DecodeUint32()) + m.L3xc.Paths[j1].Flags = fib_types.FibPathFlags(buf.DecodeUint32()) + m.L3xc.Paths[j1].Proto = fib_types.FibPathNhProto(buf.DecodeUint32()) + copy(m.L3xc.Paths[j1].Nh.Address.XXX_UnionData[:], buf.DecodeBytes(16)) + m.L3xc.Paths[j1].Nh.ViaLabel = buf.DecodeUint32() + m.L3xc.Paths[j1].Nh.ObjID = buf.DecodeUint32() + m.L3xc.Paths[j1].Nh.ClassifyTableIndex = buf.DecodeUint32() + m.L3xc.Paths[j1].NLabels = buf.DecodeUint8() + for j2 := 0; j2 < 16; j2++ { + m.L3xc.Paths[j1].LabelStack[j2].IsUniform = buf.DecodeUint8() + m.L3xc.Paths[j1].LabelStack[j2].Label = buf.DecodeUint32() + m.L3xc.Paths[j1].LabelStack[j2].TTL = buf.DecodeUint8() + m.L3xc.Paths[j1].LabelStack[j2].Exp = buf.DecodeUint8() + } + } + return nil +} + +// L3xcUpdateReply defines message 'l3xc_update_reply'. +type L3xcUpdateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + StatsIndex uint32 `binapi:"u32,name=stats_index" json:"stats_index,omitempty"` +} + +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 (m *L3xcUpdateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.StatsIndex + return size +} +func (m *L3xcUpdateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.StatsIndex) + return buf.Bytes(), nil +} +func (m *L3xcUpdateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.StatsIndex = buf.DecodeUint32() + return nil +} + +func init() { file_l3xc_binapi_init() } +func file_l3xc_binapi_init() { + api.RegisterMessage((*L3xcDel)(nil), "l3xc_del_e7dbef91") + api.RegisterMessage((*L3xcDelReply)(nil), "l3xc_del_reply_e8d4e804") + api.RegisterMessage((*L3xcDetails)(nil), "l3xc_details_bc5bf852") + api.RegisterMessage((*L3xcDump)(nil), "l3xc_dump_f9e6675e") + api.RegisterMessage((*L3xcPluginGetVersion)(nil), "l3xc_plugin_get_version_51077d14") + api.RegisterMessage((*L3xcPluginGetVersionReply)(nil), "l3xc_plugin_get_version_reply_9b32cf86") + api.RegisterMessage((*L3xcUpdate)(nil), "l3xc_update_e96aabdf") + api.RegisterMessage((*L3xcUpdateReply)(nil), "l3xc_update_reply_1992deab") +} + +// 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), + } +} diff --git a/binapi/l3xc/l3xc_rpc.ba.go b/binapi/l3xc/l3xc_rpc.ba.go new file mode 100644 index 00000000..3d47d386 --- /dev/null +++ b/binapi/l3xc/l3xc_rpc.ba.go @@ -0,0 +1,98 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package l3xc + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service l3xc. +type RPCService interface { + L3xcDel(ctx context.Context, in *L3xcDel) (*L3xcDelReply, error) + L3xcDump(ctx context.Context, in *L3xcDump) (RPCService_L3xcDumpClient, error) + L3xcPluginGetVersion(ctx context.Context, in *L3xcPluginGetVersion) (*L3xcPluginGetVersionReply, error) + L3xcUpdate(ctx context.Context, in *L3xcUpdate) (*L3xcUpdateReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) L3xcDel(ctx context.Context, in *L3xcDel) (*L3xcDelReply, error) { + out := new(L3xcDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) L3xcDump(ctx context.Context, in *L3xcDump) (RPCService_L3xcDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_L3xcDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_L3xcDumpClient interface { + Recv() (*L3xcDetails, error) + api.Stream +} + +type serviceClient_L3xcDumpClient struct { + api.Stream +} + +func (c *serviceClient_L3xcDumpClient) Recv() (*L3xcDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *L3xcDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) L3xcPluginGetVersion(ctx context.Context, in *L3xcPluginGetVersion) (*L3xcPluginGetVersionReply, error) { + out := new(L3xcPluginGetVersionReply) + err := c.conn.Invoke(ctx, in, 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.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/lacp/lacp.ba.go b/binapi/lacp/lacp.ba.go new file mode 100644 index 00000000..daea77f2 --- /dev/null +++ b/binapi/lacp/lacp.ba.go @@ -0,0 +1,198 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/lacp.api.json + +// Package lacp contains generated bindings for API file lacp.api. +// +// Contents: +// - 2 messages +package lacp + +import ( + api "github.com/alkiranet/govpp/api" + ethernet_types "github.com/alkiranet/govpp/binapi/ethernet_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "lacp" + APIVersion = "2.0.0" + VersionCrc = 0xe1609dab +) + +// Reply for lacp dump request +// - sw_if_index - software index of member interface +// - interface_name - name of member interface +// - rx_state - rx machine state +// - tx_state - tx machine state +// - mux_state - mux machine state +// - ptx_state - ptx machine state +// - bond_interface_name - name of bond interface +// - actor_system_priority - actor system priority +// - actor_system - actor system +// - actor_key - actor key +// - actor_port_priority - actor port priority +// - actor_port_number - actor port number +// - actor_state - actor state +// - partner_system_priority - partner system priority +// - partner_system - partner system +// - partner_key - partner key +// - partner_port_priority - partner port priority +// - partner_port_number - partner port number +// - partner_state - partner state +// +// SwInterfaceLacpDetails defines message 'sw_interface_lacp_details'. +type SwInterfaceLacpDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + InterfaceName string `binapi:"string[64],name=interface_name" json:"interface_name,omitempty"` + RxState uint32 `binapi:"u32,name=rx_state" json:"rx_state,omitempty"` + TxState uint32 `binapi:"u32,name=tx_state" json:"tx_state,omitempty"` + MuxState uint32 `binapi:"u32,name=mux_state" json:"mux_state,omitempty"` + PtxState uint32 `binapi:"u32,name=ptx_state" json:"ptx_state,omitempty"` + BondInterfaceName string `binapi:"string[64],name=bond_interface_name" json:"bond_interface_name,omitempty"` + ActorSystemPriority uint16 `binapi:"u16,name=actor_system_priority" json:"actor_system_priority,omitempty"` + ActorSystem ethernet_types.MacAddress `binapi:"mac_address,name=actor_system" json:"actor_system,omitempty"` + ActorKey uint16 `binapi:"u16,name=actor_key" json:"actor_key,omitempty"` + ActorPortPriority uint16 `binapi:"u16,name=actor_port_priority" json:"actor_port_priority,omitempty"` + ActorPortNumber uint16 `binapi:"u16,name=actor_port_number" json:"actor_port_number,omitempty"` + ActorState uint8 `binapi:"u8,name=actor_state" json:"actor_state,omitempty"` + PartnerSystemPriority uint16 `binapi:"u16,name=partner_system_priority" json:"partner_system_priority,omitempty"` + PartnerSystem ethernet_types.MacAddress `binapi:"mac_address,name=partner_system" json:"partner_system,omitempty"` + PartnerKey uint16 `binapi:"u16,name=partner_key" json:"partner_key,omitempty"` + PartnerPortPriority uint16 `binapi:"u16,name=partner_port_priority" json:"partner_port_priority,omitempty"` + PartnerPortNumber uint16 `binapi:"u16,name=partner_port_number" json:"partner_port_number,omitempty"` + PartnerState uint8 `binapi:"u8,name=partner_state" json:"partner_state,omitempty"` +} + +func (m *SwInterfaceLacpDetails) Reset() { *m = SwInterfaceLacpDetails{} } +func (*SwInterfaceLacpDetails) GetMessageName() string { return "sw_interface_lacp_details" } +func (*SwInterfaceLacpDetails) GetCrcString() string { return "d9a83d2f" } +func (*SwInterfaceLacpDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwInterfaceLacpDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 64 // m.InterfaceName + size += 4 // m.RxState + size += 4 // m.TxState + size += 4 // m.MuxState + size += 4 // m.PtxState + size += 64 // m.BondInterfaceName + size += 2 // m.ActorSystemPriority + size += 1 * 6 // m.ActorSystem + size += 2 // m.ActorKey + size += 2 // m.ActorPortPriority + size += 2 // m.ActorPortNumber + size += 1 // m.ActorState + size += 2 // m.PartnerSystemPriority + size += 1 * 6 // m.PartnerSystem + size += 2 // m.PartnerKey + size += 2 // m.PartnerPortPriority + size += 2 // m.PartnerPortNumber + size += 1 // m.PartnerState + return size +} +func (m *SwInterfaceLacpDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeString(m.InterfaceName, 64) + buf.EncodeUint32(m.RxState) + buf.EncodeUint32(m.TxState) + buf.EncodeUint32(m.MuxState) + buf.EncodeUint32(m.PtxState) + buf.EncodeString(m.BondInterfaceName, 64) + buf.EncodeUint16(m.ActorSystemPriority) + buf.EncodeBytes(m.ActorSystem[:], 6) + buf.EncodeUint16(m.ActorKey) + buf.EncodeUint16(m.ActorPortPriority) + buf.EncodeUint16(m.ActorPortNumber) + buf.EncodeUint8(m.ActorState) + buf.EncodeUint16(m.PartnerSystemPriority) + buf.EncodeBytes(m.PartnerSystem[:], 6) + buf.EncodeUint16(m.PartnerKey) + buf.EncodeUint16(m.PartnerPortPriority) + buf.EncodeUint16(m.PartnerPortNumber) + buf.EncodeUint8(m.PartnerState) + return buf.Bytes(), nil +} +func (m *SwInterfaceLacpDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.InterfaceName = buf.DecodeString(64) + m.RxState = buf.DecodeUint32() + m.TxState = buf.DecodeUint32() + m.MuxState = buf.DecodeUint32() + m.PtxState = buf.DecodeUint32() + m.BondInterfaceName = buf.DecodeString(64) + m.ActorSystemPriority = buf.DecodeUint16() + copy(m.ActorSystem[:], buf.DecodeBytes(6)) + m.ActorKey = buf.DecodeUint16() + m.ActorPortPriority = buf.DecodeUint16() + m.ActorPortNumber = buf.DecodeUint16() + m.ActorState = buf.DecodeUint8() + m.PartnerSystemPriority = buf.DecodeUint16() + copy(m.PartnerSystem[:], buf.DecodeBytes(6)) + m.PartnerKey = buf.DecodeUint16() + m.PartnerPortPriority = buf.DecodeUint16() + m.PartnerPortNumber = buf.DecodeUint16() + m.PartnerState = buf.DecodeUint8() + return nil +} + +// Dump lacp interfaces request +// SwInterfaceLacpDump defines message 'sw_interface_lacp_dump'. +type SwInterfaceLacpDump struct{} + +func (m *SwInterfaceLacpDump) Reset() { *m = SwInterfaceLacpDump{} } +func (*SwInterfaceLacpDump) GetMessageName() string { return "sw_interface_lacp_dump" } +func (*SwInterfaceLacpDump) GetCrcString() string { return "51077d14" } +func (*SwInterfaceLacpDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceLacpDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SwInterfaceLacpDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SwInterfaceLacpDump) Unmarshal(b []byte) error { + return nil +} + +func init() { file_lacp_binapi_init() } +func file_lacp_binapi_init() { + api.RegisterMessage((*SwInterfaceLacpDetails)(nil), "sw_interface_lacp_details_d9a83d2f") + api.RegisterMessage((*SwInterfaceLacpDump)(nil), "sw_interface_lacp_dump_51077d14") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*SwInterfaceLacpDetails)(nil), + (*SwInterfaceLacpDump)(nil), + } +} diff --git a/binapi/lacp/lacp_rpc.ba.go b/binapi/lacp/lacp_rpc.ba.go new file mode 100644 index 00000000..1cc76b51 --- /dev/null +++ b/binapi/lacp/lacp_rpc.ba.go @@ -0,0 +1,68 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package lacp + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service lacp. +type RPCService interface { + SwInterfaceLacpDump(ctx context.Context, in *SwInterfaceLacpDump) (RPCService_SwInterfaceLacpDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) SwInterfaceLacpDump(ctx context.Context, in *SwInterfaceLacpDump) (RPCService_SwInterfaceLacpDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SwInterfaceLacpDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SwInterfaceLacpDumpClient interface { + Recv() (*SwInterfaceLacpDetails, error) + api.Stream +} + +type serviceClient_SwInterfaceLacpDumpClient struct { + api.Stream +} + +func (c *serviceClient_SwInterfaceLacpDumpClient) Recv() (*SwInterfaceLacpDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SwInterfaceLacpDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/lb/lb.ba.go b/binapi/lb/lb.ba.go new file mode 100644 index 00000000..72b24c55 --- /dev/null +++ b/binapi/lb/lb.ba.go @@ -0,0 +1,984 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/lb.api.json + +// Package lb contains generated bindings for API file lb.api. +// +// Contents: +// - 18 messages +package lb + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + lb_types "github.com/alkiranet/govpp/binapi/lb_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "lb" + APIVersion = "1.1.0" + VersionCrc = 0x49e3c1c1 +) + +// Add an application server for a given VIP +// - pfx - ip prefix and length +// - protocol - tcp or udp. +// - port - destination port. +// - as_address - The application server address (IPv4 in lower order 32 bits). +// - is_del - The AS should be removed. +// - is_flush - The sessions related to this AS should be flushed. +// +// LbAddDelAs defines message 'lb_add_del_as'. +type LbAddDelAs struct { + Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"` + Protocol uint8 `binapi:"u8,name=protocol,default=255" json:"protocol,omitempty"` + Port uint16 `binapi:"u16,name=port" json:"port,omitempty"` + AsAddress ip_types.Address `binapi:"address,name=as_address" json:"as_address,omitempty"` + IsDel bool `binapi:"bool,name=is_del" json:"is_del,omitempty"` + IsFlush bool `binapi:"bool,name=is_flush" json:"is_flush,omitempty"` +} + +func (m *LbAddDelAs) Reset() { *m = LbAddDelAs{} } +func (*LbAddDelAs) GetMessageName() string { return "lb_add_del_as" } +func (*LbAddDelAs) GetCrcString() string { return "35d72500" } +func (*LbAddDelAs) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LbAddDelAs) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Pfx.Address.Af + size += 1 * 16 // m.Pfx.Address.Un + size += 1 // m.Pfx.Len + size += 1 // m.Protocol + size += 2 // m.Port + size += 1 // m.AsAddress.Af + size += 1 * 16 // m.AsAddress.Un + size += 1 // m.IsDel + size += 1 // m.IsFlush + return size +} +func (m *LbAddDelAs) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Pfx.Address.Af)) + buf.EncodeBytes(m.Pfx.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Pfx.Len) + buf.EncodeUint8(m.Protocol) + buf.EncodeUint16(m.Port) + buf.EncodeUint8(uint8(m.AsAddress.Af)) + buf.EncodeBytes(m.AsAddress.Un.XXX_UnionData[:], 16) + buf.EncodeBool(m.IsDel) + buf.EncodeBool(m.IsFlush) + return buf.Bytes(), nil +} +func (m *LbAddDelAs) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Pfx.Len = buf.DecodeUint8() + m.Protocol = buf.DecodeUint8() + m.Port = buf.DecodeUint16() + m.AsAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.AsAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.IsDel = buf.DecodeBool() + m.IsFlush = buf.DecodeBool() + return nil +} + +// LbAddDelAsReply defines message 'lb_add_del_as_reply'. +type LbAddDelAsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LbAddDelAsReply) Reset() { *m = LbAddDelAsReply{} } +func (*LbAddDelAsReply) GetMessageName() string { return "lb_add_del_as_reply" } +func (*LbAddDelAsReply) GetCrcString() string { return "e8d4e804" } +func (*LbAddDelAsReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LbAddDelAsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LbAddDelAsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LbAddDelAsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Enable/disable NAT4 feature on the interface +// - is_add - true if add, false if delete +// - sw_if_index - software index of the interface +// +// LbAddDelIntfNat4 defines message 'lb_add_del_intf_nat4'. +type LbAddDelIntfNat4 struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *LbAddDelIntfNat4) Reset() { *m = LbAddDelIntfNat4{} } +func (*LbAddDelIntfNat4) GetMessageName() string { return "lb_add_del_intf_nat4" } +func (*LbAddDelIntfNat4) GetCrcString() string { return "47d6e753" } +func (*LbAddDelIntfNat4) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LbAddDelIntfNat4) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.SwIfIndex + return size +} +func (m *LbAddDelIntfNat4) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *LbAddDelIntfNat4) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// LbAddDelIntfNat4Reply defines message 'lb_add_del_intf_nat4_reply'. +type LbAddDelIntfNat4Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LbAddDelIntfNat4Reply) Reset() { *m = LbAddDelIntfNat4Reply{} } +func (*LbAddDelIntfNat4Reply) GetMessageName() string { return "lb_add_del_intf_nat4_reply" } +func (*LbAddDelIntfNat4Reply) GetCrcString() string { return "e8d4e804" } +func (*LbAddDelIntfNat4Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LbAddDelIntfNat4Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LbAddDelIntfNat4Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LbAddDelIntfNat4Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Enable/disable NAT6 feature on the interface +// - is_add - true if add, false if delete +// - sw_if_index - software index of the interface +// +// LbAddDelIntfNat6 defines message 'lb_add_del_intf_nat6'. +type LbAddDelIntfNat6 struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *LbAddDelIntfNat6) Reset() { *m = LbAddDelIntfNat6{} } +func (*LbAddDelIntfNat6) GetMessageName() string { return "lb_add_del_intf_nat6" } +func (*LbAddDelIntfNat6) GetCrcString() string { return "47d6e753" } +func (*LbAddDelIntfNat6) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LbAddDelIntfNat6) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.SwIfIndex + return size +} +func (m *LbAddDelIntfNat6) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *LbAddDelIntfNat6) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// LbAddDelIntfNat6Reply defines message 'lb_add_del_intf_nat6_reply'. +type LbAddDelIntfNat6Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LbAddDelIntfNat6Reply) Reset() { *m = LbAddDelIntfNat6Reply{} } +func (*LbAddDelIntfNat6Reply) GetMessageName() string { return "lb_add_del_intf_nat6_reply" } +func (*LbAddDelIntfNat6Reply) GetCrcString() string { return "e8d4e804" } +func (*LbAddDelIntfNat6Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LbAddDelIntfNat6Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LbAddDelIntfNat6Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LbAddDelIntfNat6Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add a virtual address (or prefix) +// - pfx - ip prefix and length +// - protocol - tcp or udp. +// - port - destination port. (0) means 'all-port VIP' +// - encap - Encap is ip4 GRE(0) or ip6 GRE(1) or L3DSR(2) or NAT4(3) or NAT6(4). +// - dscp - DSCP bit corresponding to VIP(applicable in L3DSR mode only). +// - type - service type(applicable in NAT4/NAT6 mode only). +// - target_port - Pod's port corresponding to specific service(applicable in NAT4/NAT6 mode only). +// - node_port - Node's port(applicable in NAT4/NAT6 mode only). +// - new_flows_table_length - Size of the new connections flow table used +// for this VIP (must be power of 2). +// - is_del - The VIP should be removed. +// +// LbAddDelVip defines message 'lb_add_del_vip'. +type LbAddDelVip struct { + Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"` + Protocol uint8 `binapi:"u8,name=protocol,default=255" json:"protocol,omitempty"` + Port uint16 `binapi:"u16,name=port" json:"port,omitempty"` + Encap lb_types.LbEncapType `binapi:"lb_encap_type,name=encap" json:"encap,omitempty"` + Dscp uint8 `binapi:"u8,name=dscp" json:"dscp,omitempty"` + Type lb_types.LbSrvType `binapi:"lb_srv_type,name=type" json:"type,omitempty"` + TargetPort uint16 `binapi:"u16,name=target_port" json:"target_port,omitempty"` + NodePort uint16 `binapi:"u16,name=node_port" json:"node_port,omitempty"` + NewFlowsTableLength uint32 `binapi:"u32,name=new_flows_table_length,default=1024" json:"new_flows_table_length,omitempty"` + IsDel bool `binapi:"bool,name=is_del" json:"is_del,omitempty"` +} + +func (m *LbAddDelVip) Reset() { *m = LbAddDelVip{} } +func (*LbAddDelVip) GetMessageName() string { return "lb_add_del_vip" } +func (*LbAddDelVip) GetCrcString() string { return "6fa569c7" } +func (*LbAddDelVip) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LbAddDelVip) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Pfx.Address.Af + size += 1 * 16 // m.Pfx.Address.Un + size += 1 // m.Pfx.Len + size += 1 // m.Protocol + size += 2 // m.Port + size += 4 // m.Encap + size += 1 // m.Dscp + size += 4 // m.Type + size += 2 // m.TargetPort + size += 2 // m.NodePort + size += 4 // m.NewFlowsTableLength + size += 1 // m.IsDel + return size +} +func (m *LbAddDelVip) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Pfx.Address.Af)) + buf.EncodeBytes(m.Pfx.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Pfx.Len) + buf.EncodeUint8(m.Protocol) + buf.EncodeUint16(m.Port) + buf.EncodeUint32(uint32(m.Encap)) + buf.EncodeUint8(m.Dscp) + buf.EncodeUint32(uint32(m.Type)) + buf.EncodeUint16(m.TargetPort) + buf.EncodeUint16(m.NodePort) + buf.EncodeUint32(m.NewFlowsTableLength) + buf.EncodeBool(m.IsDel) + return buf.Bytes(), nil +} +func (m *LbAddDelVip) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Pfx.Len = buf.DecodeUint8() + m.Protocol = buf.DecodeUint8() + m.Port = buf.DecodeUint16() + m.Encap = lb_types.LbEncapType(buf.DecodeUint32()) + m.Dscp = buf.DecodeUint8() + m.Type = lb_types.LbSrvType(buf.DecodeUint32()) + m.TargetPort = buf.DecodeUint16() + m.NodePort = buf.DecodeUint16() + m.NewFlowsTableLength = buf.DecodeUint32() + m.IsDel = buf.DecodeBool() + return nil +} + +// LbAddDelVipReply defines message 'lb_add_del_vip_reply'. +type LbAddDelVipReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LbAddDelVipReply) Reset() { *m = LbAddDelVipReply{} } +func (*LbAddDelVipReply) GetMessageName() string { return "lb_add_del_vip_reply" } +func (*LbAddDelVipReply) GetCrcString() string { return "e8d4e804" } +func (*LbAddDelVipReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LbAddDelVipReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LbAddDelVipReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LbAddDelVipReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add a virtual address (or prefix) +// - pfx - ip prefix and length +// - protocol - tcp or udp. +// - port - destination port. (0) means 'all-port VIP' +// - encap - Encap is ip4 GRE(0) or ip6 GRE(1) or L3DSR(2) or NAT4(3) or NAT6(4). +// - dscp - DSCP bit corresponding to VIP(applicable in L3DSR mode only). +// - type - service type(applicable in NAT4/NAT6 mode only). +// - target_port - Pod's port corresponding to specific service(applicable in NAT4/NAT6 mode only). +// - node_port - Node's port(applicable in NAT4/NAT6 mode only). +// - new_flows_table_length - Size of the new connections flow table used +// for this VIP (must be power of 2). +// - src_ip_sticky - source ip based sticky session. +// - is_del - The VIP should be removed. +// +// LbAddDelVipV2 defines message 'lb_add_del_vip_v2'. +type LbAddDelVipV2 struct { + Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"` + Protocol uint8 `binapi:"u8,name=protocol,default=255" json:"protocol,omitempty"` + Port uint16 `binapi:"u16,name=port" json:"port,omitempty"` + Encap lb_types.LbEncapType `binapi:"lb_encap_type,name=encap" json:"encap,omitempty"` + Dscp uint8 `binapi:"u8,name=dscp" json:"dscp,omitempty"` + Type lb_types.LbSrvType `binapi:"lb_srv_type,name=type" json:"type,omitempty"` + TargetPort uint16 `binapi:"u16,name=target_port" json:"target_port,omitempty"` + NodePort uint16 `binapi:"u16,name=node_port" json:"node_port,omitempty"` + NewFlowsTableLength uint32 `binapi:"u32,name=new_flows_table_length,default=1024" json:"new_flows_table_length,omitempty"` + SrcIPSticky bool `binapi:"bool,name=src_ip_sticky" json:"src_ip_sticky,omitempty"` + IsDel bool `binapi:"bool,name=is_del" json:"is_del,omitempty"` +} + +func (m *LbAddDelVipV2) Reset() { *m = LbAddDelVipV2{} } +func (*LbAddDelVipV2) GetMessageName() string { return "lb_add_del_vip_v2" } +func (*LbAddDelVipV2) GetCrcString() string { return "7c520e0f" } +func (*LbAddDelVipV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LbAddDelVipV2) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Pfx.Address.Af + size += 1 * 16 // m.Pfx.Address.Un + size += 1 // m.Pfx.Len + size += 1 // m.Protocol + size += 2 // m.Port + size += 4 // m.Encap + size += 1 // m.Dscp + size += 4 // m.Type + size += 2 // m.TargetPort + size += 2 // m.NodePort + size += 4 // m.NewFlowsTableLength + size += 1 // m.SrcIPSticky + size += 1 // m.IsDel + return size +} +func (m *LbAddDelVipV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Pfx.Address.Af)) + buf.EncodeBytes(m.Pfx.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Pfx.Len) + buf.EncodeUint8(m.Protocol) + buf.EncodeUint16(m.Port) + buf.EncodeUint32(uint32(m.Encap)) + buf.EncodeUint8(m.Dscp) + buf.EncodeUint32(uint32(m.Type)) + buf.EncodeUint16(m.TargetPort) + buf.EncodeUint16(m.NodePort) + buf.EncodeUint32(m.NewFlowsTableLength) + buf.EncodeBool(m.SrcIPSticky) + buf.EncodeBool(m.IsDel) + return buf.Bytes(), nil +} +func (m *LbAddDelVipV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Pfx.Len = buf.DecodeUint8() + m.Protocol = buf.DecodeUint8() + m.Port = buf.DecodeUint16() + m.Encap = lb_types.LbEncapType(buf.DecodeUint32()) + m.Dscp = buf.DecodeUint8() + m.Type = lb_types.LbSrvType(buf.DecodeUint32()) + m.TargetPort = buf.DecodeUint16() + m.NodePort = buf.DecodeUint16() + m.NewFlowsTableLength = buf.DecodeUint32() + m.SrcIPSticky = buf.DecodeBool() + m.IsDel = buf.DecodeBool() + return nil +} + +// LbAddDelVipV2Reply defines message 'lb_add_del_vip_v2_reply'. +type LbAddDelVipV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LbAddDelVipV2Reply) Reset() { *m = LbAddDelVipV2Reply{} } +func (*LbAddDelVipV2Reply) GetMessageName() string { return "lb_add_del_vip_v2_reply" } +func (*LbAddDelVipV2Reply) GetCrcString() string { return "e8d4e804" } +func (*LbAddDelVipV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LbAddDelVipV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LbAddDelVipV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LbAddDelVipV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// lb_as_details +// - as - AS detail record +// +// LbAsDetails defines message 'lb_as_details'. +type LbAsDetails struct { + Vip lb_types.LbVip `binapi:"lb_vip,name=vip" json:"vip,omitempty"` + AppSrv ip_types.Address `binapi:"address,name=app_srv" json:"app_srv,omitempty"` + Flags uint8 `binapi:"u8,name=flags" json:"flags,omitempty"` + InUseSince uint32 `binapi:"u32,name=in_use_since" json:"in_use_since,omitempty"` +} + +func (m *LbAsDetails) Reset() { *m = LbAsDetails{} } +func (*LbAsDetails) GetMessageName() string { return "lb_as_details" } +func (*LbAsDetails) GetCrcString() string { return "8d24c29e" } +func (*LbAsDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LbAsDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Vip.Pfx.Address.Af + size += 1 * 16 // m.Vip.Pfx.Address.Un + size += 1 // m.Vip.Pfx.Len + size += 1 // m.Vip.Protocol + size += 2 // m.Vip.Port + size += 1 // m.AppSrv.Af + size += 1 * 16 // m.AppSrv.Un + size += 1 // m.Flags + size += 4 // m.InUseSince + return size +} +func (m *LbAsDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Vip.Pfx.Address.Af)) + buf.EncodeBytes(m.Vip.Pfx.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Vip.Pfx.Len) + buf.EncodeUint8(uint8(m.Vip.Protocol)) + buf.EncodeUint16(m.Vip.Port) + buf.EncodeUint8(uint8(m.AppSrv.Af)) + buf.EncodeBytes(m.AppSrv.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Flags) + buf.EncodeUint32(m.InUseSince) + return buf.Bytes(), nil +} +func (m *LbAsDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Vip.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Vip.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Vip.Pfx.Len = buf.DecodeUint8() + m.Vip.Protocol = ip_types.IPProto(buf.DecodeUint8()) + m.Vip.Port = buf.DecodeUint16() + m.AppSrv.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.AppSrv.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Flags = buf.DecodeUint8() + m.InUseSince = buf.DecodeUint32() + return nil +} + +// dump AS list per VIP or all ASs for all VIPs +// - pfx - ip prefix and length. +// - protocol - tcp or udp. +// - port - destination port. +// +// LbAsDump defines message 'lb_as_dump'. +type LbAsDump struct { + Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"` + Protocol uint8 `binapi:"u8,name=protocol" json:"protocol,omitempty"` + Port uint16 `binapi:"u16,name=port" json:"port,omitempty"` +} + +func (m *LbAsDump) Reset() { *m = LbAsDump{} } +func (*LbAsDump) GetMessageName() string { return "lb_as_dump" } +func (*LbAsDump) GetCrcString() string { return "1063f819" } +func (*LbAsDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LbAsDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Pfx.Address.Af + size += 1 * 16 // m.Pfx.Address.Un + size += 1 // m.Pfx.Len + size += 1 // m.Protocol + size += 2 // m.Port + return size +} +func (m *LbAsDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Pfx.Address.Af)) + buf.EncodeBytes(m.Pfx.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Pfx.Len) + buf.EncodeUint8(m.Protocol) + buf.EncodeUint16(m.Port) + return buf.Bytes(), nil +} +func (m *LbAsDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Pfx.Len = buf.DecodeUint8() + m.Protocol = buf.DecodeUint8() + m.Port = buf.DecodeUint16() + return nil +} + +// Configure Load-Balancer global parameters (unlike the CLI, both ip4_src_address and ip6_src_address need to be specified. +// - ip4_src_address - IPv4 address to be used as source for IPv4 traffic(applicable in GRE4/GRE6/NAT4/NAT6 mode only). +// - ip6_src_address - IPv6 address to be used as source for IPv6 traffic(applicable in GRE4/GRE6/NAT4/NAT6 mode only). +// - sticky_buckets_per_core - Number of buckets *per worker thread* in the +// established flow table (must be power of 2). +// - flow_timeout - Time in seconds after which, if no packet is received +// for a given flow, the flow is removed from the established flow table. +// +// LbConf defines message 'lb_conf'. +type LbConf struct { + IP4SrcAddress ip_types.IP4Address `binapi:"ip4_address,name=ip4_src_address" json:"ip4_src_address,omitempty"` + IP6SrcAddress ip_types.IP6Address `binapi:"ip6_address,name=ip6_src_address" json:"ip6_src_address,omitempty"` + StickyBucketsPerCore uint32 `binapi:"u32,name=sticky_buckets_per_core,default=4294967295" json:"sticky_buckets_per_core,omitempty"` + FlowTimeout uint32 `binapi:"u32,name=flow_timeout,default=4294967295" json:"flow_timeout,omitempty"` +} + +func (m *LbConf) Reset() { *m = LbConf{} } +func (*LbConf) GetMessageName() string { return "lb_conf" } +func (*LbConf) GetCrcString() string { return "56cd3261" } +func (*LbConf) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LbConf) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 4 // m.IP4SrcAddress + size += 1 * 16 // m.IP6SrcAddress + size += 4 // m.StickyBucketsPerCore + size += 4 // m.FlowTimeout + return size +} +func (m *LbConf) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.IP4SrcAddress[:], 4) + buf.EncodeBytes(m.IP6SrcAddress[:], 16) + buf.EncodeUint32(m.StickyBucketsPerCore) + buf.EncodeUint32(m.FlowTimeout) + return buf.Bytes(), nil +} +func (m *LbConf) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.IP4SrcAddress[:], buf.DecodeBytes(4)) + copy(m.IP6SrcAddress[:], buf.DecodeBytes(16)) + m.StickyBucketsPerCore = buf.DecodeUint32() + m.FlowTimeout = buf.DecodeUint32() + return nil +} + +// LbConfReply defines message 'lb_conf_reply'. +type LbConfReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LbConfReply) Reset() { *m = LbConfReply{} } +func (*LbConfReply) GetMessageName() string { return "lb_conf_reply" } +func (*LbConfReply) GetCrcString() string { return "e8d4e804" } +func (*LbConfReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LbConfReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LbConfReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LbConfReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Flush a given vip +// - pfx - ip prefix and length +// - protocol - tcp or udp. +// - port - destination port. +// +// LbFlushVip defines message 'lb_flush_vip'. +type LbFlushVip struct { + Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"` + Protocol uint8 `binapi:"u8,name=protocol" json:"protocol,omitempty"` + Port uint16 `binapi:"u16,name=port" json:"port,omitempty"` +} + +func (m *LbFlushVip) Reset() { *m = LbFlushVip{} } +func (*LbFlushVip) GetMessageName() string { return "lb_flush_vip" } +func (*LbFlushVip) GetCrcString() string { return "1063f819" } +func (*LbFlushVip) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LbFlushVip) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Pfx.Address.Af + size += 1 * 16 // m.Pfx.Address.Un + size += 1 // m.Pfx.Len + size += 1 // m.Protocol + size += 2 // m.Port + return size +} +func (m *LbFlushVip) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Pfx.Address.Af)) + buf.EncodeBytes(m.Pfx.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Pfx.Len) + buf.EncodeUint8(m.Protocol) + buf.EncodeUint16(m.Port) + return buf.Bytes(), nil +} +func (m *LbFlushVip) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Pfx.Len = buf.DecodeUint8() + m.Protocol = buf.DecodeUint8() + m.Port = buf.DecodeUint16() + return nil +} + +// LbFlushVipReply defines message 'lb_flush_vip_reply'. +type LbFlushVipReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LbFlushVipReply) Reset() { *m = LbFlushVipReply{} } +func (*LbFlushVipReply) GetMessageName() string { return "lb_flush_vip_reply" } +func (*LbFlushVipReply) GetCrcString() string { return "e8d4e804" } +func (*LbFlushVipReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LbFlushVipReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LbFlushVipReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LbFlushVipReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Reply all configured vip +// - vip - all vip addrs. +// +// LbVipDetails defines message 'lb_vip_details'. +type LbVipDetails struct { + Vip lb_types.LbVip `binapi:"lb_vip,name=vip" json:"vip,omitempty"` + Encap lb_types.LbEncapType `binapi:"lb_encap_type,name=encap" json:"encap,omitempty"` + Dscp ip_types.IPDscp `binapi:"ip_dscp,name=dscp" json:"dscp,omitempty"` + SrvType lb_types.LbSrvType `binapi:"lb_srv_type,name=srv_type" json:"srv_type,omitempty"` + TargetPort uint16 `binapi:"u16,name=target_port" json:"target_port,omitempty"` + FlowTableLength uint16 `binapi:"u16,name=flow_table_length" json:"flow_table_length,omitempty"` +} + +func (m *LbVipDetails) Reset() { *m = LbVipDetails{} } +func (*LbVipDetails) GetMessageName() string { return "lb_vip_details" } +func (*LbVipDetails) GetCrcString() string { return "1329ec9b" } +func (*LbVipDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LbVipDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Vip.Pfx.Address.Af + size += 1 * 16 // m.Vip.Pfx.Address.Un + size += 1 // m.Vip.Pfx.Len + size += 1 // m.Vip.Protocol + size += 2 // m.Vip.Port + size += 4 // m.Encap + size += 1 // m.Dscp + size += 4 // m.SrvType + size += 2 // m.TargetPort + size += 2 // m.FlowTableLength + return size +} +func (m *LbVipDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Vip.Pfx.Address.Af)) + buf.EncodeBytes(m.Vip.Pfx.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Vip.Pfx.Len) + buf.EncodeUint8(uint8(m.Vip.Protocol)) + buf.EncodeUint16(m.Vip.Port) + buf.EncodeUint32(uint32(m.Encap)) + buf.EncodeUint8(uint8(m.Dscp)) + buf.EncodeUint32(uint32(m.SrvType)) + buf.EncodeUint16(m.TargetPort) + buf.EncodeUint16(m.FlowTableLength) + return buf.Bytes(), nil +} +func (m *LbVipDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Vip.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Vip.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Vip.Pfx.Len = buf.DecodeUint8() + m.Vip.Protocol = ip_types.IPProto(buf.DecodeUint8()) + m.Vip.Port = buf.DecodeUint16() + m.Encap = lb_types.LbEncapType(buf.DecodeUint32()) + m.Dscp = ip_types.IPDscp(buf.DecodeUint8()) + m.SrvType = lb_types.LbSrvType(buf.DecodeUint32()) + m.TargetPort = buf.DecodeUint16() + m.FlowTableLength = buf.DecodeUint16() + return nil +} + +// Dump all vips +// LbVipDump defines message 'lb_vip_dump'. +type LbVipDump struct { + Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"` + PfxMatcher ip_types.PrefixMatcher `binapi:"prefix_matcher,name=pfx_matcher" json:"pfx_matcher,omitempty"` + Protocol uint8 `binapi:"u8,name=protocol,default=255" json:"protocol,omitempty"` + Port uint16 `binapi:"u16,name=port" json:"port,omitempty"` +} + +func (m *LbVipDump) Reset() { *m = LbVipDump{} } +func (*LbVipDump) GetMessageName() string { return "lb_vip_dump" } +func (*LbVipDump) GetCrcString() string { return "56110cb7" } +func (*LbVipDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LbVipDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Pfx.Address.Af + size += 1 * 16 // m.Pfx.Address.Un + size += 1 // m.Pfx.Len + size += 1 // m.PfxMatcher.Le + size += 1 // m.PfxMatcher.Ge + size += 1 // m.Protocol + size += 2 // m.Port + return size +} +func (m *LbVipDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Pfx.Address.Af)) + buf.EncodeBytes(m.Pfx.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Pfx.Len) + buf.EncodeUint8(m.PfxMatcher.Le) + buf.EncodeUint8(m.PfxMatcher.Ge) + buf.EncodeUint8(m.Protocol) + buf.EncodeUint16(m.Port) + return buf.Bytes(), nil +} +func (m *LbVipDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Pfx.Len = buf.DecodeUint8() + m.PfxMatcher.Le = buf.DecodeUint8() + m.PfxMatcher.Ge = buf.DecodeUint8() + m.Protocol = buf.DecodeUint8() + m.Port = buf.DecodeUint16() + return nil +} + +func init() { file_lb_binapi_init() } +func file_lb_binapi_init() { + api.RegisterMessage((*LbAddDelAs)(nil), "lb_add_del_as_35d72500") + api.RegisterMessage((*LbAddDelAsReply)(nil), "lb_add_del_as_reply_e8d4e804") + api.RegisterMessage((*LbAddDelIntfNat4)(nil), "lb_add_del_intf_nat4_47d6e753") + api.RegisterMessage((*LbAddDelIntfNat4Reply)(nil), "lb_add_del_intf_nat4_reply_e8d4e804") + api.RegisterMessage((*LbAddDelIntfNat6)(nil), "lb_add_del_intf_nat6_47d6e753") + api.RegisterMessage((*LbAddDelIntfNat6Reply)(nil), "lb_add_del_intf_nat6_reply_e8d4e804") + api.RegisterMessage((*LbAddDelVip)(nil), "lb_add_del_vip_6fa569c7") + api.RegisterMessage((*LbAddDelVipReply)(nil), "lb_add_del_vip_reply_e8d4e804") + api.RegisterMessage((*LbAddDelVipV2)(nil), "lb_add_del_vip_v2_7c520e0f") + api.RegisterMessage((*LbAddDelVipV2Reply)(nil), "lb_add_del_vip_v2_reply_e8d4e804") + api.RegisterMessage((*LbAsDetails)(nil), "lb_as_details_8d24c29e") + api.RegisterMessage((*LbAsDump)(nil), "lb_as_dump_1063f819") + api.RegisterMessage((*LbConf)(nil), "lb_conf_56cd3261") + api.RegisterMessage((*LbConfReply)(nil), "lb_conf_reply_e8d4e804") + api.RegisterMessage((*LbFlushVip)(nil), "lb_flush_vip_1063f819") + api.RegisterMessage((*LbFlushVipReply)(nil), "lb_flush_vip_reply_e8d4e804") + api.RegisterMessage((*LbVipDetails)(nil), "lb_vip_details_1329ec9b") + api.RegisterMessage((*LbVipDump)(nil), "lb_vip_dump_56110cb7") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*LbAddDelAs)(nil), + (*LbAddDelAsReply)(nil), + (*LbAddDelIntfNat4)(nil), + (*LbAddDelIntfNat4Reply)(nil), + (*LbAddDelIntfNat6)(nil), + (*LbAddDelIntfNat6Reply)(nil), + (*LbAddDelVip)(nil), + (*LbAddDelVipReply)(nil), + (*LbAddDelVipV2)(nil), + (*LbAddDelVipV2Reply)(nil), + (*LbAsDetails)(nil), + (*LbAsDump)(nil), + (*LbConf)(nil), + (*LbConfReply)(nil), + (*LbFlushVip)(nil), + (*LbFlushVipReply)(nil), + (*LbVipDetails)(nil), + (*LbVipDump)(nil), + } +} diff --git a/binapi/lb/lb_rpc.ba.go b/binapi/lb/lb_rpc.ba.go new file mode 100644 index 00000000..77eb0d84 --- /dev/null +++ b/binapi/lb/lb_rpc.ba.go @@ -0,0 +1,182 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package lb + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service lb. +type RPCService interface { + LbAddDelAs(ctx context.Context, in *LbAddDelAs) (*LbAddDelAsReply, error) + LbAddDelIntfNat4(ctx context.Context, in *LbAddDelIntfNat4) (*LbAddDelIntfNat4Reply, error) + LbAddDelIntfNat6(ctx context.Context, in *LbAddDelIntfNat6) (*LbAddDelIntfNat6Reply, error) + LbAddDelVip(ctx context.Context, in *LbAddDelVip) (*LbAddDelVipReply, error) + LbAddDelVipV2(ctx context.Context, in *LbAddDelVipV2) (*LbAddDelVipV2Reply, error) + LbAsDump(ctx context.Context, in *LbAsDump) (RPCService_LbAsDumpClient, error) + LbConf(ctx context.Context, in *LbConf) (*LbConfReply, error) + LbFlushVip(ctx context.Context, in *LbFlushVip) (*LbFlushVipReply, error) + LbVipDump(ctx context.Context, in *LbVipDump) (RPCService_LbVipDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) LbAddDelAs(ctx context.Context, in *LbAddDelAs) (*LbAddDelAsReply, error) { + out := new(LbAddDelAsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LbAddDelIntfNat4(ctx context.Context, in *LbAddDelIntfNat4) (*LbAddDelIntfNat4Reply, error) { + out := new(LbAddDelIntfNat4Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LbAddDelIntfNat6(ctx context.Context, in *LbAddDelIntfNat6) (*LbAddDelIntfNat6Reply, error) { + out := new(LbAddDelIntfNat6Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LbAddDelVip(ctx context.Context, in *LbAddDelVip) (*LbAddDelVipReply, error) { + out := new(LbAddDelVipReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LbAddDelVipV2(ctx context.Context, in *LbAddDelVipV2) (*LbAddDelVipV2Reply, error) { + out := new(LbAddDelVipV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LbAsDump(ctx context.Context, in *LbAsDump) (RPCService_LbAsDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_LbAsDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_LbAsDumpClient interface { + Recv() (*LbAsDetails, error) + api.Stream +} + +type serviceClient_LbAsDumpClient struct { + api.Stream +} + +func (c *serviceClient_LbAsDumpClient) Recv() (*LbAsDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *LbAsDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) LbConf(ctx context.Context, in *LbConf) (*LbConfReply, error) { + out := new(LbConfReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LbFlushVip(ctx context.Context, in *LbFlushVip) (*LbFlushVipReply, error) { + out := new(LbFlushVipReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LbVipDump(ctx context.Context, in *LbVipDump) (RPCService_LbVipDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_LbVipDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_LbVipDumpClient interface { + Recv() (*LbVipDetails, error) + api.Stream +} + +type serviceClient_LbVipDumpClient struct { + api.Stream +} + +func (c *serviceClient_LbVipDumpClient) Recv() (*LbVipDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *LbVipDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/lb_types/lb_types.ba.go b/binapi/lb_types/lb_types.ba.go new file mode 100644 index 00000000..cc2915ee --- /dev/null +++ b/binapi/lb_types/lb_types.ba.go @@ -0,0 +1,215 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/lb_types.api.json + +// Package lb_types contains generated bindings for API file lb_types.api. +// +// Contents: +// - 5 enums +// - 1 struct +package lb_types + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "lb_types" + APIVersion = "1.0.0" + VersionCrc = 0xba19340c +) + +// LbEncapType defines enum 'lb_encap_type'. +type LbEncapType uint32 + +const ( + LB_API_ENCAP_TYPE_GRE4 LbEncapType = 0 + LB_API_ENCAP_TYPE_GRE6 LbEncapType = 1 + LB_API_ENCAP_TYPE_L3DSR LbEncapType = 2 + LB_API_ENCAP_TYPE_NAT4 LbEncapType = 3 + LB_API_ENCAP_TYPE_NAT6 LbEncapType = 4 + LB_API_ENCAP_N_TYPES LbEncapType = 5 +) + +var ( + LbEncapType_name = map[uint32]string{ + 0: "LB_API_ENCAP_TYPE_GRE4", + 1: "LB_API_ENCAP_TYPE_GRE6", + 2: "LB_API_ENCAP_TYPE_L3DSR", + 3: "LB_API_ENCAP_TYPE_NAT4", + 4: "LB_API_ENCAP_TYPE_NAT6", + 5: "LB_API_ENCAP_N_TYPES", + } + LbEncapType_value = map[string]uint32{ + "LB_API_ENCAP_TYPE_GRE4": 0, + "LB_API_ENCAP_TYPE_GRE6": 1, + "LB_API_ENCAP_TYPE_L3DSR": 2, + "LB_API_ENCAP_TYPE_NAT4": 3, + "LB_API_ENCAP_TYPE_NAT6": 4, + "LB_API_ENCAP_N_TYPES": 5, + } +) + +func (x LbEncapType) String() string { + s, ok := LbEncapType_name[uint32(x)] + if ok { + return s + } + return "LbEncapType(" + strconv.Itoa(int(x)) + ")" +} + +// LbLkpTypeT defines enum 'lb_lkp_type_t'. +type LbLkpTypeT uint32 + +const ( + LB_API_LKP_SAME_IP_PORT LbLkpTypeT = 0 + LB_API_LKP_DIFF_IP_PORT LbLkpTypeT = 1 + LB_API_LKP_ALL_PORT_IP LbLkpTypeT = 2 + LB_API_LKP_N_TYPES LbLkpTypeT = 3 +) + +var ( + LbLkpTypeT_name = map[uint32]string{ + 0: "LB_API_LKP_SAME_IP_PORT", + 1: "LB_API_LKP_DIFF_IP_PORT", + 2: "LB_API_LKP_ALL_PORT_IP", + 3: "LB_API_LKP_N_TYPES", + } + LbLkpTypeT_value = map[string]uint32{ + "LB_API_LKP_SAME_IP_PORT": 0, + "LB_API_LKP_DIFF_IP_PORT": 1, + "LB_API_LKP_ALL_PORT_IP": 2, + "LB_API_LKP_N_TYPES": 3, + } +) + +func (x LbLkpTypeT) String() string { + s, ok := LbLkpTypeT_name[uint32(x)] + if ok { + return s + } + return "LbLkpTypeT(" + strconv.Itoa(int(x)) + ")" +} + +// LbNatProtocol defines enum 'lb_nat_protocol'. +type LbNatProtocol uint32 + +const ( + LB_API_NAT_PROTOCOL_UDP LbNatProtocol = 6 + LB_API_NAT_PROTOCOL_TCP LbNatProtocol = 23 + LB_API_NAT_PROTOCOL_ANY LbNatProtocol = 4294967295 +) + +var ( + LbNatProtocol_name = map[uint32]string{ + 6: "LB_API_NAT_PROTOCOL_UDP", + 23: "LB_API_NAT_PROTOCOL_TCP", + 4294967295: "LB_API_NAT_PROTOCOL_ANY", + } + LbNatProtocol_value = map[string]uint32{ + "LB_API_NAT_PROTOCOL_UDP": 6, + "LB_API_NAT_PROTOCOL_TCP": 23, + "LB_API_NAT_PROTOCOL_ANY": 4294967295, + } +) + +func (x LbNatProtocol) String() string { + s, ok := LbNatProtocol_name[uint32(x)] + if ok { + return s + } + return "LbNatProtocol(" + strconv.Itoa(int(x)) + ")" +} + +// LbSrvType defines enum 'lb_srv_type'. +type LbSrvType uint32 + +const ( + LB_API_SRV_TYPE_CLUSTERIP LbSrvType = 0 + LB_API_SRV_TYPE_NODEPORT LbSrvType = 1 + LB_API_SRV_N_TYPES LbSrvType = 2 +) + +var ( + LbSrvType_name = map[uint32]string{ + 0: "LB_API_SRV_TYPE_CLUSTERIP", + 1: "LB_API_SRV_TYPE_NODEPORT", + 2: "LB_API_SRV_N_TYPES", + } + LbSrvType_value = map[string]uint32{ + "LB_API_SRV_TYPE_CLUSTERIP": 0, + "LB_API_SRV_TYPE_NODEPORT": 1, + "LB_API_SRV_N_TYPES": 2, + } +) + +func (x LbSrvType) String() string { + s, ok := LbSrvType_name[uint32(x)] + if ok { + return s + } + return "LbSrvType(" + strconv.Itoa(int(x)) + ")" +} + +// LbVipType defines enum 'lb_vip_type'. +type LbVipType uint32 + +const ( + LB_API_VIP_TYPE_IP6_GRE6 LbVipType = 0 + LB_API_VIP_TYPE_IP6_GRE4 LbVipType = 1 + LB_API_VIP_TYPE_IP4_GRE6 LbVipType = 2 + LB_API_VIP_TYPE_IP4_GRE4 LbVipType = 3 + LB_API_VIP_TYPE_IP4_L3DSR LbVipType = 4 + LB_API_VIP_TYPE_IP4_NAT4 LbVipType = 5 + LB_API_VIP_TYPE_IP6_NAT6 LbVipType = 6 + LB_API_VIP_N_TYPES LbVipType = 7 +) + +var ( + LbVipType_name = map[uint32]string{ + 0: "LB_API_VIP_TYPE_IP6_GRE6", + 1: "LB_API_VIP_TYPE_IP6_GRE4", + 2: "LB_API_VIP_TYPE_IP4_GRE6", + 3: "LB_API_VIP_TYPE_IP4_GRE4", + 4: "LB_API_VIP_TYPE_IP4_L3DSR", + 5: "LB_API_VIP_TYPE_IP4_NAT4", + 6: "LB_API_VIP_TYPE_IP6_NAT6", + 7: "LB_API_VIP_N_TYPES", + } + LbVipType_value = map[string]uint32{ + "LB_API_VIP_TYPE_IP6_GRE6": 0, + "LB_API_VIP_TYPE_IP6_GRE4": 1, + "LB_API_VIP_TYPE_IP4_GRE6": 2, + "LB_API_VIP_TYPE_IP4_GRE4": 3, + "LB_API_VIP_TYPE_IP4_L3DSR": 4, + "LB_API_VIP_TYPE_IP4_NAT4": 5, + "LB_API_VIP_TYPE_IP6_NAT6": 6, + "LB_API_VIP_N_TYPES": 7, + } +) + +func (x LbVipType) String() string { + s, ok := LbVipType_name[uint32(x)] + if ok { + return s + } + return "LbVipType(" + strconv.Itoa(int(x)) + ")" +} + +// LbVip defines type 'lb_vip'. +type LbVip struct { + Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"` + Protocol ip_types.IPProto `binapi:"ip_proto,name=protocol" json:"protocol,omitempty"` + Port uint16 `binapi:"u16,name=port" json:"port,omitempty"` +} diff --git a/binapi/lcp/lcp.ba.go b/binapi/lcp/lcp.ba.go new file mode 100644 index 00000000..e2b3c394 --- /dev/null +++ b/binapi/lcp/lcp.ba.go @@ -0,0 +1,671 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/lcp.api.json + +// Package lcp contains generated bindings for API file lcp.api. +// +// Contents: +// - 1 enum +// - 15 messages +package lcp + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "lcp" + APIVersion = "1.0.0" + VersionCrc = 0x64780a3 +) + +// LcpItfHostType defines enum 'lcp_itf_host_type'. +type LcpItfHostType uint8 + +const ( + LCP_API_ITF_HOST_TAP LcpItfHostType = 0 + LCP_API_ITF_HOST_TUN LcpItfHostType = 1 +) + +var ( + LcpItfHostType_name = map[uint8]string{ + 0: "LCP_API_ITF_HOST_TAP", + 1: "LCP_API_ITF_HOST_TUN", + } + LcpItfHostType_value = map[string]uint8{ + "LCP_API_ITF_HOST_TAP": 0, + "LCP_API_ITF_HOST_TUN": 1, + } +) + +func (x LcpItfHostType) String() string { + s, ok := LcpItfHostType_name[uint8(x)] + if ok { + return s + } + return "LcpItfHostType(" + strconv.Itoa(int(x)) + ")" +} + +// get the default Linux Control Plane netns +// LcpDefaultNsGet defines message 'lcp_default_ns_get'. +type LcpDefaultNsGet struct{} + +func (m *LcpDefaultNsGet) Reset() { *m = LcpDefaultNsGet{} } +func (*LcpDefaultNsGet) GetMessageName() string { return "lcp_default_ns_get" } +func (*LcpDefaultNsGet) GetCrcString() string { return "51077d14" } +func (*LcpDefaultNsGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LcpDefaultNsGet) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *LcpDefaultNsGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *LcpDefaultNsGet) Unmarshal(b []byte) error { + return nil +} + +// get the default Linux Control Plane netns +// - netns - the default netns; netns[0] == 0 if none +// +// LcpDefaultNsGetReply defines message 'lcp_default_ns_get_reply'. +// InProgress: the message form may change in the future versions +type LcpDefaultNsGetReply struct { + Netns string `binapi:"string[32],name=netns" json:"netns,omitempty"` +} + +func (m *LcpDefaultNsGetReply) Reset() { *m = LcpDefaultNsGetReply{} } +func (*LcpDefaultNsGetReply) GetMessageName() string { return "lcp_default_ns_get_reply" } +func (*LcpDefaultNsGetReply) GetCrcString() string { return "5102feee" } +func (*LcpDefaultNsGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LcpDefaultNsGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 32 // m.Netns + return size +} +func (m *LcpDefaultNsGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.Netns, 32) + return buf.Bytes(), nil +} +func (m *LcpDefaultNsGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Netns = buf.DecodeString(32) + return nil +} + +// Set the default Linux Control Plane netns +// - netns - the new default netns; netns[0] == 0 if none +// +// LcpDefaultNsSet defines message 'lcp_default_ns_set'. +// InProgress: the message form may change in the future versions +type LcpDefaultNsSet struct { + Netns string `binapi:"string[32],name=netns" json:"netns,omitempty"` +} + +func (m *LcpDefaultNsSet) Reset() { *m = LcpDefaultNsSet{} } +func (*LcpDefaultNsSet) GetMessageName() string { return "lcp_default_ns_set" } +func (*LcpDefaultNsSet) GetCrcString() string { return "69749409" } +func (*LcpDefaultNsSet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LcpDefaultNsSet) Size() (size int) { + if m == nil { + return 0 + } + size += 32 // m.Netns + return size +} +func (m *LcpDefaultNsSet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.Netns, 32) + return buf.Bytes(), nil +} +func (m *LcpDefaultNsSet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Netns = buf.DecodeString(32) + return nil +} + +// LcpDefaultNsSetReply defines message 'lcp_default_ns_set_reply'. +// InProgress: the message form may change in the future versions +type LcpDefaultNsSetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LcpDefaultNsSetReply) Reset() { *m = LcpDefaultNsSetReply{} } +func (*LcpDefaultNsSetReply) GetMessageName() string { return "lcp_default_ns_set_reply" } +func (*LcpDefaultNsSetReply) GetCrcString() string { return "e8d4e804" } +func (*LcpDefaultNsSetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LcpDefaultNsSetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LcpDefaultNsSetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LcpDefaultNsSetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add or delete a Linux Conrol Plane interface pair +// - is_add - 0 if deleting, != 0 if adding +// - sw_if_index - index of VPP PHY SW interface +// - host_if_name - host tap interface name +// - host_if_type - the type of host interface to create (tun, tap) +// - netns - optional tap netns; netns[0] == 0 if none +// +// LcpItfPairAddDel defines message 'lcp_itf_pair_add_del'. +// InProgress: the message form may change in the future versions +type LcpItfPairAddDel struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + HostIfName string `binapi:"string[16],name=host_if_name" json:"host_if_name,omitempty"` + HostIfType LcpItfHostType `binapi:"lcp_itf_host_type,name=host_if_type" json:"host_if_type,omitempty"` + Netns string `binapi:"string[32],name=netns" json:"netns,omitempty"` +} + +func (m *LcpItfPairAddDel) Reset() { *m = LcpItfPairAddDel{} } +func (*LcpItfPairAddDel) GetMessageName() string { return "lcp_itf_pair_add_del" } +func (*LcpItfPairAddDel) GetCrcString() string { return "40482b80" } +func (*LcpItfPairAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LcpItfPairAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.SwIfIndex + size += 16 // m.HostIfName + size += 1 // m.HostIfType + size += 32 // m.Netns + return size +} +func (m *LcpItfPairAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeString(m.HostIfName, 16) + buf.EncodeUint8(uint8(m.HostIfType)) + buf.EncodeString(m.Netns, 32) + return buf.Bytes(), nil +} +func (m *LcpItfPairAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.HostIfName = buf.DecodeString(16) + m.HostIfType = LcpItfHostType(buf.DecodeUint8()) + m.Netns = buf.DecodeString(32) + return nil +} + +// LcpItfPairAddDelReply defines message 'lcp_itf_pair_add_del_reply'. +// InProgress: the message form may change in the future versions +type LcpItfPairAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LcpItfPairAddDelReply) Reset() { *m = LcpItfPairAddDelReply{} } +func (*LcpItfPairAddDelReply) GetMessageName() string { return "lcp_itf_pair_add_del_reply" } +func (*LcpItfPairAddDelReply) GetCrcString() string { return "e8d4e804" } +func (*LcpItfPairAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LcpItfPairAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LcpItfPairAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LcpItfPairAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// LcpItfPairAddDelV2 defines message 'lcp_itf_pair_add_del_v2'. +// InProgress: the message form may change in the future versions +type LcpItfPairAddDelV2 struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + HostIfName string `binapi:"string[16],name=host_if_name" json:"host_if_name,omitempty"` + HostIfType LcpItfHostType `binapi:"lcp_itf_host_type,name=host_if_type" json:"host_if_type,omitempty"` + Netns string `binapi:"string[32],name=netns" json:"netns,omitempty"` +} + +func (m *LcpItfPairAddDelV2) Reset() { *m = LcpItfPairAddDelV2{} } +func (*LcpItfPairAddDelV2) GetMessageName() string { return "lcp_itf_pair_add_del_v2" } +func (*LcpItfPairAddDelV2) GetCrcString() string { return "40482b80" } +func (*LcpItfPairAddDelV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LcpItfPairAddDelV2) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.SwIfIndex + size += 16 // m.HostIfName + size += 1 // m.HostIfType + size += 32 // m.Netns + return size +} +func (m *LcpItfPairAddDelV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeString(m.HostIfName, 16) + buf.EncodeUint8(uint8(m.HostIfType)) + buf.EncodeString(m.Netns, 32) + return buf.Bytes(), nil +} +func (m *LcpItfPairAddDelV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.HostIfName = buf.DecodeString(16) + m.HostIfType = LcpItfHostType(buf.DecodeUint8()) + m.Netns = buf.DecodeString(32) + return nil +} + +// LcpItfPairAddDelV2Reply defines message 'lcp_itf_pair_add_del_v2_reply'. +type LcpItfPairAddDelV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + HostSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=host_sw_if_index" json:"host_sw_if_index,omitempty"` +} + +func (m *LcpItfPairAddDelV2Reply) Reset() { *m = LcpItfPairAddDelV2Reply{} } +func (*LcpItfPairAddDelV2Reply) GetMessageName() string { return "lcp_itf_pair_add_del_v2_reply" } +func (*LcpItfPairAddDelV2Reply) GetCrcString() string { return "39452f52" } +func (*LcpItfPairAddDelV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LcpItfPairAddDelV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.HostSwIfIndex + return size +} +func (m *LcpItfPairAddDelV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.HostSwIfIndex)) + return buf.Bytes(), nil +} +func (m *LcpItfPairAddDelV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.HostSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Linux Control Plane interface pair dump response +// - phy_sw_if_index - VPP's sw_if_index for the PHY +// - host_sw_if_index - VPP's sw_if_index for the host tap +// - vif_index - tap linux index +// - host_if_name - host interface name +// - host_if_type - host interface type (tun, tap) +// - netns - host interface netns +// +// LcpItfPairDetails defines message 'lcp_itf_pair_details'. +// InProgress: the message form may change in the future versions +type LcpItfPairDetails struct { + PhySwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=phy_sw_if_index" json:"phy_sw_if_index,omitempty"` + HostSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=host_sw_if_index" json:"host_sw_if_index,omitempty"` + VifIndex uint32 `binapi:"u32,name=vif_index" json:"vif_index,omitempty"` + HostIfName string `binapi:"string[16],name=host_if_name" json:"host_if_name,omitempty"` + HostIfType LcpItfHostType `binapi:"lcp_itf_host_type,name=host_if_type" json:"host_if_type,omitempty"` + Netns string `binapi:"string[32],name=netns" json:"netns,omitempty"` +} + +func (m *LcpItfPairDetails) Reset() { *m = LcpItfPairDetails{} } +func (*LcpItfPairDetails) GetMessageName() string { return "lcp_itf_pair_details" } +func (*LcpItfPairDetails) GetCrcString() string { return "8b5481af" } +func (*LcpItfPairDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LcpItfPairDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PhySwIfIndex + size += 4 // m.HostSwIfIndex + size += 4 // m.VifIndex + size += 16 // m.HostIfName + size += 1 // m.HostIfType + size += 32 // m.Netns + return size +} +func (m *LcpItfPairDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.PhySwIfIndex)) + buf.EncodeUint32(uint32(m.HostSwIfIndex)) + buf.EncodeUint32(m.VifIndex) + buf.EncodeString(m.HostIfName, 16) + buf.EncodeUint8(uint8(m.HostIfType)) + buf.EncodeString(m.Netns, 32) + return buf.Bytes(), nil +} +func (m *LcpItfPairDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PhySwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.HostSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.VifIndex = buf.DecodeUint32() + m.HostIfName = buf.DecodeString(16) + m.HostIfType = LcpItfHostType(buf.DecodeUint8()) + m.Netns = buf.DecodeString(32) + return nil +} + +// Dump Linux Control Plane interface pair data +// - sw_if_index - interface to use as filter (~0 == "all") +// +// LcpItfPairGet defines message 'lcp_itf_pair_get'. +type LcpItfPairGet struct { + Cursor uint32 `binapi:"u32,name=cursor" json:"cursor,omitempty"` +} + +func (m *LcpItfPairGet) Reset() { *m = LcpItfPairGet{} } +func (*LcpItfPairGet) GetMessageName() string { return "lcp_itf_pair_get" } +func (*LcpItfPairGet) GetCrcString() string { return "f75ba505" } +func (*LcpItfPairGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LcpItfPairGet) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Cursor + return size +} +func (m *LcpItfPairGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Cursor) + return buf.Bytes(), nil +} +func (m *LcpItfPairGet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Cursor = buf.DecodeUint32() + return nil +} + +// LcpItfPairGetReply defines message 'lcp_itf_pair_get_reply'. +type LcpItfPairGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Cursor uint32 `binapi:"u32,name=cursor" json:"cursor,omitempty"` +} + +func (m *LcpItfPairGetReply) Reset() { *m = LcpItfPairGetReply{} } +func (*LcpItfPairGetReply) GetMessageName() string { return "lcp_itf_pair_get_reply" } +func (*LcpItfPairGetReply) GetCrcString() string { return "53b48f5d" } +func (*LcpItfPairGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LcpItfPairGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Cursor + return size +} +func (m *LcpItfPairGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.Cursor) + return buf.Bytes(), nil +} +func (m *LcpItfPairGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Cursor = buf.DecodeUint32() + return nil +} + +// Replace end/begin +// LcpItfPairReplaceBegin defines message 'lcp_itf_pair_replace_begin'. +type LcpItfPairReplaceBegin struct{} + +func (m *LcpItfPairReplaceBegin) Reset() { *m = LcpItfPairReplaceBegin{} } +func (*LcpItfPairReplaceBegin) GetMessageName() string { return "lcp_itf_pair_replace_begin" } +func (*LcpItfPairReplaceBegin) GetCrcString() string { return "51077d14" } +func (*LcpItfPairReplaceBegin) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LcpItfPairReplaceBegin) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *LcpItfPairReplaceBegin) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *LcpItfPairReplaceBegin) Unmarshal(b []byte) error { + return nil +} + +// LcpItfPairReplaceBeginReply defines message 'lcp_itf_pair_replace_begin_reply'. +type LcpItfPairReplaceBeginReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LcpItfPairReplaceBeginReply) Reset() { *m = LcpItfPairReplaceBeginReply{} } +func (*LcpItfPairReplaceBeginReply) GetMessageName() string { + return "lcp_itf_pair_replace_begin_reply" +} +func (*LcpItfPairReplaceBeginReply) GetCrcString() string { return "e8d4e804" } +func (*LcpItfPairReplaceBeginReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LcpItfPairReplaceBeginReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LcpItfPairReplaceBeginReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LcpItfPairReplaceBeginReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// LcpItfPairReplaceEnd defines message 'lcp_itf_pair_replace_end'. +type LcpItfPairReplaceEnd struct{} + +func (m *LcpItfPairReplaceEnd) Reset() { *m = LcpItfPairReplaceEnd{} } +func (*LcpItfPairReplaceEnd) GetMessageName() string { return "lcp_itf_pair_replace_end" } +func (*LcpItfPairReplaceEnd) GetCrcString() string { return "51077d14" } +func (*LcpItfPairReplaceEnd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LcpItfPairReplaceEnd) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *LcpItfPairReplaceEnd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *LcpItfPairReplaceEnd) Unmarshal(b []byte) error { + return nil +} + +// LcpItfPairReplaceEndReply defines message 'lcp_itf_pair_replace_end_reply'. +type LcpItfPairReplaceEndReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LcpItfPairReplaceEndReply) Reset() { *m = LcpItfPairReplaceEndReply{} } +func (*LcpItfPairReplaceEndReply) GetMessageName() string { return "lcp_itf_pair_replace_end_reply" } +func (*LcpItfPairReplaceEndReply) GetCrcString() string { return "e8d4e804" } +func (*LcpItfPairReplaceEndReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LcpItfPairReplaceEndReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LcpItfPairReplaceEndReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LcpItfPairReplaceEndReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_lcp_binapi_init() } +func file_lcp_binapi_init() { + api.RegisterMessage((*LcpDefaultNsGet)(nil), "lcp_default_ns_get_51077d14") + api.RegisterMessage((*LcpDefaultNsGetReply)(nil), "lcp_default_ns_get_reply_5102feee") + api.RegisterMessage((*LcpDefaultNsSet)(nil), "lcp_default_ns_set_69749409") + api.RegisterMessage((*LcpDefaultNsSetReply)(nil), "lcp_default_ns_set_reply_e8d4e804") + api.RegisterMessage((*LcpItfPairAddDel)(nil), "lcp_itf_pair_add_del_40482b80") + api.RegisterMessage((*LcpItfPairAddDelReply)(nil), "lcp_itf_pair_add_del_reply_e8d4e804") + api.RegisterMessage((*LcpItfPairAddDelV2)(nil), "lcp_itf_pair_add_del_v2_40482b80") + api.RegisterMessage((*LcpItfPairAddDelV2Reply)(nil), "lcp_itf_pair_add_del_v2_reply_39452f52") + api.RegisterMessage((*LcpItfPairDetails)(nil), "lcp_itf_pair_details_8b5481af") + api.RegisterMessage((*LcpItfPairGet)(nil), "lcp_itf_pair_get_f75ba505") + api.RegisterMessage((*LcpItfPairGetReply)(nil), "lcp_itf_pair_get_reply_53b48f5d") + api.RegisterMessage((*LcpItfPairReplaceBegin)(nil), "lcp_itf_pair_replace_begin_51077d14") + api.RegisterMessage((*LcpItfPairReplaceBeginReply)(nil), "lcp_itf_pair_replace_begin_reply_e8d4e804") + api.RegisterMessage((*LcpItfPairReplaceEnd)(nil), "lcp_itf_pair_replace_end_51077d14") + api.RegisterMessage((*LcpItfPairReplaceEndReply)(nil), "lcp_itf_pair_replace_end_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*LcpDefaultNsGet)(nil), + (*LcpDefaultNsGetReply)(nil), + (*LcpDefaultNsSet)(nil), + (*LcpDefaultNsSetReply)(nil), + (*LcpItfPairAddDel)(nil), + (*LcpItfPairAddDelReply)(nil), + (*LcpItfPairAddDelV2)(nil), + (*LcpItfPairAddDelV2Reply)(nil), + (*LcpItfPairDetails)(nil), + (*LcpItfPairGet)(nil), + (*LcpItfPairGetReply)(nil), + (*LcpItfPairReplaceBegin)(nil), + (*LcpItfPairReplaceBeginReply)(nil), + (*LcpItfPairReplaceEnd)(nil), + (*LcpItfPairReplaceEndReply)(nil), + } +} diff --git a/binapi/lcp/lcp_rpc.ba.go b/binapi/lcp/lcp_rpc.ba.go new file mode 100644 index 00000000..5d67077d --- /dev/null +++ b/binapi/lcp/lcp_rpc.ba.go @@ -0,0 +1,127 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package lcp + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service lcp. +type RPCService interface { + LcpDefaultNsGet(ctx context.Context, in *LcpDefaultNsGet) (*LcpDefaultNsGetReply, error) + LcpDefaultNsSet(ctx context.Context, in *LcpDefaultNsSet) (*LcpDefaultNsSetReply, error) + LcpItfPairAddDel(ctx context.Context, in *LcpItfPairAddDel) (*LcpItfPairAddDelReply, error) + LcpItfPairAddDelV2(ctx context.Context, in *LcpItfPairAddDelV2) (*LcpItfPairAddDelV2Reply, error) + LcpItfPairGet(ctx context.Context, in *LcpItfPairGet) (RPCService_LcpItfPairGetClient, error) + LcpItfPairReplaceBegin(ctx context.Context, in *LcpItfPairReplaceBegin) (*LcpItfPairReplaceBeginReply, error) + LcpItfPairReplaceEnd(ctx context.Context, in *LcpItfPairReplaceEnd) (*LcpItfPairReplaceEndReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) LcpDefaultNsGet(ctx context.Context, in *LcpDefaultNsGet) (*LcpDefaultNsGetReply, error) { + out := new(LcpDefaultNsGetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) LcpDefaultNsSet(ctx context.Context, in *LcpDefaultNsSet) (*LcpDefaultNsSetReply, error) { + out := new(LcpDefaultNsSetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LcpItfPairAddDel(ctx context.Context, in *LcpItfPairAddDel) (*LcpItfPairAddDelReply, error) { + out := new(LcpItfPairAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LcpItfPairAddDelV2(ctx context.Context, in *LcpItfPairAddDelV2) (*LcpItfPairAddDelV2Reply, error) { + out := new(LcpItfPairAddDelV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LcpItfPairGet(ctx context.Context, in *LcpItfPairGet) (RPCService_LcpItfPairGetClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_LcpItfPairGetClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_LcpItfPairGetClient interface { + Recv() (*LcpItfPairDetails, *LcpItfPairGetReply, error) + api.Stream +} + +type serviceClient_LcpItfPairGetClient struct { + api.Stream +} + +func (c *serviceClient_LcpItfPairGetClient) Recv() (*LcpItfPairDetails, *LcpItfPairGetReply, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, nil, err + } + switch m := msg.(type) { + case *LcpItfPairDetails: + return m, nil, nil + case *LcpItfPairGetReply: + if err := api.RetvalToVPPApiError(m.Retval); err != nil { + return nil, m, err + } + err = c.Stream.Close() + if err != nil { + return nil, m, err + } + return nil, m, io.EOF + default: + return nil, nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) LcpItfPairReplaceBegin(ctx context.Context, in *LcpItfPairReplaceBegin) (*LcpItfPairReplaceBeginReply, error) { + out := new(LcpItfPairReplaceBeginReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LcpItfPairReplaceEnd(ctx context.Context, in *LcpItfPairReplaceEnd) (*LcpItfPairReplaceEndReply, error) { + out := new(LcpItfPairReplaceEndReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/lisp/lisp.ba.go b/binapi/lisp/lisp.ba.go new file mode 100644 index 00000000..6a59d2da --- /dev/null +++ b/binapi/lisp/lisp.ba.go @@ -0,0 +1,2711 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/lisp.api.json + +// Package lisp contains generated bindings for API file lisp.api. +// +// Contents: +// - 1 enum +// - 1 struct +// - 60 messages +package lisp + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + _ "github.com/alkiranet/govpp/binapi/ethernet_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + lisp_types "github.com/alkiranet/govpp/binapi/lisp_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "lisp" + APIVersion = "2.0.0" + VersionCrc = 0xcb04530f +) + +// LispLocatorSetFilter defines enum 'lisp_locator_set_filter'. +type LispLocatorSetFilter uint8 + +const ( + LISP_LOCATOR_SET_FILTER_API_ALL LispLocatorSetFilter = 0 + LISP_LOCATOR_SET_FILTER_API_LOCAL LispLocatorSetFilter = 1 + LISP_LOCATOR_SET_FILTER_API_REMOTE LispLocatorSetFilter = 2 +) + +var ( + LispLocatorSetFilter_name = map[uint8]string{ + 0: "LISP_LOCATOR_SET_FILTER_API_ALL", + 1: "LISP_LOCATOR_SET_FILTER_API_LOCAL", + 2: "LISP_LOCATOR_SET_FILTER_API_REMOTE", + } + LispLocatorSetFilter_value = map[string]uint8{ + "LISP_LOCATOR_SET_FILTER_API_ALL": 0, + "LISP_LOCATOR_SET_FILTER_API_LOCAL": 1, + "LISP_LOCATOR_SET_FILTER_API_REMOTE": 2, + } +) + +func (x LispLocatorSetFilter) String() string { + s, ok := LispLocatorSetFilter_name[uint8(x)] + if ok { + return s + } + return "LispLocatorSetFilter(" + strconv.Itoa(int(x)) + ")" +} + +// LispAdjacency defines type 'lisp_adjacency'. +type LispAdjacency struct { + Reid lisp_types.Eid `binapi:"eid,name=reid" json:"reid,omitempty"` + Leid lisp_types.Eid `binapi:"eid,name=leid" json:"leid,omitempty"` +} + +// add or delete LISP adjacency adjacency +// - is_add - add address if non-zero, else delete +// - vni - virtual network instance +// - reid - remote EID +// - leid - local EID +// +// LispAddDelAdjacency defines message 'lisp_add_del_adjacency'. +type LispAddDelAdjacency struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + Reid lisp_types.Eid `binapi:"eid,name=reid" json:"reid,omitempty"` + Leid lisp_types.Eid `binapi:"eid,name=leid" json:"leid,omitempty"` +} + +func (m *LispAddDelAdjacency) Reset() { *m = LispAddDelAdjacency{} } +func (*LispAddDelAdjacency) GetMessageName() string { return "lisp_add_del_adjacency" } +func (*LispAddDelAdjacency) GetCrcString() string { return "2ce0e6f6" } +func (*LispAddDelAdjacency) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispAddDelAdjacency) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Vni + size += 1 // m.Reid.Type + size += 1 * 18 // m.Reid.Address + size += 1 // m.Leid.Type + size += 1 * 18 // m.Leid.Address + return size +} +func (m *LispAddDelAdjacency) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.Vni) + buf.EncodeUint8(uint8(m.Reid.Type)) + buf.EncodeBytes(m.Reid.Address.XXX_UnionData[:], 18) + buf.EncodeUint8(uint8(m.Leid.Type)) + buf.EncodeBytes(m.Leid.Address.XXX_UnionData[:], 18) + return buf.Bytes(), nil +} +func (m *LispAddDelAdjacency) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Vni = buf.DecodeUint32() + m.Reid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Reid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.Leid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Leid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + return nil +} + +// LispAddDelAdjacencyReply defines message 'lisp_add_del_adjacency_reply'. +type LispAddDelAdjacencyReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LispAddDelAdjacencyReply) Reset() { *m = LispAddDelAdjacencyReply{} } +func (*LispAddDelAdjacencyReply) GetMessageName() string { return "lisp_add_del_adjacency_reply" } +func (*LispAddDelAdjacencyReply) GetCrcString() string { return "e8d4e804" } +func (*LispAddDelAdjacencyReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispAddDelAdjacencyReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LispAddDelAdjacencyReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LispAddDelAdjacencyReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// add or delete lisp eid-table +// - is_add - add address if non-zero, else delete +// - eid - endpoint identifier +// - locator_set_name - name of locator_set to add/del eid-table +// - vni - virtual network instance +// - key - secret key +// +// LispAddDelLocalEid defines message 'lisp_add_del_local_eid'. +type LispAddDelLocalEid struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + Eid lisp_types.Eid `binapi:"eid,name=eid" json:"eid,omitempty"` + LocatorSetName string `binapi:"string[64],name=locator_set_name" json:"locator_set_name,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + Key lisp_types.HmacKey `binapi:"hmac_key,name=key" json:"key,omitempty"` +} + +func (m *LispAddDelLocalEid) Reset() { *m = LispAddDelLocalEid{} } +func (*LispAddDelLocalEid) GetMessageName() string { return "lisp_add_del_local_eid" } +func (*LispAddDelLocalEid) GetCrcString() string { return "4e5a83a2" } +func (*LispAddDelLocalEid) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispAddDelLocalEid) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.Eid.Type + size += 1 * 18 // m.Eid.Address + size += 64 // m.LocatorSetName + size += 4 // m.Vni + size += 1 // m.Key.ID + size += 1 * 64 // m.Key.Key + return size +} +func (m *LispAddDelLocalEid) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint8(uint8(m.Eid.Type)) + buf.EncodeBytes(m.Eid.Address.XXX_UnionData[:], 18) + buf.EncodeString(m.LocatorSetName, 64) + buf.EncodeUint32(m.Vni) + buf.EncodeUint8(uint8(m.Key.ID)) + buf.EncodeBytes(m.Key.Key, 64) + return buf.Bytes(), nil +} +func (m *LispAddDelLocalEid) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Eid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Eid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.LocatorSetName = buf.DecodeString(64) + m.Vni = buf.DecodeUint32() + m.Key.ID = lisp_types.HmacKeyID(buf.DecodeUint8()) + m.Key.Key = make([]byte, 64) + copy(m.Key.Key, buf.DecodeBytes(len(m.Key.Key))) + return nil +} + +// LispAddDelLocalEidReply defines message 'lisp_add_del_local_eid_reply'. +type LispAddDelLocalEidReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LispAddDelLocalEidReply) Reset() { *m = LispAddDelLocalEidReply{} } +func (*LispAddDelLocalEidReply) GetMessageName() string { return "lisp_add_del_local_eid_reply" } +func (*LispAddDelLocalEidReply) GetCrcString() string { return "e8d4e804" } +func (*LispAddDelLocalEidReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispAddDelLocalEidReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LispAddDelLocalEidReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LispAddDelLocalEidReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// add or delete locator for locator_set +// - is_add - add address if non-zero, else delete +// - locator_set_name - name of locator_set to add/del locator +// - sw_if_index - index of the interface +// - priority - priority of the lisp locator +// - weight - weight of the lisp locator +// +// LispAddDelLocator defines message 'lisp_add_del_locator'. +type LispAddDelLocator struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + LocatorSetName string `binapi:"string[64],name=locator_set_name" json:"locator_set_name,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Priority uint8 `binapi:"u8,name=priority" json:"priority,omitempty"` + Weight uint8 `binapi:"u8,name=weight" json:"weight,omitempty"` +} + +func (m *LispAddDelLocator) Reset() { *m = LispAddDelLocator{} } +func (*LispAddDelLocator) GetMessageName() string { return "lisp_add_del_locator" } +func (*LispAddDelLocator) GetCrcString() string { return "af4d8f13" } +func (*LispAddDelLocator) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispAddDelLocator) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 64 // m.LocatorSetName + size += 4 // m.SwIfIndex + size += 1 // m.Priority + size += 1 // m.Weight + return size +} +func (m *LispAddDelLocator) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeString(m.LocatorSetName, 64) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(m.Priority) + buf.EncodeUint8(m.Weight) + return buf.Bytes(), nil +} +func (m *LispAddDelLocator) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.LocatorSetName = buf.DecodeString(64) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Priority = buf.DecodeUint8() + m.Weight = buf.DecodeUint8() + return nil +} + +// LispAddDelLocatorReply defines message 'lisp_add_del_locator_reply'. +type LispAddDelLocatorReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LispAddDelLocatorReply) Reset() { *m = LispAddDelLocatorReply{} } +func (*LispAddDelLocatorReply) GetMessageName() string { return "lisp_add_del_locator_reply" } +func (*LispAddDelLocatorReply) GetCrcString() string { return "e8d4e804" } +func (*LispAddDelLocatorReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispAddDelLocatorReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LispAddDelLocatorReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LispAddDelLocatorReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// add or delete locator_set +// - is_add - add address if non-zero, else delete +// - locator_set_name - locator name +// - locator_num - number of locators +// - locators - LISP locator records +// +// LispAddDelLocatorSet defines message 'lisp_add_del_locator_set'. +type LispAddDelLocatorSet struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + LocatorSetName string `binapi:"string[64],name=locator_set_name" json:"locator_set_name,omitempty"` + LocatorNum uint32 `binapi:"u32,name=locator_num" json:"-"` + Locators []lisp_types.LocalLocator `binapi:"local_locator[locator_num],name=locators" json:"locators,omitempty"` +} + +func (m *LispAddDelLocatorSet) Reset() { *m = LispAddDelLocatorSet{} } +func (*LispAddDelLocatorSet) GetMessageName() string { return "lisp_add_del_locator_set" } +func (*LispAddDelLocatorSet) GetCrcString() string { return "6fcd6471" } +func (*LispAddDelLocatorSet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispAddDelLocatorSet) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 64 // m.LocatorSetName + size += 4 // m.LocatorNum + for j1 := 0; j1 < len(m.Locators); j1++ { + var s1 lisp_types.LocalLocator + _ = s1 + if j1 < len(m.Locators) { + s1 = m.Locators[j1] + } + size += 4 // s1.SwIfIndex + size += 1 // s1.Priority + size += 1 // s1.Weight + } + return size +} +func (m *LispAddDelLocatorSet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeString(m.LocatorSetName, 64) + buf.EncodeUint32(uint32(len(m.Locators))) + for j0 := 0; j0 < len(m.Locators); j0++ { + var v0 lisp_types.LocalLocator // Locators + if j0 < len(m.Locators) { + v0 = m.Locators[j0] + } + buf.EncodeUint32(uint32(v0.SwIfIndex)) + buf.EncodeUint8(v0.Priority) + buf.EncodeUint8(v0.Weight) + } + return buf.Bytes(), nil +} +func (m *LispAddDelLocatorSet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.LocatorSetName = buf.DecodeString(64) + m.LocatorNum = buf.DecodeUint32() + m.Locators = make([]lisp_types.LocalLocator, m.LocatorNum) + for j0 := 0; j0 < len(m.Locators); j0++ { + m.Locators[j0].SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Locators[j0].Priority = buf.DecodeUint8() + m.Locators[j0].Weight = buf.DecodeUint8() + } + return nil +} + +// Reply for locator_set add/del +// - retval - return code +// - ls_index - locator set index +// +// LispAddDelLocatorSetReply defines message 'lisp_add_del_locator_set_reply'. +type LispAddDelLocatorSetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + LsIndex uint32 `binapi:"u32,name=ls_index" json:"ls_index,omitempty"` +} + +func (m *LispAddDelLocatorSetReply) Reset() { *m = LispAddDelLocatorSetReply{} } +func (*LispAddDelLocatorSetReply) GetMessageName() string { return "lisp_add_del_locator_set_reply" } +func (*LispAddDelLocatorSetReply) GetCrcString() string { return "b6666db4" } +func (*LispAddDelLocatorSetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispAddDelLocatorSetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.LsIndex + return size +} +func (m *LispAddDelLocatorSetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.LsIndex) + return buf.Bytes(), nil +} +func (m *LispAddDelLocatorSetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.LsIndex = buf.DecodeUint32() + return nil +} + +// add or delete map request itr rlocs +// - is_add - add address if non-zero, else delete +// - locator_set_name - locator set name +// +// LispAddDelMapRequestItrRlocs defines message 'lisp_add_del_map_request_itr_rlocs'. +type LispAddDelMapRequestItrRlocs struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + LocatorSetName string `binapi:"string[64],name=locator_set_name" json:"locator_set_name,omitempty"` +} + +func (m *LispAddDelMapRequestItrRlocs) Reset() { *m = LispAddDelMapRequestItrRlocs{} } +func (*LispAddDelMapRequestItrRlocs) GetMessageName() string { + return "lisp_add_del_map_request_itr_rlocs" +} +func (*LispAddDelMapRequestItrRlocs) GetCrcString() string { return "6be88e45" } +func (*LispAddDelMapRequestItrRlocs) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispAddDelMapRequestItrRlocs) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 64 // m.LocatorSetName + return size +} +func (m *LispAddDelMapRequestItrRlocs) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeString(m.LocatorSetName, 64) + return buf.Bytes(), nil +} +func (m *LispAddDelMapRequestItrRlocs) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.LocatorSetName = buf.DecodeString(64) + return nil +} + +// LispAddDelMapRequestItrRlocsReply defines message 'lisp_add_del_map_request_itr_rlocs_reply'. +type LispAddDelMapRequestItrRlocsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LispAddDelMapRequestItrRlocsReply) Reset() { *m = LispAddDelMapRequestItrRlocsReply{} } +func (*LispAddDelMapRequestItrRlocsReply) GetMessageName() string { + return "lisp_add_del_map_request_itr_rlocs_reply" +} +func (*LispAddDelMapRequestItrRlocsReply) GetCrcString() string { return "e8d4e804" } +func (*LispAddDelMapRequestItrRlocsReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispAddDelMapRequestItrRlocsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LispAddDelMapRequestItrRlocsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LispAddDelMapRequestItrRlocsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// add or delete map-resolver +// - is_add - add address if non-zero, else delete +// - ip_address - ip address +// +// LispAddDelMapResolver defines message 'lisp_add_del_map_resolver'. +type LispAddDelMapResolver struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` +} + +func (m *LispAddDelMapResolver) Reset() { *m = LispAddDelMapResolver{} } +func (*LispAddDelMapResolver) GetMessageName() string { return "lisp_add_del_map_resolver" } +func (*LispAddDelMapResolver) GetCrcString() string { return "ce19e32d" } +func (*LispAddDelMapResolver) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispAddDelMapResolver) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + return size +} +func (m *LispAddDelMapResolver) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *LispAddDelMapResolver) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// LispAddDelMapResolverReply defines message 'lisp_add_del_map_resolver_reply'. +type LispAddDelMapResolverReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LispAddDelMapResolverReply) Reset() { *m = LispAddDelMapResolverReply{} } +func (*LispAddDelMapResolverReply) GetMessageName() string { return "lisp_add_del_map_resolver_reply" } +func (*LispAddDelMapResolverReply) GetCrcString() string { return "e8d4e804" } +func (*LispAddDelMapResolverReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispAddDelMapResolverReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LispAddDelMapResolverReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LispAddDelMapResolverReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add/delete map server +// - is_add - add address if non-zero; delete otherwise +// - ip_address - map server IP address +// +// LispAddDelMapServer defines message 'lisp_add_del_map_server'. +type LispAddDelMapServer struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` +} + +func (m *LispAddDelMapServer) Reset() { *m = LispAddDelMapServer{} } +func (*LispAddDelMapServer) GetMessageName() string { return "lisp_add_del_map_server" } +func (*LispAddDelMapServer) GetCrcString() string { return "ce19e32d" } +func (*LispAddDelMapServer) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispAddDelMapServer) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + return size +} +func (m *LispAddDelMapServer) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *LispAddDelMapServer) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// LispAddDelMapServerReply defines message 'lisp_add_del_map_server_reply'. +type LispAddDelMapServerReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LispAddDelMapServerReply) Reset() { *m = LispAddDelMapServerReply{} } +func (*LispAddDelMapServerReply) GetMessageName() string { return "lisp_add_del_map_server_reply" } +func (*LispAddDelMapServerReply) GetCrcString() string { return "e8d4e804" } +func (*LispAddDelMapServerReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispAddDelMapServerReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LispAddDelMapServerReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LispAddDelMapServerReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// add or delete remote static mapping +// - is_add - add address if non-zero, else delete +// - is_src_dst - flag indicating src/dst based routing policy +// - del_all - if set, delete all remote mappings +// - vni - virtual network instance +// - action - negative map-reply action +// - deid - dst EID +// - seid - src EID, valid only if is_src_dst is enabled +// - rloc_num - number of remote locators +// - rlocs - remote locator records +// +// LispAddDelRemoteMapping defines message 'lisp_add_del_remote_mapping'. +type LispAddDelRemoteMapping struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + IsSrcDst bool `binapi:"bool,name=is_src_dst" json:"is_src_dst,omitempty"` + DelAll bool `binapi:"bool,name=del_all" json:"del_all,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + Action uint8 `binapi:"u8,name=action" json:"action,omitempty"` + Deid lisp_types.Eid `binapi:"eid,name=deid" json:"deid,omitempty"` + Seid lisp_types.Eid `binapi:"eid,name=seid" json:"seid,omitempty"` + RlocNum uint32 `binapi:"u32,name=rloc_num" json:"-"` + Rlocs []lisp_types.RemoteLocator `binapi:"remote_locator[rloc_num],name=rlocs" json:"rlocs,omitempty"` +} + +func (m *LispAddDelRemoteMapping) Reset() { *m = LispAddDelRemoteMapping{} } +func (*LispAddDelRemoteMapping) GetMessageName() string { return "lisp_add_del_remote_mapping" } +func (*LispAddDelRemoteMapping) GetCrcString() string { return "6d5c789e" } +func (*LispAddDelRemoteMapping) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispAddDelRemoteMapping) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.IsSrcDst + size += 1 // m.DelAll + size += 4 // m.Vni + size += 1 // m.Action + size += 1 // m.Deid.Type + size += 1 * 18 // m.Deid.Address + size += 1 // m.Seid.Type + size += 1 * 18 // m.Seid.Address + size += 4 // m.RlocNum + for j1 := 0; j1 < len(m.Rlocs); j1++ { + var s1 lisp_types.RemoteLocator + _ = s1 + if j1 < len(m.Rlocs) { + s1 = m.Rlocs[j1] + } + size += 1 // s1.Priority + size += 1 // s1.Weight + size += 1 // s1.IPAddress.Af + size += 1 * 16 // s1.IPAddress.Un + } + return size +} +func (m *LispAddDelRemoteMapping) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeBool(m.IsSrcDst) + buf.EncodeBool(m.DelAll) + buf.EncodeUint32(m.Vni) + buf.EncodeUint8(m.Action) + buf.EncodeUint8(uint8(m.Deid.Type)) + buf.EncodeBytes(m.Deid.Address.XXX_UnionData[:], 18) + buf.EncodeUint8(uint8(m.Seid.Type)) + buf.EncodeBytes(m.Seid.Address.XXX_UnionData[:], 18) + buf.EncodeUint32(uint32(len(m.Rlocs))) + for j0 := 0; j0 < len(m.Rlocs); j0++ { + var v0 lisp_types.RemoteLocator // Rlocs + if j0 < len(m.Rlocs) { + v0 = m.Rlocs[j0] + } + buf.EncodeUint8(v0.Priority) + buf.EncodeUint8(v0.Weight) + buf.EncodeUint8(uint8(v0.IPAddress.Af)) + buf.EncodeBytes(v0.IPAddress.Un.XXX_UnionData[:], 16) + } + return buf.Bytes(), nil +} +func (m *LispAddDelRemoteMapping) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.IsSrcDst = buf.DecodeBool() + m.DelAll = buf.DecodeBool() + m.Vni = buf.DecodeUint32() + m.Action = buf.DecodeUint8() + m.Deid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Deid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.Seid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Seid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.RlocNum = buf.DecodeUint32() + m.Rlocs = make([]lisp_types.RemoteLocator, m.RlocNum) + for j0 := 0; j0 < len(m.Rlocs); j0++ { + m.Rlocs[j0].Priority = buf.DecodeUint8() + m.Rlocs[j0].Weight = buf.DecodeUint8() + m.Rlocs[j0].IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Rlocs[j0].IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + } + return nil +} + +// LispAddDelRemoteMappingReply defines message 'lisp_add_del_remote_mapping_reply'. +type LispAddDelRemoteMappingReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LispAddDelRemoteMappingReply) Reset() { *m = LispAddDelRemoteMappingReply{} } +func (*LispAddDelRemoteMappingReply) GetMessageName() string { + return "lisp_add_del_remote_mapping_reply" +} +func (*LispAddDelRemoteMappingReply) GetCrcString() string { return "e8d4e804" } +func (*LispAddDelRemoteMappingReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispAddDelRemoteMappingReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LispAddDelRemoteMappingReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LispAddDelRemoteMappingReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Request for LISP adjacencies +// - vni - filter adjacencies by VNI +// +// LispAdjacenciesGet defines message 'lisp_adjacencies_get'. +type LispAdjacenciesGet struct { + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` +} + +func (m *LispAdjacenciesGet) Reset() { *m = LispAdjacenciesGet{} } +func (*LispAdjacenciesGet) GetMessageName() string { return "lisp_adjacencies_get" } +func (*LispAdjacenciesGet) GetCrcString() string { return "8d1f2fe9" } +func (*LispAdjacenciesGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispAdjacenciesGet) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Vni + return size +} +func (m *LispAdjacenciesGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Vni) + return buf.Bytes(), nil +} +func (m *LispAdjacenciesGet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Vni = buf.DecodeUint32() + return nil +} + +// LISP adjacency reply +// - count - number of adjacencies +// - adjacencies - array of adjacencies +// +// LispAdjacenciesGetReply defines message 'lisp_adjacencies_get_reply'. +type LispAdjacenciesGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + Adjacencies []LispAdjacency `binapi:"lisp_adjacency[count],name=adjacencies" json:"adjacencies,omitempty"` +} + +func (m *LispAdjacenciesGetReply) Reset() { *m = LispAdjacenciesGetReply{} } +func (*LispAdjacenciesGetReply) GetMessageName() string { return "lisp_adjacencies_get_reply" } +func (*LispAdjacenciesGetReply) GetCrcString() string { return "807257bf" } +func (*LispAdjacenciesGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispAdjacenciesGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + for j1 := 0; j1 < len(m.Adjacencies); j1++ { + var s1 LispAdjacency + _ = s1 + if j1 < len(m.Adjacencies) { + s1 = m.Adjacencies[j1] + } + size += 1 // s1.Reid.Type + size += 1 * 18 // s1.Reid.Address + size += 1 // s1.Leid.Type + size += 1 * 18 // s1.Leid.Address + } + return size +} +func (m *LispAdjacenciesGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.Adjacencies))) + for j0 := 0; j0 < len(m.Adjacencies); j0++ { + var v0 LispAdjacency // Adjacencies + if j0 < len(m.Adjacencies) { + v0 = m.Adjacencies[j0] + } + buf.EncodeUint8(uint8(v0.Reid.Type)) + buf.EncodeBytes(v0.Reid.Address.XXX_UnionData[:], 18) + buf.EncodeUint8(uint8(v0.Leid.Type)) + buf.EncodeBytes(v0.Leid.Address.XXX_UnionData[:], 18) + } + return buf.Bytes(), nil +} +func (m *LispAdjacenciesGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.Adjacencies = make([]LispAdjacency, m.Count) + for j0 := 0; j0 < len(m.Adjacencies); j0++ { + m.Adjacencies[j0].Reid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Adjacencies[j0].Reid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.Adjacencies[j0].Leid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Adjacencies[j0].Leid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + } + return nil +} + +// map/unmap vni/bd_index to vrf +// - is_add - add or delete mapping +// - dp_table - virtual network id/bridge domain index +// - vrf - vrf +// +// LispEidTableAddDelMap defines message 'lisp_eid_table_add_del_map'. +type LispEidTableAddDelMap struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + DpTable uint32 `binapi:"u32,name=dp_table" json:"dp_table,omitempty"` + IsL2 bool `binapi:"bool,name=is_l2" json:"is_l2,omitempty"` +} + +func (m *LispEidTableAddDelMap) Reset() { *m = LispEidTableAddDelMap{} } +func (*LispEidTableAddDelMap) GetMessageName() string { return "lisp_eid_table_add_del_map" } +func (*LispEidTableAddDelMap) GetCrcString() string { return "9481416b" } +func (*LispEidTableAddDelMap) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispEidTableAddDelMap) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Vni + size += 4 // m.DpTable + size += 1 // m.IsL2 + return size +} +func (m *LispEidTableAddDelMap) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.Vni) + buf.EncodeUint32(m.DpTable) + buf.EncodeBool(m.IsL2) + return buf.Bytes(), nil +} +func (m *LispEidTableAddDelMap) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Vni = buf.DecodeUint32() + m.DpTable = buf.DecodeUint32() + m.IsL2 = buf.DecodeBool() + return nil +} + +// LispEidTableAddDelMapReply defines message 'lisp_eid_table_add_del_map_reply'. +type LispEidTableAddDelMapReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LispEidTableAddDelMapReply) Reset() { *m = LispEidTableAddDelMapReply{} } +func (*LispEidTableAddDelMapReply) GetMessageName() string { return "lisp_eid_table_add_del_map_reply" } +func (*LispEidTableAddDelMapReply) GetCrcString() string { return "e8d4e804" } +func (*LispEidTableAddDelMapReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispEidTableAddDelMapReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LispEidTableAddDelMapReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LispEidTableAddDelMapReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Dump lisp eid-table +// - locator_set_index - index of locator_set, if ~0 then the mapping +// is negative +// - action - negative map request action +// - is_local - local if non-zero, else remote +// - is_src_dst - EID is type of source/destination +// - deid - dst EID +// - seid - src EID +// - vni - virtual network instance +// - ttl - time to live +// - authoritative - authoritative +// - key_id +// HMAC_NO_KEY 0 +// HMAC_SHA_1_96 1 +// HMAC_SHA_256_128 2 +// - key - secret key +// +// LispEidTableDetails defines message 'lisp_eid_table_details'. +type LispEidTableDetails struct { + LocatorSetIndex uint32 `binapi:"u32,name=locator_set_index" json:"locator_set_index,omitempty"` + Action uint8 `binapi:"u8,name=action" json:"action,omitempty"` + IsLocal bool `binapi:"bool,name=is_local" json:"is_local,omitempty"` + IsSrcDst bool `binapi:"bool,name=is_src_dst" json:"is_src_dst,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + Deid lisp_types.Eid `binapi:"eid,name=deid" json:"deid,omitempty"` + Seid lisp_types.Eid `binapi:"eid,name=seid" json:"seid,omitempty"` + TTL uint32 `binapi:"u32,name=ttl" json:"ttl,omitempty"` + Authoritative uint8 `binapi:"u8,name=authoritative" json:"authoritative,omitempty"` + Key lisp_types.HmacKey `binapi:"hmac_key,name=key" json:"key,omitempty"` +} + +func (m *LispEidTableDetails) Reset() { *m = LispEidTableDetails{} } +func (*LispEidTableDetails) GetMessageName() string { return "lisp_eid_table_details" } +func (*LispEidTableDetails) GetCrcString() string { return "1c29f792" } +func (*LispEidTableDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispEidTableDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.LocatorSetIndex + size += 1 // m.Action + size += 1 // m.IsLocal + size += 1 // m.IsSrcDst + size += 4 // m.Vni + size += 1 // m.Deid.Type + size += 1 * 18 // m.Deid.Address + size += 1 // m.Seid.Type + size += 1 * 18 // m.Seid.Address + size += 4 // m.TTL + size += 1 // m.Authoritative + size += 1 // m.Key.ID + size += 1 * 64 // m.Key.Key + return size +} +func (m *LispEidTableDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.LocatorSetIndex) + buf.EncodeUint8(m.Action) + buf.EncodeBool(m.IsLocal) + buf.EncodeBool(m.IsSrcDst) + buf.EncodeUint32(m.Vni) + buf.EncodeUint8(uint8(m.Deid.Type)) + buf.EncodeBytes(m.Deid.Address.XXX_UnionData[:], 18) + buf.EncodeUint8(uint8(m.Seid.Type)) + buf.EncodeBytes(m.Seid.Address.XXX_UnionData[:], 18) + buf.EncodeUint32(m.TTL) + buf.EncodeUint8(m.Authoritative) + buf.EncodeUint8(uint8(m.Key.ID)) + buf.EncodeBytes(m.Key.Key, 64) + return buf.Bytes(), nil +} +func (m *LispEidTableDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.LocatorSetIndex = buf.DecodeUint32() + m.Action = buf.DecodeUint8() + m.IsLocal = buf.DecodeBool() + m.IsSrcDst = buf.DecodeBool() + m.Vni = buf.DecodeUint32() + m.Deid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Deid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.Seid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Seid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.TTL = buf.DecodeUint32() + m.Authoritative = buf.DecodeUint8() + m.Key.ID = lisp_types.HmacKeyID(buf.DecodeUint8()) + m.Key.Key = make([]byte, 64) + copy(m.Key.Key, buf.DecodeBytes(len(m.Key.Key))) + return nil +} + +// Request for eid table summary status +// - eid_set - if non-zero request info about specific mapping +// - vni - virtual network instance; valid only if eid_set != 0 +// - prefix_length - prefix length if EID is IP address; +// valid only if eid_set != 0 +// - eid - endpoint identifier +// - filter - filter type; +// Support values: +// 0: all eid +// 1: local eid +// 2: remote eid +// +// LispEidTableDump defines message 'lisp_eid_table_dump'. +type LispEidTableDump struct { + EidSet uint8 `binapi:"u8,name=eid_set" json:"eid_set,omitempty"` + PrefixLength uint8 `binapi:"u8,name=prefix_length" json:"prefix_length,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + Eid lisp_types.Eid `binapi:"eid,name=eid" json:"eid,omitempty"` + Filter LispLocatorSetFilter `binapi:"lisp_locator_set_filter,name=filter" json:"filter,omitempty"` +} + +func (m *LispEidTableDump) Reset() { *m = LispEidTableDump{} } +func (*LispEidTableDump) GetMessageName() string { return "lisp_eid_table_dump" } +func (*LispEidTableDump) GetCrcString() string { return "629468b5" } +func (*LispEidTableDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispEidTableDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.EidSet + size += 1 // m.PrefixLength + size += 4 // m.Vni + size += 1 // m.Eid.Type + size += 1 * 18 // m.Eid.Address + size += 1 // m.Filter + return size +} +func (m *LispEidTableDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.EidSet) + buf.EncodeUint8(m.PrefixLength) + buf.EncodeUint32(m.Vni) + buf.EncodeUint8(uint8(m.Eid.Type)) + buf.EncodeBytes(m.Eid.Address.XXX_UnionData[:], 18) + buf.EncodeUint8(uint8(m.Filter)) + return buf.Bytes(), nil +} +func (m *LispEidTableDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EidSet = buf.DecodeUint8() + m.PrefixLength = buf.DecodeUint8() + m.Vni = buf.DecodeUint32() + m.Eid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Eid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.Filter = LispLocatorSetFilter(buf.DecodeUint8()) + return nil +} + +// Shows relationship between vni and vrf/bd +// - dp_table - VRF index or bridge domain index +// - vni - virtual network instance +// +// LispEidTableMapDetails defines message 'lisp_eid_table_map_details'. +type LispEidTableMapDetails struct { + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + DpTable uint32 `binapi:"u32,name=dp_table" json:"dp_table,omitempty"` +} + +func (m *LispEidTableMapDetails) Reset() { *m = LispEidTableMapDetails{} } +func (*LispEidTableMapDetails) GetMessageName() string { return "lisp_eid_table_map_details" } +func (*LispEidTableMapDetails) GetCrcString() string { return "0b6859e2" } +func (*LispEidTableMapDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispEidTableMapDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Vni + size += 4 // m.DpTable + return size +} +func (m *LispEidTableMapDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Vni) + buf.EncodeUint32(m.DpTable) + return buf.Bytes(), nil +} +func (m *LispEidTableMapDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Vni = buf.DecodeUint32() + m.DpTable = buf.DecodeUint32() + return nil +} + +// Request for lisp_eid_table_map_details +// - is_l2 - if set dump vni/bd mappings else vni/vrf +// +// LispEidTableMapDump defines message 'lisp_eid_table_map_dump'. +type LispEidTableMapDump struct { + IsL2 bool `binapi:"bool,name=is_l2" json:"is_l2,omitempty"` +} + +func (m *LispEidTableMapDump) Reset() { *m = LispEidTableMapDump{} } +func (*LispEidTableMapDump) GetMessageName() string { return "lisp_eid_table_map_dump" } +func (*LispEidTableMapDump) GetCrcString() string { return "d6cf0c3d" } +func (*LispEidTableMapDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispEidTableMapDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsL2 + return size +} +func (m *LispEidTableMapDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsL2) + return buf.Bytes(), nil +} +func (m *LispEidTableMapDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsL2 = buf.DecodeBool() + return nil +} + +// reply to lisp_eid_table_vni_dump +// - vni - virtual network instance +// +// LispEidTableVniDetails defines message 'lisp_eid_table_vni_details'. +type LispEidTableVniDetails struct { + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` +} + +func (m *LispEidTableVniDetails) Reset() { *m = LispEidTableVniDetails{} } +func (*LispEidTableVniDetails) GetMessageName() string { return "lisp_eid_table_vni_details" } +func (*LispEidTableVniDetails) GetCrcString() string { return "64abc01e" } +func (*LispEidTableVniDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispEidTableVniDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Vni + return size +} +func (m *LispEidTableVniDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Vni) + return buf.Bytes(), nil +} +func (m *LispEidTableVniDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Vni = buf.DecodeUint32() + return nil +} + +// Dumps all VNIs used in mappings +// LispEidTableVniDump defines message 'lisp_eid_table_vni_dump'. +type LispEidTableVniDump struct{} + +func (m *LispEidTableVniDump) Reset() { *m = LispEidTableVniDump{} } +func (*LispEidTableVniDump) GetMessageName() string { return "lisp_eid_table_vni_dump" } +func (*LispEidTableVniDump) GetCrcString() string { return "51077d14" } +func (*LispEidTableVniDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispEidTableVniDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *LispEidTableVniDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *LispEidTableVniDump) Unmarshal(b []byte) error { + return nil +} + +// enable or disable LISP feature +// - is_en - enable protocol if non-zero, else disable +// +// LispEnableDisable defines message 'lisp_enable_disable'. +type LispEnableDisable struct { + IsEnable bool `binapi:"bool,name=is_enable,default=true" json:"is_enable,omitempty"` +} + +func (m *LispEnableDisable) Reset() { *m = LispEnableDisable{} } +func (*LispEnableDisable) GetMessageName() string { return "lisp_enable_disable" } +func (*LispEnableDisable) GetCrcString() string { return "c264d7bf" } +func (*LispEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsEnable + return size +} +func (m *LispEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *LispEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsEnable = buf.DecodeBool() + return nil +} + +// LispEnableDisableReply defines message 'lisp_enable_disable_reply'. +type LispEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LispEnableDisableReply) Reset() { *m = LispEnableDisableReply{} } +func (*LispEnableDisableReply) GetMessageName() string { return "lisp_enable_disable_reply" } +func (*LispEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*LispEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LispEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LispEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Get LISP map request itr rlocs status +// - locator_set_name - name of the locator_set +// +// LispGetMapRequestItrRlocs defines message 'lisp_get_map_request_itr_rlocs'. +type LispGetMapRequestItrRlocs struct{} + +func (m *LispGetMapRequestItrRlocs) Reset() { *m = LispGetMapRequestItrRlocs{} } +func (*LispGetMapRequestItrRlocs) GetMessageName() string { return "lisp_get_map_request_itr_rlocs" } +func (*LispGetMapRequestItrRlocs) GetCrcString() string { return "51077d14" } +func (*LispGetMapRequestItrRlocs) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispGetMapRequestItrRlocs) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *LispGetMapRequestItrRlocs) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *LispGetMapRequestItrRlocs) Unmarshal(b []byte) error { + return nil +} + +// Request for map request itr rlocs summary status +// LispGetMapRequestItrRlocsReply defines message 'lisp_get_map_request_itr_rlocs_reply'. +type LispGetMapRequestItrRlocsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + LocatorSetName string `binapi:"string[64],name=locator_set_name" json:"locator_set_name,omitempty"` +} + +func (m *LispGetMapRequestItrRlocsReply) Reset() { *m = LispGetMapRequestItrRlocsReply{} } +func (*LispGetMapRequestItrRlocsReply) GetMessageName() string { + return "lisp_get_map_request_itr_rlocs_reply" +} +func (*LispGetMapRequestItrRlocsReply) GetCrcString() string { return "76580f3a" } +func (*LispGetMapRequestItrRlocsReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispGetMapRequestItrRlocsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 64 // m.LocatorSetName + return size +} +func (m *LispGetMapRequestItrRlocsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeString(m.LocatorSetName, 64) + return buf.Bytes(), nil +} +func (m *LispGetMapRequestItrRlocsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.LocatorSetName = buf.DecodeString(64) + return nil +} + +// LISP locator_set status +// - local - if is set, then locator is local +// - locator_set_name - name of the locator_set +// - sw_if_index - sw_if_index of the locator +// - ip_address - ip address +// - priority - locator priority +// - weight - locator weight +// +// LispLocatorDetails defines message 'lisp_locator_details'. +type LispLocatorDetails struct { + Local uint8 `binapi:"u8,name=local" json:"local,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` + Priority uint8 `binapi:"u8,name=priority" json:"priority,omitempty"` + Weight uint8 `binapi:"u8,name=weight" json:"weight,omitempty"` +} + +func (m *LispLocatorDetails) Reset() { *m = LispLocatorDetails{} } +func (*LispLocatorDetails) GetMessageName() string { return "lisp_locator_details" } +func (*LispLocatorDetails) GetCrcString() string { return "2c620ffe" } +func (*LispLocatorDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispLocatorDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Local + size += 4 // m.SwIfIndex + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + size += 1 // m.Priority + size += 1 // m.Weight + return size +} +func (m *LispLocatorDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.Local) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Priority) + buf.EncodeUint8(m.Weight) + return buf.Bytes(), nil +} +func (m *LispLocatorDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Local = buf.DecodeUint8() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Priority = buf.DecodeUint8() + m.Weight = buf.DecodeUint8() + return nil +} + +// Request for map lisp locator status +// - locator_set_index - index of locator_set +// - ls_name - locator set name +// - is_index_set - flag indicating whether ls_name or ls_index is set +// +// LispLocatorDump defines message 'lisp_locator_dump'. +type LispLocatorDump struct { + LsIndex uint32 `binapi:"u32,name=ls_index" json:"ls_index,omitempty"` + LsName string `binapi:"string[64],name=ls_name" json:"ls_name,omitempty"` + IsIndexSet uint8 `binapi:"u8,name=is_index_set" json:"is_index_set,omitempty"` +} + +func (m *LispLocatorDump) Reset() { *m = LispLocatorDump{} } +func (*LispLocatorDump) GetMessageName() string { return "lisp_locator_dump" } +func (*LispLocatorDump) GetCrcString() string { return "b954fad7" } +func (*LispLocatorDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispLocatorDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.LsIndex + size += 64 // m.LsName + size += 1 // m.IsIndexSet + return size +} +func (m *LispLocatorDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.LsIndex) + buf.EncodeString(m.LsName, 64) + buf.EncodeUint8(m.IsIndexSet) + return buf.Bytes(), nil +} +func (m *LispLocatorDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.LsIndex = buf.DecodeUint32() + m.LsName = buf.DecodeString(64) + m.IsIndexSet = buf.DecodeUint8() + return nil +} + +// LISP locator_set status +// - ls_index - locator set index +// - ls_name - name of the locator set +// +// LispLocatorSetDetails defines message 'lisp_locator_set_details'. +type LispLocatorSetDetails struct { + LsIndex uint32 `binapi:"u32,name=ls_index" json:"ls_index,omitempty"` + LsName string `binapi:"string[64],name=ls_name" json:"ls_name,omitempty"` +} + +func (m *LispLocatorSetDetails) Reset() { *m = LispLocatorSetDetails{} } +func (*LispLocatorSetDetails) GetMessageName() string { return "lisp_locator_set_details" } +func (*LispLocatorSetDetails) GetCrcString() string { return "5b33a105" } +func (*LispLocatorSetDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispLocatorSetDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.LsIndex + size += 64 // m.LsName + return size +} +func (m *LispLocatorSetDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.LsIndex) + buf.EncodeString(m.LsName, 64) + return buf.Bytes(), nil +} +func (m *LispLocatorSetDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.LsIndex = buf.DecodeUint32() + m.LsName = buf.DecodeString(64) + return nil +} + +// Request for locator_set summary status +// - filter - filter type +// +// LispLocatorSetDump defines message 'lisp_locator_set_dump'. +type LispLocatorSetDump struct { + Filter LispLocatorSetFilter `binapi:"lisp_locator_set_filter,name=filter" json:"filter,omitempty"` +} + +func (m *LispLocatorSetDump) Reset() { *m = LispLocatorSetDump{} } +func (*LispLocatorSetDump) GetMessageName() string { return "lisp_locator_set_dump" } +func (*LispLocatorSetDump) GetCrcString() string { return "c2cb5922" } +func (*LispLocatorSetDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispLocatorSetDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Filter + return size +} +func (m *LispLocatorSetDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Filter)) + return buf.Bytes(), nil +} +func (m *LispLocatorSetDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Filter = LispLocatorSetFilter(buf.DecodeUint8()) + return nil +} + +// enable/disable LISP map-register +// - is_enable - enable if non-zero; disable otherwise +// +// LispMapRegisterEnableDisable defines message 'lisp_map_register_enable_disable'. +type LispMapRegisterEnableDisable struct { + IsEnable bool `binapi:"bool,name=is_enable,default=true" json:"is_enable,omitempty"` +} + +func (m *LispMapRegisterEnableDisable) Reset() { *m = LispMapRegisterEnableDisable{} } +func (*LispMapRegisterEnableDisable) GetMessageName() string { + return "lisp_map_register_enable_disable" +} +func (*LispMapRegisterEnableDisable) GetCrcString() string { return "c264d7bf" } +func (*LispMapRegisterEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispMapRegisterEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsEnable + return size +} +func (m *LispMapRegisterEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *LispMapRegisterEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsEnable = buf.DecodeBool() + return nil +} + +// LispMapRegisterEnableDisableReply defines message 'lisp_map_register_enable_disable_reply'. +type LispMapRegisterEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LispMapRegisterEnableDisableReply) Reset() { *m = LispMapRegisterEnableDisableReply{} } +func (*LispMapRegisterEnableDisableReply) GetMessageName() string { + return "lisp_map_register_enable_disable_reply" +} +func (*LispMapRegisterEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*LispMapRegisterEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispMapRegisterEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LispMapRegisterEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LispMapRegisterEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// set LISP map-request mode. Based on configuration VPP will send +// +// src/dest or just normal destination map requests. +// - is_src_dst - if non-zero source/destination else destination only +// +// LispMapRequestMode defines message 'lisp_map_request_mode'. +type LispMapRequestMode struct { + IsSrcDst bool `binapi:"bool,name=is_src_dst" json:"is_src_dst,omitempty"` +} + +func (m *LispMapRequestMode) Reset() { *m = LispMapRequestMode{} } +func (*LispMapRequestMode) GetMessageName() string { return "lisp_map_request_mode" } +func (*LispMapRequestMode) GetCrcString() string { return "f43c26ae" } +func (*LispMapRequestMode) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispMapRequestMode) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsSrcDst + return size +} +func (m *LispMapRequestMode) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsSrcDst) + return buf.Bytes(), nil +} +func (m *LispMapRequestMode) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsSrcDst = buf.DecodeBool() + return nil +} + +// LispMapRequestModeReply defines message 'lisp_map_request_mode_reply'. +type LispMapRequestModeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LispMapRequestModeReply) Reset() { *m = LispMapRequestModeReply{} } +func (*LispMapRequestModeReply) GetMessageName() string { return "lisp_map_request_mode_reply" } +func (*LispMapRequestModeReply) GetCrcString() string { return "e8d4e804" } +func (*LispMapRequestModeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispMapRequestModeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LispMapRequestModeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LispMapRequestModeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// LISP map resolver status +// - ip_address - array of address bytes +// +// LispMapResolverDetails defines message 'lisp_map_resolver_details'. +type LispMapResolverDetails struct { + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` +} + +func (m *LispMapResolverDetails) Reset() { *m = LispMapResolverDetails{} } +func (*LispMapResolverDetails) GetMessageName() string { return "lisp_map_resolver_details" } +func (*LispMapResolverDetails) GetCrcString() string { return "3e78fc57" } +func (*LispMapResolverDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispMapResolverDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + return size +} +func (m *LispMapResolverDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *LispMapResolverDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// Request for map resolver summary status +// LispMapResolverDump defines message 'lisp_map_resolver_dump'. +type LispMapResolverDump struct{} + +func (m *LispMapResolverDump) Reset() { *m = LispMapResolverDump{} } +func (*LispMapResolverDump) GetMessageName() string { return "lisp_map_resolver_dump" } +func (*LispMapResolverDump) GetCrcString() string { return "51077d14" } +func (*LispMapResolverDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispMapResolverDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *LispMapResolverDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *LispMapResolverDump) Unmarshal(b []byte) error { + return nil +} + +// LISP map server details +// - ip_address - array of address bytes +// +// LispMapServerDetails defines message 'lisp_map_server_details'. +type LispMapServerDetails struct { + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` +} + +func (m *LispMapServerDetails) Reset() { *m = LispMapServerDetails{} } +func (*LispMapServerDetails) GetMessageName() string { return "lisp_map_server_details" } +func (*LispMapServerDetails) GetCrcString() string { return "3e78fc57" } +func (*LispMapServerDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispMapServerDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + return size +} +func (m *LispMapServerDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *LispMapServerDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// Request for map server summary status +// LispMapServerDump defines message 'lisp_map_server_dump'. +type LispMapServerDump struct{} + +func (m *LispMapServerDump) Reset() { *m = LispMapServerDump{} } +func (*LispMapServerDump) GetMessageName() string { return "lisp_map_server_dump" } +func (*LispMapServerDump) GetCrcString() string { return "51077d14" } +func (*LispMapServerDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispMapServerDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *LispMapServerDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *LispMapServerDump) Unmarshal(b []byte) error { + return nil +} + +// configure or disable LISP PITR node +// - ls_name - locator set name +// - is_add - add locator set if non-zero, else disable pitr +// +// LispPitrSetLocatorSet defines message 'lisp_pitr_set_locator_set'. +type LispPitrSetLocatorSet struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + LsName string `binapi:"string[64],name=ls_name" json:"ls_name,omitempty"` +} + +func (m *LispPitrSetLocatorSet) Reset() { *m = LispPitrSetLocatorSet{} } +func (*LispPitrSetLocatorSet) GetMessageName() string { return "lisp_pitr_set_locator_set" } +func (*LispPitrSetLocatorSet) GetCrcString() string { return "486e2b76" } +func (*LispPitrSetLocatorSet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispPitrSetLocatorSet) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 64 // m.LsName + return size +} +func (m *LispPitrSetLocatorSet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeString(m.LsName, 64) + return buf.Bytes(), nil +} +func (m *LispPitrSetLocatorSet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.LsName = buf.DecodeString(64) + return nil +} + +// LispPitrSetLocatorSetReply defines message 'lisp_pitr_set_locator_set_reply'. +type LispPitrSetLocatorSetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LispPitrSetLocatorSetReply) Reset() { *m = LispPitrSetLocatorSetReply{} } +func (*LispPitrSetLocatorSetReply) GetMessageName() string { return "lisp_pitr_set_locator_set_reply" } +func (*LispPitrSetLocatorSetReply) GetCrcString() string { return "e8d4e804" } +func (*LispPitrSetLocatorSetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispPitrSetLocatorSetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LispPitrSetLocatorSetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LispPitrSetLocatorSetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// enable/disable LISP RLOC probing +// - is_enable - enable if non-zero; disable otherwise +// +// LispRlocProbeEnableDisable defines message 'lisp_rloc_probe_enable_disable'. +type LispRlocProbeEnableDisable struct { + IsEnable bool `binapi:"bool,name=is_enable,default=true" json:"is_enable,omitempty"` +} + +func (m *LispRlocProbeEnableDisable) Reset() { *m = LispRlocProbeEnableDisable{} } +func (*LispRlocProbeEnableDisable) GetMessageName() string { return "lisp_rloc_probe_enable_disable" } +func (*LispRlocProbeEnableDisable) GetCrcString() string { return "c264d7bf" } +func (*LispRlocProbeEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispRlocProbeEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsEnable + return size +} +func (m *LispRlocProbeEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *LispRlocProbeEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsEnable = buf.DecodeBool() + return nil +} + +// LispRlocProbeEnableDisableReply defines message 'lisp_rloc_probe_enable_disable_reply'. +type LispRlocProbeEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LispRlocProbeEnableDisableReply) Reset() { *m = LispRlocProbeEnableDisableReply{} } +func (*LispRlocProbeEnableDisableReply) GetMessageName() string { + return "lisp_rloc_probe_enable_disable_reply" +} +func (*LispRlocProbeEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*LispRlocProbeEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispRlocProbeEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LispRlocProbeEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LispRlocProbeEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// configure or disable use of PETR +// - ip_address - PETR IP address +// - is_add - add locator set if non-zero, else disable pitr +// +// LispUsePetr defines message 'lisp_use_petr'. +type LispUsePetr struct { + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` +} + +func (m *LispUsePetr) Reset() { *m = LispUsePetr{} } +func (*LispUsePetr) GetMessageName() string { return "lisp_use_petr" } +func (*LispUsePetr) GetCrcString() string { return "d87dbad9" } +func (*LispUsePetr) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LispUsePetr) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + size += 1 // m.IsAdd + return size +} +func (m *LispUsePetr) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *LispUsePetr) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.IsAdd = buf.DecodeBool() + return nil +} + +// LispUsePetrReply defines message 'lisp_use_petr_reply'. +type LispUsePetrReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LispUsePetrReply) Reset() { *m = LispUsePetrReply{} } +func (*LispUsePetrReply) GetMessageName() string { return "lisp_use_petr_reply" } +func (*LispUsePetrReply) GetCrcString() string { return "e8d4e804" } +func (*LispUsePetrReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LispUsePetrReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LispUsePetrReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LispUsePetrReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Get state of LISP map-register +// ShowLispMapRegisterState defines message 'show_lisp_map_register_state'. +type ShowLispMapRegisterState struct{} + +func (m *ShowLispMapRegisterState) Reset() { *m = ShowLispMapRegisterState{} } +func (*ShowLispMapRegisterState) GetMessageName() string { return "show_lisp_map_register_state" } +func (*ShowLispMapRegisterState) GetCrcString() string { return "51077d14" } +func (*ShowLispMapRegisterState) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowLispMapRegisterState) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowLispMapRegisterState) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowLispMapRegisterState) Unmarshal(b []byte) error { + return nil +} + +// Reply for show_lisp_map_register_state +// - retval - return code +// +// ShowLispMapRegisterStateReply defines message 'show_lisp_map_register_state_reply'. +type ShowLispMapRegisterStateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IsEnabled bool `binapi:"bool,name=is_enabled" json:"is_enabled,omitempty"` +} + +func (m *ShowLispMapRegisterStateReply) Reset() { *m = ShowLispMapRegisterStateReply{} } +func (*ShowLispMapRegisterStateReply) GetMessageName() string { + return "show_lisp_map_register_state_reply" +} +func (*ShowLispMapRegisterStateReply) GetCrcString() string { return "e33a377b" } +func (*ShowLispMapRegisterStateReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowLispMapRegisterStateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.IsEnabled + return size +} +func (m *ShowLispMapRegisterStateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.IsEnabled) + return buf.Bytes(), nil +} +func (m *ShowLispMapRegisterStateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IsEnabled = buf.DecodeBool() + return nil +} + +// Request for LISP map-request mode +// ShowLispMapRequestMode defines message 'show_lisp_map_request_mode'. +type ShowLispMapRequestMode struct{} + +func (m *ShowLispMapRequestMode) Reset() { *m = ShowLispMapRequestMode{} } +func (*ShowLispMapRequestMode) GetMessageName() string { return "show_lisp_map_request_mode" } +func (*ShowLispMapRequestMode) GetCrcString() string { return "51077d14" } +func (*ShowLispMapRequestMode) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowLispMapRequestMode) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowLispMapRequestMode) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowLispMapRequestMode) Unmarshal(b []byte) error { + return nil +} + +// Reply for show_lisp_map_request_mode +// - retval - return code +// - is_src_dst - if non-zero source/destination else destination only +// +// ShowLispMapRequestModeReply defines message 'show_lisp_map_request_mode_reply'. +type ShowLispMapRequestModeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IsSrcDst bool `binapi:"bool,name=is_src_dst" json:"is_src_dst,omitempty"` +} + +func (m *ShowLispMapRequestModeReply) Reset() { *m = ShowLispMapRequestModeReply{} } +func (*ShowLispMapRequestModeReply) GetMessageName() string { + return "show_lisp_map_request_mode_reply" +} +func (*ShowLispMapRequestModeReply) GetCrcString() string { return "5b05038e" } +func (*ShowLispMapRequestModeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowLispMapRequestModeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.IsSrcDst + return size +} +func (m *ShowLispMapRequestModeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.IsSrcDst) + return buf.Bytes(), nil +} +func (m *ShowLispMapRequestModeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IsSrcDst = buf.DecodeBool() + return nil +} + +// Request for lisp pitr status +// ShowLispPitr defines message 'show_lisp_pitr'. +type ShowLispPitr struct{} + +func (m *ShowLispPitr) Reset() { *m = ShowLispPitr{} } +func (*ShowLispPitr) GetMessageName() string { return "show_lisp_pitr" } +func (*ShowLispPitr) GetCrcString() string { return "51077d14" } +func (*ShowLispPitr) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowLispPitr) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowLispPitr) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowLispPitr) Unmarshal(b []byte) error { + return nil +} + +// Status of lisp pitr, enable or disable +// - status - lisp pitr enable if non-zero, else disable +// - locator_set_name - name of the locator_set +// +// ShowLispPitrReply defines message 'show_lisp_pitr_reply'. +type ShowLispPitrReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IsEnabled bool `binapi:"bool,name=is_enabled" json:"is_enabled,omitempty"` + LocatorSetName string `binapi:"string[64],name=locator_set_name" json:"locator_set_name,omitempty"` +} + +func (m *ShowLispPitrReply) Reset() { *m = ShowLispPitrReply{} } +func (*ShowLispPitrReply) GetMessageName() string { return "show_lisp_pitr_reply" } +func (*ShowLispPitrReply) GetCrcString() string { return "27aa69b1" } +func (*ShowLispPitrReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowLispPitrReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.IsEnabled + size += 64 // m.LocatorSetName + return size +} +func (m *ShowLispPitrReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.IsEnabled) + buf.EncodeString(m.LocatorSetName, 64) + return buf.Bytes(), nil +} +func (m *ShowLispPitrReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IsEnabled = buf.DecodeBool() + m.LocatorSetName = buf.DecodeString(64) + return nil +} + +// Get state of LISP RLOC probing +// ShowLispRlocProbeState defines message 'show_lisp_rloc_probe_state'. +type ShowLispRlocProbeState struct{} + +func (m *ShowLispRlocProbeState) Reset() { *m = ShowLispRlocProbeState{} } +func (*ShowLispRlocProbeState) GetMessageName() string { return "show_lisp_rloc_probe_state" } +func (*ShowLispRlocProbeState) GetCrcString() string { return "51077d14" } +func (*ShowLispRlocProbeState) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowLispRlocProbeState) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowLispRlocProbeState) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowLispRlocProbeState) Unmarshal(b []byte) error { + return nil +} + +// Reply for show_lisp_rloc_probe_state +// - retval - return code +// - is_enabled - state of RLOC probing +// +// ShowLispRlocProbeStateReply defines message 'show_lisp_rloc_probe_state_reply'. +type ShowLispRlocProbeStateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IsEnabled bool `binapi:"bool,name=is_enabled" json:"is_enabled,omitempty"` +} + +func (m *ShowLispRlocProbeStateReply) Reset() { *m = ShowLispRlocProbeStateReply{} } +func (*ShowLispRlocProbeStateReply) GetMessageName() string { + return "show_lisp_rloc_probe_state_reply" +} +func (*ShowLispRlocProbeStateReply) GetCrcString() string { return "e33a377b" } +func (*ShowLispRlocProbeStateReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowLispRlocProbeStateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.IsEnabled + return size +} +func (m *ShowLispRlocProbeStateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.IsEnabled) + return buf.Bytes(), nil +} +func (m *ShowLispRlocProbeStateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IsEnabled = buf.DecodeBool() + return nil +} + +// Request for lisp-gpe protocol status +// ShowLispStatus defines message 'show_lisp_status'. +type ShowLispStatus struct{} + +func (m *ShowLispStatus) Reset() { *m = ShowLispStatus{} } +func (*ShowLispStatus) GetMessageName() string { return "show_lisp_status" } +func (*ShowLispStatus) GetCrcString() string { return "51077d14" } +func (*ShowLispStatus) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowLispStatus) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowLispStatus) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowLispStatus) Unmarshal(b []byte) error { + return nil +} + +// Status of lisp, enable or disable +// - feature_status - lisp enable if non-zero, else disable +// - gpe_status - lisp enable if non-zero, else disable +// +// ShowLispStatusReply defines message 'show_lisp_status_reply'. +type ShowLispStatusReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IsLispEnabled bool `binapi:"bool,name=is_lisp_enabled" json:"is_lisp_enabled,omitempty"` + IsGpeEnabled bool `binapi:"bool,name=is_gpe_enabled" json:"is_gpe_enabled,omitempty"` +} + +func (m *ShowLispStatusReply) Reset() { *m = ShowLispStatusReply{} } +func (*ShowLispStatusReply) GetMessageName() string { return "show_lisp_status_reply" } +func (*ShowLispStatusReply) GetCrcString() string { return "9e8f10c0" } +func (*ShowLispStatusReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowLispStatusReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.IsLispEnabled + size += 1 // m.IsGpeEnabled + return size +} +func (m *ShowLispStatusReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.IsLispEnabled) + buf.EncodeBool(m.IsGpeEnabled) + return buf.Bytes(), nil +} +func (m *ShowLispStatusReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IsLispEnabled = buf.DecodeBool() + m.IsGpeEnabled = buf.DecodeBool() + return nil +} + +// Request for LISP PETR status +// ShowLispUsePetr defines message 'show_lisp_use_petr'. +type ShowLispUsePetr struct{} + +func (m *ShowLispUsePetr) Reset() { *m = ShowLispUsePetr{} } +func (*ShowLispUsePetr) GetMessageName() string { return "show_lisp_use_petr" } +func (*ShowLispUsePetr) GetCrcString() string { return "51077d14" } +func (*ShowLispUsePetr) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowLispUsePetr) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowLispUsePetr) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowLispUsePetr) Unmarshal(b []byte) error { + return nil +} + +// LISP PETR status, enable or disable +// - status - LISP PETR enable if non-zero, else disable +// - address - PETR IP address +// +// ShowLispUsePetrReply defines message 'show_lisp_use_petr_reply'. +type ShowLispUsePetrReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IsPetrEnable bool `binapi:"bool,name=is_petr_enable" json:"is_petr_enable,omitempty"` + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` +} + +func (m *ShowLispUsePetrReply) Reset() { *m = ShowLispUsePetrReply{} } +func (*ShowLispUsePetrReply) GetMessageName() string { return "show_lisp_use_petr_reply" } +func (*ShowLispUsePetrReply) GetCrcString() string { return "22b9a4b0" } +func (*ShowLispUsePetrReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowLispUsePetrReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.IsPetrEnable + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + return size +} +func (m *ShowLispUsePetrReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.IsPetrEnable) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *ShowLispUsePetrReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IsPetrEnable = buf.DecodeBool() + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +func init() { file_lisp_binapi_init() } +func file_lisp_binapi_init() { + api.RegisterMessage((*LispAddDelAdjacency)(nil), "lisp_add_del_adjacency_2ce0e6f6") + api.RegisterMessage((*LispAddDelAdjacencyReply)(nil), "lisp_add_del_adjacency_reply_e8d4e804") + api.RegisterMessage((*LispAddDelLocalEid)(nil), "lisp_add_del_local_eid_4e5a83a2") + api.RegisterMessage((*LispAddDelLocalEidReply)(nil), "lisp_add_del_local_eid_reply_e8d4e804") + api.RegisterMessage((*LispAddDelLocator)(nil), "lisp_add_del_locator_af4d8f13") + api.RegisterMessage((*LispAddDelLocatorReply)(nil), "lisp_add_del_locator_reply_e8d4e804") + api.RegisterMessage((*LispAddDelLocatorSet)(nil), "lisp_add_del_locator_set_6fcd6471") + api.RegisterMessage((*LispAddDelLocatorSetReply)(nil), "lisp_add_del_locator_set_reply_b6666db4") + api.RegisterMessage((*LispAddDelMapRequestItrRlocs)(nil), "lisp_add_del_map_request_itr_rlocs_6be88e45") + api.RegisterMessage((*LispAddDelMapRequestItrRlocsReply)(nil), "lisp_add_del_map_request_itr_rlocs_reply_e8d4e804") + api.RegisterMessage((*LispAddDelMapResolver)(nil), "lisp_add_del_map_resolver_ce19e32d") + api.RegisterMessage((*LispAddDelMapResolverReply)(nil), "lisp_add_del_map_resolver_reply_e8d4e804") + api.RegisterMessage((*LispAddDelMapServer)(nil), "lisp_add_del_map_server_ce19e32d") + api.RegisterMessage((*LispAddDelMapServerReply)(nil), "lisp_add_del_map_server_reply_e8d4e804") + api.RegisterMessage((*LispAddDelRemoteMapping)(nil), "lisp_add_del_remote_mapping_6d5c789e") + api.RegisterMessage((*LispAddDelRemoteMappingReply)(nil), "lisp_add_del_remote_mapping_reply_e8d4e804") + api.RegisterMessage((*LispAdjacenciesGet)(nil), "lisp_adjacencies_get_8d1f2fe9") + api.RegisterMessage((*LispAdjacenciesGetReply)(nil), "lisp_adjacencies_get_reply_807257bf") + api.RegisterMessage((*LispEidTableAddDelMap)(nil), "lisp_eid_table_add_del_map_9481416b") + api.RegisterMessage((*LispEidTableAddDelMapReply)(nil), "lisp_eid_table_add_del_map_reply_e8d4e804") + api.RegisterMessage((*LispEidTableDetails)(nil), "lisp_eid_table_details_1c29f792") + api.RegisterMessage((*LispEidTableDump)(nil), "lisp_eid_table_dump_629468b5") + api.RegisterMessage((*LispEidTableMapDetails)(nil), "lisp_eid_table_map_details_0b6859e2") + api.RegisterMessage((*LispEidTableMapDump)(nil), "lisp_eid_table_map_dump_d6cf0c3d") + api.RegisterMessage((*LispEidTableVniDetails)(nil), "lisp_eid_table_vni_details_64abc01e") + api.RegisterMessage((*LispEidTableVniDump)(nil), "lisp_eid_table_vni_dump_51077d14") + api.RegisterMessage((*LispEnableDisable)(nil), "lisp_enable_disable_c264d7bf") + api.RegisterMessage((*LispEnableDisableReply)(nil), "lisp_enable_disable_reply_e8d4e804") + api.RegisterMessage((*LispGetMapRequestItrRlocs)(nil), "lisp_get_map_request_itr_rlocs_51077d14") + api.RegisterMessage((*LispGetMapRequestItrRlocsReply)(nil), "lisp_get_map_request_itr_rlocs_reply_76580f3a") + api.RegisterMessage((*LispLocatorDetails)(nil), "lisp_locator_details_2c620ffe") + api.RegisterMessage((*LispLocatorDump)(nil), "lisp_locator_dump_b954fad7") + api.RegisterMessage((*LispLocatorSetDetails)(nil), "lisp_locator_set_details_5b33a105") + api.RegisterMessage((*LispLocatorSetDump)(nil), "lisp_locator_set_dump_c2cb5922") + api.RegisterMessage((*LispMapRegisterEnableDisable)(nil), "lisp_map_register_enable_disable_c264d7bf") + api.RegisterMessage((*LispMapRegisterEnableDisableReply)(nil), "lisp_map_register_enable_disable_reply_e8d4e804") + api.RegisterMessage((*LispMapRequestMode)(nil), "lisp_map_request_mode_f43c26ae") + api.RegisterMessage((*LispMapRequestModeReply)(nil), "lisp_map_request_mode_reply_e8d4e804") + api.RegisterMessage((*LispMapResolverDetails)(nil), "lisp_map_resolver_details_3e78fc57") + api.RegisterMessage((*LispMapResolverDump)(nil), "lisp_map_resolver_dump_51077d14") + api.RegisterMessage((*LispMapServerDetails)(nil), "lisp_map_server_details_3e78fc57") + api.RegisterMessage((*LispMapServerDump)(nil), "lisp_map_server_dump_51077d14") + api.RegisterMessage((*LispPitrSetLocatorSet)(nil), "lisp_pitr_set_locator_set_486e2b76") + api.RegisterMessage((*LispPitrSetLocatorSetReply)(nil), "lisp_pitr_set_locator_set_reply_e8d4e804") + api.RegisterMessage((*LispRlocProbeEnableDisable)(nil), "lisp_rloc_probe_enable_disable_c264d7bf") + api.RegisterMessage((*LispRlocProbeEnableDisableReply)(nil), "lisp_rloc_probe_enable_disable_reply_e8d4e804") + api.RegisterMessage((*LispUsePetr)(nil), "lisp_use_petr_d87dbad9") + api.RegisterMessage((*LispUsePetrReply)(nil), "lisp_use_petr_reply_e8d4e804") + api.RegisterMessage((*ShowLispMapRegisterState)(nil), "show_lisp_map_register_state_51077d14") + api.RegisterMessage((*ShowLispMapRegisterStateReply)(nil), "show_lisp_map_register_state_reply_e33a377b") + api.RegisterMessage((*ShowLispMapRequestMode)(nil), "show_lisp_map_request_mode_51077d14") + api.RegisterMessage((*ShowLispMapRequestModeReply)(nil), "show_lisp_map_request_mode_reply_5b05038e") + api.RegisterMessage((*ShowLispPitr)(nil), "show_lisp_pitr_51077d14") + api.RegisterMessage((*ShowLispPitrReply)(nil), "show_lisp_pitr_reply_27aa69b1") + api.RegisterMessage((*ShowLispRlocProbeState)(nil), "show_lisp_rloc_probe_state_51077d14") + api.RegisterMessage((*ShowLispRlocProbeStateReply)(nil), "show_lisp_rloc_probe_state_reply_e33a377b") + api.RegisterMessage((*ShowLispStatus)(nil), "show_lisp_status_51077d14") + api.RegisterMessage((*ShowLispStatusReply)(nil), "show_lisp_status_reply_9e8f10c0") + api.RegisterMessage((*ShowLispUsePetr)(nil), "show_lisp_use_petr_51077d14") + api.RegisterMessage((*ShowLispUsePetrReply)(nil), "show_lisp_use_petr_reply_22b9a4b0") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*LispAddDelAdjacency)(nil), + (*LispAddDelAdjacencyReply)(nil), + (*LispAddDelLocalEid)(nil), + (*LispAddDelLocalEidReply)(nil), + (*LispAddDelLocator)(nil), + (*LispAddDelLocatorReply)(nil), + (*LispAddDelLocatorSet)(nil), + (*LispAddDelLocatorSetReply)(nil), + (*LispAddDelMapRequestItrRlocs)(nil), + (*LispAddDelMapRequestItrRlocsReply)(nil), + (*LispAddDelMapResolver)(nil), + (*LispAddDelMapResolverReply)(nil), + (*LispAddDelMapServer)(nil), + (*LispAddDelMapServerReply)(nil), + (*LispAddDelRemoteMapping)(nil), + (*LispAddDelRemoteMappingReply)(nil), + (*LispAdjacenciesGet)(nil), + (*LispAdjacenciesGetReply)(nil), + (*LispEidTableAddDelMap)(nil), + (*LispEidTableAddDelMapReply)(nil), + (*LispEidTableDetails)(nil), + (*LispEidTableDump)(nil), + (*LispEidTableMapDetails)(nil), + (*LispEidTableMapDump)(nil), + (*LispEidTableVniDetails)(nil), + (*LispEidTableVniDump)(nil), + (*LispEnableDisable)(nil), + (*LispEnableDisableReply)(nil), + (*LispGetMapRequestItrRlocs)(nil), + (*LispGetMapRequestItrRlocsReply)(nil), + (*LispLocatorDetails)(nil), + (*LispLocatorDump)(nil), + (*LispLocatorSetDetails)(nil), + (*LispLocatorSetDump)(nil), + (*LispMapRegisterEnableDisable)(nil), + (*LispMapRegisterEnableDisableReply)(nil), + (*LispMapRequestMode)(nil), + (*LispMapRequestModeReply)(nil), + (*LispMapResolverDetails)(nil), + (*LispMapResolverDump)(nil), + (*LispMapServerDetails)(nil), + (*LispMapServerDump)(nil), + (*LispPitrSetLocatorSet)(nil), + (*LispPitrSetLocatorSetReply)(nil), + (*LispRlocProbeEnableDisable)(nil), + (*LispRlocProbeEnableDisableReply)(nil), + (*LispUsePetr)(nil), + (*LispUsePetrReply)(nil), + (*ShowLispMapRegisterState)(nil), + (*ShowLispMapRegisterStateReply)(nil), + (*ShowLispMapRequestMode)(nil), + (*ShowLispMapRequestModeReply)(nil), + (*ShowLispPitr)(nil), + (*ShowLispPitrReply)(nil), + (*ShowLispRlocProbeState)(nil), + (*ShowLispRlocProbeStateReply)(nil), + (*ShowLispStatus)(nil), + (*ShowLispStatusReply)(nil), + (*ShowLispUsePetr)(nil), + (*ShowLispUsePetrReply)(nil), + } +} diff --git a/binapi/lisp/lisp_rpc.ba.go b/binapi/lisp/lisp_rpc.ba.go new file mode 100644 index 00000000..d62d27d7 --- /dev/null +++ b/binapi/lisp/lisp_rpc.ba.go @@ -0,0 +1,562 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package lisp + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service lisp. +type RPCService interface { + LispAddDelAdjacency(ctx context.Context, in *LispAddDelAdjacency) (*LispAddDelAdjacencyReply, error) + LispAddDelLocalEid(ctx context.Context, in *LispAddDelLocalEid) (*LispAddDelLocalEidReply, error) + LispAddDelLocator(ctx context.Context, in *LispAddDelLocator) (*LispAddDelLocatorReply, error) + LispAddDelLocatorSet(ctx context.Context, in *LispAddDelLocatorSet) (*LispAddDelLocatorSetReply, error) + LispAddDelMapRequestItrRlocs(ctx context.Context, in *LispAddDelMapRequestItrRlocs) (*LispAddDelMapRequestItrRlocsReply, error) + LispAddDelMapResolver(ctx context.Context, in *LispAddDelMapResolver) (*LispAddDelMapResolverReply, error) + LispAddDelMapServer(ctx context.Context, in *LispAddDelMapServer) (*LispAddDelMapServerReply, error) + LispAddDelRemoteMapping(ctx context.Context, in *LispAddDelRemoteMapping) (*LispAddDelRemoteMappingReply, error) + LispAdjacenciesGet(ctx context.Context, in *LispAdjacenciesGet) (*LispAdjacenciesGetReply, error) + LispEidTableAddDelMap(ctx context.Context, in *LispEidTableAddDelMap) (*LispEidTableAddDelMapReply, error) + LispEidTableDump(ctx context.Context, in *LispEidTableDump) (RPCService_LispEidTableDumpClient, error) + LispEidTableMapDump(ctx context.Context, in *LispEidTableMapDump) (RPCService_LispEidTableMapDumpClient, error) + LispEidTableVniDump(ctx context.Context, in *LispEidTableVniDump) (RPCService_LispEidTableVniDumpClient, error) + LispEnableDisable(ctx context.Context, in *LispEnableDisable) (*LispEnableDisableReply, error) + LispGetMapRequestItrRlocs(ctx context.Context, in *LispGetMapRequestItrRlocs) (*LispGetMapRequestItrRlocsReply, error) + LispLocatorDump(ctx context.Context, in *LispLocatorDump) (RPCService_LispLocatorDumpClient, error) + LispLocatorSetDump(ctx context.Context, in *LispLocatorSetDump) (RPCService_LispLocatorSetDumpClient, error) + LispMapRegisterEnableDisable(ctx context.Context, in *LispMapRegisterEnableDisable) (*LispMapRegisterEnableDisableReply, error) + LispMapRequestMode(ctx context.Context, in *LispMapRequestMode) (*LispMapRequestModeReply, error) + LispMapResolverDump(ctx context.Context, in *LispMapResolverDump) (RPCService_LispMapResolverDumpClient, error) + LispMapServerDump(ctx context.Context, in *LispMapServerDump) (RPCService_LispMapServerDumpClient, error) + LispPitrSetLocatorSet(ctx context.Context, in *LispPitrSetLocatorSet) (*LispPitrSetLocatorSetReply, error) + LispRlocProbeEnableDisable(ctx context.Context, in *LispRlocProbeEnableDisable) (*LispRlocProbeEnableDisableReply, error) + LispUsePetr(ctx context.Context, in *LispUsePetr) (*LispUsePetrReply, error) + ShowLispMapRegisterState(ctx context.Context, in *ShowLispMapRegisterState) (*ShowLispMapRegisterStateReply, error) + ShowLispMapRequestMode(ctx context.Context, in *ShowLispMapRequestMode) (*ShowLispMapRequestModeReply, error) + ShowLispPitr(ctx context.Context, in *ShowLispPitr) (*ShowLispPitrReply, error) + ShowLispRlocProbeState(ctx context.Context, in *ShowLispRlocProbeState) (*ShowLispRlocProbeStateReply, error) + ShowLispStatus(ctx context.Context, in *ShowLispStatus) (*ShowLispStatusReply, error) + ShowLispUsePetr(ctx context.Context, in *ShowLispUsePetr) (*ShowLispUsePetrReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) LispAddDelAdjacency(ctx context.Context, in *LispAddDelAdjacency) (*LispAddDelAdjacencyReply, error) { + out := new(LispAddDelAdjacencyReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispAddDelLocalEid(ctx context.Context, in *LispAddDelLocalEid) (*LispAddDelLocalEidReply, error) { + out := new(LispAddDelLocalEidReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispAddDelLocator(ctx context.Context, in *LispAddDelLocator) (*LispAddDelLocatorReply, error) { + out := new(LispAddDelLocatorReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispAddDelLocatorSet(ctx context.Context, in *LispAddDelLocatorSet) (*LispAddDelLocatorSetReply, error) { + out := new(LispAddDelLocatorSetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispAddDelMapRequestItrRlocs(ctx context.Context, in *LispAddDelMapRequestItrRlocs) (*LispAddDelMapRequestItrRlocsReply, error) { + out := new(LispAddDelMapRequestItrRlocsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispAddDelMapResolver(ctx context.Context, in *LispAddDelMapResolver) (*LispAddDelMapResolverReply, error) { + out := new(LispAddDelMapResolverReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispAddDelMapServer(ctx context.Context, in *LispAddDelMapServer) (*LispAddDelMapServerReply, error) { + out := new(LispAddDelMapServerReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispAddDelRemoteMapping(ctx context.Context, in *LispAddDelRemoteMapping) (*LispAddDelRemoteMappingReply, error) { + out := new(LispAddDelRemoteMappingReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispAdjacenciesGet(ctx context.Context, in *LispAdjacenciesGet) (*LispAdjacenciesGetReply, error) { + out := new(LispAdjacenciesGetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispEidTableAddDelMap(ctx context.Context, in *LispEidTableAddDelMap) (*LispEidTableAddDelMapReply, error) { + out := new(LispEidTableAddDelMapReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispEidTableDump(ctx context.Context, in *LispEidTableDump) (RPCService_LispEidTableDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_LispEidTableDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_LispEidTableDumpClient interface { + Recv() (*LispEidTableDetails, error) + api.Stream +} + +type serviceClient_LispEidTableDumpClient struct { + api.Stream +} + +func (c *serviceClient_LispEidTableDumpClient) Recv() (*LispEidTableDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *LispEidTableDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) LispEidTableMapDump(ctx context.Context, in *LispEidTableMapDump) (RPCService_LispEidTableMapDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_LispEidTableMapDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_LispEidTableMapDumpClient interface { + Recv() (*LispEidTableMapDetails, error) + api.Stream +} + +type serviceClient_LispEidTableMapDumpClient struct { + api.Stream +} + +func (c *serviceClient_LispEidTableMapDumpClient) Recv() (*LispEidTableMapDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *LispEidTableMapDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) LispEidTableVniDump(ctx context.Context, in *LispEidTableVniDump) (RPCService_LispEidTableVniDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_LispEidTableVniDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_LispEidTableVniDumpClient interface { + Recv() (*LispEidTableVniDetails, error) + api.Stream +} + +type serviceClient_LispEidTableVniDumpClient struct { + api.Stream +} + +func (c *serviceClient_LispEidTableVniDumpClient) Recv() (*LispEidTableVniDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *LispEidTableVniDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) LispEnableDisable(ctx context.Context, in *LispEnableDisable) (*LispEnableDisableReply, error) { + out := new(LispEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispGetMapRequestItrRlocs(ctx context.Context, in *LispGetMapRequestItrRlocs) (*LispGetMapRequestItrRlocsReply, error) { + out := new(LispGetMapRequestItrRlocsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispLocatorDump(ctx context.Context, in *LispLocatorDump) (RPCService_LispLocatorDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_LispLocatorDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_LispLocatorDumpClient interface { + Recv() (*LispLocatorDetails, error) + api.Stream +} + +type serviceClient_LispLocatorDumpClient struct { + api.Stream +} + +func (c *serviceClient_LispLocatorDumpClient) Recv() (*LispLocatorDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *LispLocatorDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) LispLocatorSetDump(ctx context.Context, in *LispLocatorSetDump) (RPCService_LispLocatorSetDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_LispLocatorSetDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_LispLocatorSetDumpClient interface { + Recv() (*LispLocatorSetDetails, error) + api.Stream +} + +type serviceClient_LispLocatorSetDumpClient struct { + api.Stream +} + +func (c *serviceClient_LispLocatorSetDumpClient) Recv() (*LispLocatorSetDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *LispLocatorSetDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) LispMapRegisterEnableDisable(ctx context.Context, in *LispMapRegisterEnableDisable) (*LispMapRegisterEnableDisableReply, error) { + out := new(LispMapRegisterEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispMapRequestMode(ctx context.Context, in *LispMapRequestMode) (*LispMapRequestModeReply, error) { + out := new(LispMapRequestModeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispMapResolverDump(ctx context.Context, in *LispMapResolverDump) (RPCService_LispMapResolverDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_LispMapResolverDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_LispMapResolverDumpClient interface { + Recv() (*LispMapResolverDetails, error) + api.Stream +} + +type serviceClient_LispMapResolverDumpClient struct { + api.Stream +} + +func (c *serviceClient_LispMapResolverDumpClient) Recv() (*LispMapResolverDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *LispMapResolverDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) LispMapServerDump(ctx context.Context, in *LispMapServerDump) (RPCService_LispMapServerDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_LispMapServerDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_LispMapServerDumpClient interface { + Recv() (*LispMapServerDetails, error) + api.Stream +} + +type serviceClient_LispMapServerDumpClient struct { + api.Stream +} + +func (c *serviceClient_LispMapServerDumpClient) Recv() (*LispMapServerDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *LispMapServerDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) LispPitrSetLocatorSet(ctx context.Context, in *LispPitrSetLocatorSet) (*LispPitrSetLocatorSetReply, error) { + out := new(LispPitrSetLocatorSetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispRlocProbeEnableDisable(ctx context.Context, in *LispRlocProbeEnableDisable) (*LispRlocProbeEnableDisableReply, error) { + out := new(LispRlocProbeEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) LispUsePetr(ctx context.Context, in *LispUsePetr) (*LispUsePetrReply, error) { + out := new(LispUsePetrReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowLispMapRegisterState(ctx context.Context, in *ShowLispMapRegisterState) (*ShowLispMapRegisterStateReply, error) { + out := new(ShowLispMapRegisterStateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowLispMapRequestMode(ctx context.Context, in *ShowLispMapRequestMode) (*ShowLispMapRequestModeReply, error) { + out := new(ShowLispMapRequestModeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowLispPitr(ctx context.Context, in *ShowLispPitr) (*ShowLispPitrReply, error) { + out := new(ShowLispPitrReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowLispRlocProbeState(ctx context.Context, in *ShowLispRlocProbeState) (*ShowLispRlocProbeStateReply, error) { + out := new(ShowLispRlocProbeStateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowLispStatus(ctx context.Context, in *ShowLispStatus) (*ShowLispStatusReply, error) { + out := new(ShowLispStatusReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowLispUsePetr(ctx context.Context, in *ShowLispUsePetr) (*ShowLispUsePetrReply, error) { + out := new(ShowLispUsePetrReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/lisp_gpe/lisp_gpe.ba.go b/binapi/lisp_gpe/lisp_gpe.ba.go new file mode 100644 index 00000000..edb2696b --- /dev/null +++ b/binapi/lisp_gpe/lisp_gpe.ba.go @@ -0,0 +1,999 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/lisp_gpe.api.json + +// Package lisp_gpe contains generated bindings for API file lisp_gpe.api. +// +// Contents: +// - 3 structs +// - 20 messages +package lisp_gpe + +import ( + api "github.com/alkiranet/govpp/api" + _ "github.com/alkiranet/govpp/binapi/ethernet_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + lisp_types "github.com/alkiranet/govpp/binapi/lisp_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "lisp_gpe" + APIVersion = "2.0.0" + VersionCrc = 0x92611b0 +) + +// GpeFwdEntry defines type 'gpe_fwd_entry'. +type GpeFwdEntry struct { + FwdEntryIndex uint32 `binapi:"u32,name=fwd_entry_index" json:"fwd_entry_index,omitempty"` + DpTable uint32 `binapi:"u32,name=dp_table" json:"dp_table,omitempty"` + Leid lisp_types.Eid `binapi:"eid,name=leid" json:"leid,omitempty"` + Reid lisp_types.Eid `binapi:"eid,name=reid" json:"reid,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + Action uint8 `binapi:"u8,name=action" json:"action,omitempty"` +} + +// GpeLocator defines type 'gpe_locator'. +type GpeLocator struct { + Weight uint8 `binapi:"u8,name=weight" json:"weight,omitempty"` + Addr ip_types.Address `binapi:"address,name=addr" json:"addr,omitempty"` +} + +// GpeNativeFwdRpath defines type 'gpe_native_fwd_rpath'. +type GpeNativeFwdRpath struct { + FibIndex uint32 `binapi:"u32,name=fib_index" json:"fib_index,omitempty"` + NhSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=nh_sw_if_index" json:"nh_sw_if_index,omitempty"` + NhAddr ip_types.Address `binapi:"address,name=nh_addr" json:"nh_addr,omitempty"` +} + +// add or delete GPE tunnel +// - is_add - add address if non-zero, else delete +// - rmt_eid - remote eid +// - lcl_eid - local eid +// - vni - virtual network identifier +// - dp_table - vrf/bridge domain id +// - action - negative action when 0 locators configured +// - loc_num - number of locators +// - locs - array of remote locators +// +// GpeAddDelFwdEntry defines message 'gpe_add_del_fwd_entry'. +type GpeAddDelFwdEntry struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + RmtEid lisp_types.Eid `binapi:"eid,name=rmt_eid" json:"rmt_eid,omitempty"` + LclEid lisp_types.Eid `binapi:"eid,name=lcl_eid" json:"lcl_eid,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + DpTable uint32 `binapi:"u32,name=dp_table" json:"dp_table,omitempty"` + Action uint8 `binapi:"u8,name=action" json:"action,omitempty"` + LocNum uint32 `binapi:"u32,name=loc_num" json:"-"` + Locs []GpeLocator `binapi:"gpe_locator[loc_num],name=locs" json:"locs,omitempty"` +} + +func (m *GpeAddDelFwdEntry) Reset() { *m = GpeAddDelFwdEntry{} } +func (*GpeAddDelFwdEntry) GetMessageName() string { return "gpe_add_del_fwd_entry" } +func (*GpeAddDelFwdEntry) GetCrcString() string { return "f0847644" } +func (*GpeAddDelFwdEntry) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *GpeAddDelFwdEntry) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.RmtEid.Type + size += 1 * 18 // m.RmtEid.Address + size += 1 // m.LclEid.Type + size += 1 * 18 // m.LclEid.Address + size += 4 // m.Vni + size += 4 // m.DpTable + size += 1 // m.Action + size += 4 // m.LocNum + for j1 := 0; j1 < len(m.Locs); j1++ { + var s1 GpeLocator + _ = s1 + if j1 < len(m.Locs) { + s1 = m.Locs[j1] + } + size += 1 // s1.Weight + size += 1 // s1.Addr.Af + size += 1 * 16 // s1.Addr.Un + } + return size +} +func (m *GpeAddDelFwdEntry) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint8(uint8(m.RmtEid.Type)) + buf.EncodeBytes(m.RmtEid.Address.XXX_UnionData[:], 18) + buf.EncodeUint8(uint8(m.LclEid.Type)) + buf.EncodeBytes(m.LclEid.Address.XXX_UnionData[:], 18) + buf.EncodeUint32(m.Vni) + buf.EncodeUint32(m.DpTable) + buf.EncodeUint8(m.Action) + buf.EncodeUint32(uint32(len(m.Locs))) + for j0 := 0; j0 < len(m.Locs); j0++ { + var v0 GpeLocator // Locs + if j0 < len(m.Locs) { + v0 = m.Locs[j0] + } + buf.EncodeUint8(v0.Weight) + buf.EncodeUint8(uint8(v0.Addr.Af)) + buf.EncodeBytes(v0.Addr.Un.XXX_UnionData[:], 16) + } + return buf.Bytes(), nil +} +func (m *GpeAddDelFwdEntry) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.RmtEid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.RmtEid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.LclEid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.LclEid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.Vni = buf.DecodeUint32() + m.DpTable = buf.DecodeUint32() + m.Action = buf.DecodeUint8() + m.LocNum = buf.DecodeUint32() + m.Locs = make([]GpeLocator, m.LocNum) + for j0 := 0; j0 < len(m.Locs); j0++ { + m.Locs[j0].Weight = buf.DecodeUint8() + m.Locs[j0].Addr.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Locs[j0].Addr.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + } + return nil +} + +// GpeAddDelFwdEntryReply defines message 'gpe_add_del_fwd_entry_reply'. +type GpeAddDelFwdEntryReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + FwdEntryIndex uint32 `binapi:"u32,name=fwd_entry_index" json:"fwd_entry_index,omitempty"` +} + +func (m *GpeAddDelFwdEntryReply) Reset() { *m = GpeAddDelFwdEntryReply{} } +func (*GpeAddDelFwdEntryReply) GetMessageName() string { return "gpe_add_del_fwd_entry_reply" } +func (*GpeAddDelFwdEntryReply) GetCrcString() string { return "efe5f176" } +func (*GpeAddDelFwdEntryReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *GpeAddDelFwdEntryReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.FwdEntryIndex + return size +} +func (m *GpeAddDelFwdEntryReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.FwdEntryIndex) + return buf.Bytes(), nil +} +func (m *GpeAddDelFwdEntryReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.FwdEntryIndex = buf.DecodeUint32() + return nil +} + +// add or delete gpe_iface +// - is_add - add address if non-zero, else delete +// +// GpeAddDelIface defines message 'gpe_add_del_iface'. +type GpeAddDelIface struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + IsL2 bool `binapi:"bool,name=is_l2" json:"is_l2,omitempty"` + DpTable uint32 `binapi:"u32,name=dp_table" json:"dp_table,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` +} + +func (m *GpeAddDelIface) Reset() { *m = GpeAddDelIface{} } +func (*GpeAddDelIface) GetMessageName() string { return "gpe_add_del_iface" } +func (*GpeAddDelIface) GetCrcString() string { return "3ccff273" } +func (*GpeAddDelIface) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *GpeAddDelIface) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.IsL2 + size += 4 // m.DpTable + size += 4 // m.Vni + return size +} +func (m *GpeAddDelIface) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeBool(m.IsL2) + buf.EncodeUint32(m.DpTable) + buf.EncodeUint32(m.Vni) + return buf.Bytes(), nil +} +func (m *GpeAddDelIface) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.IsL2 = buf.DecodeBool() + m.DpTable = buf.DecodeUint32() + m.Vni = buf.DecodeUint32() + return nil +} + +// GpeAddDelIfaceReply defines message 'gpe_add_del_iface_reply'. +type GpeAddDelIfaceReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *GpeAddDelIfaceReply) Reset() { *m = GpeAddDelIfaceReply{} } +func (*GpeAddDelIfaceReply) GetMessageName() string { return "gpe_add_del_iface_reply" } +func (*GpeAddDelIfaceReply) GetCrcString() string { return "e8d4e804" } +func (*GpeAddDelIfaceReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *GpeAddDelIfaceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *GpeAddDelIfaceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *GpeAddDelIfaceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add native fwd rpath +// - retval - return code +// - is_add - flag to indicate add or del +// - table_id - table id for route path +// - nh_sw_if_index - next-hop sw_if_index (~0 if not set) +// - is_ip4 - flag to indicate if nh is ip4 +// - nh_addr - next hop ip address +// +// GpeAddDelNativeFwdRpath defines message 'gpe_add_del_native_fwd_rpath'. +type GpeAddDelNativeFwdRpath struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + NhSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=nh_sw_if_index" json:"nh_sw_if_index,omitempty"` + NhAddr ip_types.Address `binapi:"address,name=nh_addr" json:"nh_addr,omitempty"` +} + +func (m *GpeAddDelNativeFwdRpath) Reset() { *m = GpeAddDelNativeFwdRpath{} } +func (*GpeAddDelNativeFwdRpath) GetMessageName() string { return "gpe_add_del_native_fwd_rpath" } +func (*GpeAddDelNativeFwdRpath) GetCrcString() string { return "43fc8b54" } +func (*GpeAddDelNativeFwdRpath) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *GpeAddDelNativeFwdRpath) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.TableID + size += 4 // m.NhSwIfIndex + size += 1 // m.NhAddr.Af + size += 1 * 16 // m.NhAddr.Un + return size +} +func (m *GpeAddDelNativeFwdRpath) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.TableID) + buf.EncodeUint32(uint32(m.NhSwIfIndex)) + buf.EncodeUint8(uint8(m.NhAddr.Af)) + buf.EncodeBytes(m.NhAddr.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *GpeAddDelNativeFwdRpath) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.TableID = buf.DecodeUint32() + m.NhSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.NhAddr.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.NhAddr.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// GpeAddDelNativeFwdRpathReply defines message 'gpe_add_del_native_fwd_rpath_reply'. +type GpeAddDelNativeFwdRpathReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *GpeAddDelNativeFwdRpathReply) Reset() { *m = GpeAddDelNativeFwdRpathReply{} } +func (*GpeAddDelNativeFwdRpathReply) GetMessageName() string { + return "gpe_add_del_native_fwd_rpath_reply" +} +func (*GpeAddDelNativeFwdRpathReply) GetCrcString() string { return "e8d4e804" } +func (*GpeAddDelNativeFwdRpathReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *GpeAddDelNativeFwdRpathReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *GpeAddDelNativeFwdRpathReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *GpeAddDelNativeFwdRpathReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// enable or disable gpe protocol +// - is_enable [default=true] - enable protocol if non-zero, else disable +// +// GpeEnableDisable defines message 'gpe_enable_disable'. +type GpeEnableDisable struct { + IsEnable bool `binapi:"bool,name=is_enable,default=true" json:"is_enable,omitempty"` +} + +func (m *GpeEnableDisable) Reset() { *m = GpeEnableDisable{} } +func (*GpeEnableDisable) GetMessageName() string { return "gpe_enable_disable" } +func (*GpeEnableDisable) GetCrcString() string { return "c264d7bf" } +func (*GpeEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *GpeEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsEnable + return size +} +func (m *GpeEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *GpeEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsEnable = buf.DecodeBool() + return nil +} + +// GpeEnableDisableReply defines message 'gpe_enable_disable_reply'. +type GpeEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *GpeEnableDisableReply) Reset() { *m = GpeEnableDisableReply{} } +func (*GpeEnableDisableReply) GetMessageName() string { return "gpe_enable_disable_reply" } +func (*GpeEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*GpeEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *GpeEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *GpeEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *GpeEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// GpeFwdEntriesGet defines message 'gpe_fwd_entries_get'. +type GpeFwdEntriesGet struct { + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` +} + +func (m *GpeFwdEntriesGet) Reset() { *m = GpeFwdEntriesGet{} } +func (*GpeFwdEntriesGet) GetMessageName() string { return "gpe_fwd_entries_get" } +func (*GpeFwdEntriesGet) GetCrcString() string { return "8d1f2fe9" } +func (*GpeFwdEntriesGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *GpeFwdEntriesGet) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Vni + return size +} +func (m *GpeFwdEntriesGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Vni) + return buf.Bytes(), nil +} +func (m *GpeFwdEntriesGet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Vni = buf.DecodeUint32() + return nil +} + +// GpeFwdEntriesGetReply defines message 'gpe_fwd_entries_get_reply'. +type GpeFwdEntriesGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + Entries []GpeFwdEntry `binapi:"gpe_fwd_entry[count],name=entries" json:"entries,omitempty"` +} + +func (m *GpeFwdEntriesGetReply) Reset() { *m = GpeFwdEntriesGetReply{} } +func (*GpeFwdEntriesGetReply) GetMessageName() string { return "gpe_fwd_entries_get_reply" } +func (*GpeFwdEntriesGetReply) GetCrcString() string { return "c4844876" } +func (*GpeFwdEntriesGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *GpeFwdEntriesGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + for j1 := 0; j1 < len(m.Entries); j1++ { + var s1 GpeFwdEntry + _ = s1 + if j1 < len(m.Entries) { + s1 = m.Entries[j1] + } + size += 4 // s1.FwdEntryIndex + size += 4 // s1.DpTable + size += 1 // s1.Leid.Type + size += 1 * 18 // s1.Leid.Address + size += 1 // s1.Reid.Type + size += 1 * 18 // s1.Reid.Address + size += 4 // s1.Vni + size += 1 // s1.Action + } + return size +} +func (m *GpeFwdEntriesGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.Entries))) + for j0 := 0; j0 < len(m.Entries); j0++ { + var v0 GpeFwdEntry // Entries + if j0 < len(m.Entries) { + v0 = m.Entries[j0] + } + buf.EncodeUint32(v0.FwdEntryIndex) + buf.EncodeUint32(v0.DpTable) + buf.EncodeUint8(uint8(v0.Leid.Type)) + buf.EncodeBytes(v0.Leid.Address.XXX_UnionData[:], 18) + buf.EncodeUint8(uint8(v0.Reid.Type)) + buf.EncodeBytes(v0.Reid.Address.XXX_UnionData[:], 18) + buf.EncodeUint32(v0.Vni) + buf.EncodeUint8(v0.Action) + } + return buf.Bytes(), nil +} +func (m *GpeFwdEntriesGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.Entries = make([]GpeFwdEntry, m.Count) + for j0 := 0; j0 < len(m.Entries); j0++ { + m.Entries[j0].FwdEntryIndex = buf.DecodeUint32() + m.Entries[j0].DpTable = buf.DecodeUint32() + m.Entries[j0].Leid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Entries[j0].Leid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.Entries[j0].Reid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Entries[j0].Reid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.Entries[j0].Vni = buf.DecodeUint32() + m.Entries[j0].Action = buf.DecodeUint8() + } + return nil +} + +// GpeFwdEntryPathDetails defines message 'gpe_fwd_entry_path_details'. +type GpeFwdEntryPathDetails struct { + LclLoc GpeLocator `binapi:"gpe_locator,name=lcl_loc" json:"lcl_loc,omitempty"` + RmtLoc GpeLocator `binapi:"gpe_locator,name=rmt_loc" json:"rmt_loc,omitempty"` +} + +func (m *GpeFwdEntryPathDetails) Reset() { *m = GpeFwdEntryPathDetails{} } +func (*GpeFwdEntryPathDetails) GetMessageName() string { return "gpe_fwd_entry_path_details" } +func (*GpeFwdEntryPathDetails) GetCrcString() string { return "483df51a" } +func (*GpeFwdEntryPathDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *GpeFwdEntryPathDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.LclLoc.Weight + size += 1 // m.LclLoc.Addr.Af + size += 1 * 16 // m.LclLoc.Addr.Un + size += 1 // m.RmtLoc.Weight + size += 1 // m.RmtLoc.Addr.Af + size += 1 * 16 // m.RmtLoc.Addr.Un + return size +} +func (m *GpeFwdEntryPathDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.LclLoc.Weight) + buf.EncodeUint8(uint8(m.LclLoc.Addr.Af)) + buf.EncodeBytes(m.LclLoc.Addr.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.RmtLoc.Weight) + buf.EncodeUint8(uint8(m.RmtLoc.Addr.Af)) + buf.EncodeBytes(m.RmtLoc.Addr.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *GpeFwdEntryPathDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.LclLoc.Weight = buf.DecodeUint8() + m.LclLoc.Addr.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.LclLoc.Addr.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.RmtLoc.Weight = buf.DecodeUint8() + m.RmtLoc.Addr.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.RmtLoc.Addr.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// GpeFwdEntryPathDump defines message 'gpe_fwd_entry_path_dump'. +type GpeFwdEntryPathDump struct { + FwdEntryIndex uint32 `binapi:"u32,name=fwd_entry_index" json:"fwd_entry_index,omitempty"` +} + +func (m *GpeFwdEntryPathDump) Reset() { *m = GpeFwdEntryPathDump{} } +func (*GpeFwdEntryPathDump) GetMessageName() string { return "gpe_fwd_entry_path_dump" } +func (*GpeFwdEntryPathDump) GetCrcString() string { return "39bce980" } +func (*GpeFwdEntryPathDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *GpeFwdEntryPathDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.FwdEntryIndex + return size +} +func (m *GpeFwdEntryPathDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.FwdEntryIndex) + return buf.Bytes(), nil +} +func (m *GpeFwdEntryPathDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.FwdEntryIndex = buf.DecodeUint32() + return nil +} + +// GpeFwdEntryVnisGet defines message 'gpe_fwd_entry_vnis_get'. +type GpeFwdEntryVnisGet struct{} + +func (m *GpeFwdEntryVnisGet) Reset() { *m = GpeFwdEntryVnisGet{} } +func (*GpeFwdEntryVnisGet) GetMessageName() string { return "gpe_fwd_entry_vnis_get" } +func (*GpeFwdEntryVnisGet) GetCrcString() string { return "51077d14" } +func (*GpeFwdEntryVnisGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *GpeFwdEntryVnisGet) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *GpeFwdEntryVnisGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *GpeFwdEntryVnisGet) Unmarshal(b []byte) error { + return nil +} + +// GpeFwdEntryVnisGetReply defines message 'gpe_fwd_entry_vnis_get_reply'. +type GpeFwdEntryVnisGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + Vnis []uint32 `binapi:"u32[count],name=vnis" json:"vnis,omitempty"` +} + +func (m *GpeFwdEntryVnisGetReply) Reset() { *m = GpeFwdEntryVnisGetReply{} } +func (*GpeFwdEntryVnisGetReply) GetMessageName() string { return "gpe_fwd_entry_vnis_get_reply" } +func (*GpeFwdEntryVnisGetReply) GetCrcString() string { return "aa70da20" } +func (*GpeFwdEntryVnisGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *GpeFwdEntryVnisGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + size += 4 * len(m.Vnis) // m.Vnis + return size +} +func (m *GpeFwdEntryVnisGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.Vnis))) + for i := 0; i < len(m.Vnis); i++ { + var x uint32 + if i < len(m.Vnis) { + x = uint32(m.Vnis[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *GpeFwdEntryVnisGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.Vnis = make([]uint32, m.Count) + for i := 0; i < len(m.Vnis); i++ { + m.Vnis[i] = buf.DecodeUint32() + } + return nil +} + +// get GPE encapsulation mode +// - mode - LISP (value 0) or VXLAN (value 1) +// +// GpeGetEncapMode defines message 'gpe_get_encap_mode'. +type GpeGetEncapMode struct{} + +func (m *GpeGetEncapMode) Reset() { *m = GpeGetEncapMode{} } +func (*GpeGetEncapMode) GetMessageName() string { return "gpe_get_encap_mode" } +func (*GpeGetEncapMode) GetCrcString() string { return "51077d14" } +func (*GpeGetEncapMode) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *GpeGetEncapMode) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *GpeGetEncapMode) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *GpeGetEncapMode) Unmarshal(b []byte) error { + return nil +} + +// Reply for set_encap_mode +// - retval - return code +// - encap_mode - GPE encapsulation mode +// +// GpeGetEncapModeReply defines message 'gpe_get_encap_mode_reply'. +type GpeGetEncapModeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + EncapMode uint8 `binapi:"u8,name=encap_mode" json:"encap_mode,omitempty"` +} + +func (m *GpeGetEncapModeReply) Reset() { *m = GpeGetEncapModeReply{} } +func (*GpeGetEncapModeReply) GetMessageName() string { return "gpe_get_encap_mode_reply" } +func (*GpeGetEncapModeReply) GetCrcString() string { return "36e3f7ca" } +func (*GpeGetEncapModeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *GpeGetEncapModeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.EncapMode + return size +} +func (m *GpeGetEncapModeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint8(m.EncapMode) + return buf.Bytes(), nil +} +func (m *GpeGetEncapModeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.EncapMode = buf.DecodeUint8() + return nil +} + +// get GPE native fwd rpath +// GpeNativeFwdRpathsGet defines message 'gpe_native_fwd_rpaths_get'. +type GpeNativeFwdRpathsGet struct { + IsIP4 bool `binapi:"bool,name=is_ip4" json:"is_ip4,omitempty"` +} + +func (m *GpeNativeFwdRpathsGet) Reset() { *m = GpeNativeFwdRpathsGet{} } +func (*GpeNativeFwdRpathsGet) GetMessageName() string { return "gpe_native_fwd_rpaths_get" } +func (*GpeNativeFwdRpathsGet) GetCrcString() string { return "f652ceb4" } +func (*GpeNativeFwdRpathsGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *GpeNativeFwdRpathsGet) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsIP4 + return size +} +func (m *GpeNativeFwdRpathsGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsIP4) + return buf.Bytes(), nil +} +func (m *GpeNativeFwdRpathsGet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsIP4 = buf.DecodeBool() + return nil +} + +// Reply for get native fwd rpath +// - retval - return code +// - table_id - table id for route path +// - nh_sw_if_index - next-hop sw_if_index (~0 if not set) +// - nh_addr - next hop address +// +// GpeNativeFwdRpathsGetReply defines message 'gpe_native_fwd_rpaths_get_reply'. +type GpeNativeFwdRpathsGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + Entries []GpeNativeFwdRpath `binapi:"gpe_native_fwd_rpath[count],name=entries" json:"entries,omitempty"` +} + +func (m *GpeNativeFwdRpathsGetReply) Reset() { *m = GpeNativeFwdRpathsGetReply{} } +func (*GpeNativeFwdRpathsGetReply) GetMessageName() string { return "gpe_native_fwd_rpaths_get_reply" } +func (*GpeNativeFwdRpathsGetReply) GetCrcString() string { return "7a1ca5a2" } +func (*GpeNativeFwdRpathsGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *GpeNativeFwdRpathsGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + for j1 := 0; j1 < len(m.Entries); j1++ { + var s1 GpeNativeFwdRpath + _ = s1 + if j1 < len(m.Entries) { + s1 = m.Entries[j1] + } + size += 4 // s1.FibIndex + size += 4 // s1.NhSwIfIndex + size += 1 // s1.NhAddr.Af + size += 1 * 16 // s1.NhAddr.Un + } + return size +} +func (m *GpeNativeFwdRpathsGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.Entries))) + for j0 := 0; j0 < len(m.Entries); j0++ { + var v0 GpeNativeFwdRpath // Entries + if j0 < len(m.Entries) { + v0 = m.Entries[j0] + } + buf.EncodeUint32(v0.FibIndex) + buf.EncodeUint32(uint32(v0.NhSwIfIndex)) + buf.EncodeUint8(uint8(v0.NhAddr.Af)) + buf.EncodeBytes(v0.NhAddr.Un.XXX_UnionData[:], 16) + } + return buf.Bytes(), nil +} +func (m *GpeNativeFwdRpathsGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.Entries = make([]GpeNativeFwdRpath, m.Count) + for j0 := 0; j0 < len(m.Entries); j0++ { + m.Entries[j0].FibIndex = buf.DecodeUint32() + m.Entries[j0].NhSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Entries[j0].NhAddr.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Entries[j0].NhAddr.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + } + return nil +} + +// Set GPE encapsulation mode +// - mode - LISP (value 0) or VXLAN (value 1) +// +// GpeSetEncapMode defines message 'gpe_set_encap_mode'. +type GpeSetEncapMode struct { + IsVxlan bool `binapi:"bool,name=is_vxlan" json:"is_vxlan,omitempty"` +} + +func (m *GpeSetEncapMode) Reset() { *m = GpeSetEncapMode{} } +func (*GpeSetEncapMode) GetMessageName() string { return "gpe_set_encap_mode" } +func (*GpeSetEncapMode) GetCrcString() string { return "bd819eac" } +func (*GpeSetEncapMode) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *GpeSetEncapMode) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsVxlan + return size +} +func (m *GpeSetEncapMode) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsVxlan) + return buf.Bytes(), nil +} +func (m *GpeSetEncapMode) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsVxlan = buf.DecodeBool() + return nil +} + +// GpeSetEncapModeReply defines message 'gpe_set_encap_mode_reply'. +type GpeSetEncapModeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *GpeSetEncapModeReply) Reset() { *m = GpeSetEncapModeReply{} } +func (*GpeSetEncapModeReply) GetMessageName() string { return "gpe_set_encap_mode_reply" } +func (*GpeSetEncapModeReply) GetCrcString() string { return "e8d4e804" } +func (*GpeSetEncapModeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *GpeSetEncapModeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *GpeSetEncapModeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *GpeSetEncapModeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_lisp_gpe_binapi_init() } +func file_lisp_gpe_binapi_init() { + api.RegisterMessage((*GpeAddDelFwdEntry)(nil), "gpe_add_del_fwd_entry_f0847644") + api.RegisterMessage((*GpeAddDelFwdEntryReply)(nil), "gpe_add_del_fwd_entry_reply_efe5f176") + api.RegisterMessage((*GpeAddDelIface)(nil), "gpe_add_del_iface_3ccff273") + api.RegisterMessage((*GpeAddDelIfaceReply)(nil), "gpe_add_del_iface_reply_e8d4e804") + api.RegisterMessage((*GpeAddDelNativeFwdRpath)(nil), "gpe_add_del_native_fwd_rpath_43fc8b54") + api.RegisterMessage((*GpeAddDelNativeFwdRpathReply)(nil), "gpe_add_del_native_fwd_rpath_reply_e8d4e804") + api.RegisterMessage((*GpeEnableDisable)(nil), "gpe_enable_disable_c264d7bf") + api.RegisterMessage((*GpeEnableDisableReply)(nil), "gpe_enable_disable_reply_e8d4e804") + api.RegisterMessage((*GpeFwdEntriesGet)(nil), "gpe_fwd_entries_get_8d1f2fe9") + api.RegisterMessage((*GpeFwdEntriesGetReply)(nil), "gpe_fwd_entries_get_reply_c4844876") + api.RegisterMessage((*GpeFwdEntryPathDetails)(nil), "gpe_fwd_entry_path_details_483df51a") + api.RegisterMessage((*GpeFwdEntryPathDump)(nil), "gpe_fwd_entry_path_dump_39bce980") + api.RegisterMessage((*GpeFwdEntryVnisGet)(nil), "gpe_fwd_entry_vnis_get_51077d14") + api.RegisterMessage((*GpeFwdEntryVnisGetReply)(nil), "gpe_fwd_entry_vnis_get_reply_aa70da20") + api.RegisterMessage((*GpeGetEncapMode)(nil), "gpe_get_encap_mode_51077d14") + api.RegisterMessage((*GpeGetEncapModeReply)(nil), "gpe_get_encap_mode_reply_36e3f7ca") + api.RegisterMessage((*GpeNativeFwdRpathsGet)(nil), "gpe_native_fwd_rpaths_get_f652ceb4") + api.RegisterMessage((*GpeNativeFwdRpathsGetReply)(nil), "gpe_native_fwd_rpaths_get_reply_7a1ca5a2") + api.RegisterMessage((*GpeSetEncapMode)(nil), "gpe_set_encap_mode_bd819eac") + api.RegisterMessage((*GpeSetEncapModeReply)(nil), "gpe_set_encap_mode_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*GpeAddDelFwdEntry)(nil), + (*GpeAddDelFwdEntryReply)(nil), + (*GpeAddDelIface)(nil), + (*GpeAddDelIfaceReply)(nil), + (*GpeAddDelNativeFwdRpath)(nil), + (*GpeAddDelNativeFwdRpathReply)(nil), + (*GpeEnableDisable)(nil), + (*GpeEnableDisableReply)(nil), + (*GpeFwdEntriesGet)(nil), + (*GpeFwdEntriesGetReply)(nil), + (*GpeFwdEntryPathDetails)(nil), + (*GpeFwdEntryPathDump)(nil), + (*GpeFwdEntryVnisGet)(nil), + (*GpeFwdEntryVnisGetReply)(nil), + (*GpeGetEncapMode)(nil), + (*GpeGetEncapModeReply)(nil), + (*GpeNativeFwdRpathsGet)(nil), + (*GpeNativeFwdRpathsGetReply)(nil), + (*GpeSetEncapMode)(nil), + (*GpeSetEncapModeReply)(nil), + } +} diff --git a/binapi/lisp_gpe/lisp_gpe_rpc.ba.go b/binapi/lisp_gpe/lisp_gpe_rpc.ba.go new file mode 100644 index 00000000..17b36332 --- /dev/null +++ b/binapi/lisp_gpe/lisp_gpe_rpc.ba.go @@ -0,0 +1,158 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package lisp_gpe + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service lisp_gpe. +type RPCService interface { + GpeAddDelFwdEntry(ctx context.Context, in *GpeAddDelFwdEntry) (*GpeAddDelFwdEntryReply, error) + GpeAddDelIface(ctx context.Context, in *GpeAddDelIface) (*GpeAddDelIfaceReply, error) + GpeAddDelNativeFwdRpath(ctx context.Context, in *GpeAddDelNativeFwdRpath) (*GpeAddDelNativeFwdRpathReply, error) + GpeEnableDisable(ctx context.Context, in *GpeEnableDisable) (*GpeEnableDisableReply, error) + GpeFwdEntriesGet(ctx context.Context, in *GpeFwdEntriesGet) (*GpeFwdEntriesGetReply, error) + GpeFwdEntryPathDump(ctx context.Context, in *GpeFwdEntryPathDump) (RPCService_GpeFwdEntryPathDumpClient, error) + GpeFwdEntryVnisGet(ctx context.Context, in *GpeFwdEntryVnisGet) (*GpeFwdEntryVnisGetReply, error) + GpeGetEncapMode(ctx context.Context, in *GpeGetEncapMode) (*GpeGetEncapModeReply, error) + GpeNativeFwdRpathsGet(ctx context.Context, in *GpeNativeFwdRpathsGet) (*GpeNativeFwdRpathsGetReply, error) + GpeSetEncapMode(ctx context.Context, in *GpeSetEncapMode) (*GpeSetEncapModeReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) GpeAddDelFwdEntry(ctx context.Context, in *GpeAddDelFwdEntry) (*GpeAddDelFwdEntryReply, error) { + out := new(GpeAddDelFwdEntryReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) GpeAddDelIface(ctx context.Context, in *GpeAddDelIface) (*GpeAddDelIfaceReply, error) { + out := new(GpeAddDelIfaceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) GpeAddDelNativeFwdRpath(ctx context.Context, in *GpeAddDelNativeFwdRpath) (*GpeAddDelNativeFwdRpathReply, error) { + out := new(GpeAddDelNativeFwdRpathReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) GpeEnableDisable(ctx context.Context, in *GpeEnableDisable) (*GpeEnableDisableReply, error) { + out := new(GpeEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) GpeFwdEntriesGet(ctx context.Context, in *GpeFwdEntriesGet) (*GpeFwdEntriesGetReply, error) { + out := new(GpeFwdEntriesGetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) GpeFwdEntryPathDump(ctx context.Context, in *GpeFwdEntryPathDump) (RPCService_GpeFwdEntryPathDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_GpeFwdEntryPathDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_GpeFwdEntryPathDumpClient interface { + Recv() (*GpeFwdEntryPathDetails, error) + api.Stream +} + +type serviceClient_GpeFwdEntryPathDumpClient struct { + api.Stream +} + +func (c *serviceClient_GpeFwdEntryPathDumpClient) Recv() (*GpeFwdEntryPathDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *GpeFwdEntryPathDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) GpeFwdEntryVnisGet(ctx context.Context, in *GpeFwdEntryVnisGet) (*GpeFwdEntryVnisGetReply, error) { + out := new(GpeFwdEntryVnisGetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) GpeGetEncapMode(ctx context.Context, in *GpeGetEncapMode) (*GpeGetEncapModeReply, error) { + out := new(GpeGetEncapModeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) GpeNativeFwdRpathsGet(ctx context.Context, in *GpeNativeFwdRpathsGet) (*GpeNativeFwdRpathsGetReply, error) { + out := new(GpeNativeFwdRpathsGetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) GpeSetEncapMode(ctx context.Context, in *GpeSetEncapMode) (*GpeSetEncapModeReply, error) { + out := new(GpeSetEncapModeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/lisp_types/lisp_types.ba.go b/binapi/lisp_types/lisp_types.ba.go new file mode 100644 index 00000000..9fc93277 --- /dev/null +++ b/binapi/lisp_types/lisp_types.ba.go @@ -0,0 +1,184 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/lisp_types.api.json + +// Package lisp_types contains generated bindings for API file lisp_types.api. +// +// Contents: +// - 2 enums +// - 5 structs +// - 1 union +package lisp_types + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + ethernet_types "github.com/alkiranet/govpp/binapi/ethernet_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "lisp_types" + APIVersion = "1.0.0" + VersionCrc = 0xf05d92a6 +) + +// EidType defines enum 'eid_type'. +type EidType uint8 + +const ( + EID_TYPE_API_PREFIX EidType = 0 + EID_TYPE_API_MAC EidType = 1 + EID_TYPE_API_NSH EidType = 2 +) + +var ( + EidType_name = map[uint8]string{ + 0: "EID_TYPE_API_PREFIX", + 1: "EID_TYPE_API_MAC", + 2: "EID_TYPE_API_NSH", + } + EidType_value = map[string]uint8{ + "EID_TYPE_API_PREFIX": 0, + "EID_TYPE_API_MAC": 1, + "EID_TYPE_API_NSH": 2, + } +) + +func (x EidType) String() string { + s, ok := EidType_name[uint8(x)] + if ok { + return s + } + return "EidType(" + strconv.Itoa(int(x)) + ")" +} + +// HmacKeyID defines enum 'hmac_key_id'. +type HmacKeyID uint8 + +const ( + KEY_ID_API_HMAC_NO_KEY HmacKeyID = 0 + KEY_ID_API_HMAC_SHA_1_96 HmacKeyID = 1 + KEY_ID_API_HMAC_SHA_256_128 HmacKeyID = 2 +) + +var ( + HmacKeyID_name = map[uint8]string{ + 0: "KEY_ID_API_HMAC_NO_KEY", + 1: "KEY_ID_API_HMAC_SHA_1_96", + 2: "KEY_ID_API_HMAC_SHA_256_128", + } + HmacKeyID_value = map[string]uint8{ + "KEY_ID_API_HMAC_NO_KEY": 0, + "KEY_ID_API_HMAC_SHA_1_96": 1, + "KEY_ID_API_HMAC_SHA_256_128": 2, + } +) + +func (x HmacKeyID) String() string { + s, ok := HmacKeyID_name[uint8(x)] + if ok { + return s + } + return "HmacKeyID(" + strconv.Itoa(int(x)) + ")" +} + +// Eid defines type 'eid'. +type Eid struct { + Type EidType `binapi:"eid_type,name=type" json:"type,omitempty"` + Address EidAddressUnion `binapi:"eid_address,name=address" json:"address,omitempty"` +} + +// HmacKey defines type 'hmac_key'. +type HmacKey struct { + ID HmacKeyID `binapi:"hmac_key_id,name=id" json:"id,omitempty"` + Key []byte `binapi:"u8[64],name=key" json:"key,omitempty"` +} + +// LocalLocator defines type 'local_locator'. +type LocalLocator struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Priority uint8 `binapi:"u8,name=priority" json:"priority,omitempty"` + Weight uint8 `binapi:"u8,name=weight" json:"weight,omitempty"` +} + +// Nsh defines type 'nsh'. +type Nsh struct { + Spi uint32 `binapi:"u32,name=spi" json:"spi,omitempty"` + Si uint8 `binapi:"u8,name=si" json:"si,omitempty"` +} + +// RemoteLocator defines type 'remote_locator'. +type RemoteLocator struct { + Priority uint8 `binapi:"u8,name=priority" json:"priority,omitempty"` + Weight uint8 `binapi:"u8,name=weight" json:"weight,omitempty"` + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` +} + +// EidAddressUnion defines union 'eid_address'. +type EidAddressUnion struct { + // EidAddressUnion can be one of: + // - Prefix *ip_types.Prefix + // - Mac *ethernet_types.MacAddress + // - Nsh *Nsh + XXX_UnionData [18]byte +} + +func EidAddressUnionPrefix(a ip_types.Prefix) (u EidAddressUnion) { + u.SetPrefix(a) + return +} +func (u *EidAddressUnion) SetPrefix(a ip_types.Prefix) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + buf.EncodeUint8(uint8(a.Address.Af)) + buf.EncodeBytes(a.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(a.Len) +} +func (u *EidAddressUnion) GetPrefix() (a ip_types.Prefix) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + a.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(a.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + a.Len = buf.DecodeUint8() + return +} + +func EidAddressUnionMac(a ethernet_types.MacAddress) (u EidAddressUnion) { + u.SetMac(a) + return +} +func (u *EidAddressUnion) SetMac(a ethernet_types.MacAddress) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + buf.EncodeBytes(a[:], 6) +} +func (u *EidAddressUnion) GetMac() (a ethernet_types.MacAddress) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + copy(a[:], buf.DecodeBytes(6)) + return +} + +func EidAddressUnionNsh(a Nsh) (u EidAddressUnion) { + u.SetNsh(a) + return +} +func (u *EidAddressUnion) SetNsh(a Nsh) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + buf.EncodeUint32(a.Spi) + buf.EncodeUint8(a.Si) +} +func (u *EidAddressUnion) GetNsh() (a Nsh) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + a.Spi = buf.DecodeUint32() + a.Si = buf.DecodeUint8() + return +} diff --git a/binapi/lldp/lldp.ba.go b/binapi/lldp/lldp.ba.go new file mode 100644 index 00000000..194cd9c1 --- /dev/null +++ b/binapi/lldp/lldp.ba.go @@ -0,0 +1,223 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/lldp.api.json + +// Package lldp contains generated bindings for API file lldp.api. +// +// Contents: +// - 4 messages +package lldp + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "lldp" + APIVersion = "2.0.0" + VersionCrc = 0x8a7e7049 +) + +// configure global parameter for LLDP +// - system_name - VPP system name +// - tx_hold - multiplier for tx_interval when setting time-to-live (TTL) +// value in the LLDP packets +// - tx_interval - time interval, in seconds, between each LLDP frames +// +// LldpConfig defines message 'lldp_config'. +type LldpConfig struct { + TxHold uint32 `binapi:"u32,name=tx_hold" json:"tx_hold,omitempty"` + TxInterval uint32 `binapi:"u32,name=tx_interval" json:"tx_interval,omitempty"` + SystemName string `binapi:"string[],name=system_name" json:"system_name,omitempty"` +} + +func (m *LldpConfig) Reset() { *m = LldpConfig{} } +func (*LldpConfig) GetMessageName() string { return "lldp_config" } +func (*LldpConfig) GetCrcString() string { return "c14445df" } +func (*LldpConfig) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *LldpConfig) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TxHold + size += 4 // m.TxInterval + size += 4 + len(m.SystemName) // m.SystemName + return size +} +func (m *LldpConfig) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TxHold) + buf.EncodeUint32(m.TxInterval) + buf.EncodeString(m.SystemName, 0) + return buf.Bytes(), nil +} +func (m *LldpConfig) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TxHold = buf.DecodeUint32() + m.TxInterval = buf.DecodeUint32() + m.SystemName = buf.DecodeString(0) + return nil +} + +// LldpConfigReply defines message 'lldp_config_reply'. +type LldpConfigReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *LldpConfigReply) Reset() { *m = LldpConfigReply{} } +func (*LldpConfigReply) GetMessageName() string { return "lldp_config_reply" } +func (*LldpConfigReply) GetCrcString() string { return "e8d4e804" } +func (*LldpConfigReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *LldpConfigReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *LldpConfigReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *LldpConfigReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Interface set LLDP request +// - sw_if_index - interface for which to enable/disable LLDP +// - mgmt_ip4_addr - management ip4 address of the interface +// - mgmt_ip6_addr - management ip6 address of the interface +// - mgmt_oid - OID(Object Identifier) of the interface +// - enable - if non-zero enable, else disable +// - port_desc - local port description +// +// SwInterfaceSetLldp defines message 'sw_interface_set_lldp'. +type SwInterfaceSetLldp struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + MgmtIP4 ip_types.IP4Address `binapi:"ip4_address,name=mgmt_ip4" json:"mgmt_ip4,omitempty"` + MgmtIP6 ip_types.IP6Address `binapi:"ip6_address,name=mgmt_ip6" json:"mgmt_ip6,omitempty"` + MgmtOid []byte `binapi:"u8[128],name=mgmt_oid" json:"mgmt_oid,omitempty"` + Enable bool `binapi:"bool,name=enable,default=true" json:"enable,omitempty"` + PortDesc string `binapi:"string[],name=port_desc" json:"port_desc,omitempty"` +} + +func (m *SwInterfaceSetLldp) Reset() { *m = SwInterfaceSetLldp{} } +func (*SwInterfaceSetLldp) GetMessageName() string { return "sw_interface_set_lldp" } +func (*SwInterfaceSetLldp) GetCrcString() string { return "57afbcd4" } +func (*SwInterfaceSetLldp) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSetLldp) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 * 4 // m.MgmtIP4 + size += 1 * 16 // m.MgmtIP6 + size += 1 * 128 // m.MgmtOid + size += 1 // m.Enable + size += 4 + len(m.PortDesc) // m.PortDesc + return size +} +func (m *SwInterfaceSetLldp) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBytes(m.MgmtIP4[:], 4) + buf.EncodeBytes(m.MgmtIP6[:], 16) + buf.EncodeBytes(m.MgmtOid, 128) + buf.EncodeBool(m.Enable) + buf.EncodeString(m.PortDesc, 0) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetLldp) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + copy(m.MgmtIP4[:], buf.DecodeBytes(4)) + copy(m.MgmtIP6[:], buf.DecodeBytes(16)) + m.MgmtOid = make([]byte, 128) + copy(m.MgmtOid, buf.DecodeBytes(len(m.MgmtOid))) + m.Enable = buf.DecodeBool() + m.PortDesc = buf.DecodeString(0) + return nil +} + +// SwInterfaceSetLldpReply defines message 'sw_interface_set_lldp_reply'. +type SwInterfaceSetLldpReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SwInterfaceSetLldpReply) Reset() { *m = SwInterfaceSetLldpReply{} } +func (*SwInterfaceSetLldpReply) GetMessageName() string { return "sw_interface_set_lldp_reply" } +func (*SwInterfaceSetLldpReply) GetCrcString() string { return "e8d4e804" } +func (*SwInterfaceSetLldpReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwInterfaceSetLldpReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetLldpReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetLldpReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_lldp_binapi_init() } +func file_lldp_binapi_init() { + api.RegisterMessage((*LldpConfig)(nil), "lldp_config_c14445df") + api.RegisterMessage((*LldpConfigReply)(nil), "lldp_config_reply_e8d4e804") + api.RegisterMessage((*SwInterfaceSetLldp)(nil), "sw_interface_set_lldp_57afbcd4") + api.RegisterMessage((*SwInterfaceSetLldpReply)(nil), "sw_interface_set_lldp_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*LldpConfig)(nil), + (*LldpConfigReply)(nil), + (*SwInterfaceSetLldp)(nil), + (*SwInterfaceSetLldpReply)(nil), + } +} diff --git a/binapi/lldp/lldp_rpc.ba.go b/binapi/lldp/lldp_rpc.ba.go new file mode 100644 index 00000000..07e2925e --- /dev/null +++ b/binapi/lldp/lldp_rpc.ba.go @@ -0,0 +1,41 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package lldp + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service lldp. +type RPCService interface { + LldpConfig(ctx context.Context, in *LldpConfig) (*LldpConfigReply, error) + SwInterfaceSetLldp(ctx context.Context, in *SwInterfaceSetLldp) (*SwInterfaceSetLldpReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) LldpConfig(ctx context.Context, in *LldpConfig) (*LldpConfigReply, error) { + out := new(LldpConfigReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SwInterfaceSetLldp(ctx context.Context, in *SwInterfaceSetLldp) (*SwInterfaceSetLldpReply, error) { + out := new(SwInterfaceSetLldpReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/mactime/mactime.ba.go b/binapi/mactime/mactime.ba.go new file mode 100644 index 00000000..82922767 --- /dev/null +++ b/binapi/mactime/mactime.ba.go @@ -0,0 +1,457 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/mactime.api.json + +// Package mactime contains generated bindings for API file mactime.api. +// +// Contents: +// - 2 structs +// - 7 messages +package mactime + +import ( + api "github.com/alkiranet/govpp/api" + ethernet_types "github.com/alkiranet/govpp/binapi/ethernet_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "mactime" + APIVersion = "2.0.0" + VersionCrc = 0xc72e296e +) + +// MactimeTimeRange defines type 'mactime_time_range'. +type MactimeTimeRange struct { + Start float64 `binapi:"f64,name=start" json:"start,omitempty"` + End float64 `binapi:"f64,name=end" json:"end,omitempty"` +} + +// TimeRange defines type 'time_range'. +type TimeRange struct { + Start float64 `binapi:"f64,name=start" json:"start,omitempty"` + End float64 `binapi:"f64,name=end" json:"end,omitempty"` +} + +// @brief configure per src-mac time ranges +// +// * +// * Usage: +// * to create a static allow entry: +// * set mac_address, device_name, is_add=1, and allow=1. +// * +// * to create a static drop entry: +// * set mac_address, device_name, is_add=1, and drop=1. +// * +// * to create a (time-range-based) dynamic allow entry: +// * set mac_address, device_name, is_add=1, set allow=1. +// * set count = number of ranges +// * set each range start/end in seconds since Sunday began +// * As in: start/end >= 0.0 && start/end < 7.0 *86400.0 +// * +// * to create a (time-range-based) dynamic allow entry with quota: +// * Outside of stated time ranges, such entries revert to allow with no quota. +// * previous setup, s/allow=1/allow_quota=1/ +// * +// * to create a (time-range-based) dynamic drop entry: +// * Same procedure to create a dynamic allow entry, +// * set drop=1 instead of allow=1 +// * +// * to delete a per src-mac entry (of any kind) +// * set mac_address, is_add=0 +// * note: deletes all ranges. +// * +// * See mactime_test.c:api_mactime_add_del_range(...) for +// * a working example. +// +// MactimeAddDelRange defines message 'mactime_add_del_range'. +type MactimeAddDelRange struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + Drop bool `binapi:"bool,name=drop" json:"drop,omitempty"` + Allow bool `binapi:"bool,name=allow" json:"allow,omitempty"` + AllowQuota uint8 `binapi:"u8,name=allow_quota" json:"allow_quota,omitempty"` + NoUDP10001 bool `binapi:"bool,name=no_udp_10001" json:"no_udp_10001,omitempty"` + DataQuota uint64 `binapi:"u64,name=data_quota" json:"data_quota,omitempty"` + MacAddress ethernet_types.MacAddress `binapi:"mac_address,name=mac_address" json:"mac_address,omitempty"` + DeviceName string `binapi:"string[64],name=device_name" json:"device_name,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + Ranges []TimeRange `binapi:"time_range[count],name=ranges" json:"ranges,omitempty"` +} + +func (m *MactimeAddDelRange) Reset() { *m = MactimeAddDelRange{} } +func (*MactimeAddDelRange) GetMessageName() string { return "mactime_add_del_range" } +func (*MactimeAddDelRange) GetCrcString() string { return "cb56e877" } +func (*MactimeAddDelRange) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MactimeAddDelRange) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.Drop + size += 1 // m.Allow + size += 1 // m.AllowQuota + size += 1 // m.NoUDP10001 + size += 8 // m.DataQuota + size += 1 * 6 // m.MacAddress + size += 64 // m.DeviceName + size += 4 // m.Count + for j1 := 0; j1 < len(m.Ranges); j1++ { + var s1 TimeRange + _ = s1 + if j1 < len(m.Ranges) { + s1 = m.Ranges[j1] + } + size += 8 // s1.Start + size += 8 // s1.End + } + return size +} +func (m *MactimeAddDelRange) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeBool(m.Drop) + buf.EncodeBool(m.Allow) + buf.EncodeUint8(m.AllowQuota) + buf.EncodeBool(m.NoUDP10001) + buf.EncodeUint64(m.DataQuota) + buf.EncodeBytes(m.MacAddress[:], 6) + buf.EncodeString(m.DeviceName, 64) + buf.EncodeUint32(uint32(len(m.Ranges))) + for j0 := 0; j0 < len(m.Ranges); j0++ { + var v0 TimeRange // Ranges + if j0 < len(m.Ranges) { + v0 = m.Ranges[j0] + } + buf.EncodeFloat64(v0.Start) + buf.EncodeFloat64(v0.End) + } + return buf.Bytes(), nil +} +func (m *MactimeAddDelRange) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Drop = buf.DecodeBool() + m.Allow = buf.DecodeBool() + m.AllowQuota = buf.DecodeUint8() + m.NoUDP10001 = buf.DecodeBool() + m.DataQuota = buf.DecodeUint64() + copy(m.MacAddress[:], buf.DecodeBytes(6)) + m.DeviceName = buf.DecodeString(64) + m.Count = buf.DecodeUint32() + m.Ranges = make([]TimeRange, m.Count) + for j0 := 0; j0 < len(m.Ranges); j0++ { + m.Ranges[j0].Start = buf.DecodeFloat64() + m.Ranges[j0].End = buf.DecodeFloat64() + } + return nil +} + +// MactimeAddDelRangeReply defines message 'mactime_add_del_range_reply'. +type MactimeAddDelRangeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *MactimeAddDelRangeReply) Reset() { *m = MactimeAddDelRangeReply{} } +func (*MactimeAddDelRangeReply) GetMessageName() string { return "mactime_add_del_range_reply" } +func (*MactimeAddDelRangeReply) GetCrcString() string { return "e8d4e804" } +func (*MactimeAddDelRangeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MactimeAddDelRangeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MactimeAddDelRangeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MactimeAddDelRangeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// @brief mactime table entry details +// MactimeDetails defines message 'mactime_details'. +type MactimeDetails struct { + PoolIndex uint32 `binapi:"u32,name=pool_index" json:"pool_index,omitempty"` + MacAddress ethernet_types.MacAddress `binapi:"mac_address,name=mac_address" json:"mac_address,omitempty"` + DataQuota uint64 `binapi:"u64,name=data_quota" json:"data_quota,omitempty"` + DataUsedInRange uint64 `binapi:"u64,name=data_used_in_range" json:"data_used_in_range,omitempty"` + Flags uint32 `binapi:"u32,name=flags" json:"flags,omitempty"` + DeviceName string `binapi:"string[64],name=device_name" json:"device_name,omitempty"` + Nranges uint32 `binapi:"u32,name=nranges" json:"-"` + Ranges []MactimeTimeRange `binapi:"mactime_time_range[nranges],name=ranges" json:"ranges,omitempty"` +} + +func (m *MactimeDetails) Reset() { *m = MactimeDetails{} } +func (*MactimeDetails) GetMessageName() string { return "mactime_details" } +func (*MactimeDetails) GetCrcString() string { return "da25b13a" } +func (*MactimeDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MactimeDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PoolIndex + size += 1 * 6 // m.MacAddress + size += 8 // m.DataQuota + size += 8 // m.DataUsedInRange + size += 4 // m.Flags + size += 64 // m.DeviceName + size += 4 // m.Nranges + for j1 := 0; j1 < len(m.Ranges); j1++ { + var s1 MactimeTimeRange + _ = s1 + if j1 < len(m.Ranges) { + s1 = m.Ranges[j1] + } + size += 8 // s1.Start + size += 8 // s1.End + } + return size +} +func (m *MactimeDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PoolIndex) + buf.EncodeBytes(m.MacAddress[:], 6) + buf.EncodeUint64(m.DataQuota) + buf.EncodeUint64(m.DataUsedInRange) + buf.EncodeUint32(m.Flags) + buf.EncodeString(m.DeviceName, 64) + buf.EncodeUint32(uint32(len(m.Ranges))) + for j0 := 0; j0 < len(m.Ranges); j0++ { + var v0 MactimeTimeRange // Ranges + if j0 < len(m.Ranges) { + v0 = m.Ranges[j0] + } + buf.EncodeFloat64(v0.Start) + buf.EncodeFloat64(v0.End) + } + return buf.Bytes(), nil +} +func (m *MactimeDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PoolIndex = buf.DecodeUint32() + copy(m.MacAddress[:], buf.DecodeBytes(6)) + m.DataQuota = buf.DecodeUint64() + m.DataUsedInRange = buf.DecodeUint64() + m.Flags = buf.DecodeUint32() + m.DeviceName = buf.DecodeString(64) + m.Nranges = buf.DecodeUint32() + m.Ranges = make([]MactimeTimeRange, m.Nranges) + for j0 := 0; j0 < len(m.Ranges); j0++ { + m.Ranges[j0].Start = buf.DecodeFloat64() + m.Ranges[j0].End = buf.DecodeFloat64() + } + return nil +} + +// @brief dump mactime table +// +// * +// * Request a mactime client pool dump +// * Sequence: +// * client send vl_api_mactime_dump to vpp +// * vpp replies with zero or more vl_api_mactime_entry_t's +// * vpp replies with a vl_api_mactime_dump_reply_t +// * - my_table_epoch dump table only if update needed, 0 => full dump +// +// MactimeDump defines message 'mactime_dump'. +type MactimeDump struct { + MyTableEpoch uint32 `binapi:"u32,name=my_table_epoch" json:"my_table_epoch,omitempty"` +} + +func (m *MactimeDump) Reset() { *m = MactimeDump{} } +func (*MactimeDump) GetMessageName() string { return "mactime_dump" } +func (*MactimeDump) GetCrcString() string { return "8f454e23" } +func (*MactimeDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MactimeDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.MyTableEpoch + return size +} +func (m *MactimeDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.MyTableEpoch) + return buf.Bytes(), nil +} +func (m *MactimeDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.MyTableEpoch = buf.DecodeUint32() + return nil +} + +// @brief dump mactime table reply +// - Includes the vpp table epoch, needed to optimize API traffic +// +// MactimeDumpReply defines message 'mactime_dump_reply'. +type MactimeDumpReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TableEpoch uint32 `binapi:"u32,name=table_epoch" json:"table_epoch,omitempty"` +} + +func (m *MactimeDumpReply) Reset() { *m = MactimeDumpReply{} } +func (*MactimeDumpReply) GetMessageName() string { return "mactime_dump_reply" } +func (*MactimeDumpReply) GetCrcString() string { return "49bcc753" } +func (*MactimeDumpReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MactimeDumpReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.TableEpoch + return size +} +func (m *MactimeDumpReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.TableEpoch) + return buf.Bytes(), nil +} +func (m *MactimeDumpReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.TableEpoch = buf.DecodeUint32() + return nil +} + +// @brief api to enable or disable the time-based src mac filter on +// +// an interface +// +// MactimeEnableDisable defines message 'mactime_enable_disable'. +type MactimeEnableDisable struct { + EnableDisable bool `binapi:"bool,name=enable_disable" json:"enable_disable,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *MactimeEnableDisable) Reset() { *m = MactimeEnableDisable{} } +func (*MactimeEnableDisable) GetMessageName() string { return "mactime_enable_disable" } +func (*MactimeEnableDisable) GetCrcString() string { return "3865946c" } +func (*MactimeEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MactimeEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.EnableDisable + size += 4 // m.SwIfIndex + return size +} +func (m *MactimeEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.EnableDisable) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *MactimeEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EnableDisable = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// MactimeEnableDisableReply defines message 'mactime_enable_disable_reply'. +type MactimeEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *MactimeEnableDisableReply) Reset() { *m = MactimeEnableDisableReply{} } +func (*MactimeEnableDisableReply) GetMessageName() string { return "mactime_enable_disable_reply" } +func (*MactimeEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*MactimeEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MactimeEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MactimeEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MactimeEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_mactime_binapi_init() } +func file_mactime_binapi_init() { + api.RegisterMessage((*MactimeAddDelRange)(nil), "mactime_add_del_range_cb56e877") + api.RegisterMessage((*MactimeAddDelRangeReply)(nil), "mactime_add_del_range_reply_e8d4e804") + api.RegisterMessage((*MactimeDetails)(nil), "mactime_details_da25b13a") + api.RegisterMessage((*MactimeDump)(nil), "mactime_dump_8f454e23") + api.RegisterMessage((*MactimeDumpReply)(nil), "mactime_dump_reply_49bcc753") + api.RegisterMessage((*MactimeEnableDisable)(nil), "mactime_enable_disable_3865946c") + api.RegisterMessage((*MactimeEnableDisableReply)(nil), "mactime_enable_disable_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*MactimeAddDelRange)(nil), + (*MactimeAddDelRangeReply)(nil), + (*MactimeDetails)(nil), + (*MactimeDump)(nil), + (*MactimeDumpReply)(nil), + (*MactimeEnableDisable)(nil), + (*MactimeEnableDisableReply)(nil), + } +} diff --git a/binapi/mactime/mactime_rpc.ba.go b/binapi/mactime/mactime_rpc.ba.go new file mode 100644 index 00000000..8e0e854b --- /dev/null +++ b/binapi/mactime/mactime_rpc.ba.go @@ -0,0 +1,88 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package mactime + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service mactime. +type RPCService interface { + MactimeAddDelRange(ctx context.Context, in *MactimeAddDelRange) (*MactimeAddDelRangeReply, error) + MactimeDump(ctx context.Context, in *MactimeDump) (RPCService_MactimeDumpClient, error) + MactimeEnableDisable(ctx context.Context, in *MactimeEnableDisable) (*MactimeEnableDisableReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) MactimeAddDelRange(ctx context.Context, in *MactimeAddDelRange) (*MactimeAddDelRangeReply, error) { + out := new(MactimeAddDelRangeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MactimeDump(ctx context.Context, in *MactimeDump) (RPCService_MactimeDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_MactimeDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_MactimeDumpClient interface { + Recv() (*MactimeDetails, error) + api.Stream +} + +type serviceClient_MactimeDumpClient struct { + api.Stream +} + +func (c *serviceClient_MactimeDumpClient) Recv() (*MactimeDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *MactimeDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) MactimeEnableDisable(ctx context.Context, in *MactimeEnableDisable) (*MactimeEnableDisableReply, error) { + out := new(MactimeEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/map/map.ba.go b/binapi/map/map.ba.go new file mode 100644 index 00000000..b1e92674 --- /dev/null +++ b/binapi/map/map.ba.go @@ -0,0 +1,1478 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/map.api.json + +// Package maps contains generated bindings for API file map.api. +// +// Contents: +// - 32 messages +package maps + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "map" + APIVersion = "4.2.1" + VersionCrc = 0xd1f7f56c +) + +// Add or Delete MAP rule from a domain (Only used for shared IPv4 per subscriber) +// - index - MAP Domain index +// - is_add - If 1 add rule, if 0 delete rule +// - ip6_dst - MAP CE IPv6 address +// - psid - Rule PSID +// +// MapAddDelRule defines message 'map_add_del_rule'. +type MapAddDelRule struct { + Index uint32 `binapi:"u32,name=index" json:"index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + IP6Dst ip_types.IP6Address `binapi:"ip6_address,name=ip6_dst" json:"ip6_dst,omitempty"` + Psid uint16 `binapi:"u16,name=psid" json:"psid,omitempty"` +} + +func (m *MapAddDelRule) Reset() { *m = MapAddDelRule{} } +func (*MapAddDelRule) GetMessageName() string { return "map_add_del_rule" } +func (*MapAddDelRule) GetCrcString() string { return "c65b32f7" } +func (*MapAddDelRule) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapAddDelRule) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Index + size += 1 // m.IsAdd + size += 1 * 16 // m.IP6Dst + size += 2 // m.Psid + return size +} +func (m *MapAddDelRule) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Index) + buf.EncodeBool(m.IsAdd) + buf.EncodeBytes(m.IP6Dst[:], 16) + buf.EncodeUint16(m.Psid) + return buf.Bytes(), nil +} +func (m *MapAddDelRule) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Index = buf.DecodeUint32() + m.IsAdd = buf.DecodeBool() + copy(m.IP6Dst[:], buf.DecodeBytes(16)) + m.Psid = buf.DecodeUint16() + return nil +} + +// MapAddDelRuleReply defines message 'map_add_del_rule_reply'. +type MapAddDelRuleReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *MapAddDelRuleReply) Reset() { *m = MapAddDelRuleReply{} } +func (*MapAddDelRuleReply) GetMessageName() string { return "map_add_del_rule_reply" } +func (*MapAddDelRuleReply) GetCrcString() string { return "e8d4e804" } +func (*MapAddDelRuleReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapAddDelRuleReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MapAddDelRuleReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MapAddDelRuleReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add MAP domains +// - ip6_prefix - Rule IPv6 prefix +// - ip4_prefix - Rule IPv4 prefix +// - ip6_src - MAP domain IPv6 BR address / Tunnel source +// - ea_bits_len - Embedded Address bits length +// - psid_offset - Port Set Identifier (PSID) offset +// - psid_length - PSID length +// - mtu - MTU. default 1280 +// - tag - A user field stored with the MAP +// +// MapAddDomain defines message 'map_add_domain'. +type MapAddDomain struct { + IP6Prefix ip_types.IP6Prefix `binapi:"ip6_prefix,name=ip6_prefix" json:"ip6_prefix,omitempty"` + IP4Prefix ip_types.IP4Prefix `binapi:"ip4_prefix,name=ip4_prefix" json:"ip4_prefix,omitempty"` + IP6Src ip_types.IP6Prefix `binapi:"ip6_prefix,name=ip6_src" json:"ip6_src,omitempty"` + EaBitsLen uint8 `binapi:"u8,name=ea_bits_len" json:"ea_bits_len,omitempty"` + PsidOffset uint8 `binapi:"u8,name=psid_offset" json:"psid_offset,omitempty"` + PsidLength uint8 `binapi:"u8,name=psid_length" json:"psid_length,omitempty"` + Mtu uint16 `binapi:"u16,name=mtu,default=1280" json:"mtu,omitempty"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty"` +} + +func (m *MapAddDomain) Reset() { *m = MapAddDomain{} } +func (*MapAddDomain) GetMessageName() string { return "map_add_domain" } +func (*MapAddDomain) GetCrcString() string { return "249f195c" } +func (*MapAddDomain) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapAddDomain) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 16 // m.IP6Prefix.Address + size += 1 // m.IP6Prefix.Len + size += 1 * 4 // m.IP4Prefix.Address + size += 1 // m.IP4Prefix.Len + size += 1 * 16 // m.IP6Src.Address + size += 1 // m.IP6Src.Len + size += 1 // m.EaBitsLen + size += 1 // m.PsidOffset + size += 1 // m.PsidLength + size += 2 // m.Mtu + size += 64 // m.Tag + return size +} +func (m *MapAddDomain) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.IP6Prefix.Address[:], 16) + buf.EncodeUint8(m.IP6Prefix.Len) + buf.EncodeBytes(m.IP4Prefix.Address[:], 4) + buf.EncodeUint8(m.IP4Prefix.Len) + buf.EncodeBytes(m.IP6Src.Address[:], 16) + buf.EncodeUint8(m.IP6Src.Len) + buf.EncodeUint8(m.EaBitsLen) + buf.EncodeUint8(m.PsidOffset) + buf.EncodeUint8(m.PsidLength) + buf.EncodeUint16(m.Mtu) + buf.EncodeString(m.Tag, 64) + return buf.Bytes(), nil +} +func (m *MapAddDomain) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.IP6Prefix.Address[:], buf.DecodeBytes(16)) + m.IP6Prefix.Len = buf.DecodeUint8() + copy(m.IP4Prefix.Address[:], buf.DecodeBytes(4)) + m.IP4Prefix.Len = buf.DecodeUint8() + copy(m.IP6Src.Address[:], buf.DecodeBytes(16)) + m.IP6Src.Len = buf.DecodeUint8() + m.EaBitsLen = buf.DecodeUint8() + m.PsidOffset = buf.DecodeUint8() + m.PsidLength = buf.DecodeUint8() + m.Mtu = buf.DecodeUint16() + m.Tag = buf.DecodeString(64) + return nil +} + +// Reply for MAP domain add +// - index - MAP domain index +// - retval - return code +// +// MapAddDomainReply defines message 'map_add_domain_reply'. +type MapAddDomainReply struct { + Index uint32 `binapi:"u32,name=index" json:"index,omitempty"` + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *MapAddDomainReply) Reset() { *m = MapAddDomainReply{} } +func (*MapAddDomainReply) GetMessageName() string { return "map_add_domain_reply" } +func (*MapAddDomainReply) GetCrcString() string { return "3e6d4e2c" } +func (*MapAddDomainReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapAddDomainReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Index + size += 4 // m.Retval + return size +} +func (m *MapAddDomainReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Index) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MapAddDomainReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Index = buf.DecodeUint32() + m.Retval = buf.DecodeInt32() + return nil +} + +// Delete MAP domain +// - index - MAP Domain index +// +// MapDelDomain defines message 'map_del_domain'. +type MapDelDomain struct { + Index uint32 `binapi:"u32,name=index" json:"index,omitempty"` +} + +func (m *MapDelDomain) Reset() { *m = MapDelDomain{} } +func (*MapDelDomain) GetMessageName() string { return "map_del_domain" } +func (*MapDelDomain) GetCrcString() string { return "8ac76db6" } +func (*MapDelDomain) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapDelDomain) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Index + return size +} +func (m *MapDelDomain) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Index) + return buf.Bytes(), nil +} +func (m *MapDelDomain) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Index = buf.DecodeUint32() + return nil +} + +// MapDelDomainReply defines message 'map_del_domain_reply'. +type MapDelDomainReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *MapDelDomainReply) Reset() { *m = MapDelDomainReply{} } +func (*MapDelDomainReply) GetMessageName() string { return "map_del_domain_reply" } +func (*MapDelDomainReply) GetCrcString() string { return "e8d4e804" } +func (*MapDelDomainReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapDelDomainReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MapDelDomainReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MapDelDomainReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Details about a single MAP domain +// - domain_index - MAP domain index +// - ip6_prefix - Rule IPv6 prefix +// - ip4_prefix - Rule IPv4 prefix +// - ip6_src - MAP domain IPv6 BR address / Tunnel source +// - ea_bits_len - Embedded Address bits length +// - psid_offset - Port Set Identifier (PSID) offset +// - psid_length - PSID length +// - flags - +// - mtu - MTU +// - tag - The user field stored with the MAP at creation time +// +// MapDomainDetails defines message 'map_domain_details'. +type MapDomainDetails struct { + DomainIndex uint32 `binapi:"u32,name=domain_index" json:"domain_index,omitempty"` + IP6Prefix ip_types.IP6Prefix `binapi:"ip6_prefix,name=ip6_prefix" json:"ip6_prefix,omitempty"` + IP4Prefix ip_types.IP4Prefix `binapi:"ip4_prefix,name=ip4_prefix" json:"ip4_prefix,omitempty"` + IP6Src ip_types.IP6Prefix `binapi:"ip6_prefix,name=ip6_src" json:"ip6_src,omitempty"` + EaBitsLen uint8 `binapi:"u8,name=ea_bits_len" json:"ea_bits_len,omitempty"` + PsidOffset uint8 `binapi:"u8,name=psid_offset" json:"psid_offset,omitempty"` + PsidLength uint8 `binapi:"u8,name=psid_length" json:"psid_length,omitempty"` + Flags uint8 `binapi:"u8,name=flags" json:"flags,omitempty"` + Mtu uint16 `binapi:"u16,name=mtu" json:"mtu,omitempty"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty"` +} + +func (m *MapDomainDetails) Reset() { *m = MapDomainDetails{} } +func (*MapDomainDetails) GetMessageName() string { return "map_domain_details" } +func (*MapDomainDetails) GetCrcString() string { return "796edb50" } +func (*MapDomainDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapDomainDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.DomainIndex + size += 1 * 16 // m.IP6Prefix.Address + size += 1 // m.IP6Prefix.Len + size += 1 * 4 // m.IP4Prefix.Address + size += 1 // m.IP4Prefix.Len + size += 1 * 16 // m.IP6Src.Address + size += 1 // m.IP6Src.Len + size += 1 // m.EaBitsLen + size += 1 // m.PsidOffset + size += 1 // m.PsidLength + size += 1 // m.Flags + size += 2 // m.Mtu + size += 64 // m.Tag + return size +} +func (m *MapDomainDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.DomainIndex) + buf.EncodeBytes(m.IP6Prefix.Address[:], 16) + buf.EncodeUint8(m.IP6Prefix.Len) + buf.EncodeBytes(m.IP4Prefix.Address[:], 4) + buf.EncodeUint8(m.IP4Prefix.Len) + buf.EncodeBytes(m.IP6Src.Address[:], 16) + buf.EncodeUint8(m.IP6Src.Len) + buf.EncodeUint8(m.EaBitsLen) + buf.EncodeUint8(m.PsidOffset) + buf.EncodeUint8(m.PsidLength) + buf.EncodeUint8(m.Flags) + buf.EncodeUint16(m.Mtu) + buf.EncodeString(m.Tag, 64) + return buf.Bytes(), nil +} +func (m *MapDomainDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.DomainIndex = buf.DecodeUint32() + copy(m.IP6Prefix.Address[:], buf.DecodeBytes(16)) + m.IP6Prefix.Len = buf.DecodeUint8() + copy(m.IP4Prefix.Address[:], buf.DecodeBytes(4)) + m.IP4Prefix.Len = buf.DecodeUint8() + copy(m.IP6Src.Address[:], buf.DecodeBytes(16)) + m.IP6Src.Len = buf.DecodeUint8() + m.EaBitsLen = buf.DecodeUint8() + m.PsidOffset = buf.DecodeUint8() + m.PsidLength = buf.DecodeUint8() + m.Flags = buf.DecodeUint8() + m.Mtu = buf.DecodeUint16() + m.Tag = buf.DecodeString(64) + return nil +} + +// MapDomainDump defines message 'map_domain_dump'. +// Deprecated: the message will be removed in the future versions +type MapDomainDump struct{} + +func (m *MapDomainDump) Reset() { *m = MapDomainDump{} } +func (*MapDomainDump) GetMessageName() string { return "map_domain_dump" } +func (*MapDomainDump) GetCrcString() string { return "51077d14" } +func (*MapDomainDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapDomainDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *MapDomainDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *MapDomainDump) Unmarshal(b []byte) error { + return nil +} + +// Get list of map domains +// MapDomainsGet defines message 'map_domains_get'. +type MapDomainsGet struct { + Cursor uint32 `binapi:"u32,name=cursor" json:"cursor,omitempty"` +} + +func (m *MapDomainsGet) Reset() { *m = MapDomainsGet{} } +func (*MapDomainsGet) GetMessageName() string { return "map_domains_get" } +func (*MapDomainsGet) GetCrcString() string { return "f75ba505" } +func (*MapDomainsGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapDomainsGet) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Cursor + return size +} +func (m *MapDomainsGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Cursor) + return buf.Bytes(), nil +} +func (m *MapDomainsGet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Cursor = buf.DecodeUint32() + return nil +} + +// MapDomainsGetReply defines message 'map_domains_get_reply'. +type MapDomainsGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Cursor uint32 `binapi:"u32,name=cursor" json:"cursor,omitempty"` +} + +func (m *MapDomainsGetReply) Reset() { *m = MapDomainsGetReply{} } +func (*MapDomainsGetReply) GetMessageName() string { return "map_domains_get_reply" } +func (*MapDomainsGetReply) GetCrcString() string { return "53b48f5d" } +func (*MapDomainsGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapDomainsGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Cursor + return size +} +func (m *MapDomainsGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.Cursor) + return buf.Bytes(), nil +} +func (m *MapDomainsGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Cursor = buf.DecodeUint32() + return nil +} + +// Enable or disable a MAP interface +// - sw_if_index - +// - is_enable - 0=disable, 1=enable interface +// - is_translation - 0=encapsulation, 1=translation +// +// MapIfEnableDisable defines message 'map_if_enable_disable'. +type MapIfEnableDisable struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IsEnable bool `binapi:"bool,name=is_enable" json:"is_enable,omitempty"` + IsTranslation bool `binapi:"bool,name=is_translation" json:"is_translation,omitempty"` +} + +func (m *MapIfEnableDisable) Reset() { *m = MapIfEnableDisable{} } +func (*MapIfEnableDisable) GetMessageName() string { return "map_if_enable_disable" } +func (*MapIfEnableDisable) GetCrcString() string { return "59bb32f4" } +func (*MapIfEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapIfEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.IsEnable + size += 1 // m.IsTranslation + return size +} +func (m *MapIfEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.IsEnable) + buf.EncodeBool(m.IsTranslation) + return buf.Bytes(), nil +} +func (m *MapIfEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsEnable = buf.DecodeBool() + m.IsTranslation = buf.DecodeBool() + return nil +} + +// MapIfEnableDisableReply defines message 'map_if_enable_disable_reply'. +type MapIfEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *MapIfEnableDisableReply) Reset() { *m = MapIfEnableDisableReply{} } +func (*MapIfEnableDisableReply) GetMessageName() string { return "map_if_enable_disable_reply" } +func (*MapIfEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*MapIfEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapIfEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MapIfEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MapIfEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add/delete MAP pre-resolve IP addresses parameters +// - is_add - 1 = Add non-zero IP addresses, 0 = delete +// - ip4_nh_address - direct IP4 next-hop address +// - ip6_nh_address - direct IP6 next-hop address +// +// MapParamAddDelPreResolve defines message 'map_param_add_del_pre_resolve'. +type MapParamAddDelPreResolve struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + IP4NhAddress ip_types.IP4Address `binapi:"ip4_address,name=ip4_nh_address" json:"ip4_nh_address,omitempty"` + IP6NhAddress ip_types.IP6Address `binapi:"ip6_address,name=ip6_nh_address" json:"ip6_nh_address,omitempty"` +} + +func (m *MapParamAddDelPreResolve) Reset() { *m = MapParamAddDelPreResolve{} } +func (*MapParamAddDelPreResolve) GetMessageName() string { return "map_param_add_del_pre_resolve" } +func (*MapParamAddDelPreResolve) GetCrcString() string { return "dae5af03" } +func (*MapParamAddDelPreResolve) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapParamAddDelPreResolve) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 * 4 // m.IP4NhAddress + size += 1 * 16 // m.IP6NhAddress + return size +} +func (m *MapParamAddDelPreResolve) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeBytes(m.IP4NhAddress[:], 4) + buf.EncodeBytes(m.IP6NhAddress[:], 16) + return buf.Bytes(), nil +} +func (m *MapParamAddDelPreResolve) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + copy(m.IP4NhAddress[:], buf.DecodeBytes(4)) + copy(m.IP6NhAddress[:], buf.DecodeBytes(16)) + return nil +} + +// MapParamAddDelPreResolveReply defines message 'map_param_add_del_pre_resolve_reply'. +type MapParamAddDelPreResolveReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *MapParamAddDelPreResolveReply) Reset() { *m = MapParamAddDelPreResolveReply{} } +func (*MapParamAddDelPreResolveReply) GetMessageName() string { + return "map_param_add_del_pre_resolve_reply" +} +func (*MapParamAddDelPreResolveReply) GetCrcString() string { return "e8d4e804" } +func (*MapParamAddDelPreResolveReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapParamAddDelPreResolveReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MapParamAddDelPreResolveReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MapParamAddDelPreResolveReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Request for a single block of MAP parameters +// MapParamGet defines message 'map_param_get'. +type MapParamGet struct{} + +func (m *MapParamGet) Reset() { *m = MapParamGet{} } +func (*MapParamGet) GetMessageName() string { return "map_param_get" } +func (*MapParamGet) GetCrcString() string { return "51077d14" } +func (*MapParamGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapParamGet) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *MapParamGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *MapParamGet) Unmarshal(b []byte) error { + return nil +} + +// Reply for map_param_get request +// - retval - return code for request +// - inner - 1=frag inner packet, 0=frag tunnel packets, ~0=untouched +// - ignore_df - 1=IP4 fragm despite DF bit, 0=honor DF, ~0=untouched +// - icmp_ip4_err_relay_src - IPv4 ICMP err relay src address +// - icmp6_enable_unreachable - 1 = send ICMP unreachable err msgs +// - ip4_nh_address - direct IP4 next-hop address +// - ip6_nh_address - direct IP6 next-hop address +// - sec_check_enable - 1=enable security check on first inbound packet +// - sec_check_fragments - 1=enable check on (subsequent) fragments too +// - tc_copy - 1 = copy packet class/TOS field, 0 = use class instead +// - tc_class - class field value when copy == 0 +// +// MapParamGetReply defines message 'map_param_get_reply'. +type MapParamGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + FragInner uint8 `binapi:"u8,name=frag_inner" json:"frag_inner,omitempty"` + FragIgnoreDf uint8 `binapi:"u8,name=frag_ignore_df" json:"frag_ignore_df,omitempty"` + ICMPIP4ErrRelaySrc ip_types.IP4Address `binapi:"ip4_address,name=icmp_ip4_err_relay_src" json:"icmp_ip4_err_relay_src,omitempty"` + ICMP6EnableUnreachable bool `binapi:"bool,name=icmp6_enable_unreachable" json:"icmp6_enable_unreachable,omitempty"` + IP4NhAddress ip_types.IP4Address `binapi:"ip4_address,name=ip4_nh_address" json:"ip4_nh_address,omitempty"` + IP6NhAddress ip_types.IP6Address `binapi:"ip6_address,name=ip6_nh_address" json:"ip6_nh_address,omitempty"` + IP4LifetimeMs uint16 `binapi:"u16,name=ip4_lifetime_ms" json:"ip4_lifetime_ms,omitempty"` + IP4PoolSize uint16 `binapi:"u16,name=ip4_pool_size" json:"ip4_pool_size,omitempty"` + IP4Buffers uint32 `binapi:"u32,name=ip4_buffers" json:"ip4_buffers,omitempty"` + IP4HtRatio float64 `binapi:"f64,name=ip4_ht_ratio" json:"ip4_ht_ratio,omitempty"` + SecCheckEnable bool `binapi:"bool,name=sec_check_enable" json:"sec_check_enable,omitempty"` + SecCheckFragments bool `binapi:"bool,name=sec_check_fragments" json:"sec_check_fragments,omitempty"` + TcCopy bool `binapi:"bool,name=tc_copy" json:"tc_copy,omitempty"` + TcClass uint8 `binapi:"u8,name=tc_class" json:"tc_class,omitempty"` +} + +func (m *MapParamGetReply) Reset() { *m = MapParamGetReply{} } +func (*MapParamGetReply) GetMessageName() string { return "map_param_get_reply" } +func (*MapParamGetReply) GetCrcString() string { return "26272c90" } +func (*MapParamGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapParamGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.FragInner + size += 1 // m.FragIgnoreDf + size += 1 * 4 // m.ICMPIP4ErrRelaySrc + size += 1 // m.ICMP6EnableUnreachable + size += 1 * 4 // m.IP4NhAddress + size += 1 * 16 // m.IP6NhAddress + size += 2 // m.IP4LifetimeMs + size += 2 // m.IP4PoolSize + size += 4 // m.IP4Buffers + size += 8 // m.IP4HtRatio + size += 1 // m.SecCheckEnable + size += 1 // m.SecCheckFragments + size += 1 // m.TcCopy + size += 1 // m.TcClass + return size +} +func (m *MapParamGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint8(m.FragInner) + buf.EncodeUint8(m.FragIgnoreDf) + buf.EncodeBytes(m.ICMPIP4ErrRelaySrc[:], 4) + buf.EncodeBool(m.ICMP6EnableUnreachable) + buf.EncodeBytes(m.IP4NhAddress[:], 4) + buf.EncodeBytes(m.IP6NhAddress[:], 16) + buf.EncodeUint16(m.IP4LifetimeMs) + buf.EncodeUint16(m.IP4PoolSize) + buf.EncodeUint32(m.IP4Buffers) + buf.EncodeFloat64(m.IP4HtRatio) + buf.EncodeBool(m.SecCheckEnable) + buf.EncodeBool(m.SecCheckFragments) + buf.EncodeBool(m.TcCopy) + buf.EncodeUint8(m.TcClass) + return buf.Bytes(), nil +} +func (m *MapParamGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.FragInner = buf.DecodeUint8() + m.FragIgnoreDf = buf.DecodeUint8() + copy(m.ICMPIP4ErrRelaySrc[:], buf.DecodeBytes(4)) + m.ICMP6EnableUnreachable = buf.DecodeBool() + copy(m.IP4NhAddress[:], buf.DecodeBytes(4)) + copy(m.IP6NhAddress[:], buf.DecodeBytes(16)) + m.IP4LifetimeMs = buf.DecodeUint16() + m.IP4PoolSize = buf.DecodeUint16() + m.IP4Buffers = buf.DecodeUint32() + m.IP4HtRatio = buf.DecodeFloat64() + m.SecCheckEnable = buf.DecodeBool() + m.SecCheckFragments = buf.DecodeBool() + m.TcCopy = buf.DecodeBool() + m.TcClass = buf.DecodeUint8() + return nil +} + +// Set MAP fragmentation parameters +// - inner - 1=frag inner packet, 0=frag tunnel packets +// - ignore_df - 1=IP4 fragment despite DF bit, 0=honor DF +// +// MapParamSetFragmentation defines message 'map_param_set_fragmentation'. +type MapParamSetFragmentation struct { + Inner bool `binapi:"bool,name=inner" json:"inner,omitempty"` + IgnoreDf bool `binapi:"bool,name=ignore_df" json:"ignore_df,omitempty"` +} + +func (m *MapParamSetFragmentation) Reset() { *m = MapParamSetFragmentation{} } +func (*MapParamSetFragmentation) GetMessageName() string { return "map_param_set_fragmentation" } +func (*MapParamSetFragmentation) GetCrcString() string { return "9ff54d90" } +func (*MapParamSetFragmentation) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapParamSetFragmentation) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Inner + size += 1 // m.IgnoreDf + return size +} +func (m *MapParamSetFragmentation) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.Inner) + buf.EncodeBool(m.IgnoreDf) + return buf.Bytes(), nil +} +func (m *MapParamSetFragmentation) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Inner = buf.DecodeBool() + m.IgnoreDf = buf.DecodeBool() + return nil +} + +// MapParamSetFragmentationReply defines message 'map_param_set_fragmentation_reply'. +type MapParamSetFragmentationReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *MapParamSetFragmentationReply) Reset() { *m = MapParamSetFragmentationReply{} } +func (*MapParamSetFragmentationReply) GetMessageName() string { + return "map_param_set_fragmentation_reply" +} +func (*MapParamSetFragmentationReply) GetCrcString() string { return "e8d4e804" } +func (*MapParamSetFragmentationReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapParamSetFragmentationReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MapParamSetFragmentationReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MapParamSetFragmentationReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set MAP ICMP parameters +// - icmp4_err_relay_src - IPv4 ICMP err relay src address +// +// MapParamSetICMP defines message 'map_param_set_icmp'. +type MapParamSetICMP struct { + IP4ErrRelaySrc ip_types.IP4Address `binapi:"ip4_address,name=ip4_err_relay_src" json:"ip4_err_relay_src,omitempty"` +} + +func (m *MapParamSetICMP) Reset() { *m = MapParamSetICMP{} } +func (*MapParamSetICMP) GetMessageName() string { return "map_param_set_icmp" } +func (*MapParamSetICMP) GetCrcString() string { return "58210cbf" } +func (*MapParamSetICMP) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapParamSetICMP) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 4 // m.IP4ErrRelaySrc + return size +} +func (m *MapParamSetICMP) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.IP4ErrRelaySrc[:], 4) + return buf.Bytes(), nil +} +func (m *MapParamSetICMP) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.IP4ErrRelaySrc[:], buf.DecodeBytes(4)) + return nil +} + +// Set MAP ICMP6 parameters +// - enable_unreachable - 1 = send ICMP unreachable err msgs +// +// MapParamSetICMP6 defines message 'map_param_set_icmp6'. +type MapParamSetICMP6 struct { + EnableUnreachable bool `binapi:"bool,name=enable_unreachable" json:"enable_unreachable,omitempty"` +} + +func (m *MapParamSetICMP6) Reset() { *m = MapParamSetICMP6{} } +func (*MapParamSetICMP6) GetMessageName() string { return "map_param_set_icmp6" } +func (*MapParamSetICMP6) GetCrcString() string { return "5d01f8c1" } +func (*MapParamSetICMP6) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapParamSetICMP6) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.EnableUnreachable + return size +} +func (m *MapParamSetICMP6) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.EnableUnreachable) + return buf.Bytes(), nil +} +func (m *MapParamSetICMP6) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EnableUnreachable = buf.DecodeBool() + return nil +} + +// MapParamSetICMP6Reply defines message 'map_param_set_icmp6_reply'. +type MapParamSetICMP6Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *MapParamSetICMP6Reply) Reset() { *m = MapParamSetICMP6Reply{} } +func (*MapParamSetICMP6Reply) GetMessageName() string { return "map_param_set_icmp6_reply" } +func (*MapParamSetICMP6Reply) GetCrcString() string { return "e8d4e804" } +func (*MapParamSetICMP6Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapParamSetICMP6Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MapParamSetICMP6Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MapParamSetICMP6Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// MapParamSetICMPReply defines message 'map_param_set_icmp_reply'. +type MapParamSetICMPReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *MapParamSetICMPReply) Reset() { *m = MapParamSetICMPReply{} } +func (*MapParamSetICMPReply) GetMessageName() string { return "map_param_set_icmp_reply" } +func (*MapParamSetICMPReply) GetCrcString() string { return "e8d4e804" } +func (*MapParamSetICMPReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapParamSetICMPReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MapParamSetICMPReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MapParamSetICMPReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set MAP security-check parameters +// - enable - 1=enable security check on first inbound packet +// - fragments - 1=enable check on (subsequent) fragments too +// +// MapParamSetSecurityCheck defines message 'map_param_set_security_check'. +type MapParamSetSecurityCheck struct { + Enable bool `binapi:"bool,name=enable" json:"enable,omitempty"` + Fragments bool `binapi:"bool,name=fragments" json:"fragments,omitempty"` +} + +func (m *MapParamSetSecurityCheck) Reset() { *m = MapParamSetSecurityCheck{} } +func (*MapParamSetSecurityCheck) GetMessageName() string { return "map_param_set_security_check" } +func (*MapParamSetSecurityCheck) GetCrcString() string { return "6abe9836" } +func (*MapParamSetSecurityCheck) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapParamSetSecurityCheck) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Enable + size += 1 // m.Fragments + return size +} +func (m *MapParamSetSecurityCheck) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.Enable) + buf.EncodeBool(m.Fragments) + return buf.Bytes(), nil +} +func (m *MapParamSetSecurityCheck) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Enable = buf.DecodeBool() + m.Fragments = buf.DecodeBool() + return nil +} + +// MapParamSetSecurityCheckReply defines message 'map_param_set_security_check_reply'. +type MapParamSetSecurityCheckReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *MapParamSetSecurityCheckReply) Reset() { *m = MapParamSetSecurityCheckReply{} } +func (*MapParamSetSecurityCheckReply) GetMessageName() string { + return "map_param_set_security_check_reply" +} +func (*MapParamSetSecurityCheckReply) GetCrcString() string { return "e8d4e804" } +func (*MapParamSetSecurityCheckReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapParamSetSecurityCheckReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MapParamSetSecurityCheckReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MapParamSetSecurityCheckReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set MAP TCP parameters +// +// @parma tcp_mss - TCP MSS clamping value +// +// MapParamSetTCP defines message 'map_param_set_tcp'. +type MapParamSetTCP struct { + TCPMss uint16 `binapi:"u16,name=tcp_mss" json:"tcp_mss,omitempty"` +} + +func (m *MapParamSetTCP) Reset() { *m = MapParamSetTCP{} } +func (*MapParamSetTCP) GetMessageName() string { return "map_param_set_tcp" } +func (*MapParamSetTCP) GetCrcString() string { return "87a825d9" } +func (*MapParamSetTCP) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapParamSetTCP) Size() (size int) { + if m == nil { + return 0 + } + size += 2 // m.TCPMss + return size +} +func (m *MapParamSetTCP) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint16(m.TCPMss) + return buf.Bytes(), nil +} +func (m *MapParamSetTCP) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TCPMss = buf.DecodeUint16() + return nil +} + +// MapParamSetTCPReply defines message 'map_param_set_tcp_reply'. +type MapParamSetTCPReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *MapParamSetTCPReply) Reset() { *m = MapParamSetTCPReply{} } +func (*MapParamSetTCPReply) GetMessageName() string { return "map_param_set_tcp_reply" } +func (*MapParamSetTCPReply) GetCrcString() string { return "e8d4e804" } +func (*MapParamSetTCPReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapParamSetTCPReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MapParamSetTCPReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MapParamSetTCPReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set MAP traffic class parameters +// - copy - 1 = copy packet class/TOS field, 0 = use tc_class instead +// - tc_class - class field value when copy == 0 +// +// MapParamSetTrafficClass defines message 'map_param_set_traffic_class'. +type MapParamSetTrafficClass struct { + Copy bool `binapi:"bool,name=copy" json:"copy,omitempty"` + TcClass uint8 `binapi:"u8,name=tc_class" json:"tc_class,omitempty"` +} + +func (m *MapParamSetTrafficClass) Reset() { *m = MapParamSetTrafficClass{} } +func (*MapParamSetTrafficClass) GetMessageName() string { return "map_param_set_traffic_class" } +func (*MapParamSetTrafficClass) GetCrcString() string { return "9cac455c" } +func (*MapParamSetTrafficClass) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapParamSetTrafficClass) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Copy + size += 1 // m.TcClass + return size +} +func (m *MapParamSetTrafficClass) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.Copy) + buf.EncodeUint8(m.TcClass) + return buf.Bytes(), nil +} +func (m *MapParamSetTrafficClass) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Copy = buf.DecodeBool() + m.TcClass = buf.DecodeUint8() + return nil +} + +// MapParamSetTrafficClassReply defines message 'map_param_set_traffic_class_reply'. +type MapParamSetTrafficClassReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *MapParamSetTrafficClassReply) Reset() { *m = MapParamSetTrafficClassReply{} } +func (*MapParamSetTrafficClassReply) GetMessageName() string { + return "map_param_set_traffic_class_reply" +} +func (*MapParamSetTrafficClassReply) GetCrcString() string { return "e8d4e804" } +func (*MapParamSetTrafficClassReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapParamSetTrafficClassReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MapParamSetTrafficClassReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MapParamSetTrafficClassReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// MapRuleDetails defines message 'map_rule_details'. +type MapRuleDetails struct { + IP6Dst ip_types.IP6Address `binapi:"ip6_address,name=ip6_dst" json:"ip6_dst,omitempty"` + Psid uint16 `binapi:"u16,name=psid" json:"psid,omitempty"` +} + +func (m *MapRuleDetails) Reset() { *m = MapRuleDetails{} } +func (*MapRuleDetails) GetMessageName() string { return "map_rule_details" } +func (*MapRuleDetails) GetCrcString() string { return "c7cbeea5" } +func (*MapRuleDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapRuleDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 16 // m.IP6Dst + size += 2 // m.Psid + return size +} +func (m *MapRuleDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.IP6Dst[:], 16) + buf.EncodeUint16(m.Psid) + return buf.Bytes(), nil +} +func (m *MapRuleDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.IP6Dst[:], buf.DecodeBytes(16)) + m.Psid = buf.DecodeUint16() + return nil +} + +// MapRuleDump defines message 'map_rule_dump'. +type MapRuleDump struct { + DomainIndex uint32 `binapi:"u32,name=domain_index" json:"domain_index,omitempty"` +} + +func (m *MapRuleDump) Reset() { *m = MapRuleDump{} } +func (*MapRuleDump) GetMessageName() string { return "map_rule_dump" } +func (*MapRuleDump) GetCrcString() string { return "e43e6ff6" } +func (*MapRuleDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapRuleDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.DomainIndex + return size +} +func (m *MapRuleDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.DomainIndex) + return buf.Bytes(), nil +} +func (m *MapRuleDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.DomainIndex = buf.DecodeUint32() + return nil +} + +// Request for a single block of summary stats +// MapSummaryStats defines message 'map_summary_stats'. +type MapSummaryStats struct{} + +func (m *MapSummaryStats) Reset() { *m = MapSummaryStats{} } +func (*MapSummaryStats) GetMessageName() string { return "map_summary_stats" } +func (*MapSummaryStats) GetCrcString() string { return "51077d14" } +func (*MapSummaryStats) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MapSummaryStats) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *MapSummaryStats) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *MapSummaryStats) Unmarshal(b []byte) error { + return nil +} + +// Reply for map_summary_stats request +// - retval - return code for request +// - total_bindings - +// - total_pkts - +// - total_ip4_fragments - +// - total_security_check - +// +// MapSummaryStatsReply defines message 'map_summary_stats_reply'. +type MapSummaryStatsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TotalBindings uint64 `binapi:"u64,name=total_bindings" json:"total_bindings,omitempty"` + TotalPkts []uint64 `binapi:"u64[2],name=total_pkts" json:"total_pkts,omitempty"` + TotalBytes []uint64 `binapi:"u64[2],name=total_bytes" json:"total_bytes,omitempty"` + TotalIP4Fragments uint64 `binapi:"u64,name=total_ip4_fragments" json:"total_ip4_fragments,omitempty"` + TotalSecurityCheck []uint64 `binapi:"u64[2],name=total_security_check" json:"total_security_check,omitempty"` +} + +func (m *MapSummaryStatsReply) Reset() { *m = MapSummaryStatsReply{} } +func (*MapSummaryStatsReply) GetMessageName() string { return "map_summary_stats_reply" } +func (*MapSummaryStatsReply) GetCrcString() string { return "0e4ace0e" } +func (*MapSummaryStatsReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MapSummaryStatsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 8 // m.TotalBindings + size += 8 * 2 // m.TotalPkts + size += 8 * 2 // m.TotalBytes + size += 8 // m.TotalIP4Fragments + size += 8 * 2 // m.TotalSecurityCheck + return size +} +func (m *MapSummaryStatsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint64(m.TotalBindings) + for i := 0; i < 2; i++ { + var x uint64 + if i < len(m.TotalPkts) { + x = uint64(m.TotalPkts[i]) + } + buf.EncodeUint64(x) + } + for i := 0; i < 2; i++ { + var x uint64 + if i < len(m.TotalBytes) { + x = uint64(m.TotalBytes[i]) + } + buf.EncodeUint64(x) + } + buf.EncodeUint64(m.TotalIP4Fragments) + for i := 0; i < 2; i++ { + var x uint64 + if i < len(m.TotalSecurityCheck) { + x = uint64(m.TotalSecurityCheck[i]) + } + buf.EncodeUint64(x) + } + return buf.Bytes(), nil +} +func (m *MapSummaryStatsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.TotalBindings = buf.DecodeUint64() + m.TotalPkts = make([]uint64, 2) + for i := 0; i < len(m.TotalPkts); i++ { + m.TotalPkts[i] = buf.DecodeUint64() + } + m.TotalBytes = make([]uint64, 2) + for i := 0; i < len(m.TotalBytes); i++ { + m.TotalBytes[i] = buf.DecodeUint64() + } + m.TotalIP4Fragments = buf.DecodeUint64() + m.TotalSecurityCheck = make([]uint64, 2) + for i := 0; i < len(m.TotalSecurityCheck); i++ { + m.TotalSecurityCheck[i] = buf.DecodeUint64() + } + return nil +} + +func init() { file_maps_binapi_init() } +func file_maps_binapi_init() { + api.RegisterMessage((*MapAddDelRule)(nil), "map_add_del_rule_c65b32f7") + api.RegisterMessage((*MapAddDelRuleReply)(nil), "map_add_del_rule_reply_e8d4e804") + api.RegisterMessage((*MapAddDomain)(nil), "map_add_domain_249f195c") + api.RegisterMessage((*MapAddDomainReply)(nil), "map_add_domain_reply_3e6d4e2c") + api.RegisterMessage((*MapDelDomain)(nil), "map_del_domain_8ac76db6") + api.RegisterMessage((*MapDelDomainReply)(nil), "map_del_domain_reply_e8d4e804") + api.RegisterMessage((*MapDomainDetails)(nil), "map_domain_details_796edb50") + api.RegisterMessage((*MapDomainDump)(nil), "map_domain_dump_51077d14") + api.RegisterMessage((*MapDomainsGet)(nil), "map_domains_get_f75ba505") + api.RegisterMessage((*MapDomainsGetReply)(nil), "map_domains_get_reply_53b48f5d") + api.RegisterMessage((*MapIfEnableDisable)(nil), "map_if_enable_disable_59bb32f4") + api.RegisterMessage((*MapIfEnableDisableReply)(nil), "map_if_enable_disable_reply_e8d4e804") + api.RegisterMessage((*MapParamAddDelPreResolve)(nil), "map_param_add_del_pre_resolve_dae5af03") + api.RegisterMessage((*MapParamAddDelPreResolveReply)(nil), "map_param_add_del_pre_resolve_reply_e8d4e804") + api.RegisterMessage((*MapParamGet)(nil), "map_param_get_51077d14") + api.RegisterMessage((*MapParamGetReply)(nil), "map_param_get_reply_26272c90") + api.RegisterMessage((*MapParamSetFragmentation)(nil), "map_param_set_fragmentation_9ff54d90") + api.RegisterMessage((*MapParamSetFragmentationReply)(nil), "map_param_set_fragmentation_reply_e8d4e804") + api.RegisterMessage((*MapParamSetICMP)(nil), "map_param_set_icmp_58210cbf") + api.RegisterMessage((*MapParamSetICMP6)(nil), "map_param_set_icmp6_5d01f8c1") + api.RegisterMessage((*MapParamSetICMP6Reply)(nil), "map_param_set_icmp6_reply_e8d4e804") + api.RegisterMessage((*MapParamSetICMPReply)(nil), "map_param_set_icmp_reply_e8d4e804") + api.RegisterMessage((*MapParamSetSecurityCheck)(nil), "map_param_set_security_check_6abe9836") + api.RegisterMessage((*MapParamSetSecurityCheckReply)(nil), "map_param_set_security_check_reply_e8d4e804") + api.RegisterMessage((*MapParamSetTCP)(nil), "map_param_set_tcp_87a825d9") + api.RegisterMessage((*MapParamSetTCPReply)(nil), "map_param_set_tcp_reply_e8d4e804") + api.RegisterMessage((*MapParamSetTrafficClass)(nil), "map_param_set_traffic_class_9cac455c") + api.RegisterMessage((*MapParamSetTrafficClassReply)(nil), "map_param_set_traffic_class_reply_e8d4e804") + api.RegisterMessage((*MapRuleDetails)(nil), "map_rule_details_c7cbeea5") + api.RegisterMessage((*MapRuleDump)(nil), "map_rule_dump_e43e6ff6") + api.RegisterMessage((*MapSummaryStats)(nil), "map_summary_stats_51077d14") + api.RegisterMessage((*MapSummaryStatsReply)(nil), "map_summary_stats_reply_0e4ace0e") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*MapAddDelRule)(nil), + (*MapAddDelRuleReply)(nil), + (*MapAddDomain)(nil), + (*MapAddDomainReply)(nil), + (*MapDelDomain)(nil), + (*MapDelDomainReply)(nil), + (*MapDomainDetails)(nil), + (*MapDomainDump)(nil), + (*MapDomainsGet)(nil), + (*MapDomainsGetReply)(nil), + (*MapIfEnableDisable)(nil), + (*MapIfEnableDisableReply)(nil), + (*MapParamAddDelPreResolve)(nil), + (*MapParamAddDelPreResolveReply)(nil), + (*MapParamGet)(nil), + (*MapParamGetReply)(nil), + (*MapParamSetFragmentation)(nil), + (*MapParamSetFragmentationReply)(nil), + (*MapParamSetICMP)(nil), + (*MapParamSetICMP6)(nil), + (*MapParamSetICMP6Reply)(nil), + (*MapParamSetICMPReply)(nil), + (*MapParamSetSecurityCheck)(nil), + (*MapParamSetSecurityCheckReply)(nil), + (*MapParamSetTCP)(nil), + (*MapParamSetTCPReply)(nil), + (*MapParamSetTrafficClass)(nil), + (*MapParamSetTrafficClassReply)(nil), + (*MapRuleDetails)(nil), + (*MapRuleDump)(nil), + (*MapSummaryStats)(nil), + (*MapSummaryStatsReply)(nil), + } +} diff --git a/binapi/map/map_rpc.ba.go b/binapi/map/map_rpc.ba.go new file mode 100644 index 00000000..4cb4cd57 --- /dev/null +++ b/binapi/map/map_rpc.ba.go @@ -0,0 +1,286 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package maps + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service map. +type RPCService interface { + MapAddDelRule(ctx context.Context, in *MapAddDelRule) (*MapAddDelRuleReply, error) + MapAddDomain(ctx context.Context, in *MapAddDomain) (*MapAddDomainReply, error) + MapDelDomain(ctx context.Context, in *MapDelDomain) (*MapDelDomainReply, error) + MapDomainDump(ctx context.Context, in *MapDomainDump) (RPCService_MapDomainDumpClient, error) + MapDomainsGet(ctx context.Context, in *MapDomainsGet) (RPCService_MapDomainsGetClient, error) + MapIfEnableDisable(ctx context.Context, in *MapIfEnableDisable) (*MapIfEnableDisableReply, error) + MapParamAddDelPreResolve(ctx context.Context, in *MapParamAddDelPreResolve) (*MapParamAddDelPreResolveReply, error) + MapParamGet(ctx context.Context, in *MapParamGet) (*MapParamGetReply, error) + MapParamSetFragmentation(ctx context.Context, in *MapParamSetFragmentation) (*MapParamSetFragmentationReply, error) + MapParamSetICMP(ctx context.Context, in *MapParamSetICMP) (*MapParamSetICMPReply, error) + MapParamSetICMP6(ctx context.Context, in *MapParamSetICMP6) (*MapParamSetICMP6Reply, error) + MapParamSetSecurityCheck(ctx context.Context, in *MapParamSetSecurityCheck) (*MapParamSetSecurityCheckReply, error) + MapParamSetTCP(ctx context.Context, in *MapParamSetTCP) (*MapParamSetTCPReply, error) + MapParamSetTrafficClass(ctx context.Context, in *MapParamSetTrafficClass) (*MapParamSetTrafficClassReply, error) + MapRuleDump(ctx context.Context, in *MapRuleDump) (RPCService_MapRuleDumpClient, error) + MapSummaryStats(ctx context.Context, in *MapSummaryStats) (*MapSummaryStatsReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) MapAddDelRule(ctx context.Context, in *MapAddDelRule) (*MapAddDelRuleReply, error) { + out := new(MapAddDelRuleReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MapAddDomain(ctx context.Context, in *MapAddDomain) (*MapAddDomainReply, error) { + out := new(MapAddDomainReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MapDelDomain(ctx context.Context, in *MapDelDomain) (*MapDelDomainReply, error) { + out := new(MapDelDomainReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MapDomainDump(ctx context.Context, in *MapDomainDump) (RPCService_MapDomainDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_MapDomainDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_MapDomainDumpClient interface { + Recv() (*MapDomainDetails, error) + api.Stream +} + +type serviceClient_MapDomainDumpClient struct { + api.Stream +} + +func (c *serviceClient_MapDomainDumpClient) Recv() (*MapDomainDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *MapDomainDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) MapDomainsGet(ctx context.Context, in *MapDomainsGet) (RPCService_MapDomainsGetClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_MapDomainsGetClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_MapDomainsGetClient interface { + Recv() (*MapDomainDetails, *MapDomainsGetReply, error) + api.Stream +} + +type serviceClient_MapDomainsGetClient struct { + api.Stream +} + +func (c *serviceClient_MapDomainsGetClient) Recv() (*MapDomainDetails, *MapDomainsGetReply, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, nil, err + } + switch m := msg.(type) { + case *MapDomainDetails: + return m, nil, nil + case *MapDomainsGetReply: + if err := api.RetvalToVPPApiError(m.Retval); err != nil { + return nil, m, err + } + err = c.Stream.Close() + if err != nil { + return nil, m, err + } + return nil, m, io.EOF + default: + return nil, nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) MapIfEnableDisable(ctx context.Context, in *MapIfEnableDisable) (*MapIfEnableDisableReply, error) { + out := new(MapIfEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MapParamAddDelPreResolve(ctx context.Context, in *MapParamAddDelPreResolve) (*MapParamAddDelPreResolveReply, error) { + out := new(MapParamAddDelPreResolveReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MapParamGet(ctx context.Context, in *MapParamGet) (*MapParamGetReply, error) { + out := new(MapParamGetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MapParamSetFragmentation(ctx context.Context, in *MapParamSetFragmentation) (*MapParamSetFragmentationReply, error) { + out := new(MapParamSetFragmentationReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MapParamSetICMP(ctx context.Context, in *MapParamSetICMP) (*MapParamSetICMPReply, error) { + out := new(MapParamSetICMPReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MapParamSetICMP6(ctx context.Context, in *MapParamSetICMP6) (*MapParamSetICMP6Reply, error) { + out := new(MapParamSetICMP6Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MapParamSetSecurityCheck(ctx context.Context, in *MapParamSetSecurityCheck) (*MapParamSetSecurityCheckReply, error) { + out := new(MapParamSetSecurityCheckReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MapParamSetTCP(ctx context.Context, in *MapParamSetTCP) (*MapParamSetTCPReply, error) { + out := new(MapParamSetTCPReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MapParamSetTrafficClass(ctx context.Context, in *MapParamSetTrafficClass) (*MapParamSetTrafficClassReply, error) { + out := new(MapParamSetTrafficClassReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MapRuleDump(ctx context.Context, in *MapRuleDump) (RPCService_MapRuleDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_MapRuleDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_MapRuleDumpClient interface { + Recv() (*MapRuleDetails, error) + api.Stream +} + +type serviceClient_MapRuleDumpClient struct { + api.Stream +} + +func (c *serviceClient_MapRuleDumpClient) Recv() (*MapRuleDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *MapRuleDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) MapSummaryStats(ctx context.Context, in *MapSummaryStats) (*MapSummaryStatsReply, error) { + out := new(MapSummaryStatsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/mdata/mdata.ba.go b/binapi/mdata/mdata.ba.go new file mode 100644 index 00000000..dc6d58e0 --- /dev/null +++ b/binapi/mdata/mdata.ba.go @@ -0,0 +1,112 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/mdata.api.json + +// Package mdata contains generated bindings for API file mdata.api. +// +// Contents: +// - 2 messages +package mdata + +import ( + api "github.com/alkiranet/govpp/api" + _ "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "mdata" + APIVersion = "0.1.0" + VersionCrc = 0x5bd69477 +) + +// @brief API to enable / disable mdata on an interface +// - enable_disable - 1 to enable, 0 to disable the feature +// +// MdataEnableDisable defines message 'mdata_enable_disable'. +type MdataEnableDisable struct { + EnableDisable bool `binapi:"bool,name=enable_disable" json:"enable_disable,omitempty"` +} + +func (m *MdataEnableDisable) Reset() { *m = MdataEnableDisable{} } +func (*MdataEnableDisable) GetMessageName() string { return "mdata_enable_disable" } +func (*MdataEnableDisable) GetCrcString() string { return "2e7b47df" } +func (*MdataEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MdataEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.EnableDisable + return size +} +func (m *MdataEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.EnableDisable) + return buf.Bytes(), nil +} +func (m *MdataEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EnableDisable = buf.DecodeBool() + return nil +} + +// MdataEnableDisableReply defines message 'mdata_enable_disable_reply'. +type MdataEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *MdataEnableDisableReply) Reset() { *m = MdataEnableDisableReply{} } +func (*MdataEnableDisableReply) GetMessageName() string { return "mdata_enable_disable_reply" } +func (*MdataEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*MdataEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MdataEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MdataEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MdataEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_mdata_binapi_init() } +func file_mdata_binapi_init() { + api.RegisterMessage((*MdataEnableDisable)(nil), "mdata_enable_disable_2e7b47df") + api.RegisterMessage((*MdataEnableDisableReply)(nil), "mdata_enable_disable_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*MdataEnableDisable)(nil), + (*MdataEnableDisableReply)(nil), + } +} diff --git a/binapi/mdata/mdata_rpc.ba.go b/binapi/mdata/mdata_rpc.ba.go new file mode 100644 index 00000000..ff249c7d --- /dev/null +++ b/binapi/mdata/mdata_rpc.ba.go @@ -0,0 +1,31 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package mdata + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service mdata. +type RPCService interface { + MdataEnableDisable(ctx context.Context, in *MdataEnableDisable) (*MdataEnableDisableReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) MdataEnableDisable(ctx context.Context, in *MdataEnableDisable) (*MdataEnableDisableReply, error) { + out := new(MdataEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/memclnt/memclnt.ba.go b/binapi/memclnt/memclnt.ba.go new file mode 100644 index 00000000..f8ca2cd0 --- /dev/null +++ b/binapi/memclnt/memclnt.ba.go @@ -0,0 +1,1196 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/memclnt.api.json + +// Package memclnt contains generated bindings for API file memclnt.api. +// +// Contents: +// - 2 structs +// - 26 messages +package memclnt + +import ( + api "github.com/alkiranet/govpp/api" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "memclnt" + APIVersion = "2.1.0" + VersionCrc = 0x21d36234 +) + +// MessageTableEntry defines type 'message_table_entry'. +type MessageTableEntry struct { + Index uint16 `binapi:"u16,name=index" json:"index,omitempty"` + Name string `binapi:"string[64],name=name" json:"name,omitempty"` +} + +// ModuleVersion defines type 'module_version'. +type ModuleVersion struct { + Major uint32 `binapi:"u32,name=major" json:"major,omitempty"` + Minor uint32 `binapi:"u32,name=minor" json:"minor,omitempty"` + Patch uint32 `binapi:"u32,name=patch" json:"patch,omitempty"` + Name string `binapi:"string[64],name=name" json:"name,omitempty"` +} + +// /* +// - Get API version table (includes built-in and plugins) +// +// APIVersions defines 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 +} + +func (m *APIVersions) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *APIVersions) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *APIVersions) Unmarshal(b []byte) error { + return nil +} + +// APIVersionsReply defines message 'api_versions_reply'. +type APIVersionsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + APIVersions []ModuleVersion `binapi:"module_version[count],name=api_versions" json:"api_versions,omitempty"` +} + +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 +} + +func (m *APIVersionsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + for j1 := 0; j1 < len(m.APIVersions); j1++ { + var s1 ModuleVersion + _ = s1 + if j1 < len(m.APIVersions) { + s1 = m.APIVersions[j1] + } + size += 4 // s1.Major + size += 4 // s1.Minor + size += 4 // s1.Patch + size += 64 // s1.Name + } + return size +} +func (m *APIVersionsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.APIVersions))) + for j0 := 0; j0 < len(m.APIVersions); j0++ { + var v0 ModuleVersion // APIVersions + if j0 < len(m.APIVersions) { + v0 = m.APIVersions[j0] + } + buf.EncodeUint32(v0.Major) + buf.EncodeUint32(v0.Minor) + buf.EncodeUint32(v0.Patch) + buf.EncodeString(v0.Name, 64) + } + return buf.Bytes(), nil +} +func (m *APIVersionsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.APIVersions = make([]ModuleVersion, m.Count) + for j0 := 0; j0 < len(m.APIVersions); j0++ { + m.APIVersions[j0].Major = buf.DecodeUint32() + m.APIVersions[j0].Minor = buf.DecodeUint32() + m.APIVersions[j0].Patch = buf.DecodeUint32() + m.APIVersions[j0].Name = buf.DecodeString(64) + } + return nil +} + +// Control ping from client to api server request +// ControlPing defines 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 +} + +func (m *ControlPing) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ControlPing) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ControlPing) Unmarshal(b []byte) error { + return nil +} + +// Control ping from the client to the server response +// - retval - return code for the request +// - vpe_pid - the pid of the vpe, returned by the server +// +// ControlPingReply defines message 'control_ping_reply'. +type ControlPingReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + ClientIndex uint32 `binapi:"u32,name=client_index" json:"client_index,omitempty"` + VpePID uint32 `binapi:"u32,name=vpe_pid" json:"vpe_pid,omitempty"` +} + +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 +} + +func (m *ControlPingReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.ClientIndex + size += 4 // m.VpePID + return size +} +func (m *ControlPingReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.ClientIndex) + buf.EncodeUint32(m.VpePID) + return buf.Bytes(), nil +} +func (m *ControlPingReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.ClientIndex = buf.DecodeUint32() + m.VpePID = buf.DecodeUint32() + return nil +} + +// /* +// - Lookup message-ID base by name +// +// GetFirstMsgID defines message 'get_first_msg_id'. +type GetFirstMsgID struct { + Name string `binapi:"string[64],name=name" json:"name,omitempty"` +} + +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 +} + +func (m *GetFirstMsgID) Size() (size int) { + if m == nil { + return 0 + } + size += 64 // m.Name + return size +} +func (m *GetFirstMsgID) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.Name, 64) + return buf.Bytes(), nil +} +func (m *GetFirstMsgID) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Name = buf.DecodeString(64) + return nil +} + +// GetFirstMsgIDReply defines message 'get_first_msg_id_reply'. +type GetFirstMsgIDReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + FirstMsgID uint16 `binapi:"u16,name=first_msg_id" json:"first_msg_id,omitempty"` +} + +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 +} + +func (m *GetFirstMsgIDReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 2 // m.FirstMsgID + return size +} +func (m *GetFirstMsgIDReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint16(m.FirstMsgID) + return buf.Bytes(), nil +} +func (m *GetFirstMsgIDReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.FirstMsgID = buf.DecodeUint16() + return nil +} + +// /* +// - Create a client registration +// +// MemclntCreate defines message 'memclnt_create'. +type MemclntCreate struct { + CtxQuota int32 `binapi:"i32,name=ctx_quota" json:"ctx_quota,omitempty"` + InputQueue uint64 `binapi:"u64,name=input_queue" json:"input_queue,omitempty"` + Name string `binapi:"string[64],name=name" json:"name,omitempty"` + APIVersions []uint32 `binapi:"u32[8],name=api_versions" json:"api_versions,omitempty"` +} + +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 +} + +func (m *MemclntCreate) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.CtxQuota + size += 8 // m.InputQueue + size += 64 // m.Name + size += 4 * 8 // m.APIVersions + return size +} +func (m *MemclntCreate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.CtxQuota) + buf.EncodeUint64(m.InputQueue) + buf.EncodeString(m.Name, 64) + for i := 0; i < 8; i++ { + var x uint32 + if i < len(m.APIVersions) { + x = uint32(m.APIVersions[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *MemclntCreate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.CtxQuota = buf.DecodeInt32() + m.InputQueue = buf.DecodeUint64() + m.Name = buf.DecodeString(64) + m.APIVersions = make([]uint32, 8) + for i := 0; i < len(m.APIVersions); i++ { + m.APIVersions[i] = buf.DecodeUint32() + } + return nil +} + +// MemclntCreateReply defines message 'memclnt_create_reply'. +type MemclntCreateReply struct { + Response int32 `binapi:"i32,name=response" json:"response,omitempty"` + Handle uint64 `binapi:"u64,name=handle" json:"handle,omitempty"` + Index uint32 `binapi:"u32,name=index" json:"index,omitempty"` + MessageTable uint64 `binapi:"u64,name=message_table" json:"message_table,omitempty"` +} + +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 +} + +func (m *MemclntCreateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Response + size += 8 // m.Handle + size += 4 // m.Index + size += 8 // m.MessageTable + return size +} +func (m *MemclntCreateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Response) + buf.EncodeUint64(m.Handle) + buf.EncodeUint32(m.Index) + buf.EncodeUint64(m.MessageTable) + return buf.Bytes(), nil +} +func (m *MemclntCreateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Response = buf.DecodeInt32() + m.Handle = buf.DecodeUint64() + m.Index = buf.DecodeUint32() + m.MessageTable = buf.DecodeUint64() + return nil +} + +// MemclntCreateV2 defines message 'memclnt_create_v2'. +type MemclntCreateV2 struct { + CtxQuota int32 `binapi:"i32,name=ctx_quota" json:"ctx_quota,omitempty"` + InputQueue uint64 `binapi:"u64,name=input_queue" json:"input_queue,omitempty"` + Name string `binapi:"string[64],name=name" json:"name,omitempty"` + APIVersions []uint32 `binapi:"u32[8],name=api_versions" json:"api_versions,omitempty"` + Keepalive bool `binapi:"bool,name=keepalive,default=true" json:"keepalive,omitempty"` +} + +func (m *MemclntCreateV2) Reset() { *m = MemclntCreateV2{} } +func (*MemclntCreateV2) GetMessageName() string { return "memclnt_create_v2" } +func (*MemclntCreateV2) GetCrcString() string { return "c4bd4882" } +func (*MemclntCreateV2) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MemclntCreateV2) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.CtxQuota + size += 8 // m.InputQueue + size += 64 // m.Name + size += 4 * 8 // m.APIVersions + size += 1 // m.Keepalive + return size +} +func (m *MemclntCreateV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.CtxQuota) + buf.EncodeUint64(m.InputQueue) + buf.EncodeString(m.Name, 64) + for i := 0; i < 8; i++ { + var x uint32 + if i < len(m.APIVersions) { + x = uint32(m.APIVersions[i]) + } + buf.EncodeUint32(x) + } + buf.EncodeBool(m.Keepalive) + return buf.Bytes(), nil +} +func (m *MemclntCreateV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.CtxQuota = buf.DecodeInt32() + m.InputQueue = buf.DecodeUint64() + m.Name = buf.DecodeString(64) + m.APIVersions = make([]uint32, 8) + for i := 0; i < len(m.APIVersions); i++ { + m.APIVersions[i] = buf.DecodeUint32() + } + m.Keepalive = buf.DecodeBool() + return nil +} + +// MemclntCreateV2Reply defines message 'memclnt_create_v2_reply'. +type MemclntCreateV2Reply struct { + Response int32 `binapi:"i32,name=response" json:"response,omitempty"` + Handle uint64 `binapi:"u64,name=handle" json:"handle,omitempty"` + Index uint32 `binapi:"u32,name=index" json:"index,omitempty"` + MessageTable uint64 `binapi:"u64,name=message_table" json:"message_table,omitempty"` +} + +func (m *MemclntCreateV2Reply) Reset() { *m = MemclntCreateV2Reply{} } +func (*MemclntCreateV2Reply) GetMessageName() string { return "memclnt_create_v2_reply" } +func (*MemclntCreateV2Reply) GetCrcString() string { return "42ec4560" } +func (*MemclntCreateV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MemclntCreateV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Response + size += 8 // m.Handle + size += 4 // m.Index + size += 8 // m.MessageTable + return size +} +func (m *MemclntCreateV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Response) + buf.EncodeUint64(m.Handle) + buf.EncodeUint32(m.Index) + buf.EncodeUint64(m.MessageTable) + return buf.Bytes(), nil +} +func (m *MemclntCreateV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Response = buf.DecodeInt32() + m.Handle = buf.DecodeUint64() + m.Index = buf.DecodeUint32() + m.MessageTable = buf.DecodeUint64() + return nil +} + +// /* +// - Delete a client registration +// +// MemclntDelete defines message 'memclnt_delete'. +type MemclntDelete struct { + Index uint32 `binapi:"u32,name=index" json:"index,omitempty"` + Handle uint64 `binapi:"u64,name=handle" json:"handle,omitempty"` + DoCleanup bool `binapi:"bool,name=do_cleanup" json:"do_cleanup,omitempty"` +} + +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 +} + +func (m *MemclntDelete) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Index + size += 8 // m.Handle + size += 1 // m.DoCleanup + return size +} +func (m *MemclntDelete) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Index) + buf.EncodeUint64(m.Handle) + buf.EncodeBool(m.DoCleanup) + return buf.Bytes(), nil +} +func (m *MemclntDelete) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Index = buf.DecodeUint32() + m.Handle = buf.DecodeUint64() + m.DoCleanup = buf.DecodeBool() + return nil +} + +// MemclntDeleteReply defines message 'memclnt_delete_reply'. +type MemclntDeleteReply struct { + Response int32 `binapi:"i32,name=response" json:"response,omitempty"` + Handle uint64 `binapi:"u64,name=handle" json:"handle,omitempty"` +} + +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 +} + +func (m *MemclntDeleteReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Response + size += 8 // m.Handle + return size +} +func (m *MemclntDeleteReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Response) + buf.EncodeUint64(m.Handle) + return buf.Bytes(), nil +} +func (m *MemclntDeleteReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Response = buf.DecodeInt32() + m.Handle = buf.DecodeUint64() + return nil +} + +// /* +// - Memory client ping / response +// - Only sent on inactive connections +// +// MemclntKeepalive defines 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 +} + +func (m *MemclntKeepalive) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *MemclntKeepalive) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *MemclntKeepalive) Unmarshal(b []byte) error { + return nil +} + +// MemclntKeepaliveReply defines message 'memclnt_keepalive_reply'. +type MemclntKeepaliveReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *MemclntKeepaliveReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MemclntKeepaliveReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MemclntKeepaliveReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// /* +// - Client read timeout +// +// MemclntReadTimeout defines message 'memclnt_read_timeout'. +type MemclntReadTimeout struct { + Dummy uint8 `binapi:"u8,name=dummy" json:"dummy,omitempty"` +} + +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 +} + +func (m *MemclntReadTimeout) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Dummy + return size +} +func (m *MemclntReadTimeout) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.Dummy) + return buf.Bytes(), nil +} +func (m *MemclntReadTimeout) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Dummy = buf.DecodeUint8() + return nil +} + +// /* +// - Client RX thread suspend +// +// MemclntRxThreadSuspend defines message 'memclnt_rx_thread_suspend'. +type MemclntRxThreadSuspend struct { + Dummy uint8 `binapi:"u8,name=dummy" json:"dummy,omitempty"` +} + +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 +} + +func (m *MemclntRxThreadSuspend) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Dummy + return size +} +func (m *MemclntRxThreadSuspend) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.Dummy) + return buf.Bytes(), nil +} +func (m *MemclntRxThreadSuspend) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Dummy = buf.DecodeUint8() + return nil +} + +// /* +// - RPC +// +// RPCCall defines message 'rpc_call'. +type RPCCall struct { + Function uint64 `binapi:"u64,name=function" json:"function,omitempty"` + Multicast uint8 `binapi:"u8,name=multicast" json:"multicast,omitempty"` + NeedBarrierSync uint8 `binapi:"u8,name=need_barrier_sync" json:"need_barrier_sync,omitempty"` + SendReply uint8 `binapi:"u8,name=send_reply" json:"send_reply,omitempty"` + DataLen uint32 `binapi:"u32,name=data_len" json:"-"` + Data []byte `binapi:"u8[data_len],name=data" json:"data,omitempty"` +} + +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 +} + +func (m *RPCCall) Size() (size int) { + if m == nil { + return 0 + } + size += 8 // m.Function + size += 1 // m.Multicast + size += 1 // m.NeedBarrierSync + size += 1 // m.SendReply + size += 4 // m.DataLen + size += 1 * len(m.Data) // m.Data + return size +} +func (m *RPCCall) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint64(m.Function) + buf.EncodeUint8(m.Multicast) + buf.EncodeUint8(m.NeedBarrierSync) + buf.EncodeUint8(m.SendReply) + buf.EncodeUint32(uint32(len(m.Data))) + buf.EncodeBytes(m.Data, 0) + return buf.Bytes(), nil +} +func (m *RPCCall) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Function = buf.DecodeUint64() + m.Multicast = buf.DecodeUint8() + m.NeedBarrierSync = buf.DecodeUint8() + m.SendReply = buf.DecodeUint8() + m.DataLen = buf.DecodeUint32() + m.Data = make([]byte, m.DataLen) + copy(m.Data, buf.DecodeBytes(len(m.Data))) + return nil +} + +// RPCCallReply defines message 'rpc_call_reply'. +type RPCCallReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *RPCCallReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *RPCCallReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *RPCCallReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// /* +// - Client RX thread exit +// +// RxThreadExit defines message 'rx_thread_exit'. +type RxThreadExit struct { + Dummy uint8 `binapi:"u8,name=dummy" json:"dummy,omitempty"` +} + +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 +} + +func (m *RxThreadExit) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Dummy + return size +} +func (m *RxThreadExit) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.Dummy) + return buf.Bytes(), nil +} +func (m *RxThreadExit) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Dummy = buf.DecodeUint8() + return nil +} + +// /* +// - Initialize shm api over socket api +// +// SockInitShm defines message 'sock_init_shm'. +type SockInitShm struct { + RequestedSize uint32 `binapi:"u32,name=requested_size" json:"requested_size,omitempty"` + Nitems uint8 `binapi:"u8,name=nitems" json:"-"` + Configs []uint64 `binapi:"u64[nitems],name=configs" json:"configs,omitempty"` +} + +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 +} + +func (m *SockInitShm) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.RequestedSize + size += 1 // m.Nitems + size += 8 * len(m.Configs) // m.Configs + return size +} +func (m *SockInitShm) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.RequestedSize) + buf.EncodeUint8(uint8(len(m.Configs))) + for i := 0; i < len(m.Configs); i++ { + var x uint64 + if i < len(m.Configs) { + x = uint64(m.Configs[i]) + } + buf.EncodeUint64(x) + } + return buf.Bytes(), nil +} +func (m *SockInitShm) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.RequestedSize = buf.DecodeUint32() + m.Nitems = buf.DecodeUint8() + m.Configs = make([]uint64, m.Nitems) + for i := 0; i < len(m.Configs); i++ { + m.Configs[i] = buf.DecodeUint64() + } + return nil +} + +// SockInitShmReply defines message 'sock_init_shm_reply'. +type SockInitShmReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SockInitShmReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SockInitShmReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SockInitShmReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// /* +// - Create a socket client registration. +// +// SockclntCreate defines message 'sockclnt_create'. +type SockclntCreate struct { + Name string `binapi:"string[64],name=name" json:"name,omitempty"` +} + +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 +} + +func (m *SockclntCreate) Size() (size int) { + if m == nil { + return 0 + } + size += 64 // m.Name + return size +} +func (m *SockclntCreate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.Name, 64) + return buf.Bytes(), nil +} +func (m *SockclntCreate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Name = buf.DecodeString(64) + return nil +} + +// SockclntCreateReply defines message 'sockclnt_create_reply'. +type SockclntCreateReply struct { + Response int32 `binapi:"i32,name=response" json:"response,omitempty"` + Index uint32 `binapi:"u32,name=index" json:"index,omitempty"` + Count uint16 `binapi:"u16,name=count" json:"-"` + MessageTable []MessageTableEntry `binapi:"message_table_entry[count],name=message_table" json:"message_table,omitempty"` +} + +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 +} + +func (m *SockclntCreateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Response + size += 4 // m.Index + size += 2 // m.Count + for j1 := 0; j1 < len(m.MessageTable); j1++ { + var s1 MessageTableEntry + _ = s1 + if j1 < len(m.MessageTable) { + s1 = m.MessageTable[j1] + } + size += 2 // s1.Index + size += 64 // s1.Name + } + return size +} +func (m *SockclntCreateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Response) + buf.EncodeUint32(m.Index) + buf.EncodeUint16(uint16(len(m.MessageTable))) + for j0 := 0; j0 < len(m.MessageTable); j0++ { + var v0 MessageTableEntry // MessageTable + if j0 < len(m.MessageTable) { + v0 = m.MessageTable[j0] + } + buf.EncodeUint16(v0.Index) + buf.EncodeString(v0.Name, 64) + } + return buf.Bytes(), nil +} +func (m *SockclntCreateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Response = buf.DecodeInt32() + m.Index = buf.DecodeUint32() + m.Count = buf.DecodeUint16() + m.MessageTable = make([]MessageTableEntry, m.Count) + for j0 := 0; j0 < len(m.MessageTable); j0++ { + m.MessageTable[j0].Index = buf.DecodeUint16() + m.MessageTable[j0].Name = buf.DecodeString(64) + } + return nil +} + +// /* +// - Delete a client registration +// +// SockclntDelete defines message 'sockclnt_delete'. +type SockclntDelete struct { + Index uint32 `binapi:"u32,name=index" json:"index,omitempty"` +} + +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 +} + +func (m *SockclntDelete) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Index + return size +} +func (m *SockclntDelete) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Index) + return buf.Bytes(), nil +} +func (m *SockclntDelete) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Index = buf.DecodeUint32() + return nil +} + +// SockclntDeleteReply defines message 'sockclnt_delete_reply'. +type SockclntDeleteReply struct { + Response int32 `binapi:"i32,name=response" json:"response,omitempty"` +} + +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 +} + +func (m *SockclntDeleteReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Response + return size +} +func (m *SockclntDeleteReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Response) + return buf.Bytes(), nil +} +func (m *SockclntDeleteReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Response = buf.DecodeInt32() + return nil +} + +// /* +// - Trace the plugin message-id allocator +// - so we stand a chance of dealing with different sets of plugins +// - at api trace replay time +// +// TracePluginMsgIds defines message 'trace_plugin_msg_ids'. +type TracePluginMsgIds struct { + PluginName string `binapi:"string[128],name=plugin_name" json:"plugin_name,omitempty"` + FirstMsgID uint16 `binapi:"u16,name=first_msg_id" json:"first_msg_id,omitempty"` + LastMsgID uint16 `binapi:"u16,name=last_msg_id" json:"last_msg_id,omitempty"` +} + +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 (m *TracePluginMsgIds) Size() (size int) { + if m == nil { + return 0 + } + size += 128 // m.PluginName + size += 2 // m.FirstMsgID + size += 2 // m.LastMsgID + return size +} +func (m *TracePluginMsgIds) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.PluginName, 128) + buf.EncodeUint16(m.FirstMsgID) + buf.EncodeUint16(m.LastMsgID) + return buf.Bytes(), nil +} +func (m *TracePluginMsgIds) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PluginName = buf.DecodeString(128) + m.FirstMsgID = buf.DecodeUint16() + m.LastMsgID = buf.DecodeUint16() + return nil +} + +func init() { file_memclnt_binapi_init() } +func file_memclnt_binapi_init() { + api.RegisterMessage((*APIVersions)(nil), "api_versions_51077d14") + api.RegisterMessage((*APIVersionsReply)(nil), "api_versions_reply_5f0d99d6") + api.RegisterMessage((*ControlPing)(nil), "control_ping_51077d14") + api.RegisterMessage((*ControlPingReply)(nil), "control_ping_reply_f6b0b8ca") + api.RegisterMessage((*GetFirstMsgID)(nil), "get_first_msg_id_ebf79a66") + api.RegisterMessage((*GetFirstMsgIDReply)(nil), "get_first_msg_id_reply_7d337472") + api.RegisterMessage((*MemclntCreate)(nil), "memclnt_create_9c5e1c2f") + api.RegisterMessage((*MemclntCreateReply)(nil), "memclnt_create_reply_42ec4560") + api.RegisterMessage((*MemclntCreateV2)(nil), "memclnt_create_v2_c4bd4882") + api.RegisterMessage((*MemclntCreateV2Reply)(nil), "memclnt_create_v2_reply_42ec4560") + api.RegisterMessage((*MemclntDelete)(nil), "memclnt_delete_7e1c04e3") + api.RegisterMessage((*MemclntDeleteReply)(nil), "memclnt_delete_reply_3d3b6312") + api.RegisterMessage((*MemclntKeepalive)(nil), "memclnt_keepalive_51077d14") + api.RegisterMessage((*MemclntKeepaliveReply)(nil), "memclnt_keepalive_reply_e8d4e804") + api.RegisterMessage((*MemclntReadTimeout)(nil), "memclnt_read_timeout_c3a3a452") + api.RegisterMessage((*MemclntRxThreadSuspend)(nil), "memclnt_rx_thread_suspend_c3a3a452") + api.RegisterMessage((*RPCCall)(nil), "rpc_call_7e8a2c95") + api.RegisterMessage((*RPCCallReply)(nil), "rpc_call_reply_e8d4e804") + api.RegisterMessage((*RxThreadExit)(nil), "rx_thread_exit_c3a3a452") + api.RegisterMessage((*SockInitShm)(nil), "sock_init_shm_51646d92") + api.RegisterMessage((*SockInitShmReply)(nil), "sock_init_shm_reply_e8d4e804") + api.RegisterMessage((*SockclntCreate)(nil), "sockclnt_create_455fb9c4") + api.RegisterMessage((*SockclntCreateReply)(nil), "sockclnt_create_reply_35166268") + api.RegisterMessage((*SockclntDelete)(nil), "sockclnt_delete_8ac76db6") + api.RegisterMessage((*SockclntDeleteReply)(nil), "sockclnt_delete_reply_8f38b1ee") + api.RegisterMessage((*TracePluginMsgIds)(nil), "trace_plugin_msg_ids_f476d3ce") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*APIVersions)(nil), + (*APIVersionsReply)(nil), + (*ControlPing)(nil), + (*ControlPingReply)(nil), + (*GetFirstMsgID)(nil), + (*GetFirstMsgIDReply)(nil), + (*MemclntCreate)(nil), + (*MemclntCreateReply)(nil), + (*MemclntCreateV2)(nil), + (*MemclntCreateV2Reply)(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), + } +} diff --git a/binapi/memclnt/memclnt_rpc.ba.go b/binapi/memclnt/memclnt_rpc.ba.go new file mode 100644 index 00000000..24ac7dce --- /dev/null +++ b/binapi/memclnt/memclnt_rpc.ba.go @@ -0,0 +1,199 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package memclnt + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service memclnt. +type RPCService interface { + APIVersions(ctx context.Context, in *APIVersions) (*APIVersionsReply, error) + ControlPing(ctx context.Context, in *ControlPing) (*ControlPingReply, error) + GetFirstMsgID(ctx context.Context, in *GetFirstMsgID) (*GetFirstMsgIDReply, error) + MemclntCreate(ctx context.Context, in *MemclntCreate) (*MemclntCreateReply, error) + MemclntCreateV2(ctx context.Context, in *MemclntCreateV2) (*MemclntCreateV2Reply, 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 { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) APIVersions(ctx context.Context, in *APIVersions) (*APIVersionsReply, error) { + out := new(APIVersionsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ControlPing(ctx context.Context, in *ControlPing) (*ControlPingReply, error) { + out := new(ControlPingReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) GetFirstMsgID(ctx context.Context, in *GetFirstMsgID) (*GetFirstMsgIDReply, error) { + out := new(GetFirstMsgIDReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MemclntCreate(ctx context.Context, in *MemclntCreate) (*MemclntCreateReply, error) { + out := new(MemclntCreateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) MemclntCreateV2(ctx context.Context, in *MemclntCreateV2) (*MemclntCreateV2Reply, error) { + out := new(MemclntCreateV2Reply) + err := c.conn.Invoke(ctx, in, 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.conn.Invoke(ctx, in, 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.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MemclntReadTimeout(ctx context.Context, in *MemclntReadTimeout) error { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return err + } + err = stream.SendMsg(in) + if err != nil { + return err + } + err = stream.Close() + if err != nil { + return err + } + return nil +} + +func (c *serviceClient) MemclntRxThreadSuspend(ctx context.Context, in *MemclntRxThreadSuspend) error { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return err + } + err = stream.SendMsg(in) + if err != nil { + return err + } + err = stream.Close() + if err != nil { + return err + } + return nil +} + +func (c *serviceClient) RPCCall(ctx context.Context, in *RPCCall) (*RPCCallReply, error) { + out := new(RPCCallReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) RxThreadExit(ctx context.Context, in *RxThreadExit) error { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return err + } + err = stream.SendMsg(in) + if err != nil { + return err + } + err = stream.Close() + if err != nil { + return err + } + return nil +} + +func (c *serviceClient) SockInitShm(ctx context.Context, in *SockInitShm) (*SockInitShmReply, error) { + out := new(SockInitShmReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SockclntCreate(ctx context.Context, in *SockclntCreate) (*SockclntCreateReply, error) { + out := new(SockclntCreateReply) + err := c.conn.Invoke(ctx, in, 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.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) TracePluginMsgIds(ctx context.Context, in *TracePluginMsgIds) error { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return err + } + err = stream.SendMsg(in) + if err != nil { + return err + } + err = stream.Close() + if err != nil { + return err + } + return nil +} diff --git a/binapi/memif/memif.ba.go b/binapi/memif/memif.ba.go new file mode 100644 index 00000000..eff12445 --- /dev/null +++ b/binapi/memif/memif.ba.go @@ -0,0 +1,823 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/memif.api.json + +// Package memif contains generated bindings for API file memif.api. +// +// Contents: +// - 2 enums +// - 14 messages +package memif + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + ethernet_types "github.com/alkiranet/govpp/binapi/ethernet_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "memif" + APIVersion = "3.1.0" + VersionCrc = 0xd48ac702 +) + +// MemifMode defines 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", + } + 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 "MemifMode(" + strconv.Itoa(int(x)) + ")" +} + +// MemifRole defines 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", + } + 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 "MemifRole(" + strconv.Itoa(int(x)) + ")" +} + +// Create memory interface +// - role - role of the interface in the connection (master/slave) +// - mode - interface mode +// - rx_queues - number of rx queues (only valid for slave) +// - tx_queues - number of tx queues (only valid for slave) +// - id - 32bit integer used to authenticate and match opposite sides +// of the connection +// - socket_id - socket filename id to be used for connection +// establishment +// - ring_size - the number of entries of RX/TX rings +// - buffer_size - size of the buffer allocated for each ring entry +// - no_zero_copy - if true, disable zero copy +// - hw_addr - interface MAC address +// - secret - optional, default is "", max length 24 +// +// MemifCreate defines message 'memif_create'. +type MemifCreate struct { + Role MemifRole `binapi:"memif_role,name=role" json:"role,omitempty"` + Mode MemifMode `binapi:"memif_mode,name=mode" json:"mode,omitempty"` + RxQueues uint8 `binapi:"u8,name=rx_queues" json:"rx_queues,omitempty"` + TxQueues uint8 `binapi:"u8,name=tx_queues" json:"tx_queues,omitempty"` + ID uint32 `binapi:"u32,name=id" json:"id,omitempty"` + SocketID uint32 `binapi:"u32,name=socket_id" json:"socket_id,omitempty"` + RingSize uint32 `binapi:"u32,name=ring_size" json:"ring_size,omitempty"` + BufferSize uint16 `binapi:"u16,name=buffer_size" json:"buffer_size,omitempty"` + NoZeroCopy bool `binapi:"bool,name=no_zero_copy" json:"no_zero_copy,omitempty"` + HwAddr ethernet_types.MacAddress `binapi:"mac_address,name=hw_addr" json:"hw_addr,omitempty"` + Secret string `binapi:"string[24],name=secret" json:"secret,omitempty"` +} + +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 +} + +func (m *MemifCreate) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Role + size += 4 // m.Mode + size += 1 // m.RxQueues + size += 1 // m.TxQueues + size += 4 // m.ID + size += 4 // m.SocketID + size += 4 // m.RingSize + size += 2 // m.BufferSize + size += 1 // m.NoZeroCopy + size += 1 * 6 // m.HwAddr + size += 24 // m.Secret + return size +} +func (m *MemifCreate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Role)) + buf.EncodeUint32(uint32(m.Mode)) + buf.EncodeUint8(m.RxQueues) + buf.EncodeUint8(m.TxQueues) + buf.EncodeUint32(m.ID) + buf.EncodeUint32(m.SocketID) + buf.EncodeUint32(m.RingSize) + buf.EncodeUint16(m.BufferSize) + buf.EncodeBool(m.NoZeroCopy) + buf.EncodeBytes(m.HwAddr[:], 6) + buf.EncodeString(m.Secret, 24) + return buf.Bytes(), nil +} +func (m *MemifCreate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Role = MemifRole(buf.DecodeUint32()) + m.Mode = MemifMode(buf.DecodeUint32()) + m.RxQueues = buf.DecodeUint8() + m.TxQueues = buf.DecodeUint8() + m.ID = buf.DecodeUint32() + m.SocketID = buf.DecodeUint32() + m.RingSize = buf.DecodeUint32() + m.BufferSize = buf.DecodeUint16() + m.NoZeroCopy = buf.DecodeBool() + copy(m.HwAddr[:], buf.DecodeBytes(6)) + m.Secret = buf.DecodeString(24) + return nil +} + +// Create memory interface response +// - retval - return value for request +// - sw_if_index - software index of the newly created interface +// +// MemifCreateReply defines message 'memif_create_reply'. +type MemifCreateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *MemifCreateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *MemifCreateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *MemifCreateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Create memory interface +// - role - role of the interface in the connection (master/slave) +// - mode - interface mode +// - rx_queues - number of rx queues (only valid for slave) +// - tx_queues - number of tx queues (only valid for slave) +// - id - 32bit integer used to authenticate and match opposite sides +// of the connection +// - socket_id - socket filename id to be used for connection +// establishment +// - ring_size - the number of entries of RX/TX rings +// - buffer_size - size of the buffer allocated for each ring entry +// - no_zero_copy - if true, disable zero copy +// - use_dma - if true, use dma accelerate memory copy +// - hw_addr - interface MAC address +// - secret - optional, default is "", max length 24 +// +// MemifCreateV2 defines message 'memif_create_v2'. +type MemifCreateV2 struct { + Role MemifRole `binapi:"memif_role,name=role" json:"role,omitempty"` + Mode MemifMode `binapi:"memif_mode,name=mode" json:"mode,omitempty"` + RxQueues uint8 `binapi:"u8,name=rx_queues" json:"rx_queues,omitempty"` + TxQueues uint8 `binapi:"u8,name=tx_queues" json:"tx_queues,omitempty"` + ID uint32 `binapi:"u32,name=id" json:"id,omitempty"` + SocketID uint32 `binapi:"u32,name=socket_id" json:"socket_id,omitempty"` + RingSize uint32 `binapi:"u32,name=ring_size" json:"ring_size,omitempty"` + BufferSize uint16 `binapi:"u16,name=buffer_size" json:"buffer_size,omitempty"` + NoZeroCopy bool `binapi:"bool,name=no_zero_copy" json:"no_zero_copy,omitempty"` + UseDma bool `binapi:"bool,name=use_dma" json:"use_dma,omitempty"` + HwAddr ethernet_types.MacAddress `binapi:"mac_address,name=hw_addr" json:"hw_addr,omitempty"` + Secret string `binapi:"string[24],name=secret" json:"secret,omitempty"` +} + +func (m *MemifCreateV2) Reset() { *m = MemifCreateV2{} } +func (*MemifCreateV2) GetMessageName() string { return "memif_create_v2" } +func (*MemifCreateV2) GetCrcString() string { return "8c7de5f7" } +func (*MemifCreateV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MemifCreateV2) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Role + size += 4 // m.Mode + size += 1 // m.RxQueues + size += 1 // m.TxQueues + size += 4 // m.ID + size += 4 // m.SocketID + size += 4 // m.RingSize + size += 2 // m.BufferSize + size += 1 // m.NoZeroCopy + size += 1 // m.UseDma + size += 1 * 6 // m.HwAddr + size += 24 // m.Secret + return size +} +func (m *MemifCreateV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Role)) + buf.EncodeUint32(uint32(m.Mode)) + buf.EncodeUint8(m.RxQueues) + buf.EncodeUint8(m.TxQueues) + buf.EncodeUint32(m.ID) + buf.EncodeUint32(m.SocketID) + buf.EncodeUint32(m.RingSize) + buf.EncodeUint16(m.BufferSize) + buf.EncodeBool(m.NoZeroCopy) + buf.EncodeBool(m.UseDma) + buf.EncodeBytes(m.HwAddr[:], 6) + buf.EncodeString(m.Secret, 24) + return buf.Bytes(), nil +} +func (m *MemifCreateV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Role = MemifRole(buf.DecodeUint32()) + m.Mode = MemifMode(buf.DecodeUint32()) + m.RxQueues = buf.DecodeUint8() + m.TxQueues = buf.DecodeUint8() + m.ID = buf.DecodeUint32() + m.SocketID = buf.DecodeUint32() + m.RingSize = buf.DecodeUint32() + m.BufferSize = buf.DecodeUint16() + m.NoZeroCopy = buf.DecodeBool() + m.UseDma = buf.DecodeBool() + copy(m.HwAddr[:], buf.DecodeBytes(6)) + m.Secret = buf.DecodeString(24) + return nil +} + +// Create memory interface response +// - retval - return value for request +// - sw_if_index - software index of the newly created interface +// +// MemifCreateV2Reply defines message 'memif_create_v2_reply'. +type MemifCreateV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *MemifCreateV2Reply) Reset() { *m = MemifCreateV2Reply{} } +func (*MemifCreateV2Reply) GetMessageName() string { return "memif_create_v2_reply" } +func (*MemifCreateV2Reply) GetCrcString() string { return "5383d31f" } +func (*MemifCreateV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MemifCreateV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *MemifCreateV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *MemifCreateV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Delete memory interface +// - sw_if_index - software index of the interface to delete +// +// MemifDelete defines message 'memif_delete'. +type MemifDelete struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *MemifDelete) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *MemifDelete) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *MemifDelete) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// MemifDeleteReply defines message 'memif_delete_reply'. +type MemifDeleteReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *MemifDeleteReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MemifDeleteReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MemifDeleteReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Memory interface details structure +// - sw_if_index - index of the interface +// - hw_addr - interface MAC address +// - id - id associated with the interface +// - role - role of the interface in the connection (master/slave) +// - mode - interface mode +// - zero_copy - zero copy flag present +// - socket_id - id of the socket filename used by this interface +// to establish new connections +// - ring_size - the number of entries of RX/TX rings +// - buffer_size - size of the buffer allocated for each ring entry +// - flags - interface_status flags +// - if_name - name of the interface +// +// MemifDetails defines message 'memif_details'. +type MemifDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + HwAddr ethernet_types.MacAddress `binapi:"mac_address,name=hw_addr" json:"hw_addr,omitempty"` + ID uint32 `binapi:"u32,name=id" json:"id,omitempty"` + Role MemifRole `binapi:"memif_role,name=role" json:"role,omitempty"` + Mode MemifMode `binapi:"memif_mode,name=mode" json:"mode,omitempty"` + ZeroCopy bool `binapi:"bool,name=zero_copy" json:"zero_copy,omitempty"` + SocketID uint32 `binapi:"u32,name=socket_id" json:"socket_id,omitempty"` + RingSize uint32 `binapi:"u32,name=ring_size" json:"ring_size,omitempty"` + BufferSize uint16 `binapi:"u16,name=buffer_size" json:"buffer_size,omitempty"` + Flags interface_types.IfStatusFlags `binapi:"if_status_flags,name=flags" json:"flags,omitempty"` + IfName string `binapi:"string[64],name=if_name" json:"if_name,omitempty"` +} + +func (m *MemifDetails) Reset() { *m = MemifDetails{} } +func (*MemifDetails) GetMessageName() string { return "memif_details" } +func (*MemifDetails) GetCrcString() string { return "da34feb9" } +func (*MemifDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MemifDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 * 6 // m.HwAddr + size += 4 // m.ID + size += 4 // m.Role + size += 4 // m.Mode + size += 1 // m.ZeroCopy + size += 4 // m.SocketID + size += 4 // m.RingSize + size += 2 // m.BufferSize + size += 4 // m.Flags + size += 64 // m.IfName + return size +} +func (m *MemifDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBytes(m.HwAddr[:], 6) + buf.EncodeUint32(m.ID) + buf.EncodeUint32(uint32(m.Role)) + buf.EncodeUint32(uint32(m.Mode)) + buf.EncodeBool(m.ZeroCopy) + buf.EncodeUint32(m.SocketID) + buf.EncodeUint32(m.RingSize) + buf.EncodeUint16(m.BufferSize) + buf.EncodeUint32(uint32(m.Flags)) + buf.EncodeString(m.IfName, 64) + return buf.Bytes(), nil +} +func (m *MemifDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + copy(m.HwAddr[:], buf.DecodeBytes(6)) + m.ID = buf.DecodeUint32() + m.Role = MemifRole(buf.DecodeUint32()) + m.Mode = MemifMode(buf.DecodeUint32()) + m.ZeroCopy = buf.DecodeBool() + m.SocketID = buf.DecodeUint32() + m.RingSize = buf.DecodeUint32() + m.BufferSize = buf.DecodeUint16() + m.Flags = interface_types.IfStatusFlags(buf.DecodeUint32()) + m.IfName = buf.DecodeString(64) + return nil +} + +// Dump all memory interfaces +// MemifDump defines 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 +} + +func (m *MemifDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *MemifDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *MemifDump) Unmarshal(b []byte) error { + return nil +} + +// Create or remove named socket file for memif interfaces +// - is_add - 0 = remove, 1 = add association +// - socket_id - non-0 32-bit integer used to identify a socket file +// - socket_filename - filename of the socket to be used for connection +// establishment; id 0 always maps to default "/var/vpp/memif.sock"; +// no socket filename needed when is_add == 0. +// +// MemifSocketFilenameAddDel defines message 'memif_socket_filename_add_del'. +type MemifSocketFilenameAddDel struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + SocketID uint32 `binapi:"u32,name=socket_id" json:"socket_id,omitempty"` + SocketFilename string `binapi:"string[108],name=socket_filename" json:"socket_filename,omitempty"` +} + +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 +} + +func (m *MemifSocketFilenameAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.SocketID + size += 108 // m.SocketFilename + return size +} +func (m *MemifSocketFilenameAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.SocketID) + buf.EncodeString(m.SocketFilename, 108) + return buf.Bytes(), nil +} +func (m *MemifSocketFilenameAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.SocketID = buf.DecodeUint32() + m.SocketFilename = buf.DecodeString(108) + return nil +} + +// MemifSocketFilenameAddDelReply defines message 'memif_socket_filename_add_del_reply'. +type MemifSocketFilenameAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *MemifSocketFilenameAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *MemifSocketFilenameAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *MemifSocketFilenameAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Create or remove named socket file for memif interfaces +// - is_add - 0 = remove, 1 = add association +// - socket_id - non-0 32-bit integer used to identify a socket file +// ~0 means autogenerate +// - socket_filename - filename of the socket to be used for connection +// establishment; id 0 always maps to default "/var/vpp/memif.sock"; +// no socket filename needed when is_add == 0. +// socket_filename starting with '@' will create an abstract socket +// in the given namespace +// +// MemifSocketFilenameAddDelV2 defines message 'memif_socket_filename_add_del_v2'. +type MemifSocketFilenameAddDelV2 struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + SocketID uint32 `binapi:"u32,name=socket_id,default=4294967295" json:"socket_id,omitempty"` + SocketFilename string `binapi:"string[],name=socket_filename" json:"socket_filename,omitempty"` +} + +func (m *MemifSocketFilenameAddDelV2) Reset() { *m = MemifSocketFilenameAddDelV2{} } +func (*MemifSocketFilenameAddDelV2) GetMessageName() string { + return "memif_socket_filename_add_del_v2" +} +func (*MemifSocketFilenameAddDelV2) GetCrcString() string { return "34223bdf" } +func (*MemifSocketFilenameAddDelV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *MemifSocketFilenameAddDelV2) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.SocketID + size += 4 + len(m.SocketFilename) // m.SocketFilename + return size +} +func (m *MemifSocketFilenameAddDelV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.SocketID) + buf.EncodeString(m.SocketFilename, 0) + return buf.Bytes(), nil +} +func (m *MemifSocketFilenameAddDelV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.SocketID = buf.DecodeUint32() + m.SocketFilename = buf.DecodeString(0) + return nil +} + +// Create memory interface socket file response +// - retval - return value for request +// - socket_id - non-0 32-bit integer used to identify a socket file +// +// MemifSocketFilenameAddDelV2Reply defines message 'memif_socket_filename_add_del_v2_reply'. +type MemifSocketFilenameAddDelV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SocketID uint32 `binapi:"u32,name=socket_id" json:"socket_id,omitempty"` +} + +func (m *MemifSocketFilenameAddDelV2Reply) Reset() { *m = MemifSocketFilenameAddDelV2Reply{} } +func (*MemifSocketFilenameAddDelV2Reply) GetMessageName() string { + return "memif_socket_filename_add_del_v2_reply" +} +func (*MemifSocketFilenameAddDelV2Reply) GetCrcString() string { return "9f29bdb9" } +func (*MemifSocketFilenameAddDelV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *MemifSocketFilenameAddDelV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SocketID + return size +} +func (m *MemifSocketFilenameAddDelV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.SocketID) + return buf.Bytes(), nil +} +func (m *MemifSocketFilenameAddDelV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SocketID = buf.DecodeUint32() + return nil +} + +// Memory interface details structure +// - socket_id - u32 used to identify the given socket filename +// - socket_filename - corresponding NUL terminated socket filename +// +// MemifSocketFilenameDetails defines message 'memif_socket_filename_details'. +type MemifSocketFilenameDetails struct { + SocketID uint32 `binapi:"u32,name=socket_id" json:"socket_id,omitempty"` + SocketFilename string `binapi:"string[108],name=socket_filename" json:"socket_filename,omitempty"` +} + +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 +} + +func (m *MemifSocketFilenameDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SocketID + size += 108 // m.SocketFilename + return size +} +func (m *MemifSocketFilenameDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.SocketID) + buf.EncodeString(m.SocketFilename, 108) + return buf.Bytes(), nil +} +func (m *MemifSocketFilenameDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SocketID = buf.DecodeUint32() + m.SocketFilename = buf.DecodeString(108) + return nil +} + +// Dump the table of socket ids and corresponding filenames +// MemifSocketFilenameDump defines 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 (m *MemifSocketFilenameDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *MemifSocketFilenameDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *MemifSocketFilenameDump) Unmarshal(b []byte) error { + return nil +} + +func init() { file_memif_binapi_init() } +func file_memif_binapi_init() { + api.RegisterMessage((*MemifCreate)(nil), "memif_create_b1b25061") + api.RegisterMessage((*MemifCreateReply)(nil), "memif_create_reply_5383d31f") + api.RegisterMessage((*MemifCreateV2)(nil), "memif_create_v2_8c7de5f7") + api.RegisterMessage((*MemifCreateV2Reply)(nil), "memif_create_v2_reply_5383d31f") + api.RegisterMessage((*MemifDelete)(nil), "memif_delete_f9e6675e") + api.RegisterMessage((*MemifDeleteReply)(nil), "memif_delete_reply_e8d4e804") + api.RegisterMessage((*MemifDetails)(nil), "memif_details_da34feb9") + api.RegisterMessage((*MemifDump)(nil), "memif_dump_51077d14") + api.RegisterMessage((*MemifSocketFilenameAddDel)(nil), "memif_socket_filename_add_del_a2ce1a10") + api.RegisterMessage((*MemifSocketFilenameAddDelReply)(nil), "memif_socket_filename_add_del_reply_e8d4e804") + api.RegisterMessage((*MemifSocketFilenameAddDelV2)(nil), "memif_socket_filename_add_del_v2_34223bdf") + api.RegisterMessage((*MemifSocketFilenameAddDelV2Reply)(nil), "memif_socket_filename_add_del_v2_reply_9f29bdb9") + api.RegisterMessage((*MemifSocketFilenameDetails)(nil), "memif_socket_filename_details_7ff326f7") + api.RegisterMessage((*MemifSocketFilenameDump)(nil), "memif_socket_filename_dump_51077d14") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*MemifCreate)(nil), + (*MemifCreateReply)(nil), + (*MemifCreateV2)(nil), + (*MemifCreateV2Reply)(nil), + (*MemifDelete)(nil), + (*MemifDeleteReply)(nil), + (*MemifDetails)(nil), + (*MemifDump)(nil), + (*MemifSocketFilenameAddDel)(nil), + (*MemifSocketFilenameAddDelReply)(nil), + (*MemifSocketFilenameAddDelV2)(nil), + (*MemifSocketFilenameAddDelV2Reply)(nil), + (*MemifSocketFilenameDetails)(nil), + (*MemifSocketFilenameDump)(nil), + } +} diff --git a/binapi/memif/memif_rpc.ba.go b/binapi/memif/memif_rpc.ba.go new file mode 100644 index 00000000..e2ae45bd --- /dev/null +++ b/binapi/memif/memif_rpc.ba.go @@ -0,0 +1,162 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package memif + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service memif. +type RPCService interface { + MemifCreate(ctx context.Context, in *MemifCreate) (*MemifCreateReply, error) + MemifCreateV2(ctx context.Context, in *MemifCreateV2) (*MemifCreateV2Reply, error) + MemifDelete(ctx context.Context, in *MemifDelete) (*MemifDeleteReply, error) + MemifDump(ctx context.Context, in *MemifDump) (RPCService_MemifDumpClient, error) + MemifSocketFilenameAddDel(ctx context.Context, in *MemifSocketFilenameAddDel) (*MemifSocketFilenameAddDelReply, error) + MemifSocketFilenameAddDelV2(ctx context.Context, in *MemifSocketFilenameAddDelV2) (*MemifSocketFilenameAddDelV2Reply, error) + MemifSocketFilenameDump(ctx context.Context, in *MemifSocketFilenameDump) (RPCService_MemifSocketFilenameDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) MemifCreate(ctx context.Context, in *MemifCreate) (*MemifCreateReply, error) { + out := new(MemifCreateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MemifCreateV2(ctx context.Context, in *MemifCreateV2) (*MemifCreateV2Reply, error) { + out := new(MemifCreateV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MemifDelete(ctx context.Context, in *MemifDelete) (*MemifDeleteReply, error) { + out := new(MemifDeleteReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MemifDump(ctx context.Context, in *MemifDump) (RPCService_MemifDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_MemifDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_MemifDumpClient interface { + Recv() (*MemifDetails, error) + api.Stream +} + +type serviceClient_MemifDumpClient struct { + api.Stream +} + +func (c *serviceClient_MemifDumpClient) Recv() (*MemifDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *MemifDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) MemifSocketFilenameAddDel(ctx context.Context, in *MemifSocketFilenameAddDel) (*MemifSocketFilenameAddDelReply, error) { + out := new(MemifSocketFilenameAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MemifSocketFilenameAddDelV2(ctx context.Context, in *MemifSocketFilenameAddDelV2) (*MemifSocketFilenameAddDelV2Reply, error) { + out := new(MemifSocketFilenameAddDelV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) MemifSocketFilenameDump(ctx context.Context, in *MemifSocketFilenameDump) (RPCService_MemifSocketFilenameDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_MemifSocketFilenameDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_MemifSocketFilenameDumpClient interface { + Recv() (*MemifSocketFilenameDetails, error) + api.Stream +} + +type serviceClient_MemifSocketFilenameDumpClient struct { + api.Stream +} + +func (c *serviceClient_MemifSocketFilenameDumpClient) Recv() (*MemifSocketFilenameDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *MemifSocketFilenameDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/mfib_types/mfib_types.ba.go b/binapi/mfib_types/mfib_types.ba.go new file mode 100644 index 00000000..75cbc6bd --- /dev/null +++ b/binapi/mfib_types/mfib_types.ba.go @@ -0,0 +1,151 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/mfib_types.api.json + +// Package mfib_types contains generated bindings for API file mfib_types.api. +// +// Contents: +// - 2 enums +// - 1 struct +package mfib_types + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + fib_types "github.com/alkiranet/govpp/binapi/fib_types" + _ "github.com/alkiranet/govpp/binapi/ip_types" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "mfib_types" + APIVersion = "1.0.0" + VersionCrc = 0xd2b57aaf +) + +// MfibEntryFlags defines enum 'mfib_entry_flags'. +type MfibEntryFlags uint32 + +const ( + MFIB_API_ENTRY_FLAG_NONE MfibEntryFlags = 0 + MFIB_API_ENTRY_FLAG_SIGNAL MfibEntryFlags = 1 + MFIB_API_ENTRY_FLAG_DROP MfibEntryFlags = 2 + MFIB_API_ENTRY_FLAG_CONNECTED MfibEntryFlags = 4 + MFIB_API_ENTRY_FLAG_ACCEPT_ALL_ITF MfibEntryFlags = 8 +) + +var ( + MfibEntryFlags_name = map[uint32]string{ + 0: "MFIB_API_ENTRY_FLAG_NONE", + 1: "MFIB_API_ENTRY_FLAG_SIGNAL", + 2: "MFIB_API_ENTRY_FLAG_DROP", + 4: "MFIB_API_ENTRY_FLAG_CONNECTED", + 8: "MFIB_API_ENTRY_FLAG_ACCEPT_ALL_ITF", + } + MfibEntryFlags_value = map[string]uint32{ + "MFIB_API_ENTRY_FLAG_NONE": 0, + "MFIB_API_ENTRY_FLAG_SIGNAL": 1, + "MFIB_API_ENTRY_FLAG_DROP": 2, + "MFIB_API_ENTRY_FLAG_CONNECTED": 4, + "MFIB_API_ENTRY_FLAG_ACCEPT_ALL_ITF": 8, + } +) + +func (x MfibEntryFlags) String() string { + s, ok := MfibEntryFlags_name[uint32(x)] + if ok { + return s + } + str := func(n uint32) string { + s, ok := MfibEntryFlags_name[uint32(n)] + if ok { + return s + } + return "MfibEntryFlags(" + strconv.Itoa(int(n)) + ")" + } + for i := uint32(0); i <= 32; i++ { + val := uint32(x) + if val&(1<" means sw_if_index x, next_node gre-input +// +// NshAddDelMap defines message 'nsh_add_del_map'. +type NshAddDelMap struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + NspNsi uint32 `binapi:"u32,name=nsp_nsi" json:"nsp_nsi,omitempty"` + MappedNspNsi uint32 `binapi:"u32,name=mapped_nsp_nsi" json:"mapped_nsp_nsi,omitempty"` + NshAction uint32 `binapi:"u32,name=nsh_action" json:"nsh_action,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + RxSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=rx_sw_if_index" json:"rx_sw_if_index,omitempty"` + NextNode uint32 `binapi:"u32,name=next_node" json:"next_node,omitempty"` +} + +func (m *NshAddDelMap) Reset() { *m = NshAddDelMap{} } +func (*NshAddDelMap) GetMessageName() string { return "nsh_add_del_map" } +func (*NshAddDelMap) GetCrcString() string { return "0a0f42b0" } +func (*NshAddDelMap) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *NshAddDelMap) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.NspNsi + size += 4 // m.MappedNspNsi + size += 4 // m.NshAction + size += 4 // m.SwIfIndex + size += 4 // m.RxSwIfIndex + size += 4 // m.NextNode + return size +} +func (m *NshAddDelMap) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.NspNsi) + buf.EncodeUint32(m.MappedNspNsi) + buf.EncodeUint32(m.NshAction) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(uint32(m.RxSwIfIndex)) + buf.EncodeUint32(m.NextNode) + return buf.Bytes(), nil +} +func (m *NshAddDelMap) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.NspNsi = buf.DecodeUint32() + m.MappedNspNsi = buf.DecodeUint32() + m.NshAction = buf.DecodeUint32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.RxSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.NextNode = buf.DecodeUint32() + return nil +} + +// Reply from adding NSH map (nsh_add_del_map) +// - retval - 0 means all ok +// +// NshAddDelMapReply defines message 'nsh_add_del_map_reply'. +type NshAddDelMapReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + MapIndex uint32 `binapi:"u32,name=map_index" json:"map_index,omitempty"` +} + +func (m *NshAddDelMapReply) Reset() { *m = NshAddDelMapReply{} } +func (*NshAddDelMapReply) GetMessageName() string { return "nsh_add_del_map_reply" } +func (*NshAddDelMapReply) GetCrcString() string { return "b2b127ef" } +func (*NshAddDelMapReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *NshAddDelMapReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.MapIndex + return size +} +func (m *NshAddDelMapReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.MapIndex) + return buf.Bytes(), nil +} +func (m *NshAddDelMapReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.MapIndex = buf.DecodeUint32() + return nil +} + +// NshEntryDetails defines message 'nsh_entry_details'. +type NshEntryDetails struct { + EntryIndex uint32 `binapi:"u32,name=entry_index" json:"entry_index,omitempty"` + NspNsi uint32 `binapi:"u32,name=nsp_nsi" json:"nsp_nsi,omitempty"` + MdType uint8 `binapi:"u8,name=md_type" json:"md_type,omitempty"` + VerOC uint8 `binapi:"u8,name=ver_o_c" json:"ver_o_c,omitempty"` + TTL uint8 `binapi:"u8,name=ttl" json:"ttl,omitempty"` + Length uint8 `binapi:"u8,name=length" json:"length,omitempty"` + NextProtocol uint8 `binapi:"u8,name=next_protocol" json:"next_protocol,omitempty"` + C1 uint32 `binapi:"u32,name=c1" json:"c1,omitempty"` + C2 uint32 `binapi:"u32,name=c2" json:"c2,omitempty"` + C3 uint32 `binapi:"u32,name=c3" json:"c3,omitempty"` + C4 uint32 `binapi:"u32,name=c4" json:"c4,omitempty"` + TlvLength uint8 `binapi:"u8,name=tlv_length" json:"tlv_length,omitempty"` + Tlv []byte `binapi:"u8[248],name=tlv" json:"tlv,omitempty"` +} + +func (m *NshEntryDetails) Reset() { *m = NshEntryDetails{} } +func (*NshEntryDetails) GetMessageName() string { return "nsh_entry_details" } +func (*NshEntryDetails) GetCrcString() string { return "046fb556" } +func (*NshEntryDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *NshEntryDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.EntryIndex + size += 4 // m.NspNsi + size += 1 // m.MdType + size += 1 // m.VerOC + size += 1 // m.TTL + size += 1 // m.Length + size += 1 // m.NextProtocol + size += 4 // m.C1 + size += 4 // m.C2 + size += 4 // m.C3 + size += 4 // m.C4 + size += 1 // m.TlvLength + size += 1 * 248 // m.Tlv + return size +} +func (m *NshEntryDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.EntryIndex) + buf.EncodeUint32(m.NspNsi) + buf.EncodeUint8(m.MdType) + buf.EncodeUint8(m.VerOC) + buf.EncodeUint8(m.TTL) + buf.EncodeUint8(m.Length) + buf.EncodeUint8(m.NextProtocol) + buf.EncodeUint32(m.C1) + buf.EncodeUint32(m.C2) + buf.EncodeUint32(m.C3) + buf.EncodeUint32(m.C4) + buf.EncodeUint8(m.TlvLength) + buf.EncodeBytes(m.Tlv, 248) + return buf.Bytes(), nil +} +func (m *NshEntryDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EntryIndex = buf.DecodeUint32() + m.NspNsi = buf.DecodeUint32() + m.MdType = buf.DecodeUint8() + m.VerOC = buf.DecodeUint8() + m.TTL = buf.DecodeUint8() + m.Length = buf.DecodeUint8() + m.NextProtocol = buf.DecodeUint8() + m.C1 = buf.DecodeUint32() + m.C2 = buf.DecodeUint32() + m.C3 = buf.DecodeUint32() + m.C4 = buf.DecodeUint32() + m.TlvLength = buf.DecodeUint8() + m.Tlv = make([]byte, 248) + copy(m.Tlv, buf.DecodeBytes(len(m.Tlv))) + return nil +} + +// NshEntryDump defines message 'nsh_entry_dump'. +type NshEntryDump struct { + EntryIndex uint32 `binapi:"u32,name=entry_index" json:"entry_index,omitempty"` +} + +func (m *NshEntryDump) Reset() { *m = NshEntryDump{} } +func (*NshEntryDump) GetMessageName() string { return "nsh_entry_dump" } +func (*NshEntryDump) GetCrcString() string { return "cdaf8ccb" } +func (*NshEntryDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *NshEntryDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.EntryIndex + return size +} +func (m *NshEntryDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.EntryIndex) + return buf.Bytes(), nil +} +func (m *NshEntryDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EntryIndex = buf.DecodeUint32() + return nil +} + +// NshMapDetails defines message 'nsh_map_details'. +type NshMapDetails struct { + MapIndex uint32 `binapi:"u32,name=map_index" json:"map_index,omitempty"` + NspNsi uint32 `binapi:"u32,name=nsp_nsi" json:"nsp_nsi,omitempty"` + MappedNspNsi uint32 `binapi:"u32,name=mapped_nsp_nsi" json:"mapped_nsp_nsi,omitempty"` + NshAction uint32 `binapi:"u32,name=nsh_action" json:"nsh_action,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + RxSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=rx_sw_if_index" json:"rx_sw_if_index,omitempty"` + NextNode uint32 `binapi:"u32,name=next_node" json:"next_node,omitempty"` +} + +func (m *NshMapDetails) Reset() { *m = NshMapDetails{} } +func (*NshMapDetails) GetMessageName() string { return "nsh_map_details" } +func (*NshMapDetails) GetCrcString() string { return "2fefcf49" } +func (*NshMapDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *NshMapDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.MapIndex + size += 4 // m.NspNsi + size += 4 // m.MappedNspNsi + size += 4 // m.NshAction + size += 4 // m.SwIfIndex + size += 4 // m.RxSwIfIndex + size += 4 // m.NextNode + return size +} +func (m *NshMapDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.MapIndex) + buf.EncodeUint32(m.NspNsi) + buf.EncodeUint32(m.MappedNspNsi) + buf.EncodeUint32(m.NshAction) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(uint32(m.RxSwIfIndex)) + buf.EncodeUint32(m.NextNode) + return buf.Bytes(), nil +} +func (m *NshMapDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.MapIndex = buf.DecodeUint32() + m.NspNsi = buf.DecodeUint32() + m.MappedNspNsi = buf.DecodeUint32() + m.NshAction = buf.DecodeUint32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.RxSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.NextNode = buf.DecodeUint32() + return nil +} + +// NshMapDump defines message 'nsh_map_dump'. +type NshMapDump struct { + MapIndex uint32 `binapi:"u32,name=map_index" json:"map_index,omitempty"` +} + +func (m *NshMapDump) Reset() { *m = NshMapDump{} } +func (*NshMapDump) GetMessageName() string { return "nsh_map_dump" } +func (*NshMapDump) GetCrcString() string { return "8fc06b82" } +func (*NshMapDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *NshMapDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.MapIndex + return size +} +func (m *NshMapDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.MapIndex) + return buf.Bytes(), nil +} +func (m *NshMapDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.MapIndex = buf.DecodeUint32() + return nil +} + +func init() { file_nsh_binapi_init() } +func file_nsh_binapi_init() { + api.RegisterMessage((*NshAddDelEntry)(nil), "nsh_add_del_entry_7dea480b") + api.RegisterMessage((*NshAddDelEntryReply)(nil), "nsh_add_del_entry_reply_6296a9eb") + api.RegisterMessage((*NshAddDelMap)(nil), "nsh_add_del_map_0a0f42b0") + api.RegisterMessage((*NshAddDelMapReply)(nil), "nsh_add_del_map_reply_b2b127ef") + api.RegisterMessage((*NshEntryDetails)(nil), "nsh_entry_details_046fb556") + api.RegisterMessage((*NshEntryDump)(nil), "nsh_entry_dump_cdaf8ccb") + api.RegisterMessage((*NshMapDetails)(nil), "nsh_map_details_2fefcf49") + api.RegisterMessage((*NshMapDump)(nil), "nsh_map_dump_8fc06b82") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*NshAddDelEntry)(nil), + (*NshAddDelEntryReply)(nil), + (*NshAddDelMap)(nil), + (*NshAddDelMapReply)(nil), + (*NshEntryDetails)(nil), + (*NshEntryDump)(nil), + (*NshMapDetails)(nil), + (*NshMapDump)(nil), + } +} diff --git a/binapi/nsh/nsh_rpc.ba.go b/binapi/nsh/nsh_rpc.ba.go new file mode 100644 index 00000000..30f55781 --- /dev/null +++ b/binapi/nsh/nsh_rpc.ba.go @@ -0,0 +1,132 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package nsh + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service nsh. +type RPCService interface { + NshAddDelEntry(ctx context.Context, in *NshAddDelEntry) (*NshAddDelEntryReply, error) + NshAddDelMap(ctx context.Context, in *NshAddDelMap) (*NshAddDelMapReply, error) + NshEntryDump(ctx context.Context, in *NshEntryDump) (RPCService_NshEntryDumpClient, error) + NshMapDump(ctx context.Context, in *NshMapDump) (RPCService_NshMapDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) NshAddDelEntry(ctx context.Context, in *NshAddDelEntry) (*NshAddDelEntryReply, error) { + out := new(NshAddDelEntryReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) NshAddDelMap(ctx context.Context, in *NshAddDelMap) (*NshAddDelMapReply, error) { + out := new(NshAddDelMapReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) NshEntryDump(ctx context.Context, in *NshEntryDump) (RPCService_NshEntryDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_NshEntryDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_NshEntryDumpClient interface { + Recv() (*NshEntryDetails, error) + api.Stream +} + +type serviceClient_NshEntryDumpClient struct { + api.Stream +} + +func (c *serviceClient_NshEntryDumpClient) Recv() (*NshEntryDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *NshEntryDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) NshMapDump(ctx context.Context, in *NshMapDump) (RPCService_NshMapDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_NshMapDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_NshMapDumpClient interface { + Recv() (*NshMapDetails, error) + api.Stream +} + +type serviceClient_NshMapDumpClient struct { + api.Stream +} + +func (c *serviceClient_NshMapDumpClient) Recv() (*NshMapDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *NshMapDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/nsim/nsim.ba.go b/binapi/nsim/nsim.ba.go new file mode 100644 index 00000000..3f07aa7e --- /dev/null +++ b/binapi/nsim/nsim.ba.go @@ -0,0 +1,388 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/nsim.api.json + +// Package nsim contains generated bindings for API file nsim.api. +// +// Contents: +// - 8 messages +package nsim + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "nsim" + APIVersion = "2.2.1" + VersionCrc = 0x3b179b8f +) + +// configure the network delay simulation cross-connect +// - delay_in_usec - microseconds of link delay to simulate +// - average_packet_size - average packet size for wheel sizing +// - bandwidth_in_bits_per_second - bps for wheel sizing +// +// NsimConfigure defines message 'nsim_configure'. +// Deprecated: the message will be removed in the future versions +type NsimConfigure struct { + DelayInUsec uint32 `binapi:"u32,name=delay_in_usec" json:"delay_in_usec,omitempty"` + AveragePacketSize uint32 `binapi:"u32,name=average_packet_size" json:"average_packet_size,omitempty"` + BandwidthInBitsPerSecond uint64 `binapi:"u64,name=bandwidth_in_bits_per_second" json:"bandwidth_in_bits_per_second,omitempty"` + PacketsPerDrop uint32 `binapi:"u32,name=packets_per_drop" json:"packets_per_drop,omitempty"` +} + +func (m *NsimConfigure) Reset() { *m = NsimConfigure{} } +func (*NsimConfigure) GetMessageName() string { return "nsim_configure" } +func (*NsimConfigure) GetCrcString() string { return "16ed400f" } +func (*NsimConfigure) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *NsimConfigure) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.DelayInUsec + size += 4 // m.AveragePacketSize + size += 8 // m.BandwidthInBitsPerSecond + size += 4 // m.PacketsPerDrop + return size +} +func (m *NsimConfigure) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.DelayInUsec) + buf.EncodeUint32(m.AveragePacketSize) + buf.EncodeUint64(m.BandwidthInBitsPerSecond) + buf.EncodeUint32(m.PacketsPerDrop) + return buf.Bytes(), nil +} +func (m *NsimConfigure) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.DelayInUsec = buf.DecodeUint32() + m.AveragePacketSize = buf.DecodeUint32() + m.BandwidthInBitsPerSecond = buf.DecodeUint64() + m.PacketsPerDrop = buf.DecodeUint32() + return nil +} + +// configure the network delay simulation cross-connect +// - delay_in_usec - microseconds of link delay to simulate +// - average_packet_size - average packet size for wheel sizing +// - bandwidth_in_bits_per_second - bps for wheel sizing +// +// NsimConfigure2 defines message 'nsim_configure2'. +type NsimConfigure2 struct { + DelayInUsec uint32 `binapi:"u32,name=delay_in_usec" json:"delay_in_usec,omitempty"` + AveragePacketSize uint32 `binapi:"u32,name=average_packet_size" json:"average_packet_size,omitempty"` + BandwidthInBitsPerSecond uint64 `binapi:"u64,name=bandwidth_in_bits_per_second" json:"bandwidth_in_bits_per_second,omitempty"` + PacketsPerDrop uint32 `binapi:"u32,name=packets_per_drop" json:"packets_per_drop,omitempty"` + PacketsPerReorder uint32 `binapi:"u32,name=packets_per_reorder" json:"packets_per_reorder,omitempty"` +} + +func (m *NsimConfigure2) Reset() { *m = NsimConfigure2{} } +func (*NsimConfigure2) GetMessageName() string { return "nsim_configure2" } +func (*NsimConfigure2) GetCrcString() string { return "64de8ed3" } +func (*NsimConfigure2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *NsimConfigure2) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.DelayInUsec + size += 4 // m.AveragePacketSize + size += 8 // m.BandwidthInBitsPerSecond + size += 4 // m.PacketsPerDrop + size += 4 // m.PacketsPerReorder + return size +} +func (m *NsimConfigure2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.DelayInUsec) + buf.EncodeUint32(m.AveragePacketSize) + buf.EncodeUint64(m.BandwidthInBitsPerSecond) + buf.EncodeUint32(m.PacketsPerDrop) + buf.EncodeUint32(m.PacketsPerReorder) + return buf.Bytes(), nil +} +func (m *NsimConfigure2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.DelayInUsec = buf.DecodeUint32() + m.AveragePacketSize = buf.DecodeUint32() + m.BandwidthInBitsPerSecond = buf.DecodeUint64() + m.PacketsPerDrop = buf.DecodeUint32() + m.PacketsPerReorder = buf.DecodeUint32() + return nil +} + +// NsimConfigure2Reply defines message 'nsim_configure2_reply'. +type NsimConfigure2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *NsimConfigure2Reply) Reset() { *m = NsimConfigure2Reply{} } +func (*NsimConfigure2Reply) GetMessageName() string { return "nsim_configure2_reply" } +func (*NsimConfigure2Reply) GetCrcString() string { return "e8d4e804" } +func (*NsimConfigure2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *NsimConfigure2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *NsimConfigure2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *NsimConfigure2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// NsimConfigureReply defines message 'nsim_configure_reply'. +// Deprecated: the message will be removed in the future versions +type NsimConfigureReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *NsimConfigureReply) Reset() { *m = NsimConfigureReply{} } +func (*NsimConfigureReply) GetMessageName() string { return "nsim_configure_reply" } +func (*NsimConfigureReply) GetCrcString() string { return "e8d4e804" } +func (*NsimConfigureReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *NsimConfigureReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *NsimConfigureReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *NsimConfigureReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// enable / disable the network delay simulation cross-connect +// - enable_disable - enable or disable the feature +// - sw_if_index0 - one interface to cross-connect +// - sw_if_index1 - the other interface to cross-connect +// +// NsimCrossConnectEnableDisable defines message 'nsim_cross_connect_enable_disable'. +type NsimCrossConnectEnableDisable struct { + EnableDisable bool `binapi:"bool,name=enable_disable" json:"enable_disable,omitempty"` + SwIfIndex0 interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index0" json:"sw_if_index0,omitempty"` + SwIfIndex1 interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index1" json:"sw_if_index1,omitempty"` +} + +func (m *NsimCrossConnectEnableDisable) Reset() { *m = NsimCrossConnectEnableDisable{} } +func (*NsimCrossConnectEnableDisable) GetMessageName() string { + return "nsim_cross_connect_enable_disable" +} +func (*NsimCrossConnectEnableDisable) GetCrcString() string { return "9c3ead86" } +func (*NsimCrossConnectEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *NsimCrossConnectEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.EnableDisable + size += 4 // m.SwIfIndex0 + size += 4 // m.SwIfIndex1 + return size +} +func (m *NsimCrossConnectEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.EnableDisable) + buf.EncodeUint32(uint32(m.SwIfIndex0)) + buf.EncodeUint32(uint32(m.SwIfIndex1)) + return buf.Bytes(), nil +} +func (m *NsimCrossConnectEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EnableDisable = buf.DecodeBool() + m.SwIfIndex0 = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.SwIfIndex1 = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// NsimCrossConnectEnableDisableReply defines message 'nsim_cross_connect_enable_disable_reply'. +type NsimCrossConnectEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *NsimCrossConnectEnableDisableReply) Reset() { *m = NsimCrossConnectEnableDisableReply{} } +func (*NsimCrossConnectEnableDisableReply) GetMessageName() string { + return "nsim_cross_connect_enable_disable_reply" +} +func (*NsimCrossConnectEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*NsimCrossConnectEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *NsimCrossConnectEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *NsimCrossConnectEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *NsimCrossConnectEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// enable / disable the network delay simulation output feature +// - enable_disable - enable or disable the feature +// - sw_if_index0 - interface +// +// NsimOutputFeatureEnableDisable defines message 'nsim_output_feature_enable_disable'. +type NsimOutputFeatureEnableDisable struct { + EnableDisable bool `binapi:"bool,name=enable_disable" json:"enable_disable,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *NsimOutputFeatureEnableDisable) Reset() { *m = NsimOutputFeatureEnableDisable{} } +func (*NsimOutputFeatureEnableDisable) GetMessageName() string { + return "nsim_output_feature_enable_disable" +} +func (*NsimOutputFeatureEnableDisable) GetCrcString() string { return "3865946c" } +func (*NsimOutputFeatureEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *NsimOutputFeatureEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.EnableDisable + size += 4 // m.SwIfIndex + return size +} +func (m *NsimOutputFeatureEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.EnableDisable) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *NsimOutputFeatureEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EnableDisable = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// NsimOutputFeatureEnableDisableReply defines message 'nsim_output_feature_enable_disable_reply'. +type NsimOutputFeatureEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *NsimOutputFeatureEnableDisableReply) Reset() { *m = NsimOutputFeatureEnableDisableReply{} } +func (*NsimOutputFeatureEnableDisableReply) GetMessageName() string { + return "nsim_output_feature_enable_disable_reply" +} +func (*NsimOutputFeatureEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*NsimOutputFeatureEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *NsimOutputFeatureEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *NsimOutputFeatureEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *NsimOutputFeatureEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_nsim_binapi_init() } +func file_nsim_binapi_init() { + api.RegisterMessage((*NsimConfigure)(nil), "nsim_configure_16ed400f") + api.RegisterMessage((*NsimConfigure2)(nil), "nsim_configure2_64de8ed3") + api.RegisterMessage((*NsimConfigure2Reply)(nil), "nsim_configure2_reply_e8d4e804") + api.RegisterMessage((*NsimConfigureReply)(nil), "nsim_configure_reply_e8d4e804") + api.RegisterMessage((*NsimCrossConnectEnableDisable)(nil), "nsim_cross_connect_enable_disable_9c3ead86") + api.RegisterMessage((*NsimCrossConnectEnableDisableReply)(nil), "nsim_cross_connect_enable_disable_reply_e8d4e804") + api.RegisterMessage((*NsimOutputFeatureEnableDisable)(nil), "nsim_output_feature_enable_disable_3865946c") + api.RegisterMessage((*NsimOutputFeatureEnableDisableReply)(nil), "nsim_output_feature_enable_disable_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*NsimConfigure)(nil), + (*NsimConfigure2)(nil), + (*NsimConfigure2Reply)(nil), + (*NsimConfigureReply)(nil), + (*NsimCrossConnectEnableDisable)(nil), + (*NsimCrossConnectEnableDisableReply)(nil), + (*NsimOutputFeatureEnableDisable)(nil), + (*NsimOutputFeatureEnableDisableReply)(nil), + } +} diff --git a/binapi/nsim/nsim_rpc.ba.go b/binapi/nsim/nsim_rpc.ba.go new file mode 100644 index 00000000..11aecab3 --- /dev/null +++ b/binapi/nsim/nsim_rpc.ba.go @@ -0,0 +1,61 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package nsim + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service nsim. +type RPCService interface { + NsimConfigure(ctx context.Context, in *NsimConfigure) (*NsimConfigureReply, error) + NsimConfigure2(ctx context.Context, in *NsimConfigure2) (*NsimConfigure2Reply, error) + NsimCrossConnectEnableDisable(ctx context.Context, in *NsimCrossConnectEnableDisable) (*NsimCrossConnectEnableDisableReply, error) + NsimOutputFeatureEnableDisable(ctx context.Context, in *NsimOutputFeatureEnableDisable) (*NsimOutputFeatureEnableDisableReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) NsimConfigure(ctx context.Context, in *NsimConfigure) (*NsimConfigureReply, error) { + out := new(NsimConfigureReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) NsimConfigure2(ctx context.Context, in *NsimConfigure2) (*NsimConfigure2Reply, error) { + out := new(NsimConfigure2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) NsimCrossConnectEnableDisable(ctx context.Context, in *NsimCrossConnectEnableDisable) (*NsimCrossConnectEnableDisableReply, error) { + out := new(NsimCrossConnectEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) NsimOutputFeatureEnableDisable(ctx context.Context, in *NsimOutputFeatureEnableDisable) (*NsimOutputFeatureEnableDisableReply, error) { + out := new(NsimOutputFeatureEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/oddbuf/oddbuf.ba.go b/binapi/oddbuf/oddbuf.ba.go new file mode 100644 index 00000000..bce6a201 --- /dev/null +++ b/binapi/oddbuf/oddbuf.ba.go @@ -0,0 +1,117 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/oddbuf.api.json + +// Package oddbuf contains generated bindings for API file oddbuf.api. +// +// Contents: +// - 2 messages +package oddbuf + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "oddbuf" + APIVersion = "0.1.0" + VersionCrc = 0x3a1a2c50 +) + +// @brief API to enable / disable oddbuf on an interface +// - enable_disable - 1 to enable, 0 to disable the feature +// - sw_if_index - interface handle +// +// OddbufEnableDisable defines message 'oddbuf_enable_disable'. +type OddbufEnableDisable struct { + EnableDisable bool `binapi:"bool,name=enable_disable" json:"enable_disable,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *OddbufEnableDisable) Reset() { *m = OddbufEnableDisable{} } +func (*OddbufEnableDisable) GetMessageName() string { return "oddbuf_enable_disable" } +func (*OddbufEnableDisable) GetCrcString() string { return "3865946c" } +func (*OddbufEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OddbufEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.EnableDisable + size += 4 // m.SwIfIndex + return size +} +func (m *OddbufEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.EnableDisable) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *OddbufEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EnableDisable = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// OddbufEnableDisableReply defines message 'oddbuf_enable_disable_reply'. +type OddbufEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OddbufEnableDisableReply) Reset() { *m = OddbufEnableDisableReply{} } +func (*OddbufEnableDisableReply) GetMessageName() string { return "oddbuf_enable_disable_reply" } +func (*OddbufEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*OddbufEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OddbufEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OddbufEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OddbufEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_oddbuf_binapi_init() } +func file_oddbuf_binapi_init() { + api.RegisterMessage((*OddbufEnableDisable)(nil), "oddbuf_enable_disable_3865946c") + api.RegisterMessage((*OddbufEnableDisableReply)(nil), "oddbuf_enable_disable_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*OddbufEnableDisable)(nil), + (*OddbufEnableDisableReply)(nil), + } +} diff --git a/binapi/oddbuf/oddbuf_rpc.ba.go b/binapi/oddbuf/oddbuf_rpc.ba.go new file mode 100644 index 00000000..54febfc4 --- /dev/null +++ b/binapi/oddbuf/oddbuf_rpc.ba.go @@ -0,0 +1,31 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package oddbuf + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service oddbuf. +type RPCService interface { + OddbufEnableDisable(ctx context.Context, in *OddbufEnableDisable) (*OddbufEnableDisableReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) OddbufEnableDisable(ctx context.Context, in *OddbufEnableDisable) (*OddbufEnableDisableReply, error) { + out := new(OddbufEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/one/one.ba.go b/binapi/one/one.ba.go new file mode 100644 index 00000000..697dc6fa --- /dev/null +++ b/binapi/one/one.ba.go @@ -0,0 +1,4595 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/one.api.json + +// Package one contains generated bindings for API file one.api. +// +// Contents: +// - 2 enums +// - 3 structs +// - 108 messages +package one + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + ethernet_types "github.com/alkiranet/govpp/binapi/ethernet_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + lisp_types "github.com/alkiranet/govpp/binapi/lisp_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "one" + APIVersion = "2.0.0" + VersionCrc = 0x9f64600e +) + +// OneFilter defines enum 'one_filter'. +type OneFilter uint32 + +const ( + ONE_FILTER_API_ALL OneFilter = 0 + ONE_FILTER_API_LOCAL OneFilter = 1 + ONE_FILTER_API_REMOTE OneFilter = 2 +) + +var ( + OneFilter_name = map[uint32]string{ + 0: "ONE_FILTER_API_ALL", + 1: "ONE_FILTER_API_LOCAL", + 2: "ONE_FILTER_API_REMOTE", + } + OneFilter_value = map[string]uint32{ + "ONE_FILTER_API_ALL": 0, + "ONE_FILTER_API_LOCAL": 1, + "ONE_FILTER_API_REMOTE": 2, + } +) + +func (x OneFilter) String() string { + s, ok := OneFilter_name[uint32(x)] + if ok { + return s + } + return "OneFilter(" + strconv.Itoa(int(x)) + ")" +} + +// OneMapMode defines enum 'one_map_mode'. +type OneMapMode uint32 + +const ( + ONE_MAP_MODE_API_DST_ONLY OneMapMode = 0 + ONE_MAP_MODE_API_SRC_DST OneMapMode = 1 +) + +var ( + OneMapMode_name = map[uint32]string{ + 0: "ONE_MAP_MODE_API_DST_ONLY", + 1: "ONE_MAP_MODE_API_SRC_DST", + } + OneMapMode_value = map[string]uint32{ + "ONE_MAP_MODE_API_DST_ONLY": 0, + "ONE_MAP_MODE_API_SRC_DST": 1, + } +) + +func (x OneMapMode) String() string { + s, ok := OneMapMode_name[uint32(x)] + if ok { + return s + } + return "OneMapMode(" + strconv.Itoa(int(x)) + ")" +} + +// OneAdjacency defines type 'one_adjacency'. +type OneAdjacency struct { + Reid lisp_types.Eid `binapi:"eid,name=reid" json:"reid,omitempty"` + Leid lisp_types.Eid `binapi:"eid,name=leid" json:"leid,omitempty"` +} + +// OneL2ArpEntry defines type 'one_l2_arp_entry'. +type OneL2ArpEntry struct { + Mac ethernet_types.MacAddress `binapi:"mac_address,name=mac" json:"mac,omitempty"` + IP4 ip_types.IP4Address `binapi:"ip4_address,name=ip4" json:"ip4,omitempty"` +} + +// OneNdpEntry defines type 'one_ndp_entry'. +type OneNdpEntry struct { + Mac ethernet_types.MacAddress `binapi:"mac_address,name=mac" json:"mac,omitempty"` + IP6 ip_types.IP6Address `binapi:"ip6_address,name=ip6" json:"ip6,omitempty"` +} + +// add or delete ONE adjacency adjacency +// - is_add - add address if non-zero, else delete +// - vni - virtual network instance +// - reid - remote EID +// - leid - local EID +// +// OneAddDelAdjacency defines message 'one_add_del_adjacency'. +type OneAddDelAdjacency struct { + IsAdd uint8 `binapi:"u8,name=is_add" json:"is_add,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + Reid lisp_types.Eid `binapi:"eid,name=reid" json:"reid,omitempty"` + Leid lisp_types.Eid `binapi:"eid,name=leid" json:"leid,omitempty"` +} + +func (m *OneAddDelAdjacency) Reset() { *m = OneAddDelAdjacency{} } +func (*OneAddDelAdjacency) GetMessageName() string { return "one_add_del_adjacency" } +func (*OneAddDelAdjacency) GetCrcString() string { return "9e830312" } +func (*OneAddDelAdjacency) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneAddDelAdjacency) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Vni + size += 1 // m.Reid.Type + size += 1 * 18 // m.Reid.Address + size += 1 // m.Leid.Type + size += 1 * 18 // m.Leid.Address + return size +} +func (m *OneAddDelAdjacency) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.IsAdd) + buf.EncodeUint32(m.Vni) + buf.EncodeUint8(uint8(m.Reid.Type)) + buf.EncodeBytes(m.Reid.Address.XXX_UnionData[:], 18) + buf.EncodeUint8(uint8(m.Leid.Type)) + buf.EncodeBytes(m.Leid.Address.XXX_UnionData[:], 18) + return buf.Bytes(), nil +} +func (m *OneAddDelAdjacency) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeUint8() + m.Vni = buf.DecodeUint32() + m.Reid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Reid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.Leid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Leid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + return nil +} + +// OneAddDelAdjacencyReply defines message 'one_add_del_adjacency_reply'. +type OneAddDelAdjacencyReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneAddDelAdjacencyReply) Reset() { *m = OneAddDelAdjacencyReply{} } +func (*OneAddDelAdjacencyReply) GetMessageName() string { return "one_add_del_adjacency_reply" } +func (*OneAddDelAdjacencyReply) GetCrcString() string { return "e8d4e804" } +func (*OneAddDelAdjacencyReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneAddDelAdjacencyReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneAddDelAdjacencyReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneAddDelAdjacencyReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add/delete L2 ARP entries +// - is_add - add if non-zero; delete otherwise +// - bd - bridge domain +// - entry - ARP entry +// +// OneAddDelL2ArpEntry defines message 'one_add_del_l2_arp_entry'. +type OneAddDelL2ArpEntry struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + Bd uint32 `binapi:"u32,name=bd" json:"bd,omitempty"` + Entry OneL2ArpEntry `binapi:"one_l2_arp_entry,name=entry" json:"entry,omitempty"` +} + +func (m *OneAddDelL2ArpEntry) Reset() { *m = OneAddDelL2ArpEntry{} } +func (*OneAddDelL2ArpEntry) GetMessageName() string { return "one_add_del_l2_arp_entry" } +func (*OneAddDelL2ArpEntry) GetCrcString() string { return "1aa5e8b3" } +func (*OneAddDelL2ArpEntry) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneAddDelL2ArpEntry) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Bd + size += 1 * 6 // m.Entry.Mac + size += 1 * 4 // m.Entry.IP4 + return size +} +func (m *OneAddDelL2ArpEntry) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.Bd) + buf.EncodeBytes(m.Entry.Mac[:], 6) + buf.EncodeBytes(m.Entry.IP4[:], 4) + return buf.Bytes(), nil +} +func (m *OneAddDelL2ArpEntry) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Bd = buf.DecodeUint32() + copy(m.Entry.Mac[:], buf.DecodeBytes(6)) + copy(m.Entry.IP4[:], buf.DecodeBytes(4)) + return nil +} + +// OneAddDelL2ArpEntryReply defines message 'one_add_del_l2_arp_entry_reply'. +type OneAddDelL2ArpEntryReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneAddDelL2ArpEntryReply) Reset() { *m = OneAddDelL2ArpEntryReply{} } +func (*OneAddDelL2ArpEntryReply) GetMessageName() string { return "one_add_del_l2_arp_entry_reply" } +func (*OneAddDelL2ArpEntryReply) GetCrcString() string { return "e8d4e804" } +func (*OneAddDelL2ArpEntryReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneAddDelL2ArpEntryReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneAddDelL2ArpEntryReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneAddDelL2ArpEntryReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// add or delete ONE eid-table +// - is_add - add address if non-zero, else delete +// - eid - endpoint identifier +// - locator_set_name - name of locator_set to add/del eid-table +// - vni - virtual network instance +// - key - secret key +// +// OneAddDelLocalEid defines message 'one_add_del_local_eid'. +type OneAddDelLocalEid struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + Eid lisp_types.Eid `binapi:"eid,name=eid" json:"eid,omitempty"` + LocatorSetName string `binapi:"string[64],name=locator_set_name" json:"locator_set_name,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + Key lisp_types.HmacKey `binapi:"hmac_key,name=key" json:"key,omitempty"` +} + +func (m *OneAddDelLocalEid) Reset() { *m = OneAddDelLocalEid{} } +func (*OneAddDelLocalEid) GetMessageName() string { return "one_add_del_local_eid" } +func (*OneAddDelLocalEid) GetCrcString() string { return "4e5a83a2" } +func (*OneAddDelLocalEid) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneAddDelLocalEid) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.Eid.Type + size += 1 * 18 // m.Eid.Address + size += 64 // m.LocatorSetName + size += 4 // m.Vni + size += 1 // m.Key.ID + size += 1 * 64 // m.Key.Key + return size +} +func (m *OneAddDelLocalEid) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint8(uint8(m.Eid.Type)) + buf.EncodeBytes(m.Eid.Address.XXX_UnionData[:], 18) + buf.EncodeString(m.LocatorSetName, 64) + buf.EncodeUint32(m.Vni) + buf.EncodeUint8(uint8(m.Key.ID)) + buf.EncodeBytes(m.Key.Key, 64) + return buf.Bytes(), nil +} +func (m *OneAddDelLocalEid) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Eid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Eid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.LocatorSetName = buf.DecodeString(64) + m.Vni = buf.DecodeUint32() + m.Key.ID = lisp_types.HmacKeyID(buf.DecodeUint8()) + m.Key.Key = make([]byte, 64) + copy(m.Key.Key, buf.DecodeBytes(len(m.Key.Key))) + return nil +} + +// OneAddDelLocalEidReply defines message 'one_add_del_local_eid_reply'. +type OneAddDelLocalEidReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneAddDelLocalEidReply) Reset() { *m = OneAddDelLocalEidReply{} } +func (*OneAddDelLocalEidReply) GetMessageName() string { return "one_add_del_local_eid_reply" } +func (*OneAddDelLocalEidReply) GetCrcString() string { return "e8d4e804" } +func (*OneAddDelLocalEidReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneAddDelLocalEidReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneAddDelLocalEidReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneAddDelLocalEidReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// add or delete locator for locator set +// - is_add - add address if non-zero, else delete +// - locator_set_name - name of locator_set to add/del locator +// - sw_if_index - index of the interface +// - priority - priority of the locator +// - weight - weight of the locator +// +// OneAddDelLocator defines message 'one_add_del_locator'. +type OneAddDelLocator struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + LocatorSetName string `binapi:"string[64],name=locator_set_name" json:"locator_set_name,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Priority uint8 `binapi:"u8,name=priority" json:"priority,omitempty"` + Weight uint8 `binapi:"u8,name=weight" json:"weight,omitempty"` +} + +func (m *OneAddDelLocator) Reset() { *m = OneAddDelLocator{} } +func (*OneAddDelLocator) GetMessageName() string { return "one_add_del_locator" } +func (*OneAddDelLocator) GetCrcString() string { return "af4d8f13" } +func (*OneAddDelLocator) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneAddDelLocator) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 64 // m.LocatorSetName + size += 4 // m.SwIfIndex + size += 1 // m.Priority + size += 1 // m.Weight + return size +} +func (m *OneAddDelLocator) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeString(m.LocatorSetName, 64) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(m.Priority) + buf.EncodeUint8(m.Weight) + return buf.Bytes(), nil +} +func (m *OneAddDelLocator) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.LocatorSetName = buf.DecodeString(64) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Priority = buf.DecodeUint8() + m.Weight = buf.DecodeUint8() + return nil +} + +// OneAddDelLocatorReply defines message 'one_add_del_locator_reply'. +type OneAddDelLocatorReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneAddDelLocatorReply) Reset() { *m = OneAddDelLocatorReply{} } +func (*OneAddDelLocatorReply) GetMessageName() string { return "one_add_del_locator_reply" } +func (*OneAddDelLocatorReply) GetCrcString() string { return "e8d4e804" } +func (*OneAddDelLocatorReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneAddDelLocatorReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneAddDelLocatorReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneAddDelLocatorReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// add or delete locator_set +// - is_add - add address if non-zero, else delete +// - locator_set_name - locator name +// - locator_num - number of locators +// - locators - locator records +// +// OneAddDelLocatorSet defines message 'one_add_del_locator_set'. +type OneAddDelLocatorSet struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + LocatorSetName string `binapi:"string[64],name=locator_set_name" json:"locator_set_name,omitempty"` + LocatorNum uint32 `binapi:"u32,name=locator_num" json:"-"` + Locators []lisp_types.LocalLocator `binapi:"local_locator[locator_num],name=locators" json:"locators,omitempty"` +} + +func (m *OneAddDelLocatorSet) Reset() { *m = OneAddDelLocatorSet{} } +func (*OneAddDelLocatorSet) GetMessageName() string { return "one_add_del_locator_set" } +func (*OneAddDelLocatorSet) GetCrcString() string { return "6fcd6471" } +func (*OneAddDelLocatorSet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneAddDelLocatorSet) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 64 // m.LocatorSetName + size += 4 // m.LocatorNum + for j1 := 0; j1 < len(m.Locators); j1++ { + var s1 lisp_types.LocalLocator + _ = s1 + if j1 < len(m.Locators) { + s1 = m.Locators[j1] + } + size += 4 // s1.SwIfIndex + size += 1 // s1.Priority + size += 1 // s1.Weight + } + return size +} +func (m *OneAddDelLocatorSet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeString(m.LocatorSetName, 64) + buf.EncodeUint32(uint32(len(m.Locators))) + for j0 := 0; j0 < len(m.Locators); j0++ { + var v0 lisp_types.LocalLocator // Locators + if j0 < len(m.Locators) { + v0 = m.Locators[j0] + } + buf.EncodeUint32(uint32(v0.SwIfIndex)) + buf.EncodeUint8(v0.Priority) + buf.EncodeUint8(v0.Weight) + } + return buf.Bytes(), nil +} +func (m *OneAddDelLocatorSet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.LocatorSetName = buf.DecodeString(64) + m.LocatorNum = buf.DecodeUint32() + m.Locators = make([]lisp_types.LocalLocator, m.LocatorNum) + for j0 := 0; j0 < len(m.Locators); j0++ { + m.Locators[j0].SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Locators[j0].Priority = buf.DecodeUint8() + m.Locators[j0].Weight = buf.DecodeUint8() + } + return nil +} + +// Reply for locator_set add/del +// - retval - return code +// - ls_index - locator set index +// +// OneAddDelLocatorSetReply defines message 'one_add_del_locator_set_reply'. +type OneAddDelLocatorSetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + LsIndex uint32 `binapi:"u32,name=ls_index" json:"ls_index,omitempty"` +} + +func (m *OneAddDelLocatorSetReply) Reset() { *m = OneAddDelLocatorSetReply{} } +func (*OneAddDelLocatorSetReply) GetMessageName() string { return "one_add_del_locator_set_reply" } +func (*OneAddDelLocatorSetReply) GetCrcString() string { return "b6666db4" } +func (*OneAddDelLocatorSetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneAddDelLocatorSetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.LsIndex + return size +} +func (m *OneAddDelLocatorSetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.LsIndex) + return buf.Bytes(), nil +} +func (m *OneAddDelLocatorSetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.LsIndex = buf.DecodeUint32() + return nil +} + +// add or delete map request itr rlocs +// - is_add - add address if non-zero, else delete +// - locator_set_name - locator set name +// +// OneAddDelMapRequestItrRlocs defines message 'one_add_del_map_request_itr_rlocs'. +type OneAddDelMapRequestItrRlocs struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + LocatorSetName string `binapi:"string[64],name=locator_set_name" json:"locator_set_name,omitempty"` +} + +func (m *OneAddDelMapRequestItrRlocs) Reset() { *m = OneAddDelMapRequestItrRlocs{} } +func (*OneAddDelMapRequestItrRlocs) GetMessageName() string { + return "one_add_del_map_request_itr_rlocs" +} +func (*OneAddDelMapRequestItrRlocs) GetCrcString() string { return "6be88e45" } +func (*OneAddDelMapRequestItrRlocs) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneAddDelMapRequestItrRlocs) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 64 // m.LocatorSetName + return size +} +func (m *OneAddDelMapRequestItrRlocs) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeString(m.LocatorSetName, 64) + return buf.Bytes(), nil +} +func (m *OneAddDelMapRequestItrRlocs) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.LocatorSetName = buf.DecodeString(64) + return nil +} + +// OneAddDelMapRequestItrRlocsReply defines message 'one_add_del_map_request_itr_rlocs_reply'. +type OneAddDelMapRequestItrRlocsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneAddDelMapRequestItrRlocsReply) Reset() { *m = OneAddDelMapRequestItrRlocsReply{} } +func (*OneAddDelMapRequestItrRlocsReply) GetMessageName() string { + return "one_add_del_map_request_itr_rlocs_reply" +} +func (*OneAddDelMapRequestItrRlocsReply) GetCrcString() string { return "e8d4e804" } +func (*OneAddDelMapRequestItrRlocsReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneAddDelMapRequestItrRlocsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneAddDelMapRequestItrRlocsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneAddDelMapRequestItrRlocsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// add or delete map-resolver +// - is_add - add address if non-zero, else delete +// - is_ipv6 - if non-zero the address is ipv6, else ipv4 +// - ip_address - array of address bytes +// +// OneAddDelMapResolver defines message 'one_add_del_map_resolver'. +type OneAddDelMapResolver struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` +} + +func (m *OneAddDelMapResolver) Reset() { *m = OneAddDelMapResolver{} } +func (*OneAddDelMapResolver) GetMessageName() string { return "one_add_del_map_resolver" } +func (*OneAddDelMapResolver) GetCrcString() string { return "ce19e32d" } +func (*OneAddDelMapResolver) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneAddDelMapResolver) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + return size +} +func (m *OneAddDelMapResolver) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *OneAddDelMapResolver) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// OneAddDelMapResolverReply defines message 'one_add_del_map_resolver_reply'. +type OneAddDelMapResolverReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneAddDelMapResolverReply) Reset() { *m = OneAddDelMapResolverReply{} } +func (*OneAddDelMapResolverReply) GetMessageName() string { return "one_add_del_map_resolver_reply" } +func (*OneAddDelMapResolverReply) GetCrcString() string { return "e8d4e804" } +func (*OneAddDelMapResolverReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneAddDelMapResolverReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneAddDelMapResolverReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneAddDelMapResolverReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add/delete map server +// - is_add - add address if non-zero; delete otherwise +// - is_ipv6 - if non-zero the address is ipv6, else ipv4 +// - ip_address - map server IP address +// +// OneAddDelMapServer defines message 'one_add_del_map_server'. +type OneAddDelMapServer struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` +} + +func (m *OneAddDelMapServer) Reset() { *m = OneAddDelMapServer{} } +func (*OneAddDelMapServer) GetMessageName() string { return "one_add_del_map_server" } +func (*OneAddDelMapServer) GetCrcString() string { return "ce19e32d" } +func (*OneAddDelMapServer) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneAddDelMapServer) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + return size +} +func (m *OneAddDelMapServer) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *OneAddDelMapServer) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// OneAddDelMapServerReply defines message 'one_add_del_map_server_reply'. +type OneAddDelMapServerReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneAddDelMapServerReply) Reset() { *m = OneAddDelMapServerReply{} } +func (*OneAddDelMapServerReply) GetMessageName() string { return "one_add_del_map_server_reply" } +func (*OneAddDelMapServerReply) GetCrcString() string { return "e8d4e804" } +func (*OneAddDelMapServerReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneAddDelMapServerReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneAddDelMapServerReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneAddDelMapServerReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// OneAddDelNdpEntry defines message 'one_add_del_ndp_entry'. +type OneAddDelNdpEntry struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + Bd uint32 `binapi:"u32,name=bd" json:"bd,omitempty"` + Entry OneNdpEntry `binapi:"one_ndp_entry,name=entry" json:"entry,omitempty"` +} + +func (m *OneAddDelNdpEntry) Reset() { *m = OneAddDelNdpEntry{} } +func (*OneAddDelNdpEntry) GetMessageName() string { return "one_add_del_ndp_entry" } +func (*OneAddDelNdpEntry) GetCrcString() string { return "0f8a287c" } +func (*OneAddDelNdpEntry) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneAddDelNdpEntry) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Bd + size += 1 * 6 // m.Entry.Mac + size += 1 * 16 // m.Entry.IP6 + return size +} +func (m *OneAddDelNdpEntry) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.Bd) + buf.EncodeBytes(m.Entry.Mac[:], 6) + buf.EncodeBytes(m.Entry.IP6[:], 16) + return buf.Bytes(), nil +} +func (m *OneAddDelNdpEntry) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Bd = buf.DecodeUint32() + copy(m.Entry.Mac[:], buf.DecodeBytes(6)) + copy(m.Entry.IP6[:], buf.DecodeBytes(16)) + return nil +} + +// OneAddDelNdpEntryReply defines message 'one_add_del_ndp_entry_reply'. +type OneAddDelNdpEntryReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneAddDelNdpEntryReply) Reset() { *m = OneAddDelNdpEntryReply{} } +func (*OneAddDelNdpEntryReply) GetMessageName() string { return "one_add_del_ndp_entry_reply" } +func (*OneAddDelNdpEntryReply) GetCrcString() string { return "e8d4e804" } +func (*OneAddDelNdpEntryReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneAddDelNdpEntryReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneAddDelNdpEntryReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneAddDelNdpEntryReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// add or delete remote static mapping +// - is_add - add address if non-zero, else delete +// - is_src_dst - flag indicating src/dst based routing policy +// - del_all - if set, delete all remote mappings +// - vni - virtual network instance +// - action - negative map-reply action +// - deid - dst EID +// - seid - src EID, valid only if is_src_dst is enabled +// - rloc_num - number of remote locators +// - rlocs - remote locator records +// +// OneAddDelRemoteMapping defines message 'one_add_del_remote_mapping'. +type OneAddDelRemoteMapping struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + IsSrcDst bool `binapi:"bool,name=is_src_dst" json:"is_src_dst,omitempty"` + DelAll bool `binapi:"bool,name=del_all" json:"del_all,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + Action uint8 `binapi:"u8,name=action" json:"action,omitempty"` + Deid lisp_types.Eid `binapi:"eid,name=deid" json:"deid,omitempty"` + Seid lisp_types.Eid `binapi:"eid,name=seid" json:"seid,omitempty"` + RlocNum uint32 `binapi:"u32,name=rloc_num" json:"-"` + Rlocs []lisp_types.RemoteLocator `binapi:"remote_locator[rloc_num],name=rlocs" json:"rlocs,omitempty"` +} + +func (m *OneAddDelRemoteMapping) Reset() { *m = OneAddDelRemoteMapping{} } +func (*OneAddDelRemoteMapping) GetMessageName() string { return "one_add_del_remote_mapping" } +func (*OneAddDelRemoteMapping) GetCrcString() string { return "6d5c789e" } +func (*OneAddDelRemoteMapping) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneAddDelRemoteMapping) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.IsSrcDst + size += 1 // m.DelAll + size += 4 // m.Vni + size += 1 // m.Action + size += 1 // m.Deid.Type + size += 1 * 18 // m.Deid.Address + size += 1 // m.Seid.Type + size += 1 * 18 // m.Seid.Address + size += 4 // m.RlocNum + for j1 := 0; j1 < len(m.Rlocs); j1++ { + var s1 lisp_types.RemoteLocator + _ = s1 + if j1 < len(m.Rlocs) { + s1 = m.Rlocs[j1] + } + size += 1 // s1.Priority + size += 1 // s1.Weight + size += 1 // s1.IPAddress.Af + size += 1 * 16 // s1.IPAddress.Un + } + return size +} +func (m *OneAddDelRemoteMapping) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeBool(m.IsSrcDst) + buf.EncodeBool(m.DelAll) + buf.EncodeUint32(m.Vni) + buf.EncodeUint8(m.Action) + buf.EncodeUint8(uint8(m.Deid.Type)) + buf.EncodeBytes(m.Deid.Address.XXX_UnionData[:], 18) + buf.EncodeUint8(uint8(m.Seid.Type)) + buf.EncodeBytes(m.Seid.Address.XXX_UnionData[:], 18) + buf.EncodeUint32(uint32(len(m.Rlocs))) + for j0 := 0; j0 < len(m.Rlocs); j0++ { + var v0 lisp_types.RemoteLocator // Rlocs + if j0 < len(m.Rlocs) { + v0 = m.Rlocs[j0] + } + buf.EncodeUint8(v0.Priority) + buf.EncodeUint8(v0.Weight) + buf.EncodeUint8(uint8(v0.IPAddress.Af)) + buf.EncodeBytes(v0.IPAddress.Un.XXX_UnionData[:], 16) + } + return buf.Bytes(), nil +} +func (m *OneAddDelRemoteMapping) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.IsSrcDst = buf.DecodeBool() + m.DelAll = buf.DecodeBool() + m.Vni = buf.DecodeUint32() + m.Action = buf.DecodeUint8() + m.Deid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Deid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.Seid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Seid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.RlocNum = buf.DecodeUint32() + m.Rlocs = make([]lisp_types.RemoteLocator, m.RlocNum) + for j0 := 0; j0 < len(m.Rlocs); j0++ { + m.Rlocs[j0].Priority = buf.DecodeUint8() + m.Rlocs[j0].Weight = buf.DecodeUint8() + m.Rlocs[j0].IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Rlocs[j0].IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + } + return nil +} + +// OneAddDelRemoteMappingReply defines message 'one_add_del_remote_mapping_reply'. +type OneAddDelRemoteMappingReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneAddDelRemoteMappingReply) Reset() { *m = OneAddDelRemoteMappingReply{} } +func (*OneAddDelRemoteMappingReply) GetMessageName() string { + return "one_add_del_remote_mapping_reply" +} +func (*OneAddDelRemoteMappingReply) GetCrcString() string { return "e8d4e804" } +func (*OneAddDelRemoteMappingReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneAddDelRemoteMappingReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneAddDelRemoteMappingReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneAddDelRemoteMappingReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Request for ONE adjacencies +// - vni - filter adjacencies by VNI +// +// OneAdjacenciesGet defines message 'one_adjacencies_get'. +type OneAdjacenciesGet struct { + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` +} + +func (m *OneAdjacenciesGet) Reset() { *m = OneAdjacenciesGet{} } +func (*OneAdjacenciesGet) GetMessageName() string { return "one_adjacencies_get" } +func (*OneAdjacenciesGet) GetCrcString() string { return "8d1f2fe9" } +func (*OneAdjacenciesGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneAdjacenciesGet) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Vni + return size +} +func (m *OneAdjacenciesGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Vni) + return buf.Bytes(), nil +} +func (m *OneAdjacenciesGet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Vni = buf.DecodeUint32() + return nil +} + +// ONE adjacency reply +// - count - number of adjacencies +// - adjacencies - array of adjacencies +// +// OneAdjacenciesGetReply defines message 'one_adjacencies_get_reply'. +type OneAdjacenciesGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + Adjacencies []OneAdjacency `binapi:"one_adjacency[count],name=adjacencies" json:"adjacencies,omitempty"` +} + +func (m *OneAdjacenciesGetReply) Reset() { *m = OneAdjacenciesGetReply{} } +func (*OneAdjacenciesGetReply) GetMessageName() string { return "one_adjacencies_get_reply" } +func (*OneAdjacenciesGetReply) GetCrcString() string { return "085bab89" } +func (*OneAdjacenciesGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneAdjacenciesGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + for j1 := 0; j1 < len(m.Adjacencies); j1++ { + var s1 OneAdjacency + _ = s1 + if j1 < len(m.Adjacencies) { + s1 = m.Adjacencies[j1] + } + size += 1 // s1.Reid.Type + size += 1 * 18 // s1.Reid.Address + size += 1 // s1.Leid.Type + size += 1 * 18 // s1.Leid.Address + } + return size +} +func (m *OneAdjacenciesGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.Adjacencies))) + for j0 := 0; j0 < len(m.Adjacencies); j0++ { + var v0 OneAdjacency // Adjacencies + if j0 < len(m.Adjacencies) { + v0 = m.Adjacencies[j0] + } + buf.EncodeUint8(uint8(v0.Reid.Type)) + buf.EncodeBytes(v0.Reid.Address.XXX_UnionData[:], 18) + buf.EncodeUint8(uint8(v0.Leid.Type)) + buf.EncodeBytes(v0.Leid.Address.XXX_UnionData[:], 18) + } + return buf.Bytes(), nil +} +func (m *OneAdjacenciesGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.Adjacencies = make([]OneAdjacency, m.Count) + for j0 := 0; j0 < len(m.Adjacencies); j0++ { + m.Adjacencies[j0].Reid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Adjacencies[j0].Reid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.Adjacencies[j0].Leid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Adjacencies[j0].Leid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + } + return nil +} + +// map/unmap vni/bd_index to vrf +// - is_add - add or delete mapping +// - dp_table - virtual network id/bridge domain index +// - vrf - vrf +// - is_l2 - is l2 +// +// OneEidTableAddDelMap defines message 'one_eid_table_add_del_map'. +type OneEidTableAddDelMap struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + DpTable uint32 `binapi:"u32,name=dp_table" json:"dp_table,omitempty"` + IsL2 bool `binapi:"bool,name=is_l2" json:"is_l2,omitempty"` +} + +func (m *OneEidTableAddDelMap) Reset() { *m = OneEidTableAddDelMap{} } +func (*OneEidTableAddDelMap) GetMessageName() string { return "one_eid_table_add_del_map" } +func (*OneEidTableAddDelMap) GetCrcString() string { return "9481416b" } +func (*OneEidTableAddDelMap) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneEidTableAddDelMap) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Vni + size += 4 // m.DpTable + size += 1 // m.IsL2 + return size +} +func (m *OneEidTableAddDelMap) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.Vni) + buf.EncodeUint32(m.DpTable) + buf.EncodeBool(m.IsL2) + return buf.Bytes(), nil +} +func (m *OneEidTableAddDelMap) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Vni = buf.DecodeUint32() + m.DpTable = buf.DecodeUint32() + m.IsL2 = buf.DecodeBool() + return nil +} + +// OneEidTableAddDelMapReply defines message 'one_eid_table_add_del_map_reply'. +type OneEidTableAddDelMapReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneEidTableAddDelMapReply) Reset() { *m = OneEidTableAddDelMapReply{} } +func (*OneEidTableAddDelMapReply) GetMessageName() string { return "one_eid_table_add_del_map_reply" } +func (*OneEidTableAddDelMapReply) GetCrcString() string { return "e8d4e804" } +func (*OneEidTableAddDelMapReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneEidTableAddDelMapReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneEidTableAddDelMapReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneEidTableAddDelMapReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// // FIXME: action, authoritative +// OneEidTableDetails defines message 'one_eid_table_details'. +type OneEidTableDetails struct { + LocatorSetIndex uint32 `binapi:"u32,name=locator_set_index" json:"locator_set_index,omitempty"` + Action uint8 `binapi:"u8,name=action" json:"action,omitempty"` + IsLocal bool `binapi:"bool,name=is_local" json:"is_local,omitempty"` + IsSrcDst bool `binapi:"bool,name=is_src_dst" json:"is_src_dst,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + Deid lisp_types.Eid `binapi:"eid,name=deid" json:"deid,omitempty"` + Seid lisp_types.Eid `binapi:"eid,name=seid" json:"seid,omitempty"` + TTL uint32 `binapi:"u32,name=ttl" json:"ttl,omitempty"` + Authoritative uint8 `binapi:"u8,name=authoritative" json:"authoritative,omitempty"` + Key lisp_types.HmacKey `binapi:"hmac_key,name=key" json:"key,omitempty"` +} + +func (m *OneEidTableDetails) Reset() { *m = OneEidTableDetails{} } +func (*OneEidTableDetails) GetMessageName() string { return "one_eid_table_details" } +func (*OneEidTableDetails) GetCrcString() string { return "1c29f792" } +func (*OneEidTableDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneEidTableDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.LocatorSetIndex + size += 1 // m.Action + size += 1 // m.IsLocal + size += 1 // m.IsSrcDst + size += 4 // m.Vni + size += 1 // m.Deid.Type + size += 1 * 18 // m.Deid.Address + size += 1 // m.Seid.Type + size += 1 * 18 // m.Seid.Address + size += 4 // m.TTL + size += 1 // m.Authoritative + size += 1 // m.Key.ID + size += 1 * 64 // m.Key.Key + return size +} +func (m *OneEidTableDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.LocatorSetIndex) + buf.EncodeUint8(m.Action) + buf.EncodeBool(m.IsLocal) + buf.EncodeBool(m.IsSrcDst) + buf.EncodeUint32(m.Vni) + buf.EncodeUint8(uint8(m.Deid.Type)) + buf.EncodeBytes(m.Deid.Address.XXX_UnionData[:], 18) + buf.EncodeUint8(uint8(m.Seid.Type)) + buf.EncodeBytes(m.Seid.Address.XXX_UnionData[:], 18) + buf.EncodeUint32(m.TTL) + buf.EncodeUint8(m.Authoritative) + buf.EncodeUint8(uint8(m.Key.ID)) + buf.EncodeBytes(m.Key.Key, 64) + return buf.Bytes(), nil +} +func (m *OneEidTableDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.LocatorSetIndex = buf.DecodeUint32() + m.Action = buf.DecodeUint8() + m.IsLocal = buf.DecodeBool() + m.IsSrcDst = buf.DecodeBool() + m.Vni = buf.DecodeUint32() + m.Deid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Deid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.Seid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Seid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.TTL = buf.DecodeUint32() + m.Authoritative = buf.DecodeUint8() + m.Key.ID = lisp_types.HmacKeyID(buf.DecodeUint8()) + m.Key.Key = make([]byte, 64) + copy(m.Key.Key, buf.DecodeBytes(len(m.Key.Key))) + return nil +} + +// Request for eid table summary status +// - eid_set - if non-zero request info about specific mapping +// - vni - virtual network instance; valid only if eid_set != 0 +// - eid - endpoint identifier +// - filter - filter type; +// Support values: +// 0: all eid +// 1: local eid +// 2: remote eid +// +// OneEidTableDump defines message 'one_eid_table_dump'. +type OneEidTableDump struct { + EidSet bool `binapi:"bool,name=eid_set" json:"eid_set,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + Eid lisp_types.Eid `binapi:"eid,name=eid" json:"eid,omitempty"` + Filter OneFilter `binapi:"one_filter,name=filter" json:"filter,omitempty"` +} + +func (m *OneEidTableDump) Reset() { *m = OneEidTableDump{} } +func (*OneEidTableDump) GetMessageName() string { return "one_eid_table_dump" } +func (*OneEidTableDump) GetCrcString() string { return "bd190269" } +func (*OneEidTableDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneEidTableDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.EidSet + size += 4 // m.Vni + size += 1 // m.Eid.Type + size += 1 * 18 // m.Eid.Address + size += 4 // m.Filter + return size +} +func (m *OneEidTableDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.EidSet) + buf.EncodeUint32(m.Vni) + buf.EncodeUint8(uint8(m.Eid.Type)) + buf.EncodeBytes(m.Eid.Address.XXX_UnionData[:], 18) + buf.EncodeUint32(uint32(m.Filter)) + return buf.Bytes(), nil +} +func (m *OneEidTableDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EidSet = buf.DecodeBool() + m.Vni = buf.DecodeUint32() + m.Eid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Eid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.Filter = OneFilter(buf.DecodeUint32()) + return nil +} + +// Shows relationship between vni and vrf/bd +// - dp_table - VRF index or bridge domain index +// - vni - virtual network instance +// +// OneEidTableMapDetails defines message 'one_eid_table_map_details'. +type OneEidTableMapDetails struct { + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + DpTable uint32 `binapi:"u32,name=dp_table" json:"dp_table,omitempty"` +} + +func (m *OneEidTableMapDetails) Reset() { *m = OneEidTableMapDetails{} } +func (*OneEidTableMapDetails) GetMessageName() string { return "one_eid_table_map_details" } +func (*OneEidTableMapDetails) GetCrcString() string { return "0b6859e2" } +func (*OneEidTableMapDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneEidTableMapDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Vni + size += 4 // m.DpTable + return size +} +func (m *OneEidTableMapDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Vni) + buf.EncodeUint32(m.DpTable) + return buf.Bytes(), nil +} +func (m *OneEidTableMapDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Vni = buf.DecodeUint32() + m.DpTable = buf.DecodeUint32() + return nil +} + +// Request for one_eid_table_map_details +// - is_l2 - if set dump vni/bd mappings else vni/vrf +// +// OneEidTableMapDump defines message 'one_eid_table_map_dump'. +type OneEidTableMapDump struct { + IsL2 bool `binapi:"bool,name=is_l2" json:"is_l2,omitempty"` +} + +func (m *OneEidTableMapDump) Reset() { *m = OneEidTableMapDump{} } +func (*OneEidTableMapDump) GetMessageName() string { return "one_eid_table_map_dump" } +func (*OneEidTableMapDump) GetCrcString() string { return "d6cf0c3d" } +func (*OneEidTableMapDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneEidTableMapDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsL2 + return size +} +func (m *OneEidTableMapDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsL2) + return buf.Bytes(), nil +} +func (m *OneEidTableMapDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsL2 = buf.DecodeBool() + return nil +} + +// reply to one_eid_table_vni_dump +// - vni - virtual network instance +// +// OneEidTableVniDetails defines message 'one_eid_table_vni_details'. +type OneEidTableVniDetails struct { + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` +} + +func (m *OneEidTableVniDetails) Reset() { *m = OneEidTableVniDetails{} } +func (*OneEidTableVniDetails) GetMessageName() string { return "one_eid_table_vni_details" } +func (*OneEidTableVniDetails) GetCrcString() string { return "64abc01e" } +func (*OneEidTableVniDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneEidTableVniDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Vni + return size +} +func (m *OneEidTableVniDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Vni) + return buf.Bytes(), nil +} +func (m *OneEidTableVniDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Vni = buf.DecodeUint32() + return nil +} + +// Dumps all VNIs used in mappings +// OneEidTableVniDump defines message 'one_eid_table_vni_dump'. +type OneEidTableVniDump struct{} + +func (m *OneEidTableVniDump) Reset() { *m = OneEidTableVniDump{} } +func (*OneEidTableVniDump) GetMessageName() string { return "one_eid_table_vni_dump" } +func (*OneEidTableVniDump) GetCrcString() string { return "51077d14" } +func (*OneEidTableVniDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneEidTableVniDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *OneEidTableVniDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *OneEidTableVniDump) Unmarshal(b []byte) error { + return nil +} + +// enable or disable ONE feature +// - is_enable - enable protocol if non-zero, else disable +// +// OneEnableDisable defines message 'one_enable_disable'. +type OneEnableDisable struct { + IsEnable bool `binapi:"bool,name=is_enable,default=true" json:"is_enable,omitempty"` +} + +func (m *OneEnableDisable) Reset() { *m = OneEnableDisable{} } +func (*OneEnableDisable) GetMessageName() string { return "one_enable_disable" } +func (*OneEnableDisable) GetCrcString() string { return "c264d7bf" } +func (*OneEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsEnable + return size +} +func (m *OneEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *OneEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsEnable = buf.DecodeBool() + return nil +} + +// OneEnableDisablePetrMode defines message 'one_enable_disable_petr_mode'. +type OneEnableDisablePetrMode struct { + IsEnable bool `binapi:"bool,name=is_enable,default=true" json:"is_enable,omitempty"` +} + +func (m *OneEnableDisablePetrMode) Reset() { *m = OneEnableDisablePetrMode{} } +func (*OneEnableDisablePetrMode) GetMessageName() string { return "one_enable_disable_petr_mode" } +func (*OneEnableDisablePetrMode) GetCrcString() string { return "c264d7bf" } +func (*OneEnableDisablePetrMode) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneEnableDisablePetrMode) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsEnable + return size +} +func (m *OneEnableDisablePetrMode) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *OneEnableDisablePetrMode) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsEnable = buf.DecodeBool() + return nil +} + +// OneEnableDisablePetrModeReply defines message 'one_enable_disable_petr_mode_reply'. +type OneEnableDisablePetrModeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneEnableDisablePetrModeReply) Reset() { *m = OneEnableDisablePetrModeReply{} } +func (*OneEnableDisablePetrModeReply) GetMessageName() string { + return "one_enable_disable_petr_mode_reply" +} +func (*OneEnableDisablePetrModeReply) GetCrcString() string { return "e8d4e804" } +func (*OneEnableDisablePetrModeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneEnableDisablePetrModeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneEnableDisablePetrModeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneEnableDisablePetrModeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// OneEnableDisablePitrMode defines message 'one_enable_disable_pitr_mode'. +type OneEnableDisablePitrMode struct { + IsEnable bool `binapi:"bool,name=is_enable,default=true" json:"is_enable,omitempty"` +} + +func (m *OneEnableDisablePitrMode) Reset() { *m = OneEnableDisablePitrMode{} } +func (*OneEnableDisablePitrMode) GetMessageName() string { return "one_enable_disable_pitr_mode" } +func (*OneEnableDisablePitrMode) GetCrcString() string { return "c264d7bf" } +func (*OneEnableDisablePitrMode) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneEnableDisablePitrMode) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsEnable + return size +} +func (m *OneEnableDisablePitrMode) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *OneEnableDisablePitrMode) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsEnable = buf.DecodeBool() + return nil +} + +// OneEnableDisablePitrModeReply defines message 'one_enable_disable_pitr_mode_reply'. +type OneEnableDisablePitrModeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneEnableDisablePitrModeReply) Reset() { *m = OneEnableDisablePitrModeReply{} } +func (*OneEnableDisablePitrModeReply) GetMessageName() string { + return "one_enable_disable_pitr_mode_reply" +} +func (*OneEnableDisablePitrModeReply) GetCrcString() string { return "e8d4e804" } +func (*OneEnableDisablePitrModeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneEnableDisablePitrModeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneEnableDisablePitrModeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneEnableDisablePitrModeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// OneEnableDisableReply defines message 'one_enable_disable_reply'. +type OneEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneEnableDisableReply) Reset() { *m = OneEnableDisableReply{} } +func (*OneEnableDisableReply) GetMessageName() string { return "one_enable_disable_reply" } +func (*OneEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*OneEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// OneEnableDisableXtrMode defines message 'one_enable_disable_xtr_mode'. +type OneEnableDisableXtrMode struct { + IsEnable bool `binapi:"bool,name=is_enable,default=true" json:"is_enable,omitempty"` +} + +func (m *OneEnableDisableXtrMode) Reset() { *m = OneEnableDisableXtrMode{} } +func (*OneEnableDisableXtrMode) GetMessageName() string { return "one_enable_disable_xtr_mode" } +func (*OneEnableDisableXtrMode) GetCrcString() string { return "c264d7bf" } +func (*OneEnableDisableXtrMode) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneEnableDisableXtrMode) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsEnable + return size +} +func (m *OneEnableDisableXtrMode) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *OneEnableDisableXtrMode) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsEnable = buf.DecodeBool() + return nil +} + +// OneEnableDisableXtrModeReply defines message 'one_enable_disable_xtr_mode_reply'. +type OneEnableDisableXtrModeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneEnableDisableXtrModeReply) Reset() { *m = OneEnableDisableXtrModeReply{} } +func (*OneEnableDisableXtrModeReply) GetMessageName() string { + return "one_enable_disable_xtr_mode_reply" +} +func (*OneEnableDisableXtrModeReply) GetCrcString() string { return "e8d4e804" } +func (*OneEnableDisableXtrModeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneEnableDisableXtrModeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneEnableDisableXtrModeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneEnableDisableXtrModeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Get ONE map request itr rlocs status +// - locator_set_name - name of the locator_set +// +// OneGetMapRequestItrRlocs defines message 'one_get_map_request_itr_rlocs'. +type OneGetMapRequestItrRlocs struct{} + +func (m *OneGetMapRequestItrRlocs) Reset() { *m = OneGetMapRequestItrRlocs{} } +func (*OneGetMapRequestItrRlocs) GetMessageName() string { return "one_get_map_request_itr_rlocs" } +func (*OneGetMapRequestItrRlocs) GetCrcString() string { return "51077d14" } +func (*OneGetMapRequestItrRlocs) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneGetMapRequestItrRlocs) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *OneGetMapRequestItrRlocs) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *OneGetMapRequestItrRlocs) Unmarshal(b []byte) error { + return nil +} + +// Request for map request itr rlocs summary status +// OneGetMapRequestItrRlocsReply defines message 'one_get_map_request_itr_rlocs_reply'. +type OneGetMapRequestItrRlocsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + LocatorSetName string `binapi:"string[64],name=locator_set_name" json:"locator_set_name,omitempty"` +} + +func (m *OneGetMapRequestItrRlocsReply) Reset() { *m = OneGetMapRequestItrRlocsReply{} } +func (*OneGetMapRequestItrRlocsReply) GetMessageName() string { + return "one_get_map_request_itr_rlocs_reply" +} +func (*OneGetMapRequestItrRlocsReply) GetCrcString() string { return "76580f3a" } +func (*OneGetMapRequestItrRlocsReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneGetMapRequestItrRlocsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 64 // m.LocatorSetName + return size +} +func (m *OneGetMapRequestItrRlocsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeString(m.LocatorSetName, 64) + return buf.Bytes(), nil +} +func (m *OneGetMapRequestItrRlocsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.LocatorSetName = buf.DecodeString(64) + return nil +} + +// OneGetTransportProtocol defines message 'one_get_transport_protocol'. +type OneGetTransportProtocol struct{} + +func (m *OneGetTransportProtocol) Reset() { *m = OneGetTransportProtocol{} } +func (*OneGetTransportProtocol) GetMessageName() string { return "one_get_transport_protocol" } +func (*OneGetTransportProtocol) GetCrcString() string { return "51077d14" } +func (*OneGetTransportProtocol) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneGetTransportProtocol) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *OneGetTransportProtocol) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *OneGetTransportProtocol) Unmarshal(b []byte) error { + return nil +} + +// OneGetTransportProtocolReply defines message 'one_get_transport_protocol_reply'. +type OneGetTransportProtocolReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Protocol uint8 `binapi:"u8,name=protocol" json:"protocol,omitempty"` +} + +func (m *OneGetTransportProtocolReply) Reset() { *m = OneGetTransportProtocolReply{} } +func (*OneGetTransportProtocolReply) GetMessageName() string { + return "one_get_transport_protocol_reply" +} +func (*OneGetTransportProtocolReply) GetCrcString() string { return "62a28eb3" } +func (*OneGetTransportProtocolReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneGetTransportProtocolReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.Protocol + return size +} +func (m *OneGetTransportProtocolReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint8(m.Protocol) + return buf.Bytes(), nil +} +func (m *OneGetTransportProtocolReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Protocol = buf.DecodeUint8() + return nil +} + +// Request for list of bridge domains used by L2 ARP table +// OneL2ArpBdGet defines message 'one_l2_arp_bd_get'. +type OneL2ArpBdGet struct{} + +func (m *OneL2ArpBdGet) Reset() { *m = OneL2ArpBdGet{} } +func (*OneL2ArpBdGet) GetMessageName() string { return "one_l2_arp_bd_get" } +func (*OneL2ArpBdGet) GetCrcString() string { return "51077d14" } +func (*OneL2ArpBdGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneL2ArpBdGet) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *OneL2ArpBdGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *OneL2ArpBdGet) Unmarshal(b []byte) error { + return nil +} + +// Reply with list of bridge domains used by L2 ARP table +// - count - number of elements in the list +// - bridge_domains - list of BDs +// +// OneL2ArpBdGetReply defines message 'one_l2_arp_bd_get_reply'. +type OneL2ArpBdGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + BridgeDomains []uint32 `binapi:"u32[count],name=bridge_domains" json:"bridge_domains,omitempty"` +} + +func (m *OneL2ArpBdGetReply) Reset() { *m = OneL2ArpBdGetReply{} } +func (*OneL2ArpBdGetReply) GetMessageName() string { return "one_l2_arp_bd_get_reply" } +func (*OneL2ArpBdGetReply) GetCrcString() string { return "221ac888" } +func (*OneL2ArpBdGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneL2ArpBdGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + size += 4 * len(m.BridgeDomains) // m.BridgeDomains + return size +} +func (m *OneL2ArpBdGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.BridgeDomains))) + for i := 0; i < len(m.BridgeDomains); i++ { + var x uint32 + if i < len(m.BridgeDomains) { + x = uint32(m.BridgeDomains[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *OneL2ArpBdGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.BridgeDomains = make([]uint32, m.Count) + for i := 0; i < len(m.BridgeDomains); i++ { + m.BridgeDomains[i] = buf.DecodeUint32() + } + return nil +} + +// Request for L2 ARP entries from specified bridge domain +// - bd - bridge domain +// +// OneL2ArpEntriesGet defines message 'one_l2_arp_entries_get'. +type OneL2ArpEntriesGet struct { + Bd uint32 `binapi:"u32,name=bd" json:"bd,omitempty"` +} + +func (m *OneL2ArpEntriesGet) Reset() { *m = OneL2ArpEntriesGet{} } +func (*OneL2ArpEntriesGet) GetMessageName() string { return "one_l2_arp_entries_get" } +func (*OneL2ArpEntriesGet) GetCrcString() string { return "4d418cf4" } +func (*OneL2ArpEntriesGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneL2ArpEntriesGet) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Bd + return size +} +func (m *OneL2ArpEntriesGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Bd) + return buf.Bytes(), nil +} +func (m *OneL2ArpEntriesGet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Bd = buf.DecodeUint32() + return nil +} + +// Reply with L2 ARP entries from specified bridge domain +// - retval - error code +// - count - number of elements in the list +// - vl_api_one_arp_entry_t - list of entries +// +// OneL2ArpEntriesGetReply defines message 'one_l2_arp_entries_get_reply'. +type OneL2ArpEntriesGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + Entries []OneL2ArpEntry `binapi:"one_l2_arp_entry[count],name=entries" json:"entries,omitempty"` +} + +func (m *OneL2ArpEntriesGetReply) Reset() { *m = OneL2ArpEntriesGetReply{} } +func (*OneL2ArpEntriesGetReply) GetMessageName() string { return "one_l2_arp_entries_get_reply" } +func (*OneL2ArpEntriesGetReply) GetCrcString() string { return "b0dd200f" } +func (*OneL2ArpEntriesGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneL2ArpEntriesGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + for j1 := 0; j1 < len(m.Entries); j1++ { + var s1 OneL2ArpEntry + _ = s1 + if j1 < len(m.Entries) { + s1 = m.Entries[j1] + } + size += 1 * 6 // s1.Mac + size += 1 * 4 // s1.IP4 + } + return size +} +func (m *OneL2ArpEntriesGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.Entries))) + for j0 := 0; j0 < len(m.Entries); j0++ { + var v0 OneL2ArpEntry // Entries + if j0 < len(m.Entries) { + v0 = m.Entries[j0] + } + buf.EncodeBytes(v0.Mac[:], 6) + buf.EncodeBytes(v0.IP4[:], 4) + } + return buf.Bytes(), nil +} +func (m *OneL2ArpEntriesGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.Entries = make([]OneL2ArpEntry, m.Count) + for j0 := 0; j0 < len(m.Entries); j0++ { + copy(m.Entries[j0].Mac[:], buf.DecodeBytes(6)) + copy(m.Entries[j0].IP4[:], buf.DecodeBytes(4)) + } + return nil +} + +// ONE locator_set status +// - local - if is set, then locator is local +// - locator_set_name - name of the locator_set +// - sw_if_index - sw_if_index of the locator +// - priority - locator priority +// - weight - locator weight +// +// OneLocatorDetails defines message 'one_locator_details'. +type OneLocatorDetails struct { + Local uint8 `binapi:"u8,name=local" json:"local,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` + Priority uint8 `binapi:"u8,name=priority" json:"priority,omitempty"` + Weight uint8 `binapi:"u8,name=weight" json:"weight,omitempty"` +} + +func (m *OneLocatorDetails) Reset() { *m = OneLocatorDetails{} } +func (*OneLocatorDetails) GetMessageName() string { return "one_locator_details" } +func (*OneLocatorDetails) GetCrcString() string { return "2c620ffe" } +func (*OneLocatorDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneLocatorDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Local + size += 4 // m.SwIfIndex + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + size += 1 // m.Priority + size += 1 // m.Weight + return size +} +func (m *OneLocatorDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.Local) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Priority) + buf.EncodeUint8(m.Weight) + return buf.Bytes(), nil +} +func (m *OneLocatorDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Local = buf.DecodeUint8() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Priority = buf.DecodeUint8() + m.Weight = buf.DecodeUint8() + return nil +} + +// Request for map one locator status +// - locator_set_index - index of locator_set +// - ls_name - locator set name +// - is_index_set - flag indicating whether ls_name or ls_index is set +// +// OneLocatorDump defines message 'one_locator_dump'. +type OneLocatorDump struct { + LsIndex uint32 `binapi:"u32,name=ls_index" json:"ls_index,omitempty"` + LsName string `binapi:"string[64],name=ls_name" json:"ls_name,omitempty"` + IsIndexSet bool `binapi:"bool,name=is_index_set" json:"is_index_set,omitempty"` +} + +func (m *OneLocatorDump) Reset() { *m = OneLocatorDump{} } +func (*OneLocatorDump) GetMessageName() string { return "one_locator_dump" } +func (*OneLocatorDump) GetCrcString() string { return "9b11076c" } +func (*OneLocatorDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneLocatorDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.LsIndex + size += 64 // m.LsName + size += 1 // m.IsIndexSet + return size +} +func (m *OneLocatorDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.LsIndex) + buf.EncodeString(m.LsName, 64) + buf.EncodeBool(m.IsIndexSet) + return buf.Bytes(), nil +} +func (m *OneLocatorDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.LsIndex = buf.DecodeUint32() + m.LsName = buf.DecodeString(64) + m.IsIndexSet = buf.DecodeBool() + return nil +} + +// ONE locator_set status +// - ls_index - locator set index +// - ls_name - name of the locator set +// +// OneLocatorSetDetails defines message 'one_locator_set_details'. +type OneLocatorSetDetails struct { + LsIndex uint32 `binapi:"u32,name=ls_index" json:"ls_index,omitempty"` + LsName string `binapi:"string[64],name=ls_name" json:"ls_name,omitempty"` +} + +func (m *OneLocatorSetDetails) Reset() { *m = OneLocatorSetDetails{} } +func (*OneLocatorSetDetails) GetMessageName() string { return "one_locator_set_details" } +func (*OneLocatorSetDetails) GetCrcString() string { return "5b33a105" } +func (*OneLocatorSetDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneLocatorSetDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.LsIndex + size += 64 // m.LsName + return size +} +func (m *OneLocatorSetDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.LsIndex) + buf.EncodeString(m.LsName, 64) + return buf.Bytes(), nil +} +func (m *OneLocatorSetDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.LsIndex = buf.DecodeUint32() + m.LsName = buf.DecodeString(64) + return nil +} + +// Request for locator_set summary status +// - filter - filter type +// Supported values: +// 0: all locator sets +// 1: local locator sets +// 2: remote locator sets +// +// OneLocatorSetDump defines message 'one_locator_set_dump'. +type OneLocatorSetDump struct { + Filter OneFilter `binapi:"one_filter,name=filter" json:"filter,omitempty"` +} + +func (m *OneLocatorSetDump) Reset() { *m = OneLocatorSetDump{} } +func (*OneLocatorSetDump) GetMessageName() string { return "one_locator_set_dump" } +func (*OneLocatorSetDump) GetCrcString() string { return "71190768" } +func (*OneLocatorSetDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneLocatorSetDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Filter + return size +} +func (m *OneLocatorSetDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Filter)) + return buf.Bytes(), nil +} +func (m *OneLocatorSetDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Filter = OneFilter(buf.DecodeUint32()) + return nil +} + +// enable/disable ONE map-register +// - is_enable - enable if non-zero; disable otherwise +// +// OneMapRegisterEnableDisable defines message 'one_map_register_enable_disable'. +type OneMapRegisterEnableDisable struct { + IsEnable bool `binapi:"bool,name=is_enable,default=true" json:"is_enable,omitempty"` +} + +func (m *OneMapRegisterEnableDisable) Reset() { *m = OneMapRegisterEnableDisable{} } +func (*OneMapRegisterEnableDisable) GetMessageName() string { return "one_map_register_enable_disable" } +func (*OneMapRegisterEnableDisable) GetCrcString() string { return "c264d7bf" } +func (*OneMapRegisterEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneMapRegisterEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsEnable + return size +} +func (m *OneMapRegisterEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *OneMapRegisterEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsEnable = buf.DecodeBool() + return nil +} + +// OneMapRegisterEnableDisableReply defines message 'one_map_register_enable_disable_reply'. +type OneMapRegisterEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneMapRegisterEnableDisableReply) Reset() { *m = OneMapRegisterEnableDisableReply{} } +func (*OneMapRegisterEnableDisableReply) GetMessageName() string { + return "one_map_register_enable_disable_reply" +} +func (*OneMapRegisterEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*OneMapRegisterEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneMapRegisterEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneMapRegisterEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneMapRegisterEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// OneMapRegisterFallbackThreshold defines message 'one_map_register_fallback_threshold'. +type OneMapRegisterFallbackThreshold struct { + Value uint32 `binapi:"u32,name=value" json:"value,omitempty"` +} + +func (m *OneMapRegisterFallbackThreshold) Reset() { *m = OneMapRegisterFallbackThreshold{} } +func (*OneMapRegisterFallbackThreshold) GetMessageName() string { + return "one_map_register_fallback_threshold" +} +func (*OneMapRegisterFallbackThreshold) GetCrcString() string { return "f7d4a475" } +func (*OneMapRegisterFallbackThreshold) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneMapRegisterFallbackThreshold) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Value + return size +} +func (m *OneMapRegisterFallbackThreshold) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Value) + return buf.Bytes(), nil +} +func (m *OneMapRegisterFallbackThreshold) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Value = buf.DecodeUint32() + return nil +} + +// OneMapRegisterFallbackThresholdReply defines message 'one_map_register_fallback_threshold_reply'. +type OneMapRegisterFallbackThresholdReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneMapRegisterFallbackThresholdReply) Reset() { *m = OneMapRegisterFallbackThresholdReply{} } +func (*OneMapRegisterFallbackThresholdReply) GetMessageName() string { + return "one_map_register_fallback_threshold_reply" +} +func (*OneMapRegisterFallbackThresholdReply) GetCrcString() string { return "e8d4e804" } +func (*OneMapRegisterFallbackThresholdReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneMapRegisterFallbackThresholdReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneMapRegisterFallbackThresholdReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneMapRegisterFallbackThresholdReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set TTL for map register messages +// - ttl - time to live +// +// OneMapRegisterSetTTL defines message 'one_map_register_set_ttl'. +type OneMapRegisterSetTTL struct { + TTL uint32 `binapi:"u32,name=ttl" json:"ttl,omitempty"` +} + +func (m *OneMapRegisterSetTTL) Reset() { *m = OneMapRegisterSetTTL{} } +func (*OneMapRegisterSetTTL) GetMessageName() string { return "one_map_register_set_ttl" } +func (*OneMapRegisterSetTTL) GetCrcString() string { return "dd59f1f3" } +func (*OneMapRegisterSetTTL) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneMapRegisterSetTTL) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TTL + return size +} +func (m *OneMapRegisterSetTTL) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TTL) + return buf.Bytes(), nil +} +func (m *OneMapRegisterSetTTL) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TTL = buf.DecodeUint32() + return nil +} + +// OneMapRegisterSetTTLReply defines message 'one_map_register_set_ttl_reply'. +type OneMapRegisterSetTTLReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneMapRegisterSetTTLReply) Reset() { *m = OneMapRegisterSetTTLReply{} } +func (*OneMapRegisterSetTTLReply) GetMessageName() string { return "one_map_register_set_ttl_reply" } +func (*OneMapRegisterSetTTLReply) GetCrcString() string { return "e8d4e804" } +func (*OneMapRegisterSetTTLReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneMapRegisterSetTTLReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneMapRegisterSetTTLReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneMapRegisterSetTTLReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// set ONE map-request mode. Based on configuration VPP will send +// +// src/dest or just normal destination map requests. +// - mode - new map-request mode. Supported values are: +// 0 - destination only +// 1 - source/destination +// +// OneMapRequestMode defines message 'one_map_request_mode'. +type OneMapRequestMode struct { + Mode OneMapMode `binapi:"one_map_mode,name=mode" json:"mode,omitempty"` +} + +func (m *OneMapRequestMode) Reset() { *m = OneMapRequestMode{} } +func (*OneMapRequestMode) GetMessageName() string { return "one_map_request_mode" } +func (*OneMapRequestMode) GetCrcString() string { return "ffa5d2f5" } +func (*OneMapRequestMode) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneMapRequestMode) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Mode + return size +} +func (m *OneMapRequestMode) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Mode)) + return buf.Bytes(), nil +} +func (m *OneMapRequestMode) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Mode = OneMapMode(buf.DecodeUint32()) + return nil +} + +// OneMapRequestModeReply defines message 'one_map_request_mode_reply'. +type OneMapRequestModeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneMapRequestModeReply) Reset() { *m = OneMapRequestModeReply{} } +func (*OneMapRequestModeReply) GetMessageName() string { return "one_map_request_mode_reply" } +func (*OneMapRequestModeReply) GetCrcString() string { return "e8d4e804" } +func (*OneMapRequestModeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneMapRequestModeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneMapRequestModeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneMapRequestModeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// ONE map resolver status +// - is_ipv6 - if non-zero the address is ipv6, else ipv4 +// - ip_address - array of address bytes +// +// OneMapResolverDetails defines message 'one_map_resolver_details'. +type OneMapResolverDetails struct { + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` +} + +func (m *OneMapResolverDetails) Reset() { *m = OneMapResolverDetails{} } +func (*OneMapResolverDetails) GetMessageName() string { return "one_map_resolver_details" } +func (*OneMapResolverDetails) GetCrcString() string { return "3e78fc57" } +func (*OneMapResolverDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneMapResolverDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + return size +} +func (m *OneMapResolverDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *OneMapResolverDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// Request for map resolver summary status +// OneMapResolverDump defines message 'one_map_resolver_dump'. +type OneMapResolverDump struct{} + +func (m *OneMapResolverDump) Reset() { *m = OneMapResolverDump{} } +func (*OneMapResolverDump) GetMessageName() string { return "one_map_resolver_dump" } +func (*OneMapResolverDump) GetCrcString() string { return "51077d14" } +func (*OneMapResolverDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneMapResolverDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *OneMapResolverDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *OneMapResolverDump) Unmarshal(b []byte) error { + return nil +} + +// ONE map server details +// - is_ipv6 - if non-zero the address is ipv6, else ipv4 +// - ip_address - array of address bytes +// +// OneMapServerDetails defines message 'one_map_server_details'. +type OneMapServerDetails struct { + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` +} + +func (m *OneMapServerDetails) Reset() { *m = OneMapServerDetails{} } +func (*OneMapServerDetails) GetMessageName() string { return "one_map_server_details" } +func (*OneMapServerDetails) GetCrcString() string { return "3e78fc57" } +func (*OneMapServerDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneMapServerDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + return size +} +func (m *OneMapServerDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *OneMapServerDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// Request for map server summary status +// OneMapServerDump defines message 'one_map_server_dump'. +type OneMapServerDump struct{} + +func (m *OneMapServerDump) Reset() { *m = OneMapServerDump{} } +func (*OneMapServerDump) GetMessageName() string { return "one_map_server_dump" } +func (*OneMapServerDump) GetCrcString() string { return "51077d14" } +func (*OneMapServerDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneMapServerDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *OneMapServerDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *OneMapServerDump) Unmarshal(b []byte) error { + return nil +} + +// Request for list of bridge domains used by neighbor discovery +// OneNdpBdGet defines message 'one_ndp_bd_get'. +type OneNdpBdGet struct{} + +func (m *OneNdpBdGet) Reset() { *m = OneNdpBdGet{} } +func (*OneNdpBdGet) GetMessageName() string { return "one_ndp_bd_get" } +func (*OneNdpBdGet) GetCrcString() string { return "51077d14" } +func (*OneNdpBdGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneNdpBdGet) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *OneNdpBdGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *OneNdpBdGet) Unmarshal(b []byte) error { + return nil +} + +// Reply with list of bridge domains used by neighbor discovery +// - count - number of elements in the list +// - bridge_domains - list of BDs +// +// OneNdpBdGetReply defines message 'one_ndp_bd_get_reply'. +type OneNdpBdGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + BridgeDomains []uint32 `binapi:"u32[count],name=bridge_domains" json:"bridge_domains,omitempty"` +} + +func (m *OneNdpBdGetReply) Reset() { *m = OneNdpBdGetReply{} } +func (*OneNdpBdGetReply) GetMessageName() string { return "one_ndp_bd_get_reply" } +func (*OneNdpBdGetReply) GetCrcString() string { return "221ac888" } +func (*OneNdpBdGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneNdpBdGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + size += 4 * len(m.BridgeDomains) // m.BridgeDomains + return size +} +func (m *OneNdpBdGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.BridgeDomains))) + for i := 0; i < len(m.BridgeDomains); i++ { + var x uint32 + if i < len(m.BridgeDomains) { + x = uint32(m.BridgeDomains[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *OneNdpBdGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.BridgeDomains = make([]uint32, m.Count) + for i := 0; i < len(m.BridgeDomains); i++ { + m.BridgeDomains[i] = buf.DecodeUint32() + } + return nil +} + +// OneNdpEntriesGet defines message 'one_ndp_entries_get'. +type OneNdpEntriesGet struct { + Bd uint32 `binapi:"u32,name=bd" json:"bd,omitempty"` +} + +func (m *OneNdpEntriesGet) Reset() { *m = OneNdpEntriesGet{} } +func (*OneNdpEntriesGet) GetMessageName() string { return "one_ndp_entries_get" } +func (*OneNdpEntriesGet) GetCrcString() string { return "4d418cf4" } +func (*OneNdpEntriesGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneNdpEntriesGet) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Bd + return size +} +func (m *OneNdpEntriesGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Bd) + return buf.Bytes(), nil +} +func (m *OneNdpEntriesGet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Bd = buf.DecodeUint32() + return nil +} + +// OneNdpEntriesGetReply defines message 'one_ndp_entries_get_reply'. +type OneNdpEntriesGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + Entries []OneNdpEntry `binapi:"one_ndp_entry[count],name=entries" json:"entries,omitempty"` +} + +func (m *OneNdpEntriesGetReply) Reset() { *m = OneNdpEntriesGetReply{} } +func (*OneNdpEntriesGetReply) GetMessageName() string { return "one_ndp_entries_get_reply" } +func (*OneNdpEntriesGetReply) GetCrcString() string { return "70719b1a" } +func (*OneNdpEntriesGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneNdpEntriesGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + for j1 := 0; j1 < len(m.Entries); j1++ { + var s1 OneNdpEntry + _ = s1 + if j1 < len(m.Entries) { + s1 = m.Entries[j1] + } + size += 1 * 6 // s1.Mac + size += 1 * 16 // s1.IP6 + } + return size +} +func (m *OneNdpEntriesGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.Entries))) + for j0 := 0; j0 < len(m.Entries); j0++ { + var v0 OneNdpEntry // Entries + if j0 < len(m.Entries) { + v0 = m.Entries[j0] + } + buf.EncodeBytes(v0.Mac[:], 6) + buf.EncodeBytes(v0.IP6[:], 16) + } + return buf.Bytes(), nil +} +func (m *OneNdpEntriesGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.Entries = make([]OneNdpEntry, m.Count) + for j0 := 0; j0 < len(m.Entries); j0++ { + copy(m.Entries[j0].Mac[:], buf.DecodeBytes(6)) + copy(m.Entries[j0].IP6[:], buf.DecodeBytes(16)) + } + return nil +} + +// configure or delete ONE NSH mapping +// - ls_name - locator set name +// - is_add - add locator set if non-zero; delete otherwise +// +// OneNshSetLocatorSet defines message 'one_nsh_set_locator_set'. +type OneNshSetLocatorSet struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + LsName string `binapi:"string[64],name=ls_name" json:"ls_name,omitempty"` +} + +func (m *OneNshSetLocatorSet) Reset() { *m = OneNshSetLocatorSet{} } +func (*OneNshSetLocatorSet) GetMessageName() string { return "one_nsh_set_locator_set" } +func (*OneNshSetLocatorSet) GetCrcString() string { return "486e2b76" } +func (*OneNshSetLocatorSet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneNshSetLocatorSet) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 64 // m.LsName + return size +} +func (m *OneNshSetLocatorSet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeString(m.LsName, 64) + return buf.Bytes(), nil +} +func (m *OneNshSetLocatorSet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.LsName = buf.DecodeString(64) + return nil +} + +// OneNshSetLocatorSetReply defines message 'one_nsh_set_locator_set_reply'. +type OneNshSetLocatorSetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneNshSetLocatorSetReply) Reset() { *m = OneNshSetLocatorSetReply{} } +func (*OneNshSetLocatorSetReply) GetMessageName() string { return "one_nsh_set_locator_set_reply" } +func (*OneNshSetLocatorSetReply) GetCrcString() string { return "e8d4e804" } +func (*OneNshSetLocatorSetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneNshSetLocatorSetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneNshSetLocatorSetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneNshSetLocatorSetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// configure or disable ONE PITR node +// - ls_name - locator set name +// - is_add - add locator set if non-zero, else disable pitr +// +// OnePitrSetLocatorSet defines message 'one_pitr_set_locator_set'. +type OnePitrSetLocatorSet struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + LsName string `binapi:"string[64],name=ls_name" json:"ls_name,omitempty"` +} + +func (m *OnePitrSetLocatorSet) Reset() { *m = OnePitrSetLocatorSet{} } +func (*OnePitrSetLocatorSet) GetMessageName() string { return "one_pitr_set_locator_set" } +func (*OnePitrSetLocatorSet) GetCrcString() string { return "486e2b76" } +func (*OnePitrSetLocatorSet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OnePitrSetLocatorSet) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 64 // m.LsName + return size +} +func (m *OnePitrSetLocatorSet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeString(m.LsName, 64) + return buf.Bytes(), nil +} +func (m *OnePitrSetLocatorSet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.LsName = buf.DecodeString(64) + return nil +} + +// OnePitrSetLocatorSetReply defines message 'one_pitr_set_locator_set_reply'. +type OnePitrSetLocatorSetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OnePitrSetLocatorSetReply) Reset() { *m = OnePitrSetLocatorSetReply{} } +func (*OnePitrSetLocatorSetReply) GetMessageName() string { return "one_pitr_set_locator_set_reply" } +func (*OnePitrSetLocatorSetReply) GetCrcString() string { return "e8d4e804" } +func (*OnePitrSetLocatorSetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OnePitrSetLocatorSetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OnePitrSetLocatorSetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OnePitrSetLocatorSetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// enable/disable ONE RLOC probing +// - is_enable - enable if non-zero; disable otherwise +// +// OneRlocProbeEnableDisable defines message 'one_rloc_probe_enable_disable'. +type OneRlocProbeEnableDisable struct { + IsEnable bool `binapi:"bool,name=is_enable,default=true" json:"is_enable,omitempty"` +} + +func (m *OneRlocProbeEnableDisable) Reset() { *m = OneRlocProbeEnableDisable{} } +func (*OneRlocProbeEnableDisable) GetMessageName() string { return "one_rloc_probe_enable_disable" } +func (*OneRlocProbeEnableDisable) GetCrcString() string { return "c264d7bf" } +func (*OneRlocProbeEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneRlocProbeEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsEnable + return size +} +func (m *OneRlocProbeEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *OneRlocProbeEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsEnable = buf.DecodeBool() + return nil +} + +// OneRlocProbeEnableDisableReply defines message 'one_rloc_probe_enable_disable_reply'. +type OneRlocProbeEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneRlocProbeEnableDisableReply) Reset() { *m = OneRlocProbeEnableDisableReply{} } +func (*OneRlocProbeEnableDisableReply) GetMessageName() string { + return "one_rloc_probe_enable_disable_reply" +} +func (*OneRlocProbeEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*OneRlocProbeEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneRlocProbeEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneRlocProbeEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneRlocProbeEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set ONE transport protocol +// - protocol - supported values: +// 1: UDP based LISP (default) +// 2: binary API +// +// OneSetTransportProtocol defines message 'one_set_transport_protocol'. +type OneSetTransportProtocol struct { + Protocol uint8 `binapi:"u8,name=protocol" json:"protocol,omitempty"` +} + +func (m *OneSetTransportProtocol) Reset() { *m = OneSetTransportProtocol{} } +func (*OneSetTransportProtocol) GetMessageName() string { return "one_set_transport_protocol" } +func (*OneSetTransportProtocol) GetCrcString() string { return "07b6b85f" } +func (*OneSetTransportProtocol) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneSetTransportProtocol) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Protocol + return size +} +func (m *OneSetTransportProtocol) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.Protocol) + return buf.Bytes(), nil +} +func (m *OneSetTransportProtocol) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Protocol = buf.DecodeUint8() + return nil +} + +// OneSetTransportProtocolReply defines message 'one_set_transport_protocol_reply'. +type OneSetTransportProtocolReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneSetTransportProtocolReply) Reset() { *m = OneSetTransportProtocolReply{} } +func (*OneSetTransportProtocolReply) GetMessageName() string { + return "one_set_transport_protocol_reply" +} +func (*OneSetTransportProtocolReply) GetCrcString() string { return "e8d4e804" } +func (*OneSetTransportProtocolReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneSetTransportProtocolReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneSetTransportProtocolReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneSetTransportProtocolReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// OneShowPetrMode defines message 'one_show_petr_mode'. +type OneShowPetrMode struct{} + +func (m *OneShowPetrMode) Reset() { *m = OneShowPetrMode{} } +func (*OneShowPetrMode) GetMessageName() string { return "one_show_petr_mode" } +func (*OneShowPetrMode) GetCrcString() string { return "51077d14" } +func (*OneShowPetrMode) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneShowPetrMode) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *OneShowPetrMode) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *OneShowPetrMode) Unmarshal(b []byte) error { + return nil +} + +// OneShowPetrModeReply defines message 'one_show_petr_mode_reply'. +type OneShowPetrModeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IsEnable bool `binapi:"bool,name=is_enable" json:"is_enable,omitempty"` +} + +func (m *OneShowPetrModeReply) Reset() { *m = OneShowPetrModeReply{} } +func (*OneShowPetrModeReply) GetMessageName() string { return "one_show_petr_mode_reply" } +func (*OneShowPetrModeReply) GetCrcString() string { return "f15abb16" } +func (*OneShowPetrModeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneShowPetrModeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.IsEnable + return size +} +func (m *OneShowPetrModeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *OneShowPetrModeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IsEnable = buf.DecodeBool() + return nil +} + +// OneShowPitrMode defines message 'one_show_pitr_mode'. +type OneShowPitrMode struct{} + +func (m *OneShowPitrMode) Reset() { *m = OneShowPitrMode{} } +func (*OneShowPitrMode) GetMessageName() string { return "one_show_pitr_mode" } +func (*OneShowPitrMode) GetCrcString() string { return "51077d14" } +func (*OneShowPitrMode) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneShowPitrMode) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *OneShowPitrMode) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *OneShowPitrMode) Unmarshal(b []byte) error { + return nil +} + +// OneShowPitrModeReply defines message 'one_show_pitr_mode_reply'. +type OneShowPitrModeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IsEnable bool `binapi:"bool,name=is_enable" json:"is_enable,omitempty"` +} + +func (m *OneShowPitrModeReply) Reset() { *m = OneShowPitrModeReply{} } +func (*OneShowPitrModeReply) GetMessageName() string { return "one_show_pitr_mode_reply" } +func (*OneShowPitrModeReply) GetCrcString() string { return "f15abb16" } +func (*OneShowPitrModeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneShowPitrModeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.IsEnable + return size +} +func (m *OneShowPitrModeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *OneShowPitrModeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IsEnable = buf.DecodeBool() + return nil +} + +// OneShowXtrMode defines message 'one_show_xtr_mode'. +type OneShowXtrMode struct{} + +func (m *OneShowXtrMode) Reset() { *m = OneShowXtrMode{} } +func (*OneShowXtrMode) GetMessageName() string { return "one_show_xtr_mode" } +func (*OneShowXtrMode) GetCrcString() string { return "51077d14" } +func (*OneShowXtrMode) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneShowXtrMode) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *OneShowXtrMode) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *OneShowXtrMode) Unmarshal(b []byte) error { + return nil +} + +// OneShowXtrModeReply defines message 'one_show_xtr_mode_reply'. +type OneShowXtrModeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IsEnable bool `binapi:"bool,name=is_enable" json:"is_enable,omitempty"` +} + +func (m *OneShowXtrModeReply) Reset() { *m = OneShowXtrModeReply{} } +func (*OneShowXtrModeReply) GetMessageName() string { return "one_show_xtr_mode_reply" } +func (*OneShowXtrModeReply) GetCrcString() string { return "f15abb16" } +func (*OneShowXtrModeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneShowXtrModeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.IsEnable + return size +} +func (m *OneShowXtrModeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *OneShowXtrModeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IsEnable = buf.DecodeBool() + return nil +} + +// OneStatsDetails defines message 'one_stats_details'. +type OneStatsDetails struct { + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + Deid lisp_types.Eid `binapi:"eid,name=deid" json:"deid,omitempty"` + Seid lisp_types.Eid `binapi:"eid,name=seid" json:"seid,omitempty"` + Rloc ip_types.Address `binapi:"address,name=rloc" json:"rloc,omitempty"` + Lloc ip_types.Address `binapi:"address,name=lloc" json:"lloc,omitempty"` + PktCount uint32 `binapi:"u32,name=pkt_count" json:"pkt_count,omitempty"` + Bytes uint32 `binapi:"u32,name=bytes" json:"bytes,omitempty"` +} + +func (m *OneStatsDetails) Reset() { *m = OneStatsDetails{} } +func (*OneStatsDetails) GetMessageName() string { return "one_stats_details" } +func (*OneStatsDetails) GetCrcString() string { return "2eb74678" } +func (*OneStatsDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneStatsDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Vni + size += 1 // m.Deid.Type + size += 1 * 18 // m.Deid.Address + size += 1 // m.Seid.Type + size += 1 * 18 // m.Seid.Address + size += 1 // m.Rloc.Af + size += 1 * 16 // m.Rloc.Un + size += 1 // m.Lloc.Af + size += 1 * 16 // m.Lloc.Un + size += 4 // m.PktCount + size += 4 // m.Bytes + return size +} +func (m *OneStatsDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Vni) + buf.EncodeUint8(uint8(m.Deid.Type)) + buf.EncodeBytes(m.Deid.Address.XXX_UnionData[:], 18) + buf.EncodeUint8(uint8(m.Seid.Type)) + buf.EncodeBytes(m.Seid.Address.XXX_UnionData[:], 18) + buf.EncodeUint8(uint8(m.Rloc.Af)) + buf.EncodeBytes(m.Rloc.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Lloc.Af)) + buf.EncodeBytes(m.Lloc.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.PktCount) + buf.EncodeUint32(m.Bytes) + return buf.Bytes(), nil +} +func (m *OneStatsDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Vni = buf.DecodeUint32() + m.Deid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Deid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.Seid.Type = lisp_types.EidType(buf.DecodeUint8()) + copy(m.Seid.Address.XXX_UnionData[:], buf.DecodeBytes(18)) + m.Rloc.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Rloc.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Lloc.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Lloc.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.PktCount = buf.DecodeUint32() + m.Bytes = buf.DecodeUint32() + return nil +} + +// OneStatsDump defines message 'one_stats_dump'. +type OneStatsDump struct{} + +func (m *OneStatsDump) Reset() { *m = OneStatsDump{} } +func (*OneStatsDump) GetMessageName() string { return "one_stats_dump" } +func (*OneStatsDump) GetCrcString() string { return "51077d14" } +func (*OneStatsDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneStatsDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *OneStatsDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *OneStatsDump) Unmarshal(b []byte) error { + return nil +} + +// OneStatsEnableDisable defines message 'one_stats_enable_disable'. +type OneStatsEnableDisable struct { + IsEnable bool `binapi:"bool,name=is_enable,default=true" json:"is_enable,omitempty"` +} + +func (m *OneStatsEnableDisable) Reset() { *m = OneStatsEnableDisable{} } +func (*OneStatsEnableDisable) GetMessageName() string { return "one_stats_enable_disable" } +func (*OneStatsEnableDisable) GetCrcString() string { return "c264d7bf" } +func (*OneStatsEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneStatsEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsEnable + return size +} +func (m *OneStatsEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *OneStatsEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsEnable = buf.DecodeBool() + return nil +} + +// OneStatsEnableDisableReply defines message 'one_stats_enable_disable_reply'. +type OneStatsEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneStatsEnableDisableReply) Reset() { *m = OneStatsEnableDisableReply{} } +func (*OneStatsEnableDisableReply) GetMessageName() string { return "one_stats_enable_disable_reply" } +func (*OneStatsEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*OneStatsEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneStatsEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneStatsEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneStatsEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// OneStatsFlush defines message 'one_stats_flush'. +type OneStatsFlush struct{} + +func (m *OneStatsFlush) Reset() { *m = OneStatsFlush{} } +func (*OneStatsFlush) GetMessageName() string { return "one_stats_flush" } +func (*OneStatsFlush) GetCrcString() string { return "51077d14" } +func (*OneStatsFlush) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneStatsFlush) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *OneStatsFlush) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *OneStatsFlush) Unmarshal(b []byte) error { + return nil +} + +// OneStatsFlushReply defines message 'one_stats_flush_reply'. +type OneStatsFlushReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneStatsFlushReply) Reset() { *m = OneStatsFlushReply{} } +func (*OneStatsFlushReply) GetMessageName() string { return "one_stats_flush_reply" } +func (*OneStatsFlushReply) GetCrcString() string { return "e8d4e804" } +func (*OneStatsFlushReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneStatsFlushReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneStatsFlushReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneStatsFlushReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// configure or disable use of PETR +// - is_ip4 - Address is IPv4 if set and IPv6 otherwise +// - address - PETR IP address +// - is_add - add locator set if non-zero, else disable PETR +// +// OneUsePetr defines message 'one_use_petr'. +type OneUsePetr struct { + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` +} + +func (m *OneUsePetr) Reset() { *m = OneUsePetr{} } +func (*OneUsePetr) GetMessageName() string { return "one_use_petr" } +func (*OneUsePetr) GetCrcString() string { return "d87dbad9" } +func (*OneUsePetr) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OneUsePetr) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + size += 1 // m.IsAdd + return size +} +func (m *OneUsePetr) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *OneUsePetr) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.IsAdd = buf.DecodeBool() + return nil +} + +// OneUsePetrReply defines message 'one_use_petr_reply'. +type OneUsePetrReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OneUsePetrReply) Reset() { *m = OneUsePetrReply{} } +func (*OneUsePetrReply) GetMessageName() string { return "one_use_petr_reply" } +func (*OneUsePetrReply) GetCrcString() string { return "e8d4e804" } +func (*OneUsePetrReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OneUsePetrReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OneUsePetrReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OneUsePetrReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// ShowOneMapRegisterFallbackThreshold defines message 'show_one_map_register_fallback_threshold'. +type ShowOneMapRegisterFallbackThreshold struct{} + +func (m *ShowOneMapRegisterFallbackThreshold) Reset() { *m = ShowOneMapRegisterFallbackThreshold{} } +func (*ShowOneMapRegisterFallbackThreshold) GetMessageName() string { + return "show_one_map_register_fallback_threshold" +} +func (*ShowOneMapRegisterFallbackThreshold) GetCrcString() string { return "51077d14" } +func (*ShowOneMapRegisterFallbackThreshold) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowOneMapRegisterFallbackThreshold) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowOneMapRegisterFallbackThreshold) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowOneMapRegisterFallbackThreshold) Unmarshal(b []byte) error { + return nil +} + +// ShowOneMapRegisterFallbackThresholdReply defines message 'show_one_map_register_fallback_threshold_reply'. +type ShowOneMapRegisterFallbackThresholdReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Value uint32 `binapi:"u32,name=value" json:"value,omitempty"` +} + +func (m *ShowOneMapRegisterFallbackThresholdReply) Reset() { + *m = ShowOneMapRegisterFallbackThresholdReply{} +} +func (*ShowOneMapRegisterFallbackThresholdReply) GetMessageName() string { + return "show_one_map_register_fallback_threshold_reply" +} +func (*ShowOneMapRegisterFallbackThresholdReply) GetCrcString() string { return "c93a9113" } +func (*ShowOneMapRegisterFallbackThresholdReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowOneMapRegisterFallbackThresholdReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Value + return size +} +func (m *ShowOneMapRegisterFallbackThresholdReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.Value) + return buf.Bytes(), nil +} +func (m *ShowOneMapRegisterFallbackThresholdReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Value = buf.DecodeUint32() + return nil +} + +// Get state of ONE map-register +// ShowOneMapRegisterState defines message 'show_one_map_register_state'. +type ShowOneMapRegisterState struct{} + +func (m *ShowOneMapRegisterState) Reset() { *m = ShowOneMapRegisterState{} } +func (*ShowOneMapRegisterState) GetMessageName() string { return "show_one_map_register_state" } +func (*ShowOneMapRegisterState) GetCrcString() string { return "51077d14" } +func (*ShowOneMapRegisterState) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowOneMapRegisterState) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowOneMapRegisterState) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowOneMapRegisterState) Unmarshal(b []byte) error { + return nil +} + +// Reply for show_one_map_register_state +// - retval - return code +// +// ShowOneMapRegisterStateReply defines message 'show_one_map_register_state_reply'. +type ShowOneMapRegisterStateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IsEnable bool `binapi:"bool,name=is_enable" json:"is_enable,omitempty"` +} + +func (m *ShowOneMapRegisterStateReply) Reset() { *m = ShowOneMapRegisterStateReply{} } +func (*ShowOneMapRegisterStateReply) GetMessageName() string { + return "show_one_map_register_state_reply" +} +func (*ShowOneMapRegisterStateReply) GetCrcString() string { return "f15abb16" } +func (*ShowOneMapRegisterStateReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowOneMapRegisterStateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.IsEnable + return size +} +func (m *ShowOneMapRegisterStateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *ShowOneMapRegisterStateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IsEnable = buf.DecodeBool() + return nil +} + +// Get TTL for map register messages +// ShowOneMapRegisterTTL defines message 'show_one_map_register_ttl'. +type ShowOneMapRegisterTTL struct{} + +func (m *ShowOneMapRegisterTTL) Reset() { *m = ShowOneMapRegisterTTL{} } +func (*ShowOneMapRegisterTTL) GetMessageName() string { return "show_one_map_register_ttl" } +func (*ShowOneMapRegisterTTL) GetCrcString() string { return "51077d14" } +func (*ShowOneMapRegisterTTL) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowOneMapRegisterTTL) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowOneMapRegisterTTL) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowOneMapRegisterTTL) Unmarshal(b []byte) error { + return nil +} + +// Contains current TTL for map register messages +// - retval - return code +// - ttl - time to live +// +// ShowOneMapRegisterTTLReply defines message 'show_one_map_register_ttl_reply'. +type ShowOneMapRegisterTTLReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TTL uint32 `binapi:"u32,name=ttl" json:"ttl,omitempty"` +} + +func (m *ShowOneMapRegisterTTLReply) Reset() { *m = ShowOneMapRegisterTTLReply{} } +func (*ShowOneMapRegisterTTLReply) GetMessageName() string { return "show_one_map_register_ttl_reply" } +func (*ShowOneMapRegisterTTLReply) GetCrcString() string { return "fa83dd66" } +func (*ShowOneMapRegisterTTLReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowOneMapRegisterTTLReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.TTL + return size +} +func (m *ShowOneMapRegisterTTLReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.TTL) + return buf.Bytes(), nil +} +func (m *ShowOneMapRegisterTTLReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.TTL = buf.DecodeUint32() + return nil +} + +// Request for ONE map-request mode +// ShowOneMapRequestMode defines message 'show_one_map_request_mode'. +type ShowOneMapRequestMode struct{} + +func (m *ShowOneMapRequestMode) Reset() { *m = ShowOneMapRequestMode{} } +func (*ShowOneMapRequestMode) GetMessageName() string { return "show_one_map_request_mode" } +func (*ShowOneMapRequestMode) GetCrcString() string { return "51077d14" } +func (*ShowOneMapRequestMode) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowOneMapRequestMode) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowOneMapRequestMode) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowOneMapRequestMode) Unmarshal(b []byte) error { + return nil +} + +// Reply for show_one_map_request_mode +// - retval - return code +// - mode - map-request mode +// +// ShowOneMapRequestModeReply defines message 'show_one_map_request_mode_reply'. +type ShowOneMapRequestModeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Mode OneMapMode `binapi:"one_map_mode,name=mode" json:"mode,omitempty"` +} + +func (m *ShowOneMapRequestModeReply) Reset() { *m = ShowOneMapRequestModeReply{} } +func (*ShowOneMapRequestModeReply) GetMessageName() string { return "show_one_map_request_mode_reply" } +func (*ShowOneMapRequestModeReply) GetCrcString() string { return "d41f3c1d" } +func (*ShowOneMapRequestModeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowOneMapRequestModeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Mode + return size +} +func (m *ShowOneMapRequestModeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.Mode)) + return buf.Bytes(), nil +} +func (m *ShowOneMapRequestModeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Mode = OneMapMode(buf.DecodeUint32()) + return nil +} + +// Request for ONE NSH mapping +// ShowOneNshMapping defines message 'show_one_nsh_mapping'. +type ShowOneNshMapping struct{} + +func (m *ShowOneNshMapping) Reset() { *m = ShowOneNshMapping{} } +func (*ShowOneNshMapping) GetMessageName() string { return "show_one_nsh_mapping" } +func (*ShowOneNshMapping) GetCrcString() string { return "51077d14" } +func (*ShowOneNshMapping) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowOneNshMapping) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowOneNshMapping) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowOneNshMapping) Unmarshal(b []byte) error { + return nil +} + +// Reply for ONE NSH mapping +// - is_set - is ONE NSH mapping set +// - locator_set_name - name of the locator_set if NSH mapping is set +// +// ShowOneNshMappingReply defines message 'show_one_nsh_mapping_reply'. +type ShowOneNshMappingReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IsSet bool `binapi:"bool,name=is_set" json:"is_set,omitempty"` + LocatorSetName string `binapi:"string[64],name=locator_set_name" json:"locator_set_name,omitempty"` +} + +func (m *ShowOneNshMappingReply) Reset() { *m = ShowOneNshMappingReply{} } +func (*ShowOneNshMappingReply) GetMessageName() string { return "show_one_nsh_mapping_reply" } +func (*ShowOneNshMappingReply) GetCrcString() string { return "46478c02" } +func (*ShowOneNshMappingReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowOneNshMappingReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.IsSet + size += 64 // m.LocatorSetName + return size +} +func (m *ShowOneNshMappingReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.IsSet) + buf.EncodeString(m.LocatorSetName, 64) + return buf.Bytes(), nil +} +func (m *ShowOneNshMappingReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IsSet = buf.DecodeBool() + m.LocatorSetName = buf.DecodeString(64) + return nil +} + +// Request for ONE PITR status +// ShowOnePitr defines message 'show_one_pitr'. +type ShowOnePitr struct{} + +func (m *ShowOnePitr) Reset() { *m = ShowOnePitr{} } +func (*ShowOnePitr) GetMessageName() string { return "show_one_pitr" } +func (*ShowOnePitr) GetCrcString() string { return "51077d14" } +func (*ShowOnePitr) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowOnePitr) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowOnePitr) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowOnePitr) Unmarshal(b []byte) error { + return nil +} + +// Status of ONE PITR, enable or disable +// - status - ONE PITR enable if non-zero, else disable +// - locator_set_name - name of the locator_set +// +// ShowOnePitrReply defines message 'show_one_pitr_reply'. +type ShowOnePitrReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Status bool `binapi:"bool,name=status" json:"status,omitempty"` + LocatorSetName string `binapi:"string[64],name=locator_set_name" json:"locator_set_name,omitempty"` +} + +func (m *ShowOnePitrReply) Reset() { *m = ShowOnePitrReply{} } +func (*ShowOnePitrReply) GetMessageName() string { return "show_one_pitr_reply" } +func (*ShowOnePitrReply) GetCrcString() string { return "a2d1a49f" } +func (*ShowOnePitrReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowOnePitrReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.Status + size += 64 // m.LocatorSetName + return size +} +func (m *ShowOnePitrReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.Status) + buf.EncodeString(m.LocatorSetName, 64) + return buf.Bytes(), nil +} +func (m *ShowOnePitrReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Status = buf.DecodeBool() + m.LocatorSetName = buf.DecodeString(64) + return nil +} + +// Get state of ONE RLOC probing +// ShowOneRlocProbeState defines message 'show_one_rloc_probe_state'. +type ShowOneRlocProbeState struct{} + +func (m *ShowOneRlocProbeState) Reset() { *m = ShowOneRlocProbeState{} } +func (*ShowOneRlocProbeState) GetMessageName() string { return "show_one_rloc_probe_state" } +func (*ShowOneRlocProbeState) GetCrcString() string { return "51077d14" } +func (*ShowOneRlocProbeState) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowOneRlocProbeState) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowOneRlocProbeState) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowOneRlocProbeState) Unmarshal(b []byte) error { + return nil +} + +// Reply for show_one_rloc_probe_state +// - retval - return code +// - is_enable - state of RLOC probing +// +// ShowOneRlocProbeStateReply defines message 'show_one_rloc_probe_state_reply'. +type ShowOneRlocProbeStateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IsEnable bool `binapi:"bool,name=is_enable" json:"is_enable,omitempty"` +} + +func (m *ShowOneRlocProbeStateReply) Reset() { *m = ShowOneRlocProbeStateReply{} } +func (*ShowOneRlocProbeStateReply) GetMessageName() string { return "show_one_rloc_probe_state_reply" } +func (*ShowOneRlocProbeStateReply) GetCrcString() string { return "f15abb16" } +func (*ShowOneRlocProbeStateReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowOneRlocProbeStateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.IsEnable + return size +} +func (m *ShowOneRlocProbeStateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *ShowOneRlocProbeStateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IsEnable = buf.DecodeBool() + return nil +} + +// ShowOneStatsEnableDisable defines message 'show_one_stats_enable_disable'. +type ShowOneStatsEnableDisable struct{} + +func (m *ShowOneStatsEnableDisable) Reset() { *m = ShowOneStatsEnableDisable{} } +func (*ShowOneStatsEnableDisable) GetMessageName() string { return "show_one_stats_enable_disable" } +func (*ShowOneStatsEnableDisable) GetCrcString() string { return "51077d14" } +func (*ShowOneStatsEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowOneStatsEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowOneStatsEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowOneStatsEnableDisable) Unmarshal(b []byte) error { + return nil +} + +// ShowOneStatsEnableDisableReply defines message 'show_one_stats_enable_disable_reply'. +type ShowOneStatsEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IsEnable bool `binapi:"bool,name=is_enable" json:"is_enable,omitempty"` +} + +func (m *ShowOneStatsEnableDisableReply) Reset() { *m = ShowOneStatsEnableDisableReply{} } +func (*ShowOneStatsEnableDisableReply) GetMessageName() string { + return "show_one_stats_enable_disable_reply" +} +func (*ShowOneStatsEnableDisableReply) GetCrcString() string { return "f15abb16" } +func (*ShowOneStatsEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowOneStatsEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.IsEnable + return size +} +func (m *ShowOneStatsEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *ShowOneStatsEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IsEnable = buf.DecodeBool() + return nil +} + +// Request for ONE status +// ShowOneStatus defines message 'show_one_status'. +type ShowOneStatus struct{} + +func (m *ShowOneStatus) Reset() { *m = ShowOneStatus{} } +func (*ShowOneStatus) GetMessageName() string { return "show_one_status" } +func (*ShowOneStatus) GetCrcString() string { return "51077d14" } +func (*ShowOneStatus) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowOneStatus) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowOneStatus) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowOneStatus) Unmarshal(b []byte) error { + return nil +} + +// ONE status +// - feature_status - enabled if non-zero, else disabled +// - gpe_status - enabled if non-zero, else disabled +// +// ShowOneStatusReply defines message 'show_one_status_reply'. +type ShowOneStatusReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + FeatureStatus bool `binapi:"bool,name=feature_status" json:"feature_status,omitempty"` + GpeStatus bool `binapi:"bool,name=gpe_status" json:"gpe_status,omitempty"` +} + +func (m *ShowOneStatusReply) Reset() { *m = ShowOneStatusReply{} } +func (*ShowOneStatusReply) GetMessageName() string { return "show_one_status_reply" } +func (*ShowOneStatusReply) GetCrcString() string { return "961bb25b" } +func (*ShowOneStatusReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowOneStatusReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.FeatureStatus + size += 1 // m.GpeStatus + return size +} +func (m *ShowOneStatusReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.FeatureStatus) + buf.EncodeBool(m.GpeStatus) + return buf.Bytes(), nil +} +func (m *ShowOneStatusReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.FeatureStatus = buf.DecodeBool() + m.GpeStatus = buf.DecodeBool() + return nil +} + +// Request for ONE PETR status +// ShowOneUsePetr defines message 'show_one_use_petr'. +type ShowOneUsePetr struct{} + +func (m *ShowOneUsePetr) Reset() { *m = ShowOneUsePetr{} } +func (*ShowOneUsePetr) GetMessageName() string { return "show_one_use_petr" } +func (*ShowOneUsePetr) GetCrcString() string { return "51077d14" } +func (*ShowOneUsePetr) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ShowOneUsePetr) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ShowOneUsePetr) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ShowOneUsePetr) Unmarshal(b []byte) error { + return nil +} + +// ONE PETR status, enable or disable +// - enable - ONE PETR enable if non-zero, else disable +// - is_ip4 - Address is IPv4 if non-zero, else IPv6 +// - address - PETR IP address +// +// ShowOneUsePetrReply defines message 'show_one_use_petr_reply'. +type ShowOneUsePetrReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Status bool `binapi:"bool,name=status" json:"status,omitempty"` + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` +} + +func (m *ShowOneUsePetrReply) Reset() { *m = ShowOneUsePetrReply{} } +func (*ShowOneUsePetrReply) GetMessageName() string { return "show_one_use_petr_reply" } +func (*ShowOneUsePetrReply) GetCrcString() string { return "84a03528" } +func (*ShowOneUsePetrReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ShowOneUsePetrReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.Status + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + return size +} +func (m *ShowOneUsePetrReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBool(m.Status) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *ShowOneUsePetrReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Status = buf.DecodeBool() + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +func init() { file_one_binapi_init() } +func file_one_binapi_init() { + api.RegisterMessage((*OneAddDelAdjacency)(nil), "one_add_del_adjacency_9e830312") + api.RegisterMessage((*OneAddDelAdjacencyReply)(nil), "one_add_del_adjacency_reply_e8d4e804") + api.RegisterMessage((*OneAddDelL2ArpEntry)(nil), "one_add_del_l2_arp_entry_1aa5e8b3") + api.RegisterMessage((*OneAddDelL2ArpEntryReply)(nil), "one_add_del_l2_arp_entry_reply_e8d4e804") + api.RegisterMessage((*OneAddDelLocalEid)(nil), "one_add_del_local_eid_4e5a83a2") + api.RegisterMessage((*OneAddDelLocalEidReply)(nil), "one_add_del_local_eid_reply_e8d4e804") + api.RegisterMessage((*OneAddDelLocator)(nil), "one_add_del_locator_af4d8f13") + api.RegisterMessage((*OneAddDelLocatorReply)(nil), "one_add_del_locator_reply_e8d4e804") + api.RegisterMessage((*OneAddDelLocatorSet)(nil), "one_add_del_locator_set_6fcd6471") + api.RegisterMessage((*OneAddDelLocatorSetReply)(nil), "one_add_del_locator_set_reply_b6666db4") + api.RegisterMessage((*OneAddDelMapRequestItrRlocs)(nil), "one_add_del_map_request_itr_rlocs_6be88e45") + api.RegisterMessage((*OneAddDelMapRequestItrRlocsReply)(nil), "one_add_del_map_request_itr_rlocs_reply_e8d4e804") + api.RegisterMessage((*OneAddDelMapResolver)(nil), "one_add_del_map_resolver_ce19e32d") + api.RegisterMessage((*OneAddDelMapResolverReply)(nil), "one_add_del_map_resolver_reply_e8d4e804") + api.RegisterMessage((*OneAddDelMapServer)(nil), "one_add_del_map_server_ce19e32d") + api.RegisterMessage((*OneAddDelMapServerReply)(nil), "one_add_del_map_server_reply_e8d4e804") + api.RegisterMessage((*OneAddDelNdpEntry)(nil), "one_add_del_ndp_entry_0f8a287c") + api.RegisterMessage((*OneAddDelNdpEntryReply)(nil), "one_add_del_ndp_entry_reply_e8d4e804") + api.RegisterMessage((*OneAddDelRemoteMapping)(nil), "one_add_del_remote_mapping_6d5c789e") + api.RegisterMessage((*OneAddDelRemoteMappingReply)(nil), "one_add_del_remote_mapping_reply_e8d4e804") + api.RegisterMessage((*OneAdjacenciesGet)(nil), "one_adjacencies_get_8d1f2fe9") + api.RegisterMessage((*OneAdjacenciesGetReply)(nil), "one_adjacencies_get_reply_085bab89") + api.RegisterMessage((*OneEidTableAddDelMap)(nil), "one_eid_table_add_del_map_9481416b") + api.RegisterMessage((*OneEidTableAddDelMapReply)(nil), "one_eid_table_add_del_map_reply_e8d4e804") + api.RegisterMessage((*OneEidTableDetails)(nil), "one_eid_table_details_1c29f792") + api.RegisterMessage((*OneEidTableDump)(nil), "one_eid_table_dump_bd190269") + api.RegisterMessage((*OneEidTableMapDetails)(nil), "one_eid_table_map_details_0b6859e2") + api.RegisterMessage((*OneEidTableMapDump)(nil), "one_eid_table_map_dump_d6cf0c3d") + api.RegisterMessage((*OneEidTableVniDetails)(nil), "one_eid_table_vni_details_64abc01e") + api.RegisterMessage((*OneEidTableVniDump)(nil), "one_eid_table_vni_dump_51077d14") + api.RegisterMessage((*OneEnableDisable)(nil), "one_enable_disable_c264d7bf") + api.RegisterMessage((*OneEnableDisablePetrMode)(nil), "one_enable_disable_petr_mode_c264d7bf") + api.RegisterMessage((*OneEnableDisablePetrModeReply)(nil), "one_enable_disable_petr_mode_reply_e8d4e804") + api.RegisterMessage((*OneEnableDisablePitrMode)(nil), "one_enable_disable_pitr_mode_c264d7bf") + api.RegisterMessage((*OneEnableDisablePitrModeReply)(nil), "one_enable_disable_pitr_mode_reply_e8d4e804") + api.RegisterMessage((*OneEnableDisableReply)(nil), "one_enable_disable_reply_e8d4e804") + api.RegisterMessage((*OneEnableDisableXtrMode)(nil), "one_enable_disable_xtr_mode_c264d7bf") + api.RegisterMessage((*OneEnableDisableXtrModeReply)(nil), "one_enable_disable_xtr_mode_reply_e8d4e804") + api.RegisterMessage((*OneGetMapRequestItrRlocs)(nil), "one_get_map_request_itr_rlocs_51077d14") + api.RegisterMessage((*OneGetMapRequestItrRlocsReply)(nil), "one_get_map_request_itr_rlocs_reply_76580f3a") + api.RegisterMessage((*OneGetTransportProtocol)(nil), "one_get_transport_protocol_51077d14") + api.RegisterMessage((*OneGetTransportProtocolReply)(nil), "one_get_transport_protocol_reply_62a28eb3") + api.RegisterMessage((*OneL2ArpBdGet)(nil), "one_l2_arp_bd_get_51077d14") + api.RegisterMessage((*OneL2ArpBdGetReply)(nil), "one_l2_arp_bd_get_reply_221ac888") + api.RegisterMessage((*OneL2ArpEntriesGet)(nil), "one_l2_arp_entries_get_4d418cf4") + api.RegisterMessage((*OneL2ArpEntriesGetReply)(nil), "one_l2_arp_entries_get_reply_b0dd200f") + api.RegisterMessage((*OneLocatorDetails)(nil), "one_locator_details_2c620ffe") + api.RegisterMessage((*OneLocatorDump)(nil), "one_locator_dump_9b11076c") + api.RegisterMessage((*OneLocatorSetDetails)(nil), "one_locator_set_details_5b33a105") + api.RegisterMessage((*OneLocatorSetDump)(nil), "one_locator_set_dump_71190768") + api.RegisterMessage((*OneMapRegisterEnableDisable)(nil), "one_map_register_enable_disable_c264d7bf") + api.RegisterMessage((*OneMapRegisterEnableDisableReply)(nil), "one_map_register_enable_disable_reply_e8d4e804") + api.RegisterMessage((*OneMapRegisterFallbackThreshold)(nil), "one_map_register_fallback_threshold_f7d4a475") + api.RegisterMessage((*OneMapRegisterFallbackThresholdReply)(nil), "one_map_register_fallback_threshold_reply_e8d4e804") + api.RegisterMessage((*OneMapRegisterSetTTL)(nil), "one_map_register_set_ttl_dd59f1f3") + api.RegisterMessage((*OneMapRegisterSetTTLReply)(nil), "one_map_register_set_ttl_reply_e8d4e804") + api.RegisterMessage((*OneMapRequestMode)(nil), "one_map_request_mode_ffa5d2f5") + api.RegisterMessage((*OneMapRequestModeReply)(nil), "one_map_request_mode_reply_e8d4e804") + api.RegisterMessage((*OneMapResolverDetails)(nil), "one_map_resolver_details_3e78fc57") + api.RegisterMessage((*OneMapResolverDump)(nil), "one_map_resolver_dump_51077d14") + api.RegisterMessage((*OneMapServerDetails)(nil), "one_map_server_details_3e78fc57") + api.RegisterMessage((*OneMapServerDump)(nil), "one_map_server_dump_51077d14") + api.RegisterMessage((*OneNdpBdGet)(nil), "one_ndp_bd_get_51077d14") + api.RegisterMessage((*OneNdpBdGetReply)(nil), "one_ndp_bd_get_reply_221ac888") + api.RegisterMessage((*OneNdpEntriesGet)(nil), "one_ndp_entries_get_4d418cf4") + api.RegisterMessage((*OneNdpEntriesGetReply)(nil), "one_ndp_entries_get_reply_70719b1a") + api.RegisterMessage((*OneNshSetLocatorSet)(nil), "one_nsh_set_locator_set_486e2b76") + api.RegisterMessage((*OneNshSetLocatorSetReply)(nil), "one_nsh_set_locator_set_reply_e8d4e804") + api.RegisterMessage((*OnePitrSetLocatorSet)(nil), "one_pitr_set_locator_set_486e2b76") + api.RegisterMessage((*OnePitrSetLocatorSetReply)(nil), "one_pitr_set_locator_set_reply_e8d4e804") + api.RegisterMessage((*OneRlocProbeEnableDisable)(nil), "one_rloc_probe_enable_disable_c264d7bf") + api.RegisterMessage((*OneRlocProbeEnableDisableReply)(nil), "one_rloc_probe_enable_disable_reply_e8d4e804") + api.RegisterMessage((*OneSetTransportProtocol)(nil), "one_set_transport_protocol_07b6b85f") + api.RegisterMessage((*OneSetTransportProtocolReply)(nil), "one_set_transport_protocol_reply_e8d4e804") + api.RegisterMessage((*OneShowPetrMode)(nil), "one_show_petr_mode_51077d14") + api.RegisterMessage((*OneShowPetrModeReply)(nil), "one_show_petr_mode_reply_f15abb16") + api.RegisterMessage((*OneShowPitrMode)(nil), "one_show_pitr_mode_51077d14") + api.RegisterMessage((*OneShowPitrModeReply)(nil), "one_show_pitr_mode_reply_f15abb16") + api.RegisterMessage((*OneShowXtrMode)(nil), "one_show_xtr_mode_51077d14") + api.RegisterMessage((*OneShowXtrModeReply)(nil), "one_show_xtr_mode_reply_f15abb16") + api.RegisterMessage((*OneStatsDetails)(nil), "one_stats_details_2eb74678") + api.RegisterMessage((*OneStatsDump)(nil), "one_stats_dump_51077d14") + api.RegisterMessage((*OneStatsEnableDisable)(nil), "one_stats_enable_disable_c264d7bf") + api.RegisterMessage((*OneStatsEnableDisableReply)(nil), "one_stats_enable_disable_reply_e8d4e804") + api.RegisterMessage((*OneStatsFlush)(nil), "one_stats_flush_51077d14") + api.RegisterMessage((*OneStatsFlushReply)(nil), "one_stats_flush_reply_e8d4e804") + api.RegisterMessage((*OneUsePetr)(nil), "one_use_petr_d87dbad9") + api.RegisterMessage((*OneUsePetrReply)(nil), "one_use_petr_reply_e8d4e804") + api.RegisterMessage((*ShowOneMapRegisterFallbackThreshold)(nil), "show_one_map_register_fallback_threshold_51077d14") + api.RegisterMessage((*ShowOneMapRegisterFallbackThresholdReply)(nil), "show_one_map_register_fallback_threshold_reply_c93a9113") + api.RegisterMessage((*ShowOneMapRegisterState)(nil), "show_one_map_register_state_51077d14") + api.RegisterMessage((*ShowOneMapRegisterStateReply)(nil), "show_one_map_register_state_reply_f15abb16") + api.RegisterMessage((*ShowOneMapRegisterTTL)(nil), "show_one_map_register_ttl_51077d14") + api.RegisterMessage((*ShowOneMapRegisterTTLReply)(nil), "show_one_map_register_ttl_reply_fa83dd66") + api.RegisterMessage((*ShowOneMapRequestMode)(nil), "show_one_map_request_mode_51077d14") + api.RegisterMessage((*ShowOneMapRequestModeReply)(nil), "show_one_map_request_mode_reply_d41f3c1d") + api.RegisterMessage((*ShowOneNshMapping)(nil), "show_one_nsh_mapping_51077d14") + api.RegisterMessage((*ShowOneNshMappingReply)(nil), "show_one_nsh_mapping_reply_46478c02") + api.RegisterMessage((*ShowOnePitr)(nil), "show_one_pitr_51077d14") + api.RegisterMessage((*ShowOnePitrReply)(nil), "show_one_pitr_reply_a2d1a49f") + api.RegisterMessage((*ShowOneRlocProbeState)(nil), "show_one_rloc_probe_state_51077d14") + api.RegisterMessage((*ShowOneRlocProbeStateReply)(nil), "show_one_rloc_probe_state_reply_f15abb16") + api.RegisterMessage((*ShowOneStatsEnableDisable)(nil), "show_one_stats_enable_disable_51077d14") + api.RegisterMessage((*ShowOneStatsEnableDisableReply)(nil), "show_one_stats_enable_disable_reply_f15abb16") + api.RegisterMessage((*ShowOneStatus)(nil), "show_one_status_51077d14") + api.RegisterMessage((*ShowOneStatusReply)(nil), "show_one_status_reply_961bb25b") + api.RegisterMessage((*ShowOneUsePetr)(nil), "show_one_use_petr_51077d14") + api.RegisterMessage((*ShowOneUsePetrReply)(nil), "show_one_use_petr_reply_84a03528") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*OneAddDelAdjacency)(nil), + (*OneAddDelAdjacencyReply)(nil), + (*OneAddDelL2ArpEntry)(nil), + (*OneAddDelL2ArpEntryReply)(nil), + (*OneAddDelLocalEid)(nil), + (*OneAddDelLocalEidReply)(nil), + (*OneAddDelLocator)(nil), + (*OneAddDelLocatorReply)(nil), + (*OneAddDelLocatorSet)(nil), + (*OneAddDelLocatorSetReply)(nil), + (*OneAddDelMapRequestItrRlocs)(nil), + (*OneAddDelMapRequestItrRlocsReply)(nil), + (*OneAddDelMapResolver)(nil), + (*OneAddDelMapResolverReply)(nil), + (*OneAddDelMapServer)(nil), + (*OneAddDelMapServerReply)(nil), + (*OneAddDelNdpEntry)(nil), + (*OneAddDelNdpEntryReply)(nil), + (*OneAddDelRemoteMapping)(nil), + (*OneAddDelRemoteMappingReply)(nil), + (*OneAdjacenciesGet)(nil), + (*OneAdjacenciesGetReply)(nil), + (*OneEidTableAddDelMap)(nil), + (*OneEidTableAddDelMapReply)(nil), + (*OneEidTableDetails)(nil), + (*OneEidTableDump)(nil), + (*OneEidTableMapDetails)(nil), + (*OneEidTableMapDump)(nil), + (*OneEidTableVniDetails)(nil), + (*OneEidTableVniDump)(nil), + (*OneEnableDisable)(nil), + (*OneEnableDisablePetrMode)(nil), + (*OneEnableDisablePetrModeReply)(nil), + (*OneEnableDisablePitrMode)(nil), + (*OneEnableDisablePitrModeReply)(nil), + (*OneEnableDisableReply)(nil), + (*OneEnableDisableXtrMode)(nil), + (*OneEnableDisableXtrModeReply)(nil), + (*OneGetMapRequestItrRlocs)(nil), + (*OneGetMapRequestItrRlocsReply)(nil), + (*OneGetTransportProtocol)(nil), + (*OneGetTransportProtocolReply)(nil), + (*OneL2ArpBdGet)(nil), + (*OneL2ArpBdGetReply)(nil), + (*OneL2ArpEntriesGet)(nil), + (*OneL2ArpEntriesGetReply)(nil), + (*OneLocatorDetails)(nil), + (*OneLocatorDump)(nil), + (*OneLocatorSetDetails)(nil), + (*OneLocatorSetDump)(nil), + (*OneMapRegisterEnableDisable)(nil), + (*OneMapRegisterEnableDisableReply)(nil), + (*OneMapRegisterFallbackThreshold)(nil), + (*OneMapRegisterFallbackThresholdReply)(nil), + (*OneMapRegisterSetTTL)(nil), + (*OneMapRegisterSetTTLReply)(nil), + (*OneMapRequestMode)(nil), + (*OneMapRequestModeReply)(nil), + (*OneMapResolverDetails)(nil), + (*OneMapResolverDump)(nil), + (*OneMapServerDetails)(nil), + (*OneMapServerDump)(nil), + (*OneNdpBdGet)(nil), + (*OneNdpBdGetReply)(nil), + (*OneNdpEntriesGet)(nil), + (*OneNdpEntriesGetReply)(nil), + (*OneNshSetLocatorSet)(nil), + (*OneNshSetLocatorSetReply)(nil), + (*OnePitrSetLocatorSet)(nil), + (*OnePitrSetLocatorSetReply)(nil), + (*OneRlocProbeEnableDisable)(nil), + (*OneRlocProbeEnableDisableReply)(nil), + (*OneSetTransportProtocol)(nil), + (*OneSetTransportProtocolReply)(nil), + (*OneShowPetrMode)(nil), + (*OneShowPetrModeReply)(nil), + (*OneShowPitrMode)(nil), + (*OneShowPitrModeReply)(nil), + (*OneShowXtrMode)(nil), + (*OneShowXtrModeReply)(nil), + (*OneStatsDetails)(nil), + (*OneStatsDump)(nil), + (*OneStatsEnableDisable)(nil), + (*OneStatsEnableDisableReply)(nil), + (*OneStatsFlush)(nil), + (*OneStatsFlushReply)(nil), + (*OneUsePetr)(nil), + (*OneUsePetrReply)(nil), + (*ShowOneMapRegisterFallbackThreshold)(nil), + (*ShowOneMapRegisterFallbackThresholdReply)(nil), + (*ShowOneMapRegisterState)(nil), + (*ShowOneMapRegisterStateReply)(nil), + (*ShowOneMapRegisterTTL)(nil), + (*ShowOneMapRegisterTTLReply)(nil), + (*ShowOneMapRequestMode)(nil), + (*ShowOneMapRequestModeReply)(nil), + (*ShowOneNshMapping)(nil), + (*ShowOneNshMappingReply)(nil), + (*ShowOnePitr)(nil), + (*ShowOnePitrReply)(nil), + (*ShowOneRlocProbeState)(nil), + (*ShowOneRlocProbeStateReply)(nil), + (*ShowOneStatsEnableDisable)(nil), + (*ShowOneStatsEnableDisableReply)(nil), + (*ShowOneStatus)(nil), + (*ShowOneStatusReply)(nil), + (*ShowOneUsePetr)(nil), + (*ShowOneUsePetrReply)(nil), + } +} diff --git a/binapi/one/one_rpc.ba.go b/binapi/one/one_rpc.ba.go new file mode 100644 index 00000000..4e8de530 --- /dev/null +++ b/binapi/one/one_rpc.ba.go @@ -0,0 +1,836 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package one + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service one. +type RPCService interface { + OneAddDelAdjacency(ctx context.Context, in *OneAddDelAdjacency) (*OneAddDelAdjacencyReply, error) + OneAddDelL2ArpEntry(ctx context.Context, in *OneAddDelL2ArpEntry) (*OneAddDelL2ArpEntryReply, error) + OneAddDelLocalEid(ctx context.Context, in *OneAddDelLocalEid) (*OneAddDelLocalEidReply, error) + OneAddDelLocator(ctx context.Context, in *OneAddDelLocator) (*OneAddDelLocatorReply, error) + OneAddDelLocatorSet(ctx context.Context, in *OneAddDelLocatorSet) (*OneAddDelLocatorSetReply, error) + OneAddDelMapRequestItrRlocs(ctx context.Context, in *OneAddDelMapRequestItrRlocs) (*OneAddDelMapRequestItrRlocsReply, error) + OneAddDelMapResolver(ctx context.Context, in *OneAddDelMapResolver) (*OneAddDelMapResolverReply, error) + OneAddDelMapServer(ctx context.Context, in *OneAddDelMapServer) (*OneAddDelMapServerReply, error) + OneAddDelNdpEntry(ctx context.Context, in *OneAddDelNdpEntry) (*OneAddDelNdpEntryReply, error) + OneAddDelRemoteMapping(ctx context.Context, in *OneAddDelRemoteMapping) (*OneAddDelRemoteMappingReply, error) + OneAdjacenciesGet(ctx context.Context, in *OneAdjacenciesGet) (*OneAdjacenciesGetReply, error) + OneEidTableAddDelMap(ctx context.Context, in *OneEidTableAddDelMap) (*OneEidTableAddDelMapReply, error) + OneEidTableDump(ctx context.Context, in *OneEidTableDump) (RPCService_OneEidTableDumpClient, error) + OneEidTableMapDump(ctx context.Context, in *OneEidTableMapDump) (RPCService_OneEidTableMapDumpClient, error) + OneEidTableVniDump(ctx context.Context, in *OneEidTableVniDump) (RPCService_OneEidTableVniDumpClient, error) + OneEnableDisable(ctx context.Context, in *OneEnableDisable) (*OneEnableDisableReply, error) + OneEnableDisablePetrMode(ctx context.Context, in *OneEnableDisablePetrMode) (*OneEnableDisablePetrModeReply, error) + OneEnableDisablePitrMode(ctx context.Context, in *OneEnableDisablePitrMode) (*OneEnableDisablePitrModeReply, error) + OneEnableDisableXtrMode(ctx context.Context, in *OneEnableDisableXtrMode) (*OneEnableDisableXtrModeReply, error) + OneGetMapRequestItrRlocs(ctx context.Context, in *OneGetMapRequestItrRlocs) (*OneGetMapRequestItrRlocsReply, error) + OneGetTransportProtocol(ctx context.Context, in *OneGetTransportProtocol) (*OneGetTransportProtocolReply, error) + OneL2ArpBdGet(ctx context.Context, in *OneL2ArpBdGet) (*OneL2ArpBdGetReply, error) + OneL2ArpEntriesGet(ctx context.Context, in *OneL2ArpEntriesGet) (*OneL2ArpEntriesGetReply, error) + OneLocatorDump(ctx context.Context, in *OneLocatorDump) (RPCService_OneLocatorDumpClient, error) + OneLocatorSetDump(ctx context.Context, in *OneLocatorSetDump) (RPCService_OneLocatorSetDumpClient, error) + OneMapRegisterEnableDisable(ctx context.Context, in *OneMapRegisterEnableDisable) (*OneMapRegisterEnableDisableReply, error) + OneMapRegisterFallbackThreshold(ctx context.Context, in *OneMapRegisterFallbackThreshold) (*OneMapRegisterFallbackThresholdReply, error) + OneMapRegisterSetTTL(ctx context.Context, in *OneMapRegisterSetTTL) (*OneMapRegisterSetTTLReply, error) + OneMapRequestMode(ctx context.Context, in *OneMapRequestMode) (*OneMapRequestModeReply, error) + OneMapResolverDump(ctx context.Context, in *OneMapResolverDump) (RPCService_OneMapResolverDumpClient, error) + OneMapServerDump(ctx context.Context, in *OneMapServerDump) (RPCService_OneMapServerDumpClient, error) + OneNdpBdGet(ctx context.Context, in *OneNdpBdGet) (*OneNdpBdGetReply, error) + OneNdpEntriesGet(ctx context.Context, in *OneNdpEntriesGet) (*OneNdpEntriesGetReply, error) + OneNshSetLocatorSet(ctx context.Context, in *OneNshSetLocatorSet) (*OneNshSetLocatorSetReply, error) + OnePitrSetLocatorSet(ctx context.Context, in *OnePitrSetLocatorSet) (*OnePitrSetLocatorSetReply, error) + OneRlocProbeEnableDisable(ctx context.Context, in *OneRlocProbeEnableDisable) (*OneRlocProbeEnableDisableReply, error) + OneSetTransportProtocol(ctx context.Context, in *OneSetTransportProtocol) (*OneSetTransportProtocolReply, error) + OneShowPetrMode(ctx context.Context, in *OneShowPetrMode) (*OneShowPetrModeReply, error) + OneShowPitrMode(ctx context.Context, in *OneShowPitrMode) (*OneShowPitrModeReply, error) + OneShowXtrMode(ctx context.Context, in *OneShowXtrMode) (*OneShowXtrModeReply, error) + OneStatsDump(ctx context.Context, in *OneStatsDump) (RPCService_OneStatsDumpClient, error) + OneStatsEnableDisable(ctx context.Context, in *OneStatsEnableDisable) (*OneStatsEnableDisableReply, error) + OneStatsFlush(ctx context.Context, in *OneStatsFlush) (*OneStatsFlushReply, error) + OneUsePetr(ctx context.Context, in *OneUsePetr) (*OneUsePetrReply, error) + ShowOneMapRegisterFallbackThreshold(ctx context.Context, in *ShowOneMapRegisterFallbackThreshold) (*ShowOneMapRegisterFallbackThresholdReply, error) + ShowOneMapRegisterState(ctx context.Context, in *ShowOneMapRegisterState) (*ShowOneMapRegisterStateReply, error) + ShowOneMapRegisterTTL(ctx context.Context, in *ShowOneMapRegisterTTL) (*ShowOneMapRegisterTTLReply, error) + ShowOneMapRequestMode(ctx context.Context, in *ShowOneMapRequestMode) (*ShowOneMapRequestModeReply, error) + ShowOneNshMapping(ctx context.Context, in *ShowOneNshMapping) (*ShowOneNshMappingReply, error) + ShowOnePitr(ctx context.Context, in *ShowOnePitr) (*ShowOnePitrReply, error) + ShowOneRlocProbeState(ctx context.Context, in *ShowOneRlocProbeState) (*ShowOneRlocProbeStateReply, error) + ShowOneStatsEnableDisable(ctx context.Context, in *ShowOneStatsEnableDisable) (*ShowOneStatsEnableDisableReply, error) + ShowOneStatus(ctx context.Context, in *ShowOneStatus) (*ShowOneStatusReply, error) + ShowOneUsePetr(ctx context.Context, in *ShowOneUsePetr) (*ShowOneUsePetrReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) OneAddDelAdjacency(ctx context.Context, in *OneAddDelAdjacency) (*OneAddDelAdjacencyReply, error) { + out := new(OneAddDelAdjacencyReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneAddDelL2ArpEntry(ctx context.Context, in *OneAddDelL2ArpEntry) (*OneAddDelL2ArpEntryReply, error) { + out := new(OneAddDelL2ArpEntryReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneAddDelLocalEid(ctx context.Context, in *OneAddDelLocalEid) (*OneAddDelLocalEidReply, error) { + out := new(OneAddDelLocalEidReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneAddDelLocator(ctx context.Context, in *OneAddDelLocator) (*OneAddDelLocatorReply, error) { + out := new(OneAddDelLocatorReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneAddDelLocatorSet(ctx context.Context, in *OneAddDelLocatorSet) (*OneAddDelLocatorSetReply, error) { + out := new(OneAddDelLocatorSetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneAddDelMapRequestItrRlocs(ctx context.Context, in *OneAddDelMapRequestItrRlocs) (*OneAddDelMapRequestItrRlocsReply, error) { + out := new(OneAddDelMapRequestItrRlocsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneAddDelMapResolver(ctx context.Context, in *OneAddDelMapResolver) (*OneAddDelMapResolverReply, error) { + out := new(OneAddDelMapResolverReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneAddDelMapServer(ctx context.Context, in *OneAddDelMapServer) (*OneAddDelMapServerReply, error) { + out := new(OneAddDelMapServerReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneAddDelNdpEntry(ctx context.Context, in *OneAddDelNdpEntry) (*OneAddDelNdpEntryReply, error) { + out := new(OneAddDelNdpEntryReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneAddDelRemoteMapping(ctx context.Context, in *OneAddDelRemoteMapping) (*OneAddDelRemoteMappingReply, error) { + out := new(OneAddDelRemoteMappingReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneAdjacenciesGet(ctx context.Context, in *OneAdjacenciesGet) (*OneAdjacenciesGetReply, error) { + out := new(OneAdjacenciesGetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneEidTableAddDelMap(ctx context.Context, in *OneEidTableAddDelMap) (*OneEidTableAddDelMapReply, error) { + out := new(OneEidTableAddDelMapReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneEidTableDump(ctx context.Context, in *OneEidTableDump) (RPCService_OneEidTableDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_OneEidTableDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_OneEidTableDumpClient interface { + Recv() (*OneEidTableDetails, error) + api.Stream +} + +type serviceClient_OneEidTableDumpClient struct { + api.Stream +} + +func (c *serviceClient_OneEidTableDumpClient) Recv() (*OneEidTableDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *OneEidTableDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) OneEidTableMapDump(ctx context.Context, in *OneEidTableMapDump) (RPCService_OneEidTableMapDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_OneEidTableMapDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_OneEidTableMapDumpClient interface { + Recv() (*OneEidTableMapDetails, error) + api.Stream +} + +type serviceClient_OneEidTableMapDumpClient struct { + api.Stream +} + +func (c *serviceClient_OneEidTableMapDumpClient) Recv() (*OneEidTableMapDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *OneEidTableMapDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) OneEidTableVniDump(ctx context.Context, in *OneEidTableVniDump) (RPCService_OneEidTableVniDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_OneEidTableVniDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_OneEidTableVniDumpClient interface { + Recv() (*OneEidTableVniDetails, error) + api.Stream +} + +type serviceClient_OneEidTableVniDumpClient struct { + api.Stream +} + +func (c *serviceClient_OneEidTableVniDumpClient) Recv() (*OneEidTableVniDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *OneEidTableVniDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) OneEnableDisable(ctx context.Context, in *OneEnableDisable) (*OneEnableDisableReply, error) { + out := new(OneEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneEnableDisablePetrMode(ctx context.Context, in *OneEnableDisablePetrMode) (*OneEnableDisablePetrModeReply, error) { + out := new(OneEnableDisablePetrModeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneEnableDisablePitrMode(ctx context.Context, in *OneEnableDisablePitrMode) (*OneEnableDisablePitrModeReply, error) { + out := new(OneEnableDisablePitrModeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneEnableDisableXtrMode(ctx context.Context, in *OneEnableDisableXtrMode) (*OneEnableDisableXtrModeReply, error) { + out := new(OneEnableDisableXtrModeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneGetMapRequestItrRlocs(ctx context.Context, in *OneGetMapRequestItrRlocs) (*OneGetMapRequestItrRlocsReply, error) { + out := new(OneGetMapRequestItrRlocsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneGetTransportProtocol(ctx context.Context, in *OneGetTransportProtocol) (*OneGetTransportProtocolReply, error) { + out := new(OneGetTransportProtocolReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneL2ArpBdGet(ctx context.Context, in *OneL2ArpBdGet) (*OneL2ArpBdGetReply, error) { + out := new(OneL2ArpBdGetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneL2ArpEntriesGet(ctx context.Context, in *OneL2ArpEntriesGet) (*OneL2ArpEntriesGetReply, error) { + out := new(OneL2ArpEntriesGetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneLocatorDump(ctx context.Context, in *OneLocatorDump) (RPCService_OneLocatorDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_OneLocatorDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_OneLocatorDumpClient interface { + Recv() (*OneLocatorDetails, error) + api.Stream +} + +type serviceClient_OneLocatorDumpClient struct { + api.Stream +} + +func (c *serviceClient_OneLocatorDumpClient) Recv() (*OneLocatorDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *OneLocatorDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) OneLocatorSetDump(ctx context.Context, in *OneLocatorSetDump) (RPCService_OneLocatorSetDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_OneLocatorSetDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_OneLocatorSetDumpClient interface { + Recv() (*OneLocatorSetDetails, error) + api.Stream +} + +type serviceClient_OneLocatorSetDumpClient struct { + api.Stream +} + +func (c *serviceClient_OneLocatorSetDumpClient) Recv() (*OneLocatorSetDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *OneLocatorSetDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) OneMapRegisterEnableDisable(ctx context.Context, in *OneMapRegisterEnableDisable) (*OneMapRegisterEnableDisableReply, error) { + out := new(OneMapRegisterEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneMapRegisterFallbackThreshold(ctx context.Context, in *OneMapRegisterFallbackThreshold) (*OneMapRegisterFallbackThresholdReply, error) { + out := new(OneMapRegisterFallbackThresholdReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneMapRegisterSetTTL(ctx context.Context, in *OneMapRegisterSetTTL) (*OneMapRegisterSetTTLReply, error) { + out := new(OneMapRegisterSetTTLReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneMapRequestMode(ctx context.Context, in *OneMapRequestMode) (*OneMapRequestModeReply, error) { + out := new(OneMapRequestModeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneMapResolverDump(ctx context.Context, in *OneMapResolverDump) (RPCService_OneMapResolverDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_OneMapResolverDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_OneMapResolverDumpClient interface { + Recv() (*OneMapResolverDetails, error) + api.Stream +} + +type serviceClient_OneMapResolverDumpClient struct { + api.Stream +} + +func (c *serviceClient_OneMapResolverDumpClient) Recv() (*OneMapResolverDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *OneMapResolverDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) OneMapServerDump(ctx context.Context, in *OneMapServerDump) (RPCService_OneMapServerDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_OneMapServerDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_OneMapServerDumpClient interface { + Recv() (*OneMapServerDetails, error) + api.Stream +} + +type serviceClient_OneMapServerDumpClient struct { + api.Stream +} + +func (c *serviceClient_OneMapServerDumpClient) Recv() (*OneMapServerDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *OneMapServerDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) OneNdpBdGet(ctx context.Context, in *OneNdpBdGet) (*OneNdpBdGetReply, error) { + out := new(OneNdpBdGetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneNdpEntriesGet(ctx context.Context, in *OneNdpEntriesGet) (*OneNdpEntriesGetReply, error) { + out := new(OneNdpEntriesGetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneNshSetLocatorSet(ctx context.Context, in *OneNshSetLocatorSet) (*OneNshSetLocatorSetReply, error) { + out := new(OneNshSetLocatorSetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OnePitrSetLocatorSet(ctx context.Context, in *OnePitrSetLocatorSet) (*OnePitrSetLocatorSetReply, error) { + out := new(OnePitrSetLocatorSetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneRlocProbeEnableDisable(ctx context.Context, in *OneRlocProbeEnableDisable) (*OneRlocProbeEnableDisableReply, error) { + out := new(OneRlocProbeEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneSetTransportProtocol(ctx context.Context, in *OneSetTransportProtocol) (*OneSetTransportProtocolReply, error) { + out := new(OneSetTransportProtocolReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneShowPetrMode(ctx context.Context, in *OneShowPetrMode) (*OneShowPetrModeReply, error) { + out := new(OneShowPetrModeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneShowPitrMode(ctx context.Context, in *OneShowPitrMode) (*OneShowPitrModeReply, error) { + out := new(OneShowPitrModeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneShowXtrMode(ctx context.Context, in *OneShowXtrMode) (*OneShowXtrModeReply, error) { + out := new(OneShowXtrModeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneStatsDump(ctx context.Context, in *OneStatsDump) (RPCService_OneStatsDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_OneStatsDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_OneStatsDumpClient interface { + Recv() (*OneStatsDetails, error) + api.Stream +} + +type serviceClient_OneStatsDumpClient struct { + api.Stream +} + +func (c *serviceClient_OneStatsDumpClient) Recv() (*OneStatsDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *OneStatsDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) OneStatsEnableDisable(ctx context.Context, in *OneStatsEnableDisable) (*OneStatsEnableDisableReply, error) { + out := new(OneStatsEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneStatsFlush(ctx context.Context, in *OneStatsFlush) (*OneStatsFlushReply, error) { + out := new(OneStatsFlushReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OneUsePetr(ctx context.Context, in *OneUsePetr) (*OneUsePetrReply, error) { + out := new(OneUsePetrReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowOneMapRegisterFallbackThreshold(ctx context.Context, in *ShowOneMapRegisterFallbackThreshold) (*ShowOneMapRegisterFallbackThresholdReply, error) { + out := new(ShowOneMapRegisterFallbackThresholdReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowOneMapRegisterState(ctx context.Context, in *ShowOneMapRegisterState) (*ShowOneMapRegisterStateReply, error) { + out := new(ShowOneMapRegisterStateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowOneMapRegisterTTL(ctx context.Context, in *ShowOneMapRegisterTTL) (*ShowOneMapRegisterTTLReply, error) { + out := new(ShowOneMapRegisterTTLReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowOneMapRequestMode(ctx context.Context, in *ShowOneMapRequestMode) (*ShowOneMapRequestModeReply, error) { + out := new(ShowOneMapRequestModeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowOneNshMapping(ctx context.Context, in *ShowOneNshMapping) (*ShowOneNshMappingReply, error) { + out := new(ShowOneNshMappingReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowOnePitr(ctx context.Context, in *ShowOnePitr) (*ShowOnePitrReply, error) { + out := new(ShowOnePitrReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowOneRlocProbeState(ctx context.Context, in *ShowOneRlocProbeState) (*ShowOneRlocProbeStateReply, error) { + out := new(ShowOneRlocProbeStateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowOneStatsEnableDisable(ctx context.Context, in *ShowOneStatsEnableDisable) (*ShowOneStatsEnableDisableReply, error) { + out := new(ShowOneStatsEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowOneStatus(ctx context.Context, in *ShowOneStatus) (*ShowOneStatusReply, error) { + out := new(ShowOneStatusReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ShowOneUsePetr(ctx context.Context, in *ShowOneUsePetr) (*ShowOneUsePetrReply, error) { + out := new(ShowOneUsePetrReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/p2p_ethernet/p2p_ethernet.ba.go b/binapi/p2p_ethernet/p2p_ethernet.ba.go new file mode 100644 index 00000000..54c15ad1 --- /dev/null +++ b/binapi/p2p_ethernet/p2p_ethernet.ba.go @@ -0,0 +1,211 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/p2p_ethernet.api.json + +// Package p2p_ethernet contains generated bindings for API file p2p_ethernet.api. +// +// Contents: +// - 4 messages +package p2p_ethernet + +import ( + api "github.com/alkiranet/govpp/api" + ethernet_types "github.com/alkiranet/govpp/binapi/ethernet_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "p2p_ethernet" + APIVersion = "1.0.0" + VersionCrc = 0x3cfe55da +) + +// Create a point-to-point (p2p) Ethernet sub-interface +// - parent_if_index - index of the parent interface +// - subif_id - subinterface index identifier +// - remote_mac - client MAC address +// @retval VNET_API_ERROR_INVALID_SW_IF_INDEX on invalid parent_if_index +// @retval VNET_API_ERROR_INVALID_SW_IF_INDEX_2 on invalid subif_id +// @retval VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED +// @retval VNET_API_ERROR_SUBIF_ALREADY_EXISTS +// @retval VNET_API_ERROR_SUBIF_CREATE_FAILED +// +// P2pEthernetAdd defines message 'p2p_ethernet_add'. +type P2pEthernetAdd struct { + ParentIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=parent_if_index" json:"parent_if_index,omitempty"` + SubifID uint32 `binapi:"u32,name=subif_id" json:"subif_id,omitempty"` + RemoteMac ethernet_types.MacAddress `binapi:"mac_address,name=remote_mac" json:"remote_mac,omitempty"` +} + +func (m *P2pEthernetAdd) Reset() { *m = P2pEthernetAdd{} } +func (*P2pEthernetAdd) GetMessageName() string { return "p2p_ethernet_add" } +func (*P2pEthernetAdd) GetCrcString() string { return "36a1a6dc" } +func (*P2pEthernetAdd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *P2pEthernetAdd) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ParentIfIndex + size += 4 // m.SubifID + size += 1 * 6 // m.RemoteMac + return size +} +func (m *P2pEthernetAdd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.ParentIfIndex)) + buf.EncodeUint32(m.SubifID) + buf.EncodeBytes(m.RemoteMac[:], 6) + return buf.Bytes(), nil +} +func (m *P2pEthernetAdd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ParentIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.SubifID = buf.DecodeUint32() + copy(m.RemoteMac[:], buf.DecodeBytes(6)) + return nil +} + +// P2pEthernetAddReply defines message 'p2p_ethernet_add_reply'. +type P2pEthernetAddReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *P2pEthernetAddReply) Reset() { *m = P2pEthernetAddReply{} } +func (*P2pEthernetAddReply) GetMessageName() string { return "p2p_ethernet_add_reply" } +func (*P2pEthernetAddReply) GetCrcString() string { return "5383d31f" } +func (*P2pEthernetAddReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *P2pEthernetAddReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *P2pEthernetAddReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *P2pEthernetAddReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Delete a point-to-point (p2p) Ethernet sub-interface +// - parent_if_index - index of the parent interface +// - remote_mac - client MAC address +// @retval VNET_API_ERROR_SUBIF_DOESNT_EXIST +// +// P2pEthernetDel defines message 'p2p_ethernet_del'. +type P2pEthernetDel struct { + ParentIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=parent_if_index" json:"parent_if_index,omitempty"` + RemoteMac ethernet_types.MacAddress `binapi:"mac_address,name=remote_mac" json:"remote_mac,omitempty"` +} + +func (m *P2pEthernetDel) Reset() { *m = P2pEthernetDel{} } +func (*P2pEthernetDel) GetMessageName() string { return "p2p_ethernet_del" } +func (*P2pEthernetDel) GetCrcString() string { return "62f81c8c" } +func (*P2pEthernetDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *P2pEthernetDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ParentIfIndex + size += 1 * 6 // m.RemoteMac + return size +} +func (m *P2pEthernetDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.ParentIfIndex)) + buf.EncodeBytes(m.RemoteMac[:], 6) + return buf.Bytes(), nil +} +func (m *P2pEthernetDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ParentIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + copy(m.RemoteMac[:], buf.DecodeBytes(6)) + return nil +} + +// P2pEthernetDelReply defines message 'p2p_ethernet_del_reply'. +type P2pEthernetDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *P2pEthernetDelReply) Reset() { *m = P2pEthernetDelReply{} } +func (*P2pEthernetDelReply) GetMessageName() string { return "p2p_ethernet_del_reply" } +func (*P2pEthernetDelReply) GetCrcString() string { return "e8d4e804" } +func (*P2pEthernetDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *P2pEthernetDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *P2pEthernetDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *P2pEthernetDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_p2p_ethernet_binapi_init() } +func file_p2p_ethernet_binapi_init() { + api.RegisterMessage((*P2pEthernetAdd)(nil), "p2p_ethernet_add_36a1a6dc") + api.RegisterMessage((*P2pEthernetAddReply)(nil), "p2p_ethernet_add_reply_5383d31f") + api.RegisterMessage((*P2pEthernetDel)(nil), "p2p_ethernet_del_62f81c8c") + api.RegisterMessage((*P2pEthernetDelReply)(nil), "p2p_ethernet_del_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*P2pEthernetAdd)(nil), + (*P2pEthernetAddReply)(nil), + (*P2pEthernetDel)(nil), + (*P2pEthernetDelReply)(nil), + } +} diff --git a/binapi/p2p_ethernet/p2p_ethernet_rpc.ba.go b/binapi/p2p_ethernet/p2p_ethernet_rpc.ba.go new file mode 100644 index 00000000..d964dcc5 --- /dev/null +++ b/binapi/p2p_ethernet/p2p_ethernet_rpc.ba.go @@ -0,0 +1,41 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package p2p_ethernet + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service p2p_ethernet. +type RPCService interface { + P2pEthernetAdd(ctx context.Context, in *P2pEthernetAdd) (*P2pEthernetAddReply, error) + P2pEthernetDel(ctx context.Context, in *P2pEthernetDel) (*P2pEthernetDelReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) P2pEthernetAdd(ctx context.Context, in *P2pEthernetAdd) (*P2pEthernetAddReply, error) { + out := new(P2pEthernetAddReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) P2pEthernetDel(ctx context.Context, in *P2pEthernetDel) (*P2pEthernetDelReply, error) { + out := new(P2pEthernetDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/pci_types/pci_types.ba.go b/binapi/pci_types/pci_types.ba.go new file mode 100644 index 00000000..08f6eb87 --- /dev/null +++ b/binapi/pci_types/pci_types.ba.go @@ -0,0 +1,35 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/pci_types.api.json + +// Package pci_types contains generated bindings for API file pci_types.api. +// +// Contents: +// - 1 struct +package pci_types + +import ( + api "github.com/alkiranet/govpp/api" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "pci_types" + APIVersion = "1.0.0" + VersionCrc = 0x5d418665 +) + +// PciAddress defines type 'pci_address'. +type PciAddress struct { + Domain uint16 `binapi:"u16,name=domain" json:"domain,omitempty"` + Bus uint8 `binapi:"u8,name=bus" json:"bus,omitempty"` + Slot uint8 `binapi:"u8,name=slot" json:"slot,omitempty"` + Function uint8 `binapi:"u8,name=function" json:"function,omitempty"` +} diff --git a/binapi/pg/pg.ba.go b/binapi/pg/pg.ba.go new file mode 100644 index 00000000..1bbd93be --- /dev/null +++ b/binapi/pg/pg.ba.go @@ -0,0 +1,498 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/pg.api.json + +// Package pg contains generated bindings for API file pg.api. +// +// Contents: +// - 1 enum +// - 10 messages +package pg + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "pg" + APIVersion = "2.0.0" + VersionCrc = 0x32a1ad3b +) + +// PgInterfaceMode defines enum 'pg_interface_mode'. +type PgInterfaceMode uint8 + +const ( + PG_API_MODE_ETHERNET PgInterfaceMode = 0 + PG_API_MODE_IP4 PgInterfaceMode = 1 + PG_API_MODE_IP6 PgInterfaceMode = 2 +) + +var ( + PgInterfaceMode_name = map[uint8]string{ + 0: "PG_API_MODE_ETHERNET", + 1: "PG_API_MODE_IP4", + 2: "PG_API_MODE_IP6", + } + PgInterfaceMode_value = map[string]uint8{ + "PG_API_MODE_ETHERNET": 0, + "PG_API_MODE_IP4": 1, + "PG_API_MODE_IP6": 2, + } +) + +func (x PgInterfaceMode) String() string { + s, ok := PgInterfaceMode_name[uint8(x)] + if ok { + return s + } + return "PgInterfaceMode(" + strconv.Itoa(int(x)) + ")" +} + +// PacketGenerator capture packets on given interface request +// - interface_id - pg interface index +// - is_enabled - 1 if enabling streams, 0 if disabling +// - count - number of packets to be captured +// - pcap_file_name - pacp file name to store captured packets +// +// PgCapture defines message 'pg_capture'. +type PgCapture struct { + InterfaceID interface_types.InterfaceIndex `binapi:"interface_index,name=interface_id" json:"interface_id,omitempty"` + IsEnabled bool `binapi:"bool,name=is_enabled,default=true" json:"is_enabled,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"count,omitempty"` + PcapFileName string `binapi:"string[],name=pcap_file_name" json:"pcap_file_name,omitempty"` +} + +func (m *PgCapture) Reset() { *m = PgCapture{} } +func (*PgCapture) GetMessageName() string { return "pg_capture" } +func (*PgCapture) GetCrcString() string { return "3712fb6c" } +func (*PgCapture) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PgCapture) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.InterfaceID + size += 1 // m.IsEnabled + size += 4 // m.Count + size += 4 + len(m.PcapFileName) // m.PcapFileName + return size +} +func (m *PgCapture) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.InterfaceID)) + buf.EncodeBool(m.IsEnabled) + buf.EncodeUint32(m.Count) + buf.EncodeString(m.PcapFileName, 0) + return buf.Bytes(), nil +} +func (m *PgCapture) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.InterfaceID = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsEnabled = buf.DecodeBool() + m.Count = buf.DecodeUint32() + m.PcapFileName = buf.DecodeString(0) + return nil +} + +// PgCaptureReply defines message 'pg_capture_reply'. +type PgCaptureReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PgCaptureReply) Reset() { *m = PgCaptureReply{} } +func (*PgCaptureReply) GetMessageName() string { return "pg_capture_reply" } +func (*PgCaptureReply) GetCrcString() string { return "e8d4e804" } +func (*PgCaptureReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PgCaptureReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PgCaptureReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PgCaptureReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// PacketGenerator create interface request +// - interface_id - interface index +// - gso_enabled - enable gso on this interface +// - gso_size - gso size on this interface +// +// PgCreateInterface defines message 'pg_create_interface'. +type PgCreateInterface struct { + InterfaceID interface_types.InterfaceIndex `binapi:"interface_index,name=interface_id" json:"interface_id,omitempty"` + GsoEnabled bool `binapi:"bool,name=gso_enabled" json:"gso_enabled,omitempty"` + GsoSize uint32 `binapi:"u32,name=gso_size" json:"gso_size,omitempty"` +} + +func (m *PgCreateInterface) Reset() { *m = PgCreateInterface{} } +func (*PgCreateInterface) GetMessageName() string { return "pg_create_interface" } +func (*PgCreateInterface) GetCrcString() string { return "b7c893d7" } +func (*PgCreateInterface) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PgCreateInterface) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.InterfaceID + size += 1 // m.GsoEnabled + size += 4 // m.GsoSize + return size +} +func (m *PgCreateInterface) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.InterfaceID)) + buf.EncodeBool(m.GsoEnabled) + buf.EncodeUint32(m.GsoSize) + return buf.Bytes(), nil +} +func (m *PgCreateInterface) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.InterfaceID = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.GsoEnabled = buf.DecodeBool() + m.GsoSize = buf.DecodeUint32() + return nil +} + +// PacketGenerator create interface response +// - retval - return value for request +// +// PgCreateInterfaceReply defines message 'pg_create_interface_reply'. +type PgCreateInterfaceReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *PgCreateInterfaceReply) Reset() { *m = PgCreateInterfaceReply{} } +func (*PgCreateInterfaceReply) GetMessageName() string { return "pg_create_interface_reply" } +func (*PgCreateInterfaceReply) GetCrcString() string { return "5383d31f" } +func (*PgCreateInterfaceReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PgCreateInterfaceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *PgCreateInterfaceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *PgCreateInterfaceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// PgCreateInterfaceV2 defines message 'pg_create_interface_v2'. +type PgCreateInterfaceV2 struct { + InterfaceID interface_types.InterfaceIndex `binapi:"interface_index,name=interface_id" json:"interface_id,omitempty"` + GsoEnabled bool `binapi:"bool,name=gso_enabled" json:"gso_enabled,omitempty"` + GsoSize uint32 `binapi:"u32,name=gso_size" json:"gso_size,omitempty"` + Mode PgInterfaceMode `binapi:"pg_interface_mode,name=mode" json:"mode,omitempty"` +} + +func (m *PgCreateInterfaceV2) Reset() { *m = PgCreateInterfaceV2{} } +func (*PgCreateInterfaceV2) GetMessageName() string { return "pg_create_interface_v2" } +func (*PgCreateInterfaceV2) GetCrcString() string { return "8657466a" } +func (*PgCreateInterfaceV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PgCreateInterfaceV2) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.InterfaceID + size += 1 // m.GsoEnabled + size += 4 // m.GsoSize + size += 1 // m.Mode + return size +} +func (m *PgCreateInterfaceV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.InterfaceID)) + buf.EncodeBool(m.GsoEnabled) + buf.EncodeUint32(m.GsoSize) + buf.EncodeUint8(uint8(m.Mode)) + return buf.Bytes(), nil +} +func (m *PgCreateInterfaceV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.InterfaceID = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.GsoEnabled = buf.DecodeBool() + m.GsoSize = buf.DecodeUint32() + m.Mode = PgInterfaceMode(buf.DecodeUint8()) + return nil +} + +// PgCreateInterfaceV2Reply defines message 'pg_create_interface_v2_reply'. +type PgCreateInterfaceV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *PgCreateInterfaceV2Reply) Reset() { *m = PgCreateInterfaceV2Reply{} } +func (*PgCreateInterfaceV2Reply) GetMessageName() string { return "pg_create_interface_v2_reply" } +func (*PgCreateInterfaceV2Reply) GetCrcString() string { return "5383d31f" } +func (*PgCreateInterfaceV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PgCreateInterfaceV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *PgCreateInterfaceV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *PgCreateInterfaceV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Enable / disable packet generator request +// - is_enabled - 1 if enabling streams, 0 if disabling +// - stream_name - stream name to be enable/disabled, if not specified handle all streams +// +// PgEnableDisable defines message 'pg_enable_disable'. +type PgEnableDisable struct { + IsEnabled bool `binapi:"bool,name=is_enabled,default=true" json:"is_enabled,omitempty"` + StreamName string `binapi:"string[],name=stream_name" json:"stream_name,omitempty"` +} + +func (m *PgEnableDisable) Reset() { *m = PgEnableDisable{} } +func (*PgEnableDisable) GetMessageName() string { return "pg_enable_disable" } +func (*PgEnableDisable) GetCrcString() string { return "01f94f3a" } +func (*PgEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PgEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsEnabled + size += 4 + len(m.StreamName) // m.StreamName + return size +} +func (m *PgEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsEnabled) + buf.EncodeString(m.StreamName, 0) + return buf.Bytes(), nil +} +func (m *PgEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsEnabled = buf.DecodeBool() + m.StreamName = buf.DecodeString(0) + return nil +} + +// PgEnableDisableReply defines message 'pg_enable_disable_reply'. +type PgEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PgEnableDisableReply) Reset() { *m = PgEnableDisableReply{} } +func (*PgEnableDisableReply) GetMessageName() string { return "pg_enable_disable_reply" } +func (*PgEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*PgEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PgEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PgEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PgEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// PacketGenerator interface enable/disable packet coalesce +// - interface_id - interface index +// - coalesce_enabled - enable/disable packet coalesce on this interface +// +// PgInterfaceEnableDisableCoalesce defines message 'pg_interface_enable_disable_coalesce'. +// InProgress: the message form may change in the future versions +type PgInterfaceEnableDisableCoalesce struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + CoalesceEnabled bool `binapi:"bool,name=coalesce_enabled" json:"coalesce_enabled,omitempty"` +} + +func (m *PgInterfaceEnableDisableCoalesce) Reset() { *m = PgInterfaceEnableDisableCoalesce{} } +func (*PgInterfaceEnableDisableCoalesce) GetMessageName() string { + return "pg_interface_enable_disable_coalesce" +} +func (*PgInterfaceEnableDisableCoalesce) GetCrcString() string { return "a2ef99e7" } +func (*PgInterfaceEnableDisableCoalesce) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PgInterfaceEnableDisableCoalesce) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.CoalesceEnabled + return size +} +func (m *PgInterfaceEnableDisableCoalesce) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.CoalesceEnabled) + return buf.Bytes(), nil +} +func (m *PgInterfaceEnableDisableCoalesce) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.CoalesceEnabled = buf.DecodeBool() + return nil +} + +// PgInterfaceEnableDisableCoalesceReply defines message 'pg_interface_enable_disable_coalesce_reply'. +// InProgress: the message form may change in the future versions +type PgInterfaceEnableDisableCoalesceReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PgInterfaceEnableDisableCoalesceReply) Reset() { *m = PgInterfaceEnableDisableCoalesceReply{} } +func (*PgInterfaceEnableDisableCoalesceReply) GetMessageName() string { + return "pg_interface_enable_disable_coalesce_reply" +} +func (*PgInterfaceEnableDisableCoalesceReply) GetCrcString() string { return "e8d4e804" } +func (*PgInterfaceEnableDisableCoalesceReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PgInterfaceEnableDisableCoalesceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PgInterfaceEnableDisableCoalesceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PgInterfaceEnableDisableCoalesceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_pg_binapi_init() } +func file_pg_binapi_init() { + api.RegisterMessage((*PgCapture)(nil), "pg_capture_3712fb6c") + api.RegisterMessage((*PgCaptureReply)(nil), "pg_capture_reply_e8d4e804") + api.RegisterMessage((*PgCreateInterface)(nil), "pg_create_interface_b7c893d7") + api.RegisterMessage((*PgCreateInterfaceReply)(nil), "pg_create_interface_reply_5383d31f") + api.RegisterMessage((*PgCreateInterfaceV2)(nil), "pg_create_interface_v2_8657466a") + api.RegisterMessage((*PgCreateInterfaceV2Reply)(nil), "pg_create_interface_v2_reply_5383d31f") + api.RegisterMessage((*PgEnableDisable)(nil), "pg_enable_disable_01f94f3a") + api.RegisterMessage((*PgEnableDisableReply)(nil), "pg_enable_disable_reply_e8d4e804") + api.RegisterMessage((*PgInterfaceEnableDisableCoalesce)(nil), "pg_interface_enable_disable_coalesce_a2ef99e7") + api.RegisterMessage((*PgInterfaceEnableDisableCoalesceReply)(nil), "pg_interface_enable_disable_coalesce_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*PgCapture)(nil), + (*PgCaptureReply)(nil), + (*PgCreateInterface)(nil), + (*PgCreateInterfaceReply)(nil), + (*PgCreateInterfaceV2)(nil), + (*PgCreateInterfaceV2Reply)(nil), + (*PgEnableDisable)(nil), + (*PgEnableDisableReply)(nil), + (*PgInterfaceEnableDisableCoalesce)(nil), + (*PgInterfaceEnableDisableCoalesceReply)(nil), + } +} diff --git a/binapi/pg/pg_rpc.ba.go b/binapi/pg/pg_rpc.ba.go new file mode 100644 index 00000000..b970fc08 --- /dev/null +++ b/binapi/pg/pg_rpc.ba.go @@ -0,0 +1,71 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package pg + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service pg. +type RPCService interface { + PgCapture(ctx context.Context, in *PgCapture) (*PgCaptureReply, error) + PgCreateInterface(ctx context.Context, in *PgCreateInterface) (*PgCreateInterfaceReply, error) + PgCreateInterfaceV2(ctx context.Context, in *PgCreateInterfaceV2) (*PgCreateInterfaceV2Reply, error) + PgEnableDisable(ctx context.Context, in *PgEnableDisable) (*PgEnableDisableReply, error) + PgInterfaceEnableDisableCoalesce(ctx context.Context, in *PgInterfaceEnableDisableCoalesce) (*PgInterfaceEnableDisableCoalesceReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) PgCapture(ctx context.Context, in *PgCapture) (*PgCaptureReply, error) { + out := new(PgCaptureReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PgCreateInterface(ctx context.Context, in *PgCreateInterface) (*PgCreateInterfaceReply, error) { + out := new(PgCreateInterfaceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PgCreateInterfaceV2(ctx context.Context, in *PgCreateInterfaceV2) (*PgCreateInterfaceV2Reply, error) { + out := new(PgCreateInterfaceV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PgEnableDisable(ctx context.Context, in *PgEnableDisable) (*PgEnableDisableReply, error) { + out := new(PgEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PgInterfaceEnableDisableCoalesce(ctx context.Context, in *PgInterfaceEnableDisableCoalesce) (*PgInterfaceEnableDisableCoalesceReply, error) { + out := new(PgInterfaceEnableDisableCoalesceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/pipe/pipe.ba.go b/binapi/pipe/pipe.ba.go new file mode 100644 index 00000000..b433e732 --- /dev/null +++ b/binapi/pipe/pipe.ba.go @@ -0,0 +1,295 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/pipe.api.json + +// Package pipe contains generated bindings for API file pipe.api. +// +// Contents: +// - 6 messages +package pipe + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "pipe" + APIVersion = "1.0.1" + VersionCrc = 0xc159134a +) + +// Initialize a new pipe interface with the given parameters +// - is_specified - if non-0, a specific user_instance is being requested +// - user_instance - requested instance, ~0 => dynamically allocate +// +// PipeCreate defines message 'pipe_create'. +type PipeCreate struct { + IsSpecified bool `binapi:"bool,name=is_specified" json:"is_specified,omitempty"` + UserInstance uint32 `binapi:"u32,name=user_instance" json:"user_instance,omitempty"` +} + +func (m *PipeCreate) Reset() { *m = PipeCreate{} } +func (*PipeCreate) GetMessageName() string { return "pipe_create" } +func (*PipeCreate) GetCrcString() string { return "bb263bd3" } +func (*PipeCreate) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PipeCreate) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsSpecified + size += 4 // m.UserInstance + return size +} +func (m *PipeCreate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsSpecified) + buf.EncodeUint32(m.UserInstance) + return buf.Bytes(), nil +} +func (m *PipeCreate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsSpecified = buf.DecodeBool() + m.UserInstance = buf.DecodeUint32() + return nil +} + +// Reply for pipe create reply +// - retval - return code +// - sw_if_index - software index allocated for the new pipe parent interface +// Use the parent interface for link up/down and to delete +// - pipe_sw_if_index - the two SW indicies that form the ends of the pipe. +// +// PipeCreateReply defines message 'pipe_create_reply'. +type PipeCreateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + PipeSwIfIndex [2]interface_types.InterfaceIndex `binapi:"interface_index[2],name=pipe_sw_if_index" json:"pipe_sw_if_index,omitempty"` +} + +func (m *PipeCreateReply) Reset() { *m = PipeCreateReply{} } +func (*PipeCreateReply) GetMessageName() string { return "pipe_create_reply" } +func (*PipeCreateReply) GetCrcString() string { return "b7ce310c" } +func (*PipeCreateReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PipeCreateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + for j1 := 0; j1 < 2; j1++ { + size += 4 // m.PipeSwIfIndex[j1] + } + return size +} +func (m *PipeCreateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + for j0 := 0; j0 < 2; j0++ { + buf.EncodeUint32(uint32(m.PipeSwIfIndex[j0])) + } + return buf.Bytes(), nil +} +func (m *PipeCreateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + for j0 := 0; j0 < 2; j0++ { + m.PipeSwIfIndex[j0] = interface_types.InterfaceIndex(buf.DecodeUint32()) + } + return nil +} + +// Delete pipe interface +// - sw_if_index - interface index of existing parent pipe interface +// +// PipeDelete defines message 'pipe_delete'. +type PipeDelete struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *PipeDelete) Reset() { *m = PipeDelete{} } +func (*PipeDelete) GetMessageName() string { return "pipe_delete" } +func (*PipeDelete) GetCrcString() string { return "f9e6675e" } +func (*PipeDelete) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PipeDelete) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *PipeDelete) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *PipeDelete) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// PipeDeleteReply defines message 'pipe_delete_reply'. +type PipeDeleteReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PipeDeleteReply) Reset() { *m = PipeDeleteReply{} } +func (*PipeDeleteReply) GetMessageName() string { return "pipe_delete_reply" } +func (*PipeDeleteReply) GetCrcString() string { return "e8d4e804" } +func (*PipeDeleteReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PipeDeleteReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PipeDeleteReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PipeDeleteReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Reply for pipe dump request +// - sw_if_index - software index of pipe interface +// - sw_if_index - software index allocated for the pipe parent interface +// - pipe_sw_if_index - the two SW indicies that form the ends of the pipe. +// - instance - instance allocated +// +// PipeDetails defines message 'pipe_details'. +type PipeDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + PipeSwIfIndex [2]interface_types.InterfaceIndex `binapi:"interface_index[2],name=pipe_sw_if_index" json:"pipe_sw_if_index,omitempty"` + Instance uint32 `binapi:"u32,name=instance" json:"instance,omitempty"` +} + +func (m *PipeDetails) Reset() { *m = PipeDetails{} } +func (*PipeDetails) GetMessageName() string { return "pipe_details" } +func (*PipeDetails) GetCrcString() string { return "c52b799d" } +func (*PipeDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PipeDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + for j1 := 0; j1 < 2; j1++ { + size += 4 // m.PipeSwIfIndex[j1] + } + size += 4 // m.Instance + return size +} +func (m *PipeDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + for j0 := 0; j0 < 2; j0++ { + buf.EncodeUint32(uint32(m.PipeSwIfIndex[j0])) + } + buf.EncodeUint32(m.Instance) + return buf.Bytes(), nil +} +func (m *PipeDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + for j0 := 0; j0 < 2; j0++ { + m.PipeSwIfIndex[j0] = interface_types.InterfaceIndex(buf.DecodeUint32()) + } + m.Instance = buf.DecodeUint32() + return nil +} + +// Dump pipe interfaces request +// PipeDump defines message 'pipe_dump'. +type PipeDump struct{} + +func (m *PipeDump) Reset() { *m = PipeDump{} } +func (*PipeDump) GetMessageName() string { return "pipe_dump" } +func (*PipeDump) GetCrcString() string { return "51077d14" } +func (*PipeDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PipeDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *PipeDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *PipeDump) Unmarshal(b []byte) error { + return nil +} + +func init() { file_pipe_binapi_init() } +func file_pipe_binapi_init() { + api.RegisterMessage((*PipeCreate)(nil), "pipe_create_bb263bd3") + api.RegisterMessage((*PipeCreateReply)(nil), "pipe_create_reply_b7ce310c") + api.RegisterMessage((*PipeDelete)(nil), "pipe_delete_f9e6675e") + api.RegisterMessage((*PipeDeleteReply)(nil), "pipe_delete_reply_e8d4e804") + api.RegisterMessage((*PipeDetails)(nil), "pipe_details_c52b799d") + api.RegisterMessage((*PipeDump)(nil), "pipe_dump_51077d14") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*PipeCreate)(nil), + (*PipeCreateReply)(nil), + (*PipeDelete)(nil), + (*PipeDeleteReply)(nil), + (*PipeDetails)(nil), + (*PipeDump)(nil), + } +} diff --git a/binapi/pipe/pipe_rpc.ba.go b/binapi/pipe/pipe_rpc.ba.go new file mode 100644 index 00000000..2560a41d --- /dev/null +++ b/binapi/pipe/pipe_rpc.ba.go @@ -0,0 +1,88 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package pipe + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service pipe. +type RPCService interface { + PipeCreate(ctx context.Context, in *PipeCreate) (*PipeCreateReply, error) + PipeDelete(ctx context.Context, in *PipeDelete) (*PipeDeleteReply, error) + PipeDump(ctx context.Context, in *PipeDump) (RPCService_PipeDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) PipeCreate(ctx context.Context, in *PipeCreate) (*PipeCreateReply, error) { + out := new(PipeCreateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PipeDelete(ctx context.Context, in *PipeDelete) (*PipeDeleteReply, error) { + out := new(PipeDeleteReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PipeDump(ctx context.Context, in *PipeDump) (RPCService_PipeDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_PipeDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_PipeDumpClient interface { + Recv() (*PipeDetails, error) + api.Stream +} + +type serviceClient_PipeDumpClient struct { + api.Stream +} + +func (c *serviceClient_PipeDumpClient) Recv() (*PipeDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *PipeDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/pnat/pnat.ba.go b/binapi/pnat/pnat.ba.go new file mode 100644 index 00000000..a5316970 --- /dev/null +++ b/binapi/pnat/pnat.ba.go @@ -0,0 +1,887 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/pnat.api.json + +// Package pnat contains generated bindings for API file pnat.api. +// +// Contents: +// - 2 enums +// - 2 structs +// - 16 messages +package pnat + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "pnat" + APIVersion = "0.1.1" + VersionCrc = 0x7296c7ab +) + +// PnatAttachmentPoint defines enum 'pnat_attachment_point'. +type PnatAttachmentPoint uint32 + +const ( + PNAT_IP4_INPUT PnatAttachmentPoint = 0 + PNAT_IP4_OUTPUT PnatAttachmentPoint = 1 + PNAT_ATTACHMENT_POINT_MAX PnatAttachmentPoint = 2 +) + +var ( + PnatAttachmentPoint_name = map[uint32]string{ + 0: "PNAT_IP4_INPUT", + 1: "PNAT_IP4_OUTPUT", + 2: "PNAT_ATTACHMENT_POINT_MAX", + } + PnatAttachmentPoint_value = map[string]uint32{ + "PNAT_IP4_INPUT": 0, + "PNAT_IP4_OUTPUT": 1, + "PNAT_ATTACHMENT_POINT_MAX": 2, + } +) + +func (x PnatAttachmentPoint) String() string { + s, ok := PnatAttachmentPoint_name[uint32(x)] + if ok { + return s + } + return "PnatAttachmentPoint(" + strconv.Itoa(int(x)) + ")" +} + +// PnatMask defines enum 'pnat_mask'. +type PnatMask uint32 + +const ( + PNAT_SA PnatMask = 1 + PNAT_DA PnatMask = 2 + PNAT_SPORT PnatMask = 4 + PNAT_DPORT PnatMask = 8 + PNAT_COPY_BYTE PnatMask = 16 + PNAT_CLEAR_BYTE PnatMask = 32 + PNAT_PROTO PnatMask = 64 +) + +var ( + PnatMask_name = map[uint32]string{ + 1: "PNAT_SA", + 2: "PNAT_DA", + 4: "PNAT_SPORT", + 8: "PNAT_DPORT", + 16: "PNAT_COPY_BYTE", + 32: "PNAT_CLEAR_BYTE", + 64: "PNAT_PROTO", + } + PnatMask_value = map[string]uint32{ + "PNAT_SA": 1, + "PNAT_DA": 2, + "PNAT_SPORT": 4, + "PNAT_DPORT": 8, + "PNAT_COPY_BYTE": 16, + "PNAT_CLEAR_BYTE": 32, + "PNAT_PROTO": 64, + } +) + +func (x PnatMask) String() string { + s, ok := PnatMask_name[uint32(x)] + if ok { + return s + } + return "PnatMask(" + strconv.Itoa(int(x)) + ")" +} + +// PnatMatchTuple defines type 'pnat_match_tuple'. +type PnatMatchTuple struct { + Src ip_types.IP4Address `binapi:"ip4_address,name=src" json:"src,omitempty"` + Dst ip_types.IP4Address `binapi:"ip4_address,name=dst" json:"dst,omitempty"` + Proto ip_types.IPProto `binapi:"ip_proto,name=proto" json:"proto,omitempty"` + Sport uint16 `binapi:"u16,name=sport" json:"sport,omitempty"` + Dport uint16 `binapi:"u16,name=dport" json:"dport,omitempty"` + Mask PnatMask `binapi:"pnat_mask,name=mask" json:"mask,omitempty"` +} + +// PnatRewriteTuple defines type 'pnat_rewrite_tuple'. +type PnatRewriteTuple struct { + Src ip_types.IP4Address `binapi:"ip4_address,name=src" json:"src,omitempty"` + Dst ip_types.IP4Address `binapi:"ip4_address,name=dst" json:"dst,omitempty"` + Sport uint16 `binapi:"u16,name=sport" json:"sport,omitempty"` + Dport uint16 `binapi:"u16,name=dport" json:"dport,omitempty"` + Mask PnatMask `binapi:"pnat_mask,name=mask" json:"mask,omitempty"` + FromOffset uint8 `binapi:"u8,name=from_offset" json:"from_offset,omitempty"` + ToOffset uint8 `binapi:"u8,name=to_offset" json:"to_offset,omitempty"` + ClearOffset uint8 `binapi:"u8,name=clear_offset" json:"clear_offset,omitempty"` +} + +// /* +// - 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. +// - 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. +// +// PnatBindingAdd defines message 'pnat_binding_add'. +type PnatBindingAdd struct { + Match PnatMatchTuple `binapi:"pnat_match_tuple,name=match" json:"match,omitempty"` + Rewrite PnatRewriteTuple `binapi:"pnat_rewrite_tuple,name=rewrite" json:"rewrite,omitempty"` +} + +func (m *PnatBindingAdd) Reset() { *m = PnatBindingAdd{} } +func (*PnatBindingAdd) GetMessageName() string { return "pnat_binding_add" } +func (*PnatBindingAdd) GetCrcString() string { return "946ee0b7" } +func (*PnatBindingAdd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PnatBindingAdd) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 4 // m.Match.Src + size += 1 * 4 // m.Match.Dst + size += 1 // m.Match.Proto + size += 2 // m.Match.Sport + size += 2 // m.Match.Dport + size += 4 // m.Match.Mask + size += 1 * 4 // m.Rewrite.Src + size += 1 * 4 // m.Rewrite.Dst + size += 2 // m.Rewrite.Sport + size += 2 // m.Rewrite.Dport + size += 4 // m.Rewrite.Mask + size += 1 // m.Rewrite.FromOffset + size += 1 // m.Rewrite.ToOffset + size += 1 // m.Rewrite.ClearOffset + return size +} +func (m *PnatBindingAdd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.Match.Src[:], 4) + buf.EncodeBytes(m.Match.Dst[:], 4) + buf.EncodeUint8(uint8(m.Match.Proto)) + buf.EncodeUint16(m.Match.Sport) + buf.EncodeUint16(m.Match.Dport) + buf.EncodeUint32(uint32(m.Match.Mask)) + buf.EncodeBytes(m.Rewrite.Src[:], 4) + buf.EncodeBytes(m.Rewrite.Dst[:], 4) + buf.EncodeUint16(m.Rewrite.Sport) + buf.EncodeUint16(m.Rewrite.Dport) + buf.EncodeUint32(uint32(m.Rewrite.Mask)) + buf.EncodeUint8(m.Rewrite.FromOffset) + buf.EncodeUint8(m.Rewrite.ToOffset) + buf.EncodeUint8(m.Rewrite.ClearOffset) + return buf.Bytes(), nil +} +func (m *PnatBindingAdd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.Match.Src[:], buf.DecodeBytes(4)) + copy(m.Match.Dst[:], buf.DecodeBytes(4)) + m.Match.Proto = ip_types.IPProto(buf.DecodeUint8()) + m.Match.Sport = buf.DecodeUint16() + m.Match.Dport = buf.DecodeUint16() + m.Match.Mask = PnatMask(buf.DecodeUint32()) + copy(m.Rewrite.Src[:], buf.DecodeBytes(4)) + copy(m.Rewrite.Dst[:], buf.DecodeBytes(4)) + m.Rewrite.Sport = buf.DecodeUint16() + m.Rewrite.Dport = buf.DecodeUint16() + m.Rewrite.Mask = PnatMask(buf.DecodeUint32()) + m.Rewrite.FromOffset = buf.DecodeUint8() + m.Rewrite.ToOffset = buf.DecodeUint8() + m.Rewrite.ClearOffset = buf.DecodeUint8() + return nil +} + +// PnatBindingAddReply defines message 'pnat_binding_add_reply'. +type PnatBindingAddReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + BindingIndex uint32 `binapi:"u32,name=binding_index" json:"binding_index,omitempty"` +} + +func (m *PnatBindingAddReply) Reset() { *m = PnatBindingAddReply{} } +func (*PnatBindingAddReply) GetMessageName() string { return "pnat_binding_add_reply" } +func (*PnatBindingAddReply) GetCrcString() string { return "4cd980a7" } +func (*PnatBindingAddReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PnatBindingAddReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.BindingIndex + return size +} +func (m *PnatBindingAddReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.BindingIndex) + return buf.Bytes(), nil +} +func (m *PnatBindingAddReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.BindingIndex = buf.DecodeUint32() + return nil +} + +// PnatBindingAddV2 defines message 'pnat_binding_add_v2'. +type PnatBindingAddV2 struct { + Match PnatMatchTuple `binapi:"pnat_match_tuple,name=match" json:"match,omitempty"` + Rewrite PnatRewriteTuple `binapi:"pnat_rewrite_tuple,name=rewrite" json:"rewrite,omitempty"` +} + +func (m *PnatBindingAddV2) Reset() { *m = PnatBindingAddV2{} } +func (*PnatBindingAddV2) GetMessageName() string { return "pnat_binding_add_v2" } +func (*PnatBindingAddV2) GetCrcString() string { return "946ee0b7" } +func (*PnatBindingAddV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PnatBindingAddV2) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 4 // m.Match.Src + size += 1 * 4 // m.Match.Dst + size += 1 // m.Match.Proto + size += 2 // m.Match.Sport + size += 2 // m.Match.Dport + size += 4 // m.Match.Mask + size += 1 * 4 // m.Rewrite.Src + size += 1 * 4 // m.Rewrite.Dst + size += 2 // m.Rewrite.Sport + size += 2 // m.Rewrite.Dport + size += 4 // m.Rewrite.Mask + size += 1 // m.Rewrite.FromOffset + size += 1 // m.Rewrite.ToOffset + size += 1 // m.Rewrite.ClearOffset + return size +} +func (m *PnatBindingAddV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.Match.Src[:], 4) + buf.EncodeBytes(m.Match.Dst[:], 4) + buf.EncodeUint8(uint8(m.Match.Proto)) + buf.EncodeUint16(m.Match.Sport) + buf.EncodeUint16(m.Match.Dport) + buf.EncodeUint32(uint32(m.Match.Mask)) + buf.EncodeBytes(m.Rewrite.Src[:], 4) + buf.EncodeBytes(m.Rewrite.Dst[:], 4) + buf.EncodeUint16(m.Rewrite.Sport) + buf.EncodeUint16(m.Rewrite.Dport) + buf.EncodeUint32(uint32(m.Rewrite.Mask)) + buf.EncodeUint8(m.Rewrite.FromOffset) + buf.EncodeUint8(m.Rewrite.ToOffset) + buf.EncodeUint8(m.Rewrite.ClearOffset) + return buf.Bytes(), nil +} +func (m *PnatBindingAddV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.Match.Src[:], buf.DecodeBytes(4)) + copy(m.Match.Dst[:], buf.DecodeBytes(4)) + m.Match.Proto = ip_types.IPProto(buf.DecodeUint8()) + m.Match.Sport = buf.DecodeUint16() + m.Match.Dport = buf.DecodeUint16() + m.Match.Mask = PnatMask(buf.DecodeUint32()) + copy(m.Rewrite.Src[:], buf.DecodeBytes(4)) + copy(m.Rewrite.Dst[:], buf.DecodeBytes(4)) + m.Rewrite.Sport = buf.DecodeUint16() + m.Rewrite.Dport = buf.DecodeUint16() + m.Rewrite.Mask = PnatMask(buf.DecodeUint32()) + m.Rewrite.FromOffset = buf.DecodeUint8() + m.Rewrite.ToOffset = buf.DecodeUint8() + m.Rewrite.ClearOffset = buf.DecodeUint8() + return nil +} + +// PnatBindingAddV2Reply defines message 'pnat_binding_add_v2_reply'. +type PnatBindingAddV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + BindingIndex uint32 `binapi:"u32,name=binding_index" json:"binding_index,omitempty"` +} + +func (m *PnatBindingAddV2Reply) Reset() { *m = PnatBindingAddV2Reply{} } +func (*PnatBindingAddV2Reply) GetMessageName() string { return "pnat_binding_add_v2_reply" } +func (*PnatBindingAddV2Reply) GetCrcString() string { return "4cd980a7" } +func (*PnatBindingAddV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PnatBindingAddV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.BindingIndex + return size +} +func (m *PnatBindingAddV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.BindingIndex) + return buf.Bytes(), nil +} +func (m *PnatBindingAddV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.BindingIndex = buf.DecodeUint32() + return nil +} + +// PnatBindingAttach defines message 'pnat_binding_attach'. +type PnatBindingAttach struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Attachment PnatAttachmentPoint `binapi:"pnat_attachment_point,name=attachment" json:"attachment,omitempty"` + BindingIndex uint32 `binapi:"u32,name=binding_index" json:"binding_index,omitempty"` +} + +func (m *PnatBindingAttach) Reset() { *m = PnatBindingAttach{} } +func (*PnatBindingAttach) GetMessageName() string { return "pnat_binding_attach" } +func (*PnatBindingAttach) GetCrcString() string { return "6e074232" } +func (*PnatBindingAttach) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PnatBindingAttach) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.Attachment + size += 4 // m.BindingIndex + return size +} +func (m *PnatBindingAttach) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(uint32(m.Attachment)) + buf.EncodeUint32(m.BindingIndex) + return buf.Bytes(), nil +} +func (m *PnatBindingAttach) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Attachment = PnatAttachmentPoint(buf.DecodeUint32()) + m.BindingIndex = buf.DecodeUint32() + return nil +} + +// PnatBindingAttachReply defines message 'pnat_binding_attach_reply'. +type PnatBindingAttachReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PnatBindingAttachReply) Reset() { *m = PnatBindingAttachReply{} } +func (*PnatBindingAttachReply) GetMessageName() string { return "pnat_binding_attach_reply" } +func (*PnatBindingAttachReply) GetCrcString() string { return "e8d4e804" } +func (*PnatBindingAttachReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PnatBindingAttachReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PnatBindingAttachReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PnatBindingAttachReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// PnatBindingDel defines message 'pnat_binding_del'. +type PnatBindingDel struct { + BindingIndex uint32 `binapi:"u32,name=binding_index" json:"binding_index,omitempty"` +} + +func (m *PnatBindingDel) Reset() { *m = PnatBindingDel{} } +func (*PnatBindingDel) GetMessageName() string { return "pnat_binding_del" } +func (*PnatBindingDel) GetCrcString() string { return "9259df7b" } +func (*PnatBindingDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PnatBindingDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.BindingIndex + return size +} +func (m *PnatBindingDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.BindingIndex) + return buf.Bytes(), nil +} +func (m *PnatBindingDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.BindingIndex = buf.DecodeUint32() + return nil +} + +// PnatBindingDelReply defines message 'pnat_binding_del_reply'. +type PnatBindingDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PnatBindingDelReply) Reset() { *m = PnatBindingDelReply{} } +func (*PnatBindingDelReply) GetMessageName() string { return "pnat_binding_del_reply" } +func (*PnatBindingDelReply) GetCrcString() string { return "e8d4e804" } +func (*PnatBindingDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PnatBindingDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PnatBindingDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PnatBindingDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// PnatBindingDetach defines message 'pnat_binding_detach'. +type PnatBindingDetach struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Attachment PnatAttachmentPoint `binapi:"pnat_attachment_point,name=attachment" json:"attachment,omitempty"` + BindingIndex uint32 `binapi:"u32,name=binding_index" json:"binding_index,omitempty"` +} + +func (m *PnatBindingDetach) Reset() { *m = PnatBindingDetach{} } +func (*PnatBindingDetach) GetMessageName() string { return "pnat_binding_detach" } +func (*PnatBindingDetach) GetCrcString() string { return "6e074232" } +func (*PnatBindingDetach) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PnatBindingDetach) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.Attachment + size += 4 // m.BindingIndex + return size +} +func (m *PnatBindingDetach) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(uint32(m.Attachment)) + buf.EncodeUint32(m.BindingIndex) + return buf.Bytes(), nil +} +func (m *PnatBindingDetach) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Attachment = PnatAttachmentPoint(buf.DecodeUint32()) + m.BindingIndex = buf.DecodeUint32() + return nil +} + +// PnatBindingDetachReply defines message 'pnat_binding_detach_reply'. +type PnatBindingDetachReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PnatBindingDetachReply) Reset() { *m = PnatBindingDetachReply{} } +func (*PnatBindingDetachReply) GetMessageName() string { return "pnat_binding_detach_reply" } +func (*PnatBindingDetachReply) GetCrcString() string { return "e8d4e804" } +func (*PnatBindingDetachReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PnatBindingDetachReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PnatBindingDetachReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PnatBindingDetachReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// PnatBindingsDetails defines message 'pnat_bindings_details'. +type PnatBindingsDetails struct { + Match PnatMatchTuple `binapi:"pnat_match_tuple,name=match" json:"match,omitempty"` + Rewrite PnatRewriteTuple `binapi:"pnat_rewrite_tuple,name=rewrite" json:"rewrite,omitempty"` +} + +func (m *PnatBindingsDetails) Reset() { *m = PnatBindingsDetails{} } +func (*PnatBindingsDetails) GetMessageName() string { return "pnat_bindings_details" } +func (*PnatBindingsDetails) GetCrcString() string { return "08fb2815" } +func (*PnatBindingsDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PnatBindingsDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 4 // m.Match.Src + size += 1 * 4 // m.Match.Dst + size += 1 // m.Match.Proto + size += 2 // m.Match.Sport + size += 2 // m.Match.Dport + size += 4 // m.Match.Mask + size += 1 * 4 // m.Rewrite.Src + size += 1 * 4 // m.Rewrite.Dst + size += 2 // m.Rewrite.Sport + size += 2 // m.Rewrite.Dport + size += 4 // m.Rewrite.Mask + size += 1 // m.Rewrite.FromOffset + size += 1 // m.Rewrite.ToOffset + size += 1 // m.Rewrite.ClearOffset + return size +} +func (m *PnatBindingsDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.Match.Src[:], 4) + buf.EncodeBytes(m.Match.Dst[:], 4) + buf.EncodeUint8(uint8(m.Match.Proto)) + buf.EncodeUint16(m.Match.Sport) + buf.EncodeUint16(m.Match.Dport) + buf.EncodeUint32(uint32(m.Match.Mask)) + buf.EncodeBytes(m.Rewrite.Src[:], 4) + buf.EncodeBytes(m.Rewrite.Dst[:], 4) + buf.EncodeUint16(m.Rewrite.Sport) + buf.EncodeUint16(m.Rewrite.Dport) + buf.EncodeUint32(uint32(m.Rewrite.Mask)) + buf.EncodeUint8(m.Rewrite.FromOffset) + buf.EncodeUint8(m.Rewrite.ToOffset) + buf.EncodeUint8(m.Rewrite.ClearOffset) + return buf.Bytes(), nil +} +func (m *PnatBindingsDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.Match.Src[:], buf.DecodeBytes(4)) + copy(m.Match.Dst[:], buf.DecodeBytes(4)) + m.Match.Proto = ip_types.IPProto(buf.DecodeUint8()) + m.Match.Sport = buf.DecodeUint16() + m.Match.Dport = buf.DecodeUint16() + m.Match.Mask = PnatMask(buf.DecodeUint32()) + copy(m.Rewrite.Src[:], buf.DecodeBytes(4)) + copy(m.Rewrite.Dst[:], buf.DecodeBytes(4)) + m.Rewrite.Sport = buf.DecodeUint16() + m.Rewrite.Dport = buf.DecodeUint16() + m.Rewrite.Mask = PnatMask(buf.DecodeUint32()) + m.Rewrite.FromOffset = buf.DecodeUint8() + m.Rewrite.ToOffset = buf.DecodeUint8() + m.Rewrite.ClearOffset = buf.DecodeUint8() + return nil +} + +// PnatBindingsGet defines message 'pnat_bindings_get'. +type PnatBindingsGet struct { + Cursor uint32 `binapi:"u32,name=cursor" json:"cursor,omitempty"` +} + +func (m *PnatBindingsGet) Reset() { *m = PnatBindingsGet{} } +func (*PnatBindingsGet) GetMessageName() string { return "pnat_bindings_get" } +func (*PnatBindingsGet) GetCrcString() string { return "f75ba505" } +func (*PnatBindingsGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PnatBindingsGet) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Cursor + return size +} +func (m *PnatBindingsGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Cursor) + return buf.Bytes(), nil +} +func (m *PnatBindingsGet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Cursor = buf.DecodeUint32() + return nil +} + +// PnatBindingsGetReply defines message 'pnat_bindings_get_reply'. +type PnatBindingsGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Cursor uint32 `binapi:"u32,name=cursor" json:"cursor,omitempty"` +} + +func (m *PnatBindingsGetReply) Reset() { *m = PnatBindingsGetReply{} } +func (*PnatBindingsGetReply) GetMessageName() string { return "pnat_bindings_get_reply" } +func (*PnatBindingsGetReply) GetCrcString() string { return "53b48f5d" } +func (*PnatBindingsGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PnatBindingsGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Cursor + return size +} +func (m *PnatBindingsGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.Cursor) + return buf.Bytes(), nil +} +func (m *PnatBindingsGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Cursor = buf.DecodeUint32() + return nil +} + +// PnatInterfacesDetails defines message 'pnat_interfaces_details'. +type PnatInterfacesDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Enabled []bool `binapi:"bool[2],name=enabled" json:"enabled,omitempty"` + LookupMask [2]PnatMask `binapi:"pnat_mask[2],name=lookup_mask" json:"lookup_mask,omitempty"` +} + +func (m *PnatInterfacesDetails) Reset() { *m = PnatInterfacesDetails{} } +func (*PnatInterfacesDetails) GetMessageName() string { return "pnat_interfaces_details" } +func (*PnatInterfacesDetails) GetCrcString() string { return "4cb09493" } +func (*PnatInterfacesDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PnatInterfacesDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 * 2 // m.Enabled + for j1 := 0; j1 < 2; j1++ { + size += 4 // m.LookupMask[j1] + } + return size +} +func (m *PnatInterfacesDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + for i := 0; i < 2; i++ { + var x bool + if i < len(m.Enabled) { + x = bool(m.Enabled[i]) + } + buf.EncodeBool(x) + } + for j0 := 0; j0 < 2; j0++ { + buf.EncodeUint32(uint32(m.LookupMask[j0])) + } + return buf.Bytes(), nil +} +func (m *PnatInterfacesDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Enabled = make([]bool, 2) + for i := 0; i < len(m.Enabled); i++ { + m.Enabled[i] = buf.DecodeBool() + } + for j0 := 0; j0 < 2; j0++ { + m.LookupMask[j0] = PnatMask(buf.DecodeUint32()) + } + return nil +} + +// PnatInterfacesGet defines message 'pnat_interfaces_get'. +type PnatInterfacesGet struct { + Cursor uint32 `binapi:"u32,name=cursor" json:"cursor,omitempty"` +} + +func (m *PnatInterfacesGet) Reset() { *m = PnatInterfacesGet{} } +func (*PnatInterfacesGet) GetMessageName() string { return "pnat_interfaces_get" } +func (*PnatInterfacesGet) GetCrcString() string { return "f75ba505" } +func (*PnatInterfacesGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PnatInterfacesGet) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Cursor + return size +} +func (m *PnatInterfacesGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Cursor) + return buf.Bytes(), nil +} +func (m *PnatInterfacesGet) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Cursor = buf.DecodeUint32() + return nil +} + +// PnatInterfacesGetReply defines message 'pnat_interfaces_get_reply'. +type PnatInterfacesGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Cursor uint32 `binapi:"u32,name=cursor" json:"cursor,omitempty"` +} + +func (m *PnatInterfacesGetReply) Reset() { *m = PnatInterfacesGetReply{} } +func (*PnatInterfacesGetReply) GetMessageName() string { return "pnat_interfaces_get_reply" } +func (*PnatInterfacesGetReply) GetCrcString() string { return "53b48f5d" } +func (*PnatInterfacesGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PnatInterfacesGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Cursor + return size +} +func (m *PnatInterfacesGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.Cursor) + return buf.Bytes(), nil +} +func (m *PnatInterfacesGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Cursor = buf.DecodeUint32() + return nil +} + +func init() { file_pnat_binapi_init() } +func file_pnat_binapi_init() { + api.RegisterMessage((*PnatBindingAdd)(nil), "pnat_binding_add_946ee0b7") + api.RegisterMessage((*PnatBindingAddReply)(nil), "pnat_binding_add_reply_4cd980a7") + api.RegisterMessage((*PnatBindingAddV2)(nil), "pnat_binding_add_v2_946ee0b7") + api.RegisterMessage((*PnatBindingAddV2Reply)(nil), "pnat_binding_add_v2_reply_4cd980a7") + api.RegisterMessage((*PnatBindingAttach)(nil), "pnat_binding_attach_6e074232") + api.RegisterMessage((*PnatBindingAttachReply)(nil), "pnat_binding_attach_reply_e8d4e804") + api.RegisterMessage((*PnatBindingDel)(nil), "pnat_binding_del_9259df7b") + api.RegisterMessage((*PnatBindingDelReply)(nil), "pnat_binding_del_reply_e8d4e804") + api.RegisterMessage((*PnatBindingDetach)(nil), "pnat_binding_detach_6e074232") + api.RegisterMessage((*PnatBindingDetachReply)(nil), "pnat_binding_detach_reply_e8d4e804") + api.RegisterMessage((*PnatBindingsDetails)(nil), "pnat_bindings_details_08fb2815") + api.RegisterMessage((*PnatBindingsGet)(nil), "pnat_bindings_get_f75ba505") + api.RegisterMessage((*PnatBindingsGetReply)(nil), "pnat_bindings_get_reply_53b48f5d") + api.RegisterMessage((*PnatInterfacesDetails)(nil), "pnat_interfaces_details_4cb09493") + api.RegisterMessage((*PnatInterfacesGet)(nil), "pnat_interfaces_get_f75ba505") + api.RegisterMessage((*PnatInterfacesGetReply)(nil), "pnat_interfaces_get_reply_53b48f5d") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*PnatBindingAdd)(nil), + (*PnatBindingAddReply)(nil), + (*PnatBindingAddV2)(nil), + (*PnatBindingAddV2Reply)(nil), + (*PnatBindingAttach)(nil), + (*PnatBindingAttachReply)(nil), + (*PnatBindingDel)(nil), + (*PnatBindingDelReply)(nil), + (*PnatBindingDetach)(nil), + (*PnatBindingDetachReply)(nil), + (*PnatBindingsDetails)(nil), + (*PnatBindingsGet)(nil), + (*PnatBindingsGetReply)(nil), + (*PnatInterfacesDetails)(nil), + (*PnatInterfacesGet)(nil), + (*PnatInterfacesGetReply)(nil), + } +} diff --git a/binapi/pnat/pnat_rpc.ba.go b/binapi/pnat/pnat_rpc.ba.go new file mode 100644 index 00000000..881f24f3 --- /dev/null +++ b/binapi/pnat/pnat_rpc.ba.go @@ -0,0 +1,161 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package pnat + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service pnat. +type RPCService interface { + PnatBindingAdd(ctx context.Context, in *PnatBindingAdd) (*PnatBindingAddReply, error) + PnatBindingAddV2(ctx context.Context, in *PnatBindingAddV2) (*PnatBindingAddV2Reply, error) + PnatBindingAttach(ctx context.Context, in *PnatBindingAttach) (*PnatBindingAttachReply, error) + PnatBindingDel(ctx context.Context, in *PnatBindingDel) (*PnatBindingDelReply, error) + PnatBindingDetach(ctx context.Context, in *PnatBindingDetach) (*PnatBindingDetachReply, error) + PnatBindingsGet(ctx context.Context, in *PnatBindingsGet) (RPCService_PnatBindingsGetClient, error) + PnatInterfacesGet(ctx context.Context, in *PnatInterfacesGet) (RPCService_PnatInterfacesGetClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) PnatBindingAdd(ctx context.Context, in *PnatBindingAdd) (*PnatBindingAddReply, error) { + out := new(PnatBindingAddReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PnatBindingAddV2(ctx context.Context, in *PnatBindingAddV2) (*PnatBindingAddV2Reply, error) { + out := new(PnatBindingAddV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PnatBindingAttach(ctx context.Context, in *PnatBindingAttach) (*PnatBindingAttachReply, error) { + out := new(PnatBindingAttachReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PnatBindingDel(ctx context.Context, in *PnatBindingDel) (*PnatBindingDelReply, error) { + out := new(PnatBindingDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PnatBindingDetach(ctx context.Context, in *PnatBindingDetach) (*PnatBindingDetachReply, error) { + out := new(PnatBindingDetachReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PnatBindingsGet(ctx context.Context, in *PnatBindingsGet) (RPCService_PnatBindingsGetClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_PnatBindingsGetClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_PnatBindingsGetClient interface { + Recv() (*PnatBindingsDetails, *PnatBindingsGetReply, error) + api.Stream +} + +type serviceClient_PnatBindingsGetClient struct { + api.Stream +} + +func (c *serviceClient_PnatBindingsGetClient) Recv() (*PnatBindingsDetails, *PnatBindingsGetReply, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, nil, err + } + switch m := msg.(type) { + case *PnatBindingsDetails: + return m, nil, nil + case *PnatBindingsGetReply: + if err := api.RetvalToVPPApiError(m.Retval); err != nil { + return nil, m, err + } + err = c.Stream.Close() + if err != nil { + return nil, m, err + } + return nil, m, io.EOF + default: + return nil, nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) PnatInterfacesGet(ctx context.Context, in *PnatInterfacesGet) (RPCService_PnatInterfacesGetClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_PnatInterfacesGetClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_PnatInterfacesGetClient interface { + Recv() (*PnatInterfacesDetails, *PnatInterfacesGetReply, error) + api.Stream +} + +type serviceClient_PnatInterfacesGetClient struct { + api.Stream +} + +func (c *serviceClient_PnatInterfacesGetClient) Recv() (*PnatInterfacesDetails, *PnatInterfacesGetReply, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, nil, err + } + switch m := msg.(type) { + case *PnatInterfacesDetails: + return m, nil, nil + case *PnatInterfacesGetReply: + if err := api.RetvalToVPPApiError(m.Retval); err != nil { + return nil, m, err + } + err = c.Stream.Close() + if err != nil { + return nil, m, err + } + return nil, m, io.EOF + default: + return nil, nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/policer/policer.ba.go b/binapi/policer/policer.ba.go new file mode 100644 index 00000000..b6a7131b --- /dev/null +++ b/binapi/policer/policer.ba.go @@ -0,0 +1,1271 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/policer.api.json + +// Package policer contains generated bindings for API file policer.api. +// +// Contents: +// - 25 messages +package policer + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + policer_types "github.com/alkiranet/govpp/binapi/policer_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "policer" + APIVersion = "3.0.0" + VersionCrc = 0x341163a6 +) + +// PolicerAdd defines message 'policer_add'. +type PolicerAdd struct { + Name string `binapi:"string[64],name=name" json:"name,omitempty"` + Infos policer_types.PolicerConfig `binapi:"policer_config,name=infos" json:"infos,omitempty"` +} + +func (m *PolicerAdd) Reset() { *m = PolicerAdd{} } +func (*PolicerAdd) GetMessageName() string { return "policer_add" } +func (*PolicerAdd) GetCrcString() string { return "4d949e35" } +func (*PolicerAdd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerAdd) Size() (size int) { + if m == nil { + return 0 + } + size += 64 // m.Name + size += 4 // m.Infos.Cir + size += 4 // m.Infos.Eir + size += 8 // m.Infos.Cb + size += 8 // m.Infos.Eb + size += 1 // m.Infos.RateType + size += 1 // m.Infos.RoundType + size += 1 // m.Infos.Type + size += 1 // m.Infos.ColorAware + size += 1 // m.Infos.ConformAction.Type + size += 1 // m.Infos.ConformAction.Dscp + size += 1 // m.Infos.ExceedAction.Type + size += 1 // m.Infos.ExceedAction.Dscp + size += 1 // m.Infos.ViolateAction.Type + size += 1 // m.Infos.ViolateAction.Dscp + return size +} +func (m *PolicerAdd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.Name, 64) + buf.EncodeUint32(m.Infos.Cir) + buf.EncodeUint32(m.Infos.Eir) + buf.EncodeUint64(m.Infos.Cb) + buf.EncodeUint64(m.Infos.Eb) + buf.EncodeUint8(uint8(m.Infos.RateType)) + buf.EncodeUint8(uint8(m.Infos.RoundType)) + buf.EncodeUint8(uint8(m.Infos.Type)) + buf.EncodeBool(m.Infos.ColorAware) + buf.EncodeUint8(uint8(m.Infos.ConformAction.Type)) + buf.EncodeUint8(m.Infos.ConformAction.Dscp) + buf.EncodeUint8(uint8(m.Infos.ExceedAction.Type)) + buf.EncodeUint8(m.Infos.ExceedAction.Dscp) + buf.EncodeUint8(uint8(m.Infos.ViolateAction.Type)) + buf.EncodeUint8(m.Infos.ViolateAction.Dscp) + return buf.Bytes(), nil +} +func (m *PolicerAdd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Name = buf.DecodeString(64) + m.Infos.Cir = buf.DecodeUint32() + m.Infos.Eir = buf.DecodeUint32() + m.Infos.Cb = buf.DecodeUint64() + m.Infos.Eb = buf.DecodeUint64() + m.Infos.RateType = policer_types.Sse2QosRateType(buf.DecodeUint8()) + m.Infos.RoundType = policer_types.Sse2QosRoundType(buf.DecodeUint8()) + m.Infos.Type = policer_types.Sse2QosPolicerType(buf.DecodeUint8()) + m.Infos.ColorAware = buf.DecodeBool() + m.Infos.ConformAction.Type = policer_types.Sse2QosActionType(buf.DecodeUint8()) + m.Infos.ConformAction.Dscp = buf.DecodeUint8() + m.Infos.ExceedAction.Type = policer_types.Sse2QosActionType(buf.DecodeUint8()) + m.Infos.ExceedAction.Dscp = buf.DecodeUint8() + m.Infos.ViolateAction.Type = policer_types.Sse2QosActionType(buf.DecodeUint8()) + m.Infos.ViolateAction.Dscp = buf.DecodeUint8() + return nil +} + +// Add/del policer +// - is_add - add policer if non-zero, else delete +// - name - policer name +// - cir - CIR +// - eir - EIR +// - cb - Committed Burst +// - eb - Excess or Peak Burst +// - rate_type - rate type +// - round_type - rounding type +// - type - policer algorithm +// - color_aware - 0=color-blind, 1=color-aware +// - conform_action - conform action +// - exceed_action - exceed action type +// - violate_action - violate action type +// +// PolicerAddDel defines message 'policer_add_del'. +type PolicerAddDel struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + Name string `binapi:"string[64],name=name" json:"name,omitempty"` + Cir uint32 `binapi:"u32,name=cir" json:"cir,omitempty"` + Eir uint32 `binapi:"u32,name=eir" json:"eir,omitempty"` + Cb uint64 `binapi:"u64,name=cb" json:"cb,omitempty"` + Eb uint64 `binapi:"u64,name=eb" json:"eb,omitempty"` + RateType policer_types.Sse2QosRateType `binapi:"sse2_qos_rate_type,name=rate_type" json:"rate_type,omitempty"` + RoundType policer_types.Sse2QosRoundType `binapi:"sse2_qos_round_type,name=round_type" json:"round_type,omitempty"` + Type policer_types.Sse2QosPolicerType `binapi:"sse2_qos_policer_type,name=type" json:"type,omitempty"` + ColorAware bool `binapi:"bool,name=color_aware" json:"color_aware,omitempty"` + ConformAction policer_types.Sse2QosAction `binapi:"sse2_qos_action,name=conform_action" json:"conform_action,omitempty"` + ExceedAction policer_types.Sse2QosAction `binapi:"sse2_qos_action,name=exceed_action" json:"exceed_action,omitempty"` + ViolateAction policer_types.Sse2QosAction `binapi:"sse2_qos_action,name=violate_action" json:"violate_action,omitempty"` +} + +func (m *PolicerAddDel) Reset() { *m = PolicerAddDel{} } +func (*PolicerAddDel) GetMessageName() string { return "policer_add_del" } +func (*PolicerAddDel) GetCrcString() string { return "2b31dd38" } +func (*PolicerAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 64 // m.Name + size += 4 // m.Cir + size += 4 // m.Eir + size += 8 // m.Cb + size += 8 // m.Eb + size += 1 // m.RateType + size += 1 // m.RoundType + size += 1 // m.Type + size += 1 // m.ColorAware + size += 1 // m.ConformAction.Type + size += 1 // m.ConformAction.Dscp + size += 1 // m.ExceedAction.Type + size += 1 // m.ExceedAction.Dscp + size += 1 // m.ViolateAction.Type + size += 1 // m.ViolateAction.Dscp + return size +} +func (m *PolicerAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeString(m.Name, 64) + buf.EncodeUint32(m.Cir) + buf.EncodeUint32(m.Eir) + buf.EncodeUint64(m.Cb) + buf.EncodeUint64(m.Eb) + buf.EncodeUint8(uint8(m.RateType)) + buf.EncodeUint8(uint8(m.RoundType)) + buf.EncodeUint8(uint8(m.Type)) + buf.EncodeBool(m.ColorAware) + buf.EncodeUint8(uint8(m.ConformAction.Type)) + buf.EncodeUint8(m.ConformAction.Dscp) + buf.EncodeUint8(uint8(m.ExceedAction.Type)) + buf.EncodeUint8(m.ExceedAction.Dscp) + buf.EncodeUint8(uint8(m.ViolateAction.Type)) + buf.EncodeUint8(m.ViolateAction.Dscp) + return buf.Bytes(), nil +} +func (m *PolicerAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Name = buf.DecodeString(64) + m.Cir = buf.DecodeUint32() + m.Eir = buf.DecodeUint32() + m.Cb = buf.DecodeUint64() + m.Eb = buf.DecodeUint64() + m.RateType = policer_types.Sse2QosRateType(buf.DecodeUint8()) + m.RoundType = policer_types.Sse2QosRoundType(buf.DecodeUint8()) + m.Type = policer_types.Sse2QosPolicerType(buf.DecodeUint8()) + m.ColorAware = buf.DecodeBool() + m.ConformAction.Type = policer_types.Sse2QosActionType(buf.DecodeUint8()) + m.ConformAction.Dscp = buf.DecodeUint8() + m.ExceedAction.Type = policer_types.Sse2QosActionType(buf.DecodeUint8()) + m.ExceedAction.Dscp = buf.DecodeUint8() + m.ViolateAction.Type = policer_types.Sse2QosActionType(buf.DecodeUint8()) + m.ViolateAction.Dscp = buf.DecodeUint8() + return nil +} + +// Add/del policer response +// - retval - return value for request +// - policer_index - for add, returned index of the new policer +// +// PolicerAddDelReply defines message 'policer_add_del_reply'. +type PolicerAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + PolicerIndex uint32 `binapi:"u32,name=policer_index" json:"policer_index,omitempty"` +} + +func (m *PolicerAddDelReply) Reset() { *m = PolicerAddDelReply{} } +func (*PolicerAddDelReply) GetMessageName() string { return "policer_add_del_reply" } +func (*PolicerAddDelReply) GetCrcString() string { return "a177cef2" } +func (*PolicerAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.PolicerIndex + return size +} +func (m *PolicerAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.PolicerIndex) + return buf.Bytes(), nil +} +func (m *PolicerAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.PolicerIndex = buf.DecodeUint32() + return nil +} + +// PolicerAddReply defines message 'policer_add_reply'. +type PolicerAddReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + PolicerIndex uint32 `binapi:"u32,name=policer_index" json:"policer_index,omitempty"` +} + +func (m *PolicerAddReply) Reset() { *m = PolicerAddReply{} } +func (*PolicerAddReply) GetMessageName() string { return "policer_add_reply" } +func (*PolicerAddReply) GetCrcString() string { return "a177cef2" } +func (*PolicerAddReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerAddReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.PolicerIndex + return size +} +func (m *PolicerAddReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.PolicerIndex) + return buf.Bytes(), nil +} +func (m *PolicerAddReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.PolicerIndex = buf.DecodeUint32() + return nil +} + +// policer bind: Associate/disassociate a policer with a worker thread. +// - name - policer name to bind +// - worker_index - the worker thread to bind to +// - bind_enable - Associate/disassociate +// +// PolicerBind defines message 'policer_bind'. +type PolicerBind struct { + Name string `binapi:"string[64],name=name" json:"name,omitempty"` + WorkerIndex uint32 `binapi:"u32,name=worker_index" json:"worker_index,omitempty"` + BindEnable bool `binapi:"bool,name=bind_enable" json:"bind_enable,omitempty"` +} + +func (m *PolicerBind) Reset() { *m = PolicerBind{} } +func (*PolicerBind) GetMessageName() string { return "policer_bind" } +func (*PolicerBind) GetCrcString() string { return "dcf516f9" } +func (*PolicerBind) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerBind) Size() (size int) { + if m == nil { + return 0 + } + size += 64 // m.Name + size += 4 // m.WorkerIndex + size += 1 // m.BindEnable + return size +} +func (m *PolicerBind) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.Name, 64) + buf.EncodeUint32(m.WorkerIndex) + buf.EncodeBool(m.BindEnable) + return buf.Bytes(), nil +} +func (m *PolicerBind) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Name = buf.DecodeString(64) + m.WorkerIndex = buf.DecodeUint32() + m.BindEnable = buf.DecodeBool() + return nil +} + +// PolicerBindReply defines message 'policer_bind_reply'. +type PolicerBindReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PolicerBindReply) Reset() { *m = PolicerBindReply{} } +func (*PolicerBindReply) GetMessageName() string { return "policer_bind_reply" } +func (*PolicerBindReply) GetCrcString() string { return "e8d4e804" } +func (*PolicerBindReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerBindReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PolicerBindReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PolicerBindReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// PolicerBindV2 defines message 'policer_bind_v2'. +type PolicerBindV2 struct { + PolicerIndex uint32 `binapi:"u32,name=policer_index" json:"policer_index,omitempty"` + WorkerIndex uint32 `binapi:"u32,name=worker_index" json:"worker_index,omitempty"` + BindEnable bool `binapi:"bool,name=bind_enable" json:"bind_enable,omitempty"` +} + +func (m *PolicerBindV2) Reset() { *m = PolicerBindV2{} } +func (*PolicerBindV2) GetMessageName() string { return "policer_bind_v2" } +func (*PolicerBindV2) GetCrcString() string { return "f87bd3c0" } +func (*PolicerBindV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerBindV2) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PolicerIndex + size += 4 // m.WorkerIndex + size += 1 // m.BindEnable + return size +} +func (m *PolicerBindV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PolicerIndex) + buf.EncodeUint32(m.WorkerIndex) + buf.EncodeBool(m.BindEnable) + return buf.Bytes(), nil +} +func (m *PolicerBindV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PolicerIndex = buf.DecodeUint32() + m.WorkerIndex = buf.DecodeUint32() + m.BindEnable = buf.DecodeBool() + return nil +} + +// PolicerBindV2Reply defines message 'policer_bind_v2_reply'. +type PolicerBindV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PolicerBindV2Reply) Reset() { *m = PolicerBindV2Reply{} } +func (*PolicerBindV2Reply) GetMessageName() string { return "policer_bind_v2_reply" } +func (*PolicerBindV2Reply) GetCrcString() string { return "e8d4e804" } +func (*PolicerBindV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerBindV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PolicerBindV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PolicerBindV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// PolicerDel defines message 'policer_del'. +type PolicerDel struct { + PolicerIndex uint32 `binapi:"u32,name=policer_index" json:"policer_index,omitempty"` +} + +func (m *PolicerDel) Reset() { *m = PolicerDel{} } +func (*PolicerDel) GetMessageName() string { return "policer_del" } +func (*PolicerDel) GetCrcString() string { return "7ff7912e" } +func (*PolicerDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PolicerIndex + return size +} +func (m *PolicerDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PolicerIndex) + return buf.Bytes(), nil +} +func (m *PolicerDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PolicerIndex = buf.DecodeUint32() + return nil +} + +// PolicerDelReply defines message 'policer_del_reply'. +type PolicerDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PolicerDelReply) Reset() { *m = PolicerDelReply{} } +func (*PolicerDelReply) GetMessageName() string { return "policer_del_reply" } +func (*PolicerDelReply) GetCrcString() string { return "e8d4e804" } +func (*PolicerDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PolicerDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PolicerDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Policer operational state response. +// - name - policer name +// - cir - CIR +// - eir - EIR +// - cb - Committed Burst +// - eb - Excess or Peak Burst +// - rate_type - rate type +// - round_type - rounding type +// - type - policer algorithm +// - conform_action - conform action +// - exceed_action - exceed action +// - violate_action - violate action +// - single_rate - 1 = single rate policer, 0 = two rate policer +// - color_aware - for hierarchical policing +// - scale - power-of-2 shift amount for lower rates +// - cir_tokens_per_period - number of tokens for each period +// - pir_tokens_per_period - number of tokens for each period for 2-rate policer +// - current_limit - current limit +// - current_bucket - current bucket +// - extended_limit - extended limit +// - extended_bucket - extended bucket +// - last_update_time - last update time +// +// PolicerDetails defines message 'policer_details'. +type PolicerDetails struct { + Name string `binapi:"string[64],name=name" json:"name,omitempty"` + Cir uint32 `binapi:"u32,name=cir" json:"cir,omitempty"` + Eir uint32 `binapi:"u32,name=eir" json:"eir,omitempty"` + Cb uint64 `binapi:"u64,name=cb" json:"cb,omitempty"` + Eb uint64 `binapi:"u64,name=eb" json:"eb,omitempty"` + RateType policer_types.Sse2QosRateType `binapi:"sse2_qos_rate_type,name=rate_type" json:"rate_type,omitempty"` + RoundType policer_types.Sse2QosRoundType `binapi:"sse2_qos_round_type,name=round_type" json:"round_type,omitempty"` + Type policer_types.Sse2QosPolicerType `binapi:"sse2_qos_policer_type,name=type" json:"type,omitempty"` + ConformAction policer_types.Sse2QosAction `binapi:"sse2_qos_action,name=conform_action" json:"conform_action,omitempty"` + ExceedAction policer_types.Sse2QosAction `binapi:"sse2_qos_action,name=exceed_action" json:"exceed_action,omitempty"` + ViolateAction policer_types.Sse2QosAction `binapi:"sse2_qos_action,name=violate_action" json:"violate_action,omitempty"` + SingleRate bool `binapi:"bool,name=single_rate" json:"single_rate,omitempty"` + ColorAware bool `binapi:"bool,name=color_aware" json:"color_aware,omitempty"` + Scale uint32 `binapi:"u32,name=scale" json:"scale,omitempty"` + CirTokensPerPeriod uint32 `binapi:"u32,name=cir_tokens_per_period" json:"cir_tokens_per_period,omitempty"` + PirTokensPerPeriod uint32 `binapi:"u32,name=pir_tokens_per_period" json:"pir_tokens_per_period,omitempty"` + CurrentLimit uint32 `binapi:"u32,name=current_limit" json:"current_limit,omitempty"` + CurrentBucket uint32 `binapi:"u32,name=current_bucket" json:"current_bucket,omitempty"` + ExtendedLimit uint32 `binapi:"u32,name=extended_limit" json:"extended_limit,omitempty"` + ExtendedBucket uint32 `binapi:"u32,name=extended_bucket" json:"extended_bucket,omitempty"` + LastUpdateTime uint64 `binapi:"u64,name=last_update_time" json:"last_update_time,omitempty"` +} + +func (m *PolicerDetails) Reset() { *m = PolicerDetails{} } +func (*PolicerDetails) GetMessageName() string { return "policer_details" } +func (*PolicerDetails) GetCrcString() string { return "72d0e248" } +func (*PolicerDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 64 // m.Name + size += 4 // m.Cir + size += 4 // m.Eir + size += 8 // m.Cb + size += 8 // m.Eb + size += 1 // m.RateType + size += 1 // m.RoundType + size += 1 // m.Type + size += 1 // m.ConformAction.Type + size += 1 // m.ConformAction.Dscp + size += 1 // m.ExceedAction.Type + size += 1 // m.ExceedAction.Dscp + size += 1 // m.ViolateAction.Type + size += 1 // m.ViolateAction.Dscp + size += 1 // m.SingleRate + size += 1 // m.ColorAware + size += 4 // m.Scale + size += 4 // m.CirTokensPerPeriod + size += 4 // m.PirTokensPerPeriod + size += 4 // m.CurrentLimit + size += 4 // m.CurrentBucket + size += 4 // m.ExtendedLimit + size += 4 // m.ExtendedBucket + size += 8 // m.LastUpdateTime + return size +} +func (m *PolicerDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.Name, 64) + buf.EncodeUint32(m.Cir) + buf.EncodeUint32(m.Eir) + buf.EncodeUint64(m.Cb) + buf.EncodeUint64(m.Eb) + buf.EncodeUint8(uint8(m.RateType)) + buf.EncodeUint8(uint8(m.RoundType)) + buf.EncodeUint8(uint8(m.Type)) + buf.EncodeUint8(uint8(m.ConformAction.Type)) + buf.EncodeUint8(m.ConformAction.Dscp) + buf.EncodeUint8(uint8(m.ExceedAction.Type)) + buf.EncodeUint8(m.ExceedAction.Dscp) + buf.EncodeUint8(uint8(m.ViolateAction.Type)) + buf.EncodeUint8(m.ViolateAction.Dscp) + buf.EncodeBool(m.SingleRate) + buf.EncodeBool(m.ColorAware) + buf.EncodeUint32(m.Scale) + buf.EncodeUint32(m.CirTokensPerPeriod) + buf.EncodeUint32(m.PirTokensPerPeriod) + buf.EncodeUint32(m.CurrentLimit) + buf.EncodeUint32(m.CurrentBucket) + buf.EncodeUint32(m.ExtendedLimit) + buf.EncodeUint32(m.ExtendedBucket) + buf.EncodeUint64(m.LastUpdateTime) + return buf.Bytes(), nil +} +func (m *PolicerDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Name = buf.DecodeString(64) + m.Cir = buf.DecodeUint32() + m.Eir = buf.DecodeUint32() + m.Cb = buf.DecodeUint64() + m.Eb = buf.DecodeUint64() + m.RateType = policer_types.Sse2QosRateType(buf.DecodeUint8()) + m.RoundType = policer_types.Sse2QosRoundType(buf.DecodeUint8()) + m.Type = policer_types.Sse2QosPolicerType(buf.DecodeUint8()) + m.ConformAction.Type = policer_types.Sse2QosActionType(buf.DecodeUint8()) + m.ConformAction.Dscp = buf.DecodeUint8() + m.ExceedAction.Type = policer_types.Sse2QosActionType(buf.DecodeUint8()) + m.ExceedAction.Dscp = buf.DecodeUint8() + m.ViolateAction.Type = policer_types.Sse2QosActionType(buf.DecodeUint8()) + m.ViolateAction.Dscp = buf.DecodeUint8() + m.SingleRate = buf.DecodeBool() + m.ColorAware = buf.DecodeBool() + m.Scale = buf.DecodeUint32() + m.CirTokensPerPeriod = buf.DecodeUint32() + m.PirTokensPerPeriod = buf.DecodeUint32() + m.CurrentLimit = buf.DecodeUint32() + m.CurrentBucket = buf.DecodeUint32() + m.ExtendedLimit = buf.DecodeUint32() + m.ExtendedBucket = buf.DecodeUint32() + m.LastUpdateTime = buf.DecodeUint64() + return nil +} + +// Get list of policers +// - match_name_valid - if 0 request all policers otherwise use match_name +// - match_name - policer name +// +// PolicerDump defines message 'policer_dump'. +type PolicerDump struct { + MatchNameValid bool `binapi:"bool,name=match_name_valid" json:"match_name_valid,omitempty"` + MatchName string `binapi:"string[64],name=match_name" json:"match_name,omitempty"` +} + +func (m *PolicerDump) Reset() { *m = PolicerDump{} } +func (*PolicerDump) GetMessageName() string { return "policer_dump" } +func (*PolicerDump) GetCrcString() string { return "35f1ae0f" } +func (*PolicerDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.MatchNameValid + size += 64 // m.MatchName + return size +} +func (m *PolicerDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.MatchNameValid) + buf.EncodeString(m.MatchName, 64) + return buf.Bytes(), nil +} +func (m *PolicerDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.MatchNameValid = buf.DecodeBool() + m.MatchName = buf.DecodeString(64) + return nil +} + +// Get list of policers +// - policer_index - index of policer in the pool, ~0 to request all +// +// PolicerDumpV2 defines message 'policer_dump_v2'. +type PolicerDumpV2 struct { + PolicerIndex uint32 `binapi:"u32,name=policer_index" json:"policer_index,omitempty"` +} + +func (m *PolicerDumpV2) Reset() { *m = PolicerDumpV2{} } +func (*PolicerDumpV2) GetMessageName() string { return "policer_dump_v2" } +func (*PolicerDumpV2) GetCrcString() string { return "7ff7912e" } +func (*PolicerDumpV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerDumpV2) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PolicerIndex + return size +} +func (m *PolicerDumpV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PolicerIndex) + return buf.Bytes(), nil +} +func (m *PolicerDumpV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PolicerIndex = buf.DecodeUint32() + return nil +} + +// policer input: Apply policer as an input feature. +// - name - policer name +// - sw_if_index - interface to apply the policer +// - apply - Apply/remove +// +// PolicerInput defines message 'policer_input'. +type PolicerInput struct { + Name string `binapi:"string[64],name=name" json:"name,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Apply bool `binapi:"bool,name=apply" json:"apply,omitempty"` +} + +func (m *PolicerInput) Reset() { *m = PolicerInput{} } +func (*PolicerInput) GetMessageName() string { return "policer_input" } +func (*PolicerInput) GetCrcString() string { return "233f0ef5" } +func (*PolicerInput) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerInput) Size() (size int) { + if m == nil { + return 0 + } + size += 64 // m.Name + size += 4 // m.SwIfIndex + size += 1 // m.Apply + return size +} +func (m *PolicerInput) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.Name, 64) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.Apply) + return buf.Bytes(), nil +} +func (m *PolicerInput) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Name = buf.DecodeString(64) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Apply = buf.DecodeBool() + return nil +} + +// PolicerInputReply defines message 'policer_input_reply'. +type PolicerInputReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PolicerInputReply) Reset() { *m = PolicerInputReply{} } +func (*PolicerInputReply) GetMessageName() string { return "policer_input_reply" } +func (*PolicerInputReply) GetCrcString() string { return "e8d4e804" } +func (*PolicerInputReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerInputReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PolicerInputReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PolicerInputReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// PolicerInputV2 defines message 'policer_input_v2'. +type PolicerInputV2 struct { + PolicerIndex uint32 `binapi:"u32,name=policer_index" json:"policer_index,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Apply bool `binapi:"bool,name=apply" json:"apply,omitempty"` +} + +func (m *PolicerInputV2) Reset() { *m = PolicerInputV2{} } +func (*PolicerInputV2) GetMessageName() string { return "policer_input_v2" } +func (*PolicerInputV2) GetCrcString() string { return "8388eb84" } +func (*PolicerInputV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerInputV2) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PolicerIndex + size += 4 // m.SwIfIndex + size += 1 // m.Apply + return size +} +func (m *PolicerInputV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PolicerIndex) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.Apply) + return buf.Bytes(), nil +} +func (m *PolicerInputV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PolicerIndex = buf.DecodeUint32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Apply = buf.DecodeBool() + return nil +} + +// PolicerInputV2Reply defines message 'policer_input_v2_reply'. +type PolicerInputV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PolicerInputV2Reply) Reset() { *m = PolicerInputV2Reply{} } +func (*PolicerInputV2Reply) GetMessageName() string { return "policer_input_v2_reply" } +func (*PolicerInputV2Reply) GetCrcString() string { return "e8d4e804" } +func (*PolicerInputV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerInputV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PolicerInputV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PolicerInputV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// policer output: Apply policer as an output feature. +// - name - policer name +// - sw_if_index - interface to apply the policer +// - apply - Apply/remove +// +// PolicerOutput defines message 'policer_output'. +type PolicerOutput struct { + Name string `binapi:"string[64],name=name" json:"name,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Apply bool `binapi:"bool,name=apply" json:"apply,omitempty"` +} + +func (m *PolicerOutput) Reset() { *m = PolicerOutput{} } +func (*PolicerOutput) GetMessageName() string { return "policer_output" } +func (*PolicerOutput) GetCrcString() string { return "233f0ef5" } +func (*PolicerOutput) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerOutput) Size() (size int) { + if m == nil { + return 0 + } + size += 64 // m.Name + size += 4 // m.SwIfIndex + size += 1 // m.Apply + return size +} +func (m *PolicerOutput) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.Name, 64) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.Apply) + return buf.Bytes(), nil +} +func (m *PolicerOutput) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Name = buf.DecodeString(64) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Apply = buf.DecodeBool() + return nil +} + +// PolicerOutputReply defines message 'policer_output_reply'. +type PolicerOutputReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PolicerOutputReply) Reset() { *m = PolicerOutputReply{} } +func (*PolicerOutputReply) GetMessageName() string { return "policer_output_reply" } +func (*PolicerOutputReply) GetCrcString() string { return "e8d4e804" } +func (*PolicerOutputReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerOutputReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PolicerOutputReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PolicerOutputReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// PolicerOutputV2 defines message 'policer_output_v2'. +type PolicerOutputV2 struct { + PolicerIndex uint32 `binapi:"u32,name=policer_index" json:"policer_index,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Apply bool `binapi:"bool,name=apply" json:"apply,omitempty"` +} + +func (m *PolicerOutputV2) Reset() { *m = PolicerOutputV2{} } +func (*PolicerOutputV2) GetMessageName() string { return "policer_output_v2" } +func (*PolicerOutputV2) GetCrcString() string { return "8388eb84" } +func (*PolicerOutputV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerOutputV2) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PolicerIndex + size += 4 // m.SwIfIndex + size += 1 // m.Apply + return size +} +func (m *PolicerOutputV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PolicerIndex) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.Apply) + return buf.Bytes(), nil +} +func (m *PolicerOutputV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PolicerIndex = buf.DecodeUint32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Apply = buf.DecodeBool() + return nil +} + +// PolicerOutputV2Reply defines message 'policer_output_v2_reply'. +type PolicerOutputV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PolicerOutputV2Reply) Reset() { *m = PolicerOutputV2Reply{} } +func (*PolicerOutputV2Reply) GetMessageName() string { return "policer_output_v2_reply" } +func (*PolicerOutputV2Reply) GetCrcString() string { return "e8d4e804" } +func (*PolicerOutputV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerOutputV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PolicerOutputV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PolicerOutputV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// PolicerReset defines message 'policer_reset'. +type PolicerReset struct { + PolicerIndex uint32 `binapi:"u32,name=policer_index" json:"policer_index,omitempty"` +} + +func (m *PolicerReset) Reset() { *m = PolicerReset{} } +func (*PolicerReset) GetMessageName() string { return "policer_reset" } +func (*PolicerReset) GetCrcString() string { return "7ff7912e" } +func (*PolicerReset) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerReset) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PolicerIndex + return size +} +func (m *PolicerReset) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PolicerIndex) + return buf.Bytes(), nil +} +func (m *PolicerReset) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PolicerIndex = buf.DecodeUint32() + return nil +} + +// PolicerResetReply defines message 'policer_reset_reply'. +type PolicerResetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PolicerResetReply) Reset() { *m = PolicerResetReply{} } +func (*PolicerResetReply) GetMessageName() string { return "policer_reset_reply" } +func (*PolicerResetReply) GetCrcString() string { return "e8d4e804" } +func (*PolicerResetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerResetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PolicerResetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PolicerResetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// PolicerUpdate defines message 'policer_update'. +type PolicerUpdate struct { + PolicerIndex uint32 `binapi:"u32,name=policer_index" json:"policer_index,omitempty"` + Infos policer_types.PolicerConfig `binapi:"policer_config,name=infos" json:"infos,omitempty"` +} + +func (m *PolicerUpdate) Reset() { *m = PolicerUpdate{} } +func (*PolicerUpdate) GetMessageName() string { return "policer_update" } +func (*PolicerUpdate) GetCrcString() string { return "fd039ef0" } +func (*PolicerUpdate) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerUpdate) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PolicerIndex + size += 4 // m.Infos.Cir + size += 4 // m.Infos.Eir + size += 8 // m.Infos.Cb + size += 8 // m.Infos.Eb + size += 1 // m.Infos.RateType + size += 1 // m.Infos.RoundType + size += 1 // m.Infos.Type + size += 1 // m.Infos.ColorAware + size += 1 // m.Infos.ConformAction.Type + size += 1 // m.Infos.ConformAction.Dscp + size += 1 // m.Infos.ExceedAction.Type + size += 1 // m.Infos.ExceedAction.Dscp + size += 1 // m.Infos.ViolateAction.Type + size += 1 // m.Infos.ViolateAction.Dscp + return size +} +func (m *PolicerUpdate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PolicerIndex) + buf.EncodeUint32(m.Infos.Cir) + buf.EncodeUint32(m.Infos.Eir) + buf.EncodeUint64(m.Infos.Cb) + buf.EncodeUint64(m.Infos.Eb) + buf.EncodeUint8(uint8(m.Infos.RateType)) + buf.EncodeUint8(uint8(m.Infos.RoundType)) + buf.EncodeUint8(uint8(m.Infos.Type)) + buf.EncodeBool(m.Infos.ColorAware) + buf.EncodeUint8(uint8(m.Infos.ConformAction.Type)) + buf.EncodeUint8(m.Infos.ConformAction.Dscp) + buf.EncodeUint8(uint8(m.Infos.ExceedAction.Type)) + buf.EncodeUint8(m.Infos.ExceedAction.Dscp) + buf.EncodeUint8(uint8(m.Infos.ViolateAction.Type)) + buf.EncodeUint8(m.Infos.ViolateAction.Dscp) + return buf.Bytes(), nil +} +func (m *PolicerUpdate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PolicerIndex = buf.DecodeUint32() + m.Infos.Cir = buf.DecodeUint32() + m.Infos.Eir = buf.DecodeUint32() + m.Infos.Cb = buf.DecodeUint64() + m.Infos.Eb = buf.DecodeUint64() + m.Infos.RateType = policer_types.Sse2QosRateType(buf.DecodeUint8()) + m.Infos.RoundType = policer_types.Sse2QosRoundType(buf.DecodeUint8()) + m.Infos.Type = policer_types.Sse2QosPolicerType(buf.DecodeUint8()) + m.Infos.ColorAware = buf.DecodeBool() + m.Infos.ConformAction.Type = policer_types.Sse2QosActionType(buf.DecodeUint8()) + m.Infos.ConformAction.Dscp = buf.DecodeUint8() + m.Infos.ExceedAction.Type = policer_types.Sse2QosActionType(buf.DecodeUint8()) + m.Infos.ExceedAction.Dscp = buf.DecodeUint8() + m.Infos.ViolateAction.Type = policer_types.Sse2QosActionType(buf.DecodeUint8()) + m.Infos.ViolateAction.Dscp = buf.DecodeUint8() + return nil +} + +// PolicerUpdateReply defines message 'policer_update_reply'. +type PolicerUpdateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PolicerUpdateReply) Reset() { *m = PolicerUpdateReply{} } +func (*PolicerUpdateReply) GetMessageName() string { return "policer_update_reply" } +func (*PolicerUpdateReply) GetCrcString() string { return "e8d4e804" } +func (*PolicerUpdateReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerUpdateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PolicerUpdateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PolicerUpdateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_policer_binapi_init() } +func file_policer_binapi_init() { + api.RegisterMessage((*PolicerAdd)(nil), "policer_add_4d949e35") + api.RegisterMessage((*PolicerAddDel)(nil), "policer_add_del_2b31dd38") + api.RegisterMessage((*PolicerAddDelReply)(nil), "policer_add_del_reply_a177cef2") + api.RegisterMessage((*PolicerAddReply)(nil), "policer_add_reply_a177cef2") + api.RegisterMessage((*PolicerBind)(nil), "policer_bind_dcf516f9") + api.RegisterMessage((*PolicerBindReply)(nil), "policer_bind_reply_e8d4e804") + api.RegisterMessage((*PolicerBindV2)(nil), "policer_bind_v2_f87bd3c0") + api.RegisterMessage((*PolicerBindV2Reply)(nil), "policer_bind_v2_reply_e8d4e804") + api.RegisterMessage((*PolicerDel)(nil), "policer_del_7ff7912e") + api.RegisterMessage((*PolicerDelReply)(nil), "policer_del_reply_e8d4e804") + api.RegisterMessage((*PolicerDetails)(nil), "policer_details_72d0e248") + api.RegisterMessage((*PolicerDump)(nil), "policer_dump_35f1ae0f") + api.RegisterMessage((*PolicerDumpV2)(nil), "policer_dump_v2_7ff7912e") + api.RegisterMessage((*PolicerInput)(nil), "policer_input_233f0ef5") + api.RegisterMessage((*PolicerInputReply)(nil), "policer_input_reply_e8d4e804") + api.RegisterMessage((*PolicerInputV2)(nil), "policer_input_v2_8388eb84") + api.RegisterMessage((*PolicerInputV2Reply)(nil), "policer_input_v2_reply_e8d4e804") + api.RegisterMessage((*PolicerOutput)(nil), "policer_output_233f0ef5") + api.RegisterMessage((*PolicerOutputReply)(nil), "policer_output_reply_e8d4e804") + api.RegisterMessage((*PolicerOutputV2)(nil), "policer_output_v2_8388eb84") + api.RegisterMessage((*PolicerOutputV2Reply)(nil), "policer_output_v2_reply_e8d4e804") + api.RegisterMessage((*PolicerReset)(nil), "policer_reset_7ff7912e") + api.RegisterMessage((*PolicerResetReply)(nil), "policer_reset_reply_e8d4e804") + api.RegisterMessage((*PolicerUpdate)(nil), "policer_update_fd039ef0") + api.RegisterMessage((*PolicerUpdateReply)(nil), "policer_update_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*PolicerAdd)(nil), + (*PolicerAddDel)(nil), + (*PolicerAddDelReply)(nil), + (*PolicerAddReply)(nil), + (*PolicerBind)(nil), + (*PolicerBindReply)(nil), + (*PolicerBindV2)(nil), + (*PolicerBindV2Reply)(nil), + (*PolicerDel)(nil), + (*PolicerDelReply)(nil), + (*PolicerDetails)(nil), + (*PolicerDump)(nil), + (*PolicerDumpV2)(nil), + (*PolicerInput)(nil), + (*PolicerInputReply)(nil), + (*PolicerInputV2)(nil), + (*PolicerInputV2Reply)(nil), + (*PolicerOutput)(nil), + (*PolicerOutputReply)(nil), + (*PolicerOutputV2)(nil), + (*PolicerOutputV2Reply)(nil), + (*PolicerReset)(nil), + (*PolicerResetReply)(nil), + (*PolicerUpdate)(nil), + (*PolicerUpdateReply)(nil), + } +} diff --git a/binapi/policer/policer_rpc.ba.go b/binapi/policer/policer_rpc.ba.go new file mode 100644 index 00000000..64f37ac4 --- /dev/null +++ b/binapi/policer/policer_rpc.ba.go @@ -0,0 +1,222 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package policer + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service policer. +type RPCService interface { + PolicerAdd(ctx context.Context, in *PolicerAdd) (*PolicerAddReply, error) + PolicerAddDel(ctx context.Context, in *PolicerAddDel) (*PolicerAddDelReply, error) + PolicerBind(ctx context.Context, in *PolicerBind) (*PolicerBindReply, error) + PolicerBindV2(ctx context.Context, in *PolicerBindV2) (*PolicerBindV2Reply, error) + PolicerDel(ctx context.Context, in *PolicerDel) (*PolicerDelReply, error) + PolicerDump(ctx context.Context, in *PolicerDump) (RPCService_PolicerDumpClient, error) + PolicerDumpV2(ctx context.Context, in *PolicerDumpV2) (RPCService_PolicerDumpV2Client, error) + PolicerInput(ctx context.Context, in *PolicerInput) (*PolicerInputReply, error) + PolicerInputV2(ctx context.Context, in *PolicerInputV2) (*PolicerInputV2Reply, error) + PolicerOutput(ctx context.Context, in *PolicerOutput) (*PolicerOutputReply, error) + PolicerOutputV2(ctx context.Context, in *PolicerOutputV2) (*PolicerOutputV2Reply, error) + PolicerReset(ctx context.Context, in *PolicerReset) (*PolicerResetReply, error) + PolicerUpdate(ctx context.Context, in *PolicerUpdate) (*PolicerUpdateReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) PolicerAdd(ctx context.Context, in *PolicerAdd) (*PolicerAddReply, error) { + out := new(PolicerAddReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PolicerAddDel(ctx context.Context, in *PolicerAddDel) (*PolicerAddDelReply, error) { + out := new(PolicerAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PolicerBind(ctx context.Context, in *PolicerBind) (*PolicerBindReply, error) { + out := new(PolicerBindReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PolicerBindV2(ctx context.Context, in *PolicerBindV2) (*PolicerBindV2Reply, error) { + out := new(PolicerBindV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PolicerDel(ctx context.Context, in *PolicerDel) (*PolicerDelReply, error) { + out := new(PolicerDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PolicerDump(ctx context.Context, in *PolicerDump) (RPCService_PolicerDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_PolicerDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_PolicerDumpClient interface { + Recv() (*PolicerDetails, error) + api.Stream +} + +type serviceClient_PolicerDumpClient struct { + api.Stream +} + +func (c *serviceClient_PolicerDumpClient) Recv() (*PolicerDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *PolicerDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) PolicerDumpV2(ctx context.Context, in *PolicerDumpV2) (RPCService_PolicerDumpV2Client, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_PolicerDumpV2Client{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_PolicerDumpV2Client interface { + Recv() (*PolicerDetails, error) + api.Stream +} + +type serviceClient_PolicerDumpV2Client struct { + api.Stream +} + +func (c *serviceClient_PolicerDumpV2Client) Recv() (*PolicerDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *PolicerDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) PolicerInput(ctx context.Context, in *PolicerInput) (*PolicerInputReply, error) { + out := new(PolicerInputReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PolicerInputV2(ctx context.Context, in *PolicerInputV2) (*PolicerInputV2Reply, error) { + out := new(PolicerInputV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PolicerOutput(ctx context.Context, in *PolicerOutput) (*PolicerOutputReply, error) { + out := new(PolicerOutputReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PolicerOutputV2(ctx context.Context, in *PolicerOutputV2) (*PolicerOutputV2Reply, error) { + out := new(PolicerOutputV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PolicerReset(ctx context.Context, in *PolicerReset) (*PolicerResetReply, error) { + out := new(PolicerResetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PolicerUpdate(ctx context.Context, in *PolicerUpdate) (*PolicerUpdateReply, error) { + out := new(PolicerUpdateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/policer_types/policer_types.ba.go b/binapi/policer_types/policer_types.ba.go new file mode 100644 index 00000000..9b797bff --- /dev/null +++ b/binapi/policer_types/policer_types.ba.go @@ -0,0 +1,183 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/policer_types.api.json + +// Package policer_types contains generated bindings for API file policer_types.api. +// +// Contents: +// - 4 enums +// - 2 structs +package policer_types + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "policer_types" + APIVersion = "1.0.0" + VersionCrc = 0x5838c08b +) + +// Sse2QosActionType defines enum 'sse2_qos_action_type'. +type Sse2QosActionType uint8 + +const ( + SSE2_QOS_ACTION_API_DROP Sse2QosActionType = 0 + SSE2_QOS_ACTION_API_TRANSMIT Sse2QosActionType = 1 + SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT Sse2QosActionType = 2 +) + +var ( + Sse2QosActionType_name = map[uint8]string{ + 0: "SSE2_QOS_ACTION_API_DROP", + 1: "SSE2_QOS_ACTION_API_TRANSMIT", + 2: "SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT", + } + Sse2QosActionType_value = map[string]uint8{ + "SSE2_QOS_ACTION_API_DROP": 0, + "SSE2_QOS_ACTION_API_TRANSMIT": 1, + "SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT": 2, + } +) + +func (x Sse2QosActionType) String() string { + s, ok := Sse2QosActionType_name[uint8(x)] + if ok { + return s + } + return "Sse2QosActionType(" + strconv.Itoa(int(x)) + ")" +} + +// Sse2QosPolicerType defines enum 'sse2_qos_policer_type'. +type Sse2QosPolicerType uint8 + +const ( + SSE2_QOS_POLICER_TYPE_API_1R2C Sse2QosPolicerType = 0 + SSE2_QOS_POLICER_TYPE_API_1R3C_RFC_2697 Sse2QosPolicerType = 1 + SSE2_QOS_POLICER_TYPE_API_2R3C_RFC_2698 Sse2QosPolicerType = 2 + SSE2_QOS_POLICER_TYPE_API_2R3C_RFC_4115 Sse2QosPolicerType = 3 + SSE2_QOS_POLICER_TYPE_API_2R3C_RFC_MEF5CF1 Sse2QosPolicerType = 4 + SSE2_QOS_POLICER_TYPE_API_MAX Sse2QosPolicerType = 5 +) + +var ( + Sse2QosPolicerType_name = map[uint8]string{ + 0: "SSE2_QOS_POLICER_TYPE_API_1R2C", + 1: "SSE2_QOS_POLICER_TYPE_API_1R3C_RFC_2697", + 2: "SSE2_QOS_POLICER_TYPE_API_2R3C_RFC_2698", + 3: "SSE2_QOS_POLICER_TYPE_API_2R3C_RFC_4115", + 4: "SSE2_QOS_POLICER_TYPE_API_2R3C_RFC_MEF5CF1", + 5: "SSE2_QOS_POLICER_TYPE_API_MAX", + } + Sse2QosPolicerType_value = map[string]uint8{ + "SSE2_QOS_POLICER_TYPE_API_1R2C": 0, + "SSE2_QOS_POLICER_TYPE_API_1R3C_RFC_2697": 1, + "SSE2_QOS_POLICER_TYPE_API_2R3C_RFC_2698": 2, + "SSE2_QOS_POLICER_TYPE_API_2R3C_RFC_4115": 3, + "SSE2_QOS_POLICER_TYPE_API_2R3C_RFC_MEF5CF1": 4, + "SSE2_QOS_POLICER_TYPE_API_MAX": 5, + } +) + +func (x Sse2QosPolicerType) String() string { + s, ok := Sse2QosPolicerType_name[uint8(x)] + if ok { + return s + } + return "Sse2QosPolicerType(" + strconv.Itoa(int(x)) + ")" +} + +// Sse2QosRateType defines enum 'sse2_qos_rate_type'. +type Sse2QosRateType uint8 + +const ( + SSE2_QOS_RATE_API_KBPS Sse2QosRateType = 0 + SSE2_QOS_RATE_API_PPS Sse2QosRateType = 1 + SSE2_QOS_RATE_API_INVALID Sse2QosRateType = 2 +) + +var ( + Sse2QosRateType_name = map[uint8]string{ + 0: "SSE2_QOS_RATE_API_KBPS", + 1: "SSE2_QOS_RATE_API_PPS", + 2: "SSE2_QOS_RATE_API_INVALID", + } + Sse2QosRateType_value = map[string]uint8{ + "SSE2_QOS_RATE_API_KBPS": 0, + "SSE2_QOS_RATE_API_PPS": 1, + "SSE2_QOS_RATE_API_INVALID": 2, + } +) + +func (x Sse2QosRateType) String() string { + s, ok := Sse2QosRateType_name[uint8(x)] + if ok { + return s + } + return "Sse2QosRateType(" + strconv.Itoa(int(x)) + ")" +} + +// Sse2QosRoundType defines enum 'sse2_qos_round_type'. +type Sse2QosRoundType uint8 + +const ( + SSE2_QOS_ROUND_API_TO_CLOSEST Sse2QosRoundType = 0 + SSE2_QOS_ROUND_API_TO_UP Sse2QosRoundType = 1 + SSE2_QOS_ROUND_API_TO_DOWN Sse2QosRoundType = 2 + SSE2_QOS_ROUND_API_INVALID Sse2QosRoundType = 3 +) + +var ( + Sse2QosRoundType_name = map[uint8]string{ + 0: "SSE2_QOS_ROUND_API_TO_CLOSEST", + 1: "SSE2_QOS_ROUND_API_TO_UP", + 2: "SSE2_QOS_ROUND_API_TO_DOWN", + 3: "SSE2_QOS_ROUND_API_INVALID", + } + Sse2QosRoundType_value = map[string]uint8{ + "SSE2_QOS_ROUND_API_TO_CLOSEST": 0, + "SSE2_QOS_ROUND_API_TO_UP": 1, + "SSE2_QOS_ROUND_API_TO_DOWN": 2, + "SSE2_QOS_ROUND_API_INVALID": 3, + } +) + +func (x Sse2QosRoundType) String() string { + s, ok := Sse2QosRoundType_name[uint8(x)] + if ok { + return s + } + return "Sse2QosRoundType(" + strconv.Itoa(int(x)) + ")" +} + +// PolicerConfig defines type 'policer_config'. +type PolicerConfig struct { + Cir uint32 `binapi:"u32,name=cir" json:"cir,omitempty"` + Eir uint32 `binapi:"u32,name=eir" json:"eir,omitempty"` + Cb uint64 `binapi:"u64,name=cb" json:"cb,omitempty"` + Eb uint64 `binapi:"u64,name=eb" json:"eb,omitempty"` + RateType Sse2QosRateType `binapi:"sse2_qos_rate_type,name=rate_type" json:"rate_type,omitempty"` + RoundType Sse2QosRoundType `binapi:"sse2_qos_round_type,name=round_type" json:"round_type,omitempty"` + Type Sse2QosPolicerType `binapi:"sse2_qos_policer_type,name=type" json:"type,omitempty"` + ColorAware bool `binapi:"bool,name=color_aware" json:"color_aware,omitempty"` + ConformAction Sse2QosAction `binapi:"sse2_qos_action,name=conform_action" json:"conform_action,omitempty"` + ExceedAction Sse2QosAction `binapi:"sse2_qos_action,name=exceed_action" json:"exceed_action,omitempty"` + ViolateAction Sse2QosAction `binapi:"sse2_qos_action,name=violate_action" json:"violate_action,omitempty"` +} + +// Sse2QosAction defines type 'sse2_qos_action'. +type Sse2QosAction struct { + Type Sse2QosActionType `binapi:"sse2_qos_action_type,name=type" json:"type,omitempty"` + Dscp uint8 `binapi:"u8,name=dscp" json:"dscp,omitempty"` +} diff --git a/binapi/pot/pot.ba.go b/binapi/pot/pot.ba.go new file mode 100644 index 00000000..8df7036b --- /dev/null +++ b/binapi/pot/pot.ba.go @@ -0,0 +1,419 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/pot.api.json + +// Package pot contains generated bindings for API file pot.api. +// +// Contents: +// - 8 messages +package pot + +import ( + api "github.com/alkiranet/govpp/api" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "pot" + APIVersion = "1.0.0" + VersionCrc = 0xa9d8e55c +) + +// Proof of Transit(POT): Activate POT profile in the list +// - id - id of the profile +// - list_name - name of this profile list +// +// PotProfileActivate defines message 'pot_profile_activate'. +type PotProfileActivate struct { + ID uint8 `binapi:"u8,name=id" json:"id,omitempty"` + ListName string `binapi:"string[],name=list_name" json:"list_name,omitempty"` +} + +func (m *PotProfileActivate) Reset() { *m = PotProfileActivate{} } +func (*PotProfileActivate) GetMessageName() string { return "pot_profile_activate" } +func (*PotProfileActivate) GetCrcString() string { return "0770af98" } +func (*PotProfileActivate) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PotProfileActivate) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.ID + size += 4 + len(m.ListName) // m.ListName + return size +} +func (m *PotProfileActivate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.ID) + buf.EncodeString(m.ListName, 0) + return buf.Bytes(), nil +} +func (m *PotProfileActivate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ID = buf.DecodeUint8() + m.ListName = buf.DecodeString(0) + return nil +} + +// PotProfileActivateReply defines message 'pot_profile_activate_reply'. +type PotProfileActivateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PotProfileActivateReply) Reset() { *m = PotProfileActivateReply{} } +func (*PotProfileActivateReply) GetMessageName() string { return "pot_profile_activate_reply" } +func (*PotProfileActivateReply) GetCrcString() string { return "e8d4e804" } +func (*PotProfileActivateReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PotProfileActivateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PotProfileActivateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PotProfileActivateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Proof of Transit(POT): Set POT profile +// - id - id of the profile +// - validator - True/False to indicate if this is verifier +// - secret_key - Verification key +// - secret_share - Share of the 1st polynomial +// - prime - Prime number used for modulo operation +// - max_bits - Max bits to be used for Random number generation +// - lpc - Lagrange basis polynomial +// - polynomial_public - pre-evaluated public polynomial +// - list_name - name of this profile list +// +// PotProfileAdd defines message 'pot_profile_add'. +type PotProfileAdd struct { + ID uint8 `binapi:"u8,name=id" json:"id,omitempty"` + Validator uint8 `binapi:"u8,name=validator" json:"validator,omitempty"` + SecretKey uint64 `binapi:"u64,name=secret_key" json:"secret_key,omitempty"` + SecretShare uint64 `binapi:"u64,name=secret_share" json:"secret_share,omitempty"` + Prime uint64 `binapi:"u64,name=prime" json:"prime,omitempty"` + MaxBits uint8 `binapi:"u8,name=max_bits" json:"max_bits,omitempty"` + Lpc uint64 `binapi:"u64,name=lpc" json:"lpc,omitempty"` + PolynomialPublic uint64 `binapi:"u64,name=polynomial_public" json:"polynomial_public,omitempty"` + ListName string `binapi:"string[],name=list_name" json:"list_name,omitempty"` +} + +func (m *PotProfileAdd) Reset() { *m = PotProfileAdd{} } +func (*PotProfileAdd) GetMessageName() string { return "pot_profile_add" } +func (*PotProfileAdd) GetCrcString() string { return "ad5da3a3" } +func (*PotProfileAdd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PotProfileAdd) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.ID + size += 1 // m.Validator + size += 8 // m.SecretKey + size += 8 // m.SecretShare + size += 8 // m.Prime + size += 1 // m.MaxBits + size += 8 // m.Lpc + size += 8 // m.PolynomialPublic + size += 4 + len(m.ListName) // m.ListName + return size +} +func (m *PotProfileAdd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.ID) + buf.EncodeUint8(m.Validator) + buf.EncodeUint64(m.SecretKey) + buf.EncodeUint64(m.SecretShare) + buf.EncodeUint64(m.Prime) + buf.EncodeUint8(m.MaxBits) + buf.EncodeUint64(m.Lpc) + buf.EncodeUint64(m.PolynomialPublic) + buf.EncodeString(m.ListName, 0) + return buf.Bytes(), nil +} +func (m *PotProfileAdd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ID = buf.DecodeUint8() + m.Validator = buf.DecodeUint8() + m.SecretKey = buf.DecodeUint64() + m.SecretShare = buf.DecodeUint64() + m.Prime = buf.DecodeUint64() + m.MaxBits = buf.DecodeUint8() + m.Lpc = buf.DecodeUint64() + m.PolynomialPublic = buf.DecodeUint64() + m.ListName = buf.DecodeString(0) + return nil +} + +// PotProfileAddReply defines message 'pot_profile_add_reply'. +type PotProfileAddReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PotProfileAddReply) Reset() { *m = PotProfileAddReply{} } +func (*PotProfileAddReply) GetMessageName() string { return "pot_profile_add_reply" } +func (*PotProfileAddReply) GetCrcString() string { return "e8d4e804" } +func (*PotProfileAddReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PotProfileAddReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PotProfileAddReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PotProfileAddReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Delete POT Profile +// - list_name - name of profile list to delete +// +// PotProfileDel defines message 'pot_profile_del'. +type PotProfileDel struct { + ListName string `binapi:"string[],name=list_name" json:"list_name,omitempty"` +} + +func (m *PotProfileDel) Reset() { *m = PotProfileDel{} } +func (*PotProfileDel) GetMessageName() string { return "pot_profile_del" } +func (*PotProfileDel) GetCrcString() string { return "cd63f53b" } +func (*PotProfileDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PotProfileDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 + len(m.ListName) // m.ListName + return size +} +func (m *PotProfileDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.ListName, 0) + return buf.Bytes(), nil +} +func (m *PotProfileDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ListName = buf.DecodeString(0) + return nil +} + +// PotProfileDelReply defines message 'pot_profile_del_reply'. +type PotProfileDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PotProfileDelReply) Reset() { *m = PotProfileDelReply{} } +func (*PotProfileDelReply) GetMessageName() string { return "pot_profile_del_reply" } +func (*PotProfileDelReply) GetCrcString() string { return "e8d4e804" } +func (*PotProfileDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PotProfileDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PotProfileDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PotProfileDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Show POT profile reply +// - id - id of the profile +// - validator - True/False to indicate if this is verifier +// - secret_key - Verification key +// - secret_share - Share of the 1st polynomial +// - prime - Prime number used for modulo operation +// - max_bits - Max bits to be used for Random number generation +// - lpc - Lagrange basis polynomial +// - polynomial_public - pre-evaluated public polynomial +// - list_name_len - length of the name of this profile list +// - list_name - name of this profile list +// +// PotProfileShowConfigDetails defines message 'pot_profile_show_config_details'. +type PotProfileShowConfigDetails struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + ID uint8 `binapi:"u8,name=id" json:"id,omitempty"` + Validator uint8 `binapi:"u8,name=validator" json:"validator,omitempty"` + SecretKey uint64 `binapi:"u64,name=secret_key" json:"secret_key,omitempty"` + SecretShare uint64 `binapi:"u64,name=secret_share" json:"secret_share,omitempty"` + Prime uint64 `binapi:"u64,name=prime" json:"prime,omitempty"` + BitMask uint64 `binapi:"u64,name=bit_mask" json:"bit_mask,omitempty"` + Lpc uint64 `binapi:"u64,name=lpc" json:"lpc,omitempty"` + PolynomialPublic uint64 `binapi:"u64,name=polynomial_public" json:"polynomial_public,omitempty"` +} + +func (m *PotProfileShowConfigDetails) Reset() { *m = PotProfileShowConfigDetails{} } +func (*PotProfileShowConfigDetails) GetMessageName() string { return "pot_profile_show_config_details" } +func (*PotProfileShowConfigDetails) GetCrcString() string { return "b7ce0618" } +func (*PotProfileShowConfigDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PotProfileShowConfigDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 // m.ID + size += 1 // m.Validator + size += 8 // m.SecretKey + size += 8 // m.SecretShare + size += 8 // m.Prime + size += 8 // m.BitMask + size += 8 // m.Lpc + size += 8 // m.PolynomialPublic + return size +} +func (m *PotProfileShowConfigDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint8(m.ID) + buf.EncodeUint8(m.Validator) + buf.EncodeUint64(m.SecretKey) + buf.EncodeUint64(m.SecretShare) + buf.EncodeUint64(m.Prime) + buf.EncodeUint64(m.BitMask) + buf.EncodeUint64(m.Lpc) + buf.EncodeUint64(m.PolynomialPublic) + return buf.Bytes(), nil +} +func (m *PotProfileShowConfigDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.ID = buf.DecodeUint8() + m.Validator = buf.DecodeUint8() + m.SecretKey = buf.DecodeUint64() + m.SecretShare = buf.DecodeUint64() + m.Prime = buf.DecodeUint64() + m.BitMask = buf.DecodeUint64() + m.Lpc = buf.DecodeUint64() + m.PolynomialPublic = buf.DecodeUint64() + return nil +} + +// Show POT Profiles +// - id - id of the profile +// +// PotProfileShowConfigDump defines message 'pot_profile_show_config_dump'. +type PotProfileShowConfigDump struct { + ID uint8 `binapi:"u8,name=id" json:"id,omitempty"` +} + +func (m *PotProfileShowConfigDump) Reset() { *m = PotProfileShowConfigDump{} } +func (*PotProfileShowConfigDump) GetMessageName() string { return "pot_profile_show_config_dump" } +func (*PotProfileShowConfigDump) GetCrcString() string { return "005b7d59" } +func (*PotProfileShowConfigDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PotProfileShowConfigDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.ID + return size +} +func (m *PotProfileShowConfigDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.ID) + return buf.Bytes(), nil +} +func (m *PotProfileShowConfigDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ID = buf.DecodeUint8() + return nil +} + +func init() { file_pot_binapi_init() } +func file_pot_binapi_init() { + api.RegisterMessage((*PotProfileActivate)(nil), "pot_profile_activate_0770af98") + api.RegisterMessage((*PotProfileActivateReply)(nil), "pot_profile_activate_reply_e8d4e804") + api.RegisterMessage((*PotProfileAdd)(nil), "pot_profile_add_ad5da3a3") + api.RegisterMessage((*PotProfileAddReply)(nil), "pot_profile_add_reply_e8d4e804") + api.RegisterMessage((*PotProfileDel)(nil), "pot_profile_del_cd63f53b") + api.RegisterMessage((*PotProfileDelReply)(nil), "pot_profile_del_reply_e8d4e804") + api.RegisterMessage((*PotProfileShowConfigDetails)(nil), "pot_profile_show_config_details_b7ce0618") + api.RegisterMessage((*PotProfileShowConfigDump)(nil), "pot_profile_show_config_dump_005b7d59") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*PotProfileActivate)(nil), + (*PotProfileActivateReply)(nil), + (*PotProfileAdd)(nil), + (*PotProfileAddReply)(nil), + (*PotProfileDel)(nil), + (*PotProfileDelReply)(nil), + (*PotProfileShowConfigDetails)(nil), + (*PotProfileShowConfigDump)(nil), + } +} diff --git a/binapi/pot/pot_rpc.ba.go b/binapi/pot/pot_rpc.ba.go new file mode 100644 index 00000000..bfae315f --- /dev/null +++ b/binapi/pot/pot_rpc.ba.go @@ -0,0 +1,98 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package pot + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service pot. +type RPCService interface { + PotProfileActivate(ctx context.Context, in *PotProfileActivate) (*PotProfileActivateReply, error) + PotProfileAdd(ctx context.Context, in *PotProfileAdd) (*PotProfileAddReply, error) + PotProfileDel(ctx context.Context, in *PotProfileDel) (*PotProfileDelReply, error) + PotProfileShowConfigDump(ctx context.Context, in *PotProfileShowConfigDump) (RPCService_PotProfileShowConfigDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) PotProfileActivate(ctx context.Context, in *PotProfileActivate) (*PotProfileActivateReply, error) { + out := new(PotProfileActivateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PotProfileAdd(ctx context.Context, in *PotProfileAdd) (*PotProfileAddReply, error) { + out := new(PotProfileAddReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PotProfileDel(ctx context.Context, in *PotProfileDel) (*PotProfileDelReply, error) { + out := new(PotProfileDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PotProfileShowConfigDump(ctx context.Context, in *PotProfileShowConfigDump) (RPCService_PotProfileShowConfigDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_PotProfileShowConfigDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_PotProfileShowConfigDumpClient interface { + Recv() (*PotProfileShowConfigDetails, error) + api.Stream +} + +type serviceClient_PotProfileShowConfigDumpClient struct { + api.Stream +} + +func (c *serviceClient_PotProfileShowConfigDumpClient) Recv() (*PotProfileShowConfigDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *PotProfileShowConfigDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/pppoe/pppoe.ba.go b/binapi/pppoe/pppoe.ba.go new file mode 100644 index 00000000..4e2ce209 --- /dev/null +++ b/binapi/pppoe/pppoe.ba.go @@ -0,0 +1,335 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/pppoe.api.json + +// Package pppoe contains generated bindings for API file pppoe.api. +// +// Contents: +// - 6 messages +package pppoe + +import ( + api "github.com/alkiranet/govpp/api" + ethernet_types "github.com/alkiranet/govpp/binapi/ethernet_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "pppoe" + APIVersion = "2.0.0" + VersionCrc = 0xec9e86bf +) + +// Create PPPOE control plane interface +// - sw_if_index - software index of the interface +// - is_add - to create or to delete +// +// PppoeAddDelCp defines message 'pppoe_add_del_cp'. +type PppoeAddDelCp struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IsAdd uint8 `binapi:"u8,name=is_add" json:"is_add,omitempty"` +} + +func (m *PppoeAddDelCp) Reset() { *m = PppoeAddDelCp{} } +func (*PppoeAddDelCp) GetMessageName() string { return "pppoe_add_del_cp" } +func (*PppoeAddDelCp) GetCrcString() string { return "eacd9aaa" } +func (*PppoeAddDelCp) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PppoeAddDelCp) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.IsAdd + return size +} +func (m *PppoeAddDelCp) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(m.IsAdd) + return buf.Bytes(), nil +} +func (m *PppoeAddDelCp) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsAdd = buf.DecodeUint8() + return nil +} + +// reply for create PPPOE control plane interface +// - retval - return code +// +// PppoeAddDelCpReply defines message 'pppoe_add_del_cp_reply'. +type PppoeAddDelCpReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PppoeAddDelCpReply) Reset() { *m = PppoeAddDelCpReply{} } +func (*PppoeAddDelCpReply) GetMessageName() string { return "pppoe_add_del_cp_reply" } +func (*PppoeAddDelCpReply) GetCrcString() string { return "e8d4e804" } +func (*PppoeAddDelCpReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PppoeAddDelCpReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PppoeAddDelCpReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PppoeAddDelCpReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set or delete an PPPOE session +// - is_add - add address if non-zero, else delete +// - session_id - PPPoE session ID +// - client_ip - PPPOE session's client address. +// - decap_vrf_id - the vrf index for pppoe decaped packet +// - client_mac - the client ethernet address +// +// PppoeAddDelSession defines message 'pppoe_add_del_session'. +type PppoeAddDelSession struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + SessionID uint16 `binapi:"u16,name=session_id" json:"session_id,omitempty"` + ClientIP ip_types.Address `binapi:"address,name=client_ip" json:"client_ip,omitempty"` + DecapVrfID uint32 `binapi:"u32,name=decap_vrf_id" json:"decap_vrf_id,omitempty"` + ClientMac ethernet_types.MacAddress `binapi:"mac_address,name=client_mac" json:"client_mac,omitempty"` +} + +func (m *PppoeAddDelSession) Reset() { *m = PppoeAddDelSession{} } +func (*PppoeAddDelSession) GetMessageName() string { return "pppoe_add_del_session" } +func (*PppoeAddDelSession) GetCrcString() string { return "f6fd759e" } +func (*PppoeAddDelSession) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PppoeAddDelSession) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 2 // m.SessionID + size += 1 // m.ClientIP.Af + size += 1 * 16 // m.ClientIP.Un + size += 4 // m.DecapVrfID + size += 1 * 6 // m.ClientMac + return size +} +func (m *PppoeAddDelSession) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint16(m.SessionID) + buf.EncodeUint8(uint8(m.ClientIP.Af)) + buf.EncodeBytes(m.ClientIP.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.DecapVrfID) + buf.EncodeBytes(m.ClientMac[:], 6) + return buf.Bytes(), nil +} +func (m *PppoeAddDelSession) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.SessionID = buf.DecodeUint16() + m.ClientIP.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.ClientIP.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.DecapVrfID = buf.DecodeUint32() + copy(m.ClientMac[:], buf.DecodeBytes(6)) + return nil +} + +// reply for set or delete an PPPOE session +// - retval - return code +// - sw_if_index - software index of the interface +// +// PppoeAddDelSessionReply defines message 'pppoe_add_del_session_reply'. +type PppoeAddDelSessionReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *PppoeAddDelSessionReply) Reset() { *m = PppoeAddDelSessionReply{} } +func (*PppoeAddDelSessionReply) GetMessageName() string { return "pppoe_add_del_session_reply" } +func (*PppoeAddDelSessionReply) GetCrcString() string { return "5383d31f" } +func (*PppoeAddDelSessionReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PppoeAddDelSessionReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *PppoeAddDelSessionReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *PppoeAddDelSessionReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// dump details of an PPPOE session +// - sw_if_index - software index of the interface +// - session_id - PPPoE session ID +// - client_ip - PPPOE session's client address. +// - encap_if_index - the index of tx interface for pppoe encaped packet +// - decap_vrf_id - the vrf index for pppoe decaped packet +// - local_mac - the local ethernet address +// - client_mac - the client ethernet address +// +// PppoeSessionDetails defines message 'pppoe_session_details'. +type PppoeSessionDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + SessionID uint16 `binapi:"u16,name=session_id" json:"session_id,omitempty"` + ClientIP ip_types.Address `binapi:"address,name=client_ip" json:"client_ip,omitempty"` + EncapIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=encap_if_index" json:"encap_if_index,omitempty"` + DecapVrfID uint32 `binapi:"u32,name=decap_vrf_id" json:"decap_vrf_id,omitempty"` + LocalMac ethernet_types.MacAddress `binapi:"mac_address,name=local_mac" json:"local_mac,omitempty"` + ClientMac ethernet_types.MacAddress `binapi:"mac_address,name=client_mac" json:"client_mac,omitempty"` +} + +func (m *PppoeSessionDetails) Reset() { *m = PppoeSessionDetails{} } +func (*PppoeSessionDetails) GetMessageName() string { return "pppoe_session_details" } +func (*PppoeSessionDetails) GetCrcString() string { return "4b8e8a4a" } +func (*PppoeSessionDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PppoeSessionDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 2 // m.SessionID + size += 1 // m.ClientIP.Af + size += 1 * 16 // m.ClientIP.Un + size += 4 // m.EncapIfIndex + size += 4 // m.DecapVrfID + size += 1 * 6 // m.LocalMac + size += 1 * 6 // m.ClientMac + return size +} +func (m *PppoeSessionDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint16(m.SessionID) + buf.EncodeUint8(uint8(m.ClientIP.Af)) + buf.EncodeBytes(m.ClientIP.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.EncapIfIndex)) + buf.EncodeUint32(m.DecapVrfID) + buf.EncodeBytes(m.LocalMac[:], 6) + buf.EncodeBytes(m.ClientMac[:], 6) + return buf.Bytes(), nil +} +func (m *PppoeSessionDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.SessionID = buf.DecodeUint16() + m.ClientIP.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.ClientIP.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.EncapIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.DecapVrfID = buf.DecodeUint32() + copy(m.LocalMac[:], buf.DecodeBytes(6)) + copy(m.ClientMac[:], buf.DecodeBytes(6)) + return nil +} + +// Dump PPPOE session +// - sw_if_index - software index of the interface +// +// PppoeSessionDump defines message 'pppoe_session_dump'. +type PppoeSessionDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *PppoeSessionDump) Reset() { *m = PppoeSessionDump{} } +func (*PppoeSessionDump) GetMessageName() string { return "pppoe_session_dump" } +func (*PppoeSessionDump) GetCrcString() string { return "f9e6675e" } +func (*PppoeSessionDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PppoeSessionDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *PppoeSessionDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *PppoeSessionDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +func init() { file_pppoe_binapi_init() } +func file_pppoe_binapi_init() { + api.RegisterMessage((*PppoeAddDelCp)(nil), "pppoe_add_del_cp_eacd9aaa") + api.RegisterMessage((*PppoeAddDelCpReply)(nil), "pppoe_add_del_cp_reply_e8d4e804") + api.RegisterMessage((*PppoeAddDelSession)(nil), "pppoe_add_del_session_f6fd759e") + api.RegisterMessage((*PppoeAddDelSessionReply)(nil), "pppoe_add_del_session_reply_5383d31f") + api.RegisterMessage((*PppoeSessionDetails)(nil), "pppoe_session_details_4b8e8a4a") + api.RegisterMessage((*PppoeSessionDump)(nil), "pppoe_session_dump_f9e6675e") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*PppoeAddDelCp)(nil), + (*PppoeAddDelCpReply)(nil), + (*PppoeAddDelSession)(nil), + (*PppoeAddDelSessionReply)(nil), + (*PppoeSessionDetails)(nil), + (*PppoeSessionDump)(nil), + } +} diff --git a/binapi/pppoe/pppoe_rpc.ba.go b/binapi/pppoe/pppoe_rpc.ba.go new file mode 100644 index 00000000..368e3ed0 --- /dev/null +++ b/binapi/pppoe/pppoe_rpc.ba.go @@ -0,0 +1,88 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package pppoe + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service pppoe. +type RPCService interface { + PppoeAddDelCp(ctx context.Context, in *PppoeAddDelCp) (*PppoeAddDelCpReply, error) + PppoeAddDelSession(ctx context.Context, in *PppoeAddDelSession) (*PppoeAddDelSessionReply, error) + PppoeSessionDump(ctx context.Context, in *PppoeSessionDump) (RPCService_PppoeSessionDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) PppoeAddDelCp(ctx context.Context, in *PppoeAddDelCp) (*PppoeAddDelCpReply, error) { + out := new(PppoeAddDelCpReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PppoeAddDelSession(ctx context.Context, in *PppoeAddDelSession) (*PppoeAddDelSessionReply, error) { + out := new(PppoeAddDelSessionReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PppoeSessionDump(ctx context.Context, in *PppoeSessionDump) (RPCService_PppoeSessionDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_PppoeSessionDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_PppoeSessionDumpClient interface { + Recv() (*PppoeSessionDetails, error) + api.Stream +} + +type serviceClient_PppoeSessionDumpClient struct { + api.Stream +} + +func (c *serviceClient_PppoeSessionDumpClient) Recv() (*PppoeSessionDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *PppoeSessionDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/punt/punt.ba.go b/binapi/punt/punt.ba.go new file mode 100644 index 00000000..f8da3def --- /dev/null +++ b/binapi/punt/punt.ba.go @@ -0,0 +1,560 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/punt.api.json + +// Package punt contains generated bindings for API file punt.api. +// +// Contents: +// - 1 enum +// - 5 structs +// - 1 union +// - 10 messages +package punt + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "punt" + APIVersion = "2.2.1" + VersionCrc = 0x24d11934 +) + +// PuntType defines enum 'punt_type'. +type PuntType uint32 + +const ( + PUNT_API_TYPE_L4 PuntType = 0 + PUNT_API_TYPE_IP_PROTO PuntType = 1 + PUNT_API_TYPE_EXCEPTION PuntType = 2 +) + +var ( + PuntType_name = map[uint32]string{ + 0: "PUNT_API_TYPE_L4", + 1: "PUNT_API_TYPE_IP_PROTO", + 2: "PUNT_API_TYPE_EXCEPTION", + } + PuntType_value = map[string]uint32{ + "PUNT_API_TYPE_L4": 0, + "PUNT_API_TYPE_IP_PROTO": 1, + "PUNT_API_TYPE_EXCEPTION": 2, + } +) + +func (x PuntType) String() string { + s, ok := PuntType_name[uint32(x)] + if ok { + return s + } + return "PuntType(" + strconv.Itoa(int(x)) + ")" +} + +// Punt defines type 'punt'. +type Punt struct { + Type PuntType `binapi:"punt_type,name=type" json:"type,omitempty"` + Punt PuntUnion `binapi:"punt_union,name=punt" json:"punt,omitempty"` +} + +// PuntException defines type 'punt_exception'. +type PuntException struct { + ID uint32 `binapi:"u32,name=id" json:"id,omitempty"` +} + +// PuntIPProto defines type 'punt_ip_proto'. +type PuntIPProto struct { + Af ip_types.AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` + Protocol ip_types.IPProto `binapi:"ip_proto,name=protocol" json:"protocol,omitempty"` +} + +// PuntL4 defines type 'punt_l4'. +type PuntL4 struct { + Af ip_types.AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` + Protocol ip_types.IPProto `binapi:"ip_proto,name=protocol" json:"protocol,omitempty"` + Port uint16 `binapi:"u16,name=port" json:"port,omitempty"` +} + +// PuntReason defines type 'punt_reason'. +type PuntReason struct { + ID uint32 `binapi:"u32,name=id" json:"id,omitempty"` + Name string `binapi:"string[],name=name" json:"name,omitempty"` +} + +// PuntUnion defines union 'punt_union'. +type PuntUnion struct { + // PuntUnion can be one of: + // - Exception *PuntException + // - L4 *PuntL4 + // - IPProto *PuntIPProto + XXX_UnionData [4]byte +} + +func PuntUnionException(a PuntException) (u PuntUnion) { + u.SetException(a) + return +} +func (u *PuntUnion) SetException(a PuntException) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + buf.EncodeUint32(a.ID) +} +func (u *PuntUnion) GetException() (a PuntException) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + a.ID = buf.DecodeUint32() + return +} + +func PuntUnionL4(a PuntL4) (u PuntUnion) { + u.SetL4(a) + return +} +func (u *PuntUnion) SetL4(a PuntL4) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + buf.EncodeUint8(uint8(a.Af)) + buf.EncodeUint8(uint8(a.Protocol)) + buf.EncodeUint16(a.Port) +} +func (u *PuntUnion) GetL4() (a PuntL4) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + a.Af = ip_types.AddressFamily(buf.DecodeUint8()) + a.Protocol = ip_types.IPProto(buf.DecodeUint8()) + a.Port = buf.DecodeUint16() + return +} + +func PuntUnionIPProto(a PuntIPProto) (u PuntUnion) { + u.SetIPProto(a) + return +} +func (u *PuntUnion) SetIPProto(a PuntIPProto) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + buf.EncodeUint8(uint8(a.Af)) + buf.EncodeUint8(uint8(a.Protocol)) +} +func (u *PuntUnion) GetIPProto() (a PuntIPProto) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + a.Af = ip_types.AddressFamily(buf.DecodeUint8()) + a.Protocol = ip_types.IPProto(buf.DecodeUint8()) + return +} + +// PuntReasonDetails defines message 'punt_reason_details'. +type PuntReasonDetails struct { + Reason PuntReason `binapi:"punt_reason,name=reason" json:"reason,omitempty"` +} + +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 +} + +func (m *PuntReasonDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Reason.ID + size += 4 + len(m.Reason.Name) // m.Reason.Name + return size +} +func (m *PuntReasonDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Reason.ID) + buf.EncodeString(m.Reason.Name, 0) + return buf.Bytes(), nil +} +func (m *PuntReasonDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Reason.ID = buf.DecodeUint32() + m.Reason.Name = buf.DecodeString(0) + return nil +} + +// Dump all or one of the exception punt reasons +// * - - If the string is not set punt dump all reasons +// * else dump only the one specified +// PuntReasonDump defines message 'punt_reason_dump'. +type PuntReasonDump struct { + Reason PuntReason `binapi:"punt_reason,name=reason" json:"reason,omitempty"` +} + +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 +} + +func (m *PuntReasonDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Reason.ID + size += 4 + len(m.Reason.Name) // m.Reason.Name + return size +} +func (m *PuntReasonDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Reason.ID) + buf.EncodeString(m.Reason.Name, 0) + return buf.Bytes(), nil +} +func (m *PuntReasonDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Reason.ID = buf.DecodeUint32() + m.Reason.Name = buf.DecodeString(0) + return nil +} + +// PuntSocketDeregister defines message 'punt_socket_deregister'. +type PuntSocketDeregister struct { + Punt Punt `binapi:"punt,name=punt" json:"punt,omitempty"` +} + +func (m *PuntSocketDeregister) Reset() { *m = PuntSocketDeregister{} } +func (*PuntSocketDeregister) GetMessageName() string { return "punt_socket_deregister" } +func (*PuntSocketDeregister) GetCrcString() string { return "75afa766" } +func (*PuntSocketDeregister) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PuntSocketDeregister) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Punt.Type + size += 1 * 4 // m.Punt.Punt + return size +} +func (m *PuntSocketDeregister) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Punt.Type)) + buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 4) + return buf.Bytes(), nil +} +func (m *PuntSocketDeregister) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Punt.Type = PuntType(buf.DecodeUint32()) + copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(4)) + return nil +} + +// PuntSocketDeregisterReply defines message 'punt_socket_deregister_reply'. +type PuntSocketDeregisterReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *PuntSocketDeregisterReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PuntSocketDeregisterReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PuntSocketDeregisterReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// PuntSocketDetails defines message 'punt_socket_details'. +type PuntSocketDetails struct { + Punt Punt `binapi:"punt,name=punt" json:"punt,omitempty"` + Pathname string `binapi:"string[108],name=pathname" json:"pathname,omitempty"` +} + +func (m *PuntSocketDetails) Reset() { *m = PuntSocketDetails{} } +func (*PuntSocketDetails) GetMessageName() string { return "punt_socket_details" } +func (*PuntSocketDetails) GetCrcString() string { return "330466e4" } +func (*PuntSocketDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PuntSocketDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Punt.Type + size += 1 * 4 // m.Punt.Punt + size += 108 // m.Pathname + return size +} +func (m *PuntSocketDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Punt.Type)) + buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 4) + buf.EncodeString(m.Pathname, 108) + return buf.Bytes(), nil +} +func (m *PuntSocketDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Punt.Type = PuntType(buf.DecodeUint32()) + copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(4)) + m.Pathname = buf.DecodeString(108) + return nil +} + +// PuntSocketDump defines message 'punt_socket_dump'. +type PuntSocketDump struct { + Type PuntType `binapi:"punt_type,name=type" json:"type,omitempty"` +} + +func (m *PuntSocketDump) Reset() { *m = PuntSocketDump{} } +func (*PuntSocketDump) GetMessageName() string { return "punt_socket_dump" } +func (*PuntSocketDump) GetCrcString() string { return "916fb004" } +func (*PuntSocketDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PuntSocketDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Type + return size +} +func (m *PuntSocketDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Type)) + return buf.Bytes(), nil +} +func (m *PuntSocketDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Type = PuntType(buf.DecodeUint32()) + return nil +} + +// Punt traffic to the host via socket +// - header_version - expected meta data header version (currently 1) +// - punt - punt definition +// +// PuntSocketRegister defines message 'punt_socket_register'. +type PuntSocketRegister struct { + HeaderVersion uint32 `binapi:"u32,name=header_version" json:"header_version,omitempty"` + Punt Punt `binapi:"punt,name=punt" json:"punt,omitempty"` + Pathname string `binapi:"string[108],name=pathname" json:"pathname,omitempty"` +} + +func (m *PuntSocketRegister) Reset() { *m = PuntSocketRegister{} } +func (*PuntSocketRegister) GetMessageName() string { return "punt_socket_register" } +func (*PuntSocketRegister) GetCrcString() string { return "7875badb" } +func (*PuntSocketRegister) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PuntSocketRegister) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.HeaderVersion + size += 4 // m.Punt.Type + size += 1 * 4 // m.Punt.Punt + size += 108 // m.Pathname + return size +} +func (m *PuntSocketRegister) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.HeaderVersion) + buf.EncodeUint32(uint32(m.Punt.Type)) + buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 4) + buf.EncodeString(m.Pathname, 108) + return buf.Bytes(), nil +} +func (m *PuntSocketRegister) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.HeaderVersion = buf.DecodeUint32() + m.Punt.Type = PuntType(buf.DecodeUint32()) + copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(4)) + m.Pathname = buf.DecodeString(108) + return nil +} + +// PuntSocketRegisterReply defines message 'punt_socket_register_reply'. +type PuntSocketRegisterReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Pathname string `binapi:"string[108],name=pathname" json:"pathname,omitempty"` +} + +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 +} + +func (m *PuntSocketRegisterReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 108 // m.Pathname + return size +} +func (m *PuntSocketRegisterReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeString(m.Pathname, 108) + return buf.Bytes(), nil +} +func (m *PuntSocketRegisterReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Pathname = buf.DecodeString(108) + return nil +} + +// Punt traffic to the host +// - is_add - add punt if non-zero, else delete +// - punt - punt definition, only UDP (0x11) is supported +// +// SetPunt defines message 'set_punt'. +type SetPunt struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + Punt Punt `binapi:"punt,name=punt" json:"punt,omitempty"` +} + +func (m *SetPunt) Reset() { *m = SetPunt{} } +func (*SetPunt) GetMessageName() string { return "set_punt" } +func (*SetPunt) GetCrcString() string { return "47d0e347" } +func (*SetPunt) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SetPunt) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Punt.Type + size += 1 * 4 // m.Punt.Punt + return size +} +func (m *SetPunt) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(uint32(m.Punt.Type)) + buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 4) + return buf.Bytes(), nil +} +func (m *SetPunt) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Punt.Type = PuntType(buf.DecodeUint32()) + copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(4)) + return nil +} + +// SetPuntReply defines message 'set_punt_reply'. +type SetPuntReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 (m *SetPuntReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SetPuntReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SetPuntReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_punt_binapi_init() } +func file_punt_binapi_init() { + api.RegisterMessage((*PuntReasonDetails)(nil), "punt_reason_details_2c9d4a40") + api.RegisterMessage((*PuntReasonDump)(nil), "punt_reason_dump_5c0dd4fe") + api.RegisterMessage((*PuntSocketDeregister)(nil), "punt_socket_deregister_75afa766") + api.RegisterMessage((*PuntSocketDeregisterReply)(nil), "punt_socket_deregister_reply_e8d4e804") + api.RegisterMessage((*PuntSocketDetails)(nil), "punt_socket_details_330466e4") + api.RegisterMessage((*PuntSocketDump)(nil), "punt_socket_dump_916fb004") + api.RegisterMessage((*PuntSocketRegister)(nil), "punt_socket_register_7875badb") + api.RegisterMessage((*PuntSocketRegisterReply)(nil), "punt_socket_register_reply_bd30ae90") + api.RegisterMessage((*SetPunt)(nil), "set_punt_47d0e347") + api.RegisterMessage((*SetPuntReply)(nil), "set_punt_reply_e8d4e804") +} + +// 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), + } +} diff --git a/binapi/punt/punt_rpc.ba.go b/binapi/punt/punt_rpc.ba.go new file mode 100644 index 00000000..cb388353 --- /dev/null +++ b/binapi/punt/punt_rpc.ba.go @@ -0,0 +1,142 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package punt + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service punt. +type RPCService interface { + PuntReasonDump(ctx context.Context, in *PuntReasonDump) (RPCService_PuntReasonDumpClient, error) + PuntSocketDeregister(ctx context.Context, in *PuntSocketDeregister) (*PuntSocketDeregisterReply, error) + PuntSocketDump(ctx context.Context, in *PuntSocketDump) (RPCService_PuntSocketDumpClient, error) + PuntSocketRegister(ctx context.Context, in *PuntSocketRegister) (*PuntSocketRegisterReply, error) + SetPunt(ctx context.Context, in *SetPunt) (*SetPuntReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) PuntReasonDump(ctx context.Context, in *PuntReasonDump) (RPCService_PuntReasonDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_PuntReasonDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_PuntReasonDumpClient interface { + Recv() (*PuntReasonDetails, error) + api.Stream +} + +type serviceClient_PuntReasonDumpClient struct { + api.Stream +} + +func (c *serviceClient_PuntReasonDumpClient) Recv() (*PuntReasonDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *PuntReasonDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) PuntSocketDeregister(ctx context.Context, in *PuntSocketDeregister) (*PuntSocketDeregisterReply, error) { + out := new(PuntSocketDeregisterReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PuntSocketDump(ctx context.Context, in *PuntSocketDump) (RPCService_PuntSocketDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_PuntSocketDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_PuntSocketDumpClient interface { + Recv() (*PuntSocketDetails, error) + api.Stream +} + +type serviceClient_PuntSocketDumpClient struct { + api.Stream +} + +func (c *serviceClient_PuntSocketDumpClient) Recv() (*PuntSocketDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *PuntSocketDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) PuntSocketRegister(ctx context.Context, in *PuntSocketRegister) (*PuntSocketRegisterReply, error) { + out := new(PuntSocketRegisterReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SetPunt(ctx context.Context, in *SetPunt) (*SetPuntReply, error) { + out := new(SetPuntReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/qos/qos.ba.go b/binapi/qos/qos.ba.go new file mode 100644 index 00000000..afa06f65 --- /dev/null +++ b/binapi/qos/qos.ba.go @@ -0,0 +1,851 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/qos.api.json + +// Package qos contains generated bindings for API file qos.api. +// +// Contents: +// - 1 enum +// - 5 structs +// - 19 messages +package qos + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + _ "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "qos" + APIVersion = "1.1.1" + VersionCrc = 0x7b7b5955 +) + +// QosSource defines enum 'qos_source'. +type QosSource uint8 + +const ( + QOS_API_SOURCE_EXT QosSource = 0 + QOS_API_SOURCE_VLAN QosSource = 1 + QOS_API_SOURCE_MPLS QosSource = 2 + QOS_API_SOURCE_IP QosSource = 3 +) + +var ( + QosSource_name = map[uint8]string{ + 0: "QOS_API_SOURCE_EXT", + 1: "QOS_API_SOURCE_VLAN", + 2: "QOS_API_SOURCE_MPLS", + 3: "QOS_API_SOURCE_IP", + } + QosSource_value = map[string]uint8{ + "QOS_API_SOURCE_EXT": 0, + "QOS_API_SOURCE_VLAN": 1, + "QOS_API_SOURCE_MPLS": 2, + "QOS_API_SOURCE_IP": 3, + } +) + +func (x QosSource) String() string { + s, ok := QosSource_name[uint8(x)] + if ok { + return s + } + return "QosSource(" + strconv.Itoa(int(x)) + ")" +} + +// QosEgressMap defines type 'qos_egress_map'. +type QosEgressMap struct { + ID uint32 `binapi:"u32,name=id" json:"id,omitempty"` + Rows [4]QosEgressMapRow `binapi:"qos_egress_map_row[4],name=rows" json:"rows,omitempty"` +} + +// QosEgressMapRow defines type 'qos_egress_map_row'. +type QosEgressMapRow struct { + Outputs []byte `binapi:"u8[256],name=outputs" json:"outputs,omitempty"` +} + +// QosMark defines type 'qos_mark'. +type QosMark struct { + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + MapID uint32 `binapi:"u32,name=map_id" json:"map_id,omitempty"` + OutputSource QosSource `binapi:"qos_source,name=output_source" json:"output_source,omitempty"` +} + +// QosRecord defines type 'qos_record'. +type QosRecord struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + InputSource QosSource `binapi:"qos_source,name=input_source" json:"input_source,omitempty"` +} + +// QosStore defines type 'qos_store'. +type QosStore struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + InputSource QosSource `binapi:"qos_source,name=input_source" json:"input_source,omitempty"` + Value uint8 `binapi:"u8,name=value" json:"value,omitempty"` +} + +// * @brief Delete a Qos Map +// - - map_id - ID of the map to delete +// +// QosEgressMapDelete defines message 'qos_egress_map_delete'. +type QosEgressMapDelete struct { + ID uint32 `binapi:"u32,name=id" json:"id,omitempty"` +} + +func (m *QosEgressMapDelete) Reset() { *m = QosEgressMapDelete{} } +func (*QosEgressMapDelete) GetMessageName() string { return "qos_egress_map_delete" } +func (*QosEgressMapDelete) GetCrcString() string { return "3a91bde5" } +func (*QosEgressMapDelete) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *QosEgressMapDelete) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.ID + return size +} +func (m *QosEgressMapDelete) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.ID) + return buf.Bytes(), nil +} +func (m *QosEgressMapDelete) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ID = buf.DecodeUint32() + return nil +} + +// QosEgressMapDeleteReply defines message 'qos_egress_map_delete_reply'. +type QosEgressMapDeleteReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *QosEgressMapDeleteReply) Reset() { *m = QosEgressMapDeleteReply{} } +func (*QosEgressMapDeleteReply) GetMessageName() string { return "qos_egress_map_delete_reply" } +func (*QosEgressMapDeleteReply) GetCrcString() string { return "e8d4e804" } +func (*QosEgressMapDeleteReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *QosEgressMapDeleteReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *QosEgressMapDeleteReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *QosEgressMapDeleteReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// * QoS map details +// QosEgressMapDetails defines message 'qos_egress_map_details'. +type QosEgressMapDetails struct { + Map QosEgressMap `binapi:"qos_egress_map,name=map" json:"map,omitempty"` +} + +func (m *QosEgressMapDetails) Reset() { *m = QosEgressMapDetails{} } +func (*QosEgressMapDetails) GetMessageName() string { return "qos_egress_map_details" } +func (*QosEgressMapDetails) GetCrcString() string { return "46c5653c" } +func (*QosEgressMapDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *QosEgressMapDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Map.ID + for j2 := 0; j2 < 4; j2++ { + size += 1 * 256 // m.Map.Rows[j2].Outputs + } + return size +} +func (m *QosEgressMapDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Map.ID) + for j1 := 0; j1 < 4; j1++ { + buf.EncodeBytes(m.Map.Rows[j1].Outputs, 256) + } + return buf.Bytes(), nil +} +func (m *QosEgressMapDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Map.ID = buf.DecodeUint32() + for j1 := 0; j1 < 4; j1++ { + m.Map.Rows[j1].Outputs = make([]byte, 256) + copy(m.Map.Rows[j1].Outputs, buf.DecodeBytes(len(m.Map.Rows[j1].Outputs))) + } + return nil +} + +// * Dump the QoS egress maps +// QosEgressMapDump defines message 'qos_egress_map_dump'. +type QosEgressMapDump struct{} + +func (m *QosEgressMapDump) Reset() { *m = QosEgressMapDump{} } +func (*QosEgressMapDump) GetMessageName() string { return "qos_egress_map_dump" } +func (*QosEgressMapDump) GetCrcString() string { return "51077d14" } +func (*QosEgressMapDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *QosEgressMapDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *QosEgressMapDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *QosEgressMapDump) Unmarshal(b []byte) error { + return nil +} + +// * @brief Update a QoS Map +// - A QoS map, translates from the QoS value in the packet set by the 'record' +// - feature, to the value used for output in the 'mark' feature. +// - There is one row in the map for each input/record source. +// - The MAP is then applied to the egress interface at for a given output source +// - - map - The Map +// +// QosEgressMapUpdate defines message 'qos_egress_map_update'. +type QosEgressMapUpdate struct { + Map QosEgressMap `binapi:"qos_egress_map,name=map" json:"map,omitempty"` +} + +func (m *QosEgressMapUpdate) Reset() { *m = QosEgressMapUpdate{} } +func (*QosEgressMapUpdate) GetMessageName() string { return "qos_egress_map_update" } +func (*QosEgressMapUpdate) GetCrcString() string { return "6d1c065f" } +func (*QosEgressMapUpdate) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *QosEgressMapUpdate) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Map.ID + for j2 := 0; j2 < 4; j2++ { + size += 1 * 256 // m.Map.Rows[j2].Outputs + } + return size +} +func (m *QosEgressMapUpdate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Map.ID) + for j1 := 0; j1 < 4; j1++ { + buf.EncodeBytes(m.Map.Rows[j1].Outputs, 256) + } + return buf.Bytes(), nil +} +func (m *QosEgressMapUpdate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Map.ID = buf.DecodeUint32() + for j1 := 0; j1 < 4; j1++ { + m.Map.Rows[j1].Outputs = make([]byte, 256) + copy(m.Map.Rows[j1].Outputs, buf.DecodeBytes(len(m.Map.Rows[j1].Outputs))) + } + return nil +} + +// QosEgressMapUpdateReply defines message 'qos_egress_map_update_reply'. +type QosEgressMapUpdateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *QosEgressMapUpdateReply) Reset() { *m = QosEgressMapUpdateReply{} } +func (*QosEgressMapUpdateReply) GetMessageName() string { return "qos_egress_map_update_reply" } +func (*QosEgressMapUpdateReply) GetCrcString() string { return "e8d4e804" } +func (*QosEgressMapUpdateReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *QosEgressMapUpdateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *QosEgressMapUpdateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *QosEgressMapUpdateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// * QoS marking details +// QosMarkDetails defines message 'qos_mark_details'. +type QosMarkDetails struct { + Mark QosMark `binapi:"qos_mark,name=mark" json:"mark,omitempty"` +} + +func (m *QosMarkDetails) Reset() { *m = QosMarkDetails{} } +func (*QosMarkDetails) GetMessageName() string { return "qos_mark_details" } +func (*QosMarkDetails) GetCrcString() string { return "89fe81a9" } +func (*QosMarkDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *QosMarkDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Mark.SwIfIndex + size += 4 // m.Mark.MapID + size += 1 // m.Mark.OutputSource + return size +} +func (m *QosMarkDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Mark.SwIfIndex) + buf.EncodeUint32(m.Mark.MapID) + buf.EncodeUint8(uint8(m.Mark.OutputSource)) + return buf.Bytes(), nil +} +func (m *QosMarkDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Mark.SwIfIndex = buf.DecodeUint32() + m.Mark.MapID = buf.DecodeUint32() + m.Mark.OutputSource = QosSource(buf.DecodeUint8()) + return nil +} + +// QosMarkDetailsReply defines message 'qos_mark_details_reply'. +type QosMarkDetailsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *QosMarkDetailsReply) Reset() { *m = QosMarkDetailsReply{} } +func (*QosMarkDetailsReply) GetMessageName() string { return "qos_mark_details_reply" } +func (*QosMarkDetailsReply) GetCrcString() string { return "e8d4e804" } +func (*QosMarkDetailsReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *QosMarkDetailsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *QosMarkDetailsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *QosMarkDetailsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// * Dump QoS marking configs +// QosMarkDump defines message 'qos_mark_dump'. +type QosMarkDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *QosMarkDump) Reset() { *m = QosMarkDump{} } +func (*QosMarkDump) GetMessageName() string { return "qos_mark_dump" } +func (*QosMarkDump) GetCrcString() string { return "f9e6675e" } +func (*QosMarkDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *QosMarkDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *QosMarkDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *QosMarkDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// * @brief Enable/Disable QoS marking +// - - enable - enable=1 or disable the feature +// - - mark - Marking config +// +// QosMarkEnableDisable defines message 'qos_mark_enable_disable'. +type QosMarkEnableDisable struct { + Enable bool `binapi:"bool,name=enable,default=true" json:"enable,omitempty"` + Mark QosMark `binapi:"qos_mark,name=mark" json:"mark,omitempty"` +} + +func (m *QosMarkEnableDisable) Reset() { *m = QosMarkEnableDisable{} } +func (*QosMarkEnableDisable) GetMessageName() string { return "qos_mark_enable_disable" } +func (*QosMarkEnableDisable) GetCrcString() string { return "1a010f74" } +func (*QosMarkEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *QosMarkEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Enable + size += 4 // m.Mark.SwIfIndex + size += 4 // m.Mark.MapID + size += 1 // m.Mark.OutputSource + return size +} +func (m *QosMarkEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.Enable) + buf.EncodeUint32(m.Mark.SwIfIndex) + buf.EncodeUint32(m.Mark.MapID) + buf.EncodeUint8(uint8(m.Mark.OutputSource)) + return buf.Bytes(), nil +} +func (m *QosMarkEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Enable = buf.DecodeBool() + m.Mark.SwIfIndex = buf.DecodeUint32() + m.Mark.MapID = buf.DecodeUint32() + m.Mark.OutputSource = QosSource(buf.DecodeUint8()) + return nil +} + +// QosMarkEnableDisableReply defines message 'qos_mark_enable_disable_reply'. +type QosMarkEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *QosMarkEnableDisableReply) Reset() { *m = QosMarkEnableDisableReply{} } +func (*QosMarkEnableDisableReply) GetMessageName() string { return "qos_mark_enable_disable_reply" } +func (*QosMarkEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*QosMarkEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *QosMarkEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *QosMarkEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *QosMarkEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// * Details of QoS recording configs +// QosRecordDetails defines message 'qos_record_details'. +type QosRecordDetails struct { + Record QosRecord `binapi:"qos_record,name=record" json:"record,omitempty"` +} + +func (m *QosRecordDetails) Reset() { *m = QosRecordDetails{} } +func (*QosRecordDetails) GetMessageName() string { return "qos_record_details" } +func (*QosRecordDetails) GetCrcString() string { return "a425d4d3" } +func (*QosRecordDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *QosRecordDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Record.SwIfIndex + size += 1 // m.Record.InputSource + return size +} +func (m *QosRecordDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Record.SwIfIndex)) + buf.EncodeUint8(uint8(m.Record.InputSource)) + return buf.Bytes(), nil +} +func (m *QosRecordDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Record.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Record.InputSource = QosSource(buf.DecodeUint8()) + return nil +} + +// * Dump the QoS record configs +// QosRecordDump defines message 'qos_record_dump'. +type QosRecordDump struct{} + +func (m *QosRecordDump) Reset() { *m = QosRecordDump{} } +func (*QosRecordDump) GetMessageName() string { return "qos_record_dump" } +func (*QosRecordDump) GetCrcString() string { return "51077d14" } +func (*QosRecordDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *QosRecordDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *QosRecordDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *QosRecordDump) Unmarshal(b []byte) error { + return nil +} + +// * Enable/Disable QoS recording +// - The QoS bits from the packet at the specified input layer are copied +// - into the packet. Recording should be used in conjunction with marking +// - - enable - enable=1 or disable the feature +// - - record - Recording configuration +// +// QosRecordEnableDisable defines message 'qos_record_enable_disable'. +type QosRecordEnableDisable struct { + Enable bool `binapi:"bool,name=enable,default=true" json:"enable,omitempty"` + Record QosRecord `binapi:"qos_record,name=record" json:"record,omitempty"` +} + +func (m *QosRecordEnableDisable) Reset() { *m = QosRecordEnableDisable{} } +func (*QosRecordEnableDisable) GetMessageName() string { return "qos_record_enable_disable" } +func (*QosRecordEnableDisable) GetCrcString() string { return "2f1a4a38" } +func (*QosRecordEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *QosRecordEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Enable + size += 4 // m.Record.SwIfIndex + size += 1 // m.Record.InputSource + return size +} +func (m *QosRecordEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.Enable) + buf.EncodeUint32(uint32(m.Record.SwIfIndex)) + buf.EncodeUint8(uint8(m.Record.InputSource)) + return buf.Bytes(), nil +} +func (m *QosRecordEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Enable = buf.DecodeBool() + m.Record.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Record.InputSource = QosSource(buf.DecodeUint8()) + return nil +} + +// QosRecordEnableDisableReply defines message 'qos_record_enable_disable_reply'. +type QosRecordEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *QosRecordEnableDisableReply) Reset() { *m = QosRecordEnableDisableReply{} } +func (*QosRecordEnableDisableReply) GetMessageName() string { return "qos_record_enable_disable_reply" } +func (*QosRecordEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*QosRecordEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *QosRecordEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *QosRecordEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *QosRecordEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// * Details of QoS recording configs +// QosStoreDetails defines message 'qos_store_details'. +type QosStoreDetails struct { + Store QosStore `binapi:"qos_store,name=store" json:"store,omitempty"` +} + +func (m *QosStoreDetails) Reset() { *m = QosStoreDetails{} } +func (*QosStoreDetails) GetMessageName() string { return "qos_store_details" } +func (*QosStoreDetails) GetCrcString() string { return "3ee0aad7" } +func (*QosStoreDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *QosStoreDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Store.SwIfIndex + size += 1 // m.Store.InputSource + size += 1 // m.Store.Value + return size +} +func (m *QosStoreDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Store.SwIfIndex)) + buf.EncodeUint8(uint8(m.Store.InputSource)) + buf.EncodeUint8(m.Store.Value) + return buf.Bytes(), nil +} +func (m *QosStoreDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Store.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Store.InputSource = QosSource(buf.DecodeUint8()) + m.Store.Value = buf.DecodeUint8() + return nil +} + +// * Dump the QoS store configs +// QosStoreDump defines message 'qos_store_dump'. +type QosStoreDump struct{} + +func (m *QosStoreDump) Reset() { *m = QosStoreDump{} } +func (*QosStoreDump) GetMessageName() string { return "qos_store_dump" } +func (*QosStoreDump) GetCrcString() string { return "51077d14" } +func (*QosStoreDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *QosStoreDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *QosStoreDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *QosStoreDump) Unmarshal(b []byte) error { + return nil +} + +// * Enable/Disable QoS storing +// - The QoS bits from the packet at the specified input layer are copied +// - into the packet. Storing should be used in conjunction with marking +// - - enable - enable=1 or disable the feature +// - - store - Store configuration +// +// QosStoreEnableDisable defines message 'qos_store_enable_disable'. +type QosStoreEnableDisable struct { + Enable bool `binapi:"bool,name=enable,default=true" json:"enable,omitempty"` + Store QosStore `binapi:"qos_store,name=store" json:"store,omitempty"` +} + +func (m *QosStoreEnableDisable) Reset() { *m = QosStoreEnableDisable{} } +func (*QosStoreEnableDisable) GetMessageName() string { return "qos_store_enable_disable" } +func (*QosStoreEnableDisable) GetCrcString() string { return "f3abcc8b" } +func (*QosStoreEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *QosStoreEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Enable + size += 4 // m.Store.SwIfIndex + size += 1 // m.Store.InputSource + size += 1 // m.Store.Value + return size +} +func (m *QosStoreEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.Enable) + buf.EncodeUint32(uint32(m.Store.SwIfIndex)) + buf.EncodeUint8(uint8(m.Store.InputSource)) + buf.EncodeUint8(m.Store.Value) + return buf.Bytes(), nil +} +func (m *QosStoreEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Enable = buf.DecodeBool() + m.Store.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Store.InputSource = QosSource(buf.DecodeUint8()) + m.Store.Value = buf.DecodeUint8() + return nil +} + +// QosStoreEnableDisableReply defines message 'qos_store_enable_disable_reply'. +type QosStoreEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *QosStoreEnableDisableReply) Reset() { *m = QosStoreEnableDisableReply{} } +func (*QosStoreEnableDisableReply) GetMessageName() string { return "qos_store_enable_disable_reply" } +func (*QosStoreEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*QosStoreEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *QosStoreEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *QosStoreEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *QosStoreEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_qos_binapi_init() } +func file_qos_binapi_init() { + api.RegisterMessage((*QosEgressMapDelete)(nil), "qos_egress_map_delete_3a91bde5") + api.RegisterMessage((*QosEgressMapDeleteReply)(nil), "qos_egress_map_delete_reply_e8d4e804") + api.RegisterMessage((*QosEgressMapDetails)(nil), "qos_egress_map_details_46c5653c") + api.RegisterMessage((*QosEgressMapDump)(nil), "qos_egress_map_dump_51077d14") + api.RegisterMessage((*QosEgressMapUpdate)(nil), "qos_egress_map_update_6d1c065f") + api.RegisterMessage((*QosEgressMapUpdateReply)(nil), "qos_egress_map_update_reply_e8d4e804") + api.RegisterMessage((*QosMarkDetails)(nil), "qos_mark_details_89fe81a9") + api.RegisterMessage((*QosMarkDetailsReply)(nil), "qos_mark_details_reply_e8d4e804") + api.RegisterMessage((*QosMarkDump)(nil), "qos_mark_dump_f9e6675e") + api.RegisterMessage((*QosMarkEnableDisable)(nil), "qos_mark_enable_disable_1a010f74") + api.RegisterMessage((*QosMarkEnableDisableReply)(nil), "qos_mark_enable_disable_reply_e8d4e804") + api.RegisterMessage((*QosRecordDetails)(nil), "qos_record_details_a425d4d3") + api.RegisterMessage((*QosRecordDump)(nil), "qos_record_dump_51077d14") + api.RegisterMessage((*QosRecordEnableDisable)(nil), "qos_record_enable_disable_2f1a4a38") + api.RegisterMessage((*QosRecordEnableDisableReply)(nil), "qos_record_enable_disable_reply_e8d4e804") + api.RegisterMessage((*QosStoreDetails)(nil), "qos_store_details_3ee0aad7") + api.RegisterMessage((*QosStoreDump)(nil), "qos_store_dump_51077d14") + api.RegisterMessage((*QosStoreEnableDisable)(nil), "qos_store_enable_disable_f3abcc8b") + api.RegisterMessage((*QosStoreEnableDisableReply)(nil), "qos_store_enable_disable_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*QosEgressMapDelete)(nil), + (*QosEgressMapDeleteReply)(nil), + (*QosEgressMapDetails)(nil), + (*QosEgressMapDump)(nil), + (*QosEgressMapUpdate)(nil), + (*QosEgressMapUpdateReply)(nil), + (*QosMarkDetails)(nil), + (*QosMarkDetailsReply)(nil), + (*QosMarkDump)(nil), + (*QosMarkEnableDisable)(nil), + (*QosMarkEnableDisableReply)(nil), + (*QosRecordDetails)(nil), + (*QosRecordDump)(nil), + (*QosRecordEnableDisable)(nil), + (*QosRecordEnableDisableReply)(nil), + (*QosStoreDetails)(nil), + (*QosStoreDump)(nil), + (*QosStoreEnableDisable)(nil), + (*QosStoreEnableDisableReply)(nil), + } +} diff --git a/binapi/qos/qos_rpc.ba.go b/binapi/qos/qos_rpc.ba.go new file mode 100644 index 00000000..110261b1 --- /dev/null +++ b/binapi/qos/qos_rpc.ba.go @@ -0,0 +1,250 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package qos + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service qos. +type RPCService interface { + QosEgressMapDelete(ctx context.Context, in *QosEgressMapDelete) (*QosEgressMapDeleteReply, error) + QosEgressMapDump(ctx context.Context, in *QosEgressMapDump) (RPCService_QosEgressMapDumpClient, error) + QosEgressMapUpdate(ctx context.Context, in *QosEgressMapUpdate) (*QosEgressMapUpdateReply, error) + QosMarkDump(ctx context.Context, in *QosMarkDump) (RPCService_QosMarkDumpClient, error) + QosMarkEnableDisable(ctx context.Context, in *QosMarkEnableDisable) (*QosMarkEnableDisableReply, error) + QosRecordDump(ctx context.Context, in *QosRecordDump) (RPCService_QosRecordDumpClient, error) + QosRecordEnableDisable(ctx context.Context, in *QosRecordEnableDisable) (*QosRecordEnableDisableReply, error) + QosStoreDump(ctx context.Context, in *QosStoreDump) (RPCService_QosStoreDumpClient, error) + QosStoreEnableDisable(ctx context.Context, in *QosStoreEnableDisable) (*QosStoreEnableDisableReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) QosEgressMapDelete(ctx context.Context, in *QosEgressMapDelete) (*QosEgressMapDeleteReply, error) { + out := new(QosEgressMapDeleteReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) QosEgressMapDump(ctx context.Context, in *QosEgressMapDump) (RPCService_QosEgressMapDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_QosEgressMapDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_QosEgressMapDumpClient interface { + Recv() (*QosEgressMapDetails, error) + api.Stream +} + +type serviceClient_QosEgressMapDumpClient struct { + api.Stream +} + +func (c *serviceClient_QosEgressMapDumpClient) Recv() (*QosEgressMapDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *QosEgressMapDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) QosEgressMapUpdate(ctx context.Context, in *QosEgressMapUpdate) (*QosEgressMapUpdateReply, error) { + out := new(QosEgressMapUpdateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) QosMarkDump(ctx context.Context, in *QosMarkDump) (RPCService_QosMarkDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_QosMarkDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_QosMarkDumpClient interface { + Recv() (*QosMarkDetails, error) + api.Stream +} + +type serviceClient_QosMarkDumpClient struct { + api.Stream +} + +func (c *serviceClient_QosMarkDumpClient) Recv() (*QosMarkDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *QosMarkDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) QosMarkEnableDisable(ctx context.Context, in *QosMarkEnableDisable) (*QosMarkEnableDisableReply, error) { + out := new(QosMarkEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) QosRecordDump(ctx context.Context, in *QosRecordDump) (RPCService_QosRecordDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_QosRecordDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_QosRecordDumpClient interface { + Recv() (*QosRecordDetails, error) + api.Stream +} + +type serviceClient_QosRecordDumpClient struct { + api.Stream +} + +func (c *serviceClient_QosRecordDumpClient) Recv() (*QosRecordDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *QosRecordDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) QosRecordEnableDisable(ctx context.Context, in *QosRecordEnableDisable) (*QosRecordEnableDisableReply, error) { + out := new(QosRecordEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) QosStoreDump(ctx context.Context, in *QosStoreDump) (RPCService_QosStoreDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_QosStoreDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_QosStoreDumpClient interface { + Recv() (*QosStoreDetails, error) + api.Stream +} + +type serviceClient_QosStoreDumpClient struct { + api.Stream +} + +func (c *serviceClient_QosStoreDumpClient) Recv() (*QosStoreDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *QosStoreDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) QosStoreEnableDisable(ctx context.Context, in *QosStoreEnableDisable) (*QosStoreEnableDisableReply, error) { + out := new(QosStoreEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/rd_cp/rd_cp.ba.go b/binapi/rd_cp/rd_cp.ba.go new file mode 100644 index 00000000..fbfdab9e --- /dev/null +++ b/binapi/rd_cp/rd_cp.ba.go @@ -0,0 +1,127 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/rd_cp.api.json + +// Package rd_cp contains generated bindings for API file rd_cp.api. +// +// Contents: +// - 2 messages +package rd_cp + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "rd_cp" + APIVersion = "1.0.1" + VersionCrc = 0x871c3bee +) + +// Enable/disable IPv6 ND address autoconfiguration +// +// and setting up default routes +// - sw_if_index - interface to enable the autoconfigutation on +// - enable - 1 to enable address autoconfiguration, 0 to disable +// - install_default_routes - 1 to enable installing defaut routes, +// 0 to disable installing defaut routes, +// the value is ignored (and taken as 0) +// when enable param is set to 0 +// +// IP6NdAddressAutoconfig defines message 'ip6_nd_address_autoconfig'. +type IP6NdAddressAutoconfig struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Enable bool `binapi:"bool,name=enable" json:"enable,omitempty"` + InstallDefaultRoutes bool `binapi:"bool,name=install_default_routes" json:"install_default_routes,omitempty"` +} + +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 +} + +func (m *IP6NdAddressAutoconfig) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.Enable + size += 1 // m.InstallDefaultRoutes + return size +} +func (m *IP6NdAddressAutoconfig) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.Enable) + buf.EncodeBool(m.InstallDefaultRoutes) + return buf.Bytes(), nil +} +func (m *IP6NdAddressAutoconfig) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Enable = buf.DecodeBool() + m.InstallDefaultRoutes = buf.DecodeBool() + return nil +} + +// IP6NdAddressAutoconfigReply defines message 'ip6_nd_address_autoconfig_reply'. +type IP6NdAddressAutoconfigReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 (m *IP6NdAddressAutoconfigReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IP6NdAddressAutoconfigReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IP6NdAddressAutoconfigReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_rd_cp_binapi_init() } +func file_rd_cp_binapi_init() { + api.RegisterMessage((*IP6NdAddressAutoconfig)(nil), "ip6_nd_address_autoconfig_9e14a4a7") + api.RegisterMessage((*IP6NdAddressAutoconfigReply)(nil), "ip6_nd_address_autoconfig_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*IP6NdAddressAutoconfig)(nil), + (*IP6NdAddressAutoconfigReply)(nil), + } +} diff --git a/binapi/rd_cp/rd_cp_rpc.ba.go b/binapi/rd_cp/rd_cp_rpc.ba.go new file mode 100644 index 00000000..6ef9dbea --- /dev/null +++ b/binapi/rd_cp/rd_cp_rpc.ba.go @@ -0,0 +1,31 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package rd_cp + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service rd_cp. +type RPCService interface { + IP6NdAddressAutoconfig(ctx context.Context, in *IP6NdAddressAutoconfig) (*IP6NdAddressAutoconfigReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) IP6NdAddressAutoconfig(ctx context.Context, in *IP6NdAddressAutoconfig) (*IP6NdAddressAutoconfigReply, error) { + out := new(IP6NdAddressAutoconfigReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/rdma/rdma.ba.go b/binapi/rdma/rdma.ba.go new file mode 100644 index 00000000..ab8ad55a --- /dev/null +++ b/binapi/rdma/rdma.ba.go @@ -0,0 +1,562 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/rdma.api.json + +// Package rdma contains generated bindings for API file rdma.api. +// +// Contents: +// - 3 enums +// - 8 messages +package rdma + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "rdma" + APIVersion = "3.0.0" + VersionCrc = 0xdab70fa9 +) + +// RdmaMode defines 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", + } + 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 "RdmaMode(" + strconv.Itoa(int(x)) + ")" +} + +// RdmaRss4 defines enum 'rdma_rss4'. +type RdmaRss4 uint32 + +const ( + RDMA_API_RSS4_AUTO RdmaRss4 = 0 + RDMA_API_RSS4_IP RdmaRss4 = 1 + RDMA_API_RSS4_IP_UDP RdmaRss4 = 2 + RDMA_API_RSS4_IP_TCP RdmaRss4 = 3 +) + +var ( + RdmaRss4_name = map[uint32]string{ + 0: "RDMA_API_RSS4_AUTO", + 1: "RDMA_API_RSS4_IP", + 2: "RDMA_API_RSS4_IP_UDP", + 3: "RDMA_API_RSS4_IP_TCP", + } + RdmaRss4_value = map[string]uint32{ + "RDMA_API_RSS4_AUTO": 0, + "RDMA_API_RSS4_IP": 1, + "RDMA_API_RSS4_IP_UDP": 2, + "RDMA_API_RSS4_IP_TCP": 3, + } +) + +func (x RdmaRss4) String() string { + s, ok := RdmaRss4_name[uint32(x)] + if ok { + return s + } + return "RdmaRss4(" + strconv.Itoa(int(x)) + ")" +} + +// RdmaRss6 defines enum 'rdma_rss6'. +type RdmaRss6 uint32 + +const ( + RDMA_API_RSS6_AUTO RdmaRss6 = 0 + RDMA_API_RSS6_IP RdmaRss6 = 1 + RDMA_API_RSS6_IP_UDP RdmaRss6 = 2 + RDMA_API_RSS6_IP_TCP RdmaRss6 = 3 +) + +var ( + RdmaRss6_name = map[uint32]string{ + 0: "RDMA_API_RSS6_AUTO", + 1: "RDMA_API_RSS6_IP", + 2: "RDMA_API_RSS6_IP_UDP", + 3: "RDMA_API_RSS6_IP_TCP", + } + RdmaRss6_value = map[string]uint32{ + "RDMA_API_RSS6_AUTO": 0, + "RDMA_API_RSS6_IP": 1, + "RDMA_API_RSS6_IP_UDP": 2, + "RDMA_API_RSS6_IP_TCP": 3, + } +) + +func (x RdmaRss6) String() string { + s, ok := RdmaRss6_name[uint32(x)] + if ok { + return s + } + return "RdmaRss6(" + strconv.Itoa(int(x)) + ")" +} + +// - client_index - opaque cookie to identify the sender +// - host_if - Linux netdev interface name +// - name - new rdma interface name +// - rxq_num - number of receive queues (optional) +// - rxq_size - receive queue size (optional) +// - txq_size - transmit queue size (optional) +// - mode - operation mode (optional) +// +// RdmaCreate defines message 'rdma_create'. +// Deprecated: 21.01 +type RdmaCreate struct { + HostIf string `binapi:"string[64],name=host_if" json:"host_if,omitempty"` + Name string `binapi:"string[64],name=name" json:"name,omitempty"` + RxqNum uint16 `binapi:"u16,name=rxq_num,default=1" json:"rxq_num,omitempty"` + RxqSize uint16 `binapi:"u16,name=rxq_size,default=1024" json:"rxq_size,omitempty"` + TxqSize uint16 `binapi:"u16,name=txq_size,default=1024" json:"txq_size,omitempty"` + Mode RdmaMode `binapi:"rdma_mode,name=mode,default=0" json:"mode,omitempty"` +} + +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 +} + +func (m *RdmaCreate) Size() (size int) { + if m == nil { + return 0 + } + size += 64 // m.HostIf + size += 64 // m.Name + size += 2 // m.RxqNum + size += 2 // m.RxqSize + size += 2 // m.TxqSize + size += 4 // m.Mode + return size +} +func (m *RdmaCreate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.HostIf, 64) + buf.EncodeString(m.Name, 64) + buf.EncodeUint16(m.RxqNum) + buf.EncodeUint16(m.RxqSize) + buf.EncodeUint16(m.TxqSize) + buf.EncodeUint32(uint32(m.Mode)) + return buf.Bytes(), nil +} +func (m *RdmaCreate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.HostIf = buf.DecodeString(64) + m.Name = buf.DecodeString(64) + m.RxqNum = buf.DecodeUint16() + m.RxqSize = buf.DecodeUint16() + m.TxqSize = buf.DecodeUint16() + m.Mode = RdmaMode(buf.DecodeUint32()) + return nil +} + +// - context - sender context, to match reply w/ request +// - retval - return value for request +// - sw_if_index - software index for the new rdma interface +// +// RdmaCreateReply defines message 'rdma_create_reply'. +// Deprecated: the message will be removed in the future versions +type RdmaCreateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *RdmaCreateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *RdmaCreateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *RdmaCreateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// - client_index - opaque cookie to identify the sender +// - host_if - Linux netdev interface name +// - name - new rdma interface name +// - rxq_num - number of receive queues (optional) +// - rxq_size - receive queue size (optional) +// - txq_size - transmit queue size (optional) +// - mode - operation mode (optional) +// - no_multi_seg (optional) - disable chained buffer RX +// - max_pktlen (optional) - maximal RX packet size. +// +// RdmaCreateV2 defines message 'rdma_create_v2'. +// Deprecated: the message will be removed in the future versions +type RdmaCreateV2 struct { + HostIf string `binapi:"string[64],name=host_if" json:"host_if,omitempty"` + Name string `binapi:"string[64],name=name" json:"name,omitempty"` + RxqNum uint16 `binapi:"u16,name=rxq_num,default=1" json:"rxq_num,omitempty"` + RxqSize uint16 `binapi:"u16,name=rxq_size,default=1024" json:"rxq_size,omitempty"` + TxqSize uint16 `binapi:"u16,name=txq_size,default=1024" json:"txq_size,omitempty"` + Mode RdmaMode `binapi:"rdma_mode,name=mode,default=0" json:"mode,omitempty"` + NoMultiSeg bool `binapi:"bool,name=no_multi_seg,default=0" json:"no_multi_seg,omitempty"` + MaxPktlen uint16 `binapi:"u16,name=max_pktlen,default=0" json:"max_pktlen,omitempty"` +} + +func (m *RdmaCreateV2) Reset() { *m = RdmaCreateV2{} } +func (*RdmaCreateV2) GetMessageName() string { return "rdma_create_v2" } +func (*RdmaCreateV2) GetCrcString() string { return "5826a4f3" } +func (*RdmaCreateV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *RdmaCreateV2) Size() (size int) { + if m == nil { + return 0 + } + size += 64 // m.HostIf + size += 64 // m.Name + size += 2 // m.RxqNum + size += 2 // m.RxqSize + size += 2 // m.TxqSize + size += 4 // m.Mode + size += 1 // m.NoMultiSeg + size += 2 // m.MaxPktlen + return size +} +func (m *RdmaCreateV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.HostIf, 64) + buf.EncodeString(m.Name, 64) + buf.EncodeUint16(m.RxqNum) + buf.EncodeUint16(m.RxqSize) + buf.EncodeUint16(m.TxqSize) + buf.EncodeUint32(uint32(m.Mode)) + buf.EncodeBool(m.NoMultiSeg) + buf.EncodeUint16(m.MaxPktlen) + return buf.Bytes(), nil +} +func (m *RdmaCreateV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.HostIf = buf.DecodeString(64) + m.Name = buf.DecodeString(64) + m.RxqNum = buf.DecodeUint16() + m.RxqSize = buf.DecodeUint16() + m.TxqSize = buf.DecodeUint16() + m.Mode = RdmaMode(buf.DecodeUint32()) + m.NoMultiSeg = buf.DecodeBool() + m.MaxPktlen = buf.DecodeUint16() + return nil +} + +// - context - sender context, to match reply w/ request +// - retval - return value for request +// - sw_if_index - software index for the new rdma interface +// +// RdmaCreateV2Reply defines message 'rdma_create_v2_reply'. +// Deprecated: the message will be removed in the future versions +type RdmaCreateV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *RdmaCreateV2Reply) Reset() { *m = RdmaCreateV2Reply{} } +func (*RdmaCreateV2Reply) GetMessageName() string { return "rdma_create_v2_reply" } +func (*RdmaCreateV2Reply) GetCrcString() string { return "5383d31f" } +func (*RdmaCreateV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *RdmaCreateV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *RdmaCreateV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *RdmaCreateV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// - client_index - opaque cookie to identify the sender +// - host_if - Linux netdev interface name +// - name - new rdma interface name +// - rxq_num - number of receive queues (optional) +// - rxq_size - receive queue size (optional) +// - txq_size - transmit queue size (optional) +// - mode - operation mode (optional) +// - no_multi_seg (optional) - disable chained buffer RX +// - max_pktlen (optional) - maximal RX packet size. +// - rss4 (optional) - IPv4 RSS +// - rss6 (optional) - IPv6 RSS +// +// RdmaCreateV3 defines message 'rdma_create_v3'. +type RdmaCreateV3 struct { + HostIf string `binapi:"string[64],name=host_if" json:"host_if,omitempty"` + Name string `binapi:"string[64],name=name" json:"name,omitempty"` + RxqNum uint16 `binapi:"u16,name=rxq_num,default=1" json:"rxq_num,omitempty"` + RxqSize uint16 `binapi:"u16,name=rxq_size,default=1024" json:"rxq_size,omitempty"` + TxqSize uint16 `binapi:"u16,name=txq_size,default=1024" json:"txq_size,omitempty"` + Mode RdmaMode `binapi:"rdma_mode,name=mode,default=0" json:"mode,omitempty"` + NoMultiSeg bool `binapi:"bool,name=no_multi_seg,default=0" json:"no_multi_seg,omitempty"` + MaxPktlen uint16 `binapi:"u16,name=max_pktlen,default=0" json:"max_pktlen,omitempty"` + Rss4 RdmaRss4 `binapi:"rdma_rss4,name=rss4,default=0" json:"rss4,omitempty"` + Rss6 RdmaRss6 `binapi:"rdma_rss6,name=rss6,default=0" json:"rss6,omitempty"` +} + +func (m *RdmaCreateV3) Reset() { *m = RdmaCreateV3{} } +func (*RdmaCreateV3) GetMessageName() string { return "rdma_create_v3" } +func (*RdmaCreateV3) GetCrcString() string { return "c6287ea8" } +func (*RdmaCreateV3) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *RdmaCreateV3) Size() (size int) { + if m == nil { + return 0 + } + size += 64 // m.HostIf + size += 64 // m.Name + size += 2 // m.RxqNum + size += 2 // m.RxqSize + size += 2 // m.TxqSize + size += 4 // m.Mode + size += 1 // m.NoMultiSeg + size += 2 // m.MaxPktlen + size += 4 // m.Rss4 + size += 4 // m.Rss6 + return size +} +func (m *RdmaCreateV3) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeString(m.HostIf, 64) + buf.EncodeString(m.Name, 64) + buf.EncodeUint16(m.RxqNum) + buf.EncodeUint16(m.RxqSize) + buf.EncodeUint16(m.TxqSize) + buf.EncodeUint32(uint32(m.Mode)) + buf.EncodeBool(m.NoMultiSeg) + buf.EncodeUint16(m.MaxPktlen) + buf.EncodeUint32(uint32(m.Rss4)) + buf.EncodeUint32(uint32(m.Rss6)) + return buf.Bytes(), nil +} +func (m *RdmaCreateV3) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.HostIf = buf.DecodeString(64) + m.Name = buf.DecodeString(64) + m.RxqNum = buf.DecodeUint16() + m.RxqSize = buf.DecodeUint16() + m.TxqSize = buf.DecodeUint16() + m.Mode = RdmaMode(buf.DecodeUint32()) + m.NoMultiSeg = buf.DecodeBool() + m.MaxPktlen = buf.DecodeUint16() + m.Rss4 = RdmaRss4(buf.DecodeUint32()) + m.Rss6 = RdmaRss6(buf.DecodeUint32()) + return nil +} + +// - client_index - opaque cookie to identify the sender +// - sw_if_index - interface index +// +// RdmaCreateV3Reply defines message 'rdma_create_v3_reply'. +type RdmaCreateV3Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *RdmaCreateV3Reply) Reset() { *m = RdmaCreateV3Reply{} } +func (*RdmaCreateV3Reply) GetMessageName() string { return "rdma_create_v3_reply" } +func (*RdmaCreateV3Reply) GetCrcString() string { return "5383d31f" } +func (*RdmaCreateV3Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *RdmaCreateV3Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *RdmaCreateV3Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *RdmaCreateV3Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// - client_index - opaque cookie to identify the sender +// - sw_if_index - interface index +// +// RdmaDelete defines message 'rdma_delete'. +type RdmaDelete struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +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 +} + +func (m *RdmaDelete) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *RdmaDelete) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *RdmaDelete) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// RdmaDeleteReply defines message 'rdma_delete_reply'. +type RdmaDeleteReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 (m *RdmaDeleteReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *RdmaDeleteReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *RdmaDeleteReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_rdma_binapi_init() } +func file_rdma_binapi_init() { + api.RegisterMessage((*RdmaCreate)(nil), "rdma_create_076fe418") + api.RegisterMessage((*RdmaCreateReply)(nil), "rdma_create_reply_5383d31f") + api.RegisterMessage((*RdmaCreateV2)(nil), "rdma_create_v2_5826a4f3") + api.RegisterMessage((*RdmaCreateV2Reply)(nil), "rdma_create_v2_reply_5383d31f") + api.RegisterMessage((*RdmaCreateV3)(nil), "rdma_create_v3_c6287ea8") + api.RegisterMessage((*RdmaCreateV3Reply)(nil), "rdma_create_v3_reply_5383d31f") + api.RegisterMessage((*RdmaDelete)(nil), "rdma_delete_f9e6675e") + api.RegisterMessage((*RdmaDeleteReply)(nil), "rdma_delete_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*RdmaCreate)(nil), + (*RdmaCreateReply)(nil), + (*RdmaCreateV2)(nil), + (*RdmaCreateV2Reply)(nil), + (*RdmaCreateV3)(nil), + (*RdmaCreateV3Reply)(nil), + (*RdmaDelete)(nil), + (*RdmaDeleteReply)(nil), + } +} diff --git a/binapi/rdma/rdma_rpc.ba.go b/binapi/rdma/rdma_rpc.ba.go new file mode 100644 index 00000000..26f097c8 --- /dev/null +++ b/binapi/rdma/rdma_rpc.ba.go @@ -0,0 +1,61 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package rdma + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service rdma. +type RPCService interface { + RdmaCreate(ctx context.Context, in *RdmaCreate) (*RdmaCreateReply, error) + RdmaCreateV2(ctx context.Context, in *RdmaCreateV2) (*RdmaCreateV2Reply, error) + RdmaCreateV3(ctx context.Context, in *RdmaCreateV3) (*RdmaCreateV3Reply, error) + RdmaDelete(ctx context.Context, in *RdmaDelete) (*RdmaDeleteReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) RdmaCreate(ctx context.Context, in *RdmaCreate) (*RdmaCreateReply, error) { + out := new(RdmaCreateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) RdmaCreateV2(ctx context.Context, in *RdmaCreateV2) (*RdmaCreateV2Reply, error) { + out := new(RdmaCreateV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) RdmaCreateV3(ctx context.Context, in *RdmaCreateV3) (*RdmaCreateV3Reply, error) { + out := new(RdmaCreateV3Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) RdmaDelete(ctx context.Context, in *RdmaDelete) (*RdmaDeleteReply, error) { + out := new(RdmaDeleteReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/session/session.ba.go b/binapi/session/session.ba.go new file mode 100644 index 00000000..aeaecadf --- /dev/null +++ b/binapi/session/session.ba.go @@ -0,0 +1,1470 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/session.api.json + +// Package session contains generated bindings for API file session.api. +// +// Contents: +// - 2 enums +// - 26 messages +package session + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "session" + APIVersion = "4.0.0" + VersionCrc = 0x37cc4b71 +) + +// SessionRuleScope defines enum 'session_rule_scope'. +type SessionRuleScope uint32 + +const ( + SESSION_RULE_SCOPE_API_GLOBAL SessionRuleScope = 0 + SESSION_RULE_SCOPE_API_LOCAL SessionRuleScope = 1 + SESSION_RULE_SCOPE_API_BOTH SessionRuleScope = 2 +) + +var ( + SessionRuleScope_name = map[uint32]string{ + 0: "SESSION_RULE_SCOPE_API_GLOBAL", + 1: "SESSION_RULE_SCOPE_API_LOCAL", + 2: "SESSION_RULE_SCOPE_API_BOTH", + } + SessionRuleScope_value = map[string]uint32{ + "SESSION_RULE_SCOPE_API_GLOBAL": 0, + "SESSION_RULE_SCOPE_API_LOCAL": 1, + "SESSION_RULE_SCOPE_API_BOTH": 2, + } +) + +func (x SessionRuleScope) String() string { + s, ok := SessionRuleScope_name[uint32(x)] + if ok { + return s + } + return "SessionRuleScope(" + strconv.Itoa(int(x)) + ")" +} + +// TransportProto defines enum 'transport_proto'. +type TransportProto uint8 + +const ( + TRANSPORT_PROTO_API_TCP TransportProto = 0 + TRANSPORT_PROTO_API_UDP TransportProto = 1 + TRANSPORT_PROTO_API_NONE TransportProto = 2 + TRANSPORT_PROTO_API_TLS TransportProto = 3 + TRANSPORT_PROTO_API_QUIC TransportProto = 4 +) + +var ( + TransportProto_name = map[uint8]string{ + 0: "TRANSPORT_PROTO_API_TCP", + 1: "TRANSPORT_PROTO_API_UDP", + 2: "TRANSPORT_PROTO_API_NONE", + 3: "TRANSPORT_PROTO_API_TLS", + 4: "TRANSPORT_PROTO_API_QUIC", + } + TransportProto_value = map[string]uint8{ + "TRANSPORT_PROTO_API_TCP": 0, + "TRANSPORT_PROTO_API_UDP": 1, + "TRANSPORT_PROTO_API_NONE": 2, + "TRANSPORT_PROTO_API_TLS": 3, + "TRANSPORT_PROTO_API_QUIC": 4, + } +) + +func (x TransportProto) String() string { + s, ok := TransportProto_name[uint8(x)] + if ok { + return s + } + return "TransportProto(" + strconv.Itoa(int(x)) + ")" +} + +// Add certificate and key +// - engine - crypto engine +// - cert_len - cert length (comes first) +// - certkey_len - cert and key length +// - certkey - cert & key data (due to API limitation) +// +// AppAddCertKeyPair defines message 'app_add_cert_key_pair'. +type AppAddCertKeyPair struct { + CertLen uint16 `binapi:"u16,name=cert_len" json:"cert_len,omitempty"` + CertkeyLen uint16 `binapi:"u16,name=certkey_len" json:"-"` + Certkey []byte `binapi:"u8[certkey_len],name=certkey" json:"certkey,omitempty"` +} + +func (m *AppAddCertKeyPair) Reset() { *m = AppAddCertKeyPair{} } +func (*AppAddCertKeyPair) GetMessageName() string { return "app_add_cert_key_pair" } +func (*AppAddCertKeyPair) GetCrcString() string { return "02eb8016" } +func (*AppAddCertKeyPair) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *AppAddCertKeyPair) Size() (size int) { + if m == nil { + return 0 + } + size += 2 // m.CertLen + size += 2 // m.CertkeyLen + size += 1 * len(m.Certkey) // m.Certkey + return size +} +func (m *AppAddCertKeyPair) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint16(m.CertLen) + buf.EncodeUint16(uint16(len(m.Certkey))) + buf.EncodeBytes(m.Certkey, 0) + return buf.Bytes(), nil +} +func (m *AppAddCertKeyPair) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.CertLen = buf.DecodeUint16() + m.CertkeyLen = buf.DecodeUint16() + m.Certkey = make([]byte, m.CertkeyLen) + copy(m.Certkey, buf.DecodeBytes(len(m.Certkey))) + return nil +} + +// Add certificate and key +// - retval - return code for the request +// - index - index in certificate store +// +// AppAddCertKeyPairReply defines message 'app_add_cert_key_pair_reply'. +type AppAddCertKeyPairReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Index uint32 `binapi:"u32,name=index" json:"index,omitempty"` +} + +func (m *AppAddCertKeyPairReply) Reset() { *m = AppAddCertKeyPairReply{} } +func (*AppAddCertKeyPairReply) GetMessageName() string { return "app_add_cert_key_pair_reply" } +func (*AppAddCertKeyPairReply) GetCrcString() string { return "b42958d0" } +func (*AppAddCertKeyPairReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *AppAddCertKeyPairReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Index + return size +} +func (m *AppAddCertKeyPairReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.Index) + return buf.Bytes(), nil +} +func (m *AppAddCertKeyPairReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Index = buf.DecodeUint32() + return nil +} + +// Application attach to session layer +// - options - segment size, fifo sizes, etc. +// - namespace_id - string +// +// AppAttach defines message 'app_attach'. +type AppAttach struct { + Options []uint64 `binapi:"u64[18],name=options" json:"options,omitempty"` + NamespaceID string `binapi:"string[],name=namespace_id" json:"namespace_id,omitempty"` +} + +func (m *AppAttach) Reset() { *m = AppAttach{} } +func (*AppAttach) GetMessageName() string { return "app_attach" } +func (*AppAttach) GetCrcString() string { return "5f4a260d" } +func (*AppAttach) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *AppAttach) Size() (size int) { + if m == nil { + return 0 + } + size += 8 * 18 // m.Options + size += 4 + len(m.NamespaceID) // m.NamespaceID + return size +} +func (m *AppAttach) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + for i := 0; i < 18; i++ { + var x uint64 + if i < len(m.Options) { + x = uint64(m.Options[i]) + } + buf.EncodeUint64(x) + } + buf.EncodeString(m.NamespaceID, 0) + return buf.Bytes(), nil +} +func (m *AppAttach) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Options = make([]uint64, 18) + for i := 0; i < len(m.Options); i++ { + m.Options[i] = buf.DecodeUint64() + } + m.NamespaceID = buf.DecodeString(0) + return nil +} + +// Application attach reply +// - retval - return code for the request +// - app_mq - app message queue +// - vpp_ctrl_mq - vpp message queue for control events that should +// be handled in main thread, i.e., bind/connect +// - vpp_ctrl_mq_thread_index - thread index of the ctrl mq +// - app_index - index of the newly created app +// - n_fds - number of fds exchanged +// - fd_flags - set of flags that indicate which fds are to be expected +// over the socket (set only if socket transport available) +// - segment_size - size of first shm segment +// - segment_handle - handle for segment +// - segment_name - name of segment client needs to attach to +// +// AppAttachReply defines message 'app_attach_reply'. +type AppAttachReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + AppMq uint64 `binapi:"u64,name=app_mq" json:"app_mq,omitempty"` + VppCtrlMq uint64 `binapi:"u64,name=vpp_ctrl_mq" json:"vpp_ctrl_mq,omitempty"` + VppCtrlMqThread uint8 `binapi:"u8,name=vpp_ctrl_mq_thread" json:"vpp_ctrl_mq_thread,omitempty"` + AppIndex uint32 `binapi:"u32,name=app_index" json:"app_index,omitempty"` + NFds uint8 `binapi:"u8,name=n_fds" json:"n_fds,omitempty"` + FdFlags uint8 `binapi:"u8,name=fd_flags" json:"fd_flags,omitempty"` + SegmentSize uint32 `binapi:"u32,name=segment_size" json:"segment_size,omitempty"` + SegmentHandle uint64 `binapi:"u64,name=segment_handle" json:"segment_handle,omitempty"` + SegmentName string `binapi:"string[],name=segment_name" json:"segment_name,omitempty"` +} + +func (m *AppAttachReply) Reset() { *m = AppAttachReply{} } +func (*AppAttachReply) GetMessageName() string { return "app_attach_reply" } +func (*AppAttachReply) GetCrcString() string { return "5c89c3b0" } +func (*AppAttachReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *AppAttachReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 8 // m.AppMq + size += 8 // m.VppCtrlMq + size += 1 // m.VppCtrlMqThread + size += 4 // m.AppIndex + size += 1 // m.NFds + size += 1 // m.FdFlags + size += 4 // m.SegmentSize + size += 8 // m.SegmentHandle + size += 4 + len(m.SegmentName) // m.SegmentName + return size +} +func (m *AppAttachReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint64(m.AppMq) + buf.EncodeUint64(m.VppCtrlMq) + buf.EncodeUint8(m.VppCtrlMqThread) + buf.EncodeUint32(m.AppIndex) + buf.EncodeUint8(m.NFds) + buf.EncodeUint8(m.FdFlags) + buf.EncodeUint32(m.SegmentSize) + buf.EncodeUint64(m.SegmentHandle) + buf.EncodeString(m.SegmentName, 0) + return buf.Bytes(), nil +} +func (m *AppAttachReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.AppMq = buf.DecodeUint64() + m.VppCtrlMq = buf.DecodeUint64() + m.VppCtrlMqThread = buf.DecodeUint8() + m.AppIndex = buf.DecodeUint32() + m.NFds = buf.DecodeUint8() + m.FdFlags = buf.DecodeUint8() + m.SegmentSize = buf.DecodeUint32() + m.SegmentHandle = buf.DecodeUint64() + m.SegmentName = buf.DecodeString(0) + return nil +} + +// Delete certificate and key +// - index - index in certificate store +// +// AppDelCertKeyPair defines message 'app_del_cert_key_pair'. +type AppDelCertKeyPair struct { + Index uint32 `binapi:"u32,name=index" json:"index,omitempty"` +} + +func (m *AppDelCertKeyPair) Reset() { *m = AppDelCertKeyPair{} } +func (*AppDelCertKeyPair) GetMessageName() string { return "app_del_cert_key_pair" } +func (*AppDelCertKeyPair) GetCrcString() string { return "8ac76db6" } +func (*AppDelCertKeyPair) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *AppDelCertKeyPair) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Index + return size +} +func (m *AppDelCertKeyPair) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Index) + return buf.Bytes(), nil +} +func (m *AppDelCertKeyPair) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Index = buf.DecodeUint32() + return nil +} + +// AppDelCertKeyPairReply defines message 'app_del_cert_key_pair_reply'. +type AppDelCertKeyPairReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *AppDelCertKeyPairReply) Reset() { *m = AppDelCertKeyPairReply{} } +func (*AppDelCertKeyPairReply) GetMessageName() string { return "app_del_cert_key_pair_reply" } +func (*AppDelCertKeyPairReply) GetCrcString() string { return "e8d4e804" } +func (*AppDelCertKeyPairReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *AppDelCertKeyPairReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *AppDelCertKeyPairReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *AppDelCertKeyPairReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// add/del application namespace +// +// client to vpp direction only +// - secret - secret shared between app and vpp +// - sw_if_index - local interface that "supports" namespace. Set to +// ~0 if no preference +// - ip4_fib_id - id of ip4 fib that "supports" the namespace. Ignored +// if sw_if_index set. +// - ip6_fib_id - id of ip6 fib that "supports" the namespace. Ignored +// if sw_if_index set. +// - namespace_id - namespace id +// +// AppNamespaceAddDel defines message 'app_namespace_add_del'. +// Deprecated: the message will be removed in the future versions +type AppNamespaceAddDel struct { + Secret uint64 `binapi:"u64,name=secret" json:"secret,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` + IP4FibID uint32 `binapi:"u32,name=ip4_fib_id" json:"ip4_fib_id,omitempty"` + IP6FibID uint32 `binapi:"u32,name=ip6_fib_id" json:"ip6_fib_id,omitempty"` + NamespaceID string `binapi:"string[],name=namespace_id" json:"namespace_id,omitempty"` +} + +func (m *AppNamespaceAddDel) Reset() { *m = AppNamespaceAddDel{} } +func (*AppNamespaceAddDel) GetMessageName() string { return "app_namespace_add_del" } +func (*AppNamespaceAddDel) GetCrcString() string { return "6306aecb" } +func (*AppNamespaceAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *AppNamespaceAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 8 // m.Secret + size += 4 // m.SwIfIndex + size += 4 // m.IP4FibID + size += 4 // m.IP6FibID + size += 4 + len(m.NamespaceID) // m.NamespaceID + return size +} +func (m *AppNamespaceAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint64(m.Secret) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.IP4FibID) + buf.EncodeUint32(m.IP6FibID) + buf.EncodeString(m.NamespaceID, 0) + return buf.Bytes(), nil +} +func (m *AppNamespaceAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Secret = buf.DecodeUint64() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IP4FibID = buf.DecodeUint32() + m.IP6FibID = buf.DecodeUint32() + m.NamespaceID = buf.DecodeString(0) + return nil +} + +// Reply for app namespace add/del +// - retval - return code +// - appns_index - app namespace index +// +// AppNamespaceAddDelReply defines message 'app_namespace_add_del_reply'. +// Deprecated: the message will be removed in the future versions +type AppNamespaceAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + AppnsIndex uint32 `binapi:"u32,name=appns_index" json:"appns_index,omitempty"` +} + +func (m *AppNamespaceAddDelReply) Reset() { *m = AppNamespaceAddDelReply{} } +func (*AppNamespaceAddDelReply) GetMessageName() string { return "app_namespace_add_del_reply" } +func (*AppNamespaceAddDelReply) GetCrcString() string { return "85137120" } +func (*AppNamespaceAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *AppNamespaceAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.AppnsIndex + return size +} +func (m *AppNamespaceAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.AppnsIndex) + return buf.Bytes(), nil +} +func (m *AppNamespaceAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.AppnsIndex = buf.DecodeUint32() + return nil +} + +// add/del application namespace +// +// client to vpp direction only +// - secret - secret shared between app and vpp +// - sw_if_index - local interface that "supports" namespace. Set to +// ~0 if no preference +// - ip4_fib_id - id of ip4 fib that "supports" the namespace. Ignored +// if sw_if_index set. +// - ip6_fib_id - id of ip6 fib that "supports" the namespace. Ignored +// if sw_if_index set. +// - namespace_id - namespace id +// - netns - linux net namespace +// +// AppNamespaceAddDelV2 defines message 'app_namespace_add_del_v2'. +// Deprecated: the message will be removed in the future versions +type AppNamespaceAddDelV2 struct { + Secret uint64 `binapi:"u64,name=secret" json:"secret,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` + IP4FibID uint32 `binapi:"u32,name=ip4_fib_id" json:"ip4_fib_id,omitempty"` + IP6FibID uint32 `binapi:"u32,name=ip6_fib_id" json:"ip6_fib_id,omitempty"` + NamespaceID string `binapi:"string[64],name=namespace_id" json:"namespace_id,omitempty"` + Netns string `binapi:"string[64],name=netns" json:"netns,omitempty"` +} + +func (m *AppNamespaceAddDelV2) Reset() { *m = AppNamespaceAddDelV2{} } +func (*AppNamespaceAddDelV2) GetMessageName() string { return "app_namespace_add_del_v2" } +func (*AppNamespaceAddDelV2) GetCrcString() string { return "ee0755cf" } +func (*AppNamespaceAddDelV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *AppNamespaceAddDelV2) Size() (size int) { + if m == nil { + return 0 + } + size += 8 // m.Secret + size += 4 // m.SwIfIndex + size += 4 // m.IP4FibID + size += 4 // m.IP6FibID + size += 64 // m.NamespaceID + size += 64 // m.Netns + return size +} +func (m *AppNamespaceAddDelV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint64(m.Secret) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.IP4FibID) + buf.EncodeUint32(m.IP6FibID) + buf.EncodeString(m.NamespaceID, 64) + buf.EncodeString(m.Netns, 64) + return buf.Bytes(), nil +} +func (m *AppNamespaceAddDelV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Secret = buf.DecodeUint64() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IP4FibID = buf.DecodeUint32() + m.IP6FibID = buf.DecodeUint32() + m.NamespaceID = buf.DecodeString(64) + m.Netns = buf.DecodeString(64) + return nil +} + +// Reply for app namespace add/del +// - retval - return code +// - appns_index - app namespace index +// +// AppNamespaceAddDelV2Reply defines message 'app_namespace_add_del_v2_reply'. +// Deprecated: the message will be removed in the future versions +type AppNamespaceAddDelV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + AppnsIndex uint32 `binapi:"u32,name=appns_index" json:"appns_index,omitempty"` +} + +func (m *AppNamespaceAddDelV2Reply) Reset() { *m = AppNamespaceAddDelV2Reply{} } +func (*AppNamespaceAddDelV2Reply) GetMessageName() string { return "app_namespace_add_del_v2_reply" } +func (*AppNamespaceAddDelV2Reply) GetCrcString() string { return "85137120" } +func (*AppNamespaceAddDelV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *AppNamespaceAddDelV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.AppnsIndex + return size +} +func (m *AppNamespaceAddDelV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.AppnsIndex) + return buf.Bytes(), nil +} +func (m *AppNamespaceAddDelV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.AppnsIndex = buf.DecodeUint32() + return nil +} + +// add/del application namespace +// +// client to vpp direction only +// - secret - secret shared between app and vpp +// - sw_if_index - local interface that "supports" namespace. Set to +// ~0 if no preference +// - ip4_fib_id - id of ip4 fib that "supports" the namespace. Ignored +// if sw_if_index set. +// - ip6_fib_id - id of ip6 fib that "supports" the namespace. Ignored +// if sw_if_index set. +// - namespace_id - namespace id +// - netns - linux net namespace +// - sock_name - socket name (path, abstract socket name) +// +// AppNamespaceAddDelV3 defines message 'app_namespace_add_del_v3'. +// Deprecated: the message will be removed in the future versions +type AppNamespaceAddDelV3 struct { + Secret uint64 `binapi:"u64,name=secret" json:"secret,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` + IP4FibID uint32 `binapi:"u32,name=ip4_fib_id" json:"ip4_fib_id,omitempty"` + IP6FibID uint32 `binapi:"u32,name=ip6_fib_id" json:"ip6_fib_id,omitempty"` + NamespaceID string `binapi:"string[64],name=namespace_id" json:"namespace_id,omitempty"` + Netns string `binapi:"string[64],name=netns" json:"netns,omitempty"` + SockName string `binapi:"string[],name=sock_name" json:"sock_name,omitempty"` +} + +func (m *AppNamespaceAddDelV3) Reset() { *m = AppNamespaceAddDelV3{} } +func (*AppNamespaceAddDelV3) GetMessageName() string { return "app_namespace_add_del_v3" } +func (*AppNamespaceAddDelV3) GetCrcString() string { return "8a7e40a1" } +func (*AppNamespaceAddDelV3) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *AppNamespaceAddDelV3) Size() (size int) { + if m == nil { + return 0 + } + size += 8 // m.Secret + size += 1 // m.IsAdd + size += 4 // m.SwIfIndex + size += 4 // m.IP4FibID + size += 4 // m.IP6FibID + size += 64 // m.NamespaceID + size += 64 // m.Netns + size += 4 + len(m.SockName) // m.SockName + return size +} +func (m *AppNamespaceAddDelV3) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint64(m.Secret) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.IP4FibID) + buf.EncodeUint32(m.IP6FibID) + buf.EncodeString(m.NamespaceID, 64) + buf.EncodeString(m.Netns, 64) + buf.EncodeString(m.SockName, 0) + return buf.Bytes(), nil +} +func (m *AppNamespaceAddDelV3) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Secret = buf.DecodeUint64() + m.IsAdd = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IP4FibID = buf.DecodeUint32() + m.IP6FibID = buf.DecodeUint32() + m.NamespaceID = buf.DecodeString(64) + m.Netns = buf.DecodeString(64) + m.SockName = buf.DecodeString(0) + return nil +} + +// AppNamespaceAddDelV3Reply defines message 'app_namespace_add_del_v3_reply'. +// Deprecated: the message will be removed in the future versions +type AppNamespaceAddDelV3Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + AppnsIndex uint32 `binapi:"u32,name=appns_index" json:"appns_index,omitempty"` +} + +func (m *AppNamespaceAddDelV3Reply) Reset() { *m = AppNamespaceAddDelV3Reply{} } +func (*AppNamespaceAddDelV3Reply) GetMessageName() string { return "app_namespace_add_del_v3_reply" } +func (*AppNamespaceAddDelV3Reply) GetCrcString() string { return "85137120" } +func (*AppNamespaceAddDelV3Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *AppNamespaceAddDelV3Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.AppnsIndex + return size +} +func (m *AppNamespaceAddDelV3Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.AppnsIndex) + return buf.Bytes(), nil +} +func (m *AppNamespaceAddDelV3Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.AppnsIndex = buf.DecodeUint32() + return nil +} + +// add/del application namespace +// +// client to vpp direction only +// - secret - secret shared between app and vpp +// - sw_if_index - local interface that "supports" namespace. Set to +// ~0 if no preference +// - ip4_fib_id - id of ip4 fib that "supports" the namespace. Ignored +// if sw_if_index set. +// - ip6_fib_id - id of ip6 fib that "supports" the namespace. Ignored +// if sw_if_index set. +// - namespace_id - namespace id +// - sock_name - socket name (path, abstract socket name) +// +// AppNamespaceAddDelV4 defines message 'app_namespace_add_del_v4'. +// Deprecated: the message will be removed in the future versions +type AppNamespaceAddDelV4 struct { + Secret uint64 `binapi:"u64,name=secret" json:"secret,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` + IP4FibID uint32 `binapi:"u32,name=ip4_fib_id" json:"ip4_fib_id,omitempty"` + IP6FibID uint32 `binapi:"u32,name=ip6_fib_id" json:"ip6_fib_id,omitempty"` + NamespaceID string `binapi:"string[64],name=namespace_id" json:"namespace_id,omitempty"` + SockName string `binapi:"string[],name=sock_name" json:"sock_name,omitempty"` +} + +func (m *AppNamespaceAddDelV4) Reset() { *m = AppNamespaceAddDelV4{} } +func (*AppNamespaceAddDelV4) GetMessageName() string { return "app_namespace_add_del_v4" } +func (*AppNamespaceAddDelV4) GetCrcString() string { return "42c1d824" } +func (*AppNamespaceAddDelV4) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *AppNamespaceAddDelV4) Size() (size int) { + if m == nil { + return 0 + } + size += 8 // m.Secret + size += 1 // m.IsAdd + size += 4 // m.SwIfIndex + size += 4 // m.IP4FibID + size += 4 // m.IP6FibID + size += 64 // m.NamespaceID + size += 4 + len(m.SockName) // m.SockName + return size +} +func (m *AppNamespaceAddDelV4) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint64(m.Secret) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.IP4FibID) + buf.EncodeUint32(m.IP6FibID) + buf.EncodeString(m.NamespaceID, 64) + buf.EncodeString(m.SockName, 0) + return buf.Bytes(), nil +} +func (m *AppNamespaceAddDelV4) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Secret = buf.DecodeUint64() + m.IsAdd = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IP4FibID = buf.DecodeUint32() + m.IP6FibID = buf.DecodeUint32() + m.NamespaceID = buf.DecodeString(64) + m.SockName = buf.DecodeString(0) + return nil +} + +// Reply for app namespace add/del +// - retval - return code +// - appns_index - app namespace index +// +// AppNamespaceAddDelV4Reply defines message 'app_namespace_add_del_v4_reply'. +type AppNamespaceAddDelV4Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + AppnsIndex uint32 `binapi:"u32,name=appns_index" json:"appns_index,omitempty"` +} + +func (m *AppNamespaceAddDelV4Reply) Reset() { *m = AppNamespaceAddDelV4Reply{} } +func (*AppNamespaceAddDelV4Reply) GetMessageName() string { return "app_namespace_add_del_v4_reply" } +func (*AppNamespaceAddDelV4Reply) GetCrcString() string { return "85137120" } +func (*AppNamespaceAddDelV4Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *AppNamespaceAddDelV4Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.AppnsIndex + return size +} +func (m *AppNamespaceAddDelV4Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.AppnsIndex) + return buf.Bytes(), nil +} +func (m *AppNamespaceAddDelV4Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.AppnsIndex = buf.DecodeUint32() + return nil +} + +// add/del application worker +// +// client to vpp direction only +// - app_index - application index +// - wrk_index - worker index, if a delete +// - is_add - set if an add +// +// AppWorkerAddDel defines message 'app_worker_add_del'. +type AppWorkerAddDel struct { + AppIndex uint32 `binapi:"u32,name=app_index" json:"app_index,omitempty"` + WrkIndex uint32 `binapi:"u32,name=wrk_index" json:"wrk_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` +} + +func (m *AppWorkerAddDel) Reset() { *m = AppWorkerAddDel{} } +func (*AppWorkerAddDel) GetMessageName() string { return "app_worker_add_del" } +func (*AppWorkerAddDel) GetCrcString() string { return "753253dc" } +func (*AppWorkerAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *AppWorkerAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.AppIndex + size += 4 // m.WrkIndex + size += 1 // m.IsAdd + return size +} +func (m *AppWorkerAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.AppIndex) + buf.EncodeUint32(m.WrkIndex) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *AppWorkerAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.AppIndex = buf.DecodeUint32() + m.WrkIndex = buf.DecodeUint32() + m.IsAdd = buf.DecodeBool() + return nil +} + +// Reply for app worker add/del +// - retval - return code +// - wrk_index - worker index, if add +// - app_event_queue_address - vpp event queue address of new worker +// - n_fds - number of fds exchanged +// - fd_flags - set of flags that indicate which fds are to be expected +// over the socket (set only if socket transport available) +// - segment_handle - handle for segment +// - is_add - add if non zero, else delete +// - segment_name - name of segment client needs to attach to +// +// AppWorkerAddDelReply defines message 'app_worker_add_del_reply'. +type AppWorkerAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + WrkIndex uint32 `binapi:"u32,name=wrk_index" json:"wrk_index,omitempty"` + AppEventQueueAddress uint64 `binapi:"u64,name=app_event_queue_address" json:"app_event_queue_address,omitempty"` + NFds uint8 `binapi:"u8,name=n_fds" json:"n_fds,omitempty"` + FdFlags uint8 `binapi:"u8,name=fd_flags" json:"fd_flags,omitempty"` + SegmentHandle uint64 `binapi:"u64,name=segment_handle" json:"segment_handle,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + SegmentName string `binapi:"string[],name=segment_name" json:"segment_name,omitempty"` +} + +func (m *AppWorkerAddDelReply) Reset() { *m = AppWorkerAddDelReply{} } +func (*AppWorkerAddDelReply) GetMessageName() string { return "app_worker_add_del_reply" } +func (*AppWorkerAddDelReply) GetCrcString() string { return "5735ffe7" } +func (*AppWorkerAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *AppWorkerAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.WrkIndex + size += 8 // m.AppEventQueueAddress + size += 1 // m.NFds + size += 1 // m.FdFlags + size += 8 // m.SegmentHandle + size += 1 // m.IsAdd + size += 4 + len(m.SegmentName) // m.SegmentName + return size +} +func (m *AppWorkerAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.WrkIndex) + buf.EncodeUint64(m.AppEventQueueAddress) + buf.EncodeUint8(m.NFds) + buf.EncodeUint8(m.FdFlags) + buf.EncodeUint64(m.SegmentHandle) + buf.EncodeBool(m.IsAdd) + buf.EncodeString(m.SegmentName, 0) + return buf.Bytes(), nil +} +func (m *AppWorkerAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.WrkIndex = buf.DecodeUint32() + m.AppEventQueueAddress = buf.DecodeUint64() + m.NFds = buf.DecodeUint8() + m.FdFlags = buf.DecodeUint8() + m.SegmentHandle = buf.DecodeUint64() + m.IsAdd = buf.DecodeBool() + m.SegmentName = buf.DecodeString(0) + return nil +} + +// Application detach from session layer +// ApplicationDetach defines message 'application_detach'. +type ApplicationDetach struct{} + +func (m *ApplicationDetach) Reset() { *m = ApplicationDetach{} } +func (*ApplicationDetach) GetMessageName() string { return "application_detach" } +func (*ApplicationDetach) GetCrcString() string { return "51077d14" } +func (*ApplicationDetach) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ApplicationDetach) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ApplicationDetach) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ApplicationDetach) Unmarshal(b []byte) error { + return nil +} + +// ApplicationDetachReply defines message 'application_detach_reply'. +type ApplicationDetachReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *ApplicationDetachReply) Reset() { *m = ApplicationDetachReply{} } +func (*ApplicationDetachReply) GetMessageName() string { return "application_detach_reply" } +func (*ApplicationDetachReply) GetCrcString() string { return "e8d4e804" } +func (*ApplicationDetachReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ApplicationDetachReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *ApplicationDetachReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *ApplicationDetachReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// enable/disable session layer +// +// client to vpp direction only +// - is_enable - disable session layer if 0, enable otherwise +// +// SessionEnableDisable defines message 'session_enable_disable'. +type SessionEnableDisable struct { + IsEnable bool `binapi:"bool,name=is_enable,default=true" json:"is_enable,omitempty"` +} + +func (m *SessionEnableDisable) Reset() { *m = SessionEnableDisable{} } +func (*SessionEnableDisable) GetMessageName() string { return "session_enable_disable" } +func (*SessionEnableDisable) GetCrcString() string { return "c264d7bf" } +func (*SessionEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SessionEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsEnable + return size +} +func (m *SessionEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *SessionEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsEnable = buf.DecodeBool() + return nil +} + +// SessionEnableDisableReply defines message 'session_enable_disable_reply'. +type SessionEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SessionEnableDisableReply) Reset() { *m = SessionEnableDisableReply{} } +func (*SessionEnableDisableReply) GetMessageName() string { return "session_enable_disable_reply" } +func (*SessionEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*SessionEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SessionEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SessionEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SessionEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// add/del session rule +// +// client to vpp direction only +// - transport_proto - transport protocol +// - is_ip4 - flag to indicate if ip addresses are ip4 or 6 +// - lcl_ip - local ip +// - lcl_plen - local prefix length +// - rmt_ip - remote ip +// - rmt_ple - remote prefix length +// - lcl_port - local port +// - rmt_port - remote port +// - action_index - the only action defined now is forward to +// application with index action_index +// - is_add - flag to indicate if add or del +// - appns_index - application namespace where rule is to be applied to +// - scope - enum that indicates scope of the rule: global or local. +// If 0, default is global, 1 is global 2 is local, 3 is both +// - tag - tag +// +// SessionRuleAddDel defines message 'session_rule_add_del'. +type SessionRuleAddDel struct { + TransportProto TransportProto `binapi:"transport_proto,name=transport_proto" json:"transport_proto,omitempty"` + Lcl ip_types.Prefix `binapi:"prefix,name=lcl" json:"lcl,omitempty"` + Rmt ip_types.Prefix `binapi:"prefix,name=rmt" json:"rmt,omitempty"` + LclPort uint16 `binapi:"u16,name=lcl_port" json:"lcl_port,omitempty"` + RmtPort uint16 `binapi:"u16,name=rmt_port" json:"rmt_port,omitempty"` + ActionIndex uint32 `binapi:"u32,name=action_index" json:"action_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + AppnsIndex uint32 `binapi:"u32,name=appns_index" json:"appns_index,omitempty"` + Scope SessionRuleScope `binapi:"session_rule_scope,name=scope" json:"scope,omitempty"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty"` +} + +func (m *SessionRuleAddDel) Reset() { *m = SessionRuleAddDel{} } +func (*SessionRuleAddDel) GetMessageName() string { return "session_rule_add_del" } +func (*SessionRuleAddDel) GetCrcString() string { return "82a90af5" } +func (*SessionRuleAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SessionRuleAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.TransportProto + size += 1 // m.Lcl.Address.Af + size += 1 * 16 // m.Lcl.Address.Un + size += 1 // m.Lcl.Len + size += 1 // m.Rmt.Address.Af + size += 1 * 16 // m.Rmt.Address.Un + size += 1 // m.Rmt.Len + size += 2 // m.LclPort + size += 2 // m.RmtPort + size += 4 // m.ActionIndex + size += 1 // m.IsAdd + size += 4 // m.AppnsIndex + size += 4 // m.Scope + size += 64 // m.Tag + return size +} +func (m *SessionRuleAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.TransportProto)) + buf.EncodeUint8(uint8(m.Lcl.Address.Af)) + buf.EncodeBytes(m.Lcl.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Lcl.Len) + buf.EncodeUint8(uint8(m.Rmt.Address.Af)) + buf.EncodeBytes(m.Rmt.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Rmt.Len) + buf.EncodeUint16(m.LclPort) + buf.EncodeUint16(m.RmtPort) + buf.EncodeUint32(m.ActionIndex) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.AppnsIndex) + buf.EncodeUint32(uint32(m.Scope)) + buf.EncodeString(m.Tag, 64) + return buf.Bytes(), nil +} +func (m *SessionRuleAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TransportProto = TransportProto(buf.DecodeUint8()) + m.Lcl.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Lcl.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Lcl.Len = buf.DecodeUint8() + m.Rmt.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Rmt.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Rmt.Len = buf.DecodeUint8() + m.LclPort = buf.DecodeUint16() + m.RmtPort = buf.DecodeUint16() + m.ActionIndex = buf.DecodeUint32() + m.IsAdd = buf.DecodeBool() + m.AppnsIndex = buf.DecodeUint32() + m.Scope = SessionRuleScope(buf.DecodeUint32()) + m.Tag = buf.DecodeString(64) + return nil +} + +// SessionRuleAddDelReply defines message 'session_rule_add_del_reply'. +type SessionRuleAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SessionRuleAddDelReply) Reset() { *m = SessionRuleAddDelReply{} } +func (*SessionRuleAddDelReply) GetMessageName() string { return "session_rule_add_del_reply" } +func (*SessionRuleAddDelReply) GetCrcString() string { return "e8d4e804" } +func (*SessionRuleAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SessionRuleAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SessionRuleAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SessionRuleAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Session rules details +// - transport_proto - transport protocol +// - is_ip4 - flag to indicate if ip addresses are ip4 or 6 +// - lcl_ip - local ip +// - lcl_plen - local prefix length +// - rmt_ip - remote ip +// - rmt_ple - remote prefix length +// - lcl_port - local port +// - rmt_port - remote port +// - action_index - the only action defined now is forward to +// application with index action_index +// - appns_index - application namespace where rule is to be applied to +// - scope - enum that indicates scope of the rule: global or local. +// If 0, default is global, 1 is global 2 is local, 3 is both +// - tag - tag +// +// SessionRulesDetails defines message 'session_rules_details'. +type SessionRulesDetails struct { + TransportProto TransportProto `binapi:"transport_proto,name=transport_proto" json:"transport_proto,omitempty"` + Lcl ip_types.Prefix `binapi:"prefix,name=lcl" json:"lcl,omitempty"` + Rmt ip_types.Prefix `binapi:"prefix,name=rmt" json:"rmt,omitempty"` + LclPort uint16 `binapi:"u16,name=lcl_port" json:"lcl_port,omitempty"` + RmtPort uint16 `binapi:"u16,name=rmt_port" json:"rmt_port,omitempty"` + ActionIndex uint32 `binapi:"u32,name=action_index" json:"action_index,omitempty"` + AppnsIndex uint32 `binapi:"u32,name=appns_index" json:"appns_index,omitempty"` + Scope SessionRuleScope `binapi:"session_rule_scope,name=scope" json:"scope,omitempty"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty"` +} + +func (m *SessionRulesDetails) Reset() { *m = SessionRulesDetails{} } +func (*SessionRulesDetails) GetMessageName() string { return "session_rules_details" } +func (*SessionRulesDetails) GetCrcString() string { return "4ef746e7" } +func (*SessionRulesDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SessionRulesDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.TransportProto + size += 1 // m.Lcl.Address.Af + size += 1 * 16 // m.Lcl.Address.Un + size += 1 // m.Lcl.Len + size += 1 // m.Rmt.Address.Af + size += 1 * 16 // m.Rmt.Address.Un + size += 1 // m.Rmt.Len + size += 2 // m.LclPort + size += 2 // m.RmtPort + size += 4 // m.ActionIndex + size += 4 // m.AppnsIndex + size += 4 // m.Scope + size += 64 // m.Tag + return size +} +func (m *SessionRulesDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.TransportProto)) + buf.EncodeUint8(uint8(m.Lcl.Address.Af)) + buf.EncodeBytes(m.Lcl.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Lcl.Len) + buf.EncodeUint8(uint8(m.Rmt.Address.Af)) + buf.EncodeBytes(m.Rmt.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Rmt.Len) + buf.EncodeUint16(m.LclPort) + buf.EncodeUint16(m.RmtPort) + buf.EncodeUint32(m.ActionIndex) + buf.EncodeUint32(m.AppnsIndex) + buf.EncodeUint32(uint32(m.Scope)) + buf.EncodeString(m.Tag, 64) + return buf.Bytes(), nil +} +func (m *SessionRulesDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TransportProto = TransportProto(buf.DecodeUint8()) + m.Lcl.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Lcl.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Lcl.Len = buf.DecodeUint8() + m.Rmt.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Rmt.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Rmt.Len = buf.DecodeUint8() + m.LclPort = buf.DecodeUint16() + m.RmtPort = buf.DecodeUint16() + m.ActionIndex = buf.DecodeUint32() + m.AppnsIndex = buf.DecodeUint32() + m.Scope = SessionRuleScope(buf.DecodeUint32()) + m.Tag = buf.DecodeString(64) + return nil +} + +// Dump session rules +// SessionRulesDump defines message 'session_rules_dump'. +type SessionRulesDump struct{} + +func (m *SessionRulesDump) Reset() { *m = SessionRulesDump{} } +func (*SessionRulesDump) GetMessageName() string { return "session_rules_dump" } +func (*SessionRulesDump) GetCrcString() string { return "51077d14" } +func (*SessionRulesDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SessionRulesDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SessionRulesDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SessionRulesDump) Unmarshal(b []byte) error { + return nil +} + +// enable/disable session layer socket api +// +// client to vpp direction only +// - is_enable - disable session layer if 0, enable otherwise +// +// SessionSapiEnableDisable defines message 'session_sapi_enable_disable'. +type SessionSapiEnableDisable struct { + IsEnable bool `binapi:"bool,name=is_enable,default=true" json:"is_enable,omitempty"` +} + +func (m *SessionSapiEnableDisable) Reset() { *m = SessionSapiEnableDisable{} } +func (*SessionSapiEnableDisable) GetMessageName() string { return "session_sapi_enable_disable" } +func (*SessionSapiEnableDisable) GetCrcString() string { return "c264d7bf" } +func (*SessionSapiEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SessionSapiEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsEnable + return size +} +func (m *SessionSapiEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsEnable) + return buf.Bytes(), nil +} +func (m *SessionSapiEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsEnable = buf.DecodeBool() + return nil +} + +// SessionSapiEnableDisableReply defines message 'session_sapi_enable_disable_reply'. +type SessionSapiEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SessionSapiEnableDisableReply) Reset() { *m = SessionSapiEnableDisableReply{} } +func (*SessionSapiEnableDisableReply) GetMessageName() string { + return "session_sapi_enable_disable_reply" +} +func (*SessionSapiEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*SessionSapiEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SessionSapiEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SessionSapiEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SessionSapiEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_session_binapi_init() } +func file_session_binapi_init() { + api.RegisterMessage((*AppAddCertKeyPair)(nil), "app_add_cert_key_pair_02eb8016") + api.RegisterMessage((*AppAddCertKeyPairReply)(nil), "app_add_cert_key_pair_reply_b42958d0") + api.RegisterMessage((*AppAttach)(nil), "app_attach_5f4a260d") + api.RegisterMessage((*AppAttachReply)(nil), "app_attach_reply_5c89c3b0") + api.RegisterMessage((*AppDelCertKeyPair)(nil), "app_del_cert_key_pair_8ac76db6") + api.RegisterMessage((*AppDelCertKeyPairReply)(nil), "app_del_cert_key_pair_reply_e8d4e804") + api.RegisterMessage((*AppNamespaceAddDel)(nil), "app_namespace_add_del_6306aecb") + api.RegisterMessage((*AppNamespaceAddDelReply)(nil), "app_namespace_add_del_reply_85137120") + api.RegisterMessage((*AppNamespaceAddDelV2)(nil), "app_namespace_add_del_v2_ee0755cf") + api.RegisterMessage((*AppNamespaceAddDelV2Reply)(nil), "app_namespace_add_del_v2_reply_85137120") + api.RegisterMessage((*AppNamespaceAddDelV3)(nil), "app_namespace_add_del_v3_8a7e40a1") + api.RegisterMessage((*AppNamespaceAddDelV3Reply)(nil), "app_namespace_add_del_v3_reply_85137120") + api.RegisterMessage((*AppNamespaceAddDelV4)(nil), "app_namespace_add_del_v4_42c1d824") + api.RegisterMessage((*AppNamespaceAddDelV4Reply)(nil), "app_namespace_add_del_v4_reply_85137120") + api.RegisterMessage((*AppWorkerAddDel)(nil), "app_worker_add_del_753253dc") + api.RegisterMessage((*AppWorkerAddDelReply)(nil), "app_worker_add_del_reply_5735ffe7") + api.RegisterMessage((*ApplicationDetach)(nil), "application_detach_51077d14") + api.RegisterMessage((*ApplicationDetachReply)(nil), "application_detach_reply_e8d4e804") + api.RegisterMessage((*SessionEnableDisable)(nil), "session_enable_disable_c264d7bf") + api.RegisterMessage((*SessionEnableDisableReply)(nil), "session_enable_disable_reply_e8d4e804") + api.RegisterMessage((*SessionRuleAddDel)(nil), "session_rule_add_del_82a90af5") + api.RegisterMessage((*SessionRuleAddDelReply)(nil), "session_rule_add_del_reply_e8d4e804") + api.RegisterMessage((*SessionRulesDetails)(nil), "session_rules_details_4ef746e7") + api.RegisterMessage((*SessionRulesDump)(nil), "session_rules_dump_51077d14") + api.RegisterMessage((*SessionSapiEnableDisable)(nil), "session_sapi_enable_disable_c264d7bf") + api.RegisterMessage((*SessionSapiEnableDisableReply)(nil), "session_sapi_enable_disable_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*AppAddCertKeyPair)(nil), + (*AppAddCertKeyPairReply)(nil), + (*AppAttach)(nil), + (*AppAttachReply)(nil), + (*AppDelCertKeyPair)(nil), + (*AppDelCertKeyPairReply)(nil), + (*AppNamespaceAddDel)(nil), + (*AppNamespaceAddDelReply)(nil), + (*AppNamespaceAddDelV2)(nil), + (*AppNamespaceAddDelV2Reply)(nil), + (*AppNamespaceAddDelV3)(nil), + (*AppNamespaceAddDelV3Reply)(nil), + (*AppNamespaceAddDelV4)(nil), + (*AppNamespaceAddDelV4Reply)(nil), + (*AppWorkerAddDel)(nil), + (*AppWorkerAddDelReply)(nil), + (*ApplicationDetach)(nil), + (*ApplicationDetachReply)(nil), + (*SessionEnableDisable)(nil), + (*SessionEnableDisableReply)(nil), + (*SessionRuleAddDel)(nil), + (*SessionRuleAddDelReply)(nil), + (*SessionRulesDetails)(nil), + (*SessionRulesDump)(nil), + (*SessionSapiEnableDisable)(nil), + (*SessionSapiEnableDisableReply)(nil), + } +} diff --git a/binapi/session/session_rpc.ba.go b/binapi/session/session_rpc.ba.go new file mode 100644 index 00000000..aef0e3dc --- /dev/null +++ b/binapi/session/session_rpc.ba.go @@ -0,0 +1,188 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package session + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service session. +type RPCService interface { + AppAddCertKeyPair(ctx context.Context, in *AppAddCertKeyPair) (*AppAddCertKeyPairReply, error) + AppAttach(ctx context.Context, in *AppAttach) (*AppAttachReply, error) + AppDelCertKeyPair(ctx context.Context, in *AppDelCertKeyPair) (*AppDelCertKeyPairReply, error) + AppNamespaceAddDel(ctx context.Context, in *AppNamespaceAddDel) (*AppNamespaceAddDelReply, error) + AppNamespaceAddDelV2(ctx context.Context, in *AppNamespaceAddDelV2) (*AppNamespaceAddDelV2Reply, error) + AppNamespaceAddDelV3(ctx context.Context, in *AppNamespaceAddDelV3) (*AppNamespaceAddDelV3Reply, error) + AppNamespaceAddDelV4(ctx context.Context, in *AppNamespaceAddDelV4) (*AppNamespaceAddDelV4Reply, error) + AppWorkerAddDel(ctx context.Context, in *AppWorkerAddDel) (*AppWorkerAddDelReply, error) + ApplicationDetach(ctx context.Context, in *ApplicationDetach) (*ApplicationDetachReply, error) + SessionEnableDisable(ctx context.Context, in *SessionEnableDisable) (*SessionEnableDisableReply, error) + SessionRuleAddDel(ctx context.Context, in *SessionRuleAddDel) (*SessionRuleAddDelReply, error) + SessionRulesDump(ctx context.Context, in *SessionRulesDump) (RPCService_SessionRulesDumpClient, error) + SessionSapiEnableDisable(ctx context.Context, in *SessionSapiEnableDisable) (*SessionSapiEnableDisableReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) AppAddCertKeyPair(ctx context.Context, in *AppAddCertKeyPair) (*AppAddCertKeyPairReply, error) { + out := new(AppAddCertKeyPairReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) AppAttach(ctx context.Context, in *AppAttach) (*AppAttachReply, error) { + out := new(AppAttachReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) AppDelCertKeyPair(ctx context.Context, in *AppDelCertKeyPair) (*AppDelCertKeyPairReply, error) { + out := new(AppDelCertKeyPairReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) AppNamespaceAddDel(ctx context.Context, in *AppNamespaceAddDel) (*AppNamespaceAddDelReply, error) { + out := new(AppNamespaceAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) AppNamespaceAddDelV2(ctx context.Context, in *AppNamespaceAddDelV2) (*AppNamespaceAddDelV2Reply, error) { + out := new(AppNamespaceAddDelV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) AppNamespaceAddDelV3(ctx context.Context, in *AppNamespaceAddDelV3) (*AppNamespaceAddDelV3Reply, error) { + out := new(AppNamespaceAddDelV3Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) AppNamespaceAddDelV4(ctx context.Context, in *AppNamespaceAddDelV4) (*AppNamespaceAddDelV4Reply, error) { + out := new(AppNamespaceAddDelV4Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) AppWorkerAddDel(ctx context.Context, in *AppWorkerAddDel) (*AppWorkerAddDelReply, error) { + out := new(AppWorkerAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ApplicationDetach(ctx context.Context, in *ApplicationDetach) (*ApplicationDetachReply, error) { + out := new(ApplicationDetachReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SessionEnableDisable(ctx context.Context, in *SessionEnableDisable) (*SessionEnableDisableReply, error) { + out := new(SessionEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SessionRuleAddDel(ctx context.Context, in *SessionRuleAddDel) (*SessionRuleAddDelReply, error) { + out := new(SessionRuleAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SessionRulesDump(ctx context.Context, in *SessionRulesDump) (RPCService_SessionRulesDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SessionRulesDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SessionRulesDumpClient interface { + Recv() (*SessionRulesDetails, error) + api.Stream +} + +type serviceClient_SessionRulesDumpClient struct { + api.Stream +} + +func (c *serviceClient_SessionRulesDumpClient) Recv() (*SessionRulesDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SessionRulesDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) SessionSapiEnableDisable(ctx context.Context, in *SessionSapiEnableDisable) (*SessionSapiEnableDisableReply, error) { + out := new(SessionSapiEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/span/span.ba.go b/binapi/span/span.ba.go new file mode 100644 index 00000000..bde5accf --- /dev/null +++ b/binapi/span/span.ba.go @@ -0,0 +1,258 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/span.api.json + +// Package span contains generated bindings for API file span.api. +// +// Contents: +// - 1 enum +// - 4 messages +package span + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "span" + APIVersion = "2.0.0" + VersionCrc = 0x34ee02b +) + +// SpanState defines enum 'span_state'. +type SpanState uint32 + +const ( + SPAN_STATE_API_DISABLED SpanState = 0 + SPAN_STATE_API_RX SpanState = 1 + SPAN_STATE_API_TX SpanState = 2 + SPAN_STATE_API_RX_TX SpanState = 3 +) + +var ( + SpanState_name = map[uint32]string{ + 0: "SPAN_STATE_API_DISABLED", + 1: "SPAN_STATE_API_RX", + 2: "SPAN_STATE_API_TX", + 3: "SPAN_STATE_API_RX_TX", + } + SpanState_value = map[string]uint32{ + "SPAN_STATE_API_DISABLED": 0, + "SPAN_STATE_API_RX": 1, + "SPAN_STATE_API_TX": 2, + "SPAN_STATE_API_RX_TX": 3, + } +) + +func (x SpanState) String() string { + s, ok := SpanState_name[uint32(x)] + if ok { + return s + } + return "SpanState(" + strconv.Itoa(int(x)) + ")" +} + +// Reply to SPAN dump request +// - sw_if_index_from - mirrored interface +// - sw_if_index_to - interface where the traffic is mirrored +// - state - 0 = disabled, 1 = rx enabled, 2 = tx enabled, 3 tx & rx enabled +// - is_l2 - 0 = mirrored at hw device level, 1 = mirrored at l2 +// +// SwInterfaceSpanDetails defines message 'sw_interface_span_details'. +type SwInterfaceSpanDetails struct { + SwIfIndexFrom interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index_from" json:"sw_if_index_from,omitempty"` + SwIfIndexTo interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index_to" json:"sw_if_index_to,omitempty"` + State SpanState `binapi:"span_state,name=state" json:"state,omitempty"` + IsL2 bool `binapi:"bool,name=is_l2" json:"is_l2,omitempty"` +} + +func (m *SwInterfaceSpanDetails) Reset() { *m = SwInterfaceSpanDetails{} } +func (*SwInterfaceSpanDetails) GetMessageName() string { return "sw_interface_span_details" } +func (*SwInterfaceSpanDetails) GetCrcString() string { return "8a20e79f" } +func (*SwInterfaceSpanDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwInterfaceSpanDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndexFrom + size += 4 // m.SwIfIndexTo + size += 4 // m.State + size += 1 // m.IsL2 + return size +} +func (m *SwInterfaceSpanDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndexFrom)) + buf.EncodeUint32(uint32(m.SwIfIndexTo)) + buf.EncodeUint32(uint32(m.State)) + buf.EncodeBool(m.IsL2) + return buf.Bytes(), nil +} +func (m *SwInterfaceSpanDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndexFrom = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.SwIfIndexTo = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.State = SpanState(buf.DecodeUint32()) + m.IsL2 = buf.DecodeBool() + return nil +} + +// SPAN dump request +// - is_l2 - 0 = hw device level, 1 = L2 +// +// SwInterfaceSpanDump defines message 'sw_interface_span_dump'. +type SwInterfaceSpanDump struct { + IsL2 bool `binapi:"bool,name=is_l2" json:"is_l2,omitempty"` +} + +func (m *SwInterfaceSpanDump) Reset() { *m = SwInterfaceSpanDump{} } +func (*SwInterfaceSpanDump) GetMessageName() string { return "sw_interface_span_dump" } +func (*SwInterfaceSpanDump) GetCrcString() string { return "d6cf0c3d" } +func (*SwInterfaceSpanDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSpanDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsL2 + return size +} +func (m *SwInterfaceSpanDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsL2) + return buf.Bytes(), nil +} +func (m *SwInterfaceSpanDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsL2 = buf.DecodeBool() + return nil +} + +// Enable/Disable span to mirror traffic from one interface to another +// - sw_if_index_from - interface to be mirrored +// - sw_if_index_to - interface where the traffic is mirrored +// - state - 0 = disabled, 1 = rx enabled, 2 = tx enabled, 3 tx & rx enabled +// - is_l2 - 0 = mirror at hw device level, 1 = mirror at L2 +// +// SwInterfaceSpanEnableDisable defines message 'sw_interface_span_enable_disable'. +type SwInterfaceSpanEnableDisable struct { + SwIfIndexFrom interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index_from" json:"sw_if_index_from,omitempty"` + SwIfIndexTo interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index_to" json:"sw_if_index_to,omitempty"` + State SpanState `binapi:"span_state,name=state" json:"state,omitempty"` + IsL2 bool `binapi:"bool,name=is_l2" json:"is_l2,omitempty"` +} + +func (m *SwInterfaceSpanEnableDisable) Reset() { *m = SwInterfaceSpanEnableDisable{} } +func (*SwInterfaceSpanEnableDisable) GetMessageName() string { + return "sw_interface_span_enable_disable" +} +func (*SwInterfaceSpanEnableDisable) GetCrcString() string { return "23ddd96b" } +func (*SwInterfaceSpanEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSpanEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndexFrom + size += 4 // m.SwIfIndexTo + size += 4 // m.State + size += 1 // m.IsL2 + return size +} +func (m *SwInterfaceSpanEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndexFrom)) + buf.EncodeUint32(uint32(m.SwIfIndexTo)) + buf.EncodeUint32(uint32(m.State)) + buf.EncodeBool(m.IsL2) + return buf.Bytes(), nil +} +func (m *SwInterfaceSpanEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndexFrom = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.SwIfIndexTo = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.State = SpanState(buf.DecodeUint32()) + m.IsL2 = buf.DecodeBool() + return nil +} + +// SwInterfaceSpanEnableDisableReply defines message 'sw_interface_span_enable_disable_reply'. +type SwInterfaceSpanEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 (m *SwInterfaceSpanEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSpanEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSpanEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_span_binapi_init() } +func file_span_binapi_init() { + api.RegisterMessage((*SwInterfaceSpanDetails)(nil), "sw_interface_span_details_8a20e79f") + api.RegisterMessage((*SwInterfaceSpanDump)(nil), "sw_interface_span_dump_d6cf0c3d") + api.RegisterMessage((*SwInterfaceSpanEnableDisable)(nil), "sw_interface_span_enable_disable_23ddd96b") + api.RegisterMessage((*SwInterfaceSpanEnableDisableReply)(nil), "sw_interface_span_enable_disable_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*SwInterfaceSpanDetails)(nil), + (*SwInterfaceSpanDump)(nil), + (*SwInterfaceSpanEnableDisable)(nil), + (*SwInterfaceSpanEnableDisableReply)(nil), + } +} diff --git a/binapi/span/span_rpc.ba.go b/binapi/span/span_rpc.ba.go new file mode 100644 index 00000000..83417865 --- /dev/null +++ b/binapi/span/span_rpc.ba.go @@ -0,0 +1,78 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package span + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service span. +type RPCService interface { + SwInterfaceSpanDump(ctx context.Context, in *SwInterfaceSpanDump) (RPCService_SwInterfaceSpanDumpClient, error) + SwInterfaceSpanEnableDisable(ctx context.Context, in *SwInterfaceSpanEnableDisable) (*SwInterfaceSpanEnableDisableReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) SwInterfaceSpanDump(ctx context.Context, in *SwInterfaceSpanDump) (RPCService_SwInterfaceSpanDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SwInterfaceSpanDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SwInterfaceSpanDumpClient interface { + Recv() (*SwInterfaceSpanDetails, error) + api.Stream +} + +type serviceClient_SwInterfaceSpanDumpClient struct { + api.Stream +} + +func (c *serviceClient_SwInterfaceSpanDumpClient) Recv() (*SwInterfaceSpanDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SwInterfaceSpanDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) SwInterfaceSpanEnableDisable(ctx context.Context, in *SwInterfaceSpanEnableDisable) (*SwInterfaceSpanEnableDisableReply, error) { + out := new(SwInterfaceSpanEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/sr/sr.ba.go b/binapi/sr/sr.ba.go new file mode 100644 index 00000000..65eabeed --- /dev/null +++ b/binapi/sr/sr.ba.go @@ -0,0 +1,1645 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/sr.api.json + +// Package sr contains generated bindings for API file sr.api. +// +// Contents: +// - 1 enum +// - 2 structs +// - 30 messages +package sr + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + sr_types "github.com/alkiranet/govpp/binapi/sr_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "sr" + APIVersion = "2.1.0" + VersionCrc = 0x1fa846d0 +) + +// SrPolicyType defines enum 'sr_policy_type'. +type SrPolicyType uint8 + +const ( + SR_API_POLICY_TYPE_DEFAULT SrPolicyType = 0 + SR_API_POLICY_TYPE_SPRAY SrPolicyType = 1 + SR_API_POLICY_TYPE_TEF SrPolicyType = 2 +) + +var ( + SrPolicyType_name = map[uint8]string{ + 0: "SR_API_POLICY_TYPE_DEFAULT", + 1: "SR_API_POLICY_TYPE_SPRAY", + 2: "SR_API_POLICY_TYPE_TEF", + } + SrPolicyType_value = map[string]uint8{ + "SR_API_POLICY_TYPE_DEFAULT": 0, + "SR_API_POLICY_TYPE_SPRAY": 1, + "SR_API_POLICY_TYPE_TEF": 2, + } +) + +func (x SrPolicyType) String() string { + s, ok := SrPolicyType_name[uint8(x)] + if ok { + return s + } + return "SrPolicyType(" + strconv.Itoa(int(x)) + ")" +} + +// Srv6SidList defines type 'srv6_sid_list'. +type Srv6SidList struct { + NumSids uint8 `binapi:"u8,name=num_sids" json:"num_sids,omitempty"` + Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` + Sids [16]ip_types.IP6Address `binapi:"ip6_address[16],name=sids" json:"sids,omitempty"` +} + +// Srv6SidListWithSlIndex defines type 'srv6_sid_list_with_sl_index'. +type Srv6SidListWithSlIndex struct { + NumSids uint8 `binapi:"u8,name=num_sids" json:"num_sids,omitempty"` + Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` + SlIndex uint32 `binapi:"u32,name=sl_index" json:"sl_index,omitempty"` + Sids [16]ip_types.IP6Address `binapi:"ip6_address[16],name=sids" json:"sids,omitempty"` +} + +// IPv6 SR LocalSID add/del request +// - is_del Boolean of whether its a delete instruction +// - localsid_addr IPv6 address of the localsid +// - end_psp Boolean of whether decapsulation is allowed in this function +// - behavior Type of behavior (function) for this localsid +// - sw_if_index Only for L2/L3 xconnect. OIF. In VRF variant the +// fib_table. Default:0xffffffff +// - vlan_index Only for L2 xconnect. Outgoing VLAN tag. +// - fib_table FIB table in which we should install the localsid entry +// - nh_addr Next Hop IPv46 address. Only for L2/L3 xconnect. +// +// SrLocalsidAddDel defines message 'sr_localsid_add_del'. +type SrLocalsidAddDel struct { + IsDel bool `binapi:"bool,name=is_del,default=false" json:"is_del,omitempty"` + Localsid ip_types.IP6Address `binapi:"ip6_address,name=localsid" json:"localsid,omitempty"` + EndPsp bool `binapi:"bool,name=end_psp" json:"end_psp,omitempty"` + Behavior sr_types.SrBehavior `binapi:"sr_behavior,name=behavior" json:"behavior,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` + VlanIndex uint32 `binapi:"u32,name=vlan_index" json:"vlan_index,omitempty"` + FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` + NhAddr ip_types.Address `binapi:"address,name=nh_addr" json:"nh_addr,omitempty"` +} + +func (m *SrLocalsidAddDel) Reset() { *m = SrLocalsidAddDel{} } +func (*SrLocalsidAddDel) GetMessageName() string { return "sr_localsid_add_del" } +func (*SrLocalsidAddDel) GetCrcString() string { return "5a36c324" } +func (*SrLocalsidAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrLocalsidAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsDel + size += 1 * 16 // m.Localsid + size += 1 // m.EndPsp + size += 1 // m.Behavior + size += 4 // m.SwIfIndex + size += 4 // m.VlanIndex + size += 4 // m.FibTable + size += 1 // m.NhAddr.Af + size += 1 * 16 // m.NhAddr.Un + return size +} +func (m *SrLocalsidAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsDel) + buf.EncodeBytes(m.Localsid[:], 16) + buf.EncodeBool(m.EndPsp) + buf.EncodeUint8(uint8(m.Behavior)) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.VlanIndex) + buf.EncodeUint32(m.FibTable) + buf.EncodeUint8(uint8(m.NhAddr.Af)) + buf.EncodeBytes(m.NhAddr.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *SrLocalsidAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsDel = buf.DecodeBool() + copy(m.Localsid[:], buf.DecodeBytes(16)) + m.EndPsp = buf.DecodeBool() + m.Behavior = sr_types.SrBehavior(buf.DecodeUint8()) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.VlanIndex = buf.DecodeUint32() + m.FibTable = buf.DecodeUint32() + m.NhAddr.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.NhAddr.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// SrLocalsidAddDelReply defines message 'sr_localsid_add_del_reply'. +type SrLocalsidAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SrLocalsidAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrLocalsidAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrLocalsidAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// SrLocalsidsDetails defines message 'sr_localsids_details'. +type SrLocalsidsDetails struct { + Addr ip_types.IP6Address `binapi:"ip6_address,name=addr" json:"addr,omitempty"` + EndPsp bool `binapi:"bool,name=end_psp" json:"end_psp,omitempty"` + Behavior sr_types.SrBehavior `binapi:"sr_behavior,name=behavior" json:"behavior,omitempty"` + FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` + VlanIndex uint32 `binapi:"u32,name=vlan_index" json:"vlan_index,omitempty"` + XconnectNhAddr ip_types.Address `binapi:"address,name=xconnect_nh_addr" json:"xconnect_nh_addr,omitempty"` + XconnectIfaceOrVrfTable uint32 `binapi:"u32,name=xconnect_iface_or_vrf_table" json:"xconnect_iface_or_vrf_table,omitempty"` +} + +func (m *SrLocalsidsDetails) Reset() { *m = SrLocalsidsDetails{} } +func (*SrLocalsidsDetails) GetMessageName() string { return "sr_localsids_details" } +func (*SrLocalsidsDetails) GetCrcString() string { return "2e9221b9" } +func (*SrLocalsidsDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrLocalsidsDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 16 // m.Addr + size += 1 // m.EndPsp + size += 1 // m.Behavior + size += 4 // m.FibTable + size += 4 // m.VlanIndex + size += 1 // m.XconnectNhAddr.Af + size += 1 * 16 // m.XconnectNhAddr.Un + size += 4 // m.XconnectIfaceOrVrfTable + return size +} +func (m *SrLocalsidsDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.Addr[:], 16) + buf.EncodeBool(m.EndPsp) + buf.EncodeUint8(uint8(m.Behavior)) + buf.EncodeUint32(m.FibTable) + buf.EncodeUint32(m.VlanIndex) + buf.EncodeUint8(uint8(m.XconnectNhAddr.Af)) + buf.EncodeBytes(m.XconnectNhAddr.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.XconnectIfaceOrVrfTable) + return buf.Bytes(), nil +} +func (m *SrLocalsidsDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.Addr[:], buf.DecodeBytes(16)) + m.EndPsp = buf.DecodeBool() + m.Behavior = sr_types.SrBehavior(buf.DecodeUint8()) + m.FibTable = buf.DecodeUint32() + m.VlanIndex = buf.DecodeUint32() + m.XconnectNhAddr.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.XconnectNhAddr.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.XconnectIfaceOrVrfTable = buf.DecodeUint32() + return nil +} + +// Dump the list of SR LocalSIDs +// SrLocalsidsDump defines 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 +} + +func (m *SrLocalsidsDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SrLocalsidsDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SrLocalsidsDump) Unmarshal(b []byte) error { + return nil +} + +// SrLocalsidsWithPacketStatsDetails defines message 'sr_localsids_with_packet_stats_details'. +// InProgress: the message form may change in the future versions +type SrLocalsidsWithPacketStatsDetails struct { + Addr ip_types.IP6Address `binapi:"ip6_address,name=addr" json:"addr,omitempty"` + EndPsp bool `binapi:"bool,name=end_psp" json:"end_psp,omitempty"` + Behavior sr_types.SrBehavior `binapi:"sr_behavior,name=behavior" json:"behavior,omitempty"` + FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` + VlanIndex uint32 `binapi:"u32,name=vlan_index" json:"vlan_index,omitempty"` + XconnectNhAddr ip_types.Address `binapi:"address,name=xconnect_nh_addr" json:"xconnect_nh_addr,omitempty"` + XconnectIfaceOrVrfTable uint32 `binapi:"u32,name=xconnect_iface_or_vrf_table" json:"xconnect_iface_or_vrf_table,omitempty"` + GoodTrafficBytes uint64 `binapi:"u64,name=good_traffic_bytes" json:"good_traffic_bytes,omitempty"` + GoodTrafficPktCount uint64 `binapi:"u64,name=good_traffic_pkt_count" json:"good_traffic_pkt_count,omitempty"` + BadTrafficBytes uint64 `binapi:"u64,name=bad_traffic_bytes" json:"bad_traffic_bytes,omitempty"` + BadTrafficPktCount uint64 `binapi:"u64,name=bad_traffic_pkt_count" json:"bad_traffic_pkt_count,omitempty"` +} + +func (m *SrLocalsidsWithPacketStatsDetails) Reset() { *m = SrLocalsidsWithPacketStatsDetails{} } +func (*SrLocalsidsWithPacketStatsDetails) GetMessageName() string { + return "sr_localsids_with_packet_stats_details" +} +func (*SrLocalsidsWithPacketStatsDetails) GetCrcString() string { return "ce0b1ce0" } +func (*SrLocalsidsWithPacketStatsDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrLocalsidsWithPacketStatsDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 16 // m.Addr + size += 1 // m.EndPsp + size += 1 // m.Behavior + size += 4 // m.FibTable + size += 4 // m.VlanIndex + size += 1 // m.XconnectNhAddr.Af + size += 1 * 16 // m.XconnectNhAddr.Un + size += 4 // m.XconnectIfaceOrVrfTable + size += 8 // m.GoodTrafficBytes + size += 8 // m.GoodTrafficPktCount + size += 8 // m.BadTrafficBytes + size += 8 // m.BadTrafficPktCount + return size +} +func (m *SrLocalsidsWithPacketStatsDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.Addr[:], 16) + buf.EncodeBool(m.EndPsp) + buf.EncodeUint8(uint8(m.Behavior)) + buf.EncodeUint32(m.FibTable) + buf.EncodeUint32(m.VlanIndex) + buf.EncodeUint8(uint8(m.XconnectNhAddr.Af)) + buf.EncodeBytes(m.XconnectNhAddr.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.XconnectIfaceOrVrfTable) + buf.EncodeUint64(m.GoodTrafficBytes) + buf.EncodeUint64(m.GoodTrafficPktCount) + buf.EncodeUint64(m.BadTrafficBytes) + buf.EncodeUint64(m.BadTrafficPktCount) + return buf.Bytes(), nil +} +func (m *SrLocalsidsWithPacketStatsDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.Addr[:], buf.DecodeBytes(16)) + m.EndPsp = buf.DecodeBool() + m.Behavior = sr_types.SrBehavior(buf.DecodeUint8()) + m.FibTable = buf.DecodeUint32() + m.VlanIndex = buf.DecodeUint32() + m.XconnectNhAddr.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.XconnectNhAddr.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.XconnectIfaceOrVrfTable = buf.DecodeUint32() + m.GoodTrafficBytes = buf.DecodeUint64() + m.GoodTrafficPktCount = buf.DecodeUint64() + m.BadTrafficBytes = buf.DecodeUint64() + m.BadTrafficPktCount = buf.DecodeUint64() + return nil +} + +// Dump the list of SR LocalSIDs along with packet statistics +// SrLocalsidsWithPacketStatsDump defines message 'sr_localsids_with_packet_stats_dump'. +// InProgress: the message form may change in the future versions +type SrLocalsidsWithPacketStatsDump struct{} + +func (m *SrLocalsidsWithPacketStatsDump) Reset() { *m = SrLocalsidsWithPacketStatsDump{} } +func (*SrLocalsidsWithPacketStatsDump) GetMessageName() string { + return "sr_localsids_with_packet_stats_dump" +} +func (*SrLocalsidsWithPacketStatsDump) GetCrcString() string { return "51077d14" } +func (*SrLocalsidsWithPacketStatsDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrLocalsidsWithPacketStatsDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SrLocalsidsWithPacketStatsDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SrLocalsidsWithPacketStatsDump) Unmarshal(b []byte) error { + return nil +} + +// SrPoliciesDetails defines message 'sr_policies_details'. +type SrPoliciesDetails struct { + Bsid ip_types.IP6Address `binapi:"ip6_address,name=bsid" json:"bsid,omitempty"` + IsSpray bool `binapi:"bool,name=is_spray" json:"is_spray,omitempty"` + IsEncap bool `binapi:"bool,name=is_encap" json:"is_encap,omitempty"` + FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` + NumSidLists uint8 `binapi:"u8,name=num_sid_lists" json:"-"` + SidLists []Srv6SidList `binapi:"srv6_sid_list[num_sid_lists],name=sid_lists" json:"sid_lists,omitempty"` +} + +func (m *SrPoliciesDetails) Reset() { *m = SrPoliciesDetails{} } +func (*SrPoliciesDetails) GetMessageName() string { return "sr_policies_details" } +func (*SrPoliciesDetails) GetCrcString() string { return "db6ff2a1" } +func (*SrPoliciesDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrPoliciesDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 16 // m.Bsid + size += 1 // m.IsSpray + size += 1 // m.IsEncap + size += 4 // m.FibTable + size += 1 // m.NumSidLists + for j1 := 0; j1 < len(m.SidLists); j1++ { + var s1 Srv6SidList + _ = s1 + if j1 < len(m.SidLists) { + s1 = m.SidLists[j1] + } + size += 1 // s1.NumSids + size += 4 // s1.Weight + for j2 := 0; j2 < 16; j2++ { + size += 1 * 16 // s1.Sids[j2] + } + } + return size +} +func (m *SrPoliciesDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.Bsid[:], 16) + buf.EncodeBool(m.IsSpray) + buf.EncodeBool(m.IsEncap) + buf.EncodeUint32(m.FibTable) + buf.EncodeUint8(uint8(len(m.SidLists))) + for j0 := 0; j0 < len(m.SidLists); j0++ { + var v0 Srv6SidList // SidLists + if j0 < len(m.SidLists) { + v0 = m.SidLists[j0] + } + buf.EncodeUint8(v0.NumSids) + buf.EncodeUint32(v0.Weight) + for j1 := 0; j1 < 16; j1++ { + buf.EncodeBytes(v0.Sids[j1][:], 16) + } + } + return buf.Bytes(), nil +} +func (m *SrPoliciesDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.Bsid[:], buf.DecodeBytes(16)) + m.IsSpray = buf.DecodeBool() + m.IsEncap = buf.DecodeBool() + m.FibTable = buf.DecodeUint32() + m.NumSidLists = buf.DecodeUint8() + m.SidLists = make([]Srv6SidList, m.NumSidLists) + for j0 := 0; j0 < len(m.SidLists); j0++ { + m.SidLists[j0].NumSids = buf.DecodeUint8() + m.SidLists[j0].Weight = buf.DecodeUint32() + for j1 := 0; j1 < 16; j1++ { + copy(m.SidLists[j0].Sids[j1][:], buf.DecodeBytes(16)) + } + } + return nil +} + +// Dump the list of SR policies +// SrPoliciesDump defines 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 +} + +func (m *SrPoliciesDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SrPoliciesDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SrPoliciesDump) Unmarshal(b []byte) error { + return nil +} + +// SrPoliciesV2Details defines message 'sr_policies_v2_details'. +// InProgress: the message form may change in the future versions +type SrPoliciesV2Details struct { + Bsid ip_types.IP6Address `binapi:"ip6_address,name=bsid" json:"bsid,omitempty"` + EncapSrc ip_types.IP6Address `binapi:"ip6_address,name=encap_src" json:"encap_src,omitempty"` + Type SrPolicyType `binapi:"sr_policy_type,name=type" json:"type,omitempty"` + IsEncap bool `binapi:"bool,name=is_encap" json:"is_encap,omitempty"` + FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` + NumSidLists uint8 `binapi:"u8,name=num_sid_lists" json:"-"` + SidLists []Srv6SidList `binapi:"srv6_sid_list[num_sid_lists],name=sid_lists" json:"sid_lists,omitempty"` +} + +func (m *SrPoliciesV2Details) Reset() { *m = SrPoliciesV2Details{} } +func (*SrPoliciesV2Details) GetMessageName() string { return "sr_policies_v2_details" } +func (*SrPoliciesV2Details) GetCrcString() string { return "96dcb699" } +func (*SrPoliciesV2Details) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrPoliciesV2Details) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 16 // m.Bsid + size += 1 * 16 // m.EncapSrc + size += 1 // m.Type + size += 1 // m.IsEncap + size += 4 // m.FibTable + size += 1 // m.NumSidLists + for j1 := 0; j1 < len(m.SidLists); j1++ { + var s1 Srv6SidList + _ = s1 + if j1 < len(m.SidLists) { + s1 = m.SidLists[j1] + } + size += 1 // s1.NumSids + size += 4 // s1.Weight + for j2 := 0; j2 < 16; j2++ { + size += 1 * 16 // s1.Sids[j2] + } + } + return size +} +func (m *SrPoliciesV2Details) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.Bsid[:], 16) + buf.EncodeBytes(m.EncapSrc[:], 16) + buf.EncodeUint8(uint8(m.Type)) + buf.EncodeBool(m.IsEncap) + buf.EncodeUint32(m.FibTable) + buf.EncodeUint8(uint8(len(m.SidLists))) + for j0 := 0; j0 < len(m.SidLists); j0++ { + var v0 Srv6SidList // SidLists + if j0 < len(m.SidLists) { + v0 = m.SidLists[j0] + } + buf.EncodeUint8(v0.NumSids) + buf.EncodeUint32(v0.Weight) + for j1 := 0; j1 < 16; j1++ { + buf.EncodeBytes(v0.Sids[j1][:], 16) + } + } + return buf.Bytes(), nil +} +func (m *SrPoliciesV2Details) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.Bsid[:], buf.DecodeBytes(16)) + copy(m.EncapSrc[:], buf.DecodeBytes(16)) + m.Type = SrPolicyType(buf.DecodeUint8()) + m.IsEncap = buf.DecodeBool() + m.FibTable = buf.DecodeUint32() + m.NumSidLists = buf.DecodeUint8() + m.SidLists = make([]Srv6SidList, m.NumSidLists) + for j0 := 0; j0 < len(m.SidLists); j0++ { + m.SidLists[j0].NumSids = buf.DecodeUint8() + m.SidLists[j0].Weight = buf.DecodeUint32() + for j1 := 0; j1 < 16; j1++ { + copy(m.SidLists[j0].Sids[j1][:], buf.DecodeBytes(16)) + } + } + return nil +} + +// Dump the list of SR policies v2 +// SrPoliciesV2Dump defines message 'sr_policies_v2_dump'. +type SrPoliciesV2Dump struct{} + +func (m *SrPoliciesV2Dump) Reset() { *m = SrPoliciesV2Dump{} } +func (*SrPoliciesV2Dump) GetMessageName() string { return "sr_policies_v2_dump" } +func (*SrPoliciesV2Dump) GetCrcString() string { return "51077d14" } +func (*SrPoliciesV2Dump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrPoliciesV2Dump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SrPoliciesV2Dump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SrPoliciesV2Dump) Unmarshal(b []byte) error { + return nil +} + +// SrPoliciesWithSlIndexDetails defines message 'sr_policies_with_sl_index_details'. +// InProgress: the message form may change in the future versions +type SrPoliciesWithSlIndexDetails struct { + Bsid ip_types.IP6Address `binapi:"ip6_address,name=bsid" json:"bsid,omitempty"` + IsSpray bool `binapi:"bool,name=is_spray" json:"is_spray,omitempty"` + IsEncap bool `binapi:"bool,name=is_encap" json:"is_encap,omitempty"` + FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` + NumSidLists uint8 `binapi:"u8,name=num_sid_lists" json:"-"` + SidLists []Srv6SidListWithSlIndex `binapi:"srv6_sid_list_with_sl_index[num_sid_lists],name=sid_lists" json:"sid_lists,omitempty"` +} + +func (m *SrPoliciesWithSlIndexDetails) Reset() { *m = SrPoliciesWithSlIndexDetails{} } +func (*SrPoliciesWithSlIndexDetails) GetMessageName() string { + return "sr_policies_with_sl_index_details" +} +func (*SrPoliciesWithSlIndexDetails) GetCrcString() string { return "ca2e9bc8" } +func (*SrPoliciesWithSlIndexDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrPoliciesWithSlIndexDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 16 // m.Bsid + size += 1 // m.IsSpray + size += 1 // m.IsEncap + size += 4 // m.FibTable + size += 1 // m.NumSidLists + for j1 := 0; j1 < len(m.SidLists); j1++ { + var s1 Srv6SidListWithSlIndex + _ = s1 + if j1 < len(m.SidLists) { + s1 = m.SidLists[j1] + } + size += 1 // s1.NumSids + size += 4 // s1.Weight + size += 4 // s1.SlIndex + for j2 := 0; j2 < 16; j2++ { + size += 1 * 16 // s1.Sids[j2] + } + } + return size +} +func (m *SrPoliciesWithSlIndexDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.Bsid[:], 16) + buf.EncodeBool(m.IsSpray) + buf.EncodeBool(m.IsEncap) + buf.EncodeUint32(m.FibTable) + buf.EncodeUint8(uint8(len(m.SidLists))) + for j0 := 0; j0 < len(m.SidLists); j0++ { + var v0 Srv6SidListWithSlIndex // SidLists + if j0 < len(m.SidLists) { + v0 = m.SidLists[j0] + } + buf.EncodeUint8(v0.NumSids) + buf.EncodeUint32(v0.Weight) + buf.EncodeUint32(v0.SlIndex) + for j1 := 0; j1 < 16; j1++ { + buf.EncodeBytes(v0.Sids[j1][:], 16) + } + } + return buf.Bytes(), nil +} +func (m *SrPoliciesWithSlIndexDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.Bsid[:], buf.DecodeBytes(16)) + m.IsSpray = buf.DecodeBool() + m.IsEncap = buf.DecodeBool() + m.FibTable = buf.DecodeUint32() + m.NumSidLists = buf.DecodeUint8() + m.SidLists = make([]Srv6SidListWithSlIndex, m.NumSidLists) + for j0 := 0; j0 < len(m.SidLists); j0++ { + m.SidLists[j0].NumSids = buf.DecodeUint8() + m.SidLists[j0].Weight = buf.DecodeUint32() + m.SidLists[j0].SlIndex = buf.DecodeUint32() + for j1 := 0; j1 < 16; j1++ { + copy(m.SidLists[j0].Sids[j1][:], buf.DecodeBytes(16)) + } + } + return nil +} + +// Dump the list of SR policies along with actual segment list index on VPP +// SrPoliciesWithSlIndexDump defines message 'sr_policies_with_sl_index_dump'. +// InProgress: the message form may change in the future versions +type SrPoliciesWithSlIndexDump struct{} + +func (m *SrPoliciesWithSlIndexDump) Reset() { *m = SrPoliciesWithSlIndexDump{} } +func (*SrPoliciesWithSlIndexDump) GetMessageName() string { return "sr_policies_with_sl_index_dump" } +func (*SrPoliciesWithSlIndexDump) GetCrcString() string { return "51077d14" } +func (*SrPoliciesWithSlIndexDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrPoliciesWithSlIndexDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SrPoliciesWithSlIndexDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SrPoliciesWithSlIndexDump) Unmarshal(b []byte) error { + return nil +} + +// IPv6 SR policy add +// - bsid is the bindingSID of the SR Policy +// - weight is the weight of the sid list. optional. +// - is_encap is the behavior of the SR policy. (0.SRH insert // 1.Encapsulation) +// - is_spray is the type of the SR policy. (0.Default // 1.Spray) +// - fib_table is the VRF where to install the FIB entry for the BSID +// - sids is a srv6_sid_list object +// +// SrPolicyAdd defines message 'sr_policy_add'. +type SrPolicyAdd struct { + BsidAddr ip_types.IP6Address `binapi:"ip6_address,name=bsid_addr" json:"bsid_addr,omitempty"` + Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` + IsEncap bool `binapi:"bool,name=is_encap" json:"is_encap,omitempty"` + IsSpray bool `binapi:"bool,name=is_spray" json:"is_spray,omitempty"` + FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` + Sids Srv6SidList `binapi:"srv6_sid_list,name=sids" json:"sids,omitempty"` +} + +func (m *SrPolicyAdd) Reset() { *m = SrPolicyAdd{} } +func (*SrPolicyAdd) GetMessageName() string { return "sr_policy_add" } +func (*SrPolicyAdd) GetCrcString() string { return "44ac92e8" } +func (*SrPolicyAdd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrPolicyAdd) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 16 // m.BsidAddr + size += 4 // m.Weight + size += 1 // m.IsEncap + size += 1 // m.IsSpray + size += 4 // m.FibTable + size += 1 // m.Sids.NumSids + size += 4 // m.Sids.Weight + for j2 := 0; j2 < 16; j2++ { + size += 1 * 16 // m.Sids.Sids[j2] + } + return size +} +func (m *SrPolicyAdd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.BsidAddr[:], 16) + buf.EncodeUint32(m.Weight) + buf.EncodeBool(m.IsEncap) + buf.EncodeBool(m.IsSpray) + buf.EncodeUint32(m.FibTable) + buf.EncodeUint8(m.Sids.NumSids) + buf.EncodeUint32(m.Sids.Weight) + for j1 := 0; j1 < 16; j1++ { + buf.EncodeBytes(m.Sids.Sids[j1][:], 16) + } + return buf.Bytes(), nil +} +func (m *SrPolicyAdd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.BsidAddr[:], buf.DecodeBytes(16)) + m.Weight = buf.DecodeUint32() + m.IsEncap = buf.DecodeBool() + m.IsSpray = buf.DecodeBool() + m.FibTable = buf.DecodeUint32() + m.Sids.NumSids = buf.DecodeUint8() + m.Sids.Weight = buf.DecodeUint32() + for j1 := 0; j1 < 16; j1++ { + copy(m.Sids.Sids[j1][:], buf.DecodeBytes(16)) + } + return nil +} + +// SrPolicyAddReply defines message 'sr_policy_add_reply'. +type SrPolicyAddReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SrPolicyAddReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrPolicyAddReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrPolicyAddReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IPv6 SR policy add +// - bsid is the bindingSID of the SR Policy +// - weight is the weight of the sid list. optional. +// - is_encap is the behavior of the SR policy. (0.SRH insert // 1.Encapsulation) +// - type is the SR policy param. (0.Default // 1.Spray // 2.Tef) +// - fib_table is the VRF where to install the FIB entry for the BSID +// - sids is a srv6_sid_list object +// - encap_src is a encaps IPv6 source addr. optional. +// +// SrPolicyAddV2 defines message 'sr_policy_add_v2'. +// InProgress: the message form may change in the future versions +type SrPolicyAddV2 struct { + BsidAddr ip_types.IP6Address `binapi:"ip6_address,name=bsid_addr" json:"bsid_addr,omitempty"` + Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` + IsEncap bool `binapi:"bool,name=is_encap" json:"is_encap,omitempty"` + Type SrPolicyType `binapi:"sr_policy_type,name=type,default=0" json:"type,omitempty"` + FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` + Sids Srv6SidList `binapi:"srv6_sid_list,name=sids" json:"sids,omitempty"` + EncapSrc ip_types.IP6Address `binapi:"ip6_address,name=encap_src" json:"encap_src,omitempty"` +} + +func (m *SrPolicyAddV2) Reset() { *m = SrPolicyAddV2{} } +func (*SrPolicyAddV2) GetMessageName() string { return "sr_policy_add_v2" } +func (*SrPolicyAddV2) GetCrcString() string { return "f6297f36" } +func (*SrPolicyAddV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrPolicyAddV2) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 16 // m.BsidAddr + size += 4 // m.Weight + size += 1 // m.IsEncap + size += 1 // m.Type + size += 4 // m.FibTable + size += 1 // m.Sids.NumSids + size += 4 // m.Sids.Weight + for j2 := 0; j2 < 16; j2++ { + size += 1 * 16 // m.Sids.Sids[j2] + } + size += 1 * 16 // m.EncapSrc + return size +} +func (m *SrPolicyAddV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.BsidAddr[:], 16) + buf.EncodeUint32(m.Weight) + buf.EncodeBool(m.IsEncap) + buf.EncodeUint8(uint8(m.Type)) + buf.EncodeUint32(m.FibTable) + buf.EncodeUint8(m.Sids.NumSids) + buf.EncodeUint32(m.Sids.Weight) + for j1 := 0; j1 < 16; j1++ { + buf.EncodeBytes(m.Sids.Sids[j1][:], 16) + } + buf.EncodeBytes(m.EncapSrc[:], 16) + return buf.Bytes(), nil +} +func (m *SrPolicyAddV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.BsidAddr[:], buf.DecodeBytes(16)) + m.Weight = buf.DecodeUint32() + m.IsEncap = buf.DecodeBool() + m.Type = SrPolicyType(buf.DecodeUint8()) + m.FibTable = buf.DecodeUint32() + m.Sids.NumSids = buf.DecodeUint8() + m.Sids.Weight = buf.DecodeUint32() + for j1 := 0; j1 < 16; j1++ { + copy(m.Sids.Sids[j1][:], buf.DecodeBytes(16)) + } + copy(m.EncapSrc[:], buf.DecodeBytes(16)) + return nil +} + +// SrPolicyAddV2Reply defines message 'sr_policy_add_v2_reply'. +// InProgress: the message form may change in the future versions +type SrPolicyAddV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SrPolicyAddV2Reply) Reset() { *m = SrPolicyAddV2Reply{} } +func (*SrPolicyAddV2Reply) GetMessageName() string { return "sr_policy_add_v2_reply" } +func (*SrPolicyAddV2Reply) GetCrcString() string { return "e8d4e804" } +func (*SrPolicyAddV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrPolicyAddV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrPolicyAddV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrPolicyAddV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IPv6 SR policy deletion +// - bsid is the bindingSID of the SR Policy +// - index is the index of the SR policy +// +// SrPolicyDel defines message 'sr_policy_del'. +type SrPolicyDel struct { + BsidAddr ip_types.IP6Address `binapi:"ip6_address,name=bsid_addr" json:"bsid_addr,omitempty"` + SrPolicyIndex uint32 `binapi:"u32,name=sr_policy_index" json:"sr_policy_index,omitempty"` +} + +func (m *SrPolicyDel) Reset() { *m = SrPolicyDel{} } +func (*SrPolicyDel) GetMessageName() string { return "sr_policy_del" } +func (*SrPolicyDel) GetCrcString() string { return "cb4d48d5" } +func (*SrPolicyDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrPolicyDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 16 // m.BsidAddr + size += 4 // m.SrPolicyIndex + return size +} +func (m *SrPolicyDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.BsidAddr[:], 16) + buf.EncodeUint32(m.SrPolicyIndex) + return buf.Bytes(), nil +} +func (m *SrPolicyDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.BsidAddr[:], buf.DecodeBytes(16)) + m.SrPolicyIndex = buf.DecodeUint32() + return nil +} + +// SrPolicyDelReply defines message 'sr_policy_del_reply'. +type SrPolicyDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SrPolicyDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrPolicyDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrPolicyDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IPv6 SR policy modification +// - bsid is the bindingSID of the SR Policy +// - sr_policy_index is the index of the SR policy +// - fib_table is the VRF where to install the FIB entry for the BSID +// - operation is the operation to perform (among the top ones) +// - sl_index is the index of the Segment List to modify/delete +// - weight is the weight of the sid list. optional. +// - sids is a srv6_sid_list object +// +// SrPolicyMod defines message 'sr_policy_mod'. +type SrPolicyMod struct { + BsidAddr ip_types.IP6Address `binapi:"ip6_address,name=bsid_addr" json:"bsid_addr,omitempty"` + SrPolicyIndex uint32 `binapi:"u32,name=sr_policy_index" json:"sr_policy_index,omitempty"` + FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` + Operation sr_types.SrPolicyOp `binapi:"sr_policy_op,name=operation" json:"operation,omitempty"` + SlIndex uint32 `binapi:"u32,name=sl_index" json:"sl_index,omitempty"` + Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` + Sids Srv6SidList `binapi:"srv6_sid_list,name=sids" json:"sids,omitempty"` +} + +func (m *SrPolicyMod) Reset() { *m = SrPolicyMod{} } +func (*SrPolicyMod) GetMessageName() string { return "sr_policy_mod" } +func (*SrPolicyMod) GetCrcString() string { return "b97bb56e" } +func (*SrPolicyMod) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrPolicyMod) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 16 // m.BsidAddr + size += 4 // m.SrPolicyIndex + size += 4 // m.FibTable + size += 1 // m.Operation + size += 4 // m.SlIndex + size += 4 // m.Weight + size += 1 // m.Sids.NumSids + size += 4 // m.Sids.Weight + for j2 := 0; j2 < 16; j2++ { + size += 1 * 16 // m.Sids.Sids[j2] + } + return size +} +func (m *SrPolicyMod) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.BsidAddr[:], 16) + buf.EncodeUint32(m.SrPolicyIndex) + buf.EncodeUint32(m.FibTable) + buf.EncodeUint8(uint8(m.Operation)) + buf.EncodeUint32(m.SlIndex) + buf.EncodeUint32(m.Weight) + buf.EncodeUint8(m.Sids.NumSids) + buf.EncodeUint32(m.Sids.Weight) + for j1 := 0; j1 < 16; j1++ { + buf.EncodeBytes(m.Sids.Sids[j1][:], 16) + } + return buf.Bytes(), nil +} +func (m *SrPolicyMod) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.BsidAddr[:], buf.DecodeBytes(16)) + m.SrPolicyIndex = buf.DecodeUint32() + m.FibTable = buf.DecodeUint32() + m.Operation = sr_types.SrPolicyOp(buf.DecodeUint8()) + m.SlIndex = buf.DecodeUint32() + m.Weight = buf.DecodeUint32() + m.Sids.NumSids = buf.DecodeUint8() + m.Sids.Weight = buf.DecodeUint32() + for j1 := 0; j1 < 16; j1++ { + copy(m.Sids.Sids[j1][:], buf.DecodeBytes(16)) + } + return nil +} + +// SrPolicyModReply defines message 'sr_policy_mod_reply'. +type SrPolicyModReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SrPolicyModReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrPolicyModReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrPolicyModReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IPv6 SR policy modification +// - bsid is the bindingSID of the SR Policy +// - sr_policy_index is the index of the SR policy +// - fib_table is the VRF where to install the FIB entry for the BSID +// - operation is the operation to perform (among the top ones) +// - sl_index is the index of the Segment List to modify/delete +// - weight is the weight of the sid list. optional. +// - sids is a srv6_sid_list object +// - encap_src is a encaps IPv6 source addr. optional. +// +// SrPolicyModV2 defines message 'sr_policy_mod_v2'. +// InProgress: the message form may change in the future versions +type SrPolicyModV2 struct { + BsidAddr ip_types.IP6Address `binapi:"ip6_address,name=bsid_addr" json:"bsid_addr,omitempty"` + SrPolicyIndex uint32 `binapi:"u32,name=sr_policy_index" json:"sr_policy_index,omitempty"` + FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` + Operation sr_types.SrPolicyOp `binapi:"sr_policy_op,name=operation" json:"operation,omitempty"` + SlIndex uint32 `binapi:"u32,name=sl_index" json:"sl_index,omitempty"` + Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` + Sids Srv6SidList `binapi:"srv6_sid_list,name=sids" json:"sids,omitempty"` + EncapSrc ip_types.IP6Address `binapi:"ip6_address,name=encap_src" json:"encap_src,omitempty"` +} + +func (m *SrPolicyModV2) Reset() { *m = SrPolicyModV2{} } +func (*SrPolicyModV2) GetMessageName() string { return "sr_policy_mod_v2" } +func (*SrPolicyModV2) GetCrcString() string { return "c0544823" } +func (*SrPolicyModV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrPolicyModV2) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 16 // m.BsidAddr + size += 4 // m.SrPolicyIndex + size += 4 // m.FibTable + size += 1 // m.Operation + size += 4 // m.SlIndex + size += 4 // m.Weight + size += 1 // m.Sids.NumSids + size += 4 // m.Sids.Weight + for j2 := 0; j2 < 16; j2++ { + size += 1 * 16 // m.Sids.Sids[j2] + } + size += 1 * 16 // m.EncapSrc + return size +} +func (m *SrPolicyModV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.BsidAddr[:], 16) + buf.EncodeUint32(m.SrPolicyIndex) + buf.EncodeUint32(m.FibTable) + buf.EncodeUint8(uint8(m.Operation)) + buf.EncodeUint32(m.SlIndex) + buf.EncodeUint32(m.Weight) + buf.EncodeUint8(m.Sids.NumSids) + buf.EncodeUint32(m.Sids.Weight) + for j1 := 0; j1 < 16; j1++ { + buf.EncodeBytes(m.Sids.Sids[j1][:], 16) + } + buf.EncodeBytes(m.EncapSrc[:], 16) + return buf.Bytes(), nil +} +func (m *SrPolicyModV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.BsidAddr[:], buf.DecodeBytes(16)) + m.SrPolicyIndex = buf.DecodeUint32() + m.FibTable = buf.DecodeUint32() + m.Operation = sr_types.SrPolicyOp(buf.DecodeUint8()) + m.SlIndex = buf.DecodeUint32() + m.Weight = buf.DecodeUint32() + m.Sids.NumSids = buf.DecodeUint8() + m.Sids.Weight = buf.DecodeUint32() + for j1 := 0; j1 < 16; j1++ { + copy(m.Sids.Sids[j1][:], buf.DecodeBytes(16)) + } + copy(m.EncapSrc[:], buf.DecodeBytes(16)) + return nil +} + +// SrPolicyModV2Reply defines message 'sr_policy_mod_v2_reply'. +// InProgress: the message form may change in the future versions +type SrPolicyModV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SrPolicyModV2Reply) Reset() { *m = SrPolicyModV2Reply{} } +func (*SrPolicyModV2Reply) GetMessageName() string { return "sr_policy_mod_v2_reply" } +func (*SrPolicyModV2Reply) GetCrcString() string { return "e8d4e804" } +func (*SrPolicyModV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrPolicyModV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrPolicyModV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrPolicyModV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IPv6 SR Set SRv6 encapsulation hop-limit +// - hop_limit is the hop-limit value to set +// +// SrSetEncapHopLimit defines message 'sr_set_encap_hop_limit'. +type SrSetEncapHopLimit struct { + HopLimit uint8 `binapi:"u8,name=hop_limit" json:"hop_limit,omitempty"` +} + +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 +} + +func (m *SrSetEncapHopLimit) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.HopLimit + return size +} +func (m *SrSetEncapHopLimit) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.HopLimit) + return buf.Bytes(), nil +} +func (m *SrSetEncapHopLimit) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.HopLimit = buf.DecodeUint8() + return nil +} + +// SrSetEncapHopLimitReply defines message 'sr_set_encap_hop_limit_reply'. +type SrSetEncapHopLimitReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SrSetEncapHopLimitReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrSetEncapHopLimitReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrSetEncapHopLimitReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IPv6 SR Set SRv6 encapsulation source +// - bsid is the bindingSID of the SR Policy +// - index is the index of the SR policy +// +// SrSetEncapSource defines message 'sr_set_encap_source'. +type SrSetEncapSource struct { + EncapsSource ip_types.IP6Address `binapi:"ip6_address,name=encaps_source" json:"encaps_source,omitempty"` +} + +func (m *SrSetEncapSource) Reset() { *m = SrSetEncapSource{} } +func (*SrSetEncapSource) GetMessageName() string { return "sr_set_encap_source" } +func (*SrSetEncapSource) GetCrcString() string { return "d3bad5e1" } +func (*SrSetEncapSource) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrSetEncapSource) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 16 // m.EncapsSource + return size +} +func (m *SrSetEncapSource) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.EncapsSource[:], 16) + return buf.Bytes(), nil +} +func (m *SrSetEncapSource) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.EncapsSource[:], buf.DecodeBytes(16)) + return nil +} + +// SrSetEncapSourceReply defines message 'sr_set_encap_source_reply'. +type SrSetEncapSourceReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SrSetEncapSourceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrSetEncapSourceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrSetEncapSourceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// IPv6 SR steering add/del +// - is_del +// - bsid is the bindingSID of the SR Policy (alt to sr_policy_index) +// - sr_policy is the index of the SR Policy (alt to bsid) +// - table_id is the VRF where to install the FIB entry for the BSID +// - prefix is the IPv4/v6 address for L3 traffic type +// - mask_width is the mask for L3 traffic type +// - sw_if_index is the incoming interface for L2 traffic +// - traffic_type describes the type of traffic +// +// SrSteeringAddDel defines message 'sr_steering_add_del'. +type SrSteeringAddDel struct { + IsDel bool `binapi:"bool,name=is_del,default=false" json:"is_del,omitempty"` + BsidAddr ip_types.IP6Address `binapi:"ip6_address,name=bsid_addr" json:"bsid_addr,omitempty"` + SrPolicyIndex uint32 `binapi:"u32,name=sr_policy_index" json:"sr_policy_index,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + Prefix ip_types.Prefix `binapi:"prefix,name=prefix" json:"prefix,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + TrafficType sr_types.SrSteer `binapi:"sr_steer,name=traffic_type" json:"traffic_type,omitempty"` +} + +func (m *SrSteeringAddDel) Reset() { *m = SrSteeringAddDel{} } +func (*SrSteeringAddDel) GetMessageName() string { return "sr_steering_add_del" } +func (*SrSteeringAddDel) GetCrcString() string { return "e46b0a0f" } +func (*SrSteeringAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrSteeringAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsDel + size += 1 * 16 // m.BsidAddr + size += 4 // m.SrPolicyIndex + size += 4 // m.TableID + size += 1 // m.Prefix.Address.Af + size += 1 * 16 // m.Prefix.Address.Un + size += 1 // m.Prefix.Len + size += 4 // m.SwIfIndex + size += 1 // m.TrafficType + return size +} +func (m *SrSteeringAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsDel) + buf.EncodeBytes(m.BsidAddr[:], 16) + buf.EncodeUint32(m.SrPolicyIndex) + buf.EncodeUint32(m.TableID) + buf.EncodeUint8(uint8(m.Prefix.Address.Af)) + buf.EncodeBytes(m.Prefix.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Prefix.Len) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(uint8(m.TrafficType)) + return buf.Bytes(), nil +} +func (m *SrSteeringAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsDel = buf.DecodeBool() + copy(m.BsidAddr[:], buf.DecodeBytes(16)) + m.SrPolicyIndex = buf.DecodeUint32() + m.TableID = buf.DecodeUint32() + m.Prefix.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Prefix.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Prefix.Len = buf.DecodeUint8() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.TrafficType = sr_types.SrSteer(buf.DecodeUint8()) + return nil +} + +// SrSteeringAddDelReply defines message 'sr_steering_add_del_reply'. +type SrSteeringAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SrSteeringAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrSteeringAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrSteeringAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// SrSteeringPolDetails defines message 'sr_steering_pol_details'. +type SrSteeringPolDetails struct { + TrafficType sr_types.SrSteer `binapi:"sr_steer,name=traffic_type" json:"traffic_type,omitempty"` + FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` + Prefix ip_types.Prefix `binapi:"prefix,name=prefix" json:"prefix,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Bsid ip_types.IP6Address `binapi:"ip6_address,name=bsid" json:"bsid,omitempty"` +} + +func (m *SrSteeringPolDetails) Reset() { *m = SrSteeringPolDetails{} } +func (*SrSteeringPolDetails) GetMessageName() string { return "sr_steering_pol_details" } +func (*SrSteeringPolDetails) GetCrcString() string { return "d41258c9" } +func (*SrSteeringPolDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrSteeringPolDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.TrafficType + size += 4 // m.FibTable + size += 1 // m.Prefix.Address.Af + size += 1 * 16 // m.Prefix.Address.Un + size += 1 // m.Prefix.Len + size += 4 // m.SwIfIndex + size += 1 * 16 // m.Bsid + return size +} +func (m *SrSteeringPolDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.TrafficType)) + buf.EncodeUint32(m.FibTable) + buf.EncodeUint8(uint8(m.Prefix.Address.Af)) + buf.EncodeBytes(m.Prefix.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Prefix.Len) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBytes(m.Bsid[:], 16) + return buf.Bytes(), nil +} +func (m *SrSteeringPolDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TrafficType = sr_types.SrSteer(buf.DecodeUint8()) + m.FibTable = buf.DecodeUint32() + m.Prefix.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Prefix.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Prefix.Len = buf.DecodeUint8() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + copy(m.Bsid[:], buf.DecodeBytes(16)) + return nil +} + +// Dump the steering policies +// SrSteeringPolDump defines 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 (m *SrSteeringPolDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SrSteeringPolDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SrSteeringPolDump) Unmarshal(b []byte) error { + return nil +} + +func init() { file_sr_binapi_init() } +func file_sr_binapi_init() { + api.RegisterMessage((*SrLocalsidAddDel)(nil), "sr_localsid_add_del_5a36c324") + api.RegisterMessage((*SrLocalsidAddDelReply)(nil), "sr_localsid_add_del_reply_e8d4e804") + api.RegisterMessage((*SrLocalsidsDetails)(nil), "sr_localsids_details_2e9221b9") + api.RegisterMessage((*SrLocalsidsDump)(nil), "sr_localsids_dump_51077d14") + api.RegisterMessage((*SrLocalsidsWithPacketStatsDetails)(nil), "sr_localsids_with_packet_stats_details_ce0b1ce0") + api.RegisterMessage((*SrLocalsidsWithPacketStatsDump)(nil), "sr_localsids_with_packet_stats_dump_51077d14") + api.RegisterMessage((*SrPoliciesDetails)(nil), "sr_policies_details_db6ff2a1") + api.RegisterMessage((*SrPoliciesDump)(nil), "sr_policies_dump_51077d14") + api.RegisterMessage((*SrPoliciesV2Details)(nil), "sr_policies_v2_details_96dcb699") + api.RegisterMessage((*SrPoliciesV2Dump)(nil), "sr_policies_v2_dump_51077d14") + api.RegisterMessage((*SrPoliciesWithSlIndexDetails)(nil), "sr_policies_with_sl_index_details_ca2e9bc8") + api.RegisterMessage((*SrPoliciesWithSlIndexDump)(nil), "sr_policies_with_sl_index_dump_51077d14") + api.RegisterMessage((*SrPolicyAdd)(nil), "sr_policy_add_44ac92e8") + api.RegisterMessage((*SrPolicyAddReply)(nil), "sr_policy_add_reply_e8d4e804") + api.RegisterMessage((*SrPolicyAddV2)(nil), "sr_policy_add_v2_f6297f36") + api.RegisterMessage((*SrPolicyAddV2Reply)(nil), "sr_policy_add_v2_reply_e8d4e804") + api.RegisterMessage((*SrPolicyDel)(nil), "sr_policy_del_cb4d48d5") + api.RegisterMessage((*SrPolicyDelReply)(nil), "sr_policy_del_reply_e8d4e804") + api.RegisterMessage((*SrPolicyMod)(nil), "sr_policy_mod_b97bb56e") + api.RegisterMessage((*SrPolicyModReply)(nil), "sr_policy_mod_reply_e8d4e804") + api.RegisterMessage((*SrPolicyModV2)(nil), "sr_policy_mod_v2_c0544823") + api.RegisterMessage((*SrPolicyModV2Reply)(nil), "sr_policy_mod_v2_reply_e8d4e804") + api.RegisterMessage((*SrSetEncapHopLimit)(nil), "sr_set_encap_hop_limit_aa75d7d0") + api.RegisterMessage((*SrSetEncapHopLimitReply)(nil), "sr_set_encap_hop_limit_reply_e8d4e804") + api.RegisterMessage((*SrSetEncapSource)(nil), "sr_set_encap_source_d3bad5e1") + api.RegisterMessage((*SrSetEncapSourceReply)(nil), "sr_set_encap_source_reply_e8d4e804") + api.RegisterMessage((*SrSteeringAddDel)(nil), "sr_steering_add_del_e46b0a0f") + api.RegisterMessage((*SrSteeringAddDelReply)(nil), "sr_steering_add_del_reply_e8d4e804") + api.RegisterMessage((*SrSteeringPolDetails)(nil), "sr_steering_pol_details_d41258c9") + api.RegisterMessage((*SrSteeringPolDump)(nil), "sr_steering_pol_dump_51077d14") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*SrLocalsidAddDel)(nil), + (*SrLocalsidAddDelReply)(nil), + (*SrLocalsidsDetails)(nil), + (*SrLocalsidsDump)(nil), + (*SrLocalsidsWithPacketStatsDetails)(nil), + (*SrLocalsidsWithPacketStatsDump)(nil), + (*SrPoliciesDetails)(nil), + (*SrPoliciesDump)(nil), + (*SrPoliciesV2Details)(nil), + (*SrPoliciesV2Dump)(nil), + (*SrPoliciesWithSlIndexDetails)(nil), + (*SrPoliciesWithSlIndexDump)(nil), + (*SrPolicyAdd)(nil), + (*SrPolicyAddReply)(nil), + (*SrPolicyAddV2)(nil), + (*SrPolicyAddV2Reply)(nil), + (*SrPolicyDel)(nil), + (*SrPolicyDelReply)(nil), + (*SrPolicyMod)(nil), + (*SrPolicyModReply)(nil), + (*SrPolicyModV2)(nil), + (*SrPolicyModV2Reply)(nil), + (*SrSetEncapHopLimit)(nil), + (*SrSetEncapHopLimitReply)(nil), + (*SrSetEncapSource)(nil), + (*SrSetEncapSourceReply)(nil), + (*SrSteeringAddDel)(nil), + (*SrSteeringAddDelReply)(nil), + (*SrSteeringPolDetails)(nil), + (*SrSteeringPolDump)(nil), + } +} diff --git a/binapi/sr/sr_rpc.ba.go b/binapi/sr/sr_rpc.ba.go new file mode 100644 index 00000000..b06ad7f9 --- /dev/null +++ b/binapi/sr/sr_rpc.ba.go @@ -0,0 +1,378 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package sr + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service sr. +type RPCService interface { + SrLocalsidAddDel(ctx context.Context, in *SrLocalsidAddDel) (*SrLocalsidAddDelReply, error) + SrLocalsidsDump(ctx context.Context, in *SrLocalsidsDump) (RPCService_SrLocalsidsDumpClient, error) + SrLocalsidsWithPacketStatsDump(ctx context.Context, in *SrLocalsidsWithPacketStatsDump) (RPCService_SrLocalsidsWithPacketStatsDumpClient, error) + SrPoliciesDump(ctx context.Context, in *SrPoliciesDump) (RPCService_SrPoliciesDumpClient, error) + SrPoliciesV2Dump(ctx context.Context, in *SrPoliciesV2Dump) (RPCService_SrPoliciesV2DumpClient, error) + SrPoliciesWithSlIndexDump(ctx context.Context, in *SrPoliciesWithSlIndexDump) (RPCService_SrPoliciesWithSlIndexDumpClient, error) + SrPolicyAdd(ctx context.Context, in *SrPolicyAdd) (*SrPolicyAddReply, error) + SrPolicyAddV2(ctx context.Context, in *SrPolicyAddV2) (*SrPolicyAddV2Reply, error) + SrPolicyDel(ctx context.Context, in *SrPolicyDel) (*SrPolicyDelReply, error) + SrPolicyMod(ctx context.Context, in *SrPolicyMod) (*SrPolicyModReply, error) + SrPolicyModV2(ctx context.Context, in *SrPolicyModV2) (*SrPolicyModV2Reply, 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) + SrSteeringPolDump(ctx context.Context, in *SrSteeringPolDump) (RPCService_SrSteeringPolDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) SrLocalsidAddDel(ctx context.Context, in *SrLocalsidAddDel) (*SrLocalsidAddDelReply, error) { + out := new(SrLocalsidAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SrLocalsidsDump(ctx context.Context, in *SrLocalsidsDump) (RPCService_SrLocalsidsDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SrLocalsidsDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SrLocalsidsDumpClient interface { + Recv() (*SrLocalsidsDetails, error) + api.Stream +} + +type serviceClient_SrLocalsidsDumpClient struct { + api.Stream +} + +func (c *serviceClient_SrLocalsidsDumpClient) Recv() (*SrLocalsidsDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SrLocalsidsDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) SrLocalsidsWithPacketStatsDump(ctx context.Context, in *SrLocalsidsWithPacketStatsDump) (RPCService_SrLocalsidsWithPacketStatsDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SrLocalsidsWithPacketStatsDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SrLocalsidsWithPacketStatsDumpClient interface { + Recv() (*SrLocalsidsWithPacketStatsDetails, error) + api.Stream +} + +type serviceClient_SrLocalsidsWithPacketStatsDumpClient struct { + api.Stream +} + +func (c *serviceClient_SrLocalsidsWithPacketStatsDumpClient) Recv() (*SrLocalsidsWithPacketStatsDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SrLocalsidsWithPacketStatsDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) SrPoliciesDump(ctx context.Context, in *SrPoliciesDump) (RPCService_SrPoliciesDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SrPoliciesDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SrPoliciesDumpClient interface { + Recv() (*SrPoliciesDetails, error) + api.Stream +} + +type serviceClient_SrPoliciesDumpClient struct { + api.Stream +} + +func (c *serviceClient_SrPoliciesDumpClient) Recv() (*SrPoliciesDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SrPoliciesDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) SrPoliciesV2Dump(ctx context.Context, in *SrPoliciesV2Dump) (RPCService_SrPoliciesV2DumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SrPoliciesV2DumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SrPoliciesV2DumpClient interface { + Recv() (*SrPoliciesV2Details, error) + api.Stream +} + +type serviceClient_SrPoliciesV2DumpClient struct { + api.Stream +} + +func (c *serviceClient_SrPoliciesV2DumpClient) Recv() (*SrPoliciesV2Details, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SrPoliciesV2Details: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) SrPoliciesWithSlIndexDump(ctx context.Context, in *SrPoliciesWithSlIndexDump) (RPCService_SrPoliciesWithSlIndexDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SrPoliciesWithSlIndexDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SrPoliciesWithSlIndexDumpClient interface { + Recv() (*SrPoliciesWithSlIndexDetails, error) + api.Stream +} + +type serviceClient_SrPoliciesWithSlIndexDumpClient struct { + api.Stream +} + +func (c *serviceClient_SrPoliciesWithSlIndexDumpClient) Recv() (*SrPoliciesWithSlIndexDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SrPoliciesWithSlIndexDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) SrPolicyAdd(ctx context.Context, in *SrPolicyAdd) (*SrPolicyAddReply, error) { + out := new(SrPolicyAddReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SrPolicyAddV2(ctx context.Context, in *SrPolicyAddV2) (*SrPolicyAddV2Reply, error) { + out := new(SrPolicyAddV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SrPolicyDel(ctx context.Context, in *SrPolicyDel) (*SrPolicyDelReply, error) { + out := new(SrPolicyDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SrPolicyMod(ctx context.Context, in *SrPolicyMod) (*SrPolicyModReply, error) { + out := new(SrPolicyModReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SrPolicyModV2(ctx context.Context, in *SrPolicyModV2) (*SrPolicyModV2Reply, error) { + out := new(SrPolicyModV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SrSetEncapHopLimit(ctx context.Context, in *SrSetEncapHopLimit) (*SrSetEncapHopLimitReply, error) { + out := new(SrSetEncapHopLimitReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SrSetEncapSource(ctx context.Context, in *SrSetEncapSource) (*SrSetEncapSourceReply, error) { + out := new(SrSetEncapSourceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SrSteeringAddDel(ctx context.Context, in *SrSteeringAddDel) (*SrSteeringAddDelReply, error) { + out := new(SrSteeringAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SrSteeringPolDump(ctx context.Context, in *SrSteeringPolDump) (RPCService_SrSteeringPolDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SrSteeringPolDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SrSteeringPolDumpClient interface { + Recv() (*SrSteeringPolDetails, error) + api.Stream +} + +type serviceClient_SrSteeringPolDumpClient struct { + api.Stream +} + +func (c *serviceClient_SrSteeringPolDumpClient) Recv() (*SrSteeringPolDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SrSteeringPolDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/sr_mpls/sr_mpls.ba.go b/binapi/sr_mpls/sr_mpls.ba.go new file mode 100644 index 00000000..ad369859 --- /dev/null +++ b/binapi/sr_mpls/sr_mpls.ba.go @@ -0,0 +1,536 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/sr_mpls.api.json + +// Package sr_mpls contains generated bindings for API file sr_mpls.api. +// +// Contents: +// - 10 messages +package sr_mpls + +import ( + api "github.com/alkiranet/govpp/api" + _ "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + sr_types "github.com/alkiranet/govpp/binapi/sr_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "sr_mpls" + APIVersion = "3.0.0" + VersionCrc = 0x156edb17 +) + +// MPLS SR policy add +// - bsid - is the bindingSID of the SR Policy. MPLS label (20bit) +// - weight - is the weight of the sid list. optional. +// - is_spray - is the type of the SR policy. (0.Default // 1.Spray) +// - segments - vector of labels (20bit) composing the segment list +// +// SrMplsPolicyAdd defines message 'sr_mpls_policy_add'. +type SrMplsPolicyAdd struct { + Bsid uint32 `binapi:"u32,name=bsid" json:"bsid,omitempty"` + Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` + IsSpray bool `binapi:"bool,name=is_spray" json:"is_spray,omitempty"` + NSegments uint8 `binapi:"u8,name=n_segments" json:"-"` + Segments []uint32 `binapi:"u32[n_segments],name=segments" json:"segments,omitempty"` +} + +func (m *SrMplsPolicyAdd) Reset() { *m = SrMplsPolicyAdd{} } +func (*SrMplsPolicyAdd) GetMessageName() string { return "sr_mpls_policy_add" } +func (*SrMplsPolicyAdd) GetCrcString() string { return "a1a70c70" } +func (*SrMplsPolicyAdd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrMplsPolicyAdd) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Bsid + size += 4 // m.Weight + size += 1 // m.IsSpray + size += 1 // m.NSegments + size += 4 * len(m.Segments) // m.Segments + return size +} +func (m *SrMplsPolicyAdd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Bsid) + buf.EncodeUint32(m.Weight) + buf.EncodeBool(m.IsSpray) + buf.EncodeUint8(uint8(len(m.Segments))) + for i := 0; i < len(m.Segments); i++ { + var x uint32 + if i < len(m.Segments) { + x = uint32(m.Segments[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *SrMplsPolicyAdd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Bsid = buf.DecodeUint32() + m.Weight = buf.DecodeUint32() + m.IsSpray = buf.DecodeBool() + m.NSegments = buf.DecodeUint8() + m.Segments = make([]uint32, m.NSegments) + for i := 0; i < len(m.Segments); i++ { + m.Segments[i] = buf.DecodeUint32() + } + return nil +} + +// SrMplsPolicyAddReply defines message 'sr_mpls_policy_add_reply'. +type SrMplsPolicyAddReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SrMplsPolicyAddReply) Reset() { *m = SrMplsPolicyAddReply{} } +func (*SrMplsPolicyAddReply) GetMessageName() string { return "sr_mpls_policy_add_reply" } +func (*SrMplsPolicyAddReply) GetCrcString() string { return "e8d4e804" } +func (*SrMplsPolicyAddReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrMplsPolicyAddReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrMplsPolicyAddReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrMplsPolicyAddReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// MPLS SR steering add/del +// - bsid is the bindingSID of the SR Policy +// - endpoint is the endpoint of the SR policy +// - color is the color of the sr policy +// +// SrMplsPolicyAssignEndpointColor defines message 'sr_mpls_policy_assign_endpoint_color'. +type SrMplsPolicyAssignEndpointColor struct { + Bsid uint32 `binapi:"u32,name=bsid" json:"bsid,omitempty"` + Endpoint ip_types.Address `binapi:"address,name=endpoint" json:"endpoint,omitempty"` + Color uint32 `binapi:"u32,name=color" json:"color,omitempty"` +} + +func (m *SrMplsPolicyAssignEndpointColor) Reset() { *m = SrMplsPolicyAssignEndpointColor{} } +func (*SrMplsPolicyAssignEndpointColor) GetMessageName() string { + return "sr_mpls_policy_assign_endpoint_color" +} +func (*SrMplsPolicyAssignEndpointColor) GetCrcString() string { return "0e7eb978" } +func (*SrMplsPolicyAssignEndpointColor) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrMplsPolicyAssignEndpointColor) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Bsid + size += 1 // m.Endpoint.Af + size += 1 * 16 // m.Endpoint.Un + size += 4 // m.Color + return size +} +func (m *SrMplsPolicyAssignEndpointColor) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Bsid) + buf.EncodeUint8(uint8(m.Endpoint.Af)) + buf.EncodeBytes(m.Endpoint.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.Color) + return buf.Bytes(), nil +} +func (m *SrMplsPolicyAssignEndpointColor) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Bsid = buf.DecodeUint32() + m.Endpoint.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Endpoint.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Color = buf.DecodeUint32() + return nil +} + +// SrMplsPolicyAssignEndpointColorReply defines message 'sr_mpls_policy_assign_endpoint_color_reply'. +type SrMplsPolicyAssignEndpointColorReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SrMplsPolicyAssignEndpointColorReply) Reset() { *m = SrMplsPolicyAssignEndpointColorReply{} } +func (*SrMplsPolicyAssignEndpointColorReply) GetMessageName() string { + return "sr_mpls_policy_assign_endpoint_color_reply" +} +func (*SrMplsPolicyAssignEndpointColorReply) GetCrcString() string { return "e8d4e804" } +func (*SrMplsPolicyAssignEndpointColorReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrMplsPolicyAssignEndpointColorReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrMplsPolicyAssignEndpointColorReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrMplsPolicyAssignEndpointColorReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// MPLS SR policy deletion +// - bsid is the bindingSID of the SR Policy. MPLS label (20bit) +// +// SrMplsPolicyDel defines message 'sr_mpls_policy_del'. +type SrMplsPolicyDel struct { + Bsid uint32 `binapi:"u32,name=bsid" json:"bsid,omitempty"` +} + +func (m *SrMplsPolicyDel) Reset() { *m = SrMplsPolicyDel{} } +func (*SrMplsPolicyDel) GetMessageName() string { return "sr_mpls_policy_del" } +func (*SrMplsPolicyDel) GetCrcString() string { return "e29d34fa" } +func (*SrMplsPolicyDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrMplsPolicyDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Bsid + return size +} +func (m *SrMplsPolicyDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Bsid) + return buf.Bytes(), nil +} +func (m *SrMplsPolicyDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Bsid = buf.DecodeUint32() + return nil +} + +// SrMplsPolicyDelReply defines message 'sr_mpls_policy_del_reply'. +type SrMplsPolicyDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SrMplsPolicyDelReply) Reset() { *m = SrMplsPolicyDelReply{} } +func (*SrMplsPolicyDelReply) GetMessageName() string { return "sr_mpls_policy_del_reply" } +func (*SrMplsPolicyDelReply) GetCrcString() string { return "e8d4e804" } +func (*SrMplsPolicyDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrMplsPolicyDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrMplsPolicyDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrMplsPolicyDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// MPLS SR policy modification +// - bsid is the bindingSID of the SR Policy. MPLS label (20bit) +// - sr_policy_index is the index of the SR policy +// - fib_table is the VRF where to install the FIB entry for the BSID +// - operation is the operation to perform (among the top ones) +// - segments is a vector of MPLS labels composing the segment list +// - sl_index is the index of the Segment List to modify/delete +// - weight is the weight of the sid list. optional. +// - is_encap Mode. Encapsulation or SRH insertion. +// +// SrMplsPolicyMod defines message 'sr_mpls_policy_mod'. +type SrMplsPolicyMod struct { + Bsid uint32 `binapi:"u32,name=bsid" json:"bsid,omitempty"` + Operation sr_types.SrPolicyOp `binapi:"sr_policy_op,name=operation" json:"operation,omitempty"` + SlIndex uint32 `binapi:"u32,name=sl_index" json:"sl_index,omitempty"` + Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` + NSegments uint8 `binapi:"u8,name=n_segments" json:"-"` + Segments []uint32 `binapi:"u32[n_segments],name=segments" json:"segments,omitempty"` +} + +func (m *SrMplsPolicyMod) Reset() { *m = SrMplsPolicyMod{} } +func (*SrMplsPolicyMod) GetMessageName() string { return "sr_mpls_policy_mod" } +func (*SrMplsPolicyMod) GetCrcString() string { return "88482c17" } +func (*SrMplsPolicyMod) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrMplsPolicyMod) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Bsid + size += 1 // m.Operation + size += 4 // m.SlIndex + size += 4 // m.Weight + size += 1 // m.NSegments + size += 4 * len(m.Segments) // m.Segments + return size +} +func (m *SrMplsPolicyMod) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Bsid) + buf.EncodeUint8(uint8(m.Operation)) + buf.EncodeUint32(m.SlIndex) + buf.EncodeUint32(m.Weight) + buf.EncodeUint8(uint8(len(m.Segments))) + for i := 0; i < len(m.Segments); i++ { + var x uint32 + if i < len(m.Segments) { + x = uint32(m.Segments[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *SrMplsPolicyMod) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Bsid = buf.DecodeUint32() + m.Operation = sr_types.SrPolicyOp(buf.DecodeUint8()) + m.SlIndex = buf.DecodeUint32() + m.Weight = buf.DecodeUint32() + m.NSegments = buf.DecodeUint8() + m.Segments = make([]uint32, m.NSegments) + for i := 0; i < len(m.Segments); i++ { + m.Segments[i] = buf.DecodeUint32() + } + return nil +} + +// SrMplsPolicyModReply defines message 'sr_mpls_policy_mod_reply'. +type SrMplsPolicyModReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SrMplsPolicyModReply) Reset() { *m = SrMplsPolicyModReply{} } +func (*SrMplsPolicyModReply) GetMessageName() string { return "sr_mpls_policy_mod_reply" } +func (*SrMplsPolicyModReply) GetCrcString() string { return "e8d4e804" } +func (*SrMplsPolicyModReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrMplsPolicyModReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrMplsPolicyModReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrMplsPolicyModReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// MPLS SR steering add/del +// - is_del +// - bsid - is the bindingSID of the SR Policy (~0 is no bsid) +// - table_id - is the VRF where to install the FIB entry for the BSID +// - prefix - is the IPv4/v6 address for L3 traffic type. +// - mask_width - is the mask for L3 traffic type +// - next_hop - describes the next_hop (in case no BSID) +// - color - describes the color +// - co_bits - are the CO_bits of the steering policy +// - vpn_label - is an additonal last VPN label. (~0 is no label) +// +// SrMplsSteeringAddDel defines message 'sr_mpls_steering_add_del'. +type SrMplsSteeringAddDel struct { + IsDel bool `binapi:"bool,name=is_del,default=false" json:"is_del,omitempty"` + Bsid uint32 `binapi:"u32,name=bsid" json:"bsid,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + Prefix ip_types.Prefix `binapi:"prefix,name=prefix" json:"prefix,omitempty"` + MaskWidth uint32 `binapi:"u32,name=mask_width" json:"mask_width,omitempty"` + NextHop ip_types.Address `binapi:"address,name=next_hop" json:"next_hop,omitempty"` + Color uint32 `binapi:"u32,name=color" json:"color,omitempty"` + CoBits uint8 `binapi:"u8,name=co_bits" json:"co_bits,omitempty"` + VPNLabel uint32 `binapi:"u32,name=vpn_label" json:"vpn_label,omitempty"` +} + +func (m *SrMplsSteeringAddDel) Reset() { *m = SrMplsSteeringAddDel{} } +func (*SrMplsSteeringAddDel) GetMessageName() string { return "sr_mpls_steering_add_del" } +func (*SrMplsSteeringAddDel) GetCrcString() string { return "64acff63" } +func (*SrMplsSteeringAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrMplsSteeringAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsDel + size += 4 // m.Bsid + size += 4 // m.TableID + size += 1 // m.Prefix.Address.Af + size += 1 * 16 // m.Prefix.Address.Un + size += 1 // m.Prefix.Len + size += 4 // m.MaskWidth + size += 1 // m.NextHop.Af + size += 1 * 16 // m.NextHop.Un + size += 4 // m.Color + size += 1 // m.CoBits + size += 4 // m.VPNLabel + return size +} +func (m *SrMplsSteeringAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsDel) + buf.EncodeUint32(m.Bsid) + buf.EncodeUint32(m.TableID) + buf.EncodeUint8(uint8(m.Prefix.Address.Af)) + buf.EncodeBytes(m.Prefix.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Prefix.Len) + buf.EncodeUint32(m.MaskWidth) + buf.EncodeUint8(uint8(m.NextHop.Af)) + buf.EncodeBytes(m.NextHop.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.Color) + buf.EncodeUint8(m.CoBits) + buf.EncodeUint32(m.VPNLabel) + return buf.Bytes(), nil +} +func (m *SrMplsSteeringAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsDel = buf.DecodeBool() + m.Bsid = buf.DecodeUint32() + m.TableID = buf.DecodeUint32() + m.Prefix.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Prefix.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Prefix.Len = buf.DecodeUint8() + m.MaskWidth = buf.DecodeUint32() + m.NextHop.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.NextHop.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Color = buf.DecodeUint32() + m.CoBits = buf.DecodeUint8() + m.VPNLabel = buf.DecodeUint32() + return nil +} + +// SrMplsSteeringAddDelReply defines message 'sr_mpls_steering_add_del_reply'. +type SrMplsSteeringAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SrMplsSteeringAddDelReply) Reset() { *m = SrMplsSteeringAddDelReply{} } +func (*SrMplsSteeringAddDelReply) GetMessageName() string { return "sr_mpls_steering_add_del_reply" } +func (*SrMplsSteeringAddDelReply) GetCrcString() string { return "e8d4e804" } +func (*SrMplsSteeringAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrMplsSteeringAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrMplsSteeringAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrMplsSteeringAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_sr_mpls_binapi_init() } +func file_sr_mpls_binapi_init() { + api.RegisterMessage((*SrMplsPolicyAdd)(nil), "sr_mpls_policy_add_a1a70c70") + api.RegisterMessage((*SrMplsPolicyAddReply)(nil), "sr_mpls_policy_add_reply_e8d4e804") + api.RegisterMessage((*SrMplsPolicyAssignEndpointColor)(nil), "sr_mpls_policy_assign_endpoint_color_0e7eb978") + api.RegisterMessage((*SrMplsPolicyAssignEndpointColorReply)(nil), "sr_mpls_policy_assign_endpoint_color_reply_e8d4e804") + api.RegisterMessage((*SrMplsPolicyDel)(nil), "sr_mpls_policy_del_e29d34fa") + api.RegisterMessage((*SrMplsPolicyDelReply)(nil), "sr_mpls_policy_del_reply_e8d4e804") + api.RegisterMessage((*SrMplsPolicyMod)(nil), "sr_mpls_policy_mod_88482c17") + api.RegisterMessage((*SrMplsPolicyModReply)(nil), "sr_mpls_policy_mod_reply_e8d4e804") + api.RegisterMessage((*SrMplsSteeringAddDel)(nil), "sr_mpls_steering_add_del_64acff63") + api.RegisterMessage((*SrMplsSteeringAddDelReply)(nil), "sr_mpls_steering_add_del_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*SrMplsPolicyAdd)(nil), + (*SrMplsPolicyAddReply)(nil), + (*SrMplsPolicyAssignEndpointColor)(nil), + (*SrMplsPolicyAssignEndpointColorReply)(nil), + (*SrMplsPolicyDel)(nil), + (*SrMplsPolicyDelReply)(nil), + (*SrMplsPolicyMod)(nil), + (*SrMplsPolicyModReply)(nil), + (*SrMplsSteeringAddDel)(nil), + (*SrMplsSteeringAddDelReply)(nil), + } +} diff --git a/binapi/sr_mpls/sr_mpls_rpc.ba.go b/binapi/sr_mpls/sr_mpls_rpc.ba.go new file mode 100644 index 00000000..3bf389f3 --- /dev/null +++ b/binapi/sr_mpls/sr_mpls_rpc.ba.go @@ -0,0 +1,71 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package sr_mpls + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service sr_mpls. +type RPCService interface { + SrMplsPolicyAdd(ctx context.Context, in *SrMplsPolicyAdd) (*SrMplsPolicyAddReply, error) + SrMplsPolicyAssignEndpointColor(ctx context.Context, in *SrMplsPolicyAssignEndpointColor) (*SrMplsPolicyAssignEndpointColorReply, error) + SrMplsPolicyDel(ctx context.Context, in *SrMplsPolicyDel) (*SrMplsPolicyDelReply, error) + SrMplsPolicyMod(ctx context.Context, in *SrMplsPolicyMod) (*SrMplsPolicyModReply, error) + SrMplsSteeringAddDel(ctx context.Context, in *SrMplsSteeringAddDel) (*SrMplsSteeringAddDelReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) SrMplsPolicyAdd(ctx context.Context, in *SrMplsPolicyAdd) (*SrMplsPolicyAddReply, error) { + out := new(SrMplsPolicyAddReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SrMplsPolicyAssignEndpointColor(ctx context.Context, in *SrMplsPolicyAssignEndpointColor) (*SrMplsPolicyAssignEndpointColorReply, error) { + out := new(SrMplsPolicyAssignEndpointColorReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SrMplsPolicyDel(ctx context.Context, in *SrMplsPolicyDel) (*SrMplsPolicyDelReply, error) { + out := new(SrMplsPolicyDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SrMplsPolicyMod(ctx context.Context, in *SrMplsPolicyMod) (*SrMplsPolicyModReply, error) { + out := new(SrMplsPolicyModReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SrMplsSteeringAddDel(ctx context.Context, in *SrMplsSteeringAddDel) (*SrMplsSteeringAddDelReply, error) { + out := new(SrMplsSteeringAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/sr_pt/sr_pt.ba.go b/binapi/sr_pt/sr_pt.ba.go new file mode 100644 index 00000000..b6dab8de --- /dev/null +++ b/binapi/sr_pt/sr_pt.ba.go @@ -0,0 +1,286 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/sr_pt.api.json + +// Package sr_pt contains generated bindings for API file sr_pt.api. +// +// Contents: +// - 6 messages +package sr_pt + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "sr_pt" + APIVersion = "1.0.0" + VersionCrc = 0x1fddedad +) + +// SR PT iface add request +// - sw_if_index - index of the interface to add to SR PT +// - id - SR PT interface id +// - ingress_load - incoming interface load +// - egress_load - outgoing interface load +// - tts_template - truncated timestamp template to use +// +// SrPtIfaceAdd defines message 'sr_pt_iface_add'. +type SrPtIfaceAdd struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + ID uint16 `binapi:"u16,name=id" json:"id,omitempty"` + IngressLoad uint8 `binapi:"u8,name=ingress_load" json:"ingress_load,omitempty"` + EgressLoad uint8 `binapi:"u8,name=egress_load" json:"egress_load,omitempty"` + TtsTemplate uint8 `binapi:"u8,name=tts_template" json:"tts_template,omitempty"` +} + +func (m *SrPtIfaceAdd) Reset() { *m = SrPtIfaceAdd{} } +func (*SrPtIfaceAdd) GetMessageName() string { return "sr_pt_iface_add" } +func (*SrPtIfaceAdd) GetCrcString() string { return "852c0cda" } +func (*SrPtIfaceAdd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrPtIfaceAdd) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 2 // m.ID + size += 1 // m.IngressLoad + size += 1 // m.EgressLoad + size += 1 // m.TtsTemplate + return size +} +func (m *SrPtIfaceAdd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint16(m.ID) + buf.EncodeUint8(m.IngressLoad) + buf.EncodeUint8(m.EgressLoad) + buf.EncodeUint8(m.TtsTemplate) + return buf.Bytes(), nil +} +func (m *SrPtIfaceAdd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.ID = buf.DecodeUint16() + m.IngressLoad = buf.DecodeUint8() + m.EgressLoad = buf.DecodeUint8() + m.TtsTemplate = buf.DecodeUint8() + return nil +} + +// SrPtIfaceAddReply defines message 'sr_pt_iface_add_reply'. +type SrPtIfaceAddReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SrPtIfaceAddReply) Reset() { *m = SrPtIfaceAddReply{} } +func (*SrPtIfaceAddReply) GetMessageName() string { return "sr_pt_iface_add_reply" } +func (*SrPtIfaceAddReply) GetCrcString() string { return "e8d4e804" } +func (*SrPtIfaceAddReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrPtIfaceAddReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrPtIfaceAddReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrPtIfaceAddReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// SR PT iface del request +// - sw_if_index - index of the interface to delete from SR PT +// +// SrPtIfaceDel defines message 'sr_pt_iface_del'. +type SrPtIfaceDel struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *SrPtIfaceDel) Reset() { *m = SrPtIfaceDel{} } +func (*SrPtIfaceDel) GetMessageName() string { return "sr_pt_iface_del" } +func (*SrPtIfaceDel) GetCrcString() string { return "f9e6675e" } +func (*SrPtIfaceDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrPtIfaceDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *SrPtIfaceDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *SrPtIfaceDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// SrPtIfaceDelReply defines message 'sr_pt_iface_del_reply'. +type SrPtIfaceDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SrPtIfaceDelReply) Reset() { *m = SrPtIfaceDelReply{} } +func (*SrPtIfaceDelReply) GetMessageName() string { return "sr_pt_iface_del_reply" } +func (*SrPtIfaceDelReply) GetCrcString() string { return "e8d4e804" } +func (*SrPtIfaceDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrPtIfaceDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SrPtIfaceDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SrPtIfaceDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// SrPtIfaceDetails defines message 'sr_pt_iface_details'. +type SrPtIfaceDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + ID uint16 `binapi:"u16,name=id" json:"id,omitempty"` + IngressLoad uint8 `binapi:"u8,name=ingress_load" json:"ingress_load,omitempty"` + EgressLoad uint8 `binapi:"u8,name=egress_load" json:"egress_load,omitempty"` + TtsTemplate uint8 `binapi:"u8,name=tts_template" json:"tts_template,omitempty"` +} + +func (m *SrPtIfaceDetails) Reset() { *m = SrPtIfaceDetails{} } +func (*SrPtIfaceDetails) GetMessageName() string { return "sr_pt_iface_details" } +func (*SrPtIfaceDetails) GetCrcString() string { return "1f472f85" } +func (*SrPtIfaceDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SrPtIfaceDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 2 // m.ID + size += 1 // m.IngressLoad + size += 1 // m.EgressLoad + size += 1 // m.TtsTemplate + return size +} +func (m *SrPtIfaceDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint16(m.ID) + buf.EncodeUint8(m.IngressLoad) + buf.EncodeUint8(m.EgressLoad) + buf.EncodeUint8(m.TtsTemplate) + return buf.Bytes(), nil +} +func (m *SrPtIfaceDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.ID = buf.DecodeUint16() + m.IngressLoad = buf.DecodeUint8() + m.EgressLoad = buf.DecodeUint8() + m.TtsTemplate = buf.DecodeUint8() + return nil +} + +// SR PT iface dump request +// SrPtIfaceDump defines message 'sr_pt_iface_dump'. +type SrPtIfaceDump struct{} + +func (m *SrPtIfaceDump) Reset() { *m = SrPtIfaceDump{} } +func (*SrPtIfaceDump) GetMessageName() string { return "sr_pt_iface_dump" } +func (*SrPtIfaceDump) GetCrcString() string { return "51077d14" } +func (*SrPtIfaceDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SrPtIfaceDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SrPtIfaceDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SrPtIfaceDump) Unmarshal(b []byte) error { + return nil +} + +func init() { file_sr_pt_binapi_init() } +func file_sr_pt_binapi_init() { + api.RegisterMessage((*SrPtIfaceAdd)(nil), "sr_pt_iface_add_852c0cda") + api.RegisterMessage((*SrPtIfaceAddReply)(nil), "sr_pt_iface_add_reply_e8d4e804") + api.RegisterMessage((*SrPtIfaceDel)(nil), "sr_pt_iface_del_f9e6675e") + api.RegisterMessage((*SrPtIfaceDelReply)(nil), "sr_pt_iface_del_reply_e8d4e804") + api.RegisterMessage((*SrPtIfaceDetails)(nil), "sr_pt_iface_details_1f472f85") + api.RegisterMessage((*SrPtIfaceDump)(nil), "sr_pt_iface_dump_51077d14") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*SrPtIfaceAdd)(nil), + (*SrPtIfaceAddReply)(nil), + (*SrPtIfaceDel)(nil), + (*SrPtIfaceDelReply)(nil), + (*SrPtIfaceDetails)(nil), + (*SrPtIfaceDump)(nil), + } +} diff --git a/binapi/sr_pt/sr_pt_rpc.ba.go b/binapi/sr_pt/sr_pt_rpc.ba.go new file mode 100644 index 00000000..b20448c4 --- /dev/null +++ b/binapi/sr_pt/sr_pt_rpc.ba.go @@ -0,0 +1,88 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package sr_pt + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service sr_pt. +type RPCService interface { + SrPtIfaceAdd(ctx context.Context, in *SrPtIfaceAdd) (*SrPtIfaceAddReply, error) + SrPtIfaceDel(ctx context.Context, in *SrPtIfaceDel) (*SrPtIfaceDelReply, error) + SrPtIfaceDump(ctx context.Context, in *SrPtIfaceDump) (RPCService_SrPtIfaceDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) SrPtIfaceAdd(ctx context.Context, in *SrPtIfaceAdd) (*SrPtIfaceAddReply, error) { + out := new(SrPtIfaceAddReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SrPtIfaceDel(ctx context.Context, in *SrPtIfaceDel) (*SrPtIfaceDelReply, error) { + out := new(SrPtIfaceDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SrPtIfaceDump(ctx context.Context, in *SrPtIfaceDump) (RPCService_SrPtIfaceDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SrPtIfaceDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SrPtIfaceDumpClient interface { + Recv() (*SrPtIfaceDetails, error) + api.Stream +} + +type serviceClient_SrPtIfaceDumpClient struct { + api.Stream +} + +func (c *serviceClient_SrPtIfaceDumpClient) Recv() (*SrPtIfaceDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SrPtIfaceDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/sr_types/sr_types.ba.go b/binapi/sr_types/sr_types.ba.go new file mode 100644 index 00000000..55e095df --- /dev/null +++ b/binapi/sr_types/sr_types.ba.go @@ -0,0 +1,143 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/sr_types.api.json + +// Package sr_types contains generated bindings for API file sr_types.api. +// +// Contents: +// - 3 enums +package sr_types + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "sr_types" + APIVersion = "1.0.0" + VersionCrc = 0x7955bd50 +) + +// SrBehavior defines enum 'sr_behavior'. +type SrBehavior uint8 + +const ( + SR_BEHAVIOR_API_END SrBehavior = 1 + SR_BEHAVIOR_API_X SrBehavior = 2 + SR_BEHAVIOR_API_T SrBehavior = 3 + SR_BEHAVIOR_API_D_FIRST SrBehavior = 4 + SR_BEHAVIOR_API_DX2 SrBehavior = 5 + SR_BEHAVIOR_API_DX6 SrBehavior = 6 + SR_BEHAVIOR_API_DX4 SrBehavior = 7 + SR_BEHAVIOR_API_DT6 SrBehavior = 8 + SR_BEHAVIOR_API_DT4 SrBehavior = 9 + SR_BEHAVIOR_API_LAST SrBehavior = 10 +) + +var ( + SrBehavior_name = map[uint8]string{ + 1: "SR_BEHAVIOR_API_END", + 2: "SR_BEHAVIOR_API_X", + 3: "SR_BEHAVIOR_API_T", + 4: "SR_BEHAVIOR_API_D_FIRST", + 5: "SR_BEHAVIOR_API_DX2", + 6: "SR_BEHAVIOR_API_DX6", + 7: "SR_BEHAVIOR_API_DX4", + 8: "SR_BEHAVIOR_API_DT6", + 9: "SR_BEHAVIOR_API_DT4", + 10: "SR_BEHAVIOR_API_LAST", + } + SrBehavior_value = map[string]uint8{ + "SR_BEHAVIOR_API_END": 1, + "SR_BEHAVIOR_API_X": 2, + "SR_BEHAVIOR_API_T": 3, + "SR_BEHAVIOR_API_D_FIRST": 4, + "SR_BEHAVIOR_API_DX2": 5, + "SR_BEHAVIOR_API_DX6": 6, + "SR_BEHAVIOR_API_DX4": 7, + "SR_BEHAVIOR_API_DT6": 8, + "SR_BEHAVIOR_API_DT4": 9, + "SR_BEHAVIOR_API_LAST": 10, + } +) + +func (x SrBehavior) String() string { + s, ok := SrBehavior_name[uint8(x)] + if ok { + return s + } + return "SrBehavior(" + strconv.Itoa(int(x)) + ")" +} + +// SrPolicyOp defines enum 'sr_policy_op'. +type SrPolicyOp uint8 + +const ( + SR_POLICY_OP_API_NONE SrPolicyOp = 0 + SR_POLICY_OP_API_ADD SrPolicyOp = 1 + SR_POLICY_OP_API_DEL SrPolicyOp = 2 + SR_POLICY_OP_API_MOD SrPolicyOp = 3 +) + +var ( + SrPolicyOp_name = map[uint8]string{ + 0: "SR_POLICY_OP_API_NONE", + 1: "SR_POLICY_OP_API_ADD", + 2: "SR_POLICY_OP_API_DEL", + 3: "SR_POLICY_OP_API_MOD", + } + SrPolicyOp_value = map[string]uint8{ + "SR_POLICY_OP_API_NONE": 0, + "SR_POLICY_OP_API_ADD": 1, + "SR_POLICY_OP_API_DEL": 2, + "SR_POLICY_OP_API_MOD": 3, + } +) + +func (x SrPolicyOp) String() string { + s, ok := SrPolicyOp_name[uint8(x)] + if ok { + return s + } + return "SrPolicyOp(" + strconv.Itoa(int(x)) + ")" +} + +// SrSteer defines enum 'sr_steer'. +type SrSteer uint8 + +const ( + SR_STEER_API_L2 SrSteer = 2 + SR_STEER_API_IPV4 SrSteer = 4 + SR_STEER_API_IPV6 SrSteer = 6 +) + +var ( + SrSteer_name = map[uint8]string{ + 2: "SR_STEER_API_L2", + 4: "SR_STEER_API_IPV4", + 6: "SR_STEER_API_IPV6", + } + SrSteer_value = map[string]uint8{ + "SR_STEER_API_L2": 2, + "SR_STEER_API_IPV4": 4, + "SR_STEER_API_IPV6": 6, + } +) + +func (x SrSteer) String() string { + s, ok := SrSteer_name[uint8(x)] + if ok { + return s + } + return "SrSteer(" + strconv.Itoa(int(x)) + ")" +} diff --git a/binapi/stn/stn.ba.go b/binapi/stn/stn.ba.go new file mode 100644 index 00000000..ee1b475c --- /dev/null +++ b/binapi/stn/stn.ba.go @@ -0,0 +1,203 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/stn.api.json + +// Package stn contains generated bindings for API file stn.api. +// +// Contents: +// - 4 messages +package stn + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "stn" + APIVersion = "2.0.0" + VersionCrc = 0x9cfaef64 +) + +// Add/del STN rules +// - ip_address - STN rule IP address +// - sw_if_index - Interface index +// - is_add - 1 if add, 0 if delete +// +// StnAddDelRule defines message 'stn_add_del_rule'. +type StnAddDelRule struct { + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` +} + +func (m *StnAddDelRule) Reset() { *m = StnAddDelRule{} } +func (*StnAddDelRule) GetMessageName() string { return "stn_add_del_rule" } +func (*StnAddDelRule) GetCrcString() string { return "224c6edd" } +func (*StnAddDelRule) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *StnAddDelRule) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + size += 4 // m.SwIfIndex + size += 1 // m.IsAdd + return size +} +func (m *StnAddDelRule) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *StnAddDelRule) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsAdd = buf.DecodeBool() + return nil +} + +// StnAddDelRuleReply defines message 'stn_add_del_rule_reply'. +type StnAddDelRuleReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *StnAddDelRuleReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *StnAddDelRuleReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *StnAddDelRuleReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// STN response to rules request +// - is_ip4 - 1 if address type is IPv4 +// - ip_address - IP address +// - sw_if_index - Interface index +// +// StnRulesDetails defines message 'stn_rules_details'. +type StnRulesDetails struct { + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *StnRulesDetails) Reset() { *m = StnRulesDetails{} } +func (*StnRulesDetails) GetMessageName() string { return "stn_rules_details" } +func (*StnRulesDetails) GetCrcString() string { return "a51935a6" } +func (*StnRulesDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *StnRulesDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IPAddress.Af + size += 1 * 16 // m.IPAddress.Un + size += 4 // m.SwIfIndex + return size +} +func (m *StnRulesDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.IPAddress.Af)) + buf.EncodeBytes(m.IPAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *StnRulesDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Dump STN rules +// StnRulesDump defines 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 (m *StnRulesDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *StnRulesDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *StnRulesDump) Unmarshal(b []byte) error { + return nil +} + +func init() { file_stn_binapi_init() } +func file_stn_binapi_init() { + api.RegisterMessage((*StnAddDelRule)(nil), "stn_add_del_rule_224c6edd") + api.RegisterMessage((*StnAddDelRuleReply)(nil), "stn_add_del_rule_reply_e8d4e804") + api.RegisterMessage((*StnRulesDetails)(nil), "stn_rules_details_a51935a6") + api.RegisterMessage((*StnRulesDump)(nil), "stn_rules_dump_51077d14") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*StnAddDelRule)(nil), + (*StnAddDelRuleReply)(nil), + (*StnRulesDetails)(nil), + (*StnRulesDump)(nil), + } +} diff --git a/binapi/stn/stn_rpc.ba.go b/binapi/stn/stn_rpc.ba.go new file mode 100644 index 00000000..bb619544 --- /dev/null +++ b/binapi/stn/stn_rpc.ba.go @@ -0,0 +1,78 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package stn + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service stn. +type RPCService interface { + StnAddDelRule(ctx context.Context, in *StnAddDelRule) (*StnAddDelRuleReply, error) + StnRulesDump(ctx context.Context, in *StnRulesDump) (RPCService_StnRulesDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) StnAddDelRule(ctx context.Context, in *StnAddDelRule) (*StnAddDelRuleReply, error) { + out := new(StnAddDelRuleReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) StnRulesDump(ctx context.Context, in *StnRulesDump) (RPCService_StnRulesDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_StnRulesDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_StnRulesDumpClient interface { + Recv() (*StnRulesDetails, error) + api.Stream +} + +type serviceClient_StnRulesDumpClient struct { + api.Stream +} + +func (c *serviceClient_StnRulesDumpClient) Recv() (*StnRulesDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *StnRulesDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/svs/svs.ba.go b/binapi/svs/svs.ba.go new file mode 100644 index 00000000..811742fb --- /dev/null +++ b/binapi/svs/svs.ba.go @@ -0,0 +1,462 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/svs.api.json + +// Package svs contains generated bindings for API file svs.api. +// +// Contents: +// - 10 messages +package svs + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "svs" + APIVersion = "1.0.0" + VersionCrc = 0x816cf275 +) + +// * @brief SVS table-id to interface mapping +// - - af - Address Family +// - - table_id - The SVS table (from svs_table_add_del) +// - - sw_if_index - Interface +// +// SvsDetails defines message 'svs_details'. +type SvsDetails struct { + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Af ip_types.AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` +} + +func (m *SvsDetails) Reset() { *m = SvsDetails{} } +func (*SvsDetails) GetMessageName() string { return "svs_details" } +func (*SvsDetails) GetCrcString() string { return "6282cd55" } +func (*SvsDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SvsDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TableID + size += 4 // m.SwIfIndex + size += 1 // m.Af + return size +} +func (m *SvsDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TableID) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(uint8(m.Af)) + return buf.Bytes(), nil +} +func (m *SvsDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TableID = buf.DecodeUint32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Af = ip_types.AddressFamily(buf.DecodeUint8()) + return nil +} + +// * @brief Dump the SVS table mappings of table_id to interface +// - To see the routes added to a given table use ip_fib_dump() +// +// SvsDump defines message 'svs_dump'. +type SvsDump struct{} + +func (m *SvsDump) Reset() { *m = SvsDump{} } +func (*SvsDump) GetMessageName() string { return "svs_dump" } +func (*SvsDump) GetCrcString() string { return "51077d14" } +func (*SvsDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SvsDump) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SvsDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SvsDump) Unmarshal(b []byte) error { + return nil +} + +// * @brief Enable SVS on a given interface by using the given table to match +// - RX'd packets' source addresses +// - - af - Address Family +// - - table_id - The SVS table (from svs_table_add_del) +// - - sw_if_index - Interface +// +// SvsEnableDisable defines message 'svs_enable_disable'. +type SvsEnableDisable struct { + IsEnable bool `binapi:"bool,name=is_enable" json:"is_enable,omitempty"` + Af ip_types.AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *SvsEnableDisable) Reset() { *m = SvsEnableDisable{} } +func (*SvsEnableDisable) GetMessageName() string { return "svs_enable_disable" } +func (*SvsEnableDisable) GetCrcString() string { return "634b89d2" } +func (*SvsEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SvsEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsEnable + size += 1 // m.Af + size += 4 // m.TableID + size += 4 // m.SwIfIndex + return size +} +func (m *SvsEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsEnable) + buf.EncodeUint8(uint8(m.Af)) + buf.EncodeUint32(m.TableID) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *SvsEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsEnable = buf.DecodeBool() + m.Af = ip_types.AddressFamily(buf.DecodeUint8()) + m.TableID = buf.DecodeUint32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// SvsEnableDisableReply defines message 'svs_enable_disable_reply'. +type SvsEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SvsEnableDisableReply) Reset() { *m = SvsEnableDisableReply{} } +func (*SvsEnableDisableReply) GetMessageName() string { return "svs_enable_disable_reply" } +func (*SvsEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*SvsEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SvsEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SvsEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SvsEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// - brief Get the plugin version +// *- context - sender context, to match reply w/ request +// +// SvsPluginGetVersion defines message 'svs_plugin_get_version'. +type SvsPluginGetVersion struct{} + +func (m *SvsPluginGetVersion) Reset() { *m = SvsPluginGetVersion{} } +func (*SvsPluginGetVersion) GetMessageName() string { return "svs_plugin_get_version" } +func (*SvsPluginGetVersion) GetCrcString() string { return "51077d14" } +func (*SvsPluginGetVersion) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SvsPluginGetVersion) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SvsPluginGetVersion) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SvsPluginGetVersion) Unmarshal(b []byte) error { + return nil +} + +// * @brief Reply to get the plugin version +// - - major - Incremented every time a known breaking behavior change is introduced +// - - minor - Incremented with small changes, may be used to avoid buggy versions +// +// SvsPluginGetVersionReply defines message 'svs_plugin_get_version_reply'. +type SvsPluginGetVersionReply struct { + Major uint32 `binapi:"u32,name=major" json:"major,omitempty"` + Minor uint32 `binapi:"u32,name=minor" json:"minor,omitempty"` +} + +func (m *SvsPluginGetVersionReply) Reset() { *m = SvsPluginGetVersionReply{} } +func (*SvsPluginGetVersionReply) GetMessageName() string { return "svs_plugin_get_version_reply" } +func (*SvsPluginGetVersionReply) GetCrcString() string { return "9b32cf86" } +func (*SvsPluginGetVersionReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SvsPluginGetVersionReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Major + size += 4 // m.Minor + return size +} +func (m *SvsPluginGetVersionReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Major) + buf.EncodeUint32(m.Minor) + return buf.Bytes(), nil +} +func (m *SvsPluginGetVersionReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Major = buf.DecodeUint32() + m.Minor = buf.DecodeUint32() + return nil +} + +// * @brief Add a route into the source address matching table +// - - prefix - prefix +// - - table_id - The SVS table (from svs_table_add_del) +// - - source_table_id - This is the table ID that will be used for +// - the subsequent lookup of the packet. The V in SVS. +// - this table must exist (from e.g. ip_table_add_del) +// +// SvsRouteAddDel defines message 'svs_route_add_del'. +type SvsRouteAddDel struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + Prefix ip_types.Prefix `binapi:"prefix,name=prefix" json:"prefix,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + SourceTableID uint32 `binapi:"u32,name=source_table_id" json:"source_table_id,omitempty"` +} + +func (m *SvsRouteAddDel) Reset() { *m = SvsRouteAddDel{} } +func (*SvsRouteAddDel) GetMessageName() string { return "svs_route_add_del" } +func (*SvsRouteAddDel) GetCrcString() string { return "e49bc63c" } +func (*SvsRouteAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SvsRouteAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.Prefix.Address.Af + size += 1 * 16 // m.Prefix.Address.Un + size += 1 // m.Prefix.Len + size += 4 // m.TableID + size += 4 // m.SourceTableID + return size +} +func (m *SvsRouteAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint8(uint8(m.Prefix.Address.Af)) + buf.EncodeBytes(m.Prefix.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(m.Prefix.Len) + buf.EncodeUint32(m.TableID) + buf.EncodeUint32(m.SourceTableID) + return buf.Bytes(), nil +} +func (m *SvsRouteAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Prefix.Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Prefix.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Prefix.Len = buf.DecodeUint8() + m.TableID = buf.DecodeUint32() + m.SourceTableID = buf.DecodeUint32() + return nil +} + +// SvsRouteAddDelReply defines message 'svs_route_add_del_reply'. +type SvsRouteAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SvsRouteAddDelReply) Reset() { *m = SvsRouteAddDelReply{} } +func (*SvsRouteAddDelReply) GetMessageName() string { return "svs_route_add_del_reply" } +func (*SvsRouteAddDelReply) GetCrcString() string { return "e8d4e804" } +func (*SvsRouteAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SvsRouteAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SvsRouteAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SvsRouteAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// * @brief Add a table in which to add routes that will match against source +// - addresses +// - - af - Address Family +// - - table_id - User provided ID for the table +// - - is_add - add or delete +// +// SvsTableAddDel defines message 'svs_table_add_del'. +type SvsTableAddDel struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + Af ip_types.AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` +} + +func (m *SvsTableAddDel) Reset() { *m = SvsTableAddDel{} } +func (*SvsTableAddDel) GetMessageName() string { return "svs_table_add_del" } +func (*SvsTableAddDel) GetCrcString() string { return "7d21cb2a" } +func (*SvsTableAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SvsTableAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.Af + size += 4 // m.TableID + return size +} +func (m *SvsTableAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint8(uint8(m.Af)) + buf.EncodeUint32(m.TableID) + return buf.Bytes(), nil +} +func (m *SvsTableAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Af = ip_types.AddressFamily(buf.DecodeUint8()) + m.TableID = buf.DecodeUint32() + return nil +} + +// SvsTableAddDelReply defines message 'svs_table_add_del_reply'. +type SvsTableAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SvsTableAddDelReply) Reset() { *m = SvsTableAddDelReply{} } +func (*SvsTableAddDelReply) GetMessageName() string { return "svs_table_add_del_reply" } +func (*SvsTableAddDelReply) GetCrcString() string { return "e8d4e804" } +func (*SvsTableAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SvsTableAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SvsTableAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SvsTableAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_svs_binapi_init() } +func file_svs_binapi_init() { + api.RegisterMessage((*SvsDetails)(nil), "svs_details_6282cd55") + api.RegisterMessage((*SvsDump)(nil), "svs_dump_51077d14") + api.RegisterMessage((*SvsEnableDisable)(nil), "svs_enable_disable_634b89d2") + api.RegisterMessage((*SvsEnableDisableReply)(nil), "svs_enable_disable_reply_e8d4e804") + api.RegisterMessage((*SvsPluginGetVersion)(nil), "svs_plugin_get_version_51077d14") + api.RegisterMessage((*SvsPluginGetVersionReply)(nil), "svs_plugin_get_version_reply_9b32cf86") + api.RegisterMessage((*SvsRouteAddDel)(nil), "svs_route_add_del_e49bc63c") + api.RegisterMessage((*SvsRouteAddDelReply)(nil), "svs_route_add_del_reply_e8d4e804") + api.RegisterMessage((*SvsTableAddDel)(nil), "svs_table_add_del_7d21cb2a") + api.RegisterMessage((*SvsTableAddDelReply)(nil), "svs_table_add_del_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*SvsDetails)(nil), + (*SvsDump)(nil), + (*SvsEnableDisable)(nil), + (*SvsEnableDisableReply)(nil), + (*SvsPluginGetVersion)(nil), + (*SvsPluginGetVersionReply)(nil), + (*SvsRouteAddDel)(nil), + (*SvsRouteAddDelReply)(nil), + (*SvsTableAddDel)(nil), + (*SvsTableAddDelReply)(nil), + } +} diff --git a/binapi/svs/svs_rpc.ba.go b/binapi/svs/svs_rpc.ba.go new file mode 100644 index 00000000..c18e4409 --- /dev/null +++ b/binapi/svs/svs_rpc.ba.go @@ -0,0 +1,108 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package svs + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service svs. +type RPCService interface { + SvsDump(ctx context.Context, in *SvsDump) (RPCService_SvsDumpClient, error) + SvsEnableDisable(ctx context.Context, in *SvsEnableDisable) (*SvsEnableDisableReply, error) + SvsPluginGetVersion(ctx context.Context, in *SvsPluginGetVersion) (*SvsPluginGetVersionReply, error) + SvsRouteAddDel(ctx context.Context, in *SvsRouteAddDel) (*SvsRouteAddDelReply, error) + SvsTableAddDel(ctx context.Context, in *SvsTableAddDel) (*SvsTableAddDelReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) SvsDump(ctx context.Context, in *SvsDump) (RPCService_SvsDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SvsDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SvsDumpClient interface { + Recv() (*SvsDetails, error) + api.Stream +} + +type serviceClient_SvsDumpClient struct { + api.Stream +} + +func (c *serviceClient_SvsDumpClient) Recv() (*SvsDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SvsDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) SvsEnableDisable(ctx context.Context, in *SvsEnableDisable) (*SvsEnableDisableReply, error) { + out := new(SvsEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SvsPluginGetVersion(ctx context.Context, in *SvsPluginGetVersion) (*SvsPluginGetVersionReply, error) { + out := new(SvsPluginGetVersionReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) SvsRouteAddDel(ctx context.Context, in *SvsRouteAddDel) (*SvsRouteAddDelReply, error) { + out := new(SvsRouteAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SvsTableAddDel(ctx context.Context, in *SvsTableAddDel) (*SvsTableAddDelReply, error) { + out := new(SvsTableAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/syslog/syslog.ba.go b/binapi/syslog/syslog.ba.go new file mode 100644 index 00000000..c12fc25d --- /dev/null +++ b/binapi/syslog/syslog.ba.go @@ -0,0 +1,419 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/syslog.api.json + +// Package syslog contains generated bindings for API file syslog.api. +// +// Contents: +// - 1 enum +// - 8 messages +package syslog + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "syslog" + APIVersion = "1.0.0" + VersionCrc = 0x5ad12a74 +) + +// SyslogSeverity defines enum 'syslog_severity'. +type SyslogSeverity uint32 + +const ( + SYSLOG_API_SEVERITY_EMERG SyslogSeverity = 0 + SYSLOG_API_SEVERITY_ALERT SyslogSeverity = 1 + SYSLOG_API_SEVERITY_CRIT SyslogSeverity = 2 + SYSLOG_API_SEVERITY_ERR SyslogSeverity = 3 + SYSLOG_API_SEVERITY_WARN SyslogSeverity = 4 + SYSLOG_API_SEVERITY_NOTICE SyslogSeverity = 5 + SYSLOG_API_SEVERITY_INFO SyslogSeverity = 6 + SYSLOG_API_SEVERITY_DBG SyslogSeverity = 7 +) + +var ( + SyslogSeverity_name = map[uint32]string{ + 0: "SYSLOG_API_SEVERITY_EMERG", + 1: "SYSLOG_API_SEVERITY_ALERT", + 2: "SYSLOG_API_SEVERITY_CRIT", + 3: "SYSLOG_API_SEVERITY_ERR", + 4: "SYSLOG_API_SEVERITY_WARN", + 5: "SYSLOG_API_SEVERITY_NOTICE", + 6: "SYSLOG_API_SEVERITY_INFO", + 7: "SYSLOG_API_SEVERITY_DBG", + } + SyslogSeverity_value = map[string]uint32{ + "SYSLOG_API_SEVERITY_EMERG": 0, + "SYSLOG_API_SEVERITY_ALERT": 1, + "SYSLOG_API_SEVERITY_CRIT": 2, + "SYSLOG_API_SEVERITY_ERR": 3, + "SYSLOG_API_SEVERITY_WARN": 4, + "SYSLOG_API_SEVERITY_NOTICE": 5, + "SYSLOG_API_SEVERITY_INFO": 6, + "SYSLOG_API_SEVERITY_DBG": 7, + } +) + +func (x SyslogSeverity) String() string { + s, ok := SyslogSeverity_name[uint32(x)] + if ok { + return s + } + return "SyslogSeverity(" + strconv.Itoa(int(x)) + ")" +} + +// Get syslog filter +// SyslogGetFilter defines message 'syslog_get_filter'. +type SyslogGetFilter struct{} + +func (m *SyslogGetFilter) Reset() { *m = SyslogGetFilter{} } +func (*SyslogGetFilter) GetMessageName() string { return "syslog_get_filter" } +func (*SyslogGetFilter) GetCrcString() string { return "51077d14" } +func (*SyslogGetFilter) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SyslogGetFilter) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SyslogGetFilter) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SyslogGetFilter) Unmarshal(b []byte) error { + return nil +} + +// Get syslog filter reply +// - retval - return code for the request +// - severity - severity filter (specified severity and greater match) +// +// SyslogGetFilterReply defines message 'syslog_get_filter_reply'. +type SyslogGetFilterReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Severity SyslogSeverity `binapi:"syslog_severity,name=severity" json:"severity,omitempty"` +} + +func (m *SyslogGetFilterReply) Reset() { *m = SyslogGetFilterReply{} } +func (*SyslogGetFilterReply) GetMessageName() string { return "syslog_get_filter_reply" } +func (*SyslogGetFilterReply) GetCrcString() string { return "eb1833f8" } +func (*SyslogGetFilterReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SyslogGetFilterReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Severity + return size +} +func (m *SyslogGetFilterReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.Severity)) + return buf.Bytes(), nil +} +func (m *SyslogGetFilterReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Severity = SyslogSeverity(buf.DecodeUint32()) + return nil +} + +// Get syslog sender configuration +// SyslogGetSender defines message 'syslog_get_sender'. +type SyslogGetSender struct{} + +func (m *SyslogGetSender) Reset() { *m = SyslogGetSender{} } +func (*SyslogGetSender) GetMessageName() string { return "syslog_get_sender" } +func (*SyslogGetSender) GetCrcString() string { return "51077d14" } +func (*SyslogGetSender) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SyslogGetSender) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *SyslogGetSender) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *SyslogGetSender) Unmarshal(b []byte) error { + return nil +} + +// Get syslog sender configuration reply +// - retval - return code for the request +// - src_address - IPv4 address of syslog sender (source) +// - collector_address - IPv4 address of syslog collector (destination) +// - collector_port - UDP port of syslog collector (destination) +// - vrf_id - VRF/FIB table ID +// - max_msg_size - maximum message length +// +// SyslogGetSenderReply defines message 'syslog_get_sender_reply'. +type SyslogGetSenderReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SrcAddress ip_types.IP4Address `binapi:"ip4_address,name=src_address" json:"src_address,omitempty"` + CollectorAddress ip_types.IP4Address `binapi:"ip4_address,name=collector_address" json:"collector_address,omitempty"` + CollectorPort uint16 `binapi:"u16,name=collector_port" json:"collector_port,omitempty"` + VrfID uint32 `binapi:"u32,name=vrf_id" json:"vrf_id,omitempty"` + MaxMsgSize uint32 `binapi:"u32,name=max_msg_size" json:"max_msg_size,omitempty"` +} + +func (m *SyslogGetSenderReply) Reset() { *m = SyslogGetSenderReply{} } +func (*SyslogGetSenderReply) GetMessageName() string { return "syslog_get_sender_reply" } +func (*SyslogGetSenderReply) GetCrcString() string { return "424cfa4e" } +func (*SyslogGetSenderReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SyslogGetSenderReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 1 * 4 // m.SrcAddress + size += 1 * 4 // m.CollectorAddress + size += 2 // m.CollectorPort + size += 4 // m.VrfID + size += 4 // m.MaxMsgSize + return size +} +func (m *SyslogGetSenderReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeBytes(m.SrcAddress[:], 4) + buf.EncodeBytes(m.CollectorAddress[:], 4) + buf.EncodeUint16(m.CollectorPort) + buf.EncodeUint32(m.VrfID) + buf.EncodeUint32(m.MaxMsgSize) + return buf.Bytes(), nil +} +func (m *SyslogGetSenderReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + copy(m.SrcAddress[:], buf.DecodeBytes(4)) + copy(m.CollectorAddress[:], buf.DecodeBytes(4)) + m.CollectorPort = buf.DecodeUint16() + m.VrfID = buf.DecodeUint32() + m.MaxMsgSize = buf.DecodeUint32() + return nil +} + +// Set syslog filter +// - severity - severity filter (specified severity and greater match) +// +// SyslogSetFilter defines message 'syslog_set_filter'. +type SyslogSetFilter struct { + Severity SyslogSeverity `binapi:"syslog_severity,name=severity" json:"severity,omitempty"` +} + +func (m *SyslogSetFilter) Reset() { *m = SyslogSetFilter{} } +func (*SyslogSetFilter) GetMessageName() string { return "syslog_set_filter" } +func (*SyslogSetFilter) GetCrcString() string { return "571348c3" } +func (*SyslogSetFilter) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SyslogSetFilter) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Severity + return size +} +func (m *SyslogSetFilter) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Severity)) + return buf.Bytes(), nil +} +func (m *SyslogSetFilter) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Severity = SyslogSeverity(buf.DecodeUint32()) + return nil +} + +// SyslogSetFilterReply defines message 'syslog_set_filter_reply'. +type SyslogSetFilterReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SyslogSetFilterReply) Reset() { *m = SyslogSetFilterReply{} } +func (*SyslogSetFilterReply) GetMessageName() string { return "syslog_set_filter_reply" } +func (*SyslogSetFilterReply) GetCrcString() string { return "e8d4e804" } +func (*SyslogSetFilterReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SyslogSetFilterReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SyslogSetFilterReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SyslogSetFilterReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set syslog sender configuration +// - src_address - IPv4 address of syslog sender (source) +// - collector_address - IPv4 address of syslog collector (destination) +// - collector_port - UDP port of syslog collector (destination) Default: 514 +// - vrf_id - VRF/FIB table ID +// - max_msg_size - maximum message length. Default: 480 +// +// SyslogSetSender defines message 'syslog_set_sender'. +type SyslogSetSender struct { + SrcAddress ip_types.IP4Address `binapi:"ip4_address,name=src_address" json:"src_address,omitempty"` + CollectorAddress ip_types.IP4Address `binapi:"ip4_address,name=collector_address" json:"collector_address,omitempty"` + CollectorPort uint16 `binapi:"u16,name=collector_port,default=514" json:"collector_port,omitempty"` + VrfID uint32 `binapi:"u32,name=vrf_id" json:"vrf_id,omitempty"` + MaxMsgSize uint32 `binapi:"u32,name=max_msg_size,default=480" json:"max_msg_size,omitempty"` +} + +func (m *SyslogSetSender) Reset() { *m = SyslogSetSender{} } +func (*SyslogSetSender) GetMessageName() string { return "syslog_set_sender" } +func (*SyslogSetSender) GetCrcString() string { return "b8011d0b" } +func (*SyslogSetSender) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SyslogSetSender) Size() (size int) { + if m == nil { + return 0 + } + size += 1 * 4 // m.SrcAddress + size += 1 * 4 // m.CollectorAddress + size += 2 // m.CollectorPort + size += 4 // m.VrfID + size += 4 // m.MaxMsgSize + return size +} +func (m *SyslogSetSender) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBytes(m.SrcAddress[:], 4) + buf.EncodeBytes(m.CollectorAddress[:], 4) + buf.EncodeUint16(m.CollectorPort) + buf.EncodeUint32(m.VrfID) + buf.EncodeUint32(m.MaxMsgSize) + return buf.Bytes(), nil +} +func (m *SyslogSetSender) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.SrcAddress[:], buf.DecodeBytes(4)) + copy(m.CollectorAddress[:], buf.DecodeBytes(4)) + m.CollectorPort = buf.DecodeUint16() + m.VrfID = buf.DecodeUint32() + m.MaxMsgSize = buf.DecodeUint32() + return nil +} + +// SyslogSetSenderReply defines message 'syslog_set_sender_reply'. +type SyslogSetSenderReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SyslogSetSenderReply) Reset() { *m = SyslogSetSenderReply{} } +func (*SyslogSetSenderReply) GetMessageName() string { return "syslog_set_sender_reply" } +func (*SyslogSetSenderReply) GetCrcString() string { return "e8d4e804" } +func (*SyslogSetSenderReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SyslogSetSenderReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SyslogSetSenderReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SyslogSetSenderReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_syslog_binapi_init() } +func file_syslog_binapi_init() { + api.RegisterMessage((*SyslogGetFilter)(nil), "syslog_get_filter_51077d14") + api.RegisterMessage((*SyslogGetFilterReply)(nil), "syslog_get_filter_reply_eb1833f8") + api.RegisterMessage((*SyslogGetSender)(nil), "syslog_get_sender_51077d14") + api.RegisterMessage((*SyslogGetSenderReply)(nil), "syslog_get_sender_reply_424cfa4e") + api.RegisterMessage((*SyslogSetFilter)(nil), "syslog_set_filter_571348c3") + api.RegisterMessage((*SyslogSetFilterReply)(nil), "syslog_set_filter_reply_e8d4e804") + api.RegisterMessage((*SyslogSetSender)(nil), "syslog_set_sender_b8011d0b") + api.RegisterMessage((*SyslogSetSenderReply)(nil), "syslog_set_sender_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*SyslogGetFilter)(nil), + (*SyslogGetFilterReply)(nil), + (*SyslogGetSender)(nil), + (*SyslogGetSenderReply)(nil), + (*SyslogSetFilter)(nil), + (*SyslogSetFilterReply)(nil), + (*SyslogSetSender)(nil), + (*SyslogSetSenderReply)(nil), + } +} diff --git a/binapi/syslog/syslog_rpc.ba.go b/binapi/syslog/syslog_rpc.ba.go new file mode 100644 index 00000000..5489c51c --- /dev/null +++ b/binapi/syslog/syslog_rpc.ba.go @@ -0,0 +1,61 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package syslog + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service syslog. +type RPCService interface { + SyslogGetFilter(ctx context.Context, in *SyslogGetFilter) (*SyslogGetFilterReply, error) + SyslogGetSender(ctx context.Context, in *SyslogGetSender) (*SyslogGetSenderReply, error) + SyslogSetFilter(ctx context.Context, in *SyslogSetFilter) (*SyslogSetFilterReply, error) + SyslogSetSender(ctx context.Context, in *SyslogSetSender) (*SyslogSetSenderReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) SyslogGetFilter(ctx context.Context, in *SyslogGetFilter) (*SyslogGetFilterReply, error) { + out := new(SyslogGetFilterReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SyslogGetSender(ctx context.Context, in *SyslogGetSender) (*SyslogGetSenderReply, error) { + out := new(SyslogGetSenderReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SyslogSetFilter(ctx context.Context, in *SyslogSetFilter) (*SyslogSetFilterReply, error) { + out := new(SyslogSetFilterReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) SyslogSetSender(ctx context.Context, in *SyslogSetSender) (*SyslogSetSenderReply, error) { + out := new(SyslogSetSenderReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/tapv2/tapv2.ba.go b/binapi/tapv2/tapv2.ba.go new file mode 100644 index 00000000..ae520f60 --- /dev/null +++ b/binapi/tapv2/tapv2.ba.go @@ -0,0 +1,752 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/tapv2.api.json + +// Package tapv2 contains generated bindings for API file tapv2.api. +// +// Contents: +// - 1 enum +// - 8 messages +package tapv2 + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + ethernet_types "github.com/alkiranet/govpp/binapi/ethernet_types" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "tapv2" + APIVersion = "4.0.0" + VersionCrc = 0xc2f80dc7 +) + +// TapFlags defines enum 'tap_flags'. +type TapFlags uint32 + +const ( + TAP_API_FLAG_GSO TapFlags = 1 + TAP_API_FLAG_CSUM_OFFLOAD TapFlags = 2 + TAP_API_FLAG_PERSIST TapFlags = 4 + TAP_API_FLAG_ATTACH TapFlags = 8 + TAP_API_FLAG_TUN TapFlags = 16 + TAP_API_FLAG_GRO_COALESCE TapFlags = 32 + TAP_API_FLAG_PACKED TapFlags = 64 + TAP_API_FLAG_IN_ORDER TapFlags = 128 +) + +var ( + TapFlags_name = map[uint32]string{ + 1: "TAP_API_FLAG_GSO", + 2: "TAP_API_FLAG_CSUM_OFFLOAD", + 4: "TAP_API_FLAG_PERSIST", + 8: "TAP_API_FLAG_ATTACH", + 16: "TAP_API_FLAG_TUN", + 32: "TAP_API_FLAG_GRO_COALESCE", + 64: "TAP_API_FLAG_PACKED", + 128: "TAP_API_FLAG_IN_ORDER", + } + TapFlags_value = map[string]uint32{ + "TAP_API_FLAG_GSO": 1, + "TAP_API_FLAG_CSUM_OFFLOAD": 2, + "TAP_API_FLAG_PERSIST": 4, + "TAP_API_FLAG_ATTACH": 8, + "TAP_API_FLAG_TUN": 16, + "TAP_API_FLAG_GRO_COALESCE": 32, + "TAP_API_FLAG_PACKED": 64, + "TAP_API_FLAG_IN_ORDER": 128, + } +) + +func (x TapFlags) String() string { + s, ok := TapFlags_name[uint32(x)] + if ok { + return s + } + str := func(n uint32) string { + s, ok := TapFlags_name[uint32(n)] + if ok { + return s + } + return "TapFlags(" + strconv.Itoa(int(n)) + ")" + } + for i := uint32(0); i <= 32; i++ { + val := uint32(x) + if val&(1< IPv4, 1 -> IPv6 +// - vr_id - ID of VR +// - n_peer_addrs - number of peer addresses +// - peer_addrs - peer addresses +// +// VrrpVrPeerDetails defines message 'vrrp_vr_peer_details'. +type VrrpVrPeerDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + VrID uint8 `binapi:"u8,name=vr_id" json:"vr_id,omitempty"` + IsIPv6 uint8 `binapi:"u8,name=is_ipv6" json:"is_ipv6,omitempty"` + NPeerAddrs uint8 `binapi:"u8,name=n_peer_addrs" json:"-"` + PeerAddrs []ip_types.Address `binapi:"address[n_peer_addrs],name=peer_addrs" json:"peer_addrs,omitempty"` +} + +func (m *VrrpVrPeerDetails) Reset() { *m = VrrpVrPeerDetails{} } +func (*VrrpVrPeerDetails) GetMessageName() string { return "vrrp_vr_peer_details" } +func (*VrrpVrPeerDetails) GetCrcString() string { return "3d99c108" } +func (*VrrpVrPeerDetails) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VrrpVrPeerDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.VrID + size += 1 // m.IsIPv6 + size += 1 // m.NPeerAddrs + for j1 := 0; j1 < len(m.PeerAddrs); j1++ { + var s1 ip_types.Address + _ = s1 + if j1 < len(m.PeerAddrs) { + s1 = m.PeerAddrs[j1] + } + size += 1 // s1.Af + size += 1 * 16 // s1.Un + } + return size +} +func (m *VrrpVrPeerDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(m.VrID) + buf.EncodeUint8(m.IsIPv6) + buf.EncodeUint8(uint8(len(m.PeerAddrs))) + for j0 := 0; j0 < len(m.PeerAddrs); j0++ { + var v0 ip_types.Address // PeerAddrs + if j0 < len(m.PeerAddrs) { + v0 = m.PeerAddrs[j0] + } + buf.EncodeUint8(uint8(v0.Af)) + buf.EncodeBytes(v0.Un.XXX_UnionData[:], 16) + } + return buf.Bytes(), nil +} +func (m *VrrpVrPeerDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.VrID = buf.DecodeUint8() + m.IsIPv6 = buf.DecodeUint8() + m.NPeerAddrs = buf.DecodeUint8() + m.PeerAddrs = make([]ip_types.Address, m.NPeerAddrs) + for j0 := 0; j0 < len(m.PeerAddrs); j0++ { + m.PeerAddrs[j0].Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.PeerAddrs[j0].Un.XXX_UnionData[:], buf.DecodeBytes(16)) + } + return nil +} + +// VRRP: dump virtual router peer address data +// - sw_if_index - interface (0,~0 == "all" -> ignore is_ipv6 & vr_id)) +// - is_ipv6 - 0 -> IPv4, 1 -> IPv6 +// - vr_id - ID of VR to dump +// +// VrrpVrPeerDump defines message 'vrrp_vr_peer_dump'. +type VrrpVrPeerDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IsIPv6 uint8 `binapi:"u8,name=is_ipv6" json:"is_ipv6,omitempty"` + VrID uint8 `binapi:"u8,name=vr_id" json:"vr_id,omitempty"` +} + +func (m *VrrpVrPeerDump) Reset() { *m = VrrpVrPeerDump{} } +func (*VrrpVrPeerDump) GetMessageName() string { return "vrrp_vr_peer_dump" } +func (*VrrpVrPeerDump) GetCrcString() string { return "6fa3f7c4" } +func (*VrrpVrPeerDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VrrpVrPeerDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.IsIPv6 + size += 1 // m.VrID + return size +} +func (m *VrrpVrPeerDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(m.IsIPv6) + buf.EncodeUint8(m.VrID) + return buf.Bytes(), nil +} +func (m *VrrpVrPeerDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsIPv6 = buf.DecodeUint8() + m.VrID = buf.DecodeUint8() + return nil +} + +// VRRP: set unicast peers for a VR +// - sw_if_index - interface ID that VR is backing up +// - vr_id - VR ID +// - is_ipv6 - 1 for IPv6, 0 for IPv4 +// - n_addrs - number of peer addresses +// - addrs - peer addresses +// +// VrrpVrSetPeers defines message 'vrrp_vr_set_peers'. +type VrrpVrSetPeers struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + VrID uint8 `binapi:"u8,name=vr_id" json:"vr_id,omitempty"` + IsIPv6 uint8 `binapi:"u8,name=is_ipv6" json:"is_ipv6,omitempty"` + NAddrs uint8 `binapi:"u8,name=n_addrs" json:"-"` + Addrs []ip_types.Address `binapi:"address[n_addrs],name=addrs" json:"addrs,omitempty"` +} + +func (m *VrrpVrSetPeers) Reset() { *m = VrrpVrSetPeers{} } +func (*VrrpVrSetPeers) GetMessageName() string { return "vrrp_vr_set_peers" } +func (*VrrpVrSetPeers) GetCrcString() string { return "20bec71f" } +func (*VrrpVrSetPeers) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VrrpVrSetPeers) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.VrID + size += 1 // m.IsIPv6 + size += 1 // m.NAddrs + for j1 := 0; j1 < len(m.Addrs); j1++ { + var s1 ip_types.Address + _ = s1 + if j1 < len(m.Addrs) { + s1 = m.Addrs[j1] + } + size += 1 // s1.Af + size += 1 * 16 // s1.Un + } + return size +} +func (m *VrrpVrSetPeers) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(m.VrID) + buf.EncodeUint8(m.IsIPv6) + buf.EncodeUint8(uint8(len(m.Addrs))) + for j0 := 0; j0 < len(m.Addrs); j0++ { + var v0 ip_types.Address // Addrs + if j0 < len(m.Addrs) { + v0 = m.Addrs[j0] + } + buf.EncodeUint8(uint8(v0.Af)) + buf.EncodeBytes(v0.Un.XXX_UnionData[:], 16) + } + return buf.Bytes(), nil +} +func (m *VrrpVrSetPeers) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.VrID = buf.DecodeUint8() + m.IsIPv6 = buf.DecodeUint8() + m.NAddrs = buf.DecodeUint8() + m.Addrs = make([]ip_types.Address, m.NAddrs) + for j0 := 0; j0 < len(m.Addrs); j0++ { + m.Addrs[j0].Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Addrs[j0].Un.XXX_UnionData[:], buf.DecodeBytes(16)) + } + return nil +} + +// VrrpVrSetPeersReply defines message 'vrrp_vr_set_peers_reply'. +type VrrpVrSetPeersReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *VrrpVrSetPeersReply) Reset() { *m = VrrpVrSetPeersReply{} } +func (*VrrpVrSetPeersReply) GetMessageName() string { return "vrrp_vr_set_peers_reply" } +func (*VrrpVrSetPeersReply) GetCrcString() string { return "e8d4e804" } +func (*VrrpVrSetPeersReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *VrrpVrSetPeersReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *VrrpVrSetPeersReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *VrrpVrSetPeersReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// VRRP: start or shutdown the VRRP protocol for a virtual router +// - sw_if_index - interface ID that VR is backing up +// - vr_id - VR ID +// - is_ipv6 - 1 for IPv6, 0 for IPv4 +// - is_start - 1 to start VRRP proto on this VR, 0 to shutdown +// +// VrrpVrStartStop defines message 'vrrp_vr_start_stop'. +type VrrpVrStartStop struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + VrID uint8 `binapi:"u8,name=vr_id" json:"vr_id,omitempty"` + IsIPv6 uint8 `binapi:"u8,name=is_ipv6" json:"is_ipv6,omitempty"` + IsStart uint8 `binapi:"u8,name=is_start" json:"is_start,omitempty"` +} + +func (m *VrrpVrStartStop) Reset() { *m = VrrpVrStartStop{} } +func (*VrrpVrStartStop) GetMessageName() string { return "vrrp_vr_start_stop" } +func (*VrrpVrStartStop) GetCrcString() string { return "0662a3b7" } +func (*VrrpVrStartStop) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VrrpVrStartStop) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.VrID + size += 1 // m.IsIPv6 + size += 1 // m.IsStart + return size +} +func (m *VrrpVrStartStop) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(m.VrID) + buf.EncodeUint8(m.IsIPv6) + buf.EncodeUint8(m.IsStart) + return buf.Bytes(), nil +} +func (m *VrrpVrStartStop) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.VrID = buf.DecodeUint8() + m.IsIPv6 = buf.DecodeUint8() + m.IsStart = buf.DecodeUint8() + return nil +} + +// VrrpVrStartStopReply defines message 'vrrp_vr_start_stop_reply'. +type VrrpVrStartStopReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *VrrpVrStartStopReply) Reset() { *m = VrrpVrStartStopReply{} } +func (*VrrpVrStartStopReply) GetMessageName() string { return "vrrp_vr_start_stop_reply" } +func (*VrrpVrStartStopReply) GetCrcString() string { return "e8d4e804" } +func (*VrrpVrStartStopReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *VrrpVrStartStopReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *VrrpVrStartStopReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *VrrpVrStartStopReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// VRRP: Add/delete VR priority tracking of interface status +// - sw_if_index - interface index +// - is_ipv6 - 0 -> IPv4, 1 -> IPv6 +// - vr_id - ID of VR +// - is_add - 0 -> delete, 1 -> add +// - n_ifs - number of interface tracking records +// - ifs - array of interface tracking records +// +// VrrpVrTrackIfAddDel defines message 'vrrp_vr_track_if_add_del'. +type VrrpVrTrackIfAddDel struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IsIPv6 uint8 `binapi:"u8,name=is_ipv6" json:"is_ipv6,omitempty"` + VrID uint8 `binapi:"u8,name=vr_id" json:"vr_id,omitempty"` + IsAdd uint8 `binapi:"u8,name=is_add" json:"is_add,omitempty"` + NIfs uint8 `binapi:"u8,name=n_ifs" json:"-"` + Ifs []VrrpVrTrackIf `binapi:"vrrp_vr_track_if[n_ifs],name=ifs" json:"ifs,omitempty"` +} + +func (m *VrrpVrTrackIfAddDel) Reset() { *m = VrrpVrTrackIfAddDel{} } +func (*VrrpVrTrackIfAddDel) GetMessageName() string { return "vrrp_vr_track_if_add_del" } +func (*VrrpVrTrackIfAddDel) GetCrcString() string { return "d67df299" } +func (*VrrpVrTrackIfAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VrrpVrTrackIfAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.IsIPv6 + size += 1 // m.VrID + size += 1 // m.IsAdd + size += 1 // m.NIfs + for j1 := 0; j1 < len(m.Ifs); j1++ { + var s1 VrrpVrTrackIf + _ = s1 + if j1 < len(m.Ifs) { + s1 = m.Ifs[j1] + } + size += 4 // s1.SwIfIndex + size += 1 // s1.Priority + } + return size +} +func (m *VrrpVrTrackIfAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(m.IsIPv6) + buf.EncodeUint8(m.VrID) + buf.EncodeUint8(m.IsAdd) + buf.EncodeUint8(uint8(len(m.Ifs))) + for j0 := 0; j0 < len(m.Ifs); j0++ { + var v0 VrrpVrTrackIf // Ifs + if j0 < len(m.Ifs) { + v0 = m.Ifs[j0] + } + buf.EncodeUint32(uint32(v0.SwIfIndex)) + buf.EncodeUint8(v0.Priority) + } + return buf.Bytes(), nil +} +func (m *VrrpVrTrackIfAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsIPv6 = buf.DecodeUint8() + m.VrID = buf.DecodeUint8() + m.IsAdd = buf.DecodeUint8() + m.NIfs = buf.DecodeUint8() + m.Ifs = make([]VrrpVrTrackIf, m.NIfs) + for j0 := 0; j0 < len(m.Ifs); j0++ { + m.Ifs[j0].SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Ifs[j0].Priority = buf.DecodeUint8() + } + return nil +} + +// VrrpVrTrackIfAddDelReply defines message 'vrrp_vr_track_if_add_del_reply'. +type VrrpVrTrackIfAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *VrrpVrTrackIfAddDelReply) Reset() { *m = VrrpVrTrackIfAddDelReply{} } +func (*VrrpVrTrackIfAddDelReply) GetMessageName() string { return "vrrp_vr_track_if_add_del_reply" } +func (*VrrpVrTrackIfAddDelReply) GetCrcString() string { return "e8d4e804" } +func (*VrrpVrTrackIfAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *VrrpVrTrackIfAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *VrrpVrTrackIfAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *VrrpVrTrackIfAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// VRRP: VR interface tracking dump response +// - sw_if_index - interface index +// - is_ipv6 - 0 -> IPv4, 1 -> IPv6 +// - vr_id - ID of VR +// - n_ifs - number of tracked interfaces +// - ifs - array of tracked interface data +// +// VrrpVrTrackIfDetails defines message 'vrrp_vr_track_if_details'. +type VrrpVrTrackIfDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + VrID uint8 `binapi:"u8,name=vr_id" json:"vr_id,omitempty"` + IsIPv6 uint8 `binapi:"u8,name=is_ipv6" json:"is_ipv6,omitempty"` + NIfs uint8 `binapi:"u8,name=n_ifs" json:"-"` + Ifs []VrrpVrTrackIf `binapi:"vrrp_vr_track_if[n_ifs],name=ifs" json:"ifs,omitempty"` +} + +func (m *VrrpVrTrackIfDetails) Reset() { *m = VrrpVrTrackIfDetails{} } +func (*VrrpVrTrackIfDetails) GetMessageName() string { return "vrrp_vr_track_if_details" } +func (*VrrpVrTrackIfDetails) GetCrcString() string { return "73c36f81" } +func (*VrrpVrTrackIfDetails) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VrrpVrTrackIfDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.VrID + size += 1 // m.IsIPv6 + size += 1 // m.NIfs + for j1 := 0; j1 < len(m.Ifs); j1++ { + var s1 VrrpVrTrackIf + _ = s1 + if j1 < len(m.Ifs) { + s1 = m.Ifs[j1] + } + size += 4 // s1.SwIfIndex + size += 1 // s1.Priority + } + return size +} +func (m *VrrpVrTrackIfDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(m.VrID) + buf.EncodeUint8(m.IsIPv6) + buf.EncodeUint8(uint8(len(m.Ifs))) + for j0 := 0; j0 < len(m.Ifs); j0++ { + var v0 VrrpVrTrackIf // Ifs + if j0 < len(m.Ifs) { + v0 = m.Ifs[j0] + } + buf.EncodeUint32(uint32(v0.SwIfIndex)) + buf.EncodeUint8(v0.Priority) + } + return buf.Bytes(), nil +} +func (m *VrrpVrTrackIfDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.VrID = buf.DecodeUint8() + m.IsIPv6 = buf.DecodeUint8() + m.NIfs = buf.DecodeUint8() + m.Ifs = make([]VrrpVrTrackIf, m.NIfs) + for j0 := 0; j0 < len(m.Ifs); j0++ { + m.Ifs[j0].SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Ifs[j0].Priority = buf.DecodeUint8() + } + return nil +} + +// VRRP: dump virtual router interface tracking data +// - sw_if_index - interface +// - is_ipv6 - 0 -> IPv4, 1 -> IPv6 +// - vr_id - ID of VR to dump +// - dump_all - dump all VR interface tracking, ignore other fields +// +// VrrpVrTrackIfDump defines message 'vrrp_vr_track_if_dump'. +type VrrpVrTrackIfDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IsIPv6 uint8 `binapi:"u8,name=is_ipv6" json:"is_ipv6,omitempty"` + VrID uint8 `binapi:"u8,name=vr_id" json:"vr_id,omitempty"` + DumpAll uint8 `binapi:"u8,name=dump_all" json:"dump_all,omitempty"` +} + +func (m *VrrpVrTrackIfDump) Reset() { *m = VrrpVrTrackIfDump{} } +func (*VrrpVrTrackIfDump) GetMessageName() string { return "vrrp_vr_track_if_dump" } +func (*VrrpVrTrackIfDump) GetCrcString() string { return "a34dfc6d" } +func (*VrrpVrTrackIfDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VrrpVrTrackIfDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.IsIPv6 + size += 1 // m.VrID + size += 1 // m.DumpAll + return size +} +func (m *VrrpVrTrackIfDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(m.IsIPv6) + buf.EncodeUint8(m.VrID) + buf.EncodeUint8(m.DumpAll) + return buf.Bytes(), nil +} +func (m *VrrpVrTrackIfDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsIPv6 = buf.DecodeUint8() + m.VrID = buf.DecodeUint8() + m.DumpAll = buf.DecodeUint8() + return nil +} + +// @brief Replace an existing VRRP virtual router in-place or create a new one +// - vrrp_index - an existing VRRP entry to replace, or 0xffffffff to crate a new one +// - sw_if_index - interface backed up by this vr +// - vr_id - the VR ID advertised by this vr +// - priority - the priority advertised for this vr +// - interval - interval between advertisements in centiseconds +// - flags - bit flags for booleans - preempt, accept, unicast, ipv6 +// - n_addrs - number of addresses being backed up by this vr +// - addrs - the addresses backed up by this vr +// +// VrrpVrUpdate defines message 'vrrp_vr_update'. +type VrrpVrUpdate struct { + VrrpIndex uint32 `binapi:"u32,name=vrrp_index" json:"vrrp_index,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + VrID uint8 `binapi:"u8,name=vr_id" json:"vr_id,omitempty"` + Priority uint8 `binapi:"u8,name=priority" json:"priority,omitempty"` + Interval uint16 `binapi:"u16,name=interval" json:"interval,omitempty"` + Flags VrrpVrFlags `binapi:"vrrp_vr_flags,name=flags" json:"flags,omitempty"` + NAddrs uint8 `binapi:"u8,name=n_addrs" json:"-"` + Addrs []ip_types.Address `binapi:"address[n_addrs],name=addrs" json:"addrs,omitempty"` +} + +func (m *VrrpVrUpdate) Reset() { *m = VrrpVrUpdate{} } +func (*VrrpVrUpdate) GetMessageName() string { return "vrrp_vr_update" } +func (*VrrpVrUpdate) GetCrcString() string { return "0b51e2f4" } +func (*VrrpVrUpdate) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VrrpVrUpdate) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.VrrpIndex + size += 4 // m.SwIfIndex + size += 1 // m.VrID + size += 1 // m.Priority + size += 2 // m.Interval + size += 4 // m.Flags + size += 1 // m.NAddrs + for j1 := 0; j1 < len(m.Addrs); j1++ { + var s1 ip_types.Address + _ = s1 + if j1 < len(m.Addrs) { + s1 = m.Addrs[j1] + } + size += 1 // s1.Af + size += 1 * 16 // s1.Un + } + return size +} +func (m *VrrpVrUpdate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.VrrpIndex) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(m.VrID) + buf.EncodeUint8(m.Priority) + buf.EncodeUint16(m.Interval) + buf.EncodeUint32(uint32(m.Flags)) + buf.EncodeUint8(uint8(len(m.Addrs))) + for j0 := 0; j0 < len(m.Addrs); j0++ { + var v0 ip_types.Address // Addrs + if j0 < len(m.Addrs) { + v0 = m.Addrs[j0] + } + buf.EncodeUint8(uint8(v0.Af)) + buf.EncodeBytes(v0.Un.XXX_UnionData[:], 16) + } + return buf.Bytes(), nil +} +func (m *VrrpVrUpdate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.VrrpIndex = buf.DecodeUint32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.VrID = buf.DecodeUint8() + m.Priority = buf.DecodeUint8() + m.Interval = buf.DecodeUint16() + m.Flags = VrrpVrFlags(buf.DecodeUint32()) + m.NAddrs = buf.DecodeUint8() + m.Addrs = make([]ip_types.Address, m.NAddrs) + for j0 := 0; j0 < len(m.Addrs); j0++ { + m.Addrs[j0].Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Addrs[j0].Un.XXX_UnionData[:], buf.DecodeBytes(16)) + } + return nil +} + +// * @brief Reply to a VRRP add/replace +// - - vrrp_index - index of the updated or newly created VRRP instance +// - - retval 0 - no error +// +// VrrpVrUpdateReply defines message 'vrrp_vr_update_reply'. +type VrrpVrUpdateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + VrrpIndex uint32 `binapi:"u32,name=vrrp_index" json:"vrrp_index,omitempty"` +} + +func (m *VrrpVrUpdateReply) Reset() { *m = VrrpVrUpdateReply{} } +func (*VrrpVrUpdateReply) GetMessageName() string { return "vrrp_vr_update_reply" } +func (*VrrpVrUpdateReply) GetCrcString() string { return "5317d608" } +func (*VrrpVrUpdateReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *VrrpVrUpdateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.VrrpIndex + return size +} +func (m *VrrpVrUpdateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.VrrpIndex) + return buf.Bytes(), nil +} +func (m *VrrpVrUpdateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.VrrpIndex = buf.DecodeUint32() + return nil +} + +// Register for VRRP VR state change events +// - enable_disable - 1 to register, 0 to cancel registration +// - pid - sender's pid +// +// WantVrrpVrEvents defines message 'want_vrrp_vr_events'. +type WantVrrpVrEvents struct { + EnableDisable bool `binapi:"bool,name=enable_disable" json:"enable_disable,omitempty"` + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` +} + +func (m *WantVrrpVrEvents) Reset() { *m = WantVrrpVrEvents{} } +func (*WantVrrpVrEvents) GetMessageName() string { return "want_vrrp_vr_events" } +func (*WantVrrpVrEvents) GetCrcString() string { return "c5e2af94" } +func (*WantVrrpVrEvents) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *WantVrrpVrEvents) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.EnableDisable + size += 4 // m.PID + return size +} +func (m *WantVrrpVrEvents) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.EnableDisable) + buf.EncodeUint32(m.PID) + return buf.Bytes(), nil +} +func (m *WantVrrpVrEvents) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.EnableDisable = buf.DecodeBool() + m.PID = buf.DecodeUint32() + return nil +} + +// WantVrrpVrEventsReply defines message 'want_vrrp_vr_events_reply'. +type WantVrrpVrEventsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *WantVrrpVrEventsReply) Reset() { *m = WantVrrpVrEventsReply{} } +func (*WantVrrpVrEventsReply) GetMessageName() string { return "want_vrrp_vr_events_reply" } +func (*WantVrrpVrEventsReply) GetCrcString() string { return "e8d4e804" } +func (*WantVrrpVrEventsReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *WantVrrpVrEventsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *WantVrrpVrEventsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *WantVrrpVrEventsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_vrrp_binapi_init() } +func file_vrrp_binapi_init() { + api.RegisterMessage((*VrrpVrAddDel)(nil), "vrrp_vr_add_del_c5cf15aa") + api.RegisterMessage((*VrrpVrAddDelReply)(nil), "vrrp_vr_add_del_reply_e8d4e804") + api.RegisterMessage((*VrrpVrDel)(nil), "vrrp_vr_del_6029baa1") + api.RegisterMessage((*VrrpVrDelReply)(nil), "vrrp_vr_del_reply_e8d4e804") + api.RegisterMessage((*VrrpVrDetails)(nil), "vrrp_vr_details_46edcebd") + api.RegisterMessage((*VrrpVrDump)(nil), "vrrp_vr_dump_f9e6675e") + api.RegisterMessage((*VrrpVrEvent)(nil), "vrrp_vr_event_c1fea6a5") + api.RegisterMessage((*VrrpVrPeerDetails)(nil), "vrrp_vr_peer_details_3d99c108") + api.RegisterMessage((*VrrpVrPeerDump)(nil), "vrrp_vr_peer_dump_6fa3f7c4") + api.RegisterMessage((*VrrpVrSetPeers)(nil), "vrrp_vr_set_peers_20bec71f") + api.RegisterMessage((*VrrpVrSetPeersReply)(nil), "vrrp_vr_set_peers_reply_e8d4e804") + api.RegisterMessage((*VrrpVrStartStop)(nil), "vrrp_vr_start_stop_0662a3b7") + api.RegisterMessage((*VrrpVrStartStopReply)(nil), "vrrp_vr_start_stop_reply_e8d4e804") + api.RegisterMessage((*VrrpVrTrackIfAddDel)(nil), "vrrp_vr_track_if_add_del_d67df299") + api.RegisterMessage((*VrrpVrTrackIfAddDelReply)(nil), "vrrp_vr_track_if_add_del_reply_e8d4e804") + api.RegisterMessage((*VrrpVrTrackIfDetails)(nil), "vrrp_vr_track_if_details_73c36f81") + api.RegisterMessage((*VrrpVrTrackIfDump)(nil), "vrrp_vr_track_if_dump_a34dfc6d") + api.RegisterMessage((*VrrpVrUpdate)(nil), "vrrp_vr_update_0b51e2f4") + api.RegisterMessage((*VrrpVrUpdateReply)(nil), "vrrp_vr_update_reply_5317d608") + api.RegisterMessage((*WantVrrpVrEvents)(nil), "want_vrrp_vr_events_c5e2af94") + api.RegisterMessage((*WantVrrpVrEventsReply)(nil), "want_vrrp_vr_events_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*VrrpVrAddDel)(nil), + (*VrrpVrAddDelReply)(nil), + (*VrrpVrDel)(nil), + (*VrrpVrDelReply)(nil), + (*VrrpVrDetails)(nil), + (*VrrpVrDump)(nil), + (*VrrpVrEvent)(nil), + (*VrrpVrPeerDetails)(nil), + (*VrrpVrPeerDump)(nil), + (*VrrpVrSetPeers)(nil), + (*VrrpVrSetPeersReply)(nil), + (*VrrpVrStartStop)(nil), + (*VrrpVrStartStopReply)(nil), + (*VrrpVrTrackIfAddDel)(nil), + (*VrrpVrTrackIfAddDelReply)(nil), + (*VrrpVrTrackIfDetails)(nil), + (*VrrpVrTrackIfDump)(nil), + (*VrrpVrUpdate)(nil), + (*VrrpVrUpdateReply)(nil), + (*WantVrrpVrEvents)(nil), + (*WantVrrpVrEventsReply)(nil), + } +} diff --git a/binapi/vrrp/vrrp_rpc.ba.go b/binapi/vrrp/vrrp_rpc.ba.go new file mode 100644 index 00000000..bc823ce6 --- /dev/null +++ b/binapi/vrrp/vrrp_rpc.ba.go @@ -0,0 +1,226 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package vrrp + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service vrrp. +type RPCService interface { + VrrpVrAddDel(ctx context.Context, in *VrrpVrAddDel) (*VrrpVrAddDelReply, error) + VrrpVrDel(ctx context.Context, in *VrrpVrDel) (*VrrpVrDelReply, error) + VrrpVrDump(ctx context.Context, in *VrrpVrDump) (RPCService_VrrpVrDumpClient, error) + VrrpVrPeerDump(ctx context.Context, in *VrrpVrPeerDump) (RPCService_VrrpVrPeerDumpClient, error) + VrrpVrSetPeers(ctx context.Context, in *VrrpVrSetPeers) (*VrrpVrSetPeersReply, error) + VrrpVrStartStop(ctx context.Context, in *VrrpVrStartStop) (*VrrpVrStartStopReply, error) + VrrpVrTrackIfAddDel(ctx context.Context, in *VrrpVrTrackIfAddDel) (*VrrpVrTrackIfAddDelReply, error) + VrrpVrTrackIfDump(ctx context.Context, in *VrrpVrTrackIfDump) (RPCService_VrrpVrTrackIfDumpClient, error) + VrrpVrUpdate(ctx context.Context, in *VrrpVrUpdate) (*VrrpVrUpdateReply, error) + WantVrrpVrEvents(ctx context.Context, in *WantVrrpVrEvents) (*WantVrrpVrEventsReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) VrrpVrAddDel(ctx context.Context, in *VrrpVrAddDel) (*VrrpVrAddDelReply, error) { + out := new(VrrpVrAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) VrrpVrDel(ctx context.Context, in *VrrpVrDel) (*VrrpVrDelReply, error) { + out := new(VrrpVrDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) VrrpVrDump(ctx context.Context, in *VrrpVrDump) (RPCService_VrrpVrDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_VrrpVrDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_VrrpVrDumpClient interface { + Recv() (*VrrpVrDetails, error) + api.Stream +} + +type serviceClient_VrrpVrDumpClient struct { + api.Stream +} + +func (c *serviceClient_VrrpVrDumpClient) Recv() (*VrrpVrDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *VrrpVrDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) VrrpVrPeerDump(ctx context.Context, in *VrrpVrPeerDump) (RPCService_VrrpVrPeerDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_VrrpVrPeerDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_VrrpVrPeerDumpClient interface { + Recv() (*VrrpVrPeerDetails, error) + api.Stream +} + +type serviceClient_VrrpVrPeerDumpClient struct { + api.Stream +} + +func (c *serviceClient_VrrpVrPeerDumpClient) Recv() (*VrrpVrPeerDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *VrrpVrPeerDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) VrrpVrSetPeers(ctx context.Context, in *VrrpVrSetPeers) (*VrrpVrSetPeersReply, error) { + out := new(VrrpVrSetPeersReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) VrrpVrStartStop(ctx context.Context, in *VrrpVrStartStop) (*VrrpVrStartStopReply, error) { + out := new(VrrpVrStartStopReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) VrrpVrTrackIfAddDel(ctx context.Context, in *VrrpVrTrackIfAddDel) (*VrrpVrTrackIfAddDelReply, error) { + out := new(VrrpVrTrackIfAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) VrrpVrTrackIfDump(ctx context.Context, in *VrrpVrTrackIfDump) (RPCService_VrrpVrTrackIfDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_VrrpVrTrackIfDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_VrrpVrTrackIfDumpClient interface { + Recv() (*VrrpVrTrackIfDetails, error) + api.Stream +} + +type serviceClient_VrrpVrTrackIfDumpClient struct { + api.Stream +} + +func (c *serviceClient_VrrpVrTrackIfDumpClient) Recv() (*VrrpVrTrackIfDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *VrrpVrTrackIfDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) VrrpVrUpdate(ctx context.Context, in *VrrpVrUpdate) (*VrrpVrUpdateReply, error) { + out := new(VrrpVrUpdateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WantVrrpVrEvents(ctx context.Context, in *WantVrrpVrEvents) (*WantVrrpVrEventsReply, error) { + out := new(WantVrrpVrEventsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/vxlan/vxlan.ba.go b/binapi/vxlan/vxlan.ba.go new file mode 100644 index 00000000..e98f5593 --- /dev/null +++ b/binapi/vxlan/vxlan.ba.go @@ -0,0 +1,803 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/vxlan.api.json + +// Package vxlan contains generated bindings for API file vxlan.api. +// +// Contents: +// - 14 messages +package vxlan + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "vxlan" + APIVersion = "2.1.0" + VersionCrc = 0x95381587 +) + +// Interface set vxlan-bypass request +// - sw_if_index - interface used to reach neighbor +// - is_ipv6 - if non-zero, enable ipv6-vxlan-bypass, else ipv4-vxlan-bypass +// - enable - if non-zero enable, else disable +// +// SwInterfaceSetVxlanBypass defines message 'sw_interface_set_vxlan_bypass'. +type SwInterfaceSetVxlanBypass struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IsIPv6 bool `binapi:"bool,name=is_ipv6" json:"is_ipv6,omitempty"` + Enable bool `binapi:"bool,name=enable,default=true" json:"enable,omitempty"` +} + +func (m *SwInterfaceSetVxlanBypass) Reset() { *m = SwInterfaceSetVxlanBypass{} } +func (*SwInterfaceSetVxlanBypass) GetMessageName() string { return "sw_interface_set_vxlan_bypass" } +func (*SwInterfaceSetVxlanBypass) GetCrcString() string { return "65247409" } +func (*SwInterfaceSetVxlanBypass) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSetVxlanBypass) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.IsIPv6 + size += 1 // m.Enable + return size +} +func (m *SwInterfaceSetVxlanBypass) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.IsIPv6) + buf.EncodeBool(m.Enable) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetVxlanBypass) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsIPv6 = buf.DecodeBool() + m.Enable = buf.DecodeBool() + return nil +} + +// SwInterfaceSetVxlanBypassReply defines message 'sw_interface_set_vxlan_bypass_reply'. +type SwInterfaceSetVxlanBypassReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetVxlanBypassReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetVxlanBypassReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetVxlanBypassReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Create or delete a VXLAN tunnel +// - is_add - Use 1 to create the tunnel, 0 to remove it +// - instance - optional unique custom device instance, else ~0. +// - src_address - Source IP address +// - dst_address - Destination IP address, can be multicast +// - mcast_sw_if_index - Interface for multicast destination +// - encap_vrf_id - Encap route table FIB index +// - decap_next_index - index of decap next graph node +// - vni - The VXLAN Network Identifier, uint24 +// +// VxlanAddDelTunnel defines message 'vxlan_add_del_tunnel'. +type VxlanAddDelTunnel struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + Instance uint32 `binapi:"u32,name=instance" json:"instance,omitempty"` + SrcAddress ip_types.Address `binapi:"address,name=src_address" json:"src_address,omitempty"` + DstAddress ip_types.Address `binapi:"address,name=dst_address" json:"dst_address,omitempty"` + McastSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=mcast_sw_if_index" json:"mcast_sw_if_index,omitempty"` + EncapVrfID uint32 `binapi:"u32,name=encap_vrf_id" json:"encap_vrf_id,omitempty"` + DecapNextIndex uint32 `binapi:"u32,name=decap_next_index" json:"decap_next_index,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` +} + +func (m *VxlanAddDelTunnel) Reset() { *m = VxlanAddDelTunnel{} } +func (*VxlanAddDelTunnel) GetMessageName() string { return "vxlan_add_del_tunnel" } +func (*VxlanAddDelTunnel) GetCrcString() string { return "0c09dc80" } +func (*VxlanAddDelTunnel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VxlanAddDelTunnel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Instance + size += 1 // m.SrcAddress.Af + size += 1 * 16 // m.SrcAddress.Un + size += 1 // m.DstAddress.Af + size += 1 * 16 // m.DstAddress.Un + size += 4 // m.McastSwIfIndex + size += 4 // m.EncapVrfID + size += 4 // m.DecapNextIndex + size += 4 // m.Vni + return size +} +func (m *VxlanAddDelTunnel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.Instance) + buf.EncodeUint8(uint8(m.SrcAddress.Af)) + buf.EncodeBytes(m.SrcAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.DstAddress.Af)) + buf.EncodeBytes(m.DstAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.McastSwIfIndex)) + buf.EncodeUint32(m.EncapVrfID) + buf.EncodeUint32(m.DecapNextIndex) + buf.EncodeUint32(m.Vni) + return buf.Bytes(), nil +} +func (m *VxlanAddDelTunnel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Instance = buf.DecodeUint32() + m.SrcAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.SrcAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.DstAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.DstAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.McastSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.EncapVrfID = buf.DecodeUint32() + m.DecapNextIndex = buf.DecodeUint32() + m.Vni = buf.DecodeUint32() + return nil +} + +// VxlanAddDelTunnelReply defines message 'vxlan_add_del_tunnel_reply'. +type VxlanAddDelTunnelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *VxlanAddDelTunnelReply) Reset() { *m = VxlanAddDelTunnelReply{} } +func (*VxlanAddDelTunnelReply) GetMessageName() string { return "vxlan_add_del_tunnel_reply" } +func (*VxlanAddDelTunnelReply) GetCrcString() string { return "5383d31f" } +func (*VxlanAddDelTunnelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *VxlanAddDelTunnelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *VxlanAddDelTunnelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *VxlanAddDelTunnelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Create or delete a VXLAN tunnel +// - is_add - Use 1 to create the tunnel, 0 to remove it +// - instance - optional unique custom device instance, else ~0. +// - src_address - Source IP address +// - dst_address - Destination IP address, can be multicast +// - src_port - Source UDP port. It is not included in sent packets. Used only for port registration +// - dst_port - Destination UDP port +// - mcast_sw_if_index - Interface for multicast destination +// - encap_vrf_id - Encap route table FIB index +// - decap_next_index - index of decap next graph node +// - vni - The VXLAN Network Identifier, uint24 +// +// VxlanAddDelTunnelV2 defines message 'vxlan_add_del_tunnel_v2'. +type VxlanAddDelTunnelV2 struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + Instance uint32 `binapi:"u32,name=instance,default=4294967295" json:"instance,omitempty"` + SrcAddress ip_types.Address `binapi:"address,name=src_address" json:"src_address,omitempty"` + DstAddress ip_types.Address `binapi:"address,name=dst_address" json:"dst_address,omitempty"` + SrcPort uint16 `binapi:"u16,name=src_port" json:"src_port,omitempty"` + DstPort uint16 `binapi:"u16,name=dst_port" json:"dst_port,omitempty"` + McastSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=mcast_sw_if_index" json:"mcast_sw_if_index,omitempty"` + EncapVrfID uint32 `binapi:"u32,name=encap_vrf_id" json:"encap_vrf_id,omitempty"` + DecapNextIndex uint32 `binapi:"u32,name=decap_next_index" json:"decap_next_index,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` +} + +func (m *VxlanAddDelTunnelV2) Reset() { *m = VxlanAddDelTunnelV2{} } +func (*VxlanAddDelTunnelV2) GetMessageName() string { return "vxlan_add_del_tunnel_v2" } +func (*VxlanAddDelTunnelV2) GetCrcString() string { return "4f223f40" } +func (*VxlanAddDelTunnelV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VxlanAddDelTunnelV2) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Instance + size += 1 // m.SrcAddress.Af + size += 1 * 16 // m.SrcAddress.Un + size += 1 // m.DstAddress.Af + size += 1 * 16 // m.DstAddress.Un + size += 2 // m.SrcPort + size += 2 // m.DstPort + size += 4 // m.McastSwIfIndex + size += 4 // m.EncapVrfID + size += 4 // m.DecapNextIndex + size += 4 // m.Vni + return size +} +func (m *VxlanAddDelTunnelV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.Instance) + buf.EncodeUint8(uint8(m.SrcAddress.Af)) + buf.EncodeBytes(m.SrcAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.DstAddress.Af)) + buf.EncodeBytes(m.DstAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint16(m.SrcPort) + buf.EncodeUint16(m.DstPort) + buf.EncodeUint32(uint32(m.McastSwIfIndex)) + buf.EncodeUint32(m.EncapVrfID) + buf.EncodeUint32(m.DecapNextIndex) + buf.EncodeUint32(m.Vni) + return buf.Bytes(), nil +} +func (m *VxlanAddDelTunnelV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Instance = buf.DecodeUint32() + m.SrcAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.SrcAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.DstAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.DstAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.SrcPort = buf.DecodeUint16() + m.DstPort = buf.DecodeUint16() + m.McastSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.EncapVrfID = buf.DecodeUint32() + m.DecapNextIndex = buf.DecodeUint32() + m.Vni = buf.DecodeUint32() + return nil +} + +// VxlanAddDelTunnelV2Reply defines message 'vxlan_add_del_tunnel_v2_reply'. +type VxlanAddDelTunnelV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *VxlanAddDelTunnelV2Reply) Reset() { *m = VxlanAddDelTunnelV2Reply{} } +func (*VxlanAddDelTunnelV2Reply) GetMessageName() string { return "vxlan_add_del_tunnel_v2_reply" } +func (*VxlanAddDelTunnelV2Reply) GetCrcString() string { return "5383d31f" } +func (*VxlanAddDelTunnelV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *VxlanAddDelTunnelV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *VxlanAddDelTunnelV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *VxlanAddDelTunnelV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Create or delete a VXLAN tunnel +// - is_add - Use 1 to create the tunnel, 0 to remove it +// - instance - optional unique custom device instance, else ~0. +// - src_address - Source IP address +// - dst_address - Destination IP address, can be multicast +// - src_port - Source UDP port. It is not included in sent packets. Used only for port registration +// - dst_port - Destination UDP port +// - mcast_sw_if_index - Interface for multicast destination +// - encap_vrf_id - Encap route table FIB index +// - decap_next_index - index of decap next graph node +// - vni - The VXLAN Network Identifier, uint24 +// - is_l3 - if true, create the interface in L3 mode, w/o MAC +// +// VxlanAddDelTunnelV3 defines message 'vxlan_add_del_tunnel_v3'. +type VxlanAddDelTunnelV3 struct { + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + Instance uint32 `binapi:"u32,name=instance,default=4294967295" json:"instance,omitempty"` + SrcAddress ip_types.Address `binapi:"address,name=src_address" json:"src_address,omitempty"` + DstAddress ip_types.Address `binapi:"address,name=dst_address" json:"dst_address,omitempty"` + SrcPort uint16 `binapi:"u16,name=src_port" json:"src_port,omitempty"` + DstPort uint16 `binapi:"u16,name=dst_port" json:"dst_port,omitempty"` + McastSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=mcast_sw_if_index" json:"mcast_sw_if_index,omitempty"` + EncapVrfID uint32 `binapi:"u32,name=encap_vrf_id" json:"encap_vrf_id,omitempty"` + DecapNextIndex uint32 `binapi:"u32,name=decap_next_index" json:"decap_next_index,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + IsL3 bool `binapi:"bool,name=is_l3,default=false" json:"is_l3,omitempty"` +} + +func (m *VxlanAddDelTunnelV3) Reset() { *m = VxlanAddDelTunnelV3{} } +func (*VxlanAddDelTunnelV3) GetMessageName() string { return "vxlan_add_del_tunnel_v3" } +func (*VxlanAddDelTunnelV3) GetCrcString() string { return "0072b037" } +func (*VxlanAddDelTunnelV3) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VxlanAddDelTunnelV3) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Instance + size += 1 // m.SrcAddress.Af + size += 1 * 16 // m.SrcAddress.Un + size += 1 // m.DstAddress.Af + size += 1 * 16 // m.DstAddress.Un + size += 2 // m.SrcPort + size += 2 // m.DstPort + size += 4 // m.McastSwIfIndex + size += 4 // m.EncapVrfID + size += 4 // m.DecapNextIndex + size += 4 // m.Vni + size += 1 // m.IsL3 + return size +} +func (m *VxlanAddDelTunnelV3) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.Instance) + buf.EncodeUint8(uint8(m.SrcAddress.Af)) + buf.EncodeBytes(m.SrcAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.DstAddress.Af)) + buf.EncodeBytes(m.DstAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint16(m.SrcPort) + buf.EncodeUint16(m.DstPort) + buf.EncodeUint32(uint32(m.McastSwIfIndex)) + buf.EncodeUint32(m.EncapVrfID) + buf.EncodeUint32(m.DecapNextIndex) + buf.EncodeUint32(m.Vni) + buf.EncodeBool(m.IsL3) + return buf.Bytes(), nil +} +func (m *VxlanAddDelTunnelV3) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Instance = buf.DecodeUint32() + m.SrcAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.SrcAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.DstAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.DstAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.SrcPort = buf.DecodeUint16() + m.DstPort = buf.DecodeUint16() + m.McastSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.EncapVrfID = buf.DecodeUint32() + m.DecapNextIndex = buf.DecodeUint32() + m.Vni = buf.DecodeUint32() + m.IsL3 = buf.DecodeBool() + return nil +} + +// VxlanAddDelTunnelV3Reply defines message 'vxlan_add_del_tunnel_v3_reply'. +type VxlanAddDelTunnelV3Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *VxlanAddDelTunnelV3Reply) Reset() { *m = VxlanAddDelTunnelV3Reply{} } +func (*VxlanAddDelTunnelV3Reply) GetMessageName() string { return "vxlan_add_del_tunnel_v3_reply" } +func (*VxlanAddDelTunnelV3Reply) GetCrcString() string { return "5383d31f" } +func (*VxlanAddDelTunnelV3Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *VxlanAddDelTunnelV3Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *VxlanAddDelTunnelV3Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *VxlanAddDelTunnelV3Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Offload vxlan rx request +// - hw_if_index - rx hw interface +// - sw_if_index - vxlan interface to offload +// - enable - if non-zero enable, else disable +// +// VxlanOffloadRx defines message 'vxlan_offload_rx'. +type VxlanOffloadRx struct { + HwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=hw_if_index" json:"hw_if_index,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Enable bool `binapi:"bool,name=enable,default=true" json:"enable,omitempty"` +} + +func (m *VxlanOffloadRx) Reset() { *m = VxlanOffloadRx{} } +func (*VxlanOffloadRx) GetMessageName() string { return "vxlan_offload_rx" } +func (*VxlanOffloadRx) GetCrcString() string { return "9cc95087" } +func (*VxlanOffloadRx) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VxlanOffloadRx) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.HwIfIndex + size += 4 // m.SwIfIndex + size += 1 // m.Enable + return size +} +func (m *VxlanOffloadRx) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.HwIfIndex)) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.Enable) + return buf.Bytes(), nil +} +func (m *VxlanOffloadRx) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.HwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Enable = buf.DecodeBool() + return nil +} + +// VxlanOffloadRxReply defines message 'vxlan_offload_rx_reply'. +type VxlanOffloadRxReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *VxlanOffloadRxReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *VxlanOffloadRxReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *VxlanOffloadRxReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// VxlanTunnelDetails defines message 'vxlan_tunnel_details'. +type VxlanTunnelDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Instance uint32 `binapi:"u32,name=instance" json:"instance,omitempty"` + SrcAddress ip_types.Address `binapi:"address,name=src_address" json:"src_address,omitempty"` + DstAddress ip_types.Address `binapi:"address,name=dst_address" json:"dst_address,omitempty"` + McastSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=mcast_sw_if_index" json:"mcast_sw_if_index,omitempty"` + EncapVrfID uint32 `binapi:"u32,name=encap_vrf_id" json:"encap_vrf_id,omitempty"` + DecapNextIndex uint32 `binapi:"u32,name=decap_next_index" json:"decap_next_index,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` +} + +func (m *VxlanTunnelDetails) Reset() { *m = VxlanTunnelDetails{} } +func (*VxlanTunnelDetails) GetMessageName() string { return "vxlan_tunnel_details" } +func (*VxlanTunnelDetails) GetCrcString() string { return "c3916cb1" } +func (*VxlanTunnelDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *VxlanTunnelDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.Instance + size += 1 // m.SrcAddress.Af + size += 1 * 16 // m.SrcAddress.Un + size += 1 // m.DstAddress.Af + size += 1 * 16 // m.DstAddress.Un + size += 4 // m.McastSwIfIndex + size += 4 // m.EncapVrfID + size += 4 // m.DecapNextIndex + size += 4 // m.Vni + return size +} +func (m *VxlanTunnelDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.Instance) + buf.EncodeUint8(uint8(m.SrcAddress.Af)) + buf.EncodeBytes(m.SrcAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.DstAddress.Af)) + buf.EncodeBytes(m.DstAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.McastSwIfIndex)) + buf.EncodeUint32(m.EncapVrfID) + buf.EncodeUint32(m.DecapNextIndex) + buf.EncodeUint32(m.Vni) + return buf.Bytes(), nil +} +func (m *VxlanTunnelDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Instance = buf.DecodeUint32() + m.SrcAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.SrcAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.DstAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.DstAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.McastSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.EncapVrfID = buf.DecodeUint32() + m.DecapNextIndex = buf.DecodeUint32() + m.Vni = buf.DecodeUint32() + return nil +} + +// VxlanTunnelDump defines message 'vxlan_tunnel_dump'. +type VxlanTunnelDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *VxlanTunnelDump) Reset() { *m = VxlanTunnelDump{} } +func (*VxlanTunnelDump) GetMessageName() string { return "vxlan_tunnel_dump" } +func (*VxlanTunnelDump) GetCrcString() string { return "f9e6675e" } +func (*VxlanTunnelDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VxlanTunnelDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *VxlanTunnelDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *VxlanTunnelDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// VxlanTunnelV2Details defines message 'vxlan_tunnel_v2_details'. +type VxlanTunnelV2Details struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Instance uint32 `binapi:"u32,name=instance" json:"instance,omitempty"` + SrcAddress ip_types.Address `binapi:"address,name=src_address" json:"src_address,omitempty"` + DstAddress ip_types.Address `binapi:"address,name=dst_address" json:"dst_address,omitempty"` + SrcPort uint16 `binapi:"u16,name=src_port" json:"src_port,omitempty"` + DstPort uint16 `binapi:"u16,name=dst_port" json:"dst_port,omitempty"` + McastSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=mcast_sw_if_index" json:"mcast_sw_if_index,omitempty"` + EncapVrfID uint32 `binapi:"u32,name=encap_vrf_id" json:"encap_vrf_id,omitempty"` + DecapNextIndex uint32 `binapi:"u32,name=decap_next_index" json:"decap_next_index,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` +} + +func (m *VxlanTunnelV2Details) Reset() { *m = VxlanTunnelV2Details{} } +func (*VxlanTunnelV2Details) GetMessageName() string { return "vxlan_tunnel_v2_details" } +func (*VxlanTunnelV2Details) GetCrcString() string { return "d3bdd4d9" } +func (*VxlanTunnelV2Details) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *VxlanTunnelV2Details) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.Instance + size += 1 // m.SrcAddress.Af + size += 1 * 16 // m.SrcAddress.Un + size += 1 // m.DstAddress.Af + size += 1 * 16 // m.DstAddress.Un + size += 2 // m.SrcPort + size += 2 // m.DstPort + size += 4 // m.McastSwIfIndex + size += 4 // m.EncapVrfID + size += 4 // m.DecapNextIndex + size += 4 // m.Vni + return size +} +func (m *VxlanTunnelV2Details) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.Instance) + buf.EncodeUint8(uint8(m.SrcAddress.Af)) + buf.EncodeBytes(m.SrcAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.DstAddress.Af)) + buf.EncodeBytes(m.DstAddress.Un.XXX_UnionData[:], 16) + buf.EncodeUint16(m.SrcPort) + buf.EncodeUint16(m.DstPort) + buf.EncodeUint32(uint32(m.McastSwIfIndex)) + buf.EncodeUint32(m.EncapVrfID) + buf.EncodeUint32(m.DecapNextIndex) + buf.EncodeUint32(m.Vni) + return buf.Bytes(), nil +} +func (m *VxlanTunnelV2Details) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Instance = buf.DecodeUint32() + m.SrcAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.SrcAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.DstAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.DstAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.SrcPort = buf.DecodeUint16() + m.DstPort = buf.DecodeUint16() + m.McastSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.EncapVrfID = buf.DecodeUint32() + m.DecapNextIndex = buf.DecodeUint32() + m.Vni = buf.DecodeUint32() + return nil +} + +// VxlanTunnelV2Dump defines message 'vxlan_tunnel_v2_dump'. +type VxlanTunnelV2Dump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *VxlanTunnelV2Dump) Reset() { *m = VxlanTunnelV2Dump{} } +func (*VxlanTunnelV2Dump) GetMessageName() string { return "vxlan_tunnel_v2_dump" } +func (*VxlanTunnelV2Dump) GetCrcString() string { return "f9e6675e" } +func (*VxlanTunnelV2Dump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VxlanTunnelV2Dump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *VxlanTunnelV2Dump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *VxlanTunnelV2Dump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +func init() { file_vxlan_binapi_init() } +func file_vxlan_binapi_init() { + api.RegisterMessage((*SwInterfaceSetVxlanBypass)(nil), "sw_interface_set_vxlan_bypass_65247409") + api.RegisterMessage((*SwInterfaceSetVxlanBypassReply)(nil), "sw_interface_set_vxlan_bypass_reply_e8d4e804") + api.RegisterMessage((*VxlanAddDelTunnel)(nil), "vxlan_add_del_tunnel_0c09dc80") + api.RegisterMessage((*VxlanAddDelTunnelReply)(nil), "vxlan_add_del_tunnel_reply_5383d31f") + api.RegisterMessage((*VxlanAddDelTunnelV2)(nil), "vxlan_add_del_tunnel_v2_4f223f40") + api.RegisterMessage((*VxlanAddDelTunnelV2Reply)(nil), "vxlan_add_del_tunnel_v2_reply_5383d31f") + api.RegisterMessage((*VxlanAddDelTunnelV3)(nil), "vxlan_add_del_tunnel_v3_0072b037") + api.RegisterMessage((*VxlanAddDelTunnelV3Reply)(nil), "vxlan_add_del_tunnel_v3_reply_5383d31f") + api.RegisterMessage((*VxlanOffloadRx)(nil), "vxlan_offload_rx_9cc95087") + api.RegisterMessage((*VxlanOffloadRxReply)(nil), "vxlan_offload_rx_reply_e8d4e804") + api.RegisterMessage((*VxlanTunnelDetails)(nil), "vxlan_tunnel_details_c3916cb1") + api.RegisterMessage((*VxlanTunnelDump)(nil), "vxlan_tunnel_dump_f9e6675e") + api.RegisterMessage((*VxlanTunnelV2Details)(nil), "vxlan_tunnel_v2_details_d3bdd4d9") + api.RegisterMessage((*VxlanTunnelV2Dump)(nil), "vxlan_tunnel_v2_dump_f9e6675e") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*SwInterfaceSetVxlanBypass)(nil), + (*SwInterfaceSetVxlanBypassReply)(nil), + (*VxlanAddDelTunnel)(nil), + (*VxlanAddDelTunnelReply)(nil), + (*VxlanAddDelTunnelV2)(nil), + (*VxlanAddDelTunnelV2Reply)(nil), + (*VxlanAddDelTunnelV3)(nil), + (*VxlanAddDelTunnelV3Reply)(nil), + (*VxlanOffloadRx)(nil), + (*VxlanOffloadRxReply)(nil), + (*VxlanTunnelDetails)(nil), + (*VxlanTunnelDump)(nil), + (*VxlanTunnelV2Details)(nil), + (*VxlanTunnelV2Dump)(nil), + } +} diff --git a/binapi/vxlan/vxlan_rpc.ba.go b/binapi/vxlan/vxlan_rpc.ba.go new file mode 100644 index 00000000..3caa493b --- /dev/null +++ b/binapi/vxlan/vxlan_rpc.ba.go @@ -0,0 +1,162 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package vxlan + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service vxlan. +type RPCService interface { + SwInterfaceSetVxlanBypass(ctx context.Context, in *SwInterfaceSetVxlanBypass) (*SwInterfaceSetVxlanBypassReply, error) + VxlanAddDelTunnel(ctx context.Context, in *VxlanAddDelTunnel) (*VxlanAddDelTunnelReply, error) + VxlanAddDelTunnelV2(ctx context.Context, in *VxlanAddDelTunnelV2) (*VxlanAddDelTunnelV2Reply, error) + VxlanAddDelTunnelV3(ctx context.Context, in *VxlanAddDelTunnelV3) (*VxlanAddDelTunnelV3Reply, error) + VxlanOffloadRx(ctx context.Context, in *VxlanOffloadRx) (*VxlanOffloadRxReply, error) + VxlanTunnelDump(ctx context.Context, in *VxlanTunnelDump) (RPCService_VxlanTunnelDumpClient, error) + VxlanTunnelV2Dump(ctx context.Context, in *VxlanTunnelV2Dump) (RPCService_VxlanTunnelV2DumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) SwInterfaceSetVxlanBypass(ctx context.Context, in *SwInterfaceSetVxlanBypass) (*SwInterfaceSetVxlanBypassReply, error) { + out := new(SwInterfaceSetVxlanBypassReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) VxlanAddDelTunnel(ctx context.Context, in *VxlanAddDelTunnel) (*VxlanAddDelTunnelReply, error) { + out := new(VxlanAddDelTunnelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) VxlanAddDelTunnelV2(ctx context.Context, in *VxlanAddDelTunnelV2) (*VxlanAddDelTunnelV2Reply, error) { + out := new(VxlanAddDelTunnelV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) VxlanAddDelTunnelV3(ctx context.Context, in *VxlanAddDelTunnelV3) (*VxlanAddDelTunnelV3Reply, error) { + out := new(VxlanAddDelTunnelV3Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) VxlanOffloadRx(ctx context.Context, in *VxlanOffloadRx) (*VxlanOffloadRxReply, error) { + out := new(VxlanOffloadRxReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) VxlanTunnelDump(ctx context.Context, in *VxlanTunnelDump) (RPCService_VxlanTunnelDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_VxlanTunnelDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_VxlanTunnelDumpClient interface { + Recv() (*VxlanTunnelDetails, error) + api.Stream +} + +type serviceClient_VxlanTunnelDumpClient struct { + api.Stream +} + +func (c *serviceClient_VxlanTunnelDumpClient) Recv() (*VxlanTunnelDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *VxlanTunnelDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) VxlanTunnelV2Dump(ctx context.Context, in *VxlanTunnelV2Dump) (RPCService_VxlanTunnelV2DumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_VxlanTunnelV2DumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_VxlanTunnelV2DumpClient interface { + Recv() (*VxlanTunnelV2Details, error) + api.Stream +} + +type serviceClient_VxlanTunnelV2DumpClient struct { + api.Stream +} + +func (c *serviceClient_VxlanTunnelV2DumpClient) Recv() (*VxlanTunnelV2Details, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *VxlanTunnelV2Details: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/vxlan_gpe/vxlan_gpe.ba.go b/binapi/vxlan_gpe/vxlan_gpe.ba.go new file mode 100644 index 00000000..637437af --- /dev/null +++ b/binapi/vxlan_gpe/vxlan_gpe.ba.go @@ -0,0 +1,603 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: core/vxlan_gpe.api.json + +// Package vxlan_gpe contains generated bindings for API file vxlan_gpe.api. +// +// Contents: +// - 10 messages +package vxlan_gpe + +import ( + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "vxlan_gpe" + APIVersion = "2.1.0" + VersionCrc = 0x3bc06278 +) + +// Interface set vxlan-gpe-bypass request +// - sw_if_index - interface used to reach neighbor +// - is_ipv6 - if non-zero, enable ipv6-vxlan-bypass, else ipv4-vxlan-bypass +// - enable - if non-zero enable, else disable +// +// SwInterfaceSetVxlanGpeBypass defines message 'sw_interface_set_vxlan_gpe_bypass'. +type SwInterfaceSetVxlanGpeBypass struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IsIPv6 bool `binapi:"bool,name=is_ipv6" json:"is_ipv6,omitempty"` + Enable bool `binapi:"bool,name=enable,default=true" json:"enable,omitempty"` +} + +func (m *SwInterfaceSetVxlanGpeBypass) Reset() { *m = SwInterfaceSetVxlanGpeBypass{} } +func (*SwInterfaceSetVxlanGpeBypass) GetMessageName() string { + return "sw_interface_set_vxlan_gpe_bypass" +} +func (*SwInterfaceSetVxlanGpeBypass) GetCrcString() string { return "65247409" } +func (*SwInterfaceSetVxlanGpeBypass) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSetVxlanGpeBypass) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.IsIPv6 + size += 1 // m.Enable + return size +} +func (m *SwInterfaceSetVxlanGpeBypass) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeBool(m.IsIPv6) + buf.EncodeBool(m.Enable) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetVxlanGpeBypass) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IsIPv6 = buf.DecodeBool() + m.Enable = buf.DecodeBool() + return nil +} + +// SwInterfaceSetVxlanGpeBypassReply defines message 'sw_interface_set_vxlan_gpe_bypass_reply'. +type SwInterfaceSetVxlanGpeBypassReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +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 +} + +func (m *SwInterfaceSetVxlanGpeBypassReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSetVxlanGpeBypassReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSetVxlanGpeBypassReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// /* +// - Copyright (c) 2015-2016 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. +// +// VxlanGpeAddDelTunnel defines message 'vxlan_gpe_add_del_tunnel'. +type VxlanGpeAddDelTunnel struct { + Local ip_types.Address `binapi:"address,name=local" json:"local,omitempty"` + Remote ip_types.Address `binapi:"address,name=remote" json:"remote,omitempty"` + McastSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=mcast_sw_if_index" json:"mcast_sw_if_index,omitempty"` + EncapVrfID uint32 `binapi:"u32,name=encap_vrf_id" json:"encap_vrf_id,omitempty"` + DecapVrfID uint32 `binapi:"u32,name=decap_vrf_id" json:"decap_vrf_id,omitempty"` + Protocol ip_types.IPProto `binapi:"ip_proto,name=protocol" json:"protocol,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` +} + +func (m *VxlanGpeAddDelTunnel) Reset() { *m = VxlanGpeAddDelTunnel{} } +func (*VxlanGpeAddDelTunnel) GetMessageName() string { return "vxlan_gpe_add_del_tunnel" } +func (*VxlanGpeAddDelTunnel) GetCrcString() string { return "a645b2b0" } +func (*VxlanGpeAddDelTunnel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VxlanGpeAddDelTunnel) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Local.Af + size += 1 * 16 // m.Local.Un + size += 1 // m.Remote.Af + size += 1 * 16 // m.Remote.Un + size += 4 // m.McastSwIfIndex + size += 4 // m.EncapVrfID + size += 4 // m.DecapVrfID + size += 1 // m.Protocol + size += 4 // m.Vni + size += 1 // m.IsAdd + return size +} +func (m *VxlanGpeAddDelTunnel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Local.Af)) + buf.EncodeBytes(m.Local.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Remote.Af)) + buf.EncodeBytes(m.Remote.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.McastSwIfIndex)) + buf.EncodeUint32(m.EncapVrfID) + buf.EncodeUint32(m.DecapVrfID) + buf.EncodeUint8(uint8(m.Protocol)) + buf.EncodeUint32(m.Vni) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *VxlanGpeAddDelTunnel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Local.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Local.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Remote.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Remote.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.McastSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.EncapVrfID = buf.DecodeUint32() + m.DecapVrfID = buf.DecodeUint32() + m.Protocol = ip_types.IPProto(buf.DecodeUint8()) + m.Vni = buf.DecodeUint32() + m.IsAdd = buf.DecodeBool() + return nil +} + +// VxlanGpeAddDelTunnelReply defines message 'vxlan_gpe_add_del_tunnel_reply'. +type VxlanGpeAddDelTunnelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *VxlanGpeAddDelTunnelReply) Reset() { *m = VxlanGpeAddDelTunnelReply{} } +func (*VxlanGpeAddDelTunnelReply) GetMessageName() string { return "vxlan_gpe_add_del_tunnel_reply" } +func (*VxlanGpeAddDelTunnelReply) GetCrcString() string { return "5383d31f" } +func (*VxlanGpeAddDelTunnelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *VxlanGpeAddDelTunnelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *VxlanGpeAddDelTunnelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *VxlanGpeAddDelTunnelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Create or delete a VXLAN-GPE tunnel +// - local - Source IP address +// - remote - Destination IP address, can be multicast +// - local_port - Source UDP port. It is not included in sent packets. Used only for port registration +// - remote_port - Destination UDP port +// - mcast_sw_if_index - Interface for multicast destination +// - encap_vrf_id - Encap route table FIB index +// - decap_vrf_id - Decap route table FIB index +// - protocol - Encapsulated protocol +// - vni - The VXLAN Network Identifier, uint24 +// - is_add - Use 1 to create the tunnel, 0 to remove it +// +// VxlanGpeAddDelTunnelV2 defines message 'vxlan_gpe_add_del_tunnel_v2'. +type VxlanGpeAddDelTunnelV2 struct { + Local ip_types.Address `binapi:"address,name=local" json:"local,omitempty"` + Remote ip_types.Address `binapi:"address,name=remote" json:"remote,omitempty"` + LocalPort uint16 `binapi:"u16,name=local_port" json:"local_port,omitempty"` + RemotePort uint16 `binapi:"u16,name=remote_port" json:"remote_port,omitempty"` + McastSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=mcast_sw_if_index" json:"mcast_sw_if_index,omitempty"` + EncapVrfID uint32 `binapi:"u32,name=encap_vrf_id" json:"encap_vrf_id,omitempty"` + DecapVrfID uint32 `binapi:"u32,name=decap_vrf_id" json:"decap_vrf_id,omitempty"` + Protocol ip_types.IPProto `binapi:"ip_proto,name=protocol" json:"protocol,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` +} + +func (m *VxlanGpeAddDelTunnelV2) Reset() { *m = VxlanGpeAddDelTunnelV2{} } +func (*VxlanGpeAddDelTunnelV2) GetMessageName() string { return "vxlan_gpe_add_del_tunnel_v2" } +func (*VxlanGpeAddDelTunnelV2) GetCrcString() string { return "d62fdb35" } +func (*VxlanGpeAddDelTunnelV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VxlanGpeAddDelTunnelV2) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Local.Af + size += 1 * 16 // m.Local.Un + size += 1 // m.Remote.Af + size += 1 * 16 // m.Remote.Un + size += 2 // m.LocalPort + size += 2 // m.RemotePort + size += 4 // m.McastSwIfIndex + size += 4 // m.EncapVrfID + size += 4 // m.DecapVrfID + size += 1 // m.Protocol + size += 4 // m.Vni + size += 1 // m.IsAdd + return size +} +func (m *VxlanGpeAddDelTunnelV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Local.Af)) + buf.EncodeBytes(m.Local.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Remote.Af)) + buf.EncodeBytes(m.Remote.Un.XXX_UnionData[:], 16) + buf.EncodeUint16(m.LocalPort) + buf.EncodeUint16(m.RemotePort) + buf.EncodeUint32(uint32(m.McastSwIfIndex)) + buf.EncodeUint32(m.EncapVrfID) + buf.EncodeUint32(m.DecapVrfID) + buf.EncodeUint8(uint8(m.Protocol)) + buf.EncodeUint32(m.Vni) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *VxlanGpeAddDelTunnelV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Local.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Local.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Remote.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Remote.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.LocalPort = buf.DecodeUint16() + m.RemotePort = buf.DecodeUint16() + m.McastSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.EncapVrfID = buf.DecodeUint32() + m.DecapVrfID = buf.DecodeUint32() + m.Protocol = ip_types.IPProto(buf.DecodeUint8()) + m.Vni = buf.DecodeUint32() + m.IsAdd = buf.DecodeBool() + return nil +} + +// VxlanGpeAddDelTunnelV2Reply defines message 'vxlan_gpe_add_del_tunnel_v2_reply'. +type VxlanGpeAddDelTunnelV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *VxlanGpeAddDelTunnelV2Reply) Reset() { *m = VxlanGpeAddDelTunnelV2Reply{} } +func (*VxlanGpeAddDelTunnelV2Reply) GetMessageName() string { + return "vxlan_gpe_add_del_tunnel_v2_reply" +} +func (*VxlanGpeAddDelTunnelV2Reply) GetCrcString() string { return "5383d31f" } +func (*VxlanGpeAddDelTunnelV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *VxlanGpeAddDelTunnelV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *VxlanGpeAddDelTunnelV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *VxlanGpeAddDelTunnelV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// VxlanGpeTunnelDetails defines message 'vxlan_gpe_tunnel_details'. +type VxlanGpeTunnelDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Local ip_types.Address `binapi:"address,name=local" json:"local,omitempty"` + Remote ip_types.Address `binapi:"address,name=remote" json:"remote,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + Protocol ip_types.IPProto `binapi:"ip_proto,name=protocol" json:"protocol,omitempty"` + McastSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=mcast_sw_if_index" json:"mcast_sw_if_index,omitempty"` + EncapVrfID uint32 `binapi:"u32,name=encap_vrf_id" json:"encap_vrf_id,omitempty"` + DecapVrfID uint32 `binapi:"u32,name=decap_vrf_id" json:"decap_vrf_id,omitempty"` + IsIPv6 bool `binapi:"bool,name=is_ipv6" json:"is_ipv6,omitempty"` +} + +func (m *VxlanGpeTunnelDetails) Reset() { *m = VxlanGpeTunnelDetails{} } +func (*VxlanGpeTunnelDetails) GetMessageName() string { return "vxlan_gpe_tunnel_details" } +func (*VxlanGpeTunnelDetails) GetCrcString() string { return "0968fc8b" } +func (*VxlanGpeTunnelDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *VxlanGpeTunnelDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.Local.Af + size += 1 * 16 // m.Local.Un + size += 1 // m.Remote.Af + size += 1 * 16 // m.Remote.Un + size += 4 // m.Vni + size += 1 // m.Protocol + size += 4 // m.McastSwIfIndex + size += 4 // m.EncapVrfID + size += 4 // m.DecapVrfID + size += 1 // m.IsIPv6 + return size +} +func (m *VxlanGpeTunnelDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(uint8(m.Local.Af)) + buf.EncodeBytes(m.Local.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Remote.Af)) + buf.EncodeBytes(m.Remote.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(m.Vni) + buf.EncodeUint8(uint8(m.Protocol)) + buf.EncodeUint32(uint32(m.McastSwIfIndex)) + buf.EncodeUint32(m.EncapVrfID) + buf.EncodeUint32(m.DecapVrfID) + buf.EncodeBool(m.IsIPv6) + return buf.Bytes(), nil +} +func (m *VxlanGpeTunnelDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Local.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Local.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Remote.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Remote.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Vni = buf.DecodeUint32() + m.Protocol = ip_types.IPProto(buf.DecodeUint8()) + m.McastSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.EncapVrfID = buf.DecodeUint32() + m.DecapVrfID = buf.DecodeUint32() + m.IsIPv6 = buf.DecodeBool() + return nil +} + +// VxlanGpeTunnelDump defines message 'vxlan_gpe_tunnel_dump'. +type VxlanGpeTunnelDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *VxlanGpeTunnelDump) Reset() { *m = VxlanGpeTunnelDump{} } +func (*VxlanGpeTunnelDump) GetMessageName() string { return "vxlan_gpe_tunnel_dump" } +func (*VxlanGpeTunnelDump) GetCrcString() string { return "f9e6675e" } +func (*VxlanGpeTunnelDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VxlanGpeTunnelDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *VxlanGpeTunnelDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *VxlanGpeTunnelDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// VxlanGpeTunnelV2Details defines message 'vxlan_gpe_tunnel_v2_details'. +type VxlanGpeTunnelV2Details struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Local ip_types.Address `binapi:"address,name=local" json:"local,omitempty"` + Remote ip_types.Address `binapi:"address,name=remote" json:"remote,omitempty"` + LocalPort uint16 `binapi:"u16,name=local_port" json:"local_port,omitempty"` + RemotePort uint16 `binapi:"u16,name=remote_port" json:"remote_port,omitempty"` + Vni uint32 `binapi:"u32,name=vni" json:"vni,omitempty"` + Protocol ip_types.IPProto `binapi:"ip_proto,name=protocol" json:"protocol,omitempty"` + McastSwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=mcast_sw_if_index" json:"mcast_sw_if_index,omitempty"` + EncapVrfID uint32 `binapi:"u32,name=encap_vrf_id" json:"encap_vrf_id,omitempty"` + DecapVrfID uint32 `binapi:"u32,name=decap_vrf_id" json:"decap_vrf_id,omitempty"` + IsIPv6 bool `binapi:"bool,name=is_ipv6" json:"is_ipv6,omitempty"` +} + +func (m *VxlanGpeTunnelV2Details) Reset() { *m = VxlanGpeTunnelV2Details{} } +func (*VxlanGpeTunnelV2Details) GetMessageName() string { return "vxlan_gpe_tunnel_v2_details" } +func (*VxlanGpeTunnelV2Details) GetCrcString() string { return "06be4870" } +func (*VxlanGpeTunnelV2Details) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *VxlanGpeTunnelV2Details) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 1 // m.Local.Af + size += 1 * 16 // m.Local.Un + size += 1 // m.Remote.Af + size += 1 * 16 // m.Remote.Un + size += 2 // m.LocalPort + size += 2 // m.RemotePort + size += 4 // m.Vni + size += 1 // m.Protocol + size += 4 // m.McastSwIfIndex + size += 4 // m.EncapVrfID + size += 4 // m.DecapVrfID + size += 1 // m.IsIPv6 + return size +} +func (m *VxlanGpeTunnelV2Details) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(uint8(m.Local.Af)) + buf.EncodeBytes(m.Local.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(uint8(m.Remote.Af)) + buf.EncodeBytes(m.Remote.Un.XXX_UnionData[:], 16) + buf.EncodeUint16(m.LocalPort) + buf.EncodeUint16(m.RemotePort) + buf.EncodeUint32(m.Vni) + buf.EncodeUint8(uint8(m.Protocol)) + buf.EncodeUint32(uint32(m.McastSwIfIndex)) + buf.EncodeUint32(m.EncapVrfID) + buf.EncodeUint32(m.DecapVrfID) + buf.EncodeBool(m.IsIPv6) + return buf.Bytes(), nil +} +func (m *VxlanGpeTunnelV2Details) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Local.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Local.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Remote.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Remote.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.LocalPort = buf.DecodeUint16() + m.RemotePort = buf.DecodeUint16() + m.Vni = buf.DecodeUint32() + m.Protocol = ip_types.IPProto(buf.DecodeUint8()) + m.McastSwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.EncapVrfID = buf.DecodeUint32() + m.DecapVrfID = buf.DecodeUint32() + m.IsIPv6 = buf.DecodeBool() + return nil +} + +// VxlanGpeTunnelV2Dump defines message 'vxlan_gpe_tunnel_v2_dump'. +type VxlanGpeTunnelV2Dump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *VxlanGpeTunnelV2Dump) Reset() { *m = VxlanGpeTunnelV2Dump{} } +func (*VxlanGpeTunnelV2Dump) GetMessageName() string { return "vxlan_gpe_tunnel_v2_dump" } +func (*VxlanGpeTunnelV2Dump) GetCrcString() string { return "f9e6675e" } +func (*VxlanGpeTunnelV2Dump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VxlanGpeTunnelV2Dump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *VxlanGpeTunnelV2Dump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *VxlanGpeTunnelV2Dump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +func init() { file_vxlan_gpe_binapi_init() } +func file_vxlan_gpe_binapi_init() { + api.RegisterMessage((*SwInterfaceSetVxlanGpeBypass)(nil), "sw_interface_set_vxlan_gpe_bypass_65247409") + api.RegisterMessage((*SwInterfaceSetVxlanGpeBypassReply)(nil), "sw_interface_set_vxlan_gpe_bypass_reply_e8d4e804") + api.RegisterMessage((*VxlanGpeAddDelTunnel)(nil), "vxlan_gpe_add_del_tunnel_a645b2b0") + api.RegisterMessage((*VxlanGpeAddDelTunnelReply)(nil), "vxlan_gpe_add_del_tunnel_reply_5383d31f") + api.RegisterMessage((*VxlanGpeAddDelTunnelV2)(nil), "vxlan_gpe_add_del_tunnel_v2_d62fdb35") + api.RegisterMessage((*VxlanGpeAddDelTunnelV2Reply)(nil), "vxlan_gpe_add_del_tunnel_v2_reply_5383d31f") + api.RegisterMessage((*VxlanGpeTunnelDetails)(nil), "vxlan_gpe_tunnel_details_0968fc8b") + api.RegisterMessage((*VxlanGpeTunnelDump)(nil), "vxlan_gpe_tunnel_dump_f9e6675e") + api.RegisterMessage((*VxlanGpeTunnelV2Details)(nil), "vxlan_gpe_tunnel_v2_details_06be4870") + api.RegisterMessage((*VxlanGpeTunnelV2Dump)(nil), "vxlan_gpe_tunnel_v2_dump_f9e6675e") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*SwInterfaceSetVxlanGpeBypass)(nil), + (*SwInterfaceSetVxlanGpeBypassReply)(nil), + (*VxlanGpeAddDelTunnel)(nil), + (*VxlanGpeAddDelTunnelReply)(nil), + (*VxlanGpeAddDelTunnelV2)(nil), + (*VxlanGpeAddDelTunnelV2Reply)(nil), + (*VxlanGpeTunnelDetails)(nil), + (*VxlanGpeTunnelDump)(nil), + (*VxlanGpeTunnelV2Details)(nil), + (*VxlanGpeTunnelV2Dump)(nil), + } +} diff --git a/binapi/vxlan_gpe/vxlan_gpe_rpc.ba.go b/binapi/vxlan_gpe/vxlan_gpe_rpc.ba.go new file mode 100644 index 00000000..4add382a --- /dev/null +++ b/binapi/vxlan_gpe/vxlan_gpe_rpc.ba.go @@ -0,0 +1,142 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package vxlan_gpe + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service vxlan_gpe. +type RPCService interface { + SwInterfaceSetVxlanGpeBypass(ctx context.Context, in *SwInterfaceSetVxlanGpeBypass) (*SwInterfaceSetVxlanGpeBypassReply, error) + VxlanGpeAddDelTunnel(ctx context.Context, in *VxlanGpeAddDelTunnel) (*VxlanGpeAddDelTunnelReply, error) + VxlanGpeAddDelTunnelV2(ctx context.Context, in *VxlanGpeAddDelTunnelV2) (*VxlanGpeAddDelTunnelV2Reply, error) + VxlanGpeTunnelDump(ctx context.Context, in *VxlanGpeTunnelDump) (RPCService_VxlanGpeTunnelDumpClient, error) + VxlanGpeTunnelV2Dump(ctx context.Context, in *VxlanGpeTunnelV2Dump) (RPCService_VxlanGpeTunnelV2DumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) SwInterfaceSetVxlanGpeBypass(ctx context.Context, in *SwInterfaceSetVxlanGpeBypass) (*SwInterfaceSetVxlanGpeBypassReply, error) { + out := new(SwInterfaceSetVxlanGpeBypassReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) VxlanGpeAddDelTunnel(ctx context.Context, in *VxlanGpeAddDelTunnel) (*VxlanGpeAddDelTunnelReply, error) { + out := new(VxlanGpeAddDelTunnelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) VxlanGpeAddDelTunnelV2(ctx context.Context, in *VxlanGpeAddDelTunnelV2) (*VxlanGpeAddDelTunnelV2Reply, error) { + out := new(VxlanGpeAddDelTunnelV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) VxlanGpeTunnelDump(ctx context.Context, in *VxlanGpeTunnelDump) (RPCService_VxlanGpeTunnelDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_VxlanGpeTunnelDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_VxlanGpeTunnelDumpClient interface { + Recv() (*VxlanGpeTunnelDetails, error) + api.Stream +} + +type serviceClient_VxlanGpeTunnelDumpClient struct { + api.Stream +} + +func (c *serviceClient_VxlanGpeTunnelDumpClient) Recv() (*VxlanGpeTunnelDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *VxlanGpeTunnelDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) VxlanGpeTunnelV2Dump(ctx context.Context, in *VxlanGpeTunnelV2Dump) (RPCService_VxlanGpeTunnelV2DumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_VxlanGpeTunnelV2DumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_VxlanGpeTunnelV2DumpClient interface { + Recv() (*VxlanGpeTunnelV2Details, error) + api.Stream +} + +type serviceClient_VxlanGpeTunnelV2DumpClient struct { + api.Stream +} + +func (c *serviceClient_VxlanGpeTunnelV2DumpClient) Recv() (*VxlanGpeTunnelV2Details, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *VxlanGpeTunnelV2Details: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapi/vxlan_gpe_ioam_export/vxlan_gpe_ioam_export.ba.go b/binapi/vxlan_gpe_ioam_export/vxlan_gpe_ioam_export.ba.go new file mode 100644 index 00000000..3741f5dc --- /dev/null +++ b/binapi/vxlan_gpe_ioam_export/vxlan_gpe_ioam_export.ba.go @@ -0,0 +1,122 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/vxlan_gpe_ioam_export.api.json + +// Package vxlan_gpe_ioam_export contains generated bindings for API file vxlan_gpe_ioam_export.api. +// +// Contents: +// - 2 messages +package vxlan_gpe_ioam_export + +import ( + api "github.com/alkiranet/govpp/api" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "vxlan_gpe_ioam_export" + APIVersion = "1.0.0" + VersionCrc = 0x26bebf64 +) + +// /* Define a simple binary API to control the feature +// VxlanGpeIoamExportEnableDisable defines message 'vxlan_gpe_ioam_export_enable_disable'. +type VxlanGpeIoamExportEnableDisable struct { + IsDisable bool `binapi:"bool,name=is_disable" json:"is_disable,omitempty"` + CollectorAddress ip_types.IP4Address `binapi:"ip4_address,name=collector_address" json:"collector_address,omitempty"` + SrcAddress ip_types.IP4Address `binapi:"ip4_address,name=src_address" json:"src_address,omitempty"` +} + +func (m *VxlanGpeIoamExportEnableDisable) Reset() { *m = VxlanGpeIoamExportEnableDisable{} } +func (*VxlanGpeIoamExportEnableDisable) GetMessageName() string { + return "vxlan_gpe_ioam_export_enable_disable" +} +func (*VxlanGpeIoamExportEnableDisable) GetCrcString() string { return "d4c76d3a" } +func (*VxlanGpeIoamExportEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *VxlanGpeIoamExportEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsDisable + size += 1 * 4 // m.CollectorAddress + size += 1 * 4 // m.SrcAddress + return size +} +func (m *VxlanGpeIoamExportEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsDisable) + buf.EncodeBytes(m.CollectorAddress[:], 4) + buf.EncodeBytes(m.SrcAddress[:], 4) + return buf.Bytes(), nil +} +func (m *VxlanGpeIoamExportEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsDisable = buf.DecodeBool() + copy(m.CollectorAddress[:], buf.DecodeBytes(4)) + copy(m.SrcAddress[:], buf.DecodeBytes(4)) + return nil +} + +// VxlanGpeIoamExportEnableDisableReply defines message 'vxlan_gpe_ioam_export_enable_disable_reply'. +type VxlanGpeIoamExportEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *VxlanGpeIoamExportEnableDisableReply) Reset() { *m = VxlanGpeIoamExportEnableDisableReply{} } +func (*VxlanGpeIoamExportEnableDisableReply) GetMessageName() string { + return "vxlan_gpe_ioam_export_enable_disable_reply" +} +func (*VxlanGpeIoamExportEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*VxlanGpeIoamExportEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *VxlanGpeIoamExportEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *VxlanGpeIoamExportEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *VxlanGpeIoamExportEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_vxlan_gpe_ioam_export_binapi_init() } +func file_vxlan_gpe_ioam_export_binapi_init() { + api.RegisterMessage((*VxlanGpeIoamExportEnableDisable)(nil), "vxlan_gpe_ioam_export_enable_disable_d4c76d3a") + api.RegisterMessage((*VxlanGpeIoamExportEnableDisableReply)(nil), "vxlan_gpe_ioam_export_enable_disable_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*VxlanGpeIoamExportEnableDisable)(nil), + (*VxlanGpeIoamExportEnableDisableReply)(nil), + } +} diff --git a/binapi/vxlan_gpe_ioam_export/vxlan_gpe_ioam_export_rpc.ba.go b/binapi/vxlan_gpe_ioam_export/vxlan_gpe_ioam_export_rpc.ba.go new file mode 100644 index 00000000..fd533037 --- /dev/null +++ b/binapi/vxlan_gpe_ioam_export/vxlan_gpe_ioam_export_rpc.ba.go @@ -0,0 +1,31 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package vxlan_gpe_ioam_export + +import ( + "context" + + api "github.com/alkiranet/govpp/api" +) + +// RPCService defines RPC service vxlan_gpe_ioam_export. +type RPCService interface { + VxlanGpeIoamExportEnableDisable(ctx context.Context, in *VxlanGpeIoamExportEnableDisable) (*VxlanGpeIoamExportEnableDisableReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) VxlanGpeIoamExportEnableDisable(ctx context.Context, in *VxlanGpeIoamExportEnableDisable) (*VxlanGpeIoamExportEnableDisableReply, error) { + out := new(VxlanGpeIoamExportEnableDisableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/binapi/wireguard/wireguard.ba.go b/binapi/wireguard/wireguard.ba.go new file mode 100644 index 00000000..e40dd92f --- /dev/null +++ b/binapi/wireguard/wireguard.ba.go @@ -0,0 +1,932 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.8.0 +// VPP: 23.06-release +// source: plugins/wireguard.api.json + +// Package wireguard contains generated bindings for API file wireguard.api. +// +// Contents: +// - 1 enum +// - 2 structs +// - 17 messages +package wireguard + +import ( + "strconv" + + api "github.com/alkiranet/govpp/api" + interface_types "github.com/alkiranet/govpp/binapi/interface_types" + ip_types "github.com/alkiranet/govpp/binapi/ip_types" + codec "github.com/alkiranet/govpp/codec" +) + +// 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.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "wireguard" + APIVersion = "0.3.0" + VersionCrc = 0x5d8f9252 +) + +// WireguardPeerFlags defines enum 'wireguard_peer_flags'. +type WireguardPeerFlags uint8 + +const ( + WIREGUARD_PEER_STATUS_DEAD WireguardPeerFlags = 1 + WIREGUARD_PEER_ESTABLISHED WireguardPeerFlags = 2 +) + +var ( + WireguardPeerFlags_name = map[uint8]string{ + 1: "WIREGUARD_PEER_STATUS_DEAD", + 2: "WIREGUARD_PEER_ESTABLISHED", + } + WireguardPeerFlags_value = map[string]uint8{ + "WIREGUARD_PEER_STATUS_DEAD": 1, + "WIREGUARD_PEER_ESTABLISHED": 2, + } +) + +func (x WireguardPeerFlags) String() string { + s, ok := WireguardPeerFlags_name[uint8(x)] + if ok { + return s + } + str := func(n uint8) string { + s, ok := WireguardPeerFlags_name[uint8(n)] + if ok { + return s + } + return "WireguardPeerFlags(" + strconv.Itoa(int(n)) + ")" + } + for i := uint8(0); i <= 8; i++ { + val := uint8(x) + if val&(1< register for events, 0 => cancel registration +// - pid - sender's pid +// +// WantWireguardPeerEvents defines message 'want_wireguard_peer_events'. +type WantWireguardPeerEvents struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` + PeerIndex uint32 `binapi:"u32,name=peer_index,default=4294967295" json:"peer_index,omitempty"` + EnableDisable uint32 `binapi:"u32,name=enable_disable" json:"enable_disable,omitempty"` + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` +} + +func (m *WantWireguardPeerEvents) Reset() { *m = WantWireguardPeerEvents{} } +func (*WantWireguardPeerEvents) GetMessageName() string { return "want_wireguard_peer_events" } +func (*WantWireguardPeerEvents) GetCrcString() string { return "3bc666c8" } +func (*WantWireguardPeerEvents) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *WantWireguardPeerEvents) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.PeerIndex + size += 4 // m.EnableDisable + size += 4 // m.PID + return size +} +func (m *WantWireguardPeerEvents) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.PeerIndex) + buf.EncodeUint32(m.EnableDisable) + buf.EncodeUint32(m.PID) + return buf.Bytes(), nil +} +func (m *WantWireguardPeerEvents) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.PeerIndex = buf.DecodeUint32() + m.EnableDisable = buf.DecodeUint32() + m.PID = buf.DecodeUint32() + return nil +} + +// WantWireguardPeerEventsReply defines message 'want_wireguard_peer_events_reply'. +type WantWireguardPeerEventsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *WantWireguardPeerEventsReply) Reset() { *m = WantWireguardPeerEventsReply{} } +func (*WantWireguardPeerEventsReply) GetMessageName() string { + return "want_wireguard_peer_events_reply" +} +func (*WantWireguardPeerEventsReply) GetCrcString() string { return "e8d4e804" } +func (*WantWireguardPeerEventsReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *WantWireguardPeerEventsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *WantWireguardPeerEventsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *WantWireguardPeerEventsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Wireguard Set Async mode +// - async_enable - wireguard async mode on or off, default off +// +// WgSetAsyncMode defines message 'wg_set_async_mode'. +type WgSetAsyncMode struct { + AsyncEnable bool `binapi:"bool,name=async_enable,default=false" json:"async_enable,omitempty"` +} + +func (m *WgSetAsyncMode) Reset() { *m = WgSetAsyncMode{} } +func (*WgSetAsyncMode) GetMessageName() string { return "wg_set_async_mode" } +func (*WgSetAsyncMode) GetCrcString() string { return "a6465f7c" } +func (*WgSetAsyncMode) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *WgSetAsyncMode) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.AsyncEnable + return size +} +func (m *WgSetAsyncMode) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.AsyncEnable) + return buf.Bytes(), nil +} +func (m *WgSetAsyncMode) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.AsyncEnable = buf.DecodeBool() + return nil +} + +// WgSetAsyncModeReply defines message 'wg_set_async_mode_reply'. +type WgSetAsyncModeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *WgSetAsyncModeReply) Reset() { *m = WgSetAsyncModeReply{} } +func (*WgSetAsyncModeReply) GetMessageName() string { return "wg_set_async_mode_reply" } +func (*WgSetAsyncModeReply) GetCrcString() string { return "e8d4e804" } +func (*WgSetAsyncModeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *WgSetAsyncModeReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *WgSetAsyncModeReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *WgSetAsyncModeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Create an Wireguard interface +// WireguardInterfaceCreate defines message 'wireguard_interface_create'. +type WireguardInterfaceCreate struct { + Interface WireguardInterface `binapi:"wireguard_interface,name=interface" json:"interface,omitempty"` + GenerateKey bool `binapi:"bool,name=generate_key" json:"generate_key,omitempty"` +} + +func (m *WireguardInterfaceCreate) Reset() { *m = WireguardInterfaceCreate{} } +func (*WireguardInterfaceCreate) GetMessageName() string { return "wireguard_interface_create" } +func (*WireguardInterfaceCreate) GetCrcString() string { return "a530137e" } +func (*WireguardInterfaceCreate) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *WireguardInterfaceCreate) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Interface.UserInstance + size += 4 // m.Interface.SwIfIndex + size += 1 * 32 // m.Interface.PrivateKey + size += 1 * 32 // m.Interface.PublicKey + size += 2 // m.Interface.Port + size += 1 // m.Interface.SrcIP.Af + size += 1 * 16 // m.Interface.SrcIP.Un + size += 1 // m.GenerateKey + return size +} +func (m *WireguardInterfaceCreate) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Interface.UserInstance) + buf.EncodeUint32(uint32(m.Interface.SwIfIndex)) + buf.EncodeBytes(m.Interface.PrivateKey, 32) + buf.EncodeBytes(m.Interface.PublicKey, 32) + buf.EncodeUint16(m.Interface.Port) + buf.EncodeUint8(uint8(m.Interface.SrcIP.Af)) + buf.EncodeBytes(m.Interface.SrcIP.Un.XXX_UnionData[:], 16) + buf.EncodeBool(m.GenerateKey) + return buf.Bytes(), nil +} +func (m *WireguardInterfaceCreate) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Interface.UserInstance = buf.DecodeUint32() + m.Interface.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Interface.PrivateKey = make([]byte, 32) + copy(m.Interface.PrivateKey, buf.DecodeBytes(len(m.Interface.PrivateKey))) + m.Interface.PublicKey = make([]byte, 32) + copy(m.Interface.PublicKey, buf.DecodeBytes(len(m.Interface.PublicKey))) + m.Interface.Port = buf.DecodeUint16() + m.Interface.SrcIP.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Interface.SrcIP.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.GenerateKey = buf.DecodeBool() + return nil +} + +// Add Wireguard interface interface response +// - retval - return status +// - sw_if_index - sw_if_index of new interface (for successful add) +// +// WireguardInterfaceCreateReply defines message 'wireguard_interface_create_reply'. +type WireguardInterfaceCreateReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *WireguardInterfaceCreateReply) Reset() { *m = WireguardInterfaceCreateReply{} } +func (*WireguardInterfaceCreateReply) GetMessageName() string { + return "wireguard_interface_create_reply" +} +func (*WireguardInterfaceCreateReply) GetCrcString() string { return "5383d31f" } +func (*WireguardInterfaceCreateReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *WireguardInterfaceCreateReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *WireguardInterfaceCreateReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *WireguardInterfaceCreateReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// WireguardInterfaceDelete defines message 'wireguard_interface_delete'. +type WireguardInterfaceDelete struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *WireguardInterfaceDelete) Reset() { *m = WireguardInterfaceDelete{} } +func (*WireguardInterfaceDelete) GetMessageName() string { return "wireguard_interface_delete" } +func (*WireguardInterfaceDelete) GetCrcString() string { return "f9e6675e" } +func (*WireguardInterfaceDelete) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *WireguardInterfaceDelete) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *WireguardInterfaceDelete) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *WireguardInterfaceDelete) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// WireguardInterfaceDeleteReply defines message 'wireguard_interface_delete_reply'. +type WireguardInterfaceDeleteReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *WireguardInterfaceDeleteReply) Reset() { *m = WireguardInterfaceDeleteReply{} } +func (*WireguardInterfaceDeleteReply) GetMessageName() string { + return "wireguard_interface_delete_reply" +} +func (*WireguardInterfaceDeleteReply) GetCrcString() string { return "e8d4e804" } +func (*WireguardInterfaceDeleteReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *WireguardInterfaceDeleteReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *WireguardInterfaceDeleteReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *WireguardInterfaceDeleteReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// WireguardInterfaceDetails defines message 'wireguard_interface_details'. +type WireguardInterfaceDetails struct { + Interface WireguardInterface `binapi:"wireguard_interface,name=interface" json:"interface,omitempty"` +} + +func (m *WireguardInterfaceDetails) Reset() { *m = WireguardInterfaceDetails{} } +func (*WireguardInterfaceDetails) GetMessageName() string { return "wireguard_interface_details" } +func (*WireguardInterfaceDetails) GetCrcString() string { return "0dd4865d" } +func (*WireguardInterfaceDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *WireguardInterfaceDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Interface.UserInstance + size += 4 // m.Interface.SwIfIndex + size += 1 * 32 // m.Interface.PrivateKey + size += 1 * 32 // m.Interface.PublicKey + size += 2 // m.Interface.Port + size += 1 // m.Interface.SrcIP.Af + size += 1 * 16 // m.Interface.SrcIP.Un + return size +} +func (m *WireguardInterfaceDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Interface.UserInstance) + buf.EncodeUint32(uint32(m.Interface.SwIfIndex)) + buf.EncodeBytes(m.Interface.PrivateKey, 32) + buf.EncodeBytes(m.Interface.PublicKey, 32) + buf.EncodeUint16(m.Interface.Port) + buf.EncodeUint8(uint8(m.Interface.SrcIP.Af)) + buf.EncodeBytes(m.Interface.SrcIP.Un.XXX_UnionData[:], 16) + return buf.Bytes(), nil +} +func (m *WireguardInterfaceDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Interface.UserInstance = buf.DecodeUint32() + m.Interface.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Interface.PrivateKey = make([]byte, 32) + copy(m.Interface.PrivateKey, buf.DecodeBytes(len(m.Interface.PrivateKey))) + m.Interface.PublicKey = make([]byte, 32) + copy(m.Interface.PublicKey, buf.DecodeBytes(len(m.Interface.PublicKey))) + m.Interface.Port = buf.DecodeUint16() + m.Interface.SrcIP.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Interface.SrcIP.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// WireguardInterfaceDump defines message 'wireguard_interface_dump'. +type WireguardInterfaceDump struct { + ShowPrivateKey bool `binapi:"bool,name=show_private_key" json:"show_private_key,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *WireguardInterfaceDump) Reset() { *m = WireguardInterfaceDump{} } +func (*WireguardInterfaceDump) GetMessageName() string { return "wireguard_interface_dump" } +func (*WireguardInterfaceDump) GetCrcString() string { return "2c954158" } +func (*WireguardInterfaceDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *WireguardInterfaceDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.ShowPrivateKey + size += 4 // m.SwIfIndex + return size +} +func (m *WireguardInterfaceDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.ShowPrivateKey) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *WireguardInterfaceDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.ShowPrivateKey = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Create new peer +// - peer - peer to create +// +// WireguardPeerAdd defines message 'wireguard_peer_add'. +type WireguardPeerAdd struct { + Peer WireguardPeer `binapi:"wireguard_peer,name=peer" json:"peer,omitempty"` +} + +func (m *WireguardPeerAdd) Reset() { *m = WireguardPeerAdd{} } +func (*WireguardPeerAdd) GetMessageName() string { return "wireguard_peer_add" } +func (*WireguardPeerAdd) GetCrcString() string { return "9b8aad61" } +func (*WireguardPeerAdd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *WireguardPeerAdd) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Peer.PeerIndex + size += 1 * 32 // m.Peer.PublicKey + size += 2 // m.Peer.Port + size += 2 // m.Peer.PersistentKeepalive + size += 4 // m.Peer.TableID + size += 1 // m.Peer.Endpoint.Af + size += 1 * 16 // m.Peer.Endpoint.Un + size += 4 // m.Peer.SwIfIndex + size += 1 // m.Peer.Flags + size += 1 // m.Peer.NAllowedIps + for j2 := 0; j2 < len(m.Peer.AllowedIps); j2++ { + var s2 ip_types.Prefix + _ = s2 + if j2 < len(m.Peer.AllowedIps) { + s2 = m.Peer.AllowedIps[j2] + } + size += 1 // s2.Address.Af + size += 1 * 16 // s2.Address.Un + size += 1 // s2.Len + } + return size +} +func (m *WireguardPeerAdd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Peer.PeerIndex) + buf.EncodeBytes(m.Peer.PublicKey, 32) + buf.EncodeUint16(m.Peer.Port) + buf.EncodeUint16(m.Peer.PersistentKeepalive) + buf.EncodeUint32(m.Peer.TableID) + buf.EncodeUint8(uint8(m.Peer.Endpoint.Af)) + buf.EncodeBytes(m.Peer.Endpoint.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.Peer.SwIfIndex)) + buf.EncodeUint8(uint8(m.Peer.Flags)) + buf.EncodeUint8(uint8(len(m.Peer.AllowedIps))) + for j1 := 0; j1 < len(m.Peer.AllowedIps); j1++ { + var v1 ip_types.Prefix // AllowedIps + if j1 < len(m.Peer.AllowedIps) { + v1 = m.Peer.AllowedIps[j1] + } + buf.EncodeUint8(uint8(v1.Address.Af)) + buf.EncodeBytes(v1.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(v1.Len) + } + return buf.Bytes(), nil +} +func (m *WireguardPeerAdd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Peer.PeerIndex = buf.DecodeUint32() + m.Peer.PublicKey = make([]byte, 32) + copy(m.Peer.PublicKey, buf.DecodeBytes(len(m.Peer.PublicKey))) + m.Peer.Port = buf.DecodeUint16() + m.Peer.PersistentKeepalive = buf.DecodeUint16() + m.Peer.TableID = buf.DecodeUint32() + m.Peer.Endpoint.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Peer.Endpoint.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Peer.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Peer.Flags = WireguardPeerFlags(buf.DecodeUint8()) + m.Peer.NAllowedIps = buf.DecodeUint8() + m.Peer.AllowedIps = make([]ip_types.Prefix, m.Peer.NAllowedIps) + for j1 := 0; j1 < len(m.Peer.AllowedIps); j1++ { + m.Peer.AllowedIps[j1].Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Peer.AllowedIps[j1].Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Peer.AllowedIps[j1].Len = buf.DecodeUint8() + } + return nil +} + +// Create new peer +// - retval - return status +// - peer_index - Created or existing peer pool index +// +// WireguardPeerAddReply defines message 'wireguard_peer_add_reply'. +type WireguardPeerAddReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + PeerIndex uint32 `binapi:"u32,name=peer_index" json:"peer_index,omitempty"` +} + +func (m *WireguardPeerAddReply) Reset() { *m = WireguardPeerAddReply{} } +func (*WireguardPeerAddReply) GetMessageName() string { return "wireguard_peer_add_reply" } +func (*WireguardPeerAddReply) GetCrcString() string { return "084a0cd3" } +func (*WireguardPeerAddReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *WireguardPeerAddReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.PeerIndex + return size +} +func (m *WireguardPeerAddReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.PeerIndex) + return buf.Bytes(), nil +} +func (m *WireguardPeerAddReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.PeerIndex = buf.DecodeUint32() + return nil +} + +// Interface Event generated by want_wireguard_peer_events +// - pid - client pid registered to receive notification +// - peer_index - index of the peer for this event +// - deleted - interface was deleted +// +// WireguardPeerEvent defines message 'wireguard_peer_event'. +type WireguardPeerEvent struct { + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` + PeerIndex uint32 `binapi:"u32,name=peer_index" json:"peer_index,omitempty"` + Flags WireguardPeerFlags `binapi:"wireguard_peer_flags,name=flags" json:"flags,omitempty"` +} + +func (m *WireguardPeerEvent) Reset() { *m = WireguardPeerEvent{} } +func (*WireguardPeerEvent) GetMessageName() string { return "wireguard_peer_event" } +func (*WireguardPeerEvent) GetCrcString() string { return "4e1b5d67" } +func (*WireguardPeerEvent) GetMessageType() api.MessageType { + return api.EventMessage +} + +func (m *WireguardPeerEvent) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PID + size += 4 // m.PeerIndex + size += 1 // m.Flags + return size +} +func (m *WireguardPeerEvent) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PID) + buf.EncodeUint32(m.PeerIndex) + buf.EncodeUint8(uint8(m.Flags)) + return buf.Bytes(), nil +} +func (m *WireguardPeerEvent) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PID = buf.DecodeUint32() + m.PeerIndex = buf.DecodeUint32() + m.Flags = WireguardPeerFlags(buf.DecodeUint8()) + return nil +} + +// Remove peer +// - peer_index - peer to be removed +// +// WireguardPeerRemove defines message 'wireguard_peer_remove'. +type WireguardPeerRemove struct { + PeerIndex uint32 `binapi:"u32,name=peer_index" json:"peer_index,omitempty"` +} + +func (m *WireguardPeerRemove) Reset() { *m = WireguardPeerRemove{} } +func (*WireguardPeerRemove) GetMessageName() string { return "wireguard_peer_remove" } +func (*WireguardPeerRemove) GetCrcString() string { return "3b74607a" } +func (*WireguardPeerRemove) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *WireguardPeerRemove) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PeerIndex + return size +} +func (m *WireguardPeerRemove) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PeerIndex) + return buf.Bytes(), nil +} +func (m *WireguardPeerRemove) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PeerIndex = buf.DecodeUint32() + return nil +} + +// WireguardPeerRemoveReply defines message 'wireguard_peer_remove_reply'. +type WireguardPeerRemoveReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *WireguardPeerRemoveReply) Reset() { *m = WireguardPeerRemoveReply{} } +func (*WireguardPeerRemoveReply) GetMessageName() string { return "wireguard_peer_remove_reply" } +func (*WireguardPeerRemoveReply) GetCrcString() string { return "e8d4e804" } +func (*WireguardPeerRemoveReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *WireguardPeerRemoveReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *WireguardPeerRemoveReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *WireguardPeerRemoveReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Dump peer details +// - peer - peer details +// +// WireguardPeersDetails defines message 'wireguard_peers_details'. +type WireguardPeersDetails struct { + Peer WireguardPeer `binapi:"wireguard_peer,name=peer" json:"peer,omitempty"` +} + +func (m *WireguardPeersDetails) Reset() { *m = WireguardPeersDetails{} } +func (*WireguardPeersDetails) GetMessageName() string { return "wireguard_peers_details" } +func (*WireguardPeersDetails) GetCrcString() string { return "6a9f6bc3" } +func (*WireguardPeersDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *WireguardPeersDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Peer.PeerIndex + size += 1 * 32 // m.Peer.PublicKey + size += 2 // m.Peer.Port + size += 2 // m.Peer.PersistentKeepalive + size += 4 // m.Peer.TableID + size += 1 // m.Peer.Endpoint.Af + size += 1 * 16 // m.Peer.Endpoint.Un + size += 4 // m.Peer.SwIfIndex + size += 1 // m.Peer.Flags + size += 1 // m.Peer.NAllowedIps + for j2 := 0; j2 < len(m.Peer.AllowedIps); j2++ { + var s2 ip_types.Prefix + _ = s2 + if j2 < len(m.Peer.AllowedIps) { + s2 = m.Peer.AllowedIps[j2] + } + size += 1 // s2.Address.Af + size += 1 * 16 // s2.Address.Un + size += 1 // s2.Len + } + return size +} +func (m *WireguardPeersDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Peer.PeerIndex) + buf.EncodeBytes(m.Peer.PublicKey, 32) + buf.EncodeUint16(m.Peer.Port) + buf.EncodeUint16(m.Peer.PersistentKeepalive) + buf.EncodeUint32(m.Peer.TableID) + buf.EncodeUint8(uint8(m.Peer.Endpoint.Af)) + buf.EncodeBytes(m.Peer.Endpoint.Un.XXX_UnionData[:], 16) + buf.EncodeUint32(uint32(m.Peer.SwIfIndex)) + buf.EncodeUint8(uint8(m.Peer.Flags)) + buf.EncodeUint8(uint8(len(m.Peer.AllowedIps))) + for j1 := 0; j1 < len(m.Peer.AllowedIps); j1++ { + var v1 ip_types.Prefix // AllowedIps + if j1 < len(m.Peer.AllowedIps) { + v1 = m.Peer.AllowedIps[j1] + } + buf.EncodeUint8(uint8(v1.Address.Af)) + buf.EncodeBytes(v1.Address.Un.XXX_UnionData[:], 16) + buf.EncodeUint8(v1.Len) + } + return buf.Bytes(), nil +} +func (m *WireguardPeersDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Peer.PeerIndex = buf.DecodeUint32() + m.Peer.PublicKey = make([]byte, 32) + copy(m.Peer.PublicKey, buf.DecodeBytes(len(m.Peer.PublicKey))) + m.Peer.Port = buf.DecodeUint16() + m.Peer.PersistentKeepalive = buf.DecodeUint16() + m.Peer.TableID = buf.DecodeUint32() + m.Peer.Endpoint.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Peer.Endpoint.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Peer.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Peer.Flags = WireguardPeerFlags(buf.DecodeUint8()) + m.Peer.NAllowedIps = buf.DecodeUint8() + m.Peer.AllowedIps = make([]ip_types.Prefix, m.Peer.NAllowedIps) + for j1 := 0; j1 < len(m.Peer.AllowedIps); j1++ { + m.Peer.AllowedIps[j1].Address.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Peer.AllowedIps[j1].Address.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Peer.AllowedIps[j1].Len = buf.DecodeUint8() + } + return nil +} + +// Dump all peers +// - peer_index - peer index to be dumped. If 0xFFFFFFFF dumps all peers +// +// WireguardPeersDump defines message 'wireguard_peers_dump'. +type WireguardPeersDump struct { + PeerIndex uint32 `binapi:"u32,name=peer_index,default=4294967295" json:"peer_index,omitempty"` +} + +func (m *WireguardPeersDump) Reset() { *m = WireguardPeersDump{} } +func (*WireguardPeersDump) GetMessageName() string { return "wireguard_peers_dump" } +func (*WireguardPeersDump) GetCrcString() string { return "3b74607a" } +func (*WireguardPeersDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *WireguardPeersDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.PeerIndex + return size +} +func (m *WireguardPeersDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.PeerIndex) + return buf.Bytes(), nil +} +func (m *WireguardPeersDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PeerIndex = buf.DecodeUint32() + return nil +} + +func init() { file_wireguard_binapi_init() } +func file_wireguard_binapi_init() { + api.RegisterMessage((*WantWireguardPeerEvents)(nil), "want_wireguard_peer_events_3bc666c8") + api.RegisterMessage((*WantWireguardPeerEventsReply)(nil), "want_wireguard_peer_events_reply_e8d4e804") + api.RegisterMessage((*WgSetAsyncMode)(nil), "wg_set_async_mode_a6465f7c") + api.RegisterMessage((*WgSetAsyncModeReply)(nil), "wg_set_async_mode_reply_e8d4e804") + api.RegisterMessage((*WireguardInterfaceCreate)(nil), "wireguard_interface_create_a530137e") + api.RegisterMessage((*WireguardInterfaceCreateReply)(nil), "wireguard_interface_create_reply_5383d31f") + api.RegisterMessage((*WireguardInterfaceDelete)(nil), "wireguard_interface_delete_f9e6675e") + api.RegisterMessage((*WireguardInterfaceDeleteReply)(nil), "wireguard_interface_delete_reply_e8d4e804") + api.RegisterMessage((*WireguardInterfaceDetails)(nil), "wireguard_interface_details_0dd4865d") + api.RegisterMessage((*WireguardInterfaceDump)(nil), "wireguard_interface_dump_2c954158") + api.RegisterMessage((*WireguardPeerAdd)(nil), "wireguard_peer_add_9b8aad61") + api.RegisterMessage((*WireguardPeerAddReply)(nil), "wireguard_peer_add_reply_084a0cd3") + api.RegisterMessage((*WireguardPeerEvent)(nil), "wireguard_peer_event_4e1b5d67") + api.RegisterMessage((*WireguardPeerRemove)(nil), "wireguard_peer_remove_3b74607a") + api.RegisterMessage((*WireguardPeerRemoveReply)(nil), "wireguard_peer_remove_reply_e8d4e804") + api.RegisterMessage((*WireguardPeersDetails)(nil), "wireguard_peers_details_6a9f6bc3") + api.RegisterMessage((*WireguardPeersDump)(nil), "wireguard_peers_dump_3b74607a") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*WantWireguardPeerEvents)(nil), + (*WantWireguardPeerEventsReply)(nil), + (*WgSetAsyncMode)(nil), + (*WgSetAsyncModeReply)(nil), + (*WireguardInterfaceCreate)(nil), + (*WireguardInterfaceCreateReply)(nil), + (*WireguardInterfaceDelete)(nil), + (*WireguardInterfaceDeleteReply)(nil), + (*WireguardInterfaceDetails)(nil), + (*WireguardInterfaceDump)(nil), + (*WireguardPeerAdd)(nil), + (*WireguardPeerAddReply)(nil), + (*WireguardPeerEvent)(nil), + (*WireguardPeerRemove)(nil), + (*WireguardPeerRemoveReply)(nil), + (*WireguardPeersDetails)(nil), + (*WireguardPeersDump)(nil), + } +} diff --git a/binapi/wireguard/wireguard_rpc.ba.go b/binapi/wireguard/wireguard_rpc.ba.go new file mode 100644 index 00000000..129ff36a --- /dev/null +++ b/binapi/wireguard/wireguard_rpc.ba.go @@ -0,0 +1,172 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package wireguard + +import ( + "context" + "fmt" + "io" + + api "github.com/alkiranet/govpp/api" + memclnt "github.com/alkiranet/govpp/binapi/memclnt" +) + +// RPCService defines RPC service wireguard. +type RPCService interface { + WantWireguardPeerEvents(ctx context.Context, in *WantWireguardPeerEvents) (*WantWireguardPeerEventsReply, error) + WgSetAsyncMode(ctx context.Context, in *WgSetAsyncMode) (*WgSetAsyncModeReply, error) + WireguardInterfaceCreate(ctx context.Context, in *WireguardInterfaceCreate) (*WireguardInterfaceCreateReply, error) + WireguardInterfaceDelete(ctx context.Context, in *WireguardInterfaceDelete) (*WireguardInterfaceDeleteReply, error) + WireguardInterfaceDump(ctx context.Context, in *WireguardInterfaceDump) (RPCService_WireguardInterfaceDumpClient, error) + WireguardPeerAdd(ctx context.Context, in *WireguardPeerAdd) (*WireguardPeerAddReply, error) + WireguardPeerRemove(ctx context.Context, in *WireguardPeerRemove) (*WireguardPeerRemoveReply, error) + WireguardPeersDump(ctx context.Context, in *WireguardPeersDump) (RPCService_WireguardPeersDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) WantWireguardPeerEvents(ctx context.Context, in *WantWireguardPeerEvents) (*WantWireguardPeerEventsReply, error) { + out := new(WantWireguardPeerEventsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WgSetAsyncMode(ctx context.Context, in *WgSetAsyncMode) (*WgSetAsyncModeReply, error) { + out := new(WgSetAsyncModeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WireguardInterfaceCreate(ctx context.Context, in *WireguardInterfaceCreate) (*WireguardInterfaceCreateReply, error) { + out := new(WireguardInterfaceCreateReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WireguardInterfaceDelete(ctx context.Context, in *WireguardInterfaceDelete) (*WireguardInterfaceDeleteReply, error) { + out := new(WireguardInterfaceDeleteReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WireguardInterfaceDump(ctx context.Context, in *WireguardInterfaceDump) (RPCService_WireguardInterfaceDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_WireguardInterfaceDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_WireguardInterfaceDumpClient interface { + Recv() (*WireguardInterfaceDetails, error) + api.Stream +} + +type serviceClient_WireguardInterfaceDumpClient struct { + api.Stream +} + +func (c *serviceClient_WireguardInterfaceDumpClient) Recv() (*WireguardInterfaceDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *WireguardInterfaceDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) WireguardPeerAdd(ctx context.Context, in *WireguardPeerAdd) (*WireguardPeerAddReply, error) { + out := new(WireguardPeerAddReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WireguardPeerRemove(ctx context.Context, in *WireguardPeerRemove) (*WireguardPeerRemoveReply, error) { + out := new(WireguardPeerRemoveReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) WireguardPeersDump(ctx context.Context, in *WireguardPeersDump) (RPCService_WireguardPeersDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_WireguardPeersDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_WireguardPeersDumpClient interface { + Recv() (*WireguardPeersDetails, error) + api.Stream +} + +type serviceClient_WireguardPeersDumpClient struct { + api.Stream +} + +func (c *serviceClient_WireguardPeersDumpClient) Recv() (*WireguardPeersDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *WireguardPeersDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} diff --git a/binapigen/binapigen.go b/binapigen/binapigen.go new file mode 100644 index 00000000..179a7f65 --- /dev/null +++ b/binapigen/binapigen.go @@ -0,0 +1,651 @@ +// 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 binapigen + +import ( + "fmt" + "path" + "sort" + "strconv" + "strings" + + "github.com/alkiranet/govpp/binapigen/vppapi" +) + +type File struct { + Desc vppapi.File + + Generate bool + FilenamePrefix string + PackageName GoPackageName + GoImportPath GoImportPath + + Version string + Imports []string + + Enums []*Enum + Unions []*Union + Structs []*Struct + Aliases []*Alias + + Messages []*Message + Service *Service +} + +func newFile(gen *Generator, apifile vppapi.File, packageName GoPackageName, importPath GoImportPath) (*File, error) { + file := &File{ + Desc: apifile, + PackageName: packageName, + GoImportPath: importPath, + } + if apifile.Options != nil { + file.Version = apifile.Options[vppapi.OptFileVersion] + } + + file.FilenamePrefix = path.Join(gen.opts.OutputDir, file.Desc.Name) + + for _, imp := range apifile.Imports { + file.Imports = append(file.Imports, normalizeImport(imp)) + } + + for _, enumType := range apifile.EnumTypes { + file.Enums = append(file.Enums, newEnum(gen, file, enumType, false)) + } + for _, enumflagType := range apifile.EnumflagTypes { + file.Enums = append(file.Enums, newEnum(gen, file, enumflagType, true)) + } + for _, aliasType := range apifile.AliasTypes { + file.Aliases = append(file.Aliases, newAlias(gen, file, aliasType)) + } + for _, structType := range apifile.StructTypes { + file.Structs = append(file.Structs, newStruct(gen, file, structType)) + } + for _, unionType := range apifile.UnionTypes { + file.Unions = append(file.Unions, newUnion(gen, file, unionType)) + } + + for _, msg := range apifile.Messages { + file.Messages = append(file.Messages, newMessage(gen, file, msg)) + } + if apifile.Service != nil { + file.Service = newService(gen, file, *apifile.Service) + } + + for _, t := range file.Aliases { + if err := t.resolveDependencies(gen); err != nil { + return nil, err + } + } + for _, t := range file.Structs { + if err := t.resolveDependencies(gen); err != nil { + return nil, err + } + } + for _, t := range file.Unions { + if err := t.resolveDependencies(gen); err != nil { + return nil, err + } + } + for _, m := range file.Messages { + if err := m.resolveDependencies(gen); err != nil { + return nil, err + } + } + if file.Service != nil { + for _, rpc := range file.Service.RPCs { + if err := rpc.resolveMessages(gen); err != nil { + return nil, err + } + } + } + + return file, nil +} + +func (file *File) importedFiles(gen *Generator) []*File { + var files []*File + for _, imp := range file.Imports { + impFile, ok := gen.FilesByName[imp] + if !ok { + logf("file %s import %s not found API files", file.Desc.Name, imp) + continue + } + files = append(files, impFile) + } + return files +} + +// IsStable return true if file version is >= 1.0.0 +func (f *File) IsStable() bool { + return len(f.Version) > 1 && f.Version[0:2] != "0." +} + +const ( + enumFlagSuffix = "_flags" +) + +func isEnumFlag(enum *Enum) bool { + return strings.HasSuffix(enum.Name, enumFlagSuffix) +} + +type Enum struct { + vppapi.EnumType + + GoIdent + + IsFlag bool +} + +func newEnum(gen *Generator, file *File, apitype vppapi.EnumType, isFlag bool) *Enum { + typ := &Enum{ + EnumType: apitype, + GoIdent: file.GoImportPath.Ident(camelCaseName(apitype.Name)), + IsFlag: isFlag, + } + gen.enumsByName[typ.Name] = typ + return typ +} + +type Alias struct { + vppapi.AliasType + + GoIdent + + TypeBasic *string + TypeStruct *Struct + TypeUnion *Union +} + +func newAlias(gen *Generator, file *File, apitype vppapi.AliasType) *Alias { + typ := &Alias{ + AliasType: apitype, + GoIdent: file.GoImportPath.Ident(camelCaseName(apitype.Name)), + } + gen.aliasesByName[typ.Name] = typ + return typ +} + +func (a *Alias) resolveDependencies(gen *Generator) error { + if err := a.resolveType(gen); err != nil { + return fmt.Errorf("unable to resolve field: %w", err) + } + return nil +} + +func (a *Alias) resolveType(gen *Generator) error { + if _, ok := BaseTypesGo[a.Type]; ok { + return nil + } + typ := fromApiType(a.Type) + if t, ok := gen.structsByName[typ]; ok { + a.TypeStruct = t + return nil + } + if t, ok := gen.unionsByName[typ]; ok { + a.TypeUnion = t + return nil + } + return fmt.Errorf("unknown type: %q", a.Type) +} + +type Struct struct { + vppapi.StructType + + GoIdent + + Fields []*Field +} + +func newStruct(gen *Generator, file *File, apitype vppapi.StructType) *Struct { + typ := &Struct{ + StructType: apitype, + GoIdent: file.GoImportPath.Ident(camelCaseName(apitype.Name)), + } + gen.structsByName[typ.Name] = typ + for i, fieldType := range apitype.Fields { + field := newField(gen, file, typ, fieldType, i) + typ.Fields = append(typ.Fields, field) + } + return typ +} + +func (m *Struct) resolveDependencies(gen *Generator) (err error) { + for _, field := range m.Fields { + if err := field.resolveDependencies(gen); err != nil { + return fmt.Errorf("unable to resolve for struct %s: %w", m.Name, err) + } + } + return nil +} + +type Union struct { + vppapi.UnionType + + GoIdent + + Fields []*Field +} + +func newUnion(gen *Generator, file *File, apitype vppapi.UnionType) *Union { + typ := &Union{ + UnionType: apitype, + GoIdent: file.GoImportPath.Ident(withSuffix(camelCaseName(apitype.Name), "Union")), + } + gen.unionsByName[typ.Name] = typ + for i, fieldType := range apitype.Fields { + field := newField(gen, file, typ, fieldType, i) + typ.Fields = append(typ.Fields, field) + } + return typ +} + +func (m *Union) resolveDependencies(gen *Generator) (err error) { + for _, field := range m.Fields { + if err := field.resolveDependencies(gen); err != nil { + return err + } + } + return nil +} + +// msgType determines message header fields +type msgType int + +const ( + msgTypeBase msgType = iota // msg_id + msgTypeRequest // msg_id, client_index, context + msgTypeReply // msg_id, context + msgTypeEvent // msg_id, client_index +) + +// common message fields +const ( + fieldMsgID = "_vl_msg_id" + fieldClientIndex = "client_index" + fieldContext = "context" + fieldRetval = "retval" +) + +// field options +const ( + optFieldDefault = "default" + optFieldLimit = "limit" +) + +// status option keys +const ( + msgOptStatus = "status" + msgOptDeprecated = "deprecated" + msgOptInProgress = "in_progress" +) + +type msgStatus int + +const ( + msgStatusUnset msgStatus = iota + msgStatusInProgress + msgStatusDeprecated + msgStatusOther +) + +type Message struct { + vppapi.Message + + File *File + + CRC string + Comment string + + GoIdent + + Fields []*Field + + msgType msgType +} + +func newMessage(gen *Generator, file *File, apitype vppapi.Message) *Message { + msg := &Message{ + File: file, + Message: apitype, + CRC: normalizeCRC(apitype.CRC), + Comment: StripMessageCommentFields(CleanMessageComment(apitype.Comment), fieldContext, fieldClientIndex), + GoIdent: newGoIdent(file, apitype.Name), + } + gen.messagesByName[apitype.Name] = msg + var n int + for _, fieldType := range apitype.Fields { + if n == 0 { + switch strings.ToLower(fieldType.Name) { + case fieldMsgID, fieldClientIndex, fieldContext: + // skip header fields + continue + } + } + n++ + field := newField(gen, file, msg, fieldType, n) + msg.Fields = append(msg.Fields, field) + } + return msg +} + +func (m *Message) resolveDependencies(gen *Generator) (err error) { + if m.msgType, err = getMsgType(m.Message); err != nil { + return err + } + for _, field := range m.Fields { + if err := field.resolveDependencies(gen); err != nil { + return err + } + } + return nil +} + +func getMsgType(m vppapi.Message) (msgType, error) { + if len(m.Fields) == 0 { + return msgType(-1), fmt.Errorf("message %s has no fields", m.Name) + } + var typ msgType + var wasClientIndex bool + for i, field := range m.Fields { + switch i { + case 0: + if field.Name != fieldMsgID { + return msgType(-1), fmt.Errorf("message %s is missing ID field", m.Name) + } + case 1: + if field.Name == fieldClientIndex { + // "client_index" as the second member, + // this might be an event message or a request + typ = msgTypeEvent + wasClientIndex = true + } else if field.Name == fieldContext { + // reply needs "context" as the second member + typ = msgTypeReply + } + case 2: + if field.Name == fieldContext && wasClientIndex { + // request needs "client_index" as the second member + // and "context" as the third member + typ = msgTypeRequest + } + } + } + return typ, nil +} + +func getRetvalField(m *Message) *Field { + for _, field := range m.Fields { + if field.Name == fieldRetval { + return field + } + } + return nil +} + +func getMessageStatus(m *Message) (status msgStatus, info string) { + options := m.Options + if msg, ok := options[msgOptDeprecated]; ok || options[msgOptStatus] == msgOptDeprecated { + if msg != "" { + info = msg + } + status = msgStatusDeprecated + } else if msg, ok := options[msgOptInProgress]; ok || options[msgOptStatus] == msgOptInProgress { + if msg != "" { + info = msg + } + status = msgStatusInProgress + } else if msg, ok := options[msgOptStatus]; ok { + if msg != "" { + info = msg + } + status = msgStatusOther + } + return status, info +} + +// Field represents a field for message or struct/union types. +type Field struct { + vppapi.Field + + GoName string + + // Index defines field index in parent. + Index int + + // DefaultValue is a default value of field or + // nil if default value is not defined for field. + DefaultValue interface{} + + // Reference to actual type of this field. + // + // For fields with built-in types all of these are nil, + // otherwise only one is set to non-nil value. + TypeEnum *Enum + TypeAlias *Alias + TypeStruct *Struct + TypeUnion *Union + + // Parent in which this field is declared. + ParentMessage *Message + ParentStruct *Struct + ParentUnion *Union + + // Field reference for fields with variable size. + FieldSizeOf *Field + FieldSizeFrom *Field +} + +func newField(gen *Generator, file *File, parent interface{}, apitype vppapi.Field, index int) *Field { + typ := &Field{ + Field: apitype, + GoName: camelCaseName(apitype.Name), + Index: index, + } + switch p := parent.(type) { + case *Message: + typ.ParentMessage = p + case *Struct: + typ.ParentStruct = p + case *Union: + typ.ParentUnion = p + default: + panic(fmt.Sprintf("invalid field parent: %T", parent)) + } + if apitype.Meta != nil { + if val, ok := apitype.Meta[optFieldDefault]; ok { + typ.DefaultValue = val + } + } + return typ +} + +func (f *Field) resolveDependencies(gen *Generator) error { + if err := f.resolveType(gen); err != nil { + return fmt.Errorf("unable to resolve field type: %w", err) + } + if err := f.resolveFields(gen); err != nil { + return fmt.Errorf("unable to resolve fields: %w", err) + } + return nil +} + +func (f *Field) resolveType(gen *Generator) error { + if _, ok := BaseTypesGo[f.Type]; ok { + return nil + } + typ := fromApiType(f.Type) + if t, ok := gen.structsByName[typ]; ok { + f.TypeStruct = t + return nil + } + if t, ok := gen.enumsByName[typ]; ok { + f.TypeEnum = t + return nil + } + if t, ok := gen.aliasesByName[typ]; ok { + f.TypeAlias = t + return nil + } + if t, ok := gen.unionsByName[typ]; ok { + f.TypeUnion = t + return nil + } + return fmt.Errorf("unknown type: %q", f.Type) +} + +func (f *Field) resolveFields(gen *Generator) error { + var fields []*Field + if f.ParentMessage != nil { + fields = f.ParentMessage.Fields + } else if f.ParentStruct != nil { + fields = f.ParentStruct.Fields + } + if f.SizeFrom != "" { + for _, field := range fields { + if field.Name == f.SizeFrom { + f.FieldSizeFrom = field + break + } + } + } else { + for _, field := range fields { + if field.SizeFrom == f.Name { + f.FieldSizeOf = field + break + } + } + } + return nil +} + +type Service struct { + vppapi.Service + + RPCs []*RPC +} + +func newService(gen *Generator, file *File, apitype vppapi.Service) *Service { + svc := &Service{ + Service: apitype, + } + for _, rpc := range apitype.RPCs { + svc.RPCs = append(svc.RPCs, newRpc(file, svc, rpc)) + } + return svc +} + +const ( + serviceNoReply = "null" +) + +type RPC struct { + VPP vppapi.RPC + + GoName string + + Service *Service + + MsgRequest *Message + MsgReply *Message + MsgStream *Message +} + +func newRpc(file *File, service *Service, apitype vppapi.RPC) *RPC { + rpc := &RPC{ + VPP: apitype, + GoName: camelCaseName(apitype.Request), + Service: service, + } + return rpc +} + +func (rpc *RPC) resolveMessages(gen *Generator) error { + msg, ok := gen.messagesByName[rpc.VPP.Request] + if !ok { + return fmt.Errorf("rpc %v: no message for request type %v", rpc.GoName, rpc.VPP.Request) + } + rpc.MsgRequest = msg + + if rpc.VPP.Reply != "" && rpc.VPP.Reply != serviceNoReply { + msg, ok := gen.messagesByName[rpc.VPP.Reply] + if !ok { + return fmt.Errorf("rpc %v: no message for reply type %v", rpc.GoName, rpc.VPP.Reply) + } + rpc.MsgReply = msg + } + if rpc.VPP.StreamMsg != "" { + msg, ok := gen.messagesByName[rpc.VPP.StreamMsg] + if !ok { + return fmt.Errorf("rpc %v: no message for stream type %v", rpc.GoName, rpc.VPP.StreamMsg) + } + rpc.MsgStream = msg + } + return nil +} + +type structTags map[string]string + +func (tags structTags) String() string { + if len(tags) == 0 { + return "" + } + var keys []string + for k := range tags { + keys = append(keys, k) + } + sort.Strings(keys) + var ss []string + for _, key := range keys { + tag := tags[key] + ss = append(ss, fmt.Sprintf(`%s:%s`, key, strconv.Quote(tag))) + } + return "`" + strings.Join(ss, " ") + "`" +} + +// GoIdent is a Go identifier, consisting of a name and import path. +// The name is a single identifier and may not be a dot-qualified selector. +type GoIdent struct { + GoName string + GoImportPath GoImportPath +} + +func (id GoIdent) String() string { + return fmt.Sprintf("%q.%v", id.GoImportPath, id.GoName) +} + +func newGoIdent(f *File, fullName string) GoIdent { + name := strings.TrimPrefix(fullName, string(f.PackageName)+".") + return GoIdent{ + GoName: camelCaseName(name), + GoImportPath: f.GoImportPath, + } +} + +// GoImportPath is a Go import path for a package. +type GoImportPath string + +func (p GoImportPath) String() string { + return strconv.Quote(string(p)) +} + +func (p GoImportPath) Ident(s string) GoIdent { + return GoIdent{GoName: s, GoImportPath: p} +} + +type GoPackageName string + +func cleanPackageName(name string) GoPackageName { + return GoPackageName(sanitizedName(name)) +} diff --git a/binapigen/binapigen_test.go b/binapigen/binapigen_test.go new file mode 100644 index 00000000..5bb42252 --- /dev/null +++ b/binapigen/binapigen_test.go @@ -0,0 +1,15 @@ +// 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 binapigen diff --git a/binapigen/generate.go b/binapigen/generate.go new file mode 100644 index 00000000..db8c94d4 --- /dev/null +++ b/binapigen/generate.go @@ -0,0 +1,37 @@ +// Copyright (c) 2022 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 binapigen + +const ( + // generatedCodeVersion indicates a version of the generated code. + // It is incremented whenever an incompatibility between the generated code and + // GoVPP api package is introduced; the generated code references + // a constant, api.GoVppAPIPackageIsVersionN (where N is generatedCodeVersion). + generatedCodeVersion = 2 + + generatedFilenameSuffix = ".ba.go" +) + +// library dependencies +const ( + strconvPkg = GoImportPath("strconv") + + govppApiPkg = GoImportPath("github.com/alkiranet/govpp/api") + govppCodecPkg = GoImportPath("github.com/alkiranet/govpp/codec") +) + +func genCodeGeneratedComment(g *GenFile) { + g.P("// Code generated by GoVPP's binapi-generator. DO NOT EDIT.") +} diff --git a/binapigen/generate_api.go b/binapigen/generate_api.go new file mode 100644 index 00000000..f50c1ba3 --- /dev/null +++ b/binapigen/generate_api.go @@ -0,0 +1,516 @@ +// 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 binapigen + +import ( + "fmt" + "path" + "strconv" + "strings" + + "github.com/alkiranet/govpp/internal/version" +) + +// generated names +const ( + apiName = "APIFile" // API file name + apiVersion = "APIVersion" // API version number + apiCrc = "VersionCrc" // version checksum + + fieldUnionData = "XXX_UnionData" // name for the union data field +) + +// generated status info +const ( + statusInProgressPrefix = "InProgress" + statusDeprecatedPrefix = "Deprecated" + statusOtherPrefix = "Status" + + statusDeprecatedInfoText = "the message will be removed in the future versions" + statusInProgressInfoText = "the message form may change in the future versions" +) + +func GenerateAPI(gen *Generator, file *File) *GenFile { + logf("----------------------------") + logf(" Generate API FILE - %s", file.Desc.Name) + logf("----------------------------") + + filename := path.Join(file.FilenamePrefix, file.Desc.Name+generatedFilenameSuffix) + g := gen.NewGenFile(filename, file) + + genCodeGeneratedComment(g) + if !gen.opts.NoVersionInfo { + g.P("// versions:") + g.P("// binapi-generator: ", version.Version()) + g.P("// VPP: ", g.gen.vppapiSchema.Version) + if !gen.opts.NoSourcePathInfo { + g.P("// source: ", g.file.Desc.Path) + } + } + g.P() + + // package definition + genPackageComment(g) + g.P("package ", file.PackageName) + g.P() + + // package imports + for _, imp := range g.file.Imports { + genImport(g, imp) + } + + // GoVPP API version assertion + g.P("// This is a compile-time assertion to ensure that this generated file") + g.P("// is compatible with the GoVPP api package it is being compiled against.") + g.P("// A compilation error at this line likely means your copy of the") + g.P("// GoVPP api package needs to be updated.") + g.P("const _ = ", govppApiPkg.Ident("GoVppAPIPackageIsVersion"), generatedCodeVersion) + g.P() + + // API meta info + genApiInfo(g) + + // API types + for _, enum := range g.file.Enums { + genEnum(g, enum) + } + for _, alias := range g.file.Aliases { + genAlias(g, alias) + } + for _, typ := range g.file.Structs { + genStruct(g, typ) + } + for _, union := range g.file.Unions { + genUnion(g, union) + } + + // API messages + genMessages(g) + + return g +} + +func genApiInfo(g *GenFile) { + // generate API info + g.P("const (") + g.P(apiName, " = ", strconv.Quote(g.file.Desc.Name)) + g.P(apiVersion, " = ", strconv.Quote(g.file.Version)) + g.P(apiCrc, " = ", g.file.Desc.CRC) + g.P(")") + g.P() +} + +func genPackageComment(g *GenFile) { + apifile := g.file.Desc.Name + ".api" + g.P("// Package ", g.file.PackageName, " contains generated bindings for API file ", apifile, ".") + g.P("//") + g.P("// Contents:") + printObjNum := func(obj string, num int) { + if num > 0 { + if num > 1 { + if strings.HasSuffix(obj, "s") { + obj += "es" + } else { + obj += "s" + } + } + g.P("// - ", fmt.Sprintf("%2d", num), " ", obj) + } + } + printObjNum("alias", len(g.file.Aliases)) + printObjNum("enum", len(g.file.Enums)) + printObjNum("struct", len(g.file.Structs)) + printObjNum("union", len(g.file.Unions)) + printObjNum("message", len(g.file.Messages)) +} + +func genImport(g *GenFile, imp string) { + impFile, ok := g.gen.FilesByName[imp] + if !ok { + return + } + if impFile.GoImportPath == g.file.GoImportPath { + // Skip generating imports for types in the same package + return + } + // Generate imports for all dependencies, even if not used + g.Import(impFile.GoImportPath) +} + +func genGenericDefinesComment(g *GenFile, goName string, vppName string, objKind string) { + g.P("// ", goName, " defines ", objKind, " '", vppName, "'.") +} + +func genMessageStatusInfoComment(g *GenFile, msg *Message) { + switch status, text := getMessageStatus(msg); status { + case msgStatusInProgress: + // "in progress" status - might be changed anytime + if text == "" { + text = statusInProgressInfoText + } + g.P("// ", statusInProgressPrefix, ": ", text) + case msgStatusDeprecated: + // "deprecated" status - will be removed later + if text == "" { + text = statusDeprecatedInfoText + } + g.P("// ", statusDeprecatedPrefix, ": ", text) + case msgStatusOther: + // custom status - arbitrary info + g.P("// ", statusOtherPrefix, ": ", text) + } +} + +func genEnum(g *GenFile, enum *Enum) { + logf("gen ENUM %s (%s) - %d entries", enum.GoName, enum.Name, len(enum.Entries)) + + genGenericDefinesComment(g, enum.GoName, enum.Name, "enum") + + gotype := BaseTypesGo[enum.Type] + + g.P("type ", enum.GoName, " ", gotype) + g.P() + + // generate enum entries + g.P("const (") + for _, entry := range enum.Entries { + g.P(entry.Name, " ", enum.GoName, " = ", entry.Value) + } + g.P(")") + g.P() + + // generate enum conversion maps + g.P("var (") + g.P(enum.GoName, "_name = map[", gotype, "]string{") + for _, entry := range enum.Entries { + g.P(entry.Value, ": ", strconv.Quote(entry.Name), ",") + } + g.P("}") + g.P(enum.GoName, "_value = map[string]", gotype, "{") + for _, entry := range enum.Entries { + g.P(strconv.Quote(entry.Name), ": ", entry.Value, ",") + } + g.P("}") + g.P(")") + g.P() + + if enum.IsFlag || isEnumFlag(enum) { + size := BaseTypeSizes[enum.Type] * 8 + g.P("func (x ", enum.GoName, ") String() string {") + g.P(" s, ok := ", enum.GoName, "_name[", gotype, "(x)]") + g.P(" if ok { return s }") + g.P(" str := func(n ", gotype, ") string {") + g.P(" s, ok := ", enum.GoName, "_name[", gotype, "(n)]") + g.P(" if ok {") + g.P(" return s") + g.P(" }") + g.P(" return \"", enum.GoName, "(\" + ", strconvPkg.Ident("Itoa"), "(int(n)) + \")\"") + g.P(" }") + g.P(" for i := ", gotype, "(0); i <= ", size, "; i++ {") + g.P(" val := ", gotype, "(x)") + g.P(" if val&(1< 0 { + gotype = fmt.Sprintf("[%d]%s", alias.Length, gotype) + } + + g.P("type ", alias.GoName, " ", gotype) + g.P() + + genHelperMethods(g, alias.Name, alias.GoName) +} + +func genStruct(g *GenFile, typ *Struct) { + logf("gen STRUCT %s (%s) - %d fields", typ.GoName, typ.Name, len(typ.Fields)) + + genGenericDefinesComment(g, typ.GoName, typ.Name, "type") + + if len(typ.Fields) == 0 { + g.P("type ", typ.GoName, " struct {}") + } else { + g.P("type ", typ.GoName, " struct {") + for i := range typ.Fields { + genField(g, typ.Fields, i) + } + g.P("}") + } + g.P() + + genHelperMethods(g, typ.Name, typ.GoName) +} + +func genUnion(g *GenFile, union *Union) { + logf("gen UNION %s (%s) - %d fields", union.GoName, union.Name, len(union.Fields)) + + genGenericDefinesComment(g, union.GoName, union.Name, "union") + + g.P("type ", union.GoName, " struct {") + + // generate field comments + g.P("// ", union.GoName, " can be one of:") + for _, field := range union.Fields { + g.P("// - ", field.GoName, " *", getFieldType(g, field)) + } + + // generate data field + maxSize := getUnionSize(union) + g.P(fieldUnionData, " [", maxSize, "]byte") + + // generate end of the struct + g.P("}") + g.P() + + // generate methods for fields + for _, field := range union.Fields { + genUnionFieldMethods(g, union, field) + } + + g.P() +} + +func genUnionFieldMethods(g *GenFile, union *Union, field *Field) { + fieldType := fieldGoType(g, field) + constructorName := union.GoName + field.GoName + + // Constructor + g.P("func ", constructorName, "(a ", fieldType, ") (u ", union.GoName, ") {") + g.P(" u.Set", field.GoName, "(a)") + g.P(" return") + g.P("}") + + // Setter + g.P("func (u *", union.GoName, ") Set", field.GoName, "(a ", fieldType, ") {") + g.P(" buf := ", govppCodecPkg.Ident("NewBuffer"), "(u.", fieldUnionData, "[:])") + encodeField(g, field, "a", func(name string) string { + return "a." + name + }, 0) + g.P("}") + + // Getter + g.P("func (u *", union.GoName, ") Get", field.GoName, "() (a ", fieldType, ") {") + g.P(" buf := ", govppCodecPkg.Ident("NewBuffer"), "(u.", fieldUnionData, "[:])") + decodeField(g, field, "a", func(name string) string { + return "a." + name + }, 0) + g.P(" return") + g.P("}") + + g.P() +} + +func withSuffix(s string, suffix string) string { + if strings.HasSuffix(s, suffix) { + return s + } + return s + suffix +} + +func genField(g *GenFile, fields []*Field, i int) { + field := fields[i] + + logf(" gen FIELD[%d] %s (%s) - type: %q (array: %v/%v)", i, field.GoName, field.Name, field.Type, field.Array, field.Length) + + gotype := getFieldType(g, field) + tags := structTags{ + "binapi": fieldTagBinapi(field), + "json": fieldTagJson(field), + } + + g.P(field.GoName, " ", gotype, tags) +} + +func fieldTagJson(field *Field) string { + if field.FieldSizeOf != nil { + return "-" + } + return fmt.Sprintf("%s,omitempty", field.Name) +} + +func fieldTagBinapi(field *Field) string { + typ := fromApiType(field.Type) + if field.Array { + if field.Length > 0 { + typ += fmt.Sprintf("[%d]", field.Length) + } else if field.SizeFrom != "" { + typ += fmt.Sprintf("[%s]", field.SizeFrom) + } else { + typ += "[]" + } + } + tag := []string{ + typ, + fmt.Sprintf("name=%s", field.Name), + } + + // limit + if limit, ok := field.Meta[optFieldLimit]; ok && limit.(int) > 0 { + tag = append(tag, fmt.Sprintf("limit=%s", limit)) + } + + // default value + if def, ok := field.Meta[optFieldDefault]; ok && def != nil { + switch fieldActualType(field) { + case I8, I16, I32, I64: + def = int64(def.(float64)) + case U8, U16, U32, U64: + def = uint64(def.(float64)) + case F64: + def = def.(float64) + } + tag = append(tag, fmt.Sprintf("default=%v", def)) + } + + return strings.Join(tag, ",") +} + +func genMessages(g *GenFile) { + if len(g.file.Messages) == 0 { + return + } + + // generate definitions + for _, msg := range g.file.Messages { + genMessage(g, msg) + } + + // generate initial registration + initFnName := fmt.Sprintf("file_%s_binapi_init", g.file.PackageName) + g.P("func init() { ", initFnName, "() }") + g.P("func ", initFnName, "() {") + for _, msg := range g.file.Messages { + id := fmt.Sprintf("%s_%s", msg.Name, msg.CRC) + g.P(govppApiPkg.Ident("RegisterMessage"), "((*", msg.GoIdent, ")(nil), ", strconv.Quote(id), ")") + } + g.P("}") + g.P() + + // generate message list + g.P("// Messages returns list of all messages in this module.") + g.P("func AllMessages() []", govppApiPkg.Ident("Message"), " {") + g.P("return []", govppApiPkg.Ident("Message"), "{") + for _, msg := range g.file.Messages { + g.P("(*", msg.GoIdent, ")(nil),") + } + g.P("}") + g.P("}") +} + +func genMessage(g *GenFile, msg *Message) { + logf("gen MESSAGE %s (%s) - %d fields", msg.GoName, msg.Name, len(msg.Fields)) + + genMessageComment(g, msg) + genGenericDefinesComment(g, msg.GoIdent.GoName, msg.Name, "message") + genMessageStatusInfoComment(g, msg) + + // generate message definition + if len(msg.Fields) == 0 { + g.P("type ", msg.GoIdent, " struct {}") + } else { + g.P("type ", msg.GoIdent, " struct {") + for i := range msg.Fields { + genField(g, msg.Fields, i) + } + g.P("}") + } + g.P() + + // base methods + genMessageBaseMethods(g, msg) + + // encoding methods + genMessageEncodingMethods(g, msg) + + g.P() +} + +func genMessageBaseMethods(g *GenFile, msg *Message) { + // Reset method + g.P("func (m *", msg.GoIdent.GoName, ") Reset() { *m = ", msg.GoIdent.GoName, "{} }") + + // GetXXX methods + genMessageMethods(g, msg) + + g.P() +} + +func genMessageComment(g *GenFile, msg *Message) { + if msg.Comment != "" { + comment := strings.Replace(msg.Comment, "\n", "\n// ", -1) + g.P("// ", comment) + } +} + +func genMessageMethods(g *GenFile, msg *Message) { + // GetMessageName method + g.P("func (*", msg.GoIdent.GoName, ") GetMessageName() string { return ", strconv.Quote(msg.Name), " }") + + // GetCrcString method + g.P("func (*", msg.GoIdent.GoName, ") GetCrcString() string { return ", strconv.Quote(msg.CRC), " }") + + // GetMessageType method + g.P("func (*", msg.GoIdent.GoName, ") GetMessageType() api.MessageType {") + g.P(" return ", msgType2apiMessageType(msg.msgType)) + g.P("}") + + g.P() +} + +func msgType2apiMessageType(t msgType) GoIdent { + switch t { + case msgTypeRequest: + return govppApiPkg.Ident("RequestMessage") + case msgTypeReply: + return govppApiPkg.Ident("ReplyMessage") + case msgTypeEvent: + return govppApiPkg.Ident("EventMessage") + default: + return govppApiPkg.Ident("OtherMessage") + } +} diff --git a/cmd/binapi-generator/generate_test.go b/binapigen/generate_api_test.go similarity index 78% rename from cmd/binapi-generator/generate_test.go rename to binapigen/generate_api_test.go index 4bec874a..537bdfd8 100644 --- a/cmd/binapi-generator/generate_test.go +++ b/binapigen/generate_api_test.go @@ -1,89 +1,134 @@ -// Copyright (c) 2017 Cisco and/or its affiliates. +// 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: +// 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 +// 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. +// 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 main +package binapigen import ( - "bufio" - "io/ioutil" "os" "testing" . "github.com/onsi/gomega" + + "github.com/alkiranet/govpp/binapi/ip_types" + "github.com/alkiranet/govpp/binapigen/vppapi" ) -func TestGetInputFiles(t *testing.T) { - RegisterTestingT(t) - result, err := getInputFiles("testdata", 1) - Expect(err).ShouldNot(HaveOccurred()) - Expect(result).To(HaveLen(3)) - for _, file := range result { - Expect(file).To(BeAnExistingFile()) +const testOutputDir = "test_output_dir" + +func GenerateFromFile(file string, opts Options) error { + apifile, err := vppapi.ParseFile(file) + if err != nil { + return err + } + input := &vppapi.VppInput{Schema: vppapi.Schema{ + Files: []vppapi.File{*apifile}, + }} + gen, err := New(opts, input) + if err != nil { + return err + } + for _, file := range gen.Files { + if !file.Generate { + continue + } + GenerateAPI(gen, file) } + if err = gen.Generate(); err != nil { + return err + } + return nil } -func TestGetInputFilesError(t *testing.T) { +func TestGenerateFromFileACL(t *testing.T) { RegisterTestingT(t) - result, err := getInputFiles("nonexisting_directory", 1) - Expect(err).Should(HaveOccurred()) - Expect(result).To(BeNil()) + + // remove directory created during test + defer os.RemoveAll(testOutputDir) + + opts := Options{OutputDir: testOutputDir} + err := GenerateFromFile("vppapi/testdata/acl.api.json", opts) + Expect(err).ShouldNot(HaveOccurred()) + fileInfo, err := os.Stat(testOutputDir + "/acl/acl.ba.go") + Expect(err).ShouldNot(HaveOccurred()) + Expect(fileInfo.IsDir()).To(BeFalse()) + Expect(fileInfo.Name()).To(BeEquivalentTo("acl.ba.go")) } -func TestGenerateFromFile(t *testing.T) { +func TestGenerateFromFileIP(t *testing.T) { RegisterTestingT(t) - outDir := "test_output_directory" + // remove directory created during test - defer os.RemoveAll(outDir) - err := generateFromFile("testdata/acl.api.json", outDir, nil) + defer os.RemoveAll(testOutputDir) + + opts := Options{OutputDir: testOutputDir} + err := GenerateFromFile("vppapi/testdata/ip.api.json", opts) Expect(err).ShouldNot(HaveOccurred()) - fileInfo, err := os.Stat(outDir + "/acl/acl.ba.go") + fileInfo, err := os.Stat(testOutputDir + "/ip/ip.ba.go") Expect(err).ShouldNot(HaveOccurred()) Expect(fileInfo.IsDir()).To(BeFalse()) - Expect(fileInfo.Name()).To(BeEquivalentTo("acl.ba.go")) + Expect(fileInfo.Name()).To(BeEquivalentTo("ip.ba.go")) } func TestGenerateFromFileInputError(t *testing.T) { RegisterTestingT(t) - outDir := "test_output_directory" - err := generateFromFile("testdata/nonexisting.json", outDir, nil) + + opts := Options{OutputDir: testOutputDir} + err := GenerateFromFile("vppapi/testdata/nonexisting.json", opts) Expect(err).Should(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("invalid input file name")) + Expect(err.Error()).To(ContainSubstring("unsupported")) } func TestGenerateFromFileReadJsonError(t *testing.T) { RegisterTestingT(t) - outDir := "test_output_directory" - err := generateFromFile("testdata/input-read-json-error.json", outDir, nil) + + opts := Options{OutputDir: testOutputDir} + err := GenerateFromFile("vppapi/testdata/input-read-json-error.json", opts) Expect(err).Should(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("invalid input file name")) + Expect(err.Error()).To(ContainSubstring("unsupported")) } func TestGenerateFromFileGeneratePackageError(t *testing.T) { RegisterTestingT(t) - outDir := "test_output_directory" + // generate package throws panic, recover after it defer func() { if recovery := recover(); recovery != nil { t.Logf("Recovered from panic: %v", recovery) } - os.RemoveAll(outDir) + os.RemoveAll(testOutputDir) }() - err := generateFromFile("testdata/input-generate-error.json", outDir, nil) + + opts := Options{OutputDir: testOutputDir} + err := GenerateFromFile("vppapi/testdata/input-generate-error.json", opts) Expect(err).Should(HaveOccurred()) } -func TestGetContext(t *testing.T) { +func TestAddress(t *testing.T) { + RegisterTestingT(t) + + addr := ip_types.AddressUnionIP4(ip_types.IP4Address{10, 20, 0, 1}) + t.Logf("addr: %v (%#v)", addr, addr) + + ip4 := addr.GetIP4() + t.Logf("ip4: %v", ip4) + addr.SetIP4(ip_types.IP4Address{192, 168, 1, 1}) + t.Logf("ip4: %v", addr.GetIP4()) + + Expect(addr.GetIP4()).To(Equal(ip_types.IP4Address{192, 168, 1, 1})) +} + +/*func TestGetContext(t *testing.T) { RegisterTestingT(t) outDir := "test_output_directory" result, err := newContext("testdata/af_packet.api.json", outDir) @@ -109,31 +154,12 @@ func TestGetContextInterfaceJson(t *testing.T) { Expect(result).ToNot(BeNil()) Expect(result.outputFile) Expect(result.outputFile).To(BeEquivalentTo(outDir + "/ip/ip.ba.go")) -} - -func TestReadJson(t *testing.T) { - RegisterTestingT(t) - inputData, err := ioutil.ReadFile("testdata/af_packet.api.json") - Expect(err).ShouldNot(HaveOccurred()) - result, err := parseInputJSON(inputData) - Expect(err).ShouldNot(HaveOccurred()) - Expect(result).ToNot(BeNil()) - Expect(result.Len()).To(BeEquivalentTo(5)) -} +}*/ -func TestReadJsonError(t *testing.T) { - RegisterTestingT(t) - inputData, err := ioutil.ReadFile("testdata/input-read-json-error.json") - Expect(err).ShouldNot(HaveOccurred()) - result, err := parseInputJSON(inputData) - Expect(err).Should(HaveOccurred()) - Expect(result).To(BeNil()) -} - -func TestGeneratePackage(t *testing.T) { +/*func TestGeneratePackage(t *testing.T) { RegisterTestingT(t) // prepare context - testCtx := new(context) + testCtx := new(GenFile) testCtx.packageName = "test-package-name" // prepare input/output output files @@ -141,7 +167,7 @@ func TestGeneratePackage(t *testing.T) { Expect(err).ShouldNot(HaveOccurred()) jsonRoot, err := parseInputJSON(inputData) Expect(err).ShouldNot(HaveOccurred()) - testCtx.packageData, err = parsePackage(testCtx, jsonRoot) + testCtx.file, err = parseModule(testCtx, jsonRoot) Expect(err).ShouldNot(HaveOccurred()) outDir := "test_output_directory" outFile, err := os.Create(outDir) @@ -151,14 +177,14 @@ func TestGeneratePackage(t *testing.T) { // prepare writer writer := bufio.NewWriter(outFile) Expect(writer.Buffered()).To(BeZero()) - err = generatePackage(testCtx, writer) + err = GenerateFileBinapi(testCtx, writer) Expect(err).ShouldNot(HaveOccurred()) } func TestGenerateMessageType(t *testing.T) { RegisterTestingT(t) // prepare context - testCtx := new(context) + testCtx := new(GenFile) testCtx.packageName = "test-package-name" // prepare input/output output files @@ -169,18 +195,18 @@ func TestGenerateMessageType(t *testing.T) { outDir := "test_output_directory" outFile, err := os.Create(outDir) Expect(err).ShouldNot(HaveOccurred()) - testCtx.packageData, err = parsePackage(testCtx, jsonRoot) + testCtx.file, err = parseModule(testCtx, jsonRoot) Expect(err).ShouldNot(HaveOccurred()) defer os.RemoveAll(outDir) // prepare writer writer := bufio.NewWriter(outFile) - for _, msg := range testCtx.packageData.Messages { - generateMessage(testCtx, writer, &msg) + for _, msg := range testCtx.file.Messages { + genMessage(testCtx, writer, &msg) Expect(writer.Buffered()).ToNot(BeZero()) } -} +}*/ /*func TestGenerateMessageName(t *testing.T) { RegisterTestingT(t) @@ -206,7 +232,7 @@ func TestGenerateMessageType(t *testing.T) { for i := 0; i < types.Len(); i++ { typ := types.At(i) Expect(writer.Buffered()).To(BeZero()) - err := generateMessage(testCtx, writer, typ, false) + err := genMessage(testCtx, writer, typ, false) Expect(err).ShouldNot(HaveOccurred()) Expect(writer.Buffered()).ToNot(BeZero()) @@ -317,7 +343,7 @@ func TestGeneratePackageHeader(t *testing.T) { // prepare writer writer := bufio.NewWriter(outFile) Expect(writer.Buffered()).To(BeZero()) - generateHeader(testCtx, writer, inFile) + genPackageComment(testCtx, writer, inFile) Expect(writer.Buffered()).ToNot(BeZero()) } diff --git a/binapigen/generate_encoding.go b/binapigen/generate_encoding.go new file mode 100644 index 00000000..7700ed95 --- /dev/null +++ b/binapigen/generate_encoding.go @@ -0,0 +1,410 @@ +// 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 binapigen + +import ( + "fmt" + "strconv" + + "github.com/sirupsen/logrus" +) + +func genMessageEncodingMethods(g *GenFile, msg *Message) { + genMessageMethodSize(g, msg.GoIdent.GoName, msg.Fields) + genMessageMethodMarshal(g, msg.GoIdent.GoName, msg.Fields) + genMessageMethodUnmarshal(g, msg.GoIdent.GoName, msg.Fields) +} + +func genMessageMethodSize(g *GenFile, name string, fields []*Field) { + g.P("func (m *", name, ") Size() (size int) {") + g.P("if m == nil { return 0 }") + + sizeBaseType := func(typ, name string, length int, sizefrom string) { + switch typ { + case STRING: + if length > 0 { + g.P("size += ", length, " // ", name) + } else { + g.P("size += 4 + len(", name, ")", " // ", name) + } + default: + var size = BaseTypeSizes[typ] + if sizefrom != "" { + g.P("size += ", size, " * len(", name, ")", " // ", name) + } else { + if length > 0 { + g.P("size += ", size, " * ", length, " // ", name) + } else { + g.P("size += ", size, " // ", name) + } + } + } + } + + lvl := 0 + var sizeFields func(fields []*Field, parentName string) + sizeFields = func(fields []*Field, parentName string) { + lvl++ + defer func() { lvl-- }() + + getFieldName := func(name string) string { + return fmt.Sprintf("%s.%s", parentName, name) + } + + for _, field := range fields { + name := getFieldName(field.GoName) + + var sizeFromName string + if field.FieldSizeFrom != nil { + sizeFromName = getFieldName(field.FieldSizeFrom.GoName) + } + + if _, ok := BaseTypesGo[field.Type]; ok { + sizeBaseType(field.Type, name, field.Length, sizeFromName) + continue + } + + if field.Array { + index := fmt.Sprintf("j%d", lvl) + if field.Length > 0 { + g.P("for ", index, " := 0; ", index, " < ", field.Length, "; ", index, "++ {") + } else if field.FieldSizeFrom != nil { + g.P("for ", index, " := 0; ", index, " < len(", name, "); ", index, "++ {") + } + if field.Length == 0 || field.SizeFrom != "" { + char := fmt.Sprintf("s%d", lvl) + g.P("var ", char, " ", fieldGoType(g, field)) + g.P("_ = ", char) + g.P("if ", index, " < len(", name, ") { ", char, " = ", name, "[", index, "] }") + name = char + } else { + name = fmt.Sprintf("%s[%s]", name, index) + } + } + + switch { + case field.TypeEnum != nil: + enum := field.TypeEnum + if _, ok := BaseTypesGo[enum.Type]; ok { + sizeBaseType(enum.Type, name, 0, "") + } else { + logrus.Panicf("\t// ??? ENUM %s %s\n", name, enum.Type) + } + case field.TypeAlias != nil: + alias := field.TypeAlias + if typ := alias.TypeStruct; typ != nil { + sizeFields(typ.Fields, name) + } else { + sizeBaseType(alias.Type, name, alias.Length, "") + } + case field.TypeStruct != nil: + typ := field.TypeStruct + sizeFields(typ.Fields, name) + case field.TypeUnion != nil: + union := field.TypeUnion + maxSize := getUnionSize(union) + sizeBaseType("u8", name, maxSize, "") + default: + logrus.Panicf("\t// ??? buf[pos] = %s (%s)\n", name, field.Type) + } + + if field.Array { + g.P("}") + } + } + } + sizeFields(fields, "m") + + g.P("return size") + g.P("}") +} + +func genMessageMethodMarshal(g *GenFile, name string, fields []*Field) { + g.P("func (m *", name, ") Marshal(b []byte) ([]byte, error) {") + g.P("if b == nil {") + g.P("b = make([]byte, m.Size())") + g.P("}") + g.P("buf := ", govppCodecPkg.Ident("NewBuffer"), "(b)") + + encodeFields(g, fields, "m", 0) + + g.P("return buf.Bytes(), nil") + g.P("}") +} + +func encodeFields(g *GenFile, fields []*Field, parentName string, lvl int) { + getFieldName := func(name string) string { + return fmt.Sprintf("%s.%s", parentName, name) + } + + for _, field := range fields { + name := getFieldName(field.GoName) + + encodeField(g, field, name, getFieldName, lvl) + } +} + +func encodeField(g *GenFile, field *Field, name string, getFieldName func(name string) string, lvl int) { + if f := field.FieldSizeOf; f != nil { + if _, ok := BaseTypesGo[field.Type]; ok { + val := fmt.Sprintf("len(%s)", getFieldName(f.GoName)) + encodeBaseType(g, field.Type, "int", val, 0, "", false) + return + } else { + panic(fmt.Sprintf("failed to encode base type of sizefrom field: %s (%s)", field.Name, field.Type)) + } + } + var sizeFromName string + if field.FieldSizeFrom != nil { + sizeFromName = getFieldName(field.FieldSizeFrom.GoName) + } + + if _, ok := BaseTypesGo[field.Type]; ok { + encodeBaseType(g, field.Type, fieldGoType(g, field), name, field.Length, sizeFromName, true) + return + } + + if field.Array { + index := fmt.Sprintf("j%d", lvl) + if field.Length > 0 { + g.P("for ", index, " := 0; ", index, " < ", field.Length, "; ", index, "++ {") + } else if field.SizeFrom != "" { + g.P("for ", index, " := 0; ", index, " < len(", name, "); ", index, "++ {") + } + if field.Length == 0 || field.SizeFrom != "" { + char := fmt.Sprintf("v%d", lvl) + g.P("var ", char, " ", fieldGoType(g, field), "// ", field.GoName) + g.P("if ", index, " < len(", name, ") { ", char, " = ", name, "[", index, "] }") + name = char + } else { + name = fmt.Sprintf("%s[%s]", name, index) + } + } + + switch { + case field.TypeEnum != nil: + encodeBaseType(g, field.TypeEnum.Type, fieldGoType(g, field), name, 0, "", false) + case field.TypeAlias != nil: + alias := field.TypeAlias + if typ := alias.TypeStruct; typ != nil { + encodeFields(g, typ.Fields, name, lvl+1) + } else { + if alias.Length > 0 { + encodeBaseType(g, alias.Type, BaseTypesGo[alias.Type], name, alias.Length, "", false) + } else { + encodeBaseType(g, alias.Type, fieldGoType(g, field), name, 0, "", false) + } + } + case field.TypeStruct != nil: + encodeFields(g, field.TypeStruct.Fields, name, lvl+1) + case field.TypeUnion != nil: + maxSize := getUnionSize(field.TypeUnion) + g.P("buf.EncodeBytes(", name, ".", fieldUnionData, "[:], ", maxSize, ")") + default: + logrus.Panicf("\t// ??? buf[pos] = %s (%s)\n", name, field.Type) + } + + if field.Array { + g.P("}") + } +} + +func encodeBaseType(g *GenFile, typ, orig, name string, length int, sizefrom string, alloc bool) { + isArray := length > 0 || sizefrom != "" + if isArray { + switch typ { + case U8: + if alloc { + g.P("buf.EncodeBytes(", name, ", ", length, ")") + } else { + g.P("buf.EncodeBytes(", name, "[:], ", length, ")") + } + return + case I8, I16, U16, I32, U32, I64, U64, F64, BOOL: + gotype := BaseTypesGo[typ] + if length != 0 { + g.P("for i := 0; i < ", length, "; i++ {") + } else if sizefrom != "" { + g.P("for i := 0; i < len(", name, "); i++ {") + } + if alloc { + g.P("var x ", gotype) + g.P("if i < len(", name, ") { x = ", gotype, "(", name, "[i]) }") + name = "x" + } + } + } + conv := func(s string) string { + if gotype, ok := BaseTypesGo[typ]; !ok || gotype != orig { + return fmt.Sprintf("%s(%s)", gotype, s) + } + return s + } + switch typ { + case I8, I16, I32, I64: + typsize := BaseTypeSizes[typ] + g.P("buf.EncodeInt", typsize*8, "(", conv(name), ")") + case U8, U16, U32, U64: + typsize := BaseTypeSizes[typ] + g.P("buf.EncodeUint", typsize*8, "(", conv(name), ")") + case F64: + g.P("buf.EncodeFloat64(", conv(name), ")") + case BOOL: + g.P("buf.EncodeBool(", name, ")") + case STRING: + g.P("buf.EncodeString(", name, ", ", length, ")") + default: + logrus.Panicf("// ??? %s %s\n", name, typ) + } + if isArray { + switch typ { + case I8, U8, I16, U16, I32, U32, I64, U64, F64, BOOL: + g.P("}") + } + } +} + +func genMessageMethodUnmarshal(g *GenFile, name string, fields []*Field) { + g.P("func (m *", name, ") Unmarshal(b []byte) error {") + + if len(fields) > 0 { + g.P("buf := ", govppCodecPkg.Ident("NewBuffer"), "(b)") + decodeFields(g, fields, "m", 0) + } + + g.P("return nil") + g.P("}") +} + +func decodeFields(g *GenFile, fields []*Field, parentName string, lvl int) { + getFieldName := func(name string) string { + return fmt.Sprintf("%s.%s", parentName, name) + } + + for _, field := range fields { + name := getFieldName(field.GoName) + + decodeField(g, field, name, getFieldName, lvl) + } +} + +func decodeField(g *GenFile, field *Field, name string, getFieldName func(string) string, lvl int) { + var sizeFromName string + if field.FieldSizeFrom != nil { + sizeFromName = getFieldName(field.FieldSizeFrom.GoName) + } + + if _, ok := BaseTypesGo[field.Type]; ok { + decodeBaseType(g, field.Type, fieldGoType(g, field), name, field.Length, sizeFromName, true) + return + } + + if field.Array { + index := fmt.Sprintf("j%d", lvl) + if field.Length > 0 { + g.P("for ", index, " := 0; ", index, " < ", field.Length, ";", index, "++ {") + } else if field.SizeFrom != "" { + g.P(name, " = make(", getFieldType(g, field), ", ", sizeFromName, ")") + g.P("for ", index, " := 0; ", index, " < len(", name, ");", index, "++ {") + } + name = fmt.Sprintf("%s[%s]", name, index) + } + + if enum := field.TypeEnum; enum != nil { + if _, ok := BaseTypesGo[enum.Type]; ok { + decodeBaseType(g, enum.Type, fieldGoType(g, field), name, 0, "", false) + } else { + logrus.Panicf("\t// ??? ENUM %s %s\n", name, enum.Type) + } + } else if alias := field.TypeAlias; alias != nil { + if typ := alias.TypeStruct; typ != nil { + decodeFields(g, typ.Fields, name, lvl+1) + } else { + if alias.Length > 0 { + decodeBaseType(g, alias.Type, BaseTypesGo[alias.Type], name, alias.Length, "", false) + } else { + decodeBaseType(g, alias.Type, fieldGoType(g, field), name, 0, "", false) + } + } + } else if typ := field.TypeStruct; typ != nil { + decodeFields(g, typ.Fields, name, lvl+1) + } else if union := field.TypeUnion; union != nil { + maxSize := getUnionSize(union) + g.P("copy(", name, ".", fieldUnionData, "[:], buf.DecodeBytes(", maxSize, "))") + } else { + logrus.Panicf("\t// ??? %s (%v)\n", field.GoName, field.Type) + } + + if field.Array { + g.P("}") + } +} + +func decodeBaseType(g *GenFile, typ, orig, name string, length int, sizefrom string, alloc bool) { + isArray := length > 0 || sizefrom != "" + if isArray { + var size string + switch { + case length > 0: + size = strconv.Itoa(length) + case sizefrom != "": + size = sizefrom + } + switch typ { + case U8: + if alloc { + g.P(name, " = make([]byte, ", size, ")") + g.P("copy(", name, ", buf.DecodeBytes(len(", name, ")))") + } else { + g.P("copy(", name, "[:], buf.DecodeBytes(", size, "))") + } + return + case I8, I16, U16, I32, U32, I64, U64, F64, BOOL: + if alloc { + g.P(name, " = make([]", orig, ", ", size, ")") + } + g.P("for i := 0; i < len(", name, "); i++ {") + name = fmt.Sprintf("%s[i]", name) + } + } + conv := func(s string) string { + if gotype, ok := BaseTypesGo[typ]; !ok || gotype != orig { + return fmt.Sprintf("%s(%s)", orig, s) + } + return s + } + switch typ { + case I8, I16, I32, I64: + typsize := BaseTypeSizes[typ] + g.P(name, " = ", conv(fmt.Sprintf("buf.DecodeInt%d()", typsize*8))) + case U8, U16, U32, U64: + typsize := BaseTypeSizes[typ] + g.P(name, " = ", conv(fmt.Sprintf("buf.DecodeUint%d()", typsize*8))) + case F64: + g.P(name, " = ", conv("buf.DecodeFloat64()")) + case BOOL: + g.P(name, " = buf.DecodeBool()") + case STRING: + g.P(name, " = buf.DecodeString(", length, ")") + default: + logrus.Panicf("\t// ??? %s %s\n", name, typ) + } + if isArray { + switch typ { + case I8, U8, I16, U16, I32, U32, I64, U64, F64, BOOL: + g.P("}") + } + } +} diff --git a/binapigen/generate_helpers.go b/binapigen/generate_helpers.go new file mode 100644 index 00000000..c5857551 --- /dev/null +++ b/binapigen/generate_helpers.go @@ -0,0 +1,510 @@ +// 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 binapigen + +import ( + "fmt" +) + +// library dependencies +const ( + fmtPkg = GoImportPath("fmt") + netPkg = GoImportPath("net") + timePkg = GoImportPath("time") + stringsPkg = GoImportPath("strings") +) + +func genHelperMethods(g *GenFile, typName, goName string) { + switch typName { + + // alias-specific methods + case "ip4_address": + genIPXAddressHelpers(g, goName, 4) + case "ip6_address": + genIPXAddressHelpers(g, goName, 6) + case "address_with_prefix": + genAddressWithPrefixHelpers(g, goName) + case "mac_address": + genMacAddressHelpers(g, goName) + case "timestamp": + genTimestampHelpers(g, goName) + + // type-specific methods + case "address": + genAddressHelpers(g, goName) + case "prefix": + genPrefixHelpers(g, goName) + case "ip4_prefix": + genIPXPrefixHelpers(g, goName, 4) + case "ip6_prefix": + genIPXPrefixHelpers(g, goName, 6) + + } +} + +func genIPXAddressHelpers(g *GenFile, structName string, ipv int) { + validateIPvX(ipv) + + // IPXAddressFromIP method (net.IP -> IPXAddress) + g.P("func New", structName, "(ip ", netPkg.Ident("IP"), ") ", structName, " {") + g.P(" var ipaddr ", structName) + if ipv == 4 { + g.P(" copy(ipaddr[:], ip.To4())") + } else { + g.P(" copy(ipaddr[:], ip.To16())") + } + g.P(" return ipaddr") + g.P("}") + g.P() + + // ParseIPXAddress method (string -> IPXAddress) + g.P("func Parse", structName, "(s string) (", structName, ", error) {") + if ipv == 4 { + g.P(" ip := ", netPkg.Ident("ParseIP"), "(s).To4()") + } else { + g.P(" ip := ", netPkg.Ident("ParseIP"), "(s).To16()") + } + g.P(" if ip == nil {") + g.P(" return ", structName, "{}, ", fmtPkg.Ident("Errorf"), "(\"invalid IP"+fmt.Sprint(ipv)+" address: %s\", s)") + g.P(" }") + g.P(" var ipaddr ", structName) + if ipv == 4 { + g.P(" copy(ipaddr[:], ip.To4())") + } else { + g.P(" copy(ipaddr[:], ip.To16())") + } + g.P(" return ipaddr, nil") + g.P("}") + g.P() + + // ToIP method (IPXAddress -> net.IP) + g.P("func (x ", structName, ") ToIP() ", netPkg.Ident("IP"), " {") + if ipv == 4 { + g.P(" return ", netPkg.Ident("IP"), "(x[:]).To4()") + } else { + g.P(" return ", netPkg.Ident("IP"), "(x[:]).To16()") + } + g.P("}") + g.P() + + // String method (IPX -> string) + g.P("func (x ", structName, ") String() string {") + g.P(" return x.ToIP().String()") + g.P("}") + g.P() + + // MarshalText method + g.P("func (x *", structName, ") MarshalText() ([]byte, error) {") + g.P(" return []byte(x.String()), nil") + g.P("}") + g.P() + + // UnmarshalText method + g.P("func (x *", structName, ") UnmarshalText(text []byte) error {") + g.P(" ipaddr, err := Parse", structName, "(string(text))") + g.P(" if err !=nil {") + g.P(" return err") + g.P(" }") + g.P(" *x = ipaddr") + g.P(" return nil") + g.P("}") + g.P() +} + +func genAddressHelpers(g *GenFile, structName string) { + // AddressFromIP method (net.IP -> Address) + g.P("func New", structName, "(ip ", netPkg.Ident("IP"), ") ", structName, " {") + g.P(" var addr ", structName) + g.P(" if ip.To4() == nil {") + g.P(" addr.Af = ADDRESS_IP6") + g.P(" var ip6 IP6Address") + g.P(" copy(ip6[:], ip.To16())") + g.P(" addr.Un.SetIP6(ip6)") + g.P(" } else {") + g.P(" addr.Af = ADDRESS_IP4") + g.P(" var ip4 IP4Address") + g.P(" copy(ip4[:], ip.To4())") + g.P(" addr.Un.SetIP4(ip4)") + g.P(" }") + g.P(" return addr") + g.P("}") + g.P() + + // ParseAddress method (string -> Address) + g.P("func Parse", structName, "(s string) (", structName, ", error) {") + g.P(" ip := ", netPkg.Ident("ParseIP"), "(s)") + g.P(" if ip == nil {") + g.P(" return ", structName, "{}, ", fmtPkg.Ident("Errorf"), "(\"invalid IP address: %s\", s)") + g.P(" }") + g.P(" return New", structName, "(ip), nil") + g.P("}") + g.P() + + // ToIP method (Address -> net.IP) + g.P("func (x ", structName, ") ToIP() ", netPkg.Ident("IP"), " {") + g.P(" if x.Af == ADDRESS_IP6 {") + g.P(" ip6 := x.Un.GetIP6()") + g.P(" return ", netPkg.Ident("IP"), "(ip6[:]).To16()") + g.P(" } else {") + g.P(" ip4 := x.Un.GetIP4()") + g.P(" return ", netPkg.Ident("IP"), "(ip4[:]).To4()") + g.P(" }") + g.P("}") + g.P() + + // String method + g.P("func (x ", structName, ") String() string {") + g.P(" return x.ToIP().String()") + g.P("}") + g.P() + + // MarshalText method + g.P("func (x *", structName, ") MarshalText() ([]byte, error) {") + g.P(" return []byte(x.String()), nil") + g.P("}") + g.P() + + // UnmarshalText method + g.P("func (x *", structName, ") UnmarshalText(text []byte) error {") + g.P(" addr, err := Parse", structName, "(string(text))") + g.P(" if err != nil {") + g.P(" return err") + g.P(" }") + g.P(" *x = addr") + g.P(" return nil") + g.P("}") + g.P() +} + +func genIPXPrefixHelpers(g *GenFile, structName string, ipv int) { + validateIPvX(ipv) + + // NewIPXPrefix method (net.IPNet -> IPXPrefix) + g.P("func New", structName, "(network ", netPkg.Ident("IPNet"), ") ", structName, " {") + g.P(" var prefix ", structName) + g.P(" maskSize, _ := network.Mask.Size()") + g.P(" prefix.Len = byte(maskSize)") + if ipv == 4 { + g.P(" prefix.Address = NewIP4Address(network.IP)") + } else { + g.P(" prefix.Address = NewIP6Address(network.IP)") + } + g.P(" return prefix") + g.P("}") + g.P() + + // ParsePrefix method (string -> IPXPrefix) + g.P("func Parse", structName, "(s string) (prefix ", structName, ", err error) {") + g.P(" hasPrefix := ", stringsPkg.Ident("Contains"), "(s, \"/\")") + g.P(" if hasPrefix {") + g.P(" ip, network, err := ", netPkg.Ident("ParseCIDR"), "(s)") + g.P(" if err != nil {") + g.P(" return ", structName, "{}, ", fmtPkg.Ident("Errorf"), "(\"invalid IP"+fmt.Sprint(ipv)+" %s: %s\", s, err)") + g.P(" }") + g.P(" maskSize, _ := network.Mask.Size()") + g.P(" prefix.Len = byte(maskSize)") + if ipv == 4 { + g.P(" prefix.Address, err = ParseIP4Address(ip.String())") + } else { + g.P(" prefix.Address, err = ParseIP6Address(ip.String())") + } + g.P(" if err != nil {") + g.P(" return ", structName, "{}, ", fmtPkg.Ident("Errorf"), "(\"invalid IP"+fmt.Sprint(ipv)+" %s: %s\", s, err)") + g.P(" }") + g.P(" } else {") + g.P(" ip := ", netPkg.Ident("ParseIP"), "(s)") + g.P(" defaultMaskSize, _ := ", netPkg.Ident("CIDRMask"), "(32, 32).Size()") + g.P(" if ip.To4() == nil {") + g.P(" defaultMaskSize, _ =", netPkg.Ident("CIDRMask"), "(128, 128).Size()") + g.P(" }") + g.P(" prefix.Len = byte(defaultMaskSize)") + if ipv == 4 { + g.P(" prefix.Address, err = ParseIP4Address(ip.String())") + } else { + g.P(" prefix.Address, err = ParseIP6Address(ip.String())") + } + g.P(" if err != nil {") + g.P(" return ", structName, "{}, ", fmtPkg.Ident("Errorf"), "(\"invalid IP"+fmt.Sprint(ipv)+" %s: %s\", s, err)") + g.P(" }") + g.P(" }") + g.P(" return prefix, nil") + g.P("}") + g.P() + + // ToIPNet method (IPXPrefix -> net.IPNet) + g.P("func (x ", structName, ") ToIPNet() *", netPkg.Ident("IPNet"), " {") + if ipv == 4 { + g.P(" mask := ", netPkg.Ident("CIDRMask"), "(int(x.Len), 32)") + } else { + g.P(" mask := ", netPkg.Ident("CIDRMask"), "(int(x.Len), 128)") + } + g.P(" ipnet := &", netPkg.Ident("IPNet"), "{IP: x.Address.ToIP(), Mask: mask}") + g.P(" return ipnet") + g.P("}") + g.P() + + // String method + g.P("func (x ", structName, ") String() string {") + g.P(" ip := x.Address.String()") + g.P(" return ip + \"/\" + ", strconvPkg.Ident("Itoa"), "(int(x.Len))") + g.P("}") + g.P() + + // MarshalText method + g.P("func (x *", structName, ") MarshalText() ([]byte, error) {") + g.P(" return []byte(x.String()), nil") + g.P("}") + g.P() + + // UnmarshalText method + g.P("func (x *", structName, ") UnmarshalText(text []byte) error {") + g.P(" prefix, err := Parse", structName, "(string(text))") + g.P(" if err != nil {") + g.P(" return err") + g.P(" }") + g.P(" *x = prefix") + g.P(" return nil") + g.P("}") + g.P() +} + +func genPrefixHelpers(g *GenFile, structName string) { + // NewPrefix method (net.IPNet -> Prefix) + g.P("func New", structName, "(network ", netPkg.Ident("IPNet"), ") ", structName, " {") + g.P(" var prefix ", structName) + g.P(" maskSize, _ := network.Mask.Size()") + g.P(" prefix.Len = byte(maskSize)") + g.P(" prefix.Address = NewAddress(network.IP)") + g.P(" return prefix") + g.P("}") + g.P() + + // ParsePrefix method (string -> Prefix) + g.P("func Parse", structName, "(ip string) (prefix ", structName, ", err error) {") + g.P(" hasPrefix := ", stringsPkg.Ident("Contains"), "(ip, \"/\")") + g.P(" if hasPrefix {") + g.P(" netIP, network, err := ", netPkg.Ident("ParseCIDR"), "(ip)") + g.P(" if err != nil {") + g.P(" return Prefix{}, ", fmtPkg.Ident("Errorf"), "(\"invalid IP %s: %s\", ip, err)") + g.P(" }") + g.P(" maskSize, _ := network.Mask.Size()") + g.P(" prefix.Len = byte(maskSize)") + g.P(" prefix.Address, err = ParseAddress(netIP.String())") + g.P(" if err != nil {") + g.P(" return Prefix{}, ", fmtPkg.Ident("Errorf"), "(\"invalid IP %s: %s\", ip, err)") + g.P(" }") + g.P(" } else {") + g.P(" netIP := ", netPkg.Ident("ParseIP"), "(ip)") + g.P(" defaultMaskSize, _ := ", netPkg.Ident("CIDRMask"), "(32, 32).Size()") + g.P(" if netIP.To4() == nil {") + g.P(" defaultMaskSize, _ =", netPkg.Ident("CIDRMask"), "(128, 128).Size()") + g.P(" }") + g.P(" prefix.Len = byte(defaultMaskSize)") + g.P(" prefix.Address, err = ParseAddress(netIP.String())") + g.P(" if err != nil {") + g.P(" return Prefix{}, ", fmtPkg.Ident("Errorf"), "(\"invalid IP %s: %s\", ip, err)") + g.P(" }") + g.P(" }") + g.P(" return prefix, nil") + g.P("}") + g.P() + + // ToIPNet method (Prefix -> net.IPNet) + g.P("func (x ", structName, ") ToIPNet() *", netPkg.Ident("IPNet"), " {") + g.P(" var mask ", netPkg.Ident("IPMask")) + g.P(" if x.Address.Af == ADDRESS_IP4 {") + g.P(" mask = ", netPkg.Ident("CIDRMask"), "(int(x.Len), 32)") + g.P(" } else {") + g.P(" mask = ", netPkg.Ident("CIDRMask"), "(int(x.Len), 128)") + g.P(" }") + g.P(" ipnet := &", netPkg.Ident("IPNet"), "{IP: x.Address.ToIP(), Mask: mask}") + g.P(" return ipnet") + g.P("}") + g.P() + + // String method + g.P("func (x ", structName, ") String() string {") + g.P(" ip := x.Address.String()") + g.P(" return ip + \"/\" + ", strconvPkg.Ident("Itoa"), "(int(x.Len))") + g.P("}") + g.P() + + // MarshalText method + g.P("func (x *", structName, ") MarshalText() ([]byte, error) {") + g.P(" return []byte(x.String()), nil") + g.P("}") + g.P() + + // UnmarshalText method + g.P("func (x *", structName, ") UnmarshalText(text []byte) error {") + g.P(" prefix, err := Parse", structName, "(string(text))") + g.P(" if err !=nil {") + g.P(" return err") + g.P(" }") + g.P(" *x = prefix") + g.P(" return nil") + g.P("}") + g.P() +} + +func genAddressWithPrefixHelpers(g *GenFile, structName string) { + // NewAddressWithPrefix method (net.HardwareAddr -> MacAddress) + g.P("func New", structName, "(network ", netPkg.Ident("IPNet"), ") ", structName, " {") + g.P(" prefix := NewPrefix(network)") + g.P(" return ", structName, "(prefix)") + g.P("}") + g.P() + + // ParseAddressWithPrefix method (string -> AddressWithPrefix) + g.P("func Parse", structName, "(s string) (", structName, ", error) {") + g.P(" prefix, err := ParsePrefix(s)") + g.P(" if err != nil {") + g.P(" return ", structName, "{}, err") + g.P(" }") + g.P(" return ", structName, "(prefix), nil") + g.P("}") + g.P() + + // ToIPNet method (Prefix -> net.IPNet) + g.P("func (x ", structName, ") ToIPNet() *", netPkg.Ident("IPNet"), " {") + g.P(" return Prefix(x).ToIPNet()") + g.P("}") + g.P() + + // String method + g.P("func (x ", structName, ") String() string {") + g.P(" return Prefix(x).String()") + g.P("}") + g.P() + + // MarshalText method + g.P("func (x *", structName, ") MarshalText() ([]byte, error) {") + g.P(" return []byte(x.String()), nil") + g.P("}") + g.P() + + // UnmarshalText method + g.P("func (x *", structName, ") UnmarshalText(text []byte) error {") + g.P(" prefix, err := Parse", structName, "(string(text))") + g.P(" if err != nil {") + g.P(" return err") + g.P(" }") + g.P(" *x = prefix") + g.P(" return nil") + g.P("}") + g.P() +} + +func genMacAddressHelpers(g *GenFile, structName string) { + // NewMAC method (net.HardwareAddr -> MacAddress) + g.P("func New", structName, "(mac ", netPkg.Ident("HardwareAddr"), ") ", structName, " {") + g.P(" var macaddr ", structName) + g.P(" copy(macaddr[:], mac[:])") + g.P(" return macaddr") + g.P("}") + g.P() + + // ParseMAC method (string -> MacAddress) + g.P("func Parse", structName, "(s string) (", structName, ", error) {") + g.P(" var macaddr ", structName) + g.P(" mac, err := ", netPkg.Ident("ParseMAC"), "(s)") + g.P(" if err != nil {") + g.P(" return macaddr, err") + g.P(" }") + g.P(" copy(macaddr[:], mac[:])") + g.P(" return macaddr, nil") + g.P("}") + g.P() + + // ToMAC method (MacAddress -> net.HardwareAddr) + g.P("func (x ", structName, ") ToMAC() ", netPkg.Ident("HardwareAddr"), " {") + g.P(" return ", netPkg.Ident("HardwareAddr"), "(x[:])") + g.P("}") + g.P() + + // String method + g.P("func (x ", structName, ") String() string {") + g.P(" return x.ToMAC().String()") + g.P("}") + g.P() + + // MarshalText method + g.P("func (x *", structName, ") MarshalText() ([]byte, error) {") + g.P(" return []byte(x.String()), nil") + g.P("}") + g.P() + + // UnmarshalText method + g.P("func (x *", structName, ") UnmarshalText(text []byte) error {") + g.P(" mac, err := Parse", structName, "(string(text))") + g.P(" if err != nil {") + g.P(" return err") + g.P(" }") + g.P(" *x = mac") + g.P(" return nil") + g.P("}") + g.P() +} + +func genTimestampHelpers(g *GenFile, structName string) { + // NewTimestamp method (time.Time -> Timestamp) + g.P("func New", structName, "(t ", timePkg.Ident("Time"), ") ", structName, " {") + g.P(" sec := int64(t.Unix())") + g.P(" nsec := int32(t.Nanosecond())") + g.P(" ns := float64(sec) + float64(nsec / 1e9)") + g.P(" return ", structName, "(ns)") + g.P("}") + g.P() + + // ToTime method (Timestamp -> time.Time) + g.P("func (x ", structName, ") ToTime() ", timePkg.Ident("Time"), " {") + g.P(" ns := int64(x * 1e9)") + g.P(" sec := ns / 1e9") + g.P(" nsec := ns % 1e9") + g.P(" return ", timePkg.Ident("Unix"), "(sec, nsec)") + g.P("}") + g.P() + + // String method + g.P("func (x ", structName, ") String() string {") + g.P(" return x.ToTime().String()") + g.P("}") + g.P() + + // MarshalText method + g.P("func (x *", structName, ") MarshalText() ([]byte, error) {") + g.P(" return []byte(x.ToTime().Format(", timePkg.Ident("RFC3339Nano"), ")), nil") + g.P("}") + g.P() + + // UnmarshalText method + g.P("func (x *", structName, ") UnmarshalText(text []byte) error {") + g.P(" t, err := ", timePkg.Ident("Parse"), "(", timePkg.Ident("RFC3339Nano"), ", string(text))") + g.P(" if err != nil {") + g.P(" return err") + g.P(" }") + g.P(" *x = New", structName, "(t)") + g.P(" return nil") + g.P("}") + g.P() +} + +func validateIPvX(ipv int) { + switch ipv { + case 4, 6: + default: + panic("ipv must be 4 or 6, got: " + fmt.Sprint(ipv)) + } +} diff --git a/binapigen/generate_helpers_test.go b/binapigen/generate_helpers_test.go new file mode 100644 index 00000000..5ae10c1d --- /dev/null +++ b/binapigen/generate_helpers_test.go @@ -0,0 +1,183 @@ +// 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 binapigen + +import ( + "strings" + "testing" + "time" + + . "github.com/onsi/gomega" + + "github.com/alkiranet/govpp/binapi/ethernet_types" + "github.com/alkiranet/govpp/binapi/ip_types" + "github.com/alkiranet/govpp/binapi/vpe_types" +) + +func TestGeneratedParseAddress(t *testing.T) { + RegisterTestingT(t) + + var data = []struct { + input string + result ip_types.Address + }{ + {"192.168.0.1", ip_types.Address{ + Af: ip_types.ADDRESS_IP4, + Un: ip_types.AddressUnionIP4(ip_types.IP4Address{192, 168, 0, 1}), + }}, + {"aac1:0:ab45::", ip_types.Address{ + Af: ip_types.ADDRESS_IP6, + Un: ip_types.AddressUnionIP6(ip_types.IP6Address{170, 193, 0, 0, 171, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}), + }}, + } + + for _, entry := range data { + t.Run(entry.input, func(t *testing.T) { + parsedAddress, err := ip_types.ParseAddress(entry.input) + Expect(err).ShouldNot(HaveOccurred()) + Expect(parsedAddress).To(Equal(entry.result)) + + originAddress := parsedAddress.String() + Expect(originAddress).To(Equal(entry.input)) + }) + } +} + +func TestGeneratedParseAddressError(t *testing.T) { + RegisterTestingT(t) + + _, err := ip_types.ParseAddress("malformed_ip") + Expect(err).Should(HaveOccurred()) +} + +func TestGeneratedParsePrefix(t *testing.T) { + RegisterTestingT(t) + + var data = []struct { + input string + result ip_types.Prefix + }{ + {"192.168.0.1/24", ip_types.Prefix{ + Address: ip_types.Address{ + Af: ip_types.ADDRESS_IP4, + Un: ip_types.AddressUnionIP4(ip_types.IP4Address{192, 168, 0, 1}), + }, + Len: 24, + }}, + {"192.168.0.1", ip_types.Prefix{ + Address: ip_types.Address{ + Af: ip_types.ADDRESS_IP4, + Un: ip_types.AddressUnionIP4(ip_types.IP4Address{192, 168, 0, 1}), + }, + Len: 32, + }}, + {"aac1:0:ab45::/96", ip_types.Prefix{ + Address: ip_types.Address{ + Af: ip_types.ADDRESS_IP6, + Un: ip_types.AddressUnionIP6(ip_types.IP6Address{170, 193, 0, 0, 171, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}), + }, + Len: 96, + }}, + {"aac1:0:ab45::", ip_types.Prefix{ + Address: ip_types.Address{ + Af: ip_types.ADDRESS_IP6, + Un: ip_types.AddressUnionIP6(ip_types.IP6Address{170, 193, 0, 0, 171, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}), + }, + Len: 128, + }}, + } + + for _, entry := range data { + t.Run(entry.input, func(t *testing.T) { + parsedAddress, err := ip_types.ParsePrefix(entry.input) + Expect(err).ShouldNot(HaveOccurred()) + Expect(parsedAddress).To(Equal(entry.result)) + + // Parsed IP without prefix receives a default one + // so the input data must be adjusted + if entry.result.Address.Af == ip_types.ADDRESS_IP4 && !strings.Contains(entry.input, "/") { + entry.input = entry.input + "/32" + } + if entry.result.Address.Af == ip_types.ADDRESS_IP6 && !strings.Contains(entry.input, "/") { + entry.input = entry.input + "/128" + } + originAddress := parsedAddress.String() + Expect(originAddress).To(Equal(entry.input)) + }) + } +} + +func TestGeneratedParsePrefixError(t *testing.T) { + RegisterTestingT(t) + + _, err := ip_types.ParsePrefix("malformed_ip") + Expect(err).Should(HaveOccurred()) +} + +func TestGeneratedParseMAC(t *testing.T) { + RegisterTestingT(t) + + var data = []struct { + input string + result ethernet_types.MacAddress + }{ + {"b7:b9:bb:a1:5c:af", ethernet_types.MacAddress{183, 185, 187, 161, 92, 175}}, + {"47:4b:c7:3e:06:c8", ethernet_types.MacAddress{71, 75, 199, 62, 6, 200}}, + {"a7:cc:9f:10:18:e3", ethernet_types.MacAddress{167, 204, 159, 16, 24, 227}}, + } + + for _, entry := range data { + t.Run(entry.input, func(t *testing.T) { + parsedMac, err := ethernet_types.ParseMacAddress(entry.input) + Expect(err).ShouldNot(HaveOccurred()) + Expect(parsedMac).To(Equal(entry.result)) + + originAddress := parsedMac.String() + Expect(originAddress).To(Equal(entry.input)) + }) + } +} + +func TestGeneratedParseMACError(t *testing.T) { + RegisterTestingT(t) + + _, err := ethernet_types.ParseMacAddress("malformed_mac") + Expect(err).Should(HaveOccurred()) +} + +func TestGeneratedParseTimestamp(t *testing.T) { + RegisterTestingT(t) + + var data = []struct { + input time.Time + result vpe_types.Timestamp + }{ + {time.Unix(0, 0), vpe_types.Timestamp(0)}, + {time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), + vpe_types.Timestamp(9.466848e+08)}, + } + + for _, entry := range data { + t.Run(entry.input.String(), func(t *testing.T) { + ts := vpe_types.NewTimestamp(entry.input) + Expect(ts).To(Equal(entry.result)) + + Expect(entry.input.Equal(ts.ToTime())).To(BeTrue()) + + originTime := ts.String() + Expect(originTime).To(Equal(entry.input.Local().String())) + }) + } +} diff --git a/binapigen/generate_http.go b/binapigen/generate_http.go new file mode 100644 index 00000000..960e4911 --- /dev/null +++ b/binapigen/generate_http.go @@ -0,0 +1,102 @@ +// 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 binapigen + +import ( + "path" + "strconv" +) + +func init() { + RegisterPlugin("http", GenerateHTTP) +} + +// library dependencies +const ( + httpPkg = GoImportPath("net/http") + ioutilPkg = GoImportPath("io/ioutil") + jsonPkg = GoImportPath("encoding/json") +) + +func GenerateHTTP(gen *Generator, file *File) *GenFile { + if file.Service == nil { + return nil + } + + logf("----------------------------") + logf(" Generate HTTP - %s", file.Desc.Name) + logf("----------------------------") + + filename := path.Join(file.FilenamePrefix, file.Desc.Name+"_http"+generatedFilenameSuffix) + g := gen.NewGenFile(filename, file) + + // file header + genCodeGeneratedComment(g) + g.P() + g.P("package ", file.PackageName) + g.P() + + // service HTTP handlers + if len(file.Service.RPCs) > 0 { + genHTTPHandler(g, file.Service) + } + + return g +} + +func genHTTPHandler(g *GenFile, svc *Service) { + // constructor + g.P("func HTTPHandler(rpc ", serviceApiName, ") ", httpPkg.Ident("Handler"), " {") + g.P(" mux := ", httpPkg.Ident("NewServeMux"), "()") + + // http handlers for rpc + for _, rpc := range svc.RPCs { + if rpc.MsgReply == nil { + continue + } + if rpc.VPP.Stream { + continue // TODO: implement handler for streaming messages + } + g.P("mux.HandleFunc(", strconv.Quote("/"+rpc.VPP.Request), ", func(w ", httpPkg.Ident("ResponseWriter"), ", req *", httpPkg.Ident("Request"), ") {") + g.P("var request = new(", rpc.MsgRequest.GoName, ")") + if len(rpc.MsgRequest.Fields) > 0 { + g.P("b, err := ", ioutilPkg.Ident("ReadAll"), "(req.Body)") + g.P("if err != nil {") + g.P(" ", httpPkg.Ident("Error"), "(w, \"read body failed\", ", httpPkg.Ident("StatusBadRequest"), ")") + g.P(" return") + g.P("}") + g.P("if err := ", jsonPkg.Ident("Unmarshal"), "(b, request); err != nil {") + g.P(" ", httpPkg.Ident("Error"), "(w, \"unmarshal data failed\", ", httpPkg.Ident("StatusBadRequest"), ")") + g.P(" return") + g.P("}") + } + g.P("reply, err := rpc.", rpc.GoName, "(req.Context(), request)") + g.P("if err != nil {") + g.P(" ", httpPkg.Ident("Error"), "(w, \"request failed: \"+err.Error(), ", httpPkg.Ident("StatusInternalServerError"), ")") + g.P(" return") + g.P("}") + g.P("rep, err := ", jsonPkg.Ident("MarshalIndent"), "(reply, \"\", \" \")") + g.P("if err != nil {") + g.P(" ", httpPkg.Ident("Error"), "(w, \"marshal failed: \"+err.Error(), ", httpPkg.Ident("StatusInternalServerError"), ")") + g.P(" return") + g.P("}") + g.P("w.Write(rep)") + g.P("})") + } + + g.P("return ", httpPkg.Ident("HandlerFunc"), "(mux.ServeHTTP)") + g.P("}") + g.P() +} diff --git a/binapigen/generate_rpc.go b/binapigen/generate_rpc.go new file mode 100644 index 00000000..edfd9a73 --- /dev/null +++ b/binapigen/generate_rpc.go @@ -0,0 +1,258 @@ +// 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 binapigen + +import ( + "fmt" + "path" + + "github.com/sirupsen/logrus" +) + +func init() { + RegisterPlugin("rpc", GenerateRPC) +} + +// library dependencies +const ( + contextPkg = GoImportPath("context") + ioPkg = GoImportPath("io") +) + +// generated names +const ( + serviceApiName = "RPCService" // name for the RPC service interface + serviceImplName = "serviceClient" // name for the RPC service implementation + serviceClientName = "ServiceClient" // name for the RPC service client + + // TODO: register service descriptor + //serviceDescType = "ServiceDesc" // name for service descriptor type + //serviceDescName = "_ServiceRPC_serviceDesc" // name for service descriptor var +) + +func GenerateRPC(gen *Generator, file *File) *GenFile { + // skip if no service is defined for file + if file.Service == nil { + return nil + } + + logf("----------------------------") + logf(" Generate RPC - %s", file.Desc.Name) + logf("----------------------------") + + filename := path.Join(file.FilenamePrefix, file.Desc.Name+"_rpc"+generatedFilenameSuffix) + g := gen.NewGenFile(filename, file) + + // file header + genCodeGeneratedComment(g) + g.P() + g.P("package ", file.PackageName) + g.P() + + // service RPCs + if len(file.Service.RPCs) > 0 { + genService(g, file.Service) + } + + return g +} + +func genService(g *GenFile, svc *Service) { + // generate comment + g.P("// ", serviceApiName, " defines RPC service ", g.file.Desc.Name, ".") + + // generate service interface + g.P("type ", serviceApiName, " interface {") + for _, rpc := range svc.RPCs { + g.P(rpcMethodSignature(g, rpc)) + } + g.P("}") + g.P() + + // generate client implementation + g.P("type ", serviceImplName, " struct {") + g.P("conn ", govppApiPkg.Ident("Connection")) + g.P("}") + g.P() + + // generate client constructor + g.P("func New", serviceClientName, "(conn ", govppApiPkg.Ident("Connection"), ") ", serviceApiName, " {") + g.P("return &", serviceImplName, "{conn}") + g.P("}") + g.P() + + msgControlPingReply, ok := g.gen.messagesByName["control_ping_reply"] + if !ok { + logrus.Fatalf("no message for %v", "control_ping_reply") + } + msgControlPing, ok := g.gen.messagesByName["control_ping"] + if !ok { + logrus.Fatalf("no message for %v", "control_ping") + } + + for _, rpc := range svc.RPCs { + logf(" gen RPC: %v (%s)", rpc.GoName, rpc.VPP.Request) + + g.P("func (c *", serviceImplName, ") ", rpcMethodSignature(g, rpc), " {") + if rpc.VPP.Stream { + streamImpl := fmt.Sprintf("%s_%sClient", serviceImplName, rpc.GoName) + streamApi := fmt.Sprintf("%s_%sClient", serviceApiName, rpc.GoName) + + var msgReply, msgDetails *Message + if rpc.MsgStream != nil { + msgDetails = rpc.MsgStream + msgReply = rpc.MsgReply + } else { + msgDetails = rpc.MsgReply + msgReply = msgControlPingReply + } + + g.P("stream, err := c.conn.NewStream(ctx)") + g.P("if err != nil { return nil, err }") + g.P("x := &", streamImpl, "{stream}") + g.P("if err := x.Stream.SendMsg(in); err != nil {") + g.P(" return nil, err") + g.P("}") + if rpc.MsgStream == nil { + g.P("if err = x.Stream.SendMsg(&", msgControlPing.GoIdent, "{}); err != nil {") + g.P(" return nil, err") + g.P("}") + } + g.P("return x, nil") + g.P("}") + g.P() + g.P("type ", streamApi, " interface {") + if msgReply != msgControlPingReply { + g.P(" Recv() (*", msgDetails.GoIdent, ", *", msgReply.GoIdent, ", error)") + } else { + g.P(" Recv() (*", msgDetails.GoIdent, ", error)") + } + g.P(" ", govppApiPkg.Ident("Stream")) + g.P("}") + g.P() + + g.P("type ", streamImpl, " struct {") + g.P(" ", govppApiPkg.Ident("Stream")) + g.P("}") + g.P() + + if msgReply != msgControlPingReply { + g.P("func (c *", streamImpl, ") Recv() (*", msgDetails.GoIdent, ", *", msgReply.GoIdent, ", error) {") + } else { + g.P("func (c *", streamImpl, ") Recv() (*", msgDetails.GoIdent, ", error) {") + } + g.P(" msg, err := c.Stream.RecvMsg()") + if msgReply != msgControlPingReply { + g.P(" if err != nil { return nil, nil, err }") + } else { + g.P(" if err != nil { return nil, err }") + } + g.P(" switch m := msg.(type) {") + g.P(" case *", msgDetails.GoIdent, ":") + if msgReply != msgControlPingReply { + g.P(" return m, nil, nil") + } else { + g.P(" return m, nil") + } + g.P(" case *", msgReply.GoIdent, ":") + if msgReply != msgControlPingReply { + if retvalField := getRetvalField(msgReply); retvalField != nil { + g.P("if err := ", retvalFieldToErr(g, "m", retvalField), "; err != nil {") + if msgReply != msgControlPingReply { + g.P(" return nil, m, err") + } else { + g.P(" return nil, err") + } + g.P("}") + } + } + g.P(" err = c.Stream.Close()") + if msgReply != msgControlPingReply { + g.P(" if err != nil { return nil, m, err }") + } else { + g.P(" if err != nil { return nil, err }") + } + if msgReply != msgControlPingReply { + g.P(" return nil, m, ", ioPkg.Ident("EOF")) + } else { + g.P(" return nil, ", ioPkg.Ident("EOF")) + } + g.P(" default:") + if msgReply != msgControlPingReply { + g.P(" return nil, nil, ", fmtPkg.Ident("Errorf"), "(\"unexpected message: %T %v\", m, m)") + } else { + g.P(" return nil, ", fmtPkg.Ident("Errorf"), "(\"unexpected message: %T %v\", m, m)") + } + g.P("}") + } else if rpc.MsgReply != nil { + g.P("out := new(", rpc.MsgReply.GoIdent, ")") + g.P("err := c.conn.Invoke(ctx, in, out)") + g.P("if err != nil { return nil, err }") + if retvalField := getRetvalField(rpc.MsgReply); retvalField != nil { + g.P("return out, ", retvalFieldToErr(g, "out", retvalField)) + } else { + g.P("return out, nil") + } + } else { // MsgReply == nil + g.P("stream, err := c.conn.NewStream(ctx)") + g.P("if err != nil { return err }") + g.P("err = stream.SendMsg(in)") + g.P("if err != nil { return err }") + g.P("err = stream.Close()") + g.P("if err != nil { return err }") + g.P("return nil") + } + g.P("}") + g.P() + } + + // TODO: generate service descriptor + /*fmt.Fprintf(w, "var %s = api.%s{\n", serviceDescName, serviceDescType) + fmt.Fprintf(w, "\tServiceName: \"%s\",\n", ctx.moduleName) + fmt.Fprintf(w, "\tHandlerType: (*%s)(nil),\n", serviceApiName) + fmt.Fprintf(w, "\tMethods: []api.MethodDesc{\n") + for _, method := range rpcs { + fmt.Fprintf(w, "\t {\n") + fmt.Fprintf(w, "\t MethodName: \"%s\",\n", method.Name) + fmt.Fprintf(w, "\t },\n") + } + fmt.Fprintf(w, "\t},\n") + //fmt.Fprintf(w, "\tCompatibility: %s,\n", messageCrcName) + //fmt.Fprintf(w, "\tMetadata: reflect.TypeOf((*%s)(nil)).Elem().PkgPath(),\n", serviceApiName) + fmt.Fprintf(w, "\tMetadata: \"%s\",\n", ctx.inputFile) + fmt.Fprintln(w, "}")*/ + + g.P() +} + +func retvalFieldToErr(g *GenFile, varName string, retvalField *Field) string { + if getFieldType(g, retvalField) == "int32" { + return g.GoIdent(govppApiPkg.Ident("RetvalToVPPApiError")) + "(" + varName + "." + retvalField.GoName + ")" + } else { + return g.GoIdent(govppApiPkg.Ident("RetvalToVPPApiError")) + "(int32(" + varName + "." + retvalField.GoName + "))" + } +} + +func rpcMethodSignature(g *GenFile, rpc *RPC) string { + s := rpc.GoName + "(ctx " + g.GoIdent(contextPkg.Ident("Context")) + s += ", in *" + g.GoIdent(rpc.MsgRequest.GoIdent) + ") (" + if rpc.VPP.Stream { + s += serviceApiName + "_" + rpc.GoName + "Client, " + } else if rpc.MsgReply != nil { + s += "*" + g.GoIdent(rpc.MsgReply.GoIdent) + ", " + } + s += "error)" + return s +} diff --git a/binapigen/generator.go b/binapigen/generator.go new file mode 100644 index 00000000..59c7d83c --- /dev/null +++ b/binapigen/generator.go @@ -0,0 +1,374 @@ +// 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 binapigen + +import ( + "bufio" + "bytes" + "fmt" + "go/ast" + "go/parser" + "go/printer" + "go/token" + "os" + "path" + "path/filepath" + "sort" + "strconv" + "strings" + + "github.com/sirupsen/logrus" + + "github.com/alkiranet/govpp/binapigen/vppapi" +) + +// Options is set of input parameters for the Generator. +type Options struct { + OutputDir string // output directory for generated files + ImportPrefix string // prefix for package import paths + GenerateFiles []string // list of files to generate + + NoVersionInfo bool // disables generating version info + NoSourcePathInfo bool // disables the 'source: /path' comment +} + +// Generator processes VPP API files as input, provides API to handle content +// of generated files. +type Generator struct { + opts Options + + vppapiSchema *vppapi.Schema + + Files []*File + FilesByName map[string]*File + FilesByPath map[string]*File + + genfiles []*GenFile + + enumsByName map[string]*Enum + aliasesByName map[string]*Alias + structsByName map[string]*Struct + unionsByName map[string]*Union + messagesByName map[string]*Message +} + +func New(opts Options, input *vppapi.VppInput) (*Generator, error) { + gen := &Generator{ + opts: opts, + vppapiSchema: &input.Schema, + FilesByName: make(map[string]*File), + FilesByPath: make(map[string]*File), + enumsByName: map[string]*Enum{}, + aliasesByName: map[string]*Alias{}, + structsByName: map[string]*Struct{}, + unionsByName: map[string]*Union{}, + messagesByName: map[string]*Message{}, + } + + // normalize API files + SortFilesByImports(gen.vppapiSchema.Files) + for i, apiFile := range gen.vppapiSchema.Files { + f := apiFile + RemoveImportedTypes(gen.vppapiSchema.Files, &f) + SortFileObjectsByName(&f) + gen.vppapiSchema.Files[i] = f + } + + // prepare package names and import paths + packageNames := make(map[string]GoPackageName) + importPaths := make(map[string]GoImportPath) + for _, apifile := range gen.vppapiSchema.Files { + filename := getFilename(apifile) + packageNames[filename] = cleanPackageName(apifile.Name) + importPaths[filename] = GoImportPath(path.Join(gen.opts.ImportPrefix, baseName(apifile.Name))) + } + + logrus.Debugf("adding %d VPP API files to generator", len(gen.vppapiSchema.Files)) + + for _, apifile := range gen.vppapiSchema.Files { + if _, ok := gen.FilesByName[apifile.Name]; ok { + return nil, fmt.Errorf("duplicate file: %q", apifile.Name) + } + + filename := getFilename(apifile) + file, err := newFile(gen, apifile, packageNames[filename], importPaths[filename]) + if err != nil { + return nil, fmt.Errorf("loading file %s failed: %w", apifile.Name, err) + } + gen.Files = append(gen.Files, file) + gen.FilesByName[apifile.Name] = file + gen.FilesByPath[apifile.Path] = file + + logrus.Debugf("added file %q (path: %v)", apifile.Name, apifile.Path) + } + + // mark files for generation + if len(gen.opts.GenerateFiles) > 0 { + logrus.Debugf("Checking %d files to generate: %v", len(gen.opts.GenerateFiles), gen.opts.GenerateFiles) + for _, genFile := range gen.opts.GenerateFiles { + markGen := func(file *File) { + file.Generate = true + // generate all imported files + for _, impFile := range file.importedFiles(gen) { + impFile.Generate = true + } + } + + if file, ok := gen.FilesByName[genFile]; ok { + markGen(file) + continue + } + logrus.Debugf("File %s was not found by name", genFile) + if file, ok := gen.FilesByPath[genFile]; ok { + markGen(file) + continue + } + return nil, fmt.Errorf("no API file found for: %v", genFile) + } + } else { + logrus.Debugf("Files to generate not specified, marking all %d files for generate", len(gen.Files)) + for _, file := range gen.Files { + file.Generate = true + } + } + + return gen, nil +} + +func (g *Generator) GetMessageByName(name string) *Message { + return g.messagesByName[name] +} + +func (g *Generator) GetOpts() Options { return g.opts } + +func getFilename(file vppapi.File) string { + if file.Path == "" { + return file.Name + } + return file.Path +} + +func (g *Generator) Generate() error { + if len(g.genfiles) == 0 { + return fmt.Errorf("no files to generate") + } + + logrus.Infof("Generating %d files", len(g.genfiles)) + + for _, genfile := range g.genfiles { + content, err := genfile.Content() + if err != nil { + return err + } + logrus.Debugf("- generating file: %v (%v bytes)", genfile.filename, len(content)) + if err := WriteContentToFile(genfile.filename, content); err != nil { + return fmt.Errorf("writing source package %s failed: %v", genfile.filename, err) + } + } + + return nil +} + +type GenFile struct { + gen *Generator + file *File + filename string + buf bytes.Buffer + manualImports map[GoImportPath]bool + packageNames map[GoImportPath]GoPackageName +} + +// NewGenFile creates new generated file with +func (g *Generator) NewGenFile(filename string, file *File) *GenFile { + f := &GenFile{ + gen: g, + file: file, + filename: filename, + manualImports: make(map[GoImportPath]bool), + packageNames: make(map[GoImportPath]GoPackageName), + } + g.genfiles = append(g.genfiles, f) + return f +} + +func (g *GenFile) GetFile() *File { return g.file } + +func (g *GenFile) Write(p []byte) (n int, err error) { + return g.buf.Write(p) +} + +func (g *GenFile) Import(importPath GoImportPath) { + g.manualImports[importPath] = true +} + +func (g *GenFile) GoIdent(ident GoIdent) string { + if g.file != nil && ident.GoImportPath == g.file.GoImportPath { + return ident.GoName + } + if packageName, ok := g.packageNames[ident.GoImportPath]; ok { + return string(packageName) + "." + ident.GoName + } + packageName := cleanPackageName(baseName(string(ident.GoImportPath))) + g.packageNames[ident.GoImportPath] = packageName + return string(packageName) + "." + ident.GoName +} + +func (g *GenFile) P(v ...interface{}) { + for _, x := range v { + switch x := x.(type) { + case GoIdent: + fmt.Fprint(&g.buf, g.GoIdent(x)) + default: + fmt.Fprint(&g.buf, x) + } + } + fmt.Fprintln(&g.buf) +} + +func (g *GenFile) Content() ([]byte, error) { + // for *.go files we inject imports + if strings.HasSuffix(g.filename, ".go") { + return g.injectImports(g.buf.Bytes()) + } + return g.buf.Bytes(), nil +} + +// baseName returns the last path element of the name, with the last dotted suffix removed. +func baseName(name string) string { + // First, find the last element + if i := strings.LastIndex(name, "/"); i >= 0 { + name = name[i+1:] + } + // Now drop the suffix + if i := strings.LastIndex(name, "."); i >= 0 { + name = name[:i] + } + return name +} + +func getImportClass(importPath string) int { + if !strings.Contains(importPath, ".") { + return 0 /* std */ + } + return 1 /* External */ +} + +// injectImports parses source, injects import block declaration with all imports and return formatted +func (g *GenFile) injectImports(original []byte) ([]byte, error) { + // Parse source code + fset := token.NewFileSet() + file, err := parser.ParseFile(fset, "", original, parser.ParseComments) + if err != nil { + var src bytes.Buffer + s := bufio.NewScanner(bytes.NewReader(original)) + for line := 1; s.Scan(); line++ { + fmt.Fprintf(&src, "%5d\t%s\n", line, s.Bytes()) + } + return nil, fmt.Errorf("%v: unparsable Go source: %v\n%v", g.filename, err, src.String()) + } + type Import struct { + Name string + Path string + } + // Prepare list of all imports + var importPaths []Import + for importPath := range g.packageNames { + importPaths = append(importPaths, Import{ + Name: string(g.packageNames[importPath]), + Path: string(importPath), + }) + } + for importPath := range g.manualImports { + if _, ok := g.packageNames[importPath]; ok { + continue + } + importPaths = append(importPaths, Import{ + Name: "_", + Path: string(importPath), + }) + } + // Sort imports by import path + sort.Slice(importPaths, func(i, j int) bool { + ci := getImportClass(importPaths[i].Path) + cj := getImportClass(importPaths[j].Path) + if ci == cj { + return importPaths[i].Path < importPaths[j].Path + } + return ci < cj + }) + // Inject new import block into parsed AST + if len(importPaths) > 0 { + // Find import block position + pos := file.Package + tokFile := fset.File(file.Package) + pkgLine := tokFile.Line(file.Package) + for _, c := range file.Comments { + if tokFile.Line(c.Pos()) > pkgLine { + break + } + pos = c.End() + } + // Prepare the import block + impDecl := &ast.GenDecl{Tok: token.IMPORT, TokPos: pos, Lparen: pos, Rparen: pos} + for i, importPath := range importPaths { + var name *ast.Ident + if importPath.Name == "_" || strings.Contains(importPath.Path, ".") { + name = &ast.Ident{Name: importPath.Name, NamePos: pos} + } + value := strconv.Quote(importPath.Path) + if i < len(importPaths)-1 { + if getImportClass(importPath.Path) != getImportClass(importPaths[i+1].Path) { + value += "\n" + } + } + impDecl.Specs = append(impDecl.Specs, &ast.ImportSpec{ + Name: name, + Path: &ast.BasicLit{Kind: token.STRING, Value: value, ValuePos: pos}, + EndPos: pos, + }) + } + + file.Decls = append([]ast.Decl{impDecl}, file.Decls...) + } + // Reformat source code + var out bytes.Buffer + cfg := &printer.Config{ + Mode: printer.TabIndent | printer.UseSpaces, + Tabwidth: 8, + } + if err = cfg.Fprint(&out, fset, file); err != nil { + return nil, fmt.Errorf("cannot reformat Go code in file %q: %w", g.filename, err) + } + return out.Bytes(), nil +} + +func WriteContentToFile(outputFile string, content []byte) error { + // create output directory + packageDir := filepath.Dir(outputFile) + + if err := os.MkdirAll(packageDir, 0775); err != nil { + return fmt.Errorf("creating output dir %s failed: %v", packageDir, err) + } + + // write generated code to output file + if err := os.WriteFile(outputFile, content, 0666); err != nil { + return fmt.Errorf("writing to output file %s failed: %v", outputFile, err) + } + + lines := bytes.Count(content, []byte("\n")) + logf("written %d lines (%d bytes) to: %q", lines, len(content), outputFile) + + return nil +} diff --git a/binapigen/generator_test.go b/binapigen/generator_test.go new file mode 100644 index 00000000..72f5a0ac --- /dev/null +++ b/binapigen/generator_test.go @@ -0,0 +1,136 @@ +// 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 binapigen + +import ( + "bufio" + "fmt" + "os" + "strings" + "testing" + + . "github.com/onsi/gomega" + + "github.com/alkiranet/govpp/binapigen/vppapi" +) + +func TestGenerator(t *testing.T) { + tests := []struct { + name string + file *vppapi.File + expectPackage string + }{ + {name: "vpe", file: &vppapi.File{ + Name: "vpe", + Path: "/usr/share/vpp/api/core/vpe.api.json", + CRC: "0x12345678", + }, + expectPackage: "vpe", + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + RegisterTestingT(t) + + apiFiles := []vppapi.File{*test.file} + + input := &vppapi.VppInput{Schema: vppapi.Schema{ + Files: apiFiles, + }} + + gen, err := New(Options{ + ImportPrefix: "test", + }, input) + Expect(err).ToNot(HaveOccurred(), "unexpected generator error: %v", err) + + Expect(gen.Files).To(HaveLen(1)) + Expect(gen.Files[0].PackageName).To(BeEquivalentTo(test.expectPackage)) + Expect(gen.Files[0].GoImportPath).To(BeEquivalentTo("test/" + test.expectPackage)) + }) + } +} + +func TestGoModule(t *testing.T) { + const expected = "github.com/alkiranet/govpp/binapi" + + impPath, err := ResolveImportPath("../binapi") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if impPath != expected { + t.Fatalf("expected: %q, got: %q", expected, impPath) + } +} + +func TestBinapiTypeSizes(t *testing.T) { + tests := []struct { + name string + input string + expsize int + }{ + {name: "basic1", input: "u8", expsize: 1}, + {name: "basic2", input: "i8", expsize: 1}, + {name: "basic3", input: "u16", expsize: 2}, + {name: "basic4", input: "i32", expsize: 4}, + {name: "string", input: "string", expsize: 1}, + {name: "invalid1", input: "x", expsize: 0}, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + size := getSizeOfBinapiBaseType(test.input, 1) + if size != test.expsize { + t.Errorf("expected %d, got %d", test.expsize, size) + } + }) + } +} + +func TestBinapiUnionSizes(t *testing.T) { + RegisterTestingT(t) + + // order of the union sizes in file generated from union.api.json + var sizes = []int{16, 4, 32, 16, 64, 111} + + // remove directory created during test + defer func() { + err := os.RemoveAll(testOutputDir) + Expect(err).ToNot(HaveOccurred()) + }() + + err := GenerateFromFile("vppapi/testdata/union.api.json", Options{OutputDir: testOutputDir}) + Expect(err).ShouldNot(HaveOccurred()) + + file, err := os.Open(testOutputDir + "/union/union.ba.go") + Expect(err).ShouldNot(HaveOccurred()) + defer func() { + err := file.Close() + Expect(err).ToNot(HaveOccurred()) + }() + + // the generated line with union size is in format XXX_UnionData []byte + // the prefix identifies these lines (the starting tab is important) + prefix := fmt.Sprintf("\t%s", "XXX_UnionData [") + + index := 0 + scanner := bufio.NewScanner(file) + for scanner.Scan() { + if strings.HasPrefix(scanner.Text(), prefix) { + Expect(scanner.Text()).To(Equal(prefix + fmt.Sprintf("%d]byte", sizes[index]))) + index++ + } + } + // ensure all union sizes were found and tested + Expect(index).To(Equal(len(sizes))) +} diff --git a/binapigen/log.go b/binapigen/log.go new file mode 100644 index 00000000..c918725a --- /dev/null +++ b/binapigen/log.go @@ -0,0 +1,35 @@ +// Copyright (c) 2022 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 binapigen + +import ( + "os" + "strings" + + "github.com/sirupsen/logrus" +) + +var Logger = logrus.New() + +func init() { + if debug := os.Getenv("DEBUG_GOVPP"); strings.Contains(debug, "binapigen") { + Logger.SetLevel(logrus.DebugLevel) + logrus.SetLevel(logrus.DebugLevel) + } +} + +func logf(f string, v ...interface{}) { + Logger.Debugf(f, v...) +} diff --git a/binapigen/plugin.go b/binapigen/plugin.go new file mode 100644 index 00000000..4a8f5d64 --- /dev/null +++ b/binapigen/plugin.go @@ -0,0 +1,119 @@ +// 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 binapigen + +import ( + "fmt" + "plugin" +) + +// Plugin is an extension of the Generator. Plugins can be registered in +// application with RegisterPlugin or loaded from an external file compiled +// when calling RunPlugin. +type Plugin struct { + Name string + GenerateAll GenerateAllFn + GenerateFile GenerateFileFn + External bool +} + +type GenerateAllFn = func(*Generator) []*GenFile +type GenerateFileFn = func(*Generator, *File) *GenFile + +var plugins []*Plugin +var pluginsByName = map[string]*Plugin{} + +// RegisterPlugin registers a new plugin with name and generate +// func. Name must not be empty or already taken. +func RegisterPlugin(name string, genfn GenerateFileFn) { + if name == "" { + panic("plugin name is empty") + } + if _, ok := pluginsByName[name]; ok { + panic("duplicate plugin name: " + name) + } + p := &Plugin{ + Name: name, + GenerateFile: genfn, + } + addPlugin(p) +} + +// RunPlugin executes plugin with given name, if name is not found it attempts +// to load plugin from a filesystem, using name as path to the file. The file +// must be Go binary compiled using "plugin" buildmode and must contain exported +// func with the signature of GenerateFileFn. +func RunPlugin(name string, gen *Generator, file *File) error { + p, err := getPlugin(name) + if err != nil { + return fmt.Errorf("plugin %s not found: %w", name, err) + } + + if file != nil && p.GenerateFile != nil { + p.GenerateFile(gen, file) + } else if file == nil && p.GenerateAll != nil { + p.GenerateAll(gen) + } + + return nil +} + +func addPlugin(p *Plugin) { + plugins = append(plugins, p) + pluginsByName[p.Name] = p +} + +func getPlugin(name string) (*Plugin, error) { + var err error + + // check in registered plugins + p, ok := pluginsByName[name] + if !ok { + // name might be the path to an external plugin + p, err = loadExternalPlugin(name) + if err != nil { + return nil, err + } + addPlugin(p) + } + + return p, nil +} + +func loadExternalPlugin(name string) (*Plugin, error) { + plg, err := plugin.Open(name) + if err != nil { + return nil, err + } + + p := &Plugin{ + Name: name, + External: true, + } + + symGenerateFile, err := plg.Lookup("GenerateFile") + if err != nil { + symGenerateAll, err := plg.Lookup("GenerateAll") + if err != nil { + return nil, err + } else { + p.GenerateAll = symGenerateAll.(GenerateAllFn) + } + } else { + p.GenerateFile = symGenerateFile.(GenerateFileFn) + } + + return p, nil +} diff --git a/binapigen/run.go b/binapigen/run.go new file mode 100644 index 00000000..44eb03d7 --- /dev/null +++ b/binapigen/run.go @@ -0,0 +1,152 @@ +// 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 binapigen + +import ( + "fmt" + "os" + "path" + "path/filepath" + "regexp" + + "github.com/sirupsen/logrus" + + "github.com/alkiranet/govpp/binapigen/vppapi" +) + +func Run(vppInput *vppapi.VppInput, opts Options, f func(*Generator) error) { + if err := run(vppInput, opts, f); err != nil { + fmt.Fprintf(os.Stderr, "%s: %v\n", filepath.Base(os.Args[0]), err) + os.Exit(1) + } +} + +func run(vppInput *vppapi.VppInput, opts Options, genFn func(*Generator) error) error { + var err error + + if opts.ImportPrefix == "" { + opts.ImportPrefix, err = ResolveImportPath(opts.OutputDir) + if err != nil { + return fmt.Errorf("cannot resolve import path for output dir %s: %w", opts.OutputDir, err) + } + logrus.Debugf("resolved import path prefix: %s", opts.ImportPrefix) + } + + gen, err := New(opts, vppInput) + if err != nil { + return err + } + + if genFn == nil { + genFn = GenerateDefault + } + if err := genFn(gen); err != nil { + return err + } + + if err = gen.Generate(); err != nil { + return err + } + + return nil +} + +func GeneratePlugins(genPlugins []string) func(*Generator) error { + return func(gen *Generator) error { + for _, file := range gen.Files { + if !file.Generate { + continue + } + logrus.Debugf("GENERATE FILE: %v", file.Desc.Path) + GenerateAPI(gen, file) + for _, p := range genPlugins { + logrus.Debugf(" [GEN plugin: %v]", p) + if err := RunPlugin(p, gen, file); err != nil { + return err + } + } + } + for _, p := range genPlugins { + logrus.Debugf(" [GEN ALL plugin: %v]", p) + if err := RunPlugin(p, gen, nil); err != nil { + return err + } + } + return nil + } +} + +func GenerateDefault(gen *Generator) error { + for _, file := range gen.Files { + if !file.Generate { + continue + } + GenerateAPI(gen, file) + GenerateRPC(gen, file) + } + return nil +} + +// ResolveImportPath tries to resolve import path for a directory. +func ResolveImportPath(dir string) (string, error) { + absPath, err := filepath.Abs(dir) + if err != nil { + return "", err + } + modRoot := findGoModuleRoot(absPath) + if modRoot == "" { + return "", err + } + modPath, err := readModulePath(path.Join(modRoot, "go.mod")) + if err != nil { + return "", err + } + relDir, err := filepath.Rel(modRoot, absPath) + if err != nil { + return "", err + } + return filepath.Join(modPath, relDir), nil +} + +// findGoModuleRoot looks for enclosing Go module. +func findGoModuleRoot(dir string) (root string) { + dir = filepath.Clean(dir) + for { + if fi, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil && !fi.IsDir() { + return dir + } + d := filepath.Dir(dir) + if d == dir { + break + } + dir = d + } + return "" +} + +var modulePathRE = regexp.MustCompile(`module[ \t]+([^ \t\r\n]+)`) + +// readModulePath reads module path from go.mod file. +func readModulePath(gomod string) (string, error) { + data, err := os.ReadFile(gomod) + if err != nil { + return "", err + } + m := modulePathRE.FindSubmatch(data) + if m == nil { + return "", err + } + return string(m[1]), nil +} diff --git a/cmd/binapi-generator/definitions.go b/binapigen/strings.go similarity index 69% rename from cmd/binapi-generator/definitions.go rename to binapigen/strings.go index 9bf9e539..80cedf52 100644 --- a/cmd/binapi-generator/definitions.go +++ b/binapigen/strings.go @@ -1,29 +1,37 @@ -// Copyright (c) 2018 Cisco and/or its affiliates. +// 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: +// 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 +// 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. +// 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 main +package binapigen import ( + "go/token" "strings" "unicode" + "unicode/utf8" + + "golang.org/x/text/cases" + "golang.org/x/text/language" ) // commonInitialisms is a set of common initialisms that need to stay in upper case. var commonInitialisms = map[string]bool{ "ACL": true, "API": true, - //"ASCII": true, // there are only two use cases for ASCII which already have initialism before and after + // NOTE: There are only two occurences of the word 'ascii' and + // these already have initialism before and after ASCII part, + // thus disabling initialism for this case. + "ASCII": false, "CPU": true, "CSS": true, "DNS": true, @@ -68,12 +76,11 @@ var commonInitialisms = map[string]bool{ // specialInitialisms is a set of special initialisms that need part to stay in upper case. var specialInitialisms = map[string]string{ "IPV": "IPv", - //"IPV4": "IPv4", - //"IPV6": "IPv6", } func usesInitialism(s string) string { - if u := strings.ToUpper(s); commonInitialisms[u] { + u := strings.ToUpper(s) + if commonInitialisms[u] { return u } else if su, ok := specialInitialisms[u]; ok { return su @@ -83,7 +90,9 @@ func usesInitialism(s string) string { // camelCaseName returns correct name identifier (camelCase). func camelCaseName(name string) (should string) { - name = strings.Title(name) + + name = cases.Title(language.Zulu).String(name) + // name = strings.Title(name) // Fast path for simple cases: "_" and all lowercase. if name == "_" { @@ -150,3 +159,12 @@ func camelCaseName(name string) (should string) { } return string(runes) } + +// sanitizedName returns the string converted into a valid Go identifier. +func sanitizedName(s string) string { + r, _ := utf8.DecodeRuneInString(s) + if token.Lookup(s).IsKeyword() || !unicode.IsLetter(r) { + return s + "s" + } + return s +} diff --git a/binapigen/strings_test.go b/binapigen/strings_test.go new file mode 100644 index 00000000..3578daab --- /dev/null +++ b/binapigen/strings_test.go @@ -0,0 +1,56 @@ +// 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 binapigen + +import ( + "testing" +) + +func TestInitialism(t *testing.T) { + tests := []struct { + name string + input string + expOutput string + }{ + {name: "id", input: "id", expOutput: "ID"}, + {name: "ipv6", input: "is_ipv6", expOutput: "IsIPv6"}, + {name: "ip6", input: "is_ip6", expOutput: "IsIP6"}, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + output := camelCaseName(test.input) + if output != test.expOutput { + t.Errorf("expected %q, got %q", test.expOutput, output) + } + }) + } +} + +func TestSanitize(t *testing.T) { + tests := []struct { + name string + expected string + }{ + {"interface", "interfaces"}, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + s := sanitizedName(test.name) + if s != test.expected { + t.Fatalf("expected: %q, got: %q", test.expected, s) + } + }) + } +} diff --git a/binapigen/types.go b/binapigen/types.go new file mode 100644 index 00000000..483e8209 --- /dev/null +++ b/binapigen/types.go @@ -0,0 +1,181 @@ +// 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 binapigen + +import ( + "fmt" + "strings" + + "github.com/sirupsen/logrus" +) + +// define api +const ( + defineApiPrefix = "vl_api_" + defineApiSuffix = "_t" +) + +func fromApiType(typ string) string { + name := typ + name = strings.TrimPrefix(name, defineApiPrefix) + name = strings.TrimSuffix(name, defineApiSuffix) + return name +} + +const ( + U8 = "u8" + I8 = "i8" + U16 = "u16" + I16 = "i16" + U32 = "u32" + I32 = "i32" + U64 = "u64" + I64 = "i64" + F64 = "f64" + BOOL = "bool" + STRING = "string" +) + +var BaseTypeSizes = map[string]int{ + U8: 1, + I8: 1, + U16: 2, + I16: 2, + U32: 4, + I32: 4, + U64: 8, + I64: 8, + F64: 8, + BOOL: 1, + STRING: 1, +} + +var BaseTypesGo = map[string]string{ + U8: "uint8", + I8: "int8", + U16: "uint16", + I16: "int16", + U32: "uint32", + I32: "int32", + U64: "uint64", + I64: "int64", + F64: "float64", + BOOL: "bool", + STRING: "string", +} + +func fieldActualType(field *Field) (actual string) { + switch { + case field.TypeAlias != nil: + actual = field.TypeAlias.Type + case field.TypeEnum != nil: + actual = field.TypeEnum.Type + default: + actual = field.Type + } + return +} + +func fieldGoType(g *GenFile, field *Field) string { + switch { + case field.TypeAlias != nil: + return g.GoIdent(field.TypeAlias.GoIdent) + case field.TypeEnum != nil: + return g.GoIdent(field.TypeEnum.GoIdent) + case field.TypeStruct != nil: + return g.GoIdent(field.TypeStruct.GoIdent) + case field.TypeUnion != nil: + return g.GoIdent(field.TypeUnion.GoIdent) + } + t, ok := BaseTypesGo[field.Type] + if !ok { + logrus.Panicf("type %s is not base type", field.Type) + } + return t +} + +func getFieldType(g *GenFile, field *Field) string { + gotype := fieldGoType(g, field) + if field.Array { + switch gotype { + case "uint8": + return "[]byte" + case "string": + return "string" + } + if _, ok := BaseTypesGo[field.Type]; !ok && field.Length > 0 { + return fmt.Sprintf("[%d]%s", field.Length, gotype) + } + return "[]" + gotype + } + return gotype +} + +func getUnionSize(union *Union) (maxSize int) { + for _, field := range union.Fields { + if size, isBaseType := getSizeOfField(field); isBaseType { + logrus.Panicf("union %s field %s has unexpected type %q", union.Name, field.Name, field.Type) + } else if size > maxSize { + maxSize = size + } + } + //logf("getUnionSize: %s %+v max=%v", union.Name, union.Fields, maxSize) + return +} + +func getSizeOfField(field *Field) (size int, isBaseType bool) { + if alias := field.TypeAlias; alias != nil { + size = getSizeOfBinapiBaseType(alias.Type, alias.Length) + return + } + if enum := field.TypeEnum; enum != nil { + size = getSizeOfBinapiBaseType(enum.Type, field.Length) + return + } + if structType := field.TypeStruct; structType != nil { + size = getSizeOfStruct(structType) + return + } + if union := field.TypeUnion; union != nil { + size = getUnionSize(union) + return + } + return size, true +} + +func getSizeOfStruct(typ *Struct) (size int) { + for _, field := range typ.Fields { + fieldSize, isBaseType := getSizeOfField(field) + if isBaseType { + size += getSizeOfBinapiBaseType(field.Type, field.Length) + continue + } + size += fieldSize + } + return size +} + +// Returns size of base type multiplied by length. Length equal to zero +// returns base type size. +func getSizeOfBinapiBaseType(typ string, length int) (size int) { + if n := BaseTypeSizes[typ]; n > 0 { + if length > 1 { + return n * length + } else { + return n + } + } + return +} diff --git a/binapigen/vppapi.go b/binapigen/vppapi.go new file mode 100644 index 00000000..2b3db4f2 --- /dev/null +++ b/binapigen/vppapi.go @@ -0,0 +1,310 @@ +// 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 binapigen + +import ( + "log" + "path" + "sort" + "strings" + + "github.com/alkiranet/govpp/binapigen/vppapi" +) + +// SortFileObjectsByName sorts all objects of file by their name. +func SortFileObjectsByName(file *vppapi.File) { + sort.SliceStable(file.Imports, func(i, j int) bool { + return file.Imports[i] < file.Imports[j] + }) + sort.SliceStable(file.EnumTypes, func(i, j int) bool { + return file.EnumTypes[i].Name < file.EnumTypes[j].Name + }) + sort.SliceStable(file.EnumflagTypes, func(i, j int) bool { + return file.EnumflagTypes[i].Name < file.EnumflagTypes[j].Name + }) + sort.Slice(file.AliasTypes, func(i, j int) bool { + return file.AliasTypes[i].Name < file.AliasTypes[j].Name + }) + sort.SliceStable(file.StructTypes, func(i, j int) bool { + return file.StructTypes[i].Name < file.StructTypes[j].Name + }) + sort.SliceStable(file.UnionTypes, func(i, j int) bool { + return file.UnionTypes[i].Name < file.UnionTypes[j].Name + }) + sort.SliceStable(file.Messages, func(i, j int) bool { + return file.Messages[i].Name < file.Messages[j].Name + }) + if file.Service != nil { + sort.Slice(file.Service.RPCs, func(i, j int) bool { + return file.Service.RPCs[i].Request < file.Service.RPCs[j].Request + }) + } +} + +func ListImportedFiles(files []vppapi.File, file *vppapi.File) []vppapi.File { + var list []vppapi.File + byName := func(s string) *vppapi.File { + for _, f := range files { + file := f + if f.Name == s { + return &file + } + } + return nil + } + imported := map[string]struct{}{} + for _, imp := range file.Imports { + imp = normalizeImport(imp) + impFile := byName(imp) + if impFile == nil { + log.Fatalf("imported file %q not found", imp) + } + for _, nest := range ListImportedFiles(files, impFile) { + if _, ok := imported[nest.Name]; !ok { + list = append(list, nest) + imported[nest.Name] = struct{}{} + } + } + if _, ok := imported[impFile.Name]; !ok { + list = append(list, *impFile) + imported[impFile.Name] = struct{}{} + } + } + return list +} + +// normalizeImport returns the last path element of the import, with all dotted suffixes removed. +func normalizeImport(imp string) string { + imp = path.Base(imp) + if idx := strings.Index(imp, "."); idx >= 0 { + imp = imp[:idx] + } + return imp +} + +// SortFilesByName sorts list of files by their name. +func SortFilesByName(apifiles []vppapi.File) { + sort.SliceStable(apifiles, func(i, j int) bool { + a := apifiles[i] + b := apifiles[j] + return a.Name < b.Name + }) +} + +// SortFilesByImports sorts list of files by their imports. +func SortFilesByImports(apifiles []vppapi.File) { + dependsOn := func(file *vppapi.File, dep string) bool { + for _, imp := range ListImportedFiles(apifiles, file) { + if imp.Name == dep { + return true + } + } + return false + } + sort.SliceStable(apifiles, func(i, j int) bool { + a := apifiles[i] + b := apifiles[j] + if dependsOn(&a, b.Name) { + return false + } + if dependsOn(&b, a.Name) { + return true + } + return len(b.Imports) > len(a.Imports) + }) +} + +// ListImportedTypes returns list of names for imported types. +func ListImportedTypes(apifiles []vppapi.File, file *vppapi.File) []string { + var importedTypes []string + typeFiles := ListImportedFiles(apifiles, file) + for _, t := range file.StructTypes { + var imported bool + for _, imp := range typeFiles { + for _, at := range imp.StructTypes { + if at.Name != t.Name { + continue + } + importedTypes = append(importedTypes, t.Name) + imported = true + break + } + if imported { + break + } + } + } + for _, t := range file.AliasTypes { + var imported bool + for _, imp := range typeFiles { + for _, at := range imp.AliasTypes { + if at.Name != t.Name { + continue + } + importedTypes = append(importedTypes, t.Name) + imported = true + break + } + if imported { + break + } + } + } + for _, t := range file.EnumTypes { + var imported bool + for _, imp := range typeFiles { + for _, at := range imp.EnumTypes { + if at.Name != t.Name { + continue + } + importedTypes = append(importedTypes, t.Name) + imported = true + break + } + if imported { + break + } + } + } + for _, t := range file.EnumflagTypes { + var imported bool + for _, imp := range typeFiles { + for _, at := range imp.EnumflagTypes { + if at.Name != t.Name { + continue + } + importedTypes = append(importedTypes, t.Name) + imported = true + break + } + if imported { + break + } + } + } + for _, t := range file.UnionTypes { + var imported bool + for _, imp := range typeFiles { + for _, at := range imp.UnionTypes { + if at.Name != t.Name { + continue + } + importedTypes = append(importedTypes, t.Name) + imported = true + break + } + if imported { + break + } + } + } + return importedTypes +} + +// RemoveImportedTypes removes imported types from file. +func RemoveImportedTypes(apifiles []vppapi.File, apifile *vppapi.File) { + importedTypes := ListImportedTypes(apifiles, apifile) + isImportedType := func(s string) bool { + for _, t := range importedTypes { + if t == s { + return true + } + } + return false + } + var enums []vppapi.EnumType + for _, enumType := range apifile.EnumTypes { + if !isImportedType(enumType.Name) { + enums = append(enums, enumType) + } + } + var enumflags []vppapi.EnumType + for _, enumflagType := range apifile.EnumflagTypes { + if !isImportedType(enumflagType.Name) { + enumflags = append(enumflags, enumflagType) + } + } + var aliases []vppapi.AliasType + for _, aliasType := range apifile.AliasTypes { + if !isImportedType(aliasType.Name) { + aliases = append(aliases, aliasType) + } + } + var structs []vppapi.StructType + for _, structType := range apifile.StructTypes { + if !isImportedType(structType.Name) { + structs = append(structs, structType) + } + } + var unions []vppapi.UnionType + for _, unionType := range apifile.UnionTypes { + if !isImportedType(unionType.Name) { + unions = append(unions, unionType) + } + } + apifile.EnumTypes = enums + apifile.EnumflagTypes = enumflags + apifile.AliasTypes = aliases + apifile.StructTypes = structs + apifile.UnionTypes = unions +} + +// CleanMessageComment processes a comment string from VPP API message and +// returns a modified version with the following changes: +// - trim comment syntax ("/**", "*/") +// - remove special syntax ("\brief") parts +// - replace all occurrences of "@param" with a dash ("-"). +func CleanMessageComment(comment string) string { + // trim comment syntax + comment = strings.TrimPrefix(comment, "/**") + comment = strings.TrimSuffix(comment, " */") + comment = strings.TrimSuffix(comment, "*/") + + // remove \\brief from the comment + comment = strings.Replace(comment, `\\brief`, "", -1) + comment = strings.Replace(comment, `\brief`, "", -1) + + // replace @param with a dash (-) + comment = strings.Replace(comment, "@param", "-", -1) + + return strings.TrimSpace(comment) +} + +// StripMessageCommentFields processes a comment string from VPP API message and +// returns a modified version where a set of fields are omitted. +func StripMessageCommentFields(comment string, fields ...string) string { + lines := strings.Split(comment, "\n") + result := "" + for _, line := range lines { + if strings.TrimSpace(line) == "" { + continue + } + add := true + for _, field := range fields { + if strings.Contains(line, " - "+field) { + add = false + break + } + } + if add { + result += line + "\n" + } + } + return strings.TrimSuffix(result, "\n") +} + +func normalizeCRC(crc string) string { + return strings.TrimPrefix(crc, "0x") +} diff --git a/binapigen/vppapi/api_schema.go b/binapigen/vppapi/api_schema.go new file mode 100644 index 00000000..1ca91951 --- /dev/null +++ b/binapigen/vppapi/api_schema.go @@ -0,0 +1,126 @@ +// 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 vppapi + +type ( + // Schema represents a collection of API files for a specific VPP version. + Schema struct { + // Files is a list of File objects that are part of this scheme. + Files []File + // Version is a VPP version of this schema. + Version string + } + + // File is a single API file and its contents. + File struct { + Name string // Name is the name of this API file (without any extension). + Path string // Path is the location of thi API file relative to API directory. + CRC string // CRC is a checksum for this API file. + + // Options is a map of string key-value pairs that provides additional options for this file. + Options map[string]string `json:",omitempty"` + // Imports is a list of strings representing the names of API files that are imported by this file. + Imports []string `json:",omitempty"` + + AliasTypes []AliasType `json:",omitempty"` + EnumTypes []EnumType `json:",omitempty"` + EnumflagTypes []EnumType `json:",omitempty"` + StructTypes []StructType `json:",omitempty"` + UnionTypes []UnionType `json:",omitempty"` + + // Messages is a list of Message objects representing messages used in the API. + Messages []Message `json:",omitempty"` + // Service is an object representing the RPC services used in the API. + // In case there is not any services defined for this File, the Service is nil. + Service *Service `json:",omitempty"` + + Counters []Counter `json:",omitempty"` + Paths []CounterPaths `json:",omitempty"` + } + + AliasType struct { + Name string + Type string + Length int `json:",omitempty"` + } + + EnumType struct { + Name string + Type string + Entries []EnumEntry + } + + EnumEntry struct { + Name string + Value uint32 + } + + StructType struct { + Name string + Fields []Field + } + + UnionType struct { + Name string + Fields []Field + } + + Message struct { + Name string + Fields []Field + CRC string + Options map[string]string `json:",omitempty"` + Comment string `json:",omitempty"` + } + + Field struct { + Name string + Type string + Length int `json:",omitempty"` + Array bool `json:",omitempty"` + SizeFrom string `json:",omitempty"` + Meta map[string]interface{} `json:",omitempty"` + } + + Service struct { + RPCs []RPC `json:",omitempty"` + } + + RPC struct { + Request string + Reply string + Stream bool `json:",omitempty"` + StreamMsg string `json:",omitempty"` + Events []string `json:",omitempty"` + } + + Counter struct { + Name string + Elements []Element `json:",omitempty"` + } + + Element struct { + Name string + Severity string + Type string + Units string + Description string + } + + CounterPaths struct { + Name string + Paths []string `json:",omitempty"` + } +) diff --git a/binapigen/vppapi/input.go b/binapigen/vppapi/input.go new file mode 100644 index 00000000..c81f58db --- /dev/null +++ b/binapigen/vppapi/input.go @@ -0,0 +1,235 @@ +// Copyright (c) 2023 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 vppapi + +import ( + "archive/tar" + "compress/gzip" + "fmt" + "io" + "os" + "os/exec" + "path/filepath" + "strings" + + "github.com/sirupsen/logrus" +) + +// ResolveVppInput parses an input string and returns VppInput or an error if a problem +// occurs durig parsing. The input string consists of path, which can be followed +// by '#' and one or more options separated by comma. The actual format can be +// specified explicitely by an option 'format', if that is not the case then the +// format will be detected from path automatically if possible. +// +// - `path` +// - `path#option1=val,option2=val` +// +// Available formats: +// +// * Directory: `dir` +// - absolute: `/usr/share/vpp/api` +// - relative: `path/to/apidir` +// +// * Git repository: `git` +// - local repository: `.git` +// - remote repository: `https://github.com/FDio/vpp.git` +// +// * Tarball/Zip Archive (`tar`/`zip`) +// - local archive: `api.tar.gz` +// - remote archive: `https://example.com/api.tar.gz` +// - standard input: `-` +// +// Format options: +// +// * Git repository +// - `branch`: name of branch +// - `tag`: specific git tag +// - `ref`: git reference +// - `depth`: git depth +// - `subdir`: subdirectory to use as base directory +// +// * Tarball/ZIP Archive +// - `compression`: compression to use (`gzip`) +// - `subdir`: subdirectory to use as base directory +// - 'strip': strip first N directories, applied before `subdir` +func ResolveVppInput(input string) (*VppInput, error) { + inputRef, err := ParseInputRef(input) + if err != nil { + return nil, err + } + return inputRef.Retrieve() +} + +// VppInput defines VPP API input source. +type VppInput struct { + ApiDirectory string + Schema Schema +} + +func resolveVppInputFromDir(path string) (*VppInput, error) { + vppInput := new(VppInput) + + apidir := ResolveApiDir(path) + vppInput.ApiDirectory = apidir + + logrus.Debugf("path %q resolved to api dir: %v", path, apidir) + + apiFiles, err := ParseDir(apidir) + if err != nil { + logrus.Warnf("vppapi parsedir error: %v", err) + } else { + vppInput.Schema.Files = apiFiles + logrus.Debugf("resolved %d apifiles", len(apiFiles)) + } + + vppInput.Schema.Version = ResolveVPPVersion(path) + if vppInput.Schema.Version == "" { + vppInput.Schema.Version = "unknown" + } + + return vppInput, nil +} + +const ( + cacheDir = "./.cache" +) + +func cloneRepoLocally(repo string, commit string, branch string, depth int) (string, error) { + repoPath := strings.ReplaceAll(repo, "/", "_") + repoPath = strings.ReplaceAll(repoPath, ":", "_") + cachePath := filepath.Join(cacheDir, repoPath) + + // Clone the repository or use cached one + if _, err := os.Stat(cachePath); os.IsNotExist(err) { + if err := os.MkdirAll(cacheDir, 0755); err != nil { + return "", fmt.Errorf("failed to create cache directory: %w", err) + } + + args := []string{"--single-branch"} + if depth > 0 { + args = append(args, fmt.Sprintf("--depth=%d", depth)) + } + args = append(args, repo, cachePath) + logrus.Debugf("cloning repo: %v", args) + cmd := exec.Command("git", append([]string{"clone"}, args...)...) + if output, err := cmd.CombinedOutput(); err != nil { + return "", fmt.Errorf("failed to clone repository: %w\nOutput: %s", err, output) + } + } else if err != nil { + return "", fmt.Errorf("failed to check if cache exists: %w", err) + } + logrus.Debugf("local repo dir: %q, fetching %q", cachePath, commit) + + cmd := exec.Command("git", "fetch", "-f", "origin", commit) + cmd.Dir = cachePath + if output, err := cmd.CombinedOutput(); err != nil { + return "", fmt.Errorf("failed to fetch repository: %w\nOutput: %s", err, output) + } + + // Resolve the commit hash for the given branch/tag + ref := commit + if branch != "" { + ref = "origin/" + branch + } + commitHash, err := resolveCommitHash(cachePath, ref) + if err != nil { + return "", fmt.Errorf("failed to resolve commit hash: %w", err) + } + + // Check out the repository at the resolved commit + cmd = exec.Command("git", "checkout", commitHash) + cmd.Dir = cachePath + if output, err := cmd.CombinedOutput(); err != nil { + return "", fmt.Errorf("failed to check out repository: %w\nOutput: %s", err, output) + } + + return cachePath, nil +} + +func resolveCommitHash(repoPath, ref string) (string, error) { + cmd := exec.Command("git", "rev-parse", "--verify", ref) + cmd.Dir = repoPath + + outputBytes, err := cmd.Output() + logrus.Tracef("command %q output: %s", cmd, outputBytes) + if err != nil { + return "", fmt.Errorf("failed to run command: %w", err) + } + + return strings.TrimSpace(string(outputBytes)), nil +} + +func extractTar(reader io.Reader, gzipped bool, strip int) (string, error) { + tempDir, err := os.MkdirTemp("", "govpp-vppapi-archive-") + if err != nil { + return "", err + } + + if gzipped { + gzReader, err := gzip.NewReader(reader) + if err != nil { + return "", err + } + defer gzReader.Close() + + reader = gzReader + } + + tarReader := tar.NewReader(reader) + for { + header, err := tarReader.Next() + if err == io.EOF { + break + } + if err != nil { + return "", err + } + + nameList := strings.Split(header.Name, "/") + if len(nameList) < strip { + return "", fmt.Errorf("cannot strip first %d directories for file: %s", strip, header.Name) + } + fileName := filepath.Join(nameList[strip:]...) + filePath := filepath.Join(tempDir, fileName) + fileInfo := header.FileInfo() + + logrus.Tracef(" - extracting tar file: %s into: %s", header.Name, filePath) + + if fileInfo.IsDir() { + err = os.MkdirAll(filePath, fileInfo.Mode()) + if err != nil { + return "", err + } + continue + } else { + err = os.MkdirAll(filepath.Dir(filePath), 0750) + if err != nil { + return "", err + } + } + file, err := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, fileInfo.Mode()) + if err != nil { + return "", fmt.Errorf("open file error: %w", err) + } + _, err = io.Copy(file, tarReader) + if err != nil { + return "", fmt.Errorf("copy data error: %w", err) + } + if err := file.Close(); err != nil { + return "", fmt.Errorf("close file error: %w", err) + } + } + return tempDir, nil +} diff --git a/binapigen/vppapi/input_test.go b/binapigen/vppapi/input_test.go new file mode 100644 index 00000000..904b8444 --- /dev/null +++ b/binapigen/vppapi/input_test.go @@ -0,0 +1,54 @@ +// Copyright (c) 2023 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 vppapi + +import ( + "testing" +) + +func Test_runCommandInRepo(t *testing.T) { + type args struct { + repo string + commit string + command string + args []string + } + tests := []struct { + name string + args args + wantErr bool + }{ + { + name: "branch", + args: args{ + repo: "https://github.com/FDio/vpp.git", + commit: "master", + command: "bash", + args: []string{"-exc", "bash ./src/scripts/version; make json-api-files && ls ./build-root/install-vpp-native/vpp/share/vpp/api"}, + }, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + //, tt.args.command, tt.args.args... + _, err := cloneRepoLocally(tt.args.repo, tt.args.commit, "", 0) + if (err != nil) != tt.wantErr { + t.Errorf("cloneRepoLocally() error = %v, wantErr %v", err, tt.wantErr) + } + //t.Logf("OUTPUT:") + }) + } +} diff --git a/binapigen/vppapi/integration_test.go b/binapigen/vppapi/integration_test.go new file mode 100644 index 00000000..85990cad --- /dev/null +++ b/binapigen/vppapi/integration_test.go @@ -0,0 +1,42 @@ +// 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. + +//go:build integration +// +build integration + +package vppapi_test + +import ( + "encoding/json" + "testing" + + "github.com/alkiranet/govpp/binapigen/vppapi" +) + +func TestParse(t *testing.T) { + files, err := vppapi.Parse() + if err != nil { + t.Fatal(err) + } + + for _, file := range files { + b, err := json.MarshalIndent(file, "\t", " ") + if err != nil { + t.Fatal(err) + } + t.Logf(" - %s:\n%s", file.Name, b) + } + + t.Logf("parsed %d files", len(files)) +} diff --git a/binapigen/vppapi/log.go b/binapigen/vppapi/log.go new file mode 100644 index 00000000..54d5f0b5 --- /dev/null +++ b/binapigen/vppapi/log.go @@ -0,0 +1,29 @@ +// Copyright (c) 2023 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 vppapi + +import ( + "log" + "os" + "strings" +) + +var debug = strings.Contains(os.Getenv("DEBUG_GOVPP"), "parser") + +func logf(f string, v ...interface{}) { + if debug { + log.Printf(f, v...) + } +} diff --git a/binapigen/vppapi/parse_json.go b/binapigen/vppapi/parse_json.go new file mode 100644 index 00000000..d99bfe35 --- /dev/null +++ b/binapigen/vppapi/parse_json.go @@ -0,0 +1,636 @@ +// 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 vppapi + +import ( + "encoding/json" + "errors" + "fmt" + + "github.com/bennyscetbun/jsongo" +) + +const ( + // root keys + fileVersionCrc = "vl_api_version" + fileOptions = "options" + fileTypes = "types" + fileMessages = "messages" + fileUnions = "unions" + fileEnums = "enums" + fileEnumflags = "enumflags" + fileAliases = "aliases" + fileServices = "services" + fileImports = "imports" + fileCounters = "counters" + filePaths = "paths" + + // message keys + messageCrc = "crc" + messageOptions = "options" + messageComment = "comment" + + // type keys + enumType = "enumtype" + aliasLength = "length" + aliasType = "type" + + // counters + counter = "counter" + counterName = "name" + counterPath = "path" + elements = "elements" + elementName = "name" + elementSeverity = "severity" + elementType = "type" + elementUnits = "units" + elementDesc = "description" + + // service + serviceReply = "reply" + serviceStream = "stream" + serviceStreamMsg = "stream_msg" + serviceEvents = "events" +) + +const ( + OptFileVersion = "version" +) + +func parseApiJsonFile(data []byte) (file *File, err error) { + // parse root json node + rootNode := new(jsongo.Node) + if err := json.Unmarshal(data, rootNode); err != nil { + return nil, fmt.Errorf("unmarshalling JSON failed: %w", err) + } + + // print contents + logf("file contents:") + for _, rootKey := range rootNode.GetKeys() { + length := rootNode.At(rootKey).Len() + if length > 0 { + logf(" - %2d %s", length, rootKey) + } + } + + file = new(File) + + // parse file CRC + crc := rootNode.At(fileVersionCrc) + if crc.GetType() == jsongo.TypeValue { + file.CRC = crc.MustGetString() + } + + // parse file options + opt := rootNode.Map(fileOptions) + if opt.GetType() == jsongo.TypeMap { + file.Options = make(map[string]string) + for _, key := range opt.GetKeys() { + optionKey := key.(string) + optionVal := opt.At(key).MustGetString() + file.Options[optionKey] = optionVal + } + } + + // parse imports + importsNode := rootNode.Map(fileImports) + file.Imports = make([]string, 0, importsNode.Len()) + uniq := make(map[string]struct{}) + for i := 0; i < importsNode.Len(); i++ { + importNode := importsNode.At(i) + imp := importNode.MustGetString() + if _, ok := uniq[imp]; ok { + logf("duplicate import found: %v", imp) + continue + } + uniq[imp] = struct{}{} + file.Imports = append(file.Imports, imp) + } + + // avoid duplicate objects + known := make(map[string]struct{}) + exists := func(name string) bool { + if _, ok := known[name]; ok { + logf("duplicate object found: %v", name) + return true + } + known[name] = struct{}{} + return false + } + + // parse enum types + enumsNode := rootNode.Map(fileEnums) + file.EnumTypes = make([]EnumType, 0) + for i := 0; i < enumsNode.Len(); i++ { + enum, err := parseEnum(enumsNode.At(i)) + if err != nil { + return nil, err + } + if exists(enum.Name) { + continue + } + file.EnumTypes = append(file.EnumTypes, *enum) + } + + // parse enumflags types + enumflagsNode := rootNode.Map(fileEnumflags) + file.EnumflagTypes = make([]EnumType, 0) + for i := 0; i < enumflagsNode.Len(); i++ { + enumflag, err := parseEnum(enumflagsNode.At(i)) + if err != nil { + return nil, err + } + if exists(enumflag.Name) { + continue + } + file.EnumflagTypes = append(file.EnumflagTypes, *enumflag) + } + + // parse alias types + aliasesNode := rootNode.Map(fileAliases) + if aliasesNode.GetType() == jsongo.TypeMap { + file.AliasTypes = make([]AliasType, 0) + for _, key := range aliasesNode.GetKeys() { + aliasName := key.(string) + alias, err := parseAlias(aliasName, aliasesNode.At(key)) + if err != nil { + return nil, err + } + if exists(alias.Name) { + continue + } + file.AliasTypes = append(file.AliasTypes, *alias) + } + } + + // parse struct types + typesNode := rootNode.Map(fileTypes) + file.StructTypes = make([]StructType, 0) + for i := 0; i < typesNode.Len(); i++ { + structyp, err := parseStruct(typesNode.At(i)) + if err != nil { + return nil, err + } + if exists(structyp.Name) { + continue + } + file.StructTypes = append(file.StructTypes, *structyp) + } + + // parse union types + unionsNode := rootNode.Map(fileUnions) + file.UnionTypes = make([]UnionType, 0) + for i := 0; i < unionsNode.Len(); i++ { + union, err := parseUnion(unionsNode.At(i)) + if err != nil { + return nil, err + } + if exists(union.Name) { + continue + } + file.UnionTypes = append(file.UnionTypes, *union) + } + + // parse messages + messagesNode := rootNode.Map(fileMessages) + if messagesNode.GetType() == jsongo.TypeArray { + file.Messages = make([]Message, messagesNode.Len()) + for i := 0; i < messagesNode.Len(); i++ { + msg, err := parseMessage(messagesNode.At(i)) + if err != nil { + return nil, err + } + file.Messages[i] = *msg + } + } + + // parse services + servicesNode := rootNode.Map(fileServices) + if servicesNode.GetType() == jsongo.TypeMap { + file.Service = &Service{ + RPCs: make([]RPC, servicesNode.Len()), + } + for i, key := range servicesNode.GetKeys() { + rpcName := key.(string) + svc, err := parseServiceRPC(rpcName, servicesNode.At(key)) + if err != nil { + return nil, err + } + file.Service.RPCs[i] = *svc + } + } + + // parse counters + countersNode := rootNode.Map(fileCounters) + if countersNode.GetType() == jsongo.TypeArray { + file.Counters = make([]Counter, countersNode.Len()) + for i := 0; i < countersNode.Len(); i++ { + c, err := parseCounter(countersNode.At(i)) + if err != nil { + return nil, err + } + file.Counters[i] = *c + } + } + + // parse paths + pathsNode := rootNode.Map(filePaths) + if pathsNode.GetType() == jsongo.TypeArray { + file.Paths = make([]CounterPaths, 0) + for i := 0; i < pathsNode.Len(); i++ { + counterPaths, err := parsePath(pathsNode.At(i)) + if err != nil { + return nil, err + } + file.Paths = append(file.Paths, *counterPaths...) + } + } + + return file, nil +} + +// parseEnum parses VPP binary API enum object from JSON node +func parseEnum(enumNode *jsongo.Node) (*EnumType, error) { + if enumNode.Len() == 0 || enumNode.At(0).GetType() != jsongo.TypeValue { + return nil, errors.New("invalid JSON for enum specified") + } + + enumName, ok := enumNode.At(0).Get().(string) + if !ok { + return nil, fmt.Errorf("enum name is %T, not a string", enumNode.At(0).Get()) + } + enumType, ok := enumNode.At(enumNode.Len() - 1).At(enumType).Get().(string) + if !ok { + return nil, fmt.Errorf("enum type invalid or missing") + } + + enum := EnumType{ + Name: enumName, + Type: enumType, + } + + // loop through enum entries, skip first (name) and last (enumtype) + for j := 1; j < enumNode.Len()-1; j++ { + if enumNode.At(j).GetType() == jsongo.TypeArray { + entry := enumNode.At(j) + + if entry.Len() < 2 || entry.At(0).GetType() != jsongo.TypeValue || entry.At(1).GetType() != jsongo.TypeValue { + return nil, errors.New("invalid JSON for enum entry specified") + } + + entryName, ok := entry.At(0).Get().(string) + if !ok { + return nil, fmt.Errorf("enum entry name is %T, not a string", entry.At(0).Get()) + } + entryVal := entry.At(1).Get().(float64) + + enum.Entries = append(enum.Entries, EnumEntry{ + Name: entryName, + Value: uint32(entryVal), + }) + } + } + + return &enum, nil +} + +// parseUnion parses VPP binary API union object from JSON node +func parseUnion(unionNode *jsongo.Node) (*UnionType, error) { + if unionNode.Len() == 0 || unionNode.At(0).GetType() != jsongo.TypeValue { + return nil, errors.New("invalid JSON for union specified") + } + + unionName, ok := unionNode.At(0).Get().(string) + if !ok { + return nil, fmt.Errorf("union name is %T, not a string", unionNode.At(0).Get()) + } + + union := UnionType{ + Name: unionName, + } + + // loop through union fields, skip first (name) + for j := 1; j < unionNode.Len(); j++ { + if unionNode.At(j).GetType() == jsongo.TypeArray { + fieldNode := unionNode.At(j) + + field, err := parseField(fieldNode) + if err != nil { + return nil, err + } + + union.Fields = append(union.Fields, *field) + } + } + + return &union, nil +} + +// parseStruct parses VPP binary API type object from JSON node +func parseStruct(typeNode *jsongo.Node) (*StructType, error) { + if typeNode.Len() == 0 || typeNode.At(0).GetType() != jsongo.TypeValue { + return nil, errors.New("invalid JSON for type specified") + } + + typeName, ok := typeNode.At(0).Get().(string) + if !ok { + return nil, fmt.Errorf("type name is %T, not a string", typeNode.At(0).Get()) + } + + typ := StructType{ + Name: typeName, + } + + // loop through type fields, skip first (name) + for j := 1; j < typeNode.Len(); j++ { + if typeNode.At(j).GetType() == jsongo.TypeArray { + fieldNode := typeNode.At(j) + + field, err := parseField(fieldNode) + if err != nil { + return nil, err + } + + typ.Fields = append(typ.Fields, *field) + } + } + + return &typ, nil +} + +// parseAlias parses VPP binary API alias object from JSON node +func parseAlias(aliasName string, aliasNode *jsongo.Node) (*AliasType, error) { + if aliasNode.Len() == 0 || aliasNode.At(aliasType).GetType() != jsongo.TypeValue { + return nil, errors.New("invalid JSON for alias specified") + } + + alias := AliasType{ + Name: aliasName, + } + + if typeNode := aliasNode.At(aliasType); typeNode.GetType() == jsongo.TypeValue { + typ, ok := typeNode.Get().(string) + if !ok { + return nil, fmt.Errorf("alias type is %T, not a string", typeNode.Get()) + } + if typ != "null" { + alias.Type = typ + } + } + + if lengthNode := aliasNode.At(aliasLength); lengthNode.GetType() == jsongo.TypeValue { + length, ok := lengthNode.Get().(float64) + if !ok { + return nil, fmt.Errorf("alias length is %T, not a float64", lengthNode.Get()) + } + alias.Length = int(length) + } + + return &alias, nil +} + +// parseMessage parses VPP binary API message object from JSON node +func parseMessage(msgNode *jsongo.Node) (*Message, error) { + if msgNode.Len() < 2 || msgNode.At(0).GetType() != jsongo.TypeValue { + return nil, errors.New("invalid JSON for message specified") + } + + msgName, ok := msgNode.At(0).Get().(string) + if !ok { + return nil, fmt.Errorf("message name is %T, not a string", msgNode.At(0).Get()) + } + + msgMeta := msgNode.At(msgNode.Len() - 1) + + // parse message CRC + msgCRC, ok := msgMeta.At(messageCrc).Get().(string) + if !ok { + return nil, fmt.Errorf("message crc invalid or missing") + } + + // parse message options + var msgOpts map[string]string + msgOptsNode := msgMeta.Map(messageOptions) + if msgOptsNode.GetType() == jsongo.TypeMap { + msgOpts = make(map[string]string) + for _, opt := range msgOptsNode.GetKeys() { + if _, ok := opt.(string); !ok { + logf("invalid message option key, expected string") + continue + } + msgOpts[opt.(string)] = "" + if msgOptsNode.At(opt).Get() != nil { + if optMsgStr, ok := msgOptsNode.At(opt).Get().(string); ok { + msgOpts[opt.(string)] = optMsgStr + } else { + logf("invalid message option value, expected string") + } + } + } + } + + // parse message comment + var msgComment string + msgCommentNode := msgMeta.At(messageComment) + if msgCommentNode.GetType() == jsongo.TypeValue { + comment, ok := msgCommentNode.Get().(string) + if !ok { + logf("message comment value invalid, expected string") + } else { + msgComment = comment + } + } + + msg := Message{ + Name: msgName, + CRC: msgCRC, + Options: msgOpts, + Comment: msgComment, + } + + // loop through message fields, skip first (name) and last (crc) + for j := 1; j < msgNode.Len()-1; j++ { + if msgNode.At(j).GetType() == jsongo.TypeArray { + fieldNode := msgNode.At(j) + + field, err := parseField(fieldNode) + if err != nil { + return nil, err + } + + msg.Fields = append(msg.Fields, *field) + } + } + + return &msg, nil +} + +// parseField parses VPP binary API object field from JSON node +func parseField(field *jsongo.Node) (*Field, error) { + if field.Len() < 2 || field.At(0).GetType() != jsongo.TypeValue || field.At(1).GetType() != jsongo.TypeValue { + return nil, errors.New("invalid JSON for field specified") + } + + fieldType, ok := field.At(0).Get().(string) + if !ok { + return nil, fmt.Errorf("field type is %T, not a string", field.At(0).Get()) + } + fieldName, ok := field.At(1).Get().(string) + if !ok { + return nil, fmt.Errorf("field name is %T, not a string", field.At(1).Get()) + } + + f := &Field{ + Name: fieldName, + Type: fieldType, + } + + // field length (array) or field meta + if field.Len() >= 3 { + switch field.At(2).GetType() { + case jsongo.TypeValue: + fieldLength, ok := field.At(2).Get().(float64) + if !ok { + return nil, fmt.Errorf("field length is %T, not float64", field.At(2).Get()) + } + f.Length = int(fieldLength) + f.Array = true + + case jsongo.TypeMap: + fieldMeta := field.At(2) + if fieldMeta.Len() == 0 { + break + } + f.Meta = map[string]interface{}{} + for _, key := range fieldMeta.GetKeys() { + metaName := key.(string) + metaValue := fieldMeta.At(key).Get() + f.Meta[metaName] = metaValue + } + + default: + return nil, errors.New("invalid JSON for field specified") + } + } + // field size from + if field.Len() >= 4 { + fieldLengthFrom, ok := field.At(3).Get().(string) + if !ok { + return nil, fmt.Errorf("field length from is %T, not a string", field.At(3).Get()) + } + f.SizeFrom = fieldLengthFrom + } + + return f, nil +} + +// parseServiceRPC parses VPP binary API service object from JSON node +func parseServiceRPC(rpcName string, rpcNode *jsongo.Node) (*RPC, error) { + if rpcNode.Len() == 0 || rpcNode.At(serviceReply).GetType() != jsongo.TypeValue { + return nil, errors.New("invalid JSON for service RPC specified") + } + + rpc := RPC{ + Request: rpcName, + } + + if replyNode := rpcNode.At(serviceReply); replyNode.GetType() == jsongo.TypeValue { + reply, ok := replyNode.Get().(string) + if !ok { + return nil, fmt.Errorf("service RPC reply is %T, not a string", replyNode.Get()) + } + rpc.Reply = reply + } + + // is stream (dump) + if streamNode := rpcNode.At(serviceStream); streamNode.GetType() == jsongo.TypeValue { + var ok bool + rpc.Stream, ok = streamNode.Get().(bool) + if !ok { + return nil, fmt.Errorf("service RPC stream is %T, not a boolean", streamNode.Get()) + } + } + + // stream message + if streamMsgNode := rpcNode.At(serviceStreamMsg); streamMsgNode.GetType() == jsongo.TypeValue { + var ok bool + rpc.StreamMsg, ok = streamMsgNode.Get().(string) + if !ok { + return nil, fmt.Errorf("service RPC stream msg is %T, not a string", streamMsgNode.Get()) + } + } + + // events service (event subscription) + if eventsNode := rpcNode.At(serviceEvents); eventsNode.GetType() == jsongo.TypeArray { + for j := 0; j < eventsNode.Len(); j++ { + event := eventsNode.At(j).Get().(string) + rpc.Events = append(rpc.Events, event) + } + } + + return &rpc, nil +} + +// parseCounter parses VPP binary API service object from JSON node +func parseCounter(counterNode *jsongo.Node) (*Counter, error) { + // counter name + c := &Counter{} + if counterNameNode := counterNode.At(counterName); counterNameNode.GetType() == jsongo.TypeValue { + var ok bool + if c.Name, ok = counterNameNode.Get().(string); !ok { + return nil, fmt.Errorf("counter name is %T, not a string", counterNameNode.Get()) + } + } + + // counter elements + if elementsNode := counterNode.At(elements); elementsNode.GetType() == jsongo.TypeArray { + c.Elements = make([]Element, elementsNode.Len()) + for i := 0; i < elementsNode.Len(); i++ { + if elementNode := elementsNode.At(i); elementNode.GetType() == jsongo.TypeMap { + c.Elements[i] = Element{ + Name: elementNode.At(elementName).Get().(string), + Severity: elementNode.At(elementSeverity).Get().(string), + Type: elementNode.At(elementType).Get().(string), + Units: elementNode.At(elementUnits).Get().(string), + Description: elementNode.At(elementDesc).Get().(string), + } + } + } + } + + return c, nil +} + +// parseCounter parses VPP binary API service object from JSON node +func parsePath(pathsNode *jsongo.Node) (*[]CounterPaths, error) { + paths := make([]CounterPaths, 0) +NodeLoop: + for i := 0; i < pathsNode.Len(); i++ { + if pathValues := pathsNode.At(i); pathValues.GetType() == jsongo.TypeMap { + for j, path := range paths { + if path.Name == pathsNode.At(i).At(counter).Get().(string) { + paths[j].Paths = append(path.Paths, pathsNode.At(i).At(counterPath).Get().(string)) + continue NodeLoop + } + } + path := CounterPaths{ + Name: pathsNode.At(i).At(counter).Get().(string), + Paths: []string{pathsNode.At(i).At(counterPath).Get().(string)}, + } + paths = append(paths, path) + } + } + return &paths, nil +} diff --git a/binapigen/vppapi/source.go b/binapigen/vppapi/source.go new file mode 100644 index 00000000..15c7661f --- /dev/null +++ b/binapigen/vppapi/source.go @@ -0,0 +1,294 @@ +// Copyright (c) 2023 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 vppapi + +import ( + "fmt" + "io" + "os" + "path/filepath" + "strconv" + "strings" + + "github.com/sirupsen/logrus" +) + +type InputFormat string + +const ( + FormatNone InputFormat = "" + FormatDir InputFormat = "dir" + FormatGit InputFormat = "git" + FormatTar InputFormat = "tar" + FormatZip InputFormat = "zip" +) + +const ( + OptionFormat = "format" + + OptionGitBranch = "branch" + OptionGitTag = "tag" + OptionGitRef = "ref" + OptionGitDepth = "depth" + OptionGitSubdir = "subdir" + + OptionArchiveCompression = "compression" + OptionArchiveSubdir = "subdir" + OptionArchiveStrip = "strip" +) + +const ( + defaultGitRef = "master" +) + +// InputRef is used to specify reference to VPP API input. +type InputRef struct { + Path string + Format InputFormat + Options map[string]string +} + +func (input *InputRef) Retrieve() (*VppInput, error) { + if input.Path == "" { + return nil, fmt.Errorf("invalid path in input reference") + } + + logrus.Tracef("retrieving input: %+v", input) + + switch input.Format { + case FormatNone: + return nil, fmt.Errorf("undefined format") + + case FormatDir: + info, err := os.Stat(input.Path) + if err != nil { + return nil, fmt.Errorf("path error: %v", err) + } + if !info.IsDir() { + return nil, fmt.Errorf("path must be a directory") + } + + return resolveVppInputFromDir(input.Path) + + case FormatGit: + branch := input.Options[OptionGitBranch] + tag := input.Options[OptionGitTag] + ref := input.Options[OptionGitRef] + if branch != "" && tag != "" { + return nil, fmt.Errorf("cannot set both branch and tag") + } else if branch != "" || tag != "" { + if ref != "" { + return nil, fmt.Errorf("cannot set rev if branch or tag is set") + } + if branch != "" { + ref = branch + } else if tag != "" { + ref = tag + } + } + + commit := ref + if commit == "" { + commit = defaultGitRef + } + + cloneDepth := 0 + if depth := input.Options[OptionGitDepth]; depth != "" { + d, err := strconv.Atoi(depth) + if err != nil { + return nil, fmt.Errorf("invalid depth: %w", err) + } + cloneDepth = d + } + + logrus.Debugf("updating local repo %s to %s", input.Path, commit) + + repoDir, err := cloneRepoLocally(input.Path, commit, branch, cloneDepth) + if err != nil { + return nil, err + } + dir := repoDir + + subdir, hasSubdir := input.Options[OptionGitSubdir] + if hasSubdir { + dir = filepath.Join(repoDir, subdir) + if info, err := os.Stat(dir); err != nil { + if os.IsNotExist(err) { + return nil, fmt.Errorf("subdirectory %q does not exists", subdir) + } + return nil, fmt.Errorf("subdirectory %q err: %w", subdir, err) + } else if !info.IsDir() { + return nil, fmt.Errorf("subdirectory must be a directory") + } + } + + return resolveVppInputFromDir(dir) + + case FormatTar: + stripN := 0 + strip, hasStrip := input.Options[OptionArchiveStrip] + if hasStrip { + parsedStrip, err := strconv.Atoi(strip) + if err != nil { + return nil, fmt.Errorf("invalid strip value: %s", strip) + } + if parsedStrip < 0 { + return nil, fmt.Errorf("strip must be a non-negative integer") + } + stripN = parsedStrip + } + + gzipped := false + compression, hasCompression := input.Options[OptionArchiveCompression] + if hasCompression { + if compression == "gzip" { + gzipped = true + } else { + return nil, fmt.Errorf("unknown compression: %s", compression) + } + } else { + if strings.HasSuffix(input.Path, ".gz") || strings.HasSuffix(input.Path, ".tgz") { + gzipped = true + } + } + + reader, err := getInputPathReader(input.Path) + if err != nil { + return nil, fmt.Errorf("input path: %w", err) + } + + logrus.Tracef("extracting tarball %s (gzip: %v)", input.Path, gzipped) + + tempDir, err := extractTar(reader, gzipped, stripN) + if err != nil { + return nil, fmt.Errorf("failed to extract tarball: %w", err) + } + + dir := tempDir + + subdir, hasSubdir := input.Options[OptionArchiveSubdir] + if hasSubdir { + dir = filepath.Join(tempDir, subdir) + if info, err := os.Stat(dir); err != nil { + if os.IsNotExist(err) { + return nil, fmt.Errorf("subdirectory %q does not exists", subdir) + } + return nil, fmt.Errorf("subdirectory %q err: %w", subdir, err) + } else if !info.IsDir() { + return nil, fmt.Errorf("subdirectory must be a directory") + } + } + + return resolveVppInputFromDir(dir) + + case FormatZip: + return resolveVppInputFromZip(input.Path) + + default: + return nil, fmt.Errorf("unknown format: %q", input.Format) + } +} + +func resolveVppInputFromZip(path string) (*VppInput, error) { + return nil, fmt.Errorf("zip format is not yet supported") +} + +func getInputPathReader(path string) (io.ReadCloser, error) { + var reader io.ReadCloser + if path == "-" { + reader = os.Stdin + } else { + file, err := os.Open(path) + if err != nil { + return nil, err + } + reader = file + } + return reader, nil +} + +func ParseInputRef(input string) (*InputRef, error) { + logrus.Tracef("parsing input string: %q", input) + + path, options := parsePathAndOptions(input) + + var inputFormat InputFormat + format, ok := options[OptionFormat] + if ok { + inputFormat = InputFormat(format) + delete(options, OptionFormat) + } else { + inputFormat = detectFormatFromPath(path) + logrus.Tracef("detected format: %v", inputFormat) + } + + // Use current working dir by default + if inputFormat == FormatDir && path == "" { + path = "." + } + + ref := &InputRef{ + Format: inputFormat, + Path: path, + Options: options, + } + logrus.Tracef("parsed InputRef: %+v", ref) + + return ref, nil + +} + +func parsePathAndOptions(input string) (path string, options map[string]string) { + // Split into path and options + parts := strings.Split(input, "#") + path = parts[0] + options = make(map[string]string) + if len(parts) > 1 { + // Split into key-value pairs + optionsList := strings.Split(parts[1], ",") + for _, option := range optionsList { + // Split each option into key and value + keyValue := strings.SplitN(option, "=", 2) + key := keyValue[0] + value := "" + if len(keyValue) > 1 { + value = keyValue[1] + } + options[key] = value + } + } + return path, options +} + +func detectFormatFromPath(path string) InputFormat { + // By suffix + if strings.HasSuffix(path, ".tar") || strings.HasSuffix(path, ".tar.gz") || strings.HasSuffix(path, ".tgz") { + return FormatTar + } + if strings.HasSuffix(path, ".zip") { + return FormatZip + } + if strings.HasSuffix(path, ".git") { + return FormatGit + } + + // By prefix + if strings.HasPrefix(path, "http://") || strings.HasPrefix(path, "https://") || strings.HasPrefix(path, "ssh://") || strings.HasPrefix(path, "git://") { + return FormatGit + } + + // By default + return FormatDir +} diff --git a/binapigen/vppapi/source_test.go b/binapigen/vppapi/source_test.go new file mode 100644 index 00000000..93059591 --- /dev/null +++ b/binapigen/vppapi/source_test.go @@ -0,0 +1,126 @@ +// Copyright (c) 2023 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 vppapi + +import ( + "reflect" + "testing" +) + +func TestParseInput(t *testing.T) { + type args struct { + input string + } + tests := []struct { + name string + args args + want *InputRef + wantErr bool + pre, post func() + }{ + { + name: "local dir", + args: args{"/usr/share/vpp/api"}, + want: &InputRef{ + Format: FormatDir, + Path: "/usr/share/vpp/api", + }, + }, + { + name: "git repo", + args: args{".git#branch=master"}, + want: &InputRef{ + Format: FormatGit, + Path: ".git", + Options: map[string]string{ + "branch": "master", + }, + }, + }, + { + name: "archive", + args: args{"input.tar.gz"}, + want: &InputRef{ + Format: FormatTar, + Path: "input.tar.gz", + }, + }, + { + name: "remote archive", + args: args{"https://example.com/input.tar.gz"}, + want: &InputRef{ + Format: FormatTar, + Path: "https://example.com/input.tar.gz", + }, + }, + { + name: "remote repo", + args: args{"https://github.com/FDio/vpp.git"}, + want: &InputRef{ + Format: FormatGit, + Path: "https://github.com/FDio/vpp.git", + }, + }, + { + name: "no .git", + args: args{"https://github.com/FDio/vpp#format=git"}, + want: &InputRef{ + Format: FormatGit, + Path: "https://github.com/FDio/vpp", + }, + }, + { + name: "git@xxx", + args: args{"git@github.com:FDio/vpp#format=git"}, + want: &InputRef{ + Format: FormatGit, + Path: "git@github.com:FDio/vpp", + }, + }, + { + name: "git tag", + args: args{"https://github.com/FDio/vpp.git#tag=v23.02"}, + want: &InputRef{ + Format: FormatGit, + Path: "https://github.com/FDio/vpp.git", + Options: map[string]string{ + OptionGitTag: "v23.02", + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if tt.pre != nil { + tt.pre() + } + if tt.post != nil { + t.Cleanup(tt.post) + } + if tt.want.Options == nil { + tt.want.Options = map[string]string{} + } + + got, err := ParseInputRef(tt.args.input) + if (err != nil) != tt.wantErr { + t.Errorf("ResolveVppInput() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("ResolveVppInput() got = %+v, want %+v", got, tt.want) + } + }) + } +} diff --git a/cmd/binapi-generator/testdata/acl.api.json b/binapigen/vppapi/testdata/acl.api.json similarity index 100% rename from cmd/binapi-generator/testdata/acl.api.json rename to binapigen/vppapi/testdata/acl.api.json diff --git a/cmd/binapi-generator/testdata/af_packet.api.json b/binapigen/vppapi/testdata/af_packet.api.json similarity index 88% rename from cmd/binapi-generator/testdata/af_packet.api.json rename to binapigen/vppapi/testdata/af_packet.api.json index 81ee2f9b..dc0de169 100644 --- a/cmd/binapi-generator/testdata/af_packet.api.json +++ b/binapigen/vppapi/testdata/af_packet.api.json @@ -1,21 +1,15 @@ { - "services": [ - { - "af_packet_delete": { - "reply": "af_packet_delete_reply" - } + "services": { + "af_packet_delete": { + "reply": "af_packet_delete_reply" }, - { - "af_packet_create": { - "reply": "af_packet_create_reply" - } + "af_packet_create": { + "reply": "af_packet_create_reply" }, - { - "af_packet_set_l4_cksum_offload": { - "reply": "af_packet_set_l4_cksum_offload_reply" - } + "af_packet_set_l4_cksum_offload": { + "reply": "af_packet_set_l4_cksum_offload_reply" } - ], + }, "vl_api_version": "0x8957ca8b", "enums": [], "messages": [ diff --git a/cmd/binapi-generator/testdata/input-generate-error.json b/binapigen/vppapi/testdata/input-generate-error.json similarity index 100% rename from cmd/binapi-generator/testdata/input-generate-error.json rename to binapigen/vppapi/testdata/input-generate-error.json diff --git a/cmd/binapi-generator/testdata/input-read-json-error.json b/binapigen/vppapi/testdata/input-read-json-error.json similarity index 100% rename from cmd/binapi-generator/testdata/input-read-json-error.json rename to binapigen/vppapi/testdata/input-read-json-error.json diff --git a/cmd/binapi-generator/testdata/input.txt b/binapigen/vppapi/testdata/input.txt similarity index 100% rename from cmd/binapi-generator/testdata/input.txt rename to binapigen/vppapi/testdata/input.txt diff --git a/binapigen/vppapi/testdata/ip.api.json b/binapigen/vppapi/testdata/ip.api.json new file mode 100644 index 00000000..32be9968 --- /dev/null +++ b/binapigen/vppapi/testdata/ip.api.json @@ -0,0 +1,3578 @@ +{ + "types": [ + [ + "address", + [ + "vl_api_address_family_t", + "af" + ], + [ + "vl_api_address_union_t", + "un" + ] + ], + [ + "prefix", + [ + "vl_api_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "ip4_address_and_mask", + [ + "vl_api_ip4_address_t", + "addr" + ], + [ + "vl_api_ip4_address_t", + "mask" + ] + ], + [ + "ip6_address_and_mask", + [ + "vl_api_ip6_address_t", + "addr" + ], + [ + "vl_api_ip6_address_t", + "mask" + ] + ], + [ + "mprefix", + [ + "vl_api_address_family_t", + "af" + ], + [ + "u16", + "grp_address_length" + ], + [ + "vl_api_address_union_t", + "grp_address" + ], + [ + "vl_api_address_union_t", + "src_address" + ] + ], + [ + "ip6_prefix", + [ + "vl_api_ip6_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "ip4_prefix", + [ + "vl_api_ip4_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "prefix_matcher", + [ + "u8", + "le" + ], + [ + "u8", + "ge" + ] + ], + [ + "fib_mpls_label", + [ + "u8", + "is_uniform" + ], + [ + "u32", + "label" + ], + [ + "u8", + "ttl" + ], + [ + "u8", + "exp" + ] + ], + [ + "fib_path_nh", + [ + "vl_api_address_union_t", + "address" + ], + [ + "u32", + "via_label" + ], + [ + "u32", + "obj_id" + ], + [ + "u32", + "classify_table_index" + ] + ], + [ + "fib_path", + [ + "u32", + "sw_if_index" + ], + [ + "u32", + "table_id" + ], + [ + "u32", + "rpf_id" + ], + [ + "u8", + "weight" + ], + [ + "u8", + "preference" + ], + [ + "vl_api_fib_path_type_t", + "type" + ], + [ + "vl_api_fib_path_flags_t", + "flags" + ], + [ + "vl_api_fib_path_nh_proto_t", + "proto" + ], + [ + "vl_api_fib_path_nh_t", + "nh" + ], + [ + "u8", + "n_labels" + ], + [ + "vl_api_fib_mpls_label_t", + "label_stack", + 16 + ] + ], + [ + "address", + [ + "vl_api_address_family_t", + "af" + ], + [ + "vl_api_address_union_t", + "un" + ] + ], + [ + "prefix", + [ + "vl_api_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "ip4_address_and_mask", + [ + "vl_api_ip4_address_t", + "addr" + ], + [ + "vl_api_ip4_address_t", + "mask" + ] + ], + [ + "ip6_address_and_mask", + [ + "vl_api_ip6_address_t", + "addr" + ], + [ + "vl_api_ip6_address_t", + "mask" + ] + ], + [ + "mprefix", + [ + "vl_api_address_family_t", + "af" + ], + [ + "u16", + "grp_address_length" + ], + [ + "vl_api_address_union_t", + "grp_address" + ], + [ + "vl_api_address_union_t", + "src_address" + ] + ], + [ + "ip6_prefix", + [ + "vl_api_ip6_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "ip4_prefix", + [ + "vl_api_ip4_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "prefix_matcher", + [ + "u8", + "le" + ], + [ + "u8", + "ge" + ] + ], + [ + "fib_mpls_label", + [ + "u8", + "is_uniform" + ], + [ + "u32", + "label" + ], + [ + "u8", + "ttl" + ], + [ + "u8", + "exp" + ] + ], + [ + "fib_path_nh", + [ + "vl_api_address_union_t", + "address" + ], + [ + "u32", + "via_label" + ], + [ + "u32", + "obj_id" + ], + [ + "u32", + "classify_table_index" + ] + ], + [ + "fib_path", + [ + "u32", + "sw_if_index" + ], + [ + "u32", + "table_id" + ], + [ + "u32", + "rpf_id" + ], + [ + "u8", + "weight" + ], + [ + "u8", + "preference" + ], + [ + "vl_api_fib_path_type_t", + "type" + ], + [ + "vl_api_fib_path_flags_t", + "flags" + ], + [ + "vl_api_fib_path_nh_proto_t", + "proto" + ], + [ + "vl_api_fib_path_nh_t", + "nh" + ], + [ + "u8", + "n_labels" + ], + [ + "vl_api_fib_mpls_label_t", + "label_stack", + 16 + ] + ], + [ + "address", + [ + "vl_api_address_family_t", + "af" + ], + [ + "vl_api_address_union_t", + "un" + ] + ], + [ + "prefix", + [ + "vl_api_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "ip4_address_and_mask", + [ + "vl_api_ip4_address_t", + "addr" + ], + [ + "vl_api_ip4_address_t", + "mask" + ] + ], + [ + "ip6_address_and_mask", + [ + "vl_api_ip6_address_t", + "addr" + ], + [ + "vl_api_ip6_address_t", + "mask" + ] + ], + [ + "mprefix", + [ + "vl_api_address_family_t", + "af" + ], + [ + "u16", + "grp_address_length" + ], + [ + "vl_api_address_union_t", + "grp_address" + ], + [ + "vl_api_address_union_t", + "src_address" + ] + ], + [ + "ip6_prefix", + [ + "vl_api_ip6_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "ip4_prefix", + [ + "vl_api_ip4_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "prefix_matcher", + [ + "u8", + "le" + ], + [ + "u8", + "ge" + ] + ], + [ + "mfib_path", + [ + "vl_api_mfib_itf_flags_t", + "itf_flags" + ], + [ + "vl_api_fib_path_t", + "path" + ] + ], + [ + "ip_table", + [ + "u32", + "table_id" + ], + [ + "bool", + "is_ip6" + ], + [ + "string", + "name", + 64 + ] + ], + [ + "ip_route", + [ + "u32", + "table_id" + ], + [ + "u32", + "stats_index" + ], + [ + "vl_api_prefix_t", + "prefix" + ], + [ + "u8", + "n_paths" + ], + [ + "vl_api_fib_path_t", + "paths", + 0, + "n_paths" + ] + ], + [ + "ip_mroute", + [ + "u32", + "table_id" + ], + [ + "vl_api_mfib_entry_flags_t", + "entry_flags" + ], + [ + "u32", + "rpf_id" + ], + [ + "vl_api_mprefix_t", + "prefix" + ], + [ + "u8", + "n_paths" + ], + [ + "vl_api_mfib_path_t", + "paths", + 0, + "n_paths" + ] + ], + [ + "punt_redirect", + [ + "vl_api_interface_index_t", + "rx_sw_if_index" + ], + [ + "vl_api_interface_index_t", + "tx_sw_if_index" + ], + [ + "vl_api_address_t", + "nh" + ] + ] + ], + "messages": [ + [ + "ip_table_add_del", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0x0ffdaec0" + } + ], + [ + "ip_table_add_del_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_table_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + { + "crc": "0x51077d14" + } + ], + [ + "ip_table_replace_begin", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xb9d2e09e" + } + ], + [ + "ip_table_replace_begin_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_table_replace_end", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xb9d2e09e" + } + ], + [ + "ip_table_replace_end_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_table_flush", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xb9d2e09e" + } + ], + [ + "ip_table_flush_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_table_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xc79fca0f" + } + ], + [ + "ip_route_add_del", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + [ + "bool", + "is_multipath" + ], + [ + "vl_api_ip_route_t", + "route" + ], + { + "crc": "0xc1ff832d" + } + ], + [ + "ip_route_add_del_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "u32", + "stats_index" + ], + { + "crc": "0x1992deab" + } + ], + [ + "ip_route_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xb9d2e09e" + } + ], + [ + "ip_route_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_route_t", + "route" + ], + { + "crc": "0xd1ffaae1" + } + ], + [ + "ip_route_lookup", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "u32", + "table_id" + ], + [ + "u8", + "exact" + ], + [ + "vl_api_prefix_t", + "prefix" + ], + { + "crc": "0xe2986185" + } + ], + [ + "ip_route_lookup_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "vl_api_ip_route_t", + "route" + ], + { + "crc": "0xae99de8e" + } + ], + [ + "set_ip_flow_hash", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "u32", + "vrf_id" + ], + [ + "bool", + "is_ipv6" + ], + [ + "bool", + "src" + ], + [ + "bool", + "dst" + ], + [ + "bool", + "sport" + ], + [ + "bool", + "dport" + ], + [ + "bool", + "proto" + ], + [ + "bool", + "reverse" + ], + [ + "bool", + "symmetric" + ], + { + "crc": "0x084ee09e" + } + ], + [ + "set_ip_flow_hash_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "set_ip_flow_hash_v2", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "u32", + "table_id" + ], + [ + "vl_api_address_family_t", + "af" + ], + [ + "vl_api_ip_flow_hash_config_t", + "flow_hash_config" + ], + { + "crc": "0x6d132100" + } + ], + [ + "set_ip_flow_hash_v2_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "set_ip_flow_hash_router_id", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "u32", + "router_id" + ], + { + "crc": "0x03e4f48e" + } + ], + [ + "set_ip_flow_hash_router_id_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "sw_interface_ip6_enable_disable", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "bool", + "enable" + ], + { + "crc": "0xae6cfcfb" + } + ], + [ + "sw_interface_ip6_enable_disable_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_mtable_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + { + "crc": "0x51077d14" + } + ], + [ + "ip_mtable_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xb9d2e09e" + } + ], + [ + "ip_mroute_add_del", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + [ + "bool", + "is_multipath" + ], + [ + "vl_api_ip_mroute_t", + "route" + ], + { + "crc": "0x0dd7e790" + } + ], + [ + "ip_mroute_add_del_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "u32", + "stats_index" + ], + { + "crc": "0x1992deab" + } + ], + [ + "ip_mroute_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xb9d2e09e" + } + ], + [ + "ip_mroute_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_mroute_t", + "route" + ], + { + "crc": "0xc5cb23fc" + } + ], + [ + "ip_address_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "vl_api_address_with_prefix_t", + "prefix" + ], + { + "crc": "0xb1199745" + } + ], + [ + "ip_address_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "bool", + "is_ipv6" + ], + { + "crc": "0x2d033de4" + } + ], + [ + "ip_unnumbered_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "vl_api_interface_index_t", + "ip_sw_if_index" + ], + { + "crc": "0xaa12a483" + } + ], + [ + "ip_unnumbered_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index", + { + "default": 4294967295 + } + ], + { + "crc": "0xf9e6675e" + } + ], + [ + "ip_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "bool", + "is_ipv6" + ], + { + "crc": "0xeb152d07" + } + ], + [ + "ip_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "bool", + "is_ipv6" + ], + { + "crc": "0x98d231ca" + } + ], + [ + "mfib_signal_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + { + "crc": "0x51077d14" + } + ], + [ + "mfib_signal_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "u32", + "table_id" + ], + [ + "vl_api_mprefix_t", + "prefix" + ], + [ + "u16", + "ip_packet_len" + ], + [ + "u8", + "ip_packet_data", + 256 + ], + { + "crc": "0x64398a9a" + } + ], + [ + "ip_punt_police", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "u32", + "policer_index" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + [ + "bool", + "is_ip6" + ], + { + "crc": "0xdb867cea" + } + ], + [ + "ip_punt_police_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_punt_redirect", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_punt_redirect_t", + "punt" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + { + "crc": "0xa9a5592c" + } + ], + [ + "ip_punt_redirect_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_punt_redirect_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "bool", + "is_ipv6" + ], + { + "crc": "0x2d033de4" + } + ], + [ + "ip_punt_redirect_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_punt_redirect_t", + "punt" + ], + { + "crc": "0x3924f5d3" + } + ], + [ + "ip_container_proxy_add_del", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_prefix_t", + "pfx" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + { + "crc": "0x91189f40" + } + ], + [ + "ip_container_proxy_add_del_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_container_proxy_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + { + "crc": "0x51077d14" + } + ], + [ + "ip_container_proxy_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "vl_api_prefix_t", + "prefix" + ], + { + "crc": "0x0ee460e8" + } + ], + [ + "ip_source_and_port_range_check_add_del", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + [ + "vl_api_prefix_t", + "prefix" + ], + [ + "u8", + "number_of_ranges" + ], + [ + "u16", + "low_ports", + 32 + ], + [ + "u16", + "high_ports", + 32 + ], + [ + "u32", + "vrf_id" + ], + { + "crc": "0x8bfc76f2" + } + ], + [ + "ip_source_and_port_range_check_add_del_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_source_and_port_range_check_interface_add_del", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "u32", + "tcp_in_vrf_id" + ], + [ + "u32", + "tcp_out_vrf_id" + ], + [ + "u32", + "udp_in_vrf_id" + ], + [ + "u32", + "udp_out_vrf_id" + ], + { + "crc": "0xe1ba8987" + } + ], + [ + "ip_source_and_port_range_check_interface_add_del_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "sw_interface_ip6_set_link_local_address", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "vl_api_ip6_address_t", + "ip" + ], + { + "crc": "0x2931d9fa" + } + ], + [ + "sw_interface_ip6_set_link_local_address_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "sw_interface_ip6_get_link_local_address", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + { + "crc": "0xf9e6675e" + } + ], + [ + "sw_interface_ip6_get_link_local_address_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "vl_api_ip6_address_t", + "ip" + ], + { + "crc": "0xd16b7130" + } + ], + [ + "ioam_enable", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "u16", + "id" + ], + [ + "bool", + "seqno" + ], + [ + "bool", + "analyse" + ], + [ + "bool", + "pot_enable" + ], + [ + "bool", + "trace_enable" + ], + [ + "u32", + "node_id" + ], + { + "crc": "0x51ccd868" + } + ], + [ + "ioam_enable_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ioam_disable", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "u16", + "id" + ], + { + "crc": "0x6b16a45e" + } + ], + [ + "ioam_disable_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_reassembly_set", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "u32", + "timeout_ms" + ], + [ + "u32", + "max_reassemblies" + ], + [ + "u32", + "max_reassembly_length" + ], + [ + "u32", + "expire_walk_interval_ms" + ], + [ + "bool", + "is_ip6" + ], + [ + "vl_api_ip_reass_type_t", + "type" + ], + { + "crc": "0x16467d25" + } + ], + [ + "ip_reassembly_set_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_reassembly_get", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "bool", + "is_ip6" + ], + [ + "vl_api_ip_reass_type_t", + "type" + ], + { + "crc": "0xea13ff63" + } + ], + [ + "ip_reassembly_get_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "u32", + "timeout_ms" + ], + [ + "u32", + "max_reassemblies" + ], + [ + "u32", + "max_reassembly_length" + ], + [ + "u32", + "expire_walk_interval_ms" + ], + [ + "bool", + "is_ip6" + ], + { + "crc": "0xd5eb8d34" + } + ], + [ + "ip_reassembly_enable_disable", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "bool", + "enable_ip4" + ], + [ + "bool", + "enable_ip6" + ], + [ + "vl_api_ip_reass_type_t", + "type" + ], + { + "crc": "0x885c85a6" + } + ], + [ + "ip_reassembly_enable_disable_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ] + ], + "unions": [ + [ + "address_union", + [ + "vl_api_ip4_address_t", + "ip4" + ], + [ + "vl_api_ip6_address_t", + "ip6" + ] + ], + [ + "address_union", + [ + "vl_api_ip4_address_t", + "ip4" + ], + [ + "vl_api_ip6_address_t", + "ip6" + ] + ], + [ + "address_union", + [ + "vl_api_ip4_address_t", + "ip4" + ], + [ + "vl_api_ip6_address_t", + "ip6" + ] + ] + ], + "enums": [ + [ + "if_status_flags", + [ + "IF_STATUS_API_FLAG_ADMIN_UP", + 1 + ], + [ + "IF_STATUS_API_FLAG_LINK_UP", + 2 + ], + { + "enumtype": "u32" + } + ], + [ + "mtu_proto", + [ + "MTU_PROTO_API_L3", + 0 + ], + [ + "MTU_PROTO_API_IP4", + 1 + ], + [ + "MTU_PROTO_API_IP6", + 2 + ], + [ + "MTU_PROTO_API_MPLS", + 3 + ], + { + "enumtype": "u32" + } + ], + [ + "link_duplex", + [ + "LINK_DUPLEX_API_UNKNOWN", + 0 + ], + [ + "LINK_DUPLEX_API_HALF", + 1 + ], + [ + "LINK_DUPLEX_API_FULL", + 2 + ], + { + "enumtype": "u32" + } + ], + [ + "sub_if_flags", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "rx_mode", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "if_type", + [ + "IF_API_TYPE_HARDWARE", + 0 + ], + [ + "IF_API_TYPE_SUB", + 1 + ], + [ + "IF_API_TYPE_P2P", + 2 + ], + [ + "IF_API_TYPE_PIPE", + 3 + ], + { + "enumtype": "u32" + } + ], + [ + "address_family", + [ + "ADDRESS_IP4", + 0 + ], + [ + "ADDRESS_IP6", + 1 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_feature_location", + [ + "IP_API_FEATURE_INPUT", + 0 + ], + [ + "IP_API_FEATURE_OUTPUT", + 1 + ], + [ + "IP_API_FEATURE_LOCAL", + 2 + ], + [ + "IP_API_FEATURE_PUNT", + 3 + ], + [ + "IP_API_FEATURE_DROP", + 4 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_ecn", + [ + "IP_API_ECN_NONE", + 0 + ], + [ + "IP_API_ECN_ECT0", + 1 + ], + [ + "IP_API_ECN_ECT1", + 2 + ], + [ + "IP_API_ECN_CE", + 3 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_dscp", + [ + "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 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_proto", + [ + "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_ESP", + 50 + ], + [ + "IP_API_PROTO_AH", + 51 + ], + [ + "IP_API_PROTO_ICMP6", + 58 + ], + [ + "IP_API_PROTO_EIGRP", + 88 + ], + [ + "IP_API_PROTO_OSPF", + 89 + ], + [ + "IP_API_PROTO_SCTP", + 132 + ], + [ + "IP_API_PROTO_RESERVED", + 255 + ], + { + "enumtype": "u8" + } + ], + [ + "fib_path_nh_proto", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "fib_path_flags", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "fib_path_type", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "address_family", + [ + "ADDRESS_IP4", + 0 + ], + [ + "ADDRESS_IP6", + 1 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_feature_location", + [ + "IP_API_FEATURE_INPUT", + 0 + ], + [ + "IP_API_FEATURE_OUTPUT", + 1 + ], + [ + "IP_API_FEATURE_LOCAL", + 2 + ], + [ + "IP_API_FEATURE_PUNT", + 3 + ], + [ + "IP_API_FEATURE_DROP", + 4 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_ecn", + [ + "IP_API_ECN_NONE", + 0 + ], + [ + "IP_API_ECN_ECT0", + 1 + ], + [ + "IP_API_ECN_ECT1", + 2 + ], + [ + "IP_API_ECN_CE", + 3 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_dscp", + [ + "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 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_proto", + [ + "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_ESP", + 50 + ], + [ + "IP_API_PROTO_AH", + 51 + ], + [ + "IP_API_PROTO_ICMP6", + 58 + ], + [ + "IP_API_PROTO_EIGRP", + 88 + ], + [ + "IP_API_PROTO_OSPF", + 89 + ], + [ + "IP_API_PROTO_SCTP", + 132 + ], + [ + "IP_API_PROTO_RESERVED", + 255 + ], + { + "enumtype": "u8" + } + ], + [ + "fib_path_nh_proto", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "fib_path_flags", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "fib_path_type", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "address_family", + [ + "ADDRESS_IP4", + 0 + ], + [ + "ADDRESS_IP6", + 1 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_feature_location", + [ + "IP_API_FEATURE_INPUT", + 0 + ], + [ + "IP_API_FEATURE_OUTPUT", + 1 + ], + [ + "IP_API_FEATURE_LOCAL", + 2 + ], + [ + "IP_API_FEATURE_PUNT", + 3 + ], + [ + "IP_API_FEATURE_DROP", + 4 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_ecn", + [ + "IP_API_ECN_NONE", + 0 + ], + [ + "IP_API_ECN_ECT0", + 1 + ], + [ + "IP_API_ECN_ECT1", + 2 + ], + [ + "IP_API_ECN_CE", + 3 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_dscp", + [ + "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 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_proto", + [ + "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_ESP", + 50 + ], + [ + "IP_API_PROTO_AH", + 51 + ], + [ + "IP_API_PROTO_ICMP6", + 58 + ], + [ + "IP_API_PROTO_EIGRP", + 88 + ], + [ + "IP_API_PROTO_OSPF", + 89 + ], + [ + "IP_API_PROTO_SCTP", + 132 + ], + [ + "IP_API_PROTO_RESERVED", + 255 + ], + { + "enumtype": "u8" + } + ], + [ + "mfib_entry_flags", + [ + "MFIB_API_ENTRY_FLAG_NONE", + 0 + ], + [ + "MFIB_API_ENTRY_FLAG_SIGNAL", + 1 + ], + [ + "MFIB_API_ENTRY_FLAG_DROP", + 2 + ], + [ + "MFIB_API_ENTRY_FLAG_CONNECTED", + 4 + ], + [ + "MFIB_API_ENTRY_FLAG_ACCEPT_ALL_ITF", + 8 + ], + { + "enumtype": "u32" + } + ], + [ + "mfib_itf_flags", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "if_status_flags", + [ + "IF_STATUS_API_FLAG_ADMIN_UP", + 1 + ], + [ + "IF_STATUS_API_FLAG_LINK_UP", + 2 + ], + { + "enumtype": "u32" + } + ], + [ + "mtu_proto", + [ + "MTU_PROTO_API_L3", + 0 + ], + [ + "MTU_PROTO_API_IP4", + 1 + ], + [ + "MTU_PROTO_API_IP6", + 2 + ], + [ + "MTU_PROTO_API_MPLS", + 3 + ], + { + "enumtype": "u32" + } + ], + [ + "link_duplex", + [ + "LINK_DUPLEX_API_UNKNOWN", + 0 + ], + [ + "LINK_DUPLEX_API_HALF", + 1 + ], + [ + "LINK_DUPLEX_API_FULL", + 2 + ], + { + "enumtype": "u32" + } + ], + [ + "sub_if_flags", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "rx_mode", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "if_type", + [ + "IF_API_TYPE_HARDWARE", + 0 + ], + [ + "IF_API_TYPE_SUB", + 1 + ], + [ + "IF_API_TYPE_P2P", + 2 + ], + [ + "IF_API_TYPE_PIPE", + 3 + ], + { + "enumtype": "u32" + } + ], + [ + "ip_reass_type", + [ + "IP_REASS_TYPE_FULL", + 0 + ], + [ + "IP_REASS_TYPE_SHALLOW_VIRTUAL", + 1 + ], + { + "enumtype": "u32" + } + ] + ], + "enumflags": [ + [ + "ip_flow_hash_config", + [ + "IP_API_FLOW_HASH_SRC_IP", + 1 + ], + [ + "IP_API_FLOW_HASH_DST_IP", + 2 + ], + [ + "IP_API_FLOW_HASH_SRC_PORT", + 4 + ], + [ + "IP_API_FLOW_HASH_DST_PORT", + 8 + ], + [ + "IP_API_FLOW_HASH_PROTO", + 16 + ], + [ + "IP_API_FLOW_HASH_REVERSE", + 32 + ], + [ + "IP_API_FLOW_HASH_SYMETRIC", + 64 + ], + [ + "IP_API_FLOW_HASH_FLOW_LABEL", + 128 + ], + { + "enumtype": "u32" + } + ] + ], + "services": { + "ip_table_add_del": { + "reply": "ip_table_add_del_reply" + }, + "ip_table_dump": { + "reply": "ip_table_details", + "stream": true + }, + "ip_table_replace_begin": { + "reply": "ip_table_replace_begin_reply" + }, + "ip_table_replace_end": { + "reply": "ip_table_replace_end_reply" + }, + "ip_table_flush": { + "reply": "ip_table_flush_reply" + }, + "ip_route_add_del": { + "reply": "ip_route_add_del_reply" + }, + "ip_route_dump": { + "reply": "ip_route_details", + "stream": true + }, + "ip_route_lookup": { + "reply": "ip_route_lookup_reply" + }, + "set_ip_flow_hash": { + "reply": "set_ip_flow_hash_reply" + }, + "set_ip_flow_hash_v2": { + "reply": "set_ip_flow_hash_v2_reply" + }, + "set_ip_flow_hash_router_id": { + "reply": "set_ip_flow_hash_router_id_reply" + }, + "sw_interface_ip6_enable_disable": { + "reply": "sw_interface_ip6_enable_disable_reply" + }, + "ip_mtable_dump": { + "reply": "ip_mtable_details", + "stream": true + }, + "ip_mroute_add_del": { + "reply": "ip_mroute_add_del_reply" + }, + "ip_mroute_dump": { + "reply": "ip_mroute_details", + "stream": true + }, + "ip_address_dump": { + "reply": "ip_address_details", + "stream": true + }, + "ip_unnumbered_dump": { + "reply": "ip_unnumbered_details", + "stream": true + }, + "ip_dump": { + "reply": "ip_details", + "stream": true + }, + "mfib_signal_dump": { + "reply": "mfib_signal_details", + "stream": true + }, + "ip_punt_police": { + "reply": "ip_punt_police_reply" + }, + "ip_punt_redirect": { + "reply": "ip_punt_redirect_reply" + }, + "ip_punt_redirect_dump": { + "reply": "ip_punt_redirect_details", + "stream": true + }, + "ip_container_proxy_add_del": { + "reply": "ip_container_proxy_add_del_reply" + }, + "ip_container_proxy_dump": { + "reply": "ip_container_proxy_details", + "stream": true + }, + "ip_source_and_port_range_check_add_del": { + "reply": "ip_source_and_port_range_check_add_del_reply" + }, + "ip_source_and_port_range_check_interface_add_del": { + "reply": "ip_source_and_port_range_check_interface_add_del_reply" + }, + "sw_interface_ip6_set_link_local_address": { + "reply": "sw_interface_ip6_set_link_local_address_reply" + }, + "sw_interface_ip6_get_link_local_address": { + "reply": "sw_interface_ip6_get_link_local_address_reply" + }, + "ioam_enable": { + "reply": "ioam_enable_reply" + }, + "ioam_disable": { + "reply": "ioam_disable_reply" + }, + "ip_reassembly_set": { + "reply": "ip_reassembly_set_reply" + }, + "ip_reassembly_get": { + "reply": "ip_reassembly_get_reply" + }, + "ip_reassembly_enable_disable": { + "reply": "ip_reassembly_enable_disable_reply" + } + }, + "options": { + "version": "3.0.3" + }, + "aliases": { + "interface_index": { + "type": "u32" + }, + "ip4_address": { + "type": "u8", + "length": 4 + }, + "ip6_address": { + "type": "u8", + "length": 16 + }, + "address_with_prefix": { + "type": "vl_api_prefix_t" + }, + "ip4_address_with_prefix": { + "type": "vl_api_ip4_prefix_t" + }, + "ip6_address_with_prefix": { + "type": "vl_api_ip6_prefix_t" + }, + "mac_address": { + "type": "u8", + "length": 6 + } + }, + "vl_api_version": "0xf2f5f4e" +} diff --git a/binapigen/vppapi/testdata/test-all.api.json b/binapigen/vppapi/testdata/test-all.api.json new file mode 100644 index 00000000..4e858b8e --- /dev/null +++ b/binapigen/vppapi/testdata/test-all.api.json @@ -0,0 +1,3240 @@ +[ + { + "types": [ + [ + "address", + [ + "vl_api_address_family_t", + "af" + ], + [ + "vl_api_address_union_t", + "un" + ] + ], + [ + "prefix", + [ + "vl_api_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "mprefix", + [ + "vl_api_address_family_t", + "af" + ], + [ + "u16", + "grp_address_length" + ], + [ + "vl_api_address_union_t", + "grp_address" + ], + [ + "vl_api_address_union_t", + "src_address" + ] + ], + [ + "ip6_prefix", + [ + "vl_api_ip6_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "ip4_prefix", + [ + "vl_api_ip4_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "prefix_matcher", + [ + "u8", + "le" + ], + [ + "u8", + "ge" + ] + ], + [ + "fib_mpls_label", + [ + "u8", + "is_uniform" + ], + [ + "u32", + "label" + ], + [ + "u8", + "ttl" + ], + [ + "u8", + "exp" + ] + ], + [ + "fib_path_nh", + [ + "vl_api_address_union_t", + "address" + ], + [ + "u32", + "via_label" + ], + [ + "u32", + "obj_id" + ], + [ + "u32", + "classify_table_index" + ] + ], + [ + "fib_path", + [ + "u32", + "sw_if_index" + ], + [ + "u32", + "table_id" + ], + [ + "u32", + "rpf_id" + ], + [ + "u8", + "weight" + ], + [ + "u8", + "preference" + ], + [ + "vl_api_fib_path_type_t", + "type" + ], + [ + "vl_api_fib_path_flags_t", + "flags" + ], + [ + "vl_api_fib_path_nh_proto_t", + "proto" + ], + [ + "vl_api_fib_path_nh_t", + "nh" + ], + [ + "u8", + "n_labels" + ], + [ + "vl_api_fib_mpls_label_t", + "label_stack", + 16 + ] + ], + [ + "address", + [ + "vl_api_address_family_t", + "af" + ], + [ + "vl_api_address_union_t", + "un" + ] + ], + [ + "prefix", + [ + "vl_api_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "mprefix", + [ + "vl_api_address_family_t", + "af" + ], + [ + "u16", + "grp_address_length" + ], + [ + "vl_api_address_union_t", + "grp_address" + ], + [ + "vl_api_address_union_t", + "src_address" + ] + ], + [ + "ip6_prefix", + [ + "vl_api_ip6_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "ip4_prefix", + [ + "vl_api_ip4_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "prefix_matcher", + [ + "u8", + "le" + ], + [ + "u8", + "ge" + ] + ], + [ + "fib_mpls_label", + [ + "u8", + "is_uniform" + ], + [ + "u32", + "label" + ], + [ + "u8", + "ttl" + ], + [ + "u8", + "exp" + ] + ], + [ + "fib_path_nh", + [ + "vl_api_address_union_t", + "address" + ], + [ + "u32", + "via_label" + ], + [ + "u32", + "obj_id" + ], + [ + "u32", + "classify_table_index" + ] + ], + [ + "fib_path", + [ + "u32", + "sw_if_index" + ], + [ + "u32", + "table_id" + ], + [ + "u32", + "rpf_id" + ], + [ + "u8", + "weight" + ], + [ + "u8", + "preference" + ], + [ + "vl_api_fib_path_type_t", + "type" + ], + [ + "vl_api_fib_path_flags_t", + "flags" + ], + [ + "vl_api_fib_path_nh_proto_t", + "proto" + ], + [ + "vl_api_fib_path_nh_t", + "nh" + ], + [ + "u8", + "n_labels" + ], + [ + "vl_api_fib_mpls_label_t", + "label_stack", + 16 + ] + ], + [ + "address", + [ + "vl_api_address_family_t", + "af" + ], + [ + "vl_api_address_union_t", + "un" + ] + ], + [ + "prefix", + [ + "vl_api_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "mprefix", + [ + "vl_api_address_family_t", + "af" + ], + [ + "u16", + "grp_address_length" + ], + [ + "vl_api_address_union_t", + "grp_address" + ], + [ + "vl_api_address_union_t", + "src_address" + ] + ], + [ + "ip6_prefix", + [ + "vl_api_ip6_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "ip4_prefix", + [ + "vl_api_ip4_address_t", + "address" + ], + [ + "u8", + "len" + ] + ], + [ + "prefix_matcher", + [ + "u8", + "le" + ], + [ + "u8", + "ge" + ] + ], + [ + "mfib_path", + [ + "vl_api_mfib_itf_flags_t", + "itf_flags" + ], + [ + "vl_api_fib_path_t", + "path" + ] + ], + [ + "ip_table", + [ + "u32", + "table_id" + ], + [ + "bool", + "is_ip6" + ], + [ + "string", + "name", + 64 + ] + ], + [ + "ip_route", + [ + "u32", + "table_id" + ], + [ + "u32", + "stats_index" + ], + [ + "vl_api_prefix_t", + "prefix" + ], + [ + "u8", + "n_paths" + ], + [ + "vl_api_fib_path_t", + "paths", + 0, + "n_paths" + ] + ], + [ + "ip_mroute", + [ + "u32", + "table_id" + ], + [ + "u32", + "entry_flags" + ], + [ + "u32", + "rpf_id" + ], + [ + "vl_api_mprefix_t", + "prefix" + ], + [ + "u8", + "n_paths" + ], + [ + "vl_api_mfib_path_t", + "paths", + 0, + "n_paths" + ] + ], + [ + "punt_redirect", + [ + "vl_api_interface_index_t", + "rx_sw_if_index" + ], + [ + "vl_api_interface_index_t", + "tx_sw_if_index" + ], + [ + "vl_api_address_t", + "nh" + ] + ] + ], + "messages": [ + [ + "ip_table_add_del", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0x0ffdaec0" + } + ], + [ + "ip_table_add_del_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_table_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + { + "crc": "0x51077d14" + } + ], + [ + "ip_table_replace_begin", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xb9d2e09e" + } + ], + [ + "ip_table_replace_begin_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_table_replace_end", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xb9d2e09e" + } + ], + [ + "ip_table_replace_end_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_table_flush", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xb9d2e09e" + } + ], + [ + "ip_table_flush_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_table_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xc79fca0f" + } + ], + [ + "ip_route_add_del", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + [ + "bool", + "is_multipath" + ], + [ + "vl_api_ip_route_t", + "route" + ], + { + "crc": "0xc1ff832d" + } + ], + [ + "ip_route_add_del_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "u32", + "stats_index" + ], + { + "crc": "0x1992deab" + } + ], + [ + "ip_route_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xb9d2e09e" + } + ], + [ + "ip_route_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_route_t", + "route" + ], + { + "crc": "0xd1ffaae1" + } + ], + [ + "ip_route_lookup", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "u32", + "table_id" + ], + [ + "u8", + "exact" + ], + [ + "vl_api_prefix_t", + "prefix" + ], + { + "crc": "0xe2986185" + } + ], + [ + "ip_route_lookup_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "vl_api_ip_route_t", + "route" + ], + { + "crc": "0xae99de8e" + } + ], + [ + "set_ip_flow_hash", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "u32", + "vrf_id" + ], + [ + "bool", + "is_ipv6" + ], + [ + "bool", + "src" + ], + [ + "bool", + "dst" + ], + [ + "bool", + "sport" + ], + [ + "bool", + "dport" + ], + [ + "bool", + "proto" + ], + [ + "bool", + "reverse" + ], + [ + "bool", + "symmetric" + ], + { + "crc": "0x084ee09e" + } + ], + [ + "set_ip_flow_hash_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "sw_interface_ip6_enable_disable", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "bool", + "enable" + ], + { + "crc": "0xae6cfcfb" + } + ], + [ + "sw_interface_ip6_enable_disable_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_mtable_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + { + "crc": "0x51077d14" + } + ], + [ + "ip_mtable_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xb9d2e09e" + } + ], + [ + "ip_mroute_add_del", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + [ + "bool", + "is_multipath" + ], + [ + "vl_api_ip_mroute_t", + "route" + ], + { + "crc": "0xf6627d17" + } + ], + [ + "ip_mroute_add_del_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "u32", + "stats_index" + ], + { + "crc": "0x1992deab" + } + ], + [ + "ip_mroute_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xb9d2e09e" + } + ], + [ + "ip_mroute_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_ip_mroute_t", + "route" + ], + { + "crc": "0xc1cb4b44" + } + ], + [ + "ip_address_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "vl_api_address_with_prefix_t", + "prefix" + ], + { + "crc": "0xb1199745" + } + ], + [ + "ip_address_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "bool", + "is_ipv6" + ], + { + "crc": "0x2d033de4" + } + ], + [ + "ip_unnumbered_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "vl_api_interface_index_t", + "ip_sw_if_index" + ], + { + "crc": "0xaa12a483" + } + ], + [ + "ip_unnumbered_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index", + { + "default": 4294967295 + } + ], + { + "crc": "0xf9e6675e" + } + ], + [ + "ip_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "bool", + "is_ipv6" + ], + { + "crc": "0xeb152d07" + } + ], + [ + "ip_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "bool", + "is_ipv6" + ], + { + "crc": "0x98d231ca" + } + ], + [ + "mfib_signal_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + { + "crc": "0x51077d14" + } + ], + [ + "mfib_signal_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "u32", + "table_id" + ], + [ + "vl_api_mprefix_t", + "prefix" + ], + [ + "u16", + "ip_packet_len" + ], + [ + "u8", + "ip_packet_data", + 256 + ], + { + "crc": "0x64398a9a" + } + ], + [ + "ip_punt_police", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "u32", + "policer_index" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + [ + "bool", + "is_ip6" + ], + { + "crc": "0xdb867cea" + } + ], + [ + "ip_punt_police_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_punt_redirect", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_punt_redirect_t", + "punt" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + { + "crc": "0xa9a5592c" + } + ], + [ + "ip_punt_redirect_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_punt_redirect_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "bool", + "is_ipv6" + ], + { + "crc": "0x2d033de4" + } + ], + [ + "ip_punt_redirect_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_punt_redirect_t", + "punt" + ], + { + "crc": "0x3924f5d3" + } + ], + [ + "ip_container_proxy_add_del", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_prefix_t", + "pfx" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + { + "crc": "0x91189f40" + } + ], + [ + "ip_container_proxy_add_del_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_container_proxy_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + { + "crc": "0x51077d14" + } + ], + [ + "ip_container_proxy_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "vl_api_prefix_t", + "prefix" + ], + { + "crc": "0x0ee460e8" + } + ], + [ + "ip_source_and_port_range_check_add_del", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + [ + "vl_api_prefix_t", + "prefix" + ], + [ + "u8", + "number_of_ranges" + ], + [ + "u16", + "low_ports", + 32 + ], + [ + "u16", + "high_ports", + 32 + ], + [ + "u32", + "vrf_id" + ], + { + "crc": "0x8bfc76f2" + } + ], + [ + "ip_source_and_port_range_check_add_del_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_source_and_port_range_check_interface_add_del", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "u32", + "tcp_in_vrf_id" + ], + [ + "u32", + "tcp_out_vrf_id" + ], + [ + "u32", + "udp_in_vrf_id" + ], + [ + "u32", + "udp_out_vrf_id" + ], + { + "crc": "0xe1ba8987" + } + ], + [ + "ip_source_and_port_range_check_interface_add_del_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "sw_interface_ip6_set_link_local_address", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "vl_api_ip6_address_t", + "ip" + ], + { + "crc": "0x2931d9fa" + } + ], + [ + "sw_interface_ip6_set_link_local_address_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ioam_enable", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "u16", + "id" + ], + [ + "bool", + "seqno" + ], + [ + "bool", + "analyse" + ], + [ + "bool", + "pot_enable" + ], + [ + "bool", + "trace_enable" + ], + [ + "u32", + "node_id" + ], + { + "crc": "0x51ccd868" + } + ], + [ + "ioam_enable_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ioam_disable", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "u16", + "id" + ], + { + "crc": "0x6b16a45e" + } + ], + [ + "ioam_disable_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_reassembly_set", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "u32", + "timeout_ms" + ], + [ + "u32", + "max_reassemblies" + ], + [ + "u32", + "max_reassembly_length" + ], + [ + "u32", + "expire_walk_interval_ms" + ], + [ + "bool", + "is_ip6" + ], + [ + "vl_api_ip_reass_type_t", + "type" + ], + { + "crc": "0x16467d25" + } + ], + [ + "ip_reassembly_set_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ], + [ + "ip_reassembly_get", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "bool", + "is_ip6" + ], + [ + "vl_api_ip_reass_type_t", + "type" + ], + { + "crc": "0xea13ff63" + } + ], + [ + "ip_reassembly_get_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "u32", + "timeout_ms" + ], + [ + "u32", + "max_reassemblies" + ], + [ + "u32", + "max_reassembly_length" + ], + [ + "u32", + "expire_walk_interval_ms" + ], + [ + "bool", + "is_ip6" + ], + { + "crc": "0xd5eb8d34" + } + ], + [ + "ip_reassembly_enable_disable", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_interface_index_t", + "sw_if_index" + ], + [ + "bool", + "enable_ip4" + ], + [ + "bool", + "enable_ip6" + ], + [ + "vl_api_ip_reass_type_t", + "type" + ], + { + "crc": "0x885c85a6" + } + ], + [ + "ip_reassembly_enable_disable_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + { + "crc": "0xe8d4e804" + } + ] + ], + "unions": [ + [ + "address_union", + [ + "vl_api_ip4_address_t", + "ip4" + ], + [ + "vl_api_ip6_address_t", + "ip6" + ] + ], + [ + "address_union", + [ + "vl_api_ip4_address_t", + "ip4" + ], + [ + "vl_api_ip6_address_t", + "ip6" + ] + ], + [ + "address_union", + [ + "vl_api_ip4_address_t", + "ip4" + ], + [ + "vl_api_ip6_address_t", + "ip6" + ] + ] + ], + "enums": [ + [ + "if_status_flags", + [ + "IF_STATUS_API_FLAG_ADMIN_UP", + 1 + ], + [ + "IF_STATUS_API_FLAG_LINK_UP", + 2 + ], + { + "enumtype": "u32" + } + ], + [ + "mtu_proto", + [ + "MTU_PROTO_API_L3", + 0 + ], + [ + "MTU_PROTO_API_IP4", + 1 + ], + [ + "MTU_PROTO_API_IP6", + 2 + ], + [ + "MTU_PROTO_API_MPLS", + 3 + ], + { + "enumtype": "u32" + } + ], + [ + "link_duplex", + [ + "LINK_DUPLEX_API_UNKNOWN", + 0 + ], + [ + "LINK_DUPLEX_API_HALF", + 1 + ], + [ + "LINK_DUPLEX_API_FULL", + 2 + ], + { + "enumtype": "u32" + } + ], + [ + "sub_if_flags", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "rx_mode", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "if_type", + [ + "IF_API_TYPE_HARDWARE", + 0 + ], + [ + "IF_API_TYPE_SUB", + 1 + ], + [ + "IF_API_TYPE_P2P", + 2 + ], + [ + "IF_API_TYPE_PIPE", + 3 + ], + { + "enumtype": "u32" + } + ], + [ + "address_family", + [ + "ADDRESS_IP4", + 0 + ], + [ + "ADDRESS_IP6", + 1 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_ecn", + [ + "IP_API_ECN_NONE", + 0 + ], + [ + "IP_API_ECN_ECT0", + 1 + ], + [ + "IP_API_ECN_ECT1", + 2 + ], + [ + "IP_API_ECN_CE", + 3 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_dscp", + [ + "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 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_proto", + [ + "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_ESP", + 50 + ], + [ + "IP_API_PROTO_AH", + 51 + ], + [ + "IP_API_PROTO_ICMP6", + 58 + ], + [ + "IP_API_PROTO_EIGRP", + 88 + ], + [ + "IP_API_PROTO_OSPF", + 89 + ], + [ + "IP_API_PROTO_SCTP", + 132 + ], + [ + "IP_API_PROTO_RESERVED", + 255 + ], + { + "enumtype": "u8" + } + ], + [ + "fib_path_nh_proto", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "fib_path_flags", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "fib_path_type", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "address_family", + [ + "ADDRESS_IP4", + 0 + ], + [ + "ADDRESS_IP6", + 1 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_ecn", + [ + "IP_API_ECN_NONE", + 0 + ], + [ + "IP_API_ECN_ECT0", + 1 + ], + [ + "IP_API_ECN_ECT1", + 2 + ], + [ + "IP_API_ECN_CE", + 3 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_dscp", + [ + "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 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_proto", + [ + "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_ESP", + 50 + ], + [ + "IP_API_PROTO_AH", + 51 + ], + [ + "IP_API_PROTO_ICMP6", + 58 + ], + [ + "IP_API_PROTO_EIGRP", + 88 + ], + [ + "IP_API_PROTO_OSPF", + 89 + ], + [ + "IP_API_PROTO_SCTP", + 132 + ], + [ + "IP_API_PROTO_RESERVED", + 255 + ], + { + "enumtype": "u8" + } + ], + [ + "fib_path_nh_proto", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "fib_path_flags", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "fib_path_type", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "address_family", + [ + "ADDRESS_IP4", + 0 + ], + [ + "ADDRESS_IP6", + 1 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_ecn", + [ + "IP_API_ECN_NONE", + 0 + ], + [ + "IP_API_ECN_ECT0", + 1 + ], + [ + "IP_API_ECN_ECT1", + 2 + ], + [ + "IP_API_ECN_CE", + 3 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_dscp", + [ + "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 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_proto", + [ + "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_ESP", + 50 + ], + [ + "IP_API_PROTO_AH", + 51 + ], + [ + "IP_API_PROTO_ICMP6", + 58 + ], + [ + "IP_API_PROTO_EIGRP", + 88 + ], + [ + "IP_API_PROTO_OSPF", + 89 + ], + [ + "IP_API_PROTO_SCTP", + 132 + ], + [ + "IP_API_PROTO_RESERVED", + 255 + ], + { + "enumtype": "u8" + } + ], + [ + "mfib_itf_flags", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "if_status_flags", + [ + "IF_STATUS_API_FLAG_ADMIN_UP", + 1 + ], + [ + "IF_STATUS_API_FLAG_LINK_UP", + 2 + ], + { + "enumtype": "u32" + } + ], + [ + "mtu_proto", + [ + "MTU_PROTO_API_L3", + 0 + ], + [ + "MTU_PROTO_API_IP4", + 1 + ], + [ + "MTU_PROTO_API_IP6", + 2 + ], + [ + "MTU_PROTO_API_MPLS", + 3 + ], + { + "enumtype": "u32" + } + ], + [ + "link_duplex", + [ + "LINK_DUPLEX_API_UNKNOWN", + 0 + ], + [ + "LINK_DUPLEX_API_HALF", + 1 + ], + [ + "LINK_DUPLEX_API_FULL", + 2 + ], + { + "enumtype": "u32" + } + ], + [ + "sub_if_flags", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "rx_mode", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "if_type", + [ + "IF_API_TYPE_HARDWARE", + 0 + ], + [ + "IF_API_TYPE_SUB", + 1 + ], + [ + "IF_API_TYPE_P2P", + 2 + ], + [ + "IF_API_TYPE_PIPE", + 3 + ], + { + "enumtype": "u32" + } + ], + [ + "ip_reass_type", + [ + "IP_REASS_TYPE_FULL", + 0 + ], + [ + "IP_REASS_TYPE_SHALLOW_VIRTUAL", + 1 + ], + { + "enumtype": "u32" + } + ] + ], + "services": { + "ip_table_add_del": { + "reply": "ip_table_add_del_reply" + }, + "ip_table_dump": { + "reply": "ip_table_details", + "stream": true + }, + "ip_table_replace_begin": { + "reply": "ip_table_replace_begin_reply" + }, + "ip_table_replace_end": { + "reply": "ip_table_replace_end_reply" + }, + "ip_table_flush": { + "reply": "ip_table_flush_reply" + }, + "ip_route_add_del": { + "reply": "ip_route_add_del_reply" + }, + "ip_route_dump": { + "reply": "ip_route_details", + "stream": true + }, + "ip_route_lookup": { + "reply": "ip_route_lookup_reply" + }, + "set_ip_flow_hash": { + "reply": "set_ip_flow_hash_reply" + }, + "sw_interface_ip6_enable_disable": { + "reply": "sw_interface_ip6_enable_disable_reply" + }, + "ip_mtable_dump": { + "reply": "ip_mtable_details", + "stream": true + }, + "ip_mroute_add_del": { + "reply": "ip_mroute_add_del_reply" + }, + "ip_mroute_dump": { + "reply": "ip_mroute_details", + "stream": true + }, + "ip_address_dump": { + "reply": "ip_address_details", + "stream": true + }, + "ip_unnumbered_dump": { + "reply": "ip_unnumbered_details", + "stream": true + }, + "ip_dump": { + "reply": "ip_details", + "stream": true + }, + "mfib_signal_dump": { + "reply": "mfib_signal_details", + "stream": true + }, + "ip_punt_police": { + "reply": "ip_punt_police_reply" + }, + "ip_punt_redirect": { + "reply": "ip_punt_redirect_reply" + }, + "ip_punt_redirect_dump": { + "reply": "ip_punt_redirect_details", + "stream": true + }, + "ip_container_proxy_add_del": { + "reply": "ip_container_proxy_add_del_reply" + }, + "ip_container_proxy_dump": { + "reply": "ip_container_proxy_details", + "stream": true + }, + "ip_source_and_port_range_check_add_del": { + "reply": "ip_source_and_port_range_check_add_del_reply" + }, + "ip_source_and_port_range_check_interface_add_del": { + "reply": "ip_source_and_port_range_check_interface_add_del_reply" + }, + "sw_interface_ip6_set_link_local_address": { + "reply": "sw_interface_ip6_set_link_local_address_reply" + }, + "ioam_enable": { + "reply": "ioam_enable_reply" + }, + "ioam_disable": { + "reply": "ioam_disable_reply" + }, + "ip_reassembly_set": { + "reply": "ip_reassembly_set_reply" + }, + "ip_reassembly_get": { + "reply": "ip_reassembly_get_reply" + }, + "ip_reassembly_enable_disable": { + "reply": "ip_reassembly_enable_disable_reply" + } + }, + "options": { + "version": "3.0.1" + }, + "aliases": { + "interface_index": { + "type": "u32" + }, + "ip4_address": { + "type": "u8", + "length": 4 + }, + "ip6_address": { + "type": "u8", + "length": 16 + }, + "address_with_prefix": { + "type": "vl_api_prefix_t" + }, + "ip4_address_with_prefix": { + "type": "vl_api_ip4_prefix_t" + }, + "ip6_address_with_prefix": { + "type": "vl_api_ip6_prefix_t" + }, + "mac_address": { + "type": "u8", + "length": 6 + } + }, + "vl_api_version": "0x765d74b1", + "imports": [ + "vnet/interface_types.api", + "vnet/fib/fib_types.api", + "vnet/ip/ip_types.api", + "vnet/ethernet/ethernet_types.api", + "vnet/mfib/mfib_types.api", + "vnet/fib/fib_types.api", + "vnet/ip/ip_types.api", + "vnet/ip/ip_types.api", + "vnet/interface_types.api" + ] + } +] diff --git a/binapigen/vppapi/testdata/union.api.json b/binapigen/vppapi/testdata/union.api.json new file mode 100644 index 00000000..0811f22a --- /dev/null +++ b/binapigen/vppapi/testdata/union.api.json @@ -0,0 +1,231 @@ +{ + "services": [], + "vl_api_version": "0x1db2ece9", + "enums": [ + [ + "enum1", + [ + "ENUM_1_VALUE_1", + 1 + ], + [ + "ENUM_1_VALUE_2", + 2 + ], + { + "enumtype": "u16" + } + ], + [ + "enum2", + [ + "ENUM_2_VALUE_1", + 10 + ], + [ + "ENUM_2_VALUE_2", + 20 + ], + { + "enumtype": "u32" + } + ] + ], + "messages": [], + "types": [ + [ + "type1", + [ + "u8", + "field1", + 16 + ], + [ + "u8", + "field2", + 16 + ] + ], + [ + "type2", + [ + "u16", + "field1" + ], + [ + "u32", + "field2" + ], + [ + "u32", + "field3" + ] + ], + [ + "type3", + [ + "u8", + "field1", + 64 + ] + ], + [ + "type4", + [ + "u8", + "field1" + ], + [ + "u8", + "field2", + 16 + ] + ], + [ + "type5", + [ + "u32", + "field1" + ], + [ + "union5", + "field2" + ] + ], + [ + "type6", + [ + "u16", + "field1" + ], + [ + "u32", + "field2" + ], + [ + "type4", + "field3" + ], + [ + "u16", + "field4" + ], + [ + "u32", + "field5" + ], + [ + "u32", + "field6" + ] + ], + [ + "complex_type", + [ + "u32", + "field1" + ], + [ + "u8", + "field2" + ], + [ + "u8", + "field3" + ], + [ + "u32", + "field4" + ], + [ + "type5", + "field5" + ], + [ + "type6", + "field6" + ] + ] + ], + "unions": [ + [ + "union1", + [ + "vl_api_alias1_t", + "alias1" + ], + [ + "vl_api_alias2_t", + "alias2" + ] + ], + [ + "union2", + [ + "vl_api_enum1_t", + "enum1" + ], + [ + "vl_api_enum2_t", + "enum2" + ] + ], + [ + "union3", + [ + "vl_api_type1_t", + "type1" + ], + [ + "vl_api_type2_t", + "type2" + ] + ], + [ + "union4", + [ + "vl_api_union1_t", + "union1" + ], + [ + "vl_api_union2_t", + "union2" + ] + ], + [ + "union5", + [ + "vl_api_type1_t", + "type1" + ], + [ + "vl_api_type3_t", + "type3" + ] + ], + [ + "union6", + [ + "vl_api_type1_t", + "type1" + ], + [ + "vl_api_complex_type_t", + "type3" + ] + ] + ], + "aliases": { + "alias1": { + "type": "u8", + "length": 4 + }, + "alias2": { + "type": "u8", + "length": 16 + }, + "alias3": { + "type": "u32" + } + } +} diff --git a/binapigen/vppapi/testdata/vpe.api.json b/binapigen/vppapi/testdata/vpe.api.json new file mode 100644 index 00000000..960ba126 --- /dev/null +++ b/binapigen/vppapi/testdata/vpe.api.json @@ -0,0 +1,775 @@ +{ + "types": [ + [ + "version", + [ + "u32", + "major" + ], + [ + "u32", + "minor" + ], + [ + "u32", + "patch" + ], + [ + "u8", + "pre_release", + 17 + ], + [ + "u8", + "build_metadata", + 17 + ] + ], + [ + "thread_data", + [ + "u32", + "id" + ], + [ + "string", + "name", + 64 + ], + [ + "string", + "type", + 64 + ], + [ + "u32", + "pid" + ], + [ + "u32", + "cpu_id" + ], + [ + "u32", + "core" + ], + [ + "u32", + "cpu_socket" + ] + ] + ], + "messages": [ + [ + "control_ping", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + { + "crc": "0x51077d14" + } + ], + [ + "control_ping_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "vpe_pid" + ], + { + "crc": "0xf6b0b8ca" + } + ], + [ + "cli", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "u64", + "cmd_in_shmem" + ], + { + "crc": "0x23bfbfff" + } + ], + [ + "cli_inband", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "string", + "cmd", + 0 + ], + { + "crc": "0xf8377302" + } + ], + [ + "cli_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "u64", + "reply_in_shmem" + ], + { + "crc": "0x06d68297" + } + ], + [ + "cli_inband_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "string", + "reply", + 0 + ], + { + "crc": "0x05879051" + } + ], + [ + "get_node_index", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "string", + "node_name", + 64 + ], + { + "crc": "0xf1984c64" + } + ], + [ + "get_node_index_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "u32", + "node_index" + ], + { + "crc": "0xa8600b89" + } + ], + [ + "add_node_next", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "string", + "node_name", + 64 + ], + [ + "string", + "next_name", + 64 + ], + { + "crc": "0x2457116d" + } + ], + [ + "add_node_next_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "u32", + "next_index" + ], + { + "crc": "0x2ed75f32" + } + ], + [ + "show_version", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + { + "crc": "0x51077d14" + } + ], + [ + "show_version_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "string", + "program", + 32 + ], + [ + "string", + "version", + 32 + ], + [ + "string", + "build_date", + 32 + ], + [ + "string", + "build_directory", + 256 + ], + { + "crc": "0xc919bde1" + } + ], + [ + "show_threads", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + { + "crc": "0x51077d14" + } + ], + [ + "show_threads_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "u32", + "count" + ], + [ + "vl_api_thread_data_t", + "thread_data", + 0, + "count" + ], + { + "crc": "0xefd78e83" + } + ], + [ + "get_node_graph", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + { + "crc": "0x51077d14" + } + ], + [ + "get_node_graph_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "u64", + "reply_in_shmem" + ], + { + "crc": "0x06d68297" + } + ], + [ + "get_next_index", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "string", + "node_name", + 64 + ], + [ + "string", + "next_name", + 64 + ], + { + "crc": "0x2457116d" + } + ], + [ + "get_next_index_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "u32", + "next_index" + ], + { + "crc": "0x2ed75f32" + } + ], + [ + "log_dump", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_timestamp_t", + "start_timestamp" + ], + { + "crc": "0x6ab31753" + } + ], + [ + "log_details", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_timestamp_t", + "timestamp" + ], + [ + "vl_api_log_level_t", + "level" + ], + [ + "string", + "msg_class", + 32 + ], + [ + "string", + "message", + 256 + ], + { + "crc": "0x255827a1" + } + ], + [ + "show_vpe_system_time", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + { + "crc": "0x51077d14" + } + ], + [ + "show_vpe_system_time_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "i32", + "retval" + ], + [ + "vl_api_timestamp_t", + "vpe_system_time" + ], + { + "crc": "0x7ffd8193" + } + ], + [ + "get_f64_endian_value", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "f64", + "f64_one", + { + "default": 1.0 + } + ], + { + "crc": "0x809fcd44" + } + ], + [ + "get_f64_endian_value_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "u32", + "retval" + ], + [ + "f64", + "f64_one_result" + ], + { + "crc": "0x7e02e404" + } + ], + [ + "get_f64_increment_by_one", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "f64", + "f64_value", + { + "default": 1.0 + } + ], + { + "crc": "0xb64f027e" + } + ], + [ + "get_f64_increment_by_one_reply", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "u32", + "retval" + ], + [ + "f64", + "f64_value" + ], + { + "crc": "0xd25dbaa3" + } + ] + ], + "unions": [], + "enums": [ + [ + "log_level", + [ + "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 + ], + { + "enumtype": "u32" + } + ] + ], + "services": { + "control_ping": { + "reply": "control_ping_reply" + }, + "cli": { + "reply": "cli_reply" + }, + "cli_inband": { + "reply": "cli_inband_reply" + }, + "get_node_index": { + "reply": "get_node_index_reply" + }, + "add_node_next": { + "reply": "add_node_next_reply" + }, + "show_version": { + "reply": "show_version_reply" + }, + "show_threads": { + "reply": "show_threads_reply" + }, + "get_node_graph": { + "reply": "get_node_graph_reply" + }, + "get_next_index": { + "reply": "get_next_index_reply" + }, + "log_dump": { + "reply": "log_details", + "stream": true + }, + "show_vpe_system_time": { + "reply": "show_vpe_system_time_reply" + }, + "get_f64_endian_value": { + "reply": "get_f64_endian_value_reply" + }, + "get_f64_increment_by_one": { + "reply": "get_f64_increment_by_one_reply" + } + }, + "options": { + "version": "1.6.1" + }, + "aliases": { + "timestamp": { + "type": "f64" + }, + "timedelta": { + "type": "f64" + } + }, + "vl_api_version": "0xbd2c94f4", + "imports": [ + "vpp/api/vpe_types.api" + ] +} diff --git a/binapigen/vppapi/util.go b/binapigen/vppapi/util.go new file mode 100644 index 00000000..435ea881 --- /dev/null +++ b/binapigen/vppapi/util.go @@ -0,0 +1,191 @@ +// 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 vppapi + +import ( + "bytes" + "errors" + "fmt" + "os" + "os/exec" + "path" + "path/filepath" + "strings" + "time" + + "github.com/sirupsen/logrus" +) + +const ( + VPPVersionEnvVar = "VPP_VERSION" + VPPDirEnvVar = "VPP_DIR" + + versionScriptPath = "src/scripts/version" + localVPPBuildApiDir = "build-root/install-vpp-native/vpp/share/vpp/api" +) + +// ResolveApiDir checks if parameter dir is a path to directory of local VPP +// repository and returns path to directory with VPP API JSON files under +// build-root. It will execute `make json-api-files` in case the folder with +// VPP API JSON files does not exist yet. +func ResolveApiDir(dir string) string { + log := logrus.WithField("dir", dir) + log.Tracef("trying to resolve VPP API directory") + + apiDirPath := path.Join(dir, localVPPBuildApiDir) + + // assume dir is a local VPP repository + _, err := os.Stat(path.Join(dir, "build-root")) + if err == nil { + logrus.Tracef("build-root exists in %s, checking %q", dir, localVPPBuildApiDir) + + // check if the API directory exists + _, err := os.Stat(apiDirPath) + if err == nil { + logrus.Tracef("api dir %q exists, running 'make json-api-files'", localVPPBuildApiDir) + if err := makeJsonApiFiles(dir); err != nil { + logrus.Warnf("make json-api-files failed: %v", err) + } + return apiDirPath + } else if errors.Is(err, os.ErrNotExist) { + logrus.Tracef("api dir %q does not exist, running 'make json-api-files'", localVPPBuildApiDir) + if err := makeJsonApiFiles(dir); err != nil { + logrus.Warnf("make json-api-files failed: %v", err) + } else { + return apiDirPath + } + } else { + logrus.Tracef("error occurred when checking %q: %v'", localVPPBuildApiDir, err) + } + } + return dir +} + +func makeJsonApiFiles(dir string) error { + var stdout, stderr bytes.Buffer + cmd := exec.Command("make", "json-api-files") + cmd.Dir = dir + cmd.Stdout = &stdout + cmd.Stderr = &stderr + t := time.Now() + if err := cmd.Run(); err != nil { + logrus.Debugf("command `%v` failed: %v", cmd, err) + if stdout.Len() > 0 { + logrus.Debugf("# STDOUT:\n%v", stdout.String()) + } + if stderr.Len() > 0 { + logrus.Debugf("# STDERR:\n%v", stderr.String()) + } + return fmt.Errorf("command `%v` failed: %v", cmd, err) + } + logrus.Debugf("command `%v` done (took %.3fs)\n", cmd, time.Since(t).Seconds()) + return nil +} + +// ResolveVPPVersion resolves version of the VPP for target directory. +// +// Version resolved here can be overriden by setting VPP_VERSION env var. +func ResolveVPPVersion(apidir string) string { + // check if inside VPP repo + repoDir, err := findGitRepoRootDir(apidir) + if err != nil { + logrus.Debugf("ERR: failed to check VPP git repo: %v", err) + } else { + logrus.Debugf("resolved git repo root directory: %v", repoDir) + + version, err := GetVPPVersionRepo(repoDir) + if err != nil { + logrus.Debugf("ERR: failed to resolve VPP version from version script: %v", err) + } else { + logrus.Debugf("resolved VPP version from version script: %v", version) + return version + } + + // try to read VPP_VERSION file + data, err := os.ReadFile(path.Join(repoDir, "VPP_VERSION")) + if err == nil { + ver := strings.TrimSpace(string(data)) + logrus.Debugf("VPP version was resolved to %q from VPP_VERSION file", ver) + return ver + } + } + + // try to read VPP_VERSION file + data, err := os.ReadFile(path.Join(apidir, "VPP_VERSION")) + if err == nil { + ver := strings.TrimSpace(string(data)) + logrus.Debugf("VPP version was resolved to %q from VPP_VERSION file", ver) + return ver + } + + // check env variable override + if ver := os.Getenv(VPPVersionEnvVar); ver != "" { + logrus.Debugf("VPP version was manually set to %q via %s env var", ver, VPPVersionEnvVar) + return ver + } + + // assuming VPP package is installed + if filepath.Clean(apidir) == DefaultDir { + version, err := GetVPPVersionInstalled() + if err != nil { + logrus.Debugf("ERR: failed to resolve VPP version from installed package: %v", err) + } else { + logrus.Debugf("resolved VPP version from installed package: %v", version) + return version + } + } + + logrus.Warnf("VPP version could not be resolved, you can set it manually using %s env var", VPPVersionEnvVar) + return "" +} + +// GetVPPVersionInstalled retrieves VPP version of installed package using dpkg-query. +func GetVPPVersionInstalled() (string, error) { + cmd := exec.Command("dpkg-query", "-f", "${Version}", "-W", "vpp") + out, err := cmd.CombinedOutput() + if err != nil { + return "", fmt.Errorf("dpkg-query command failed: %v\noutput: %s", err, out) + } + return strings.TrimSpace(string(out)), nil +} + +// GetVPPVersionRepo retrieves VPP version using script in repo directory. +func GetVPPVersionRepo(repoDir string) (string, error) { + scriptPath := path.Join(repoDir, versionScriptPath) + if _, err := os.Stat(scriptPath); err != nil { + return "", err + } + cmd := exec.Command(scriptPath) + cmd.Dir = repoDir + out, err := cmd.CombinedOutput() + if err != nil { + return "", fmt.Errorf("version script failed: %v\noutput: %s", err, out) + } + return strings.TrimSpace(string(out)), nil +} + +func findGitRepoRootDir(dir string) (string, error) { + if conf := os.Getenv(VPPDirEnvVar); conf != "" { + logrus.Infof("VPP directory was manually set to %q via %s env var", conf, VPPDirEnvVar) + return conf, nil + } + cmd := exec.Command("git", "rev-parse", "--show-toplevel") + cmd.Dir = dir + out, err := cmd.CombinedOutput() + if err != nil { + return "", fmt.Errorf("git command failed: %v\noutput: %s", err, out) + } + return strings.TrimSpace(string(out)), nil +} diff --git a/binapigen/vppapi/vppapi.go b/binapigen/vppapi/vppapi.go new file mode 100644 index 00000000..cefc12db --- /dev/null +++ b/binapigen/vppapi/vppapi.go @@ -0,0 +1,139 @@ +// 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 vppapi parses VPP API files without any additional processing. +package vppapi + +import ( + "fmt" + "os" + "path/filepath" + "strings" +) + +const ( + // DefaultDir is default location of API files. + DefaultDir = "/usr/share/vpp/api" + + // APIFileExtension is a VPP API file extension suffix + APIFileExtension = ".api.json" +) + +// FindFiles searches for API files in given directory or in a nested directory +// that is at most one level deeper than dir. This effectively finds all API files +// under core & plugins directories inside API directory. +func FindFiles(dir string) (files []string, err error) { + return FindFilesRecursive(dir, 1) +} + +// FindFilesRecursive searches for API files under dir or in a nested directory that is not +// nested deeper than deep. +func FindFilesRecursive(dir string, deep int) (files []string, err error) { + entries, err := os.ReadDir(dir) + if err != nil { + return nil, fmt.Errorf("read dir %s failed: %v", dir, err) + } + for _, e := range entries { + if e.IsDir() && deep > 0 { + nestedDir := filepath.Join(dir, e.Name()) + if nested, err := FindFilesRecursive(nestedDir, deep-1); err != nil { + return nil, err + } else { + files = append(files, nested...) + } + } else if !e.IsDir() && strings.HasSuffix(e.Name(), APIFileExtension) { + files = append(files, filepath.Join(dir, e.Name())) + } + } + return files, nil +} + +// Parse parses API files in directory DefaultDir and returns collection of File +// or an error if any error occurs during parsing. +func Parse() ([]File, error) { + return ParseDir(DefaultDir) +} + +// ParseDir searches for API files in apiDir, parses the found API files and +// returns collection of File. +// +// API files must have suffix `.api.json` and must be formatted as JSON. +func ParseDir(apiDir string) ([]File, error) { + list, err := FindFiles(apiDir) + if err != nil { + return nil, err + } + + logf("found %d files in API dir %q", len(list), apiDir) + + var files []File + for _, f := range list { + file, err := ParseFile(f) + if err != nil { + return nil, err + } + // use file path relative to apiDir + if path, err := filepath.Rel(apiDir, file.Path); err == nil { + file.Path = path + } + files = append(files, *file) + } + return files, nil +} + +// ParseFile parses API file and returns File or an error if any error occurs +// during parsing. +func ParseFile(apiFile string) (*File, error) { + // check API file extension + if !strings.HasSuffix(apiFile, APIFileExtension) { + return nil, fmt.Errorf("unsupported file: %q, file must have suffix %q", apiFile, APIFileExtension) + } + + content, err := os.ReadFile(apiFile) + if err != nil { + return nil, fmt.Errorf("read file %s error: %w", apiFile, err) + } + + // extract file name + base := filepath.Base(apiFile) + name := base[:strings.Index(base, ".")] + + logf("parsing file %q (%d bytes)", base, len(content)) + + file, err := ParseRaw(content) + if err != nil { + return nil, fmt.Errorf("parsing API file %q content failed: %w", base, err) + } + file.Name = name + file.Path = apiFile + + return file, nil +} + +// ParseRaw parses raw API file content and returns File or an error if any error +// occurs during parsing. +func ParseRaw(content []byte) (file *File, err error) { + defer func() { + if e := recover(); e != nil { + err = fmt.Errorf("panic occurred during parsing: %+v", e) + } + }() + + file, err = parseApiJsonFile(content) + if err != nil { + return nil, fmt.Errorf("parseApiJsonFile error: %w", err) + } + + return file, nil +} diff --git a/binapigen/vppapi/vppapi_test.go b/binapigen/vppapi/vppapi_test.go new file mode 100644 index 00000000..6ec9139f --- /dev/null +++ b/binapigen/vppapi/vppapi_test.go @@ -0,0 +1,118 @@ +// 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 vppapi + +import ( + "encoding/json" + "os" + "testing" + + . "github.com/onsi/gomega" +) + +func TestGetInputFiles(t *testing.T) { + RegisterTestingT(t) + + result, err := FindFiles("testdata") + Expect(err).ShouldNot(HaveOccurred()) + Expect(result).To(HaveLen(6)) + for _, file := range result { + Expect(file).To(BeAnExistingFile()) + } +} + +func TestGetInputFilesError(t *testing.T) { + RegisterTestingT(t) + + result, err := FindFiles("nonexisting_directory") + Expect(err).Should(HaveOccurred()) + Expect(result).To(BeNil()) +} + +func TestReadJson(t *testing.T) { + RegisterTestingT(t) + + inputData, err := os.ReadFile("testdata/af_packet.api.json") + Expect(err).ShouldNot(HaveOccurred()) + result, err := ParseRaw(inputData) + Expect(err).ShouldNot(HaveOccurred()) + Expect(result).ToNot(BeNil()) + Expect(result.EnumTypes).To(HaveLen(0)) + Expect(result.StructTypes).To(HaveLen(0)) + Expect(result.Messages).To(HaveLen(6)) + Expect(result.Service.RPCs).To(HaveLen(3)) +} + +func TestReadJsonError(t *testing.T) { + RegisterTestingT(t) + + inputData, err := os.ReadFile("testdata/input-read-json-error.json") + Expect(err).ShouldNot(HaveOccurred()) + result, err := ParseRaw(inputData) + Expect(err).Should(HaveOccurred()) + Expect(result).To(BeNil()) +} + +func TestParseFile(t *testing.T) { + module, err := ParseFile("testdata/vpe.api.json") + if err != nil { + t.Fatal("unexpected error:", err) + } + + b, err := json.MarshalIndent(module, "", " ") + if err != nil { + t.Fatal(err) + } + t.Logf("parsed module: %s", b) + + if module.Name != "vpe" { + t.Errorf("expected Name=%s, got %v", "vpe", module.Name) + } + if module.Path != "testdata/vpe.api.json" { + t.Errorf("expected Path=%s, got %v", "testdata/vpe.api.json", module.Path) + } + if module.CRC != "0xbd2c94f4" { + t.Errorf("expected CRC=%s, got %v", "0xbd2c94f4", module.CRC) + } + + if version := module.Options["version"]; version != "1.6.1" { + t.Errorf("expected option[version]=%s, got %v", "1.6.1", version) + } + if len(module.Imports) == 0 { + t.Errorf("expected imports, got none") + } + if len(module.EnumTypes) == 0 { + t.Errorf("expected enums, got none") + } + if len(module.AliasTypes) == 0 { + t.Errorf("expected aliases, got none") + } + if len(module.StructTypes) == 0 { + t.Errorf("expected types, got none") + } + if len(module.Messages) == 0 { + t.Errorf("expected messages, got none") + } + if len(module.Service.RPCs) == 0 { + t.Errorf("expected service RPCs, got none") + } +} + +func TestParseFileUnsupported(t *testing.T) { + _, err := ParseFile("testdata/input.txt") + if err == nil { + t.Fatal("expected error") + } +} diff --git a/binapigen/vppapi_test.go b/binapigen/vppapi_test.go new file mode 100644 index 00000000..f65bfd5d --- /dev/null +++ b/binapigen/vppapi_test.go @@ -0,0 +1,99 @@ +// Copyright (c) 2023 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 binapigen + +import ( + "fmt" + "testing" +) + +func TestCleanMessageComment(t *testing.T) { + tests := []struct { + comment string + expected string + }{ + { + comment: `/** \\brief Test comment. + @param foo - first parameter + @param bar - second parameter +*/`, + expected: `Test comment. + - foo - first parameter + - bar - second parameter`, + }, + { + comment: `/** \\brief Another test. +*/`, + expected: "Another test.", + }, + { + comment: `/** \\brief Empty param. + @param +*/`, + expected: `Empty param. + -`, + }, + { + comment: `/** \\brief Show the current system timestamp. + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request +*/`, + expected: `Show the current system timestamp. + - client_index - opaque cookie to identify the sender + - context - sender context, to match reply w/ request`, + }, + { + comment: "/** \\brief Reply to get the plugin version\n @param context - returned sender context, to match reply w/ request\n @param major - Incremented every time a known breaking behavior change is introduced\n @param minor - Incremented with small changes, may be used to avoid buggy versions\n*/", + expected: "Reply to get the plugin version\n - context - returned sender context, to match reply w/ request\n - major - Incremented every time a known breaking behavior change is introduced\n - minor - Incremented with small changes, may be used to avoid buggy versions", + }, + } + + for i, test := range tests { + t.Run(fmt.Sprintf("test-%d", i), func(t *testing.T) { + result := CleanMessageComment(test.comment) + if result != test.expected { + t.Errorf("Expected:\n%s\nbut got:\n%s", test.expected, result) + } + }) + } +} + +func TestStripMessageCommentFields(t *testing.T) { + tests := []struct { + comment string + expected string + }{ + { + comment: ` - context - sender context, to match reply w/ request + - retval - return value for request + - sw_if_index - software index for the new af_xdp interface`, + expected: ` - retval - return value for request + - sw_if_index - software index for the new af_xdp interface`, + }, + { + comment: "Reply to get the plugin version\n - context - returned sender context, to match reply w/ request\n - major - Incremented every time a known breaking behavior change is introduced\n - minor - Incremented with small changes, may be used to avoid buggy versions", + expected: "Reply to get the plugin version\n - major - Incremented every time a known breaking behavior change is introduced\n - minor - Incremented with small changes, may be used to avoid buggy versions", + }, + } + + for i, test := range tests { + t.Run(fmt.Sprintf("test-%d", i), func(t *testing.T) { + result := StripMessageCommentFields(test.comment, "context", "client_index") + if result != test.expected { + t.Errorf("Expected:\n%q\nbut got:\n%q", test.expected, result) + } + }) + } +} diff --git a/cmd/binapi-generator/definitions_test.go b/cmd/binapi-generator/definitions_test.go deleted file mode 100644 index 30c85ae3..00000000 --- a/cmd/binapi-generator/definitions_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "testing" -) - -func TestInitialism(t *testing.T) { - tests := []struct { - name string - input string - expOutput string - }{ - {name: "id", input: "id", expOutput: "ID"}, - {name: "ipv6", input: "is_ipv6", expOutput: "IsIPv6"}, - {name: "ip6", input: "is_ip6", expOutput: "IsIP6"}, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - output := camelCaseName(test.input) - if output != test.expOutput { - t.Errorf("expected %q, got %q", test.expOutput, output) - } - }) - } -} diff --git a/cmd/binapi-generator/doc.go b/cmd/binapi-generator/doc.go index d74d47bc..3c3f518d 100644 --- a/cmd/binapi-generator/doc.go +++ b/cmd/binapi-generator/doc.go @@ -1,12 +1,30 @@ -// Generator of Go structs out of the VPP binary API definitions in JSON format. +// Copyright (c) 2020 Cisco and/or its affiliates. // -// The JSON input can be specified as a single file (using the `input-file` -// CLI flag), or as a directory that will be scanned for all `.json` files -// (using the `input-dir` CLI flag). The generated Go bindings will be -// placed into `output-dir` (by default the current working directory), -// where each Go package will be placed into its own separate directory, -// for example: +// 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: // -// binapi-generator --input-file=/usr/share/vpp/api/core/interface.api.json --output-dir=. +// 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. + +// The binapi-generator parses VPP API definitions in JSON format and generates Go code. +// +// The VPP API input can be specified using --input= option, where INPUT +// is one of the following: +// +// - path to directory containing `*.api.json` files (these may be nested under core/plugins) +// - path to local VPP repository (uses files under`build-root/install-vpp-native/vpp/share/vpp/api`) +// +// The generated Go code will be placed into directory specified using +// `--output-dir=` option (defaults to `binapi`). +// Each VPP API file will be generated as a separate Go package. +// +// Example: +// +// binapi-generator --input=/usr/share/vpp/api --output-dir=binapi package main diff --git a/cmd/binapi-generator/generate.go b/cmd/binapi-generator/generate.go deleted file mode 100644 index 938966a4..00000000 --- a/cmd/binapi-generator/generate.go +++ /dev/null @@ -1,848 +0,0 @@ -// Copyright (c) 2017 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 main - -import ( - "bytes" - "fmt" - "io" - "os/exec" - "path" - "path/filepath" - "sort" - "strings" - "unicode" -) - -// generatedCodeVersion indicates a version of the generated code. -// It is incremented whenever an incompatibility between the generated code and -// GoVPP api package is introduced; the generated code references -// a constant, api.GoVppAPIPackageIsVersionN (where N is generatedCodeVersion). -const generatedCodeVersion = 1 - -const ( - inputFileExt = ".api.json" // file extension of the VPP API files - outputFileExt = ".ba.go" // file extension of the Go generated files - - constModuleName = "ModuleName" // module name constant - constAPIVersion = "APIVersion" // API version constant - constVersionCrc = "VersionCrc" // version CRC constant - - unionDataField = "XXX_UnionData" // name for the union data field - - serviceApiName = "RPCService" // name for the RPC service interface - serviceImplName = "serviceClient" // name for the RPC service implementation - serviceClientName = "ServiceClient" // name for the RPC service client -) - -// context is a structure storing data for code generation -type context struct { - inputFile string // input file with VPP API in JSON - outputFile string // output file with generated Go package - - importPrefix string // defines import path prefix for importing types - - inputData []byte // contents of the input file - - includeAPIVersion bool // include constant with API version string - includeComments bool // include parts of original source in comments - includeBinapiNames bool // include binary API names as struct tag - includeServices bool // include service interface with client implementation - - moduleName string // name of the source VPP module - packageName string // name of the Go package being generated - - packageData *Package // parsed package data -} - -// newContext returns context details of the code generation task -func newContext(inputFile, outputDir string) (*context, error) { - if !strings.HasSuffix(inputFile, inputFileExt) { - return nil, fmt.Errorf("invalid input file name: %q", inputFile) - } - - ctx := &context{ - inputFile: inputFile, - } - - // package name - inputFileName := filepath.Base(inputFile) - ctx.moduleName = inputFileName[:strings.Index(inputFileName, ".")] - - // alter package names for modules that are reserved keywords in Go - switch ctx.moduleName { - case "interface": - ctx.packageName = "interfaces" - case "map": - ctx.packageName = "maps" - default: - ctx.packageName = ctx.moduleName - } - - // output file - packageDir := filepath.Join(outputDir, ctx.packageName) - outputFileName := ctx.packageName + outputFileExt - ctx.outputFile = filepath.Join(packageDir, outputFileName) - - return ctx, nil -} - -func generatePackage(ctx *context, w io.Writer) error { - logf("----------------------------") - logf("generating package %q", ctx.packageName) - logf("----------------------------") - - fmt.Fprintln(w, "// Code generated by GoVPP's binapi-generator. DO NOT EDIT.") - fmt.Fprintf(w, "// source: %s\n", ctx.inputFile) - fmt.Fprintln(w) - - generateHeader(ctx, w) - generateImports(ctx, w) - - // generate module desc - fmt.Fprintln(w, "const (") - fmt.Fprintf(w, "\t// %s is the name of this module.\n", constModuleName) - fmt.Fprintf(w, "\t%s = \"%s\"\n", constModuleName, ctx.moduleName) - - if ctx.includeAPIVersion { - if ctx.packageData.Version != "" { - fmt.Fprintf(w, "\t// %s is the API version of this module.\n", constAPIVersion) - fmt.Fprintf(w, "\t%s = \"%s\"\n", constAPIVersion, ctx.packageData.Version) - } - fmt.Fprintf(w, "\t// %s is the CRC of this module.\n", constVersionCrc) - fmt.Fprintf(w, "\t%s = %v\n", constVersionCrc, ctx.packageData.CRC) - } - fmt.Fprintln(w, ")") - fmt.Fprintln(w) - - // generate enums - if len(ctx.packageData.Enums) > 0 { - for _, enum := range ctx.packageData.Enums { - if imp, ok := ctx.packageData.Imports[enum.Name]; ok { - generateImportedAlias(ctx, w, enum.Name, &imp) - continue - } - generateEnum(ctx, w, &enum) - } - } - - // generate aliases - if len(ctx.packageData.Aliases) > 0 { - for _, alias := range ctx.packageData.Aliases { - if imp, ok := ctx.packageData.Imports[alias.Name]; ok { - generateImportedAlias(ctx, w, alias.Name, &imp) - continue - } - generateAlias(ctx, w, &alias) - } - } - - // generate types - if len(ctx.packageData.Types) > 0 { - for _, typ := range ctx.packageData.Types { - if imp, ok := ctx.packageData.Imports[typ.Name]; ok { - generateImportedAlias(ctx, w, typ.Name, &imp) - continue - } - generateType(ctx, w, &typ) - } - } - - // generate unions - if len(ctx.packageData.Unions) > 0 { - for _, union := range ctx.packageData.Unions { - if imp, ok := ctx.packageData.Imports[union.Name]; ok { - generateImportedAlias(ctx, w, union.Name, &imp) - continue - } - generateUnion(ctx, w, &union) - } - } - - // generate messages - if len(ctx.packageData.Messages) > 0 { - for _, msg := range ctx.packageData.Messages { - generateMessage(ctx, w, &msg) - } - - // generate message registrations - fmt.Fprintln(w, "func init() {") - for _, msg := range ctx.packageData.Messages { - name := camelCaseName(msg.Name) - fmt.Fprintf(w, "\tapi.RegisterMessage((*%s)(nil), \"%s\")\n", name, ctx.moduleName+"."+name) - } - fmt.Fprintln(w, "}") - fmt.Fprintln(w) - - // generate list of messages - fmt.Fprintf(w, "// Messages returns list of all messages in this module.\n") - fmt.Fprintln(w, "func AllMessages() []api.Message {") - fmt.Fprintln(w, "\treturn []api.Message{") - for _, msg := range ctx.packageData.Messages { - name := camelCaseName(msg.Name) - fmt.Fprintf(w, "\t(*%s)(nil),\n", name) - } - fmt.Fprintln(w, "}") - fmt.Fprintln(w, "}") - } - - if ctx.includeServices { - // generate services - if len(ctx.packageData.Services) > 0 { - generateServices(ctx, w, ctx.packageData.Services) - } - } - - generateFooter(ctx, w) - - return nil -} - -func generateHeader(ctx *context, w io.Writer) { - fmt.Fprintln(w, "/*") - fmt.Fprintf(w, "Package %s is a generated VPP binary API for '%s' module.\n", ctx.packageName, ctx.moduleName) - fmt.Fprintln(w) - fmt.Fprintln(w, "It consists of:") - printObjNum := func(obj string, num int) { - if num > 0 { - if num > 1 { - if strings.HasSuffix(obj, "s") { - - obj += "es" - } else { - obj += "s" - } - } - fmt.Fprintf(w, "\t%3d %s\n", num, obj) - } - } - printObjNum("enum", len(ctx.packageData.Enums)) - printObjNum("alias", len(ctx.packageData.Aliases)) - printObjNum("type", len(ctx.packageData.Types)) - printObjNum("union", len(ctx.packageData.Unions)) - printObjNum("message", len(ctx.packageData.Messages)) - printObjNum("service", len(ctx.packageData.Services)) - fmt.Fprintln(w, "*/") - fmt.Fprintf(w, "package %s\n", ctx.packageName) - fmt.Fprintln(w) - -} - -func generateImports(ctx *context, w io.Writer) { - fmt.Fprintln(w, "import (") - fmt.Fprintln(w, ` "bytes"`) - fmt.Fprintln(w, ` "context"`) - fmt.Fprintln(w, ` "io"`) - fmt.Fprintln(w, ` "strconv"`) - fmt.Fprintln(w) - fmt.Fprintf(w, "\tapi \"%s\"\n", "github.com/alkiranet/govpp/api") - fmt.Fprintf(w, "\tstruc \"%s\"\n", "github.com/lunixbochs/struc") - if len(ctx.packageData.Imports) > 0 { - fmt.Fprintln(w) - for _, imp := range getImports(ctx) { - importPath := path.Join(ctx.importPrefix, imp) - if importPath == "" { - importPath = getImportPath(filepath.Dir(ctx.outputFile), imp) - } - fmt.Fprintf(w, "\t%s \"%s\"\n", imp, strings.TrimSpace(importPath)) - } - } - fmt.Fprintln(w, ")") - fmt.Fprintln(w) -} - -func getImportPath(outputDir string, pkg string) string { - absPath, _ := filepath.Abs(filepath.Join(outputDir, "..", pkg)) - cmd := exec.Command("go", "list", absPath) - var errbuf, outbuf bytes.Buffer - cmd.Stdout = &outbuf - cmd.Stderr = &errbuf - if err := cmd.Run(); err != nil { - fmt.Printf("ERR: %v\n", errbuf.String()) - panic(err) - } - return outbuf.String() -} - -func getImports(ctx *context) (imports []string) { - impmap := map[string]struct{}{} - for _, imp := range ctx.packageData.Imports { - if _, ok := impmap[imp.Package]; !ok { - imports = append(imports, imp.Package) - impmap[imp.Package] = struct{}{} - } - } - sort.Strings(imports) - return imports -} - -func generateFooter(ctx *context, w io.Writer) { - fmt.Fprintln(w, "// This is a compile-time assertion to ensure that this generated file") - fmt.Fprintln(w, "// is compatible with the GoVPP api package it is being compiled against.") - fmt.Fprintln(w, "// A compilation error at this line likely means your copy of the") - fmt.Fprintln(w, "// GoVPP api package needs to be updated.") - fmt.Fprintf(w, "const _ = api.GoVppAPIPackageIsVersion%d // please upgrade the GoVPP api package\n", generatedCodeVersion) - fmt.Fprintln(w) - - fmt.Fprintf(w, "// Reference imports to suppress errors if they are not otherwise used.\n") - fmt.Fprintf(w, "var _ = api.RegisterMessage\n") - fmt.Fprintf(w, "var _ = bytes.NewBuffer\n") - fmt.Fprintf(w, "var _ = context.Background\n") - fmt.Fprintf(w, "var _ = io.Copy\n") - fmt.Fprintf(w, "var _ = strconv.Itoa\n") - fmt.Fprintf(w, "var _ = struc.Pack\n") -} - -func generateComment(ctx *context, w io.Writer, goName string, vppName string, objKind string) { - if objKind == "service" { - fmt.Fprintf(w, "// %s represents RPC service API for %s module.\n", goName, ctx.moduleName) - } else { - fmt.Fprintf(w, "// %s represents VPP binary API %s '%s'.\n", goName, objKind, vppName) - } - - if !ctx.includeComments { - return - } - - var isNotSpace = func(r rune) bool { - return !unicode.IsSpace(r) - } - - // print out the source of the generated object - mapType := false - objFound := false - objTitle := fmt.Sprintf(`"%s",`, vppName) - switch objKind { - case "alias", "service": - objTitle = fmt.Sprintf(`"%s": {`, vppName) - mapType = true - } - - inputBuff := bytes.NewBuffer(ctx.inputData) - inputLine := 0 - - var trimIndent string - var indent int - for { - line, err := inputBuff.ReadString('\n') - if err != nil { - break - } - inputLine++ - - noSpaceAt := strings.IndexFunc(line, isNotSpace) - if !objFound { - indent = strings.Index(line, objTitle) - if indent == -1 { - continue - } - trimIndent = line[:indent] - // If no other non-whitespace character then we are at the message header. - if trimmed := strings.TrimSpace(line); trimmed == objTitle { - objFound = true - fmt.Fprintln(w, "//") - } - } else if noSpaceAt < indent { - break // end of the definition in JSON for array types - } else if objFound && mapType && noSpaceAt <= indent { - fmt.Fprintf(w, "//\t%s", strings.TrimPrefix(line, trimIndent)) - break // end of the definition in JSON for map types (aliases, services) - } - fmt.Fprintf(w, "//\t%s", strings.TrimPrefix(line, trimIndent)) - } - - fmt.Fprintln(w, "//") -} - -func generateEnum(ctx *context, w io.Writer, enum *Enum) { - name := camelCaseName(enum.Name) - typ := binapiTypes[enum.Type] - - logf(" writing enum %q (%s) with %d entries", enum.Name, name, len(enum.Entries)) - - // generate enum comment - generateComment(ctx, w, name, enum.Name, "enum") - - // generate enum definition - fmt.Fprintf(w, "type %s %s\n", name, typ) - fmt.Fprintln(w) - - // generate enum entries - fmt.Fprintln(w, "const (") - for _, entry := range enum.Entries { - fmt.Fprintf(w, "\t%s %s = %v\n", entry.Name, name, entry.Value) - } - fmt.Fprintln(w, ")") - fmt.Fprintln(w) - - // generate enum conversion maps - fmt.Fprintf(w, "var %s_name = map[%s]string{\n", name, typ) - for _, entry := range enum.Entries { - fmt.Fprintf(w, "\t%v: \"%s\",\n", entry.Value, entry.Name) - } - fmt.Fprintln(w, "}") - fmt.Fprintln(w) - - fmt.Fprintf(w, "var %s_value = map[string]%s{\n", name, typ) - for _, entry := range enum.Entries { - fmt.Fprintf(w, "\t\"%s\": %v,\n", entry.Name, entry.Value) - } - fmt.Fprintln(w, "}") - fmt.Fprintln(w) - - fmt.Fprintf(w, "func (x %s) String() string {\n", name) - fmt.Fprintf(w, "\ts, ok := %s_name[%s(x)]\n", name, typ) - fmt.Fprintf(w, "\tif ok { return s }\n") - fmt.Fprintf(w, "\treturn strconv.Itoa(int(x))\n") - fmt.Fprintln(w, "}") - fmt.Fprintln(w) -} - -func generateImportedAlias(ctx *context, w io.Writer, tName string, imp *Import) { - name := camelCaseName(tName) - - fmt.Fprintf(w, "type %s = %s.%s\n", name, imp.Package, name) - - fmt.Fprintln(w) -} - -func generateAlias(ctx *context, w io.Writer, alias *Alias) { - name := camelCaseName(alias.Name) - - logf(" writing type %q (%s), length: %d", alias.Name, name, alias.Length) - - // generate struct comment - generateComment(ctx, w, name, alias.Name, "alias") - - // generate struct definition - fmt.Fprintf(w, "type %s ", name) - - if alias.Length > 0 { - fmt.Fprintf(w, "[%d]", alias.Length) - } - - dataType := convertToGoType(ctx, alias.Type) - fmt.Fprintf(w, "%s\n", dataType) - - fmt.Fprintln(w) -} - -func generateUnion(ctx *context, w io.Writer, union *Union) { - name := camelCaseName(union.Name) - - logf(" writing union %q (%s) with %d fields", union.Name, name, len(union.Fields)) - - // generate struct comment - generateComment(ctx, w, name, union.Name, "union") - - // generate struct definition - fmt.Fprintln(w, "type", name, "struct {") - - // maximum size for union - maxSize := getUnionSize(ctx, union) - - // generate data field - fmt.Fprintf(w, "\t%s [%d]byte\n", unionDataField, maxSize) - - // generate end of the struct - fmt.Fprintln(w, "}") - - // generate name getter - generateTypeNameGetter(w, name, union.Name) - - // generate CRC getter - if union.CRC != "" { - generateCrcGetter(w, name, union.CRC) - } - - // generate getters for fields - for _, field := range union.Fields { - fieldName := camelCaseName(field.Name) - fieldType := convertToGoType(ctx, field.Type) - generateUnionGetterSetter(w, name, fieldName, fieldType) - } - - // generate union methods - //generateUnionMethods(w, name) - - fmt.Fprintln(w) -} - -// generateUnionMethods generates methods that implement struc.Custom -// interface to allow having XXX_uniondata field unexported -// TODO: do more testing when unions are actually used in some messages -/*func generateUnionMethods(w io.Writer, structName string) { - // generate struc.Custom implementation for union - fmt.Fprintf(w, ` -func (u *%[1]s) Pack(p []byte, opt *struc.Options) (int, error) { - var b = new(bytes.Buffer) - if err := struc.PackWithOptions(b, u.union_data, opt); err != nil { - return 0, err - } - copy(p, b.Bytes()) - return b.Len(), nil -} -func (u *%[1]s) Unpack(r io.Reader, length int, opt *struc.Options) error { - return struc.UnpackWithOptions(r, u.union_data[:], opt) -} -func (u *%[1]s) Size(opt *struc.Options) int { - return len(u.union_data) -} -func (u *%[1]s) String() string { - return string(u.union_data[:]) -} -`, structName) -}*/ - -func generateUnionGetterSetter(w io.Writer, structName string, getterField, getterStruct string) { - fmt.Fprintf(w, ` -func %[1]s%[2]s(a %[3]s) (u %[1]s) { - u.Set%[2]s(a) - return -} -func (u *%[1]s) Set%[2]s(a %[3]s) { - var b = new(bytes.Buffer) - if err := struc.Pack(b, &a); err != nil { - return - } - copy(u.%[4]s[:], b.Bytes()) -} -func (u *%[1]s) Get%[2]s() (a %[3]s) { - var b = bytes.NewReader(u.%[4]s[:]) - struc.Unpack(b, &a) - return -} -`, structName, getterField, getterStruct, unionDataField) -} - -func generateType(ctx *context, w io.Writer, typ *Type) { - name := camelCaseName(typ.Name) - - logf(" writing type %q (%s) with %d fields", typ.Name, name, len(typ.Fields)) - - // generate struct comment - generateComment(ctx, w, name, typ.Name, "type") - - // generate struct definition - fmt.Fprintf(w, "type %s struct {\n", name) - - // generate struct fields - for i, field := range typ.Fields { - // skip internal fields - switch strings.ToLower(field.Name) { - case crcField, msgIdField: - continue - } - - generateField(ctx, w, typ.Fields, i) - } - - // generate end of the struct - fmt.Fprintln(w, "}") - - // generate name getter - generateTypeNameGetter(w, name, typ.Name) - - // generate CRC getter - if typ.CRC != "" { - generateCrcGetter(w, name, typ.CRC) - } - - fmt.Fprintln(w) -} - -func generateMessage(ctx *context, w io.Writer, msg *Message) { - name := camelCaseName(msg.Name) - - logf(" writing message %q (%s) with %d fields", msg.Name, name, len(msg.Fields)) - - // generate struct comment - generateComment(ctx, w, name, msg.Name, "message") - - // generate struct definition - fmt.Fprintf(w, "type %s struct {", name) - - msgType := otherMessage - wasClientIndex := false - - // generate struct fields - n := 0 - for i, field := range msg.Fields { - if i == 1 { - if field.Name == clientIndexField { - // "client_index" as the second member, - // this might be an event message or a request - msgType = eventMessage - wasClientIndex = true - } else if field.Name == contextField { - // reply needs "context" as the second member - msgType = replyMessage - } - } else if i == 2 { - if wasClientIndex && field.Name == contextField { - // request needs "client_index" as the second member - // and "context" as the third member - msgType = requestMessage - } - } - - // skip internal fields - switch strings.ToLower(field.Name) { - case crcField, msgIdField: - continue - case clientIndexField, contextField: - if n == 0 { - continue - } - } - n++ - if n == 1 { - fmt.Fprintln(w) - } - - generateField(ctx, w, msg.Fields, i) - } - - // generate end of the struct - fmt.Fprintln(w, "}") - - // generate message methods - generateMessageResetMethod(w, name) - generateMessageNameGetter(w, name, msg.Name) - generateCrcGetter(w, name, msg.CRC) - generateMessageTypeGetter(w, name, msgType) - - fmt.Fprintln(w) -} - -func generateField(ctx *context, w io.Writer, fields []Field, i int) { - field := fields[i] - - fieldName := strings.TrimPrefix(field.Name, "_") - fieldName = camelCaseName(fieldName) - - dataType := convertToGoType(ctx, field.Type) - fieldType := dataType - - // generate length field for strings - if field.Type == "string" && field.Length == 0 { - fmt.Fprintf(w, "\tXXX_%sLen uint32 `struc:\"sizeof=%s\"`\n", fieldName, fieldName) - } - - // check if it is array - if field.Length > 0 || field.SizeFrom != "" { - if dataType == "uint8" { - dataType = "byte" - } - if dataType == "string" && field.SpecifiedLen { - fieldType = "string" - dataType = "byte" - } else { - fieldType = "[]" + dataType - } - } - fmt.Fprintf(w, "\t%s %s", fieldName, fieldType) - - fieldTags := map[string]string{} - - if field.Length > 0 && field.SpecifiedLen { - // fixed size array - fieldTags["struc"] = fmt.Sprintf("[%d]%s", field.Length, dataType) - } else { - for _, f := range fields { - if f.SizeFrom == field.Name { - // variable sized array - sizeOfName := camelCaseName(f.Name) - fieldTags["struc"] = fmt.Sprintf("sizeof=%s", sizeOfName) - } - } - } - - if ctx.includeBinapiNames { - fieldTags["binapi"] = field.Name - } - if field.Meta.Limit > 0 { - fieldTags["binapi"] = fmt.Sprintf("%s,limit=%d", fieldTags["binapi"], field.Meta.Limit) - } - - if len(fieldTags) > 0 { - fmt.Fprintf(w, "\t`") - var keys []string - for k := range fieldTags { - keys = append(keys, k) - } - sort.Strings(keys) - var n int - for _, tt := range keys { - t, ok := fieldTags[tt] - if !ok { - continue - } - if n > 0 { - fmt.Fprintf(w, " ") - } - n++ - fmt.Fprintf(w, `%s:"%s"`, tt, t) - } - fmt.Fprintf(w, "`") - } - - fmt.Fprintln(w) -} - -func generateMessageResetMethod(w io.Writer, structName string) { - fmt.Fprintf(w, "func (m *%[1]s) Reset() { *m = %[1]s{} }\n", structName) -} - -func generateMessageNameGetter(w io.Writer, structName, msgName string) { - fmt.Fprintf(w, "func (*%s) GetMessageName() string { return %q }\n", structName, msgName) -} - -func generateTypeNameGetter(w io.Writer, structName, msgName string) { - fmt.Fprintf(w, "func (*%s) GetTypeName() string { return %q }\n", structName, msgName) -} - -func generateCrcGetter(w io.Writer, structName, crc string) { - crc = strings.TrimPrefix(crc, "0x") - fmt.Fprintf(w, "func (*%s) GetCrcString() string { return %q }\n", structName, crc) -} - -func generateMessageTypeGetter(w io.Writer, structName string, msgType MessageType) { - fmt.Fprintf(w, "func (*"+structName+") GetMessageType() api.MessageType {") - if msgType == requestMessage { - fmt.Fprintf(w, "\treturn api.RequestMessage") - } else if msgType == replyMessage { - fmt.Fprintf(w, "\treturn api.ReplyMessage") - } else if msgType == eventMessage { - fmt.Fprintf(w, "\treturn api.EventMessage") - } else { - fmt.Fprintf(w, "\treturn api.OtherMessage") - } - fmt.Fprintln(w, "}") - fmt.Fprintln(w) -} - -func generateServices(ctx *context, w io.Writer, services []Service) { - - // generate services comment - generateComment(ctx, w, serviceApiName, "services", "service") - - // generate service api - fmt.Fprintf(w, "type %s interface {\n", serviceApiName) - for _, svc := range services { - generateServiceMethod(ctx, w, &svc) - fmt.Fprintln(w) - } - fmt.Fprintln(w, "}") - fmt.Fprintln(w) - - // generate client implementation - fmt.Fprintf(w, "type %s struct {\n", serviceImplName) - fmt.Fprintf(w, "\tch api.Channel\n") - fmt.Fprintln(w, "}") - fmt.Fprintln(w) - - // generate client constructor - fmt.Fprintf(w, "func New%s(ch api.Channel) %s {\n", serviceClientName, serviceApiName) - fmt.Fprintf(w, "\treturn &%s{ch}\n", serviceImplName) - fmt.Fprintln(w, "}") - fmt.Fprintln(w) - - for _, svc := range services { - method := camelCaseName(svc.RequestType) - if m := strings.TrimSuffix(method, "Dump"); method != m { - method = "Dump" + m - } - - fmt.Fprintf(w, "func (c *%s) ", serviceImplName) - generateServiceMethod(ctx, w, &svc) - fmt.Fprintln(w, " {") - if svc.Stream { - streamImpl := fmt.Sprintf("%s_%sClient", serviceImplName, method) - fmt.Fprintf(w, "\tstream := c.ch.SendMultiRequest(in)\n") - fmt.Fprintf(w, "\tx := &%s{stream}\n", streamImpl) - fmt.Fprintf(w, "\treturn x, nil\n") - } else if replyTyp := camelCaseName(svc.ReplyType); replyTyp != "" { - fmt.Fprintf(w, "\tout := new(%s)\n", replyTyp) - fmt.Fprintf(w, "\terr:= c.ch.SendRequest(in).ReceiveReply(out)\n") - fmt.Fprintf(w, "\tif err != nil { return nil, err }\n") - fmt.Fprintf(w, "\treturn out, nil\n") - } else { - fmt.Fprintf(w, "\tc.ch.SendRequest(in)\n") - fmt.Fprintf(w, "\treturn nil\n") - } - fmt.Fprintln(w, "}") - fmt.Fprintln(w) - - if svc.Stream { - replyTyp := camelCaseName(svc.ReplyType) - method := camelCaseName(svc.RequestType) - if m := strings.TrimSuffix(method, "Dump"); method != m { - method = "Dump" + m - } - streamApi := fmt.Sprintf("%s_%sClient", serviceApiName, method) - - fmt.Fprintf(w, "type %s interface {\n", streamApi) - fmt.Fprintf(w, "\tRecv() (*%s, error)\n", replyTyp) - fmt.Fprintln(w, "}") - fmt.Fprintln(w) - - streamImpl := fmt.Sprintf("%s_%sClient", serviceImplName, method) - fmt.Fprintf(w, "type %s struct {\n", streamImpl) - fmt.Fprintf(w, "\tapi.MultiRequestCtx\n") - fmt.Fprintln(w, "}") - fmt.Fprintln(w) - - fmt.Fprintf(w, "func (c *%s) Recv() (*%s, error) {\n", streamImpl, replyTyp) - fmt.Fprintf(w, "\tm := new(%s)\n", replyTyp) - fmt.Fprintf(w, "\tstop, err := c.MultiRequestCtx.ReceiveReply(m)\n") - fmt.Fprintf(w, "\tif err != nil { return nil, err }\n") - fmt.Fprintf(w, "\tif stop { return nil, io.EOF }\n") - fmt.Fprintf(w, "\treturn m, nil\n") - fmt.Fprintln(w, "}") - fmt.Fprintln(w) - } - } - - fmt.Fprintln(w) -} - -func generateServiceMethod(ctx *context, w io.Writer, svc *Service) { - reqTyp := camelCaseName(svc.RequestType) - - // method name is same as parameter type name by default - method := reqTyp - if svc.Stream { - // use Dump as prefix instead of suffix for stream services - if m := strings.TrimSuffix(method, "Dump"); method != m { - method = "Dump" + m - } - } - - params := fmt.Sprintf("in *%s", reqTyp) - returns := "error" - - if replyType := camelCaseName(svc.ReplyType); replyType != "" { - var replyTyp string - if svc.Stream { - replyTyp = fmt.Sprintf("%s_%sClient", serviceApiName, method) - } else { - replyTyp = fmt.Sprintf("*%s", replyType) - } - returns = fmt.Sprintf("(%s, error)", replyTyp) - } - - fmt.Fprintf(w, "\t%s(ctx context.Context, %s) %s", method, params, returns) -} diff --git a/cmd/binapi-generator/main.go b/cmd/binapi-generator/main.go index dfe7c3a3..8d020a8d 100644 --- a/cmd/binapi-generator/main.go +++ b/cmd/binapi-generator/main.go @@ -15,324 +15,100 @@ package main import ( - "bytes" - "encoding/json" - "flag" "fmt" - "go/format" - "io/ioutil" "os" "path/filepath" - "strings" - "github.com/bennyscetbun/jsongo" "github.com/sirupsen/logrus" + "github.com/spf13/pflag" - "github.com/alkiranet/govpp/version" + "github.com/alkiranet/govpp/binapigen" + "github.com/alkiranet/govpp/binapigen/vppapi" + "github.com/alkiranet/govpp/internal/version" ) -var ( - theInputFile = flag.String("input-file", "", "Input file with VPP API in JSON format.") - theInputTypes = flag.String("input-types", "", "Types input file with VPP API in JSON format. (split by comma)") - theInputDir = flag.String("input-dir", "/usr/share/vpp/api", "Input directory with VPP API files in JSON format.") - theOutputDir = flag.String("output-dir", ".", "Output directory where package folders will be generated.") +const ( + DefaultOutputDir = "binapi" +) - includeAPIVer = flag.Bool("include-apiver", true, "Include APIVersion constant for each module.") - includeServices = flag.Bool("include-services", true, "Include RPC service api and client implementation.") - includeComments = flag.Bool("include-comments", false, "Include JSON API source in comments for each object.") - includeBinapiNames = flag.Bool("include-binapi-names", false, "Include binary API names in struct tag.") - importPrefix = flag.String("import-prefix", "", "Define import path prefix to be used to import types.") +var ( + input = pflag.String("input", "", "Input for VPP API (e.g. path to VPP API directory, local VPP repo)") + inputDir = pflag.String("input-dir", "", "DEPRECATED: Input directory containing API files.") + theOutputDir = pflag.StringP("output-dir", "o", DefaultOutputDir, "Output directory where code will be generated.") + runPlugins = pflag.StringSlice("gen", []string{"rpc"}, "List of generator plugins to run for files.") + importPrefix = pflag.String("import-prefix", "", "Prefix imports in the generated go code. \nE.g. other API Files (e.g. api_file.ba.go) will be imported with :\nimport (\n api_file \"/api_file\"\n)") - continueOnError = flag.Bool("continue-onerror", false, "Continue with next file on error.") - debugMode = flag.Bool("debug", os.Getenv("GOVPP_DEBUG") != "", "Enable debug mode.") + noVersionInfo = pflag.Bool("no-version-info", false, "Disable version info in generated files.") + noSourcePathInfo = pflag.Bool("no-source-path-info", false, "Disable source path info in generated files.") - printVersion = flag.Bool("version", false, "Prints current version and exits.") + printVersion = pflag.Bool("version", false, "Prints version and exits.") + enableDebug = pflag.Bool("debug", false, "Enable debugging mode.") ) -func main() { - flag.Parse() - - if flag.NArg() > 1 { - flag.Usage() - os.Exit(1) +func init() { + pflag.Usage = func() { + fmt.Fprintf(os.Stderr, "USAGE\n") + fmt.Fprintf(os.Stderr, " Parse API_FILES and generate Go bindings\n") + fmt.Fprintf(os.Stderr, " Provide API_FILES by file name, or with full path including extension.\n") + fmt.Fprintf(os.Stderr, " %s [OPTION] API_FILES\n\n", os.Args[0]) + fmt.Fprintf(os.Stderr, "OPTIONS\n") + pflag.PrintDefaults() + fmt.Fprintf(os.Stderr, "\nEXAMPLES:\n") + fmt.Fprintf(os.Stderr, " %s \\\n", os.Args[0]) + fmt.Fprintf(os.Stderr, " --input=$VPP/build-root/install-vpp-native/vpp/share/vpp/api/ \\\n") + fmt.Fprintf(os.Stderr, " --output-dir=~/output \\\n") + fmt.Fprintf(os.Stderr, " interface ip\n") + fmt.Fprintf(os.Stderr, "\n") } +} - if flag.NArg() > 0 { - switch cmd := flag.Arg(0); cmd { - case "version": - fmt.Fprintln(os.Stdout, version.Verbose()) - os.Exit(0) - - default: - fmt.Fprintf(os.Stderr, "unknown command: %s\n", cmd) - flag.Usage() - os.Exit(2) - } - } +func main() { + pflag.Parse() if *printVersion { fmt.Fprintln(os.Stdout, version.Info()) os.Exit(0) } - if *debugMode { + if *enableDebug { logrus.SetLevel(logrus.DebugLevel) - logrus.Info("debug mode enabled") - } - - if err := run(*theInputFile, *theInputDir, *theOutputDir, *continueOnError); err != nil { - logrus.Errorln("binapi-generator:", err) - os.Exit(1) - } -} - -func run(inputFile, inputDir string, outputDir string, continueErr bool) (err error) { - if inputFile == "" && inputDir == "" { - return fmt.Errorf("input-file or input-dir must be specified") } - var typesPkgs []*context - if *theInputTypes != "" { - types := strings.Split(*theInputTypes, ",") - typesPkgs, err = loadTypesPackages(types...) - if err != nil { - return fmt.Errorf("loading types input failed: %v", err) - } - } + var filesToGenerate []string + filesToGenerate = append(filesToGenerate, pflag.Args()...) - if inputFile != "" { - // process one input file - if err := generateFromFile(inputFile, outputDir, typesPkgs); err != nil { - return fmt.Errorf("code generation from %s failed: %v\n", inputFile, err) - } - } else { - // process all files in specified directory - dir, err := filepath.Abs(inputDir) - if err != nil { - return fmt.Errorf("invalid input directory: %v\n", err) - } - files, err := getInputFiles(inputDir, 1) - if err != nil { - return fmt.Errorf("problem getting files from input directory: %v\n", err) - } else if len(files) == 0 { - return fmt.Errorf("no input files found in input directory: %v\n", dir) - } - for _, file := range files { - if err := generateFromFile(file, outputDir, typesPkgs); err != nil { - if continueErr { - logrus.Warnf("code generation from %s failed: %v (error ignored)\n", file, err) - continue - } else { - return fmt.Errorf("code generation from %s failed: %v\n", file, err) - } - } - } + opts := binapigen.Options{ + ImportPrefix: *importPrefix, + OutputDir: *theOutputDir, + NoVersionInfo: *noVersionInfo, + NoSourcePathInfo: *noSourcePathInfo, + GenerateFiles: filesToGenerate, } - return nil -} - -// getInputFiles returns all input files located in specified directory -func getInputFiles(inputDir string, deep int) (files []string, err error) { - entries, err := ioutil.ReadDir(inputDir) - if err != nil { - return nil, fmt.Errorf("reading directory %s failed: %v", inputDir, err) - } - for _, e := range entries { - if e.IsDir() && deep > 0 { - nestedDir := filepath.Join(inputDir, e.Name()) - if nested, err := getInputFiles(nestedDir, deep-1); err != nil { - return nil, err - } else { - files = append(files, nested...) - } - } else if strings.HasSuffix(e.Name(), inputFileExt) { - files = append(files, filepath.Join(inputDir, e.Name())) + // generate in same directory when current dir is binapi + if opts.OutputDir == DefaultOutputDir { + if wd, _ := os.Getwd(); filepath.Base(wd) == DefaultOutputDir { + opts.OutputDir = "." } } - return files, nil -} - -func parseInputJSON(inputData []byte) (*jsongo.Node, error) { - jsonRoot := new(jsongo.Node) - if err := json.Unmarshal(inputData, jsonRoot); err != nil { - return nil, fmt.Errorf("unmarshalling JSON failed: %v", err) - } - return jsonRoot, nil -} - -// generateFromFile generates Go package from one input JSON file -func generateFromFile(inputFile, outputDir string, typesPkgs []*context) error { - // create generator context - ctx, err := newContext(inputFile, outputDir) - if err != nil { - return err - } - logf("------------------------------------------------------------") - logf("module: %s", ctx.moduleName) - logf(" - input: %s", ctx.inputFile) - logf(" - output: %s", ctx.outputFile) - logf("------------------------------------------------------------") + theInputDir := *inputDir + theInput := *input + genPlugins := *runPlugins - // prepare options - ctx.includeAPIVersion = *includeAPIVer - ctx.includeComments = *includeComments - ctx.includeBinapiNames = *includeBinapiNames - ctx.includeServices = *includeServices - ctx.importPrefix = *importPrefix - - // read API definition from input file - ctx.inputData, err = ioutil.ReadFile(ctx.inputFile) - if err != nil { - return fmt.Errorf("reading input file %s failed: %v", ctx.inputFile, err) - } - // parse JSON data into objects - jsonRoot, err := parseInputJSON(ctx.inputData) - if err != nil { - return fmt.Errorf("parsing JSON input failed: %v", err) - } - ctx.packageData, err = parsePackage(ctx, jsonRoot) - if err != nil { - return fmt.Errorf("parsing package %s failed: %v", ctx.packageName, err) - } - - if len(typesPkgs) > 0 { - err = loadTypeAliases(ctx, typesPkgs) - if err != nil { - return fmt.Errorf("loading type aliases failed: %v", err) + if theInputDir != "" { + if theInput != "" { + logrus.Fatalf("ignoring deprecated option 'input-dir', using 'input' instead") + } else { + theInput = theInputDir } } - // generate Go package - var buf bytes.Buffer - if err := generatePackage(ctx, &buf); err != nil { - return fmt.Errorf("generating Go package for %s failed: %v", ctx.packageName, err) - } - // format generated source code - gosrc, err := format.Source(buf.Bytes()) + vppInput, err := vppapi.ResolveVppInput(theInput) if err != nil { - return fmt.Errorf("formatting source code for package %s failed: %v", ctx.packageName, err) - } - - // create output directory - packageDir := filepath.Dir(ctx.outputFile) - if err := os.MkdirAll(packageDir, 0775); err != nil { - return fmt.Errorf("creating output dir %s failed: %v", packageDir, err) - } - // write generated code to output file - if err := ioutil.WriteFile(ctx.outputFile, gosrc, 0666); err != nil { - return fmt.Errorf("writing to output file %s failed: %v", ctx.outputFile, err) - } - - return nil -} - -func loadTypesPackages(types ...string) ([]*context, error) { - var ctxs []*context - for _, inputFile := range types { - // create generator context - ctx, err := newContext(inputFile, "") - if err != nil { - return nil, err - } - // read API definition from input file - ctx.inputData, err = ioutil.ReadFile(ctx.inputFile) - if err != nil { - return nil, fmt.Errorf("reading input file %s failed: %v", ctx.inputFile, err) - } - // parse JSON data into objects - jsonRoot, err := parseInputJSON(ctx.inputData) - if err != nil { - return nil, fmt.Errorf("parsing JSON input failed: %v", err) - } - ctx.packageData, err = parsePackage(ctx, jsonRoot) - if err != nil { - return nil, fmt.Errorf("parsing package %s failed: %v", ctx.packageName, err) - } - ctxs = append(ctxs, ctx) - } - return ctxs, nil -} - -func loadTypeAliases(ctx *context, typesCtxs []*context) error { - for _, t := range ctx.packageData.Types { - for _, c := range typesCtxs { - if _, ok := ctx.packageData.Imports[t.Name]; ok { - break - } - for _, at := range c.packageData.Types { - if at.Name != t.Name { - continue - } - if len(at.Fields) != len(t.Fields) { - continue - } - ctx.packageData.Imports[t.Name] = Import{ - Package: c.packageName, - } - } - } + logrus.Fatal(err) } - for _, t := range ctx.packageData.Aliases { - for _, c := range typesCtxs { - if _, ok := ctx.packageData.Imports[t.Name]; ok { - break - } - for _, at := range c.packageData.Aliases { - if at.Name != t.Name { - continue - } - if at.Length != t.Length { - continue - } - if at.Type != t.Type { - continue - } - ctx.packageData.Imports[t.Name] = Import{ - Package: c.packageName, - } - } - } - } - for _, t := range ctx.packageData.Enums { - for _, c := range typesCtxs { - if _, ok := ctx.packageData.Imports[t.Name]; ok { - break - } - for _, at := range c.packageData.Enums { - if at.Name != t.Name { - continue - } - if at.Type != t.Type { - continue - } - ctx.packageData.Imports[t.Name] = Import{ - Package: c.packageName, - } - } - } - } - for _, t := range ctx.packageData.Unions { - for _, c := range typesCtxs { - if _, ok := ctx.packageData.Imports[t.Name]; ok { - break - } - for _, at := range c.packageData.Unions { - if at.Name != t.Name { - continue - } - ctx.packageData.Imports[t.Name] = Import{ - Package: c.packageName, - } - } - } - } - return nil -} + logrus.Debugf("resolved VPP input: %+v", vppInput) -func logf(f string, v ...interface{}) { - if *debugMode { - logrus.Debugf(f, v...) - } + binapigen.Run(vppInput, opts, binapigen.GeneratePlugins(genPlugins)) } diff --git a/cmd/binapi-generator/objects.go b/cmd/binapi-generator/objects.go deleted file mode 100644 index 9871abc5..00000000 --- a/cmd/binapi-generator/objects.go +++ /dev/null @@ -1,139 +0,0 @@ -package main - -import "fmt" - -// Package represents collection of objects parsed from VPP binary API JSON data -type Package struct { - Name string - Version string - CRC string - Services []Service - Enums []Enum - Aliases []Alias - Types []Type - Unions []Union - Messages []Message - RefMap map[string]string - Imports map[string]Import -} - -type Import struct { - Package string -} - -// Service represents VPP binary API service -type Service struct { - Name string - RequestType string - ReplyType string - Stream bool - Events []string -} - -// Enum represents VPP binary API enum -type Enum struct { - Name string - Type string - Entries []EnumEntry -} - -// EnumEntry represents VPP binary API enum entry -type EnumEntry struct { - Name string - Value interface{} -} - -// Alias represents VPP binary API alias -type Alias struct { - Name string - Type string - Length int -} - -// Type represents VPP binary API type -type Type struct { - Name string - CRC string - Fields []Field -} - -// Field represents VPP binary API object field -type Field struct { - Name string - Type string - Length int - SpecifiedLen bool - SizeFrom string - Meta FieldMeta -} - -// FieldMeta represents VPP binary API meta info for field -type FieldMeta struct { - Limit int - Default string -} - -// Union represents VPP binary API union -type Union struct { - Name string - CRC string - Fields []Field -} - -// Message represents VPP binary API message -type Message struct { - Name string - CRC string - Fields []Field -} - -// MessageType represents the type of a VPP message -type MessageType int - -const ( - requestMessage MessageType = iota // VPP request message - replyMessage // VPP reply message - eventMessage // VPP event message - otherMessage // other VPP message -) - -// printPackage prints all loaded objects for package -func printPackage(pkg *Package) { - logf("package: %s %s (%s)", pkg.Name, pkg.Version, pkg.CRC) - if len(pkg.Enums) > 0 { - logf(" %d enums:", len(pkg.Enums)) - for _, enum := range pkg.Enums { - logf(" - %s: %+v", enum.Name, enum) - } - } - if len(pkg.Unions) > 0 { - logf(" %d unions:", len(pkg.Unions)) - for _, union := range pkg.Unions { - logf(" - %s: %+v", union.Name, union) - } - } - if len(pkg.Types) > 0 { - logf(" %d types:", len(pkg.Types)) - for _, typ := range pkg.Types { - logf(" - %s (%d fields): %+v", typ.Name, len(typ.Fields), typ) - } - } - if len(pkg.Messages) > 0 { - logf(" %d messages:", len(pkg.Messages)) - for _, msg := range pkg.Messages { - logf(" - %s (%d fields) %s", msg.Name, len(msg.Fields), msg.CRC) - } - } - if len(pkg.Services) > 0 { - logf(" %d services:", len(pkg.Services)) - for _, svc := range pkg.Services { - var info string - if svc.Stream { - info = "(STREAM)" - } else if len(svc.Events) > 0 { - info = fmt.Sprintf("(EVENTS: %v)", svc.Events) - } - logf(" - %s: %q -> %q %s", svc.Name, svc.RequestType, svc.ReplyType, info) - } - } -} diff --git a/cmd/binapi-generator/parse.go b/cmd/binapi-generator/parse.go deleted file mode 100644 index 6598b7bf..00000000 --- a/cmd/binapi-generator/parse.go +++ /dev/null @@ -1,557 +0,0 @@ -// Copyright (c) 2018 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 main - -import ( - "errors" - "fmt" - "sort" - "strings" - - "github.com/bennyscetbun/jsongo" - "github.com/sirupsen/logrus" -) - -// top level objects -const ( - objTypes = "types" - objMessages = "messages" - objUnions = "unions" - objEnums = "enums" - objServices = "services" - objAliases = "aliases" - vlAPIVersion = "vl_api_version" - objOptions = "options" -) - -// various object fields -const ( - crcField = "crc" - msgIdField = "_vl_msg_id" - - clientIndexField = "client_index" - contextField = "context" - - aliasLengthField = "length" - aliasTypeField = "type" - - replyField = "reply" - streamField = "stream" - eventsField = "events" -) - -// service name parts -const ( - serviceEventPrefix = "want_" - serviceDumpSuffix = "_dump" - serviceDetailsSuffix = "_details" - serviceReplySuffix = "_reply" - serviceNoReply = "null" -) - -// field meta info -const ( - fieldMetaLimit = "limit" - fieldMetaDefault = "default" -) - -// module options -const ( - versionOption = "version" -) - -// parsePackage parses provided JSON data into objects prepared for code generation -func parsePackage(ctx *context, jsonRoot *jsongo.Node) (*Package, error) { - pkg := Package{ - Name: ctx.packageName, - RefMap: make(map[string]string), - Imports: map[string]Import{}, - } - - // parse CRC for API version - if crc := jsonRoot.At(vlAPIVersion); crc.GetType() == jsongo.TypeValue { - pkg.CRC = crc.Get().(string) - } - - // parse version string - if opt := jsonRoot.Map(objOptions); opt.GetType() == jsongo.TypeMap { - if ver := opt.Map(versionOption); ver.GetType() == jsongo.TypeValue { - pkg.Version = ver.Get().(string) - } - } - - logf("parsing package %s (version: %s, CRC: %s)", pkg.Name, pkg.Version, pkg.CRC) - logf(" consists of:") - for _, key := range jsonRoot.GetKeys() { - logf(" - %d %s", jsonRoot.At(key).Len(), key) - } - - // parse enums - enums := jsonRoot.Map(objEnums) - pkg.Enums = make([]Enum, 0) - for i := 0; i < enums.Len(); i++ { - enumNode := enums.At(i) - - enum, err := parseEnum(ctx, enumNode) - if err != nil { - return nil, err - } - - enumApi := toApiType(enum.Name) - if _, ok := pkg.RefMap[enumApi]; ok { - logf("enum %v already known", enumApi) - continue - } - pkg.RefMap[enumApi] = enum.Name - pkg.Enums = append(pkg.Enums, *enum) - } - // sort enums - sort.SliceStable(pkg.Enums, func(i, j int) bool { - return pkg.Enums[i].Name < pkg.Enums[j].Name - }) - - // parse aliases - aliases := jsonRoot.Map(objAliases) - if aliases.GetType() == jsongo.TypeMap { - pkg.Aliases = make([]Alias, 0) - for _, key := range aliases.GetKeys() { - aliasNode := aliases.At(key) - - alias, err := parseAlias(ctx, key.(string), aliasNode) - if err != nil { - return nil, err - } - - aliasApi := toApiType(alias.Name) - if _, ok := pkg.RefMap[aliasApi]; ok { - logf("alias %v already known", aliasApi) - continue - } - pkg.RefMap[aliasApi] = alias.Name - pkg.Aliases = append(pkg.Aliases, *alias) - } - } - // sort aliases to ensure consistent order - sort.Slice(pkg.Aliases, func(i, j int) bool { - return pkg.Aliases[i].Name < pkg.Aliases[j].Name - }) - - // parse types - types := jsonRoot.Map(objTypes) - pkg.Types = make([]Type, 0) - for i := 0; i < types.Len(); i++ { - typNode := types.At(i) - - typ, err := parseType(ctx, typNode) - if err != nil { - return nil, err - } - - typApi := toApiType(typ.Name) - if _, ok := pkg.RefMap[typApi]; ok { - logf("type %v already known", typApi) - continue - } - pkg.RefMap[typApi] = typ.Name - pkg.Types = append(pkg.Types, *typ) - } - // sort types - sort.SliceStable(pkg.Types, func(i, j int) bool { - return pkg.Types[i].Name < pkg.Types[j].Name - }) - - // parse unions - unions := jsonRoot.Map(objUnions) - pkg.Unions = make([]Union, 0) - for i := 0; i < unions.Len(); i++ { - unionNode := unions.At(i) - - union, err := parseUnion(ctx, unionNode) - if err != nil { - return nil, err - } - - unionApi := toApiType(union.Name) - if _, ok := pkg.RefMap[unionApi]; ok { - logf("union %v already known", unionApi) - continue - } - pkg.RefMap[unionApi] = union.Name - pkg.Unions = append(pkg.Unions, *union) - } - // sort unions - sort.SliceStable(pkg.Unions, func(i, j int) bool { - return pkg.Unions[i].Name < pkg.Unions[j].Name - }) - - // parse messages - messages := jsonRoot.Map(objMessages) - pkg.Messages = make([]Message, messages.Len()) - for i := 0; i < messages.Len(); i++ { - msgNode := messages.At(i) - - msg, err := parseMessage(ctx, msgNode) - if err != nil { - return nil, err - } - pkg.Messages[i] = *msg - } - // sort messages - sort.SliceStable(pkg.Messages, func(i, j int) bool { - return pkg.Messages[i].Name < pkg.Messages[j].Name - }) - - // parse services - services := jsonRoot.Map(objServices) - if services.GetType() == jsongo.TypeMap { - pkg.Services = make([]Service, services.Len()) - for i, key := range services.GetKeys() { - svcNode := services.At(key) - - svc, err := parseService(ctx, key.(string), svcNode) - if err != nil { - return nil, err - } - pkg.Services[i] = *svc - } - } - // sort services - sort.Slice(pkg.Services, func(i, j int) bool { - // dumps first - if pkg.Services[i].Stream != pkg.Services[j].Stream { - return pkg.Services[i].Stream - } - return pkg.Services[i].RequestType < pkg.Services[j].RequestType - }) - - printPackage(&pkg) - - return &pkg, nil -} - -// parseEnum parses VPP binary API enum object from JSON node -func parseEnum(ctx *context, enumNode *jsongo.Node) (*Enum, error) { - if enumNode.Len() == 0 || enumNode.At(0).GetType() != jsongo.TypeValue { - return nil, errors.New("invalid JSON for enum specified") - } - - enumName, ok := enumNode.At(0).Get().(string) - if !ok { - return nil, fmt.Errorf("enum name is %T, not a string", enumNode.At(0).Get()) - } - enumType, ok := enumNode.At(enumNode.Len() - 1).At("enumtype").Get().(string) - if !ok { - return nil, fmt.Errorf("enum type invalid or missing") - } - - enum := Enum{ - Name: enumName, - Type: enumType, - } - - // loop through enum entries, skip first (name) and last (enumtype) - for j := 1; j < enumNode.Len()-1; j++ { - if enumNode.At(j).GetType() == jsongo.TypeArray { - entry := enumNode.At(j) - - if entry.Len() < 2 || entry.At(0).GetType() != jsongo.TypeValue || entry.At(1).GetType() != jsongo.TypeValue { - return nil, errors.New("invalid JSON for enum entry specified") - } - - entryName, ok := entry.At(0).Get().(string) - if !ok { - return nil, fmt.Errorf("enum entry name is %T, not a string", entry.At(0).Get()) - } - entryVal := entry.At(1).Get() - - enum.Entries = append(enum.Entries, EnumEntry{ - Name: entryName, - Value: entryVal, - }) - } - } - - return &enum, nil -} - -// parseUnion parses VPP binary API union object from JSON node -func parseUnion(ctx *context, unionNode *jsongo.Node) (*Union, error) { - if unionNode.Len() == 0 || unionNode.At(0).GetType() != jsongo.TypeValue { - return nil, errors.New("invalid JSON for union specified") - } - - unionName, ok := unionNode.At(0).Get().(string) - if !ok { - return nil, fmt.Errorf("union name is %T, not a string", unionNode.At(0).Get()) - } - var unionCRC string - if unionNode.At(unionNode.Len()-1).GetType() == jsongo.TypeMap { - unionCRC = unionNode.At(unionNode.Len() - 1).At(crcField).Get().(string) - } - - union := Union{ - Name: unionName, - CRC: unionCRC, - } - - // loop through union fields, skip first (name) - for j := 1; j < unionNode.Len(); j++ { - if unionNode.At(j).GetType() == jsongo.TypeArray { - fieldNode := unionNode.At(j) - - field, err := parseField(ctx, fieldNode) - if err != nil { - return nil, err - } - - union.Fields = append(union.Fields, *field) - } - } - - return &union, nil -} - -// parseType parses VPP binary API type object from JSON node -func parseType(ctx *context, typeNode *jsongo.Node) (*Type, error) { - if typeNode.Len() == 0 || typeNode.At(0).GetType() != jsongo.TypeValue { - return nil, errors.New("invalid JSON for type specified") - } - - typeName, ok := typeNode.At(0).Get().(string) - if !ok { - return nil, fmt.Errorf("type name is %T, not a string", typeNode.At(0).Get()) - } - var typeCRC string - if lastField := typeNode.At(typeNode.Len() - 1); lastField.GetType() == jsongo.TypeMap { - typeCRC = lastField.At(crcField).Get().(string) - } - - typ := Type{ - Name: typeName, - CRC: typeCRC, - } - - // loop through type fields, skip first (name) - for j := 1; j < typeNode.Len(); j++ { - if typeNode.At(j).GetType() == jsongo.TypeArray { - fieldNode := typeNode.At(j) - - field, err := parseField(ctx, fieldNode) - if err != nil { - return nil, err - } - - typ.Fields = append(typ.Fields, *field) - } - } - - return &typ, nil -} - -// parseAlias parses VPP binary API alias object from JSON node -func parseAlias(ctx *context, aliasName string, aliasNode *jsongo.Node) (*Alias, error) { - if aliasNode.Len() == 0 || aliasNode.At(aliasTypeField).GetType() != jsongo.TypeValue { - return nil, errors.New("invalid JSON for alias specified") - } - - alias := Alias{ - Name: aliasName, - } - - if typeNode := aliasNode.At(aliasTypeField); typeNode.GetType() == jsongo.TypeValue { - typ, ok := typeNode.Get().(string) - if !ok { - return nil, fmt.Errorf("alias type is %T, not a string", typeNode.Get()) - } - if typ != "null" { - alias.Type = typ - } - } - - if lengthNode := aliasNode.At(aliasLengthField); lengthNode.GetType() == jsongo.TypeValue { - length, ok := lengthNode.Get().(float64) - if !ok { - return nil, fmt.Errorf("alias length is %T, not a float64", lengthNode.Get()) - } - alias.Length = int(length) - } - - return &alias, nil -} - -// parseMessage parses VPP binary API message object from JSON node -func parseMessage(ctx *context, msgNode *jsongo.Node) (*Message, error) { - if msgNode.Len() == 0 || msgNode.At(0).GetType() != jsongo.TypeValue { - return nil, errors.New("invalid JSON for message specified") - } - - msgName, ok := msgNode.At(0).Get().(string) - if !ok { - return nil, fmt.Errorf("message name is %T, not a string", msgNode.At(0).Get()) - } - msgCRC, ok := msgNode.At(msgNode.Len() - 1).At(crcField).Get().(string) - if !ok { - - return nil, fmt.Errorf("message crc invalid or missing") - } - - msg := Message{ - Name: msgName, - CRC: msgCRC, - } - - // loop through message fields, skip first (name) and last (crc) - for j := 1; j < msgNode.Len()-1; j++ { - if msgNode.At(j).GetType() == jsongo.TypeArray { - fieldNode := msgNode.At(j) - - field, err := parseField(ctx, fieldNode) - if err != nil { - return nil, err - } - - msg.Fields = append(msg.Fields, *field) - } - } - - return &msg, nil -} - -// parseField parses VPP binary API object field from JSON node -func parseField(ctx *context, field *jsongo.Node) (*Field, error) { - if field.Len() < 2 || field.At(0).GetType() != jsongo.TypeValue || field.At(1).GetType() != jsongo.TypeValue { - return nil, errors.New("invalid JSON for field specified") - } - - fieldType, ok := field.At(0).Get().(string) - if !ok { - return nil, fmt.Errorf("field type is %T, not a string", field.At(0).Get()) - } - fieldName, ok := field.At(1).Get().(string) - if !ok { - return nil, fmt.Errorf("field name is %T, not a string", field.At(1).Get()) - } - - f := &Field{ - Name: fieldName, - Type: fieldType, - } - - if field.Len() >= 3 { - switch field.At(2).GetType() { - case jsongo.TypeValue: - fieldLength, ok := field.At(2).Get().(float64) - if !ok { - return nil, fmt.Errorf("field length is %T, not float64", field.At(2).Get()) - } - f.Length = int(fieldLength) - f.SpecifiedLen = true - - case jsongo.TypeMap: - fieldMeta := field.At(2) - - for _, key := range fieldMeta.GetKeys() { - metaNode := fieldMeta.At(key) - - switch metaName := key.(string); metaName { - case fieldMetaLimit: - f.Meta.Limit = int(metaNode.Get().(float64)) - case fieldMetaDefault: - f.Meta.Default = fmt.Sprint(metaNode.Get()) - default: - logrus.Warnf("unknown meta info (%s) for field (%s)", metaName, fieldName) - } - } - default: - return nil, errors.New("invalid JSON for field specified") - } - } - if field.Len() >= 4 { - fieldLengthFrom, ok := field.At(3).Get().(string) - if !ok { - return nil, fmt.Errorf("field length from is %T, not a string", field.At(3).Get()) - } - f.SizeFrom = fieldLengthFrom - } - - return f, nil -} - -// parseService parses VPP binary API service object from JSON node -func parseService(ctx *context, svcName string, svcNode *jsongo.Node) (*Service, error) { - if svcNode.Len() == 0 || svcNode.At(replyField).GetType() != jsongo.TypeValue { - return nil, errors.New("invalid JSON for service specified") - } - - svc := Service{ - Name: svcName, - RequestType: svcName, - } - - if replyNode := svcNode.At(replyField); replyNode.GetType() == jsongo.TypeValue { - reply, ok := replyNode.Get().(string) - if !ok { - return nil, fmt.Errorf("service reply is %T, not a string", replyNode.Get()) - } - if reply != serviceNoReply { - svc.ReplyType = reply - } - } - - // stream service (dumps) - if streamNode := svcNode.At(streamField); streamNode.GetType() == jsongo.TypeValue { - var ok bool - svc.Stream, ok = streamNode.Get().(bool) - if !ok { - return nil, fmt.Errorf("service stream is %T, not a string", streamNode.Get()) - } - } - - // events service (event subscription) - if eventsNode := svcNode.At(eventsField); eventsNode.GetType() == jsongo.TypeArray { - for j := 0; j < eventsNode.Len(); j++ { - event := eventsNode.At(j).Get().(string) - svc.Events = append(svc.Events, event) - } - } - - // validate service - if len(svc.Events) > 0 { - // EVENT service - if !strings.HasPrefix(svc.RequestType, serviceEventPrefix) { - logrus.Debugf("unusual EVENTS service: %+v\n"+ - "- events service %q does not have %q prefix in request.", - svc, svc.Name, serviceEventPrefix) - } - } else if svc.Stream { - // STREAM service - if !strings.HasSuffix(svc.RequestType, serviceDumpSuffix) || - !strings.HasSuffix(svc.ReplyType, serviceDetailsSuffix) { - logrus.Debugf("unusual STREAM service: %+v\n"+ - "- stream service %q does not have %q suffix in request or reply does not have %q suffix.", - svc, svc.Name, serviceDumpSuffix, serviceDetailsSuffix) - } - } else if svc.ReplyType != "" && svc.ReplyType != serviceNoReply { - // REQUEST service - // some messages might have `null` reply (for example: memclnt) - if !strings.HasSuffix(svc.ReplyType, serviceReplySuffix) { - logrus.Debugf("unusual REQUEST service: %+v\n"+ - "- service %q does not have %q suffix in reply.", - svc, svc.Name, serviceReplySuffix) - } - } - - return &svc, nil -} diff --git a/cmd/binapi-generator/parse_test.go b/cmd/binapi-generator/parse_test.go deleted file mode 100644 index e1459790..00000000 --- a/cmd/binapi-generator/parse_test.go +++ /dev/null @@ -1,97 +0,0 @@ -package main - -import ( - "testing" -) - -func TestBinapiTypeSizes(t *testing.T) { - tests := []struct { - name string - input string - expsize int - }{ - {name: "basic1", input: "u8", expsize: 1}, - {name: "basic2", input: "i8", expsize: 1}, - {name: "basic3", input: "u16", expsize: 2}, - {name: "basic4", input: "i32", expsize: 4}, - {name: "invalid1", input: "x", expsize: -1}, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - size := getBinapiTypeSize(test.input) - if size != test.expsize { - t.Errorf("expected %d, got %d", test.expsize, size) - } - }) - } -} - -func TestSizeOfType(t *testing.T) { - tests := []struct { - name string - input Type - expsize int - }{ - { - name: "basic1", - input: Type{ - Fields: []Field{ - {Type: "u8"}, - }, - }, - expsize: 1, - }, - { - name: "basic2", - input: Type{ - Fields: []Field{ - {Type: "u8", Length: 4}, - }, - }, - expsize: 4, - }, - { - name: "basic3", - input: Type{ - Fields: []Field{ - {Type: "u8", Length: 16}, - }, - }, - expsize: 16, - }, - { - name: "withEnum", - input: Type{ - Fields: []Field{ - {Type: "u16"}, - {Type: "vl_api_myenum_t"}, - }, - }, - expsize: 6, - }, - { - name: "invalid1", - input: Type{ - Fields: []Field{ - {Type: "x", Length: 16}, - }, - }, - expsize: 0, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - ctx := &context{ - packageData: &Package{ - Enums: []Enum{ - {Name: "myenum", Type: "u32"}, - }, - }, - } - size := getSizeOfType(ctx, &test.input) - if size != test.expsize { - t.Errorf("expected %d, got %d", test.expsize, size) - } - }) - } -} diff --git a/cmd/binapi-generator/testdata/ip.api.json b/cmd/binapi-generator/testdata/ip.api.json deleted file mode 100644 index 530b6d61..00000000 --- a/cmd/binapi-generator/testdata/ip.api.json +++ /dev/null @@ -1,2246 +0,0 @@ -{ - "services": [ - { - "ip_source_and_port_range_check_add_del": { - "reply": "ip_source_and_port_range_check_add_del_reply" - } - }, - { - "ip6_fib_dump": { - "reply": "ip6_fib_details", - "stream": true - } - }, - { - "want_ip6_nd_events": { - "reply": "want_ip6_nd_events_reply" - } - }, - { - "ip_punt_police": { - "reply": "ip_punt_police_reply" - } - }, - { - "set_arp_neighbor_limit": { - "reply": "set_arp_neighbor_limit_reply" - } - }, - { - "ip6nd_proxy_add_del": { - "reply": "ip6nd_proxy_add_del_reply" - } - }, - { - "ioam_disable": { - "reply": "ioam_disable_reply" - } - }, - { - "ip_table_add_del": { - "reply": "ip_table_add_del_reply" - } - }, - { - "ip_neighbor_dump": { - "reply": "ip_neighbor_details", - "stream": true - } - }, - { - "ip4_arp_event": { - "reply": null - } - }, - { - "ip_punt_redirect": { - "reply": "ip_punt_redirect_reply" - } - }, - { - "sw_interface_ip6nd_ra_prefix": { - "reply": "sw_interface_ip6nd_ra_prefix_reply" - } - }, - { - "reset_fib": { - "reply": "reset_fib_reply" - } - }, - { - "ip6_mfib_dump": { - "reply": "ip6_mfib_details", - "stream": true - } - }, - { - "sw_interface_ip6nd_ra_config": { - "reply": "sw_interface_ip6nd_ra_config_reply" - } - }, - { - "sw_interface_ip6_enable_disable": { - "reply": "sw_interface_ip6_enable_disable_reply" - } - }, - { - "sw_interface_ip6_set_link_local_address": { - "reply": "sw_interface_ip6_set_link_local_address_reply" - } - }, - { - "mfib_signal_dump": { - "reply": "mfib_signal_details", - "stream": true - } - }, - { - "ip_container_proxy_add_del": { - "reply": "ip_container_proxy_add_del_reply" - } - }, - { - "ip_mfib_dump": { - "reply": "ip_mfib_details", - "stream": true - } - }, - { - "ip_address_dump": { - "reply": "ip_address_details", - "stream": true - } - }, - { - "ip_dump": { - "reply": "ip_details", - "stream": true - } - }, - { - "ip_neighbor_add_del": { - "reply": "ip_neighbor_add_del_reply" - } - }, - { - "proxy_arp_intfc_enable_disable": { - "reply": "proxy_arp_intfc_enable_disable_reply" - } - }, - { - "proxy_arp_add_del": { - "reply": "proxy_arp_add_del_reply" - } - }, - { - "ip_add_del_route": { - "reply": "ip_add_del_route_reply" - } - }, - { - "ip6nd_proxy_dump": { - "reply": "ip6nd_proxy_details", - "stream": true - } - }, - { - "ip_fib_dump": { - "reply": "ip_fib_details", - "stream": true - } - }, - { - "want_ip4_arp_events": { - "reply": "want_ip4_arp_events_reply" - } - }, - { - "ioam_enable": { - "reply": "ioam_enable_reply" - } - }, - { - "ip6_nd_event": { - "reply": null - } - }, - { - "ip_mroute_add_del": { - "reply": "ip_mroute_add_del_reply" - } - }, - { - "ip_source_and_port_range_check_interface_add_del": { - "reply": "ip_source_and_port_range_check_interface_add_del_reply" - } - }, - { - "set_ip_flow_hash": { - "reply": "set_ip_flow_hash_reply" - } - } - ], - "vl_api_version": "0xb395c625", - "enums": [], - "messages": [ - [ - "ip_table_add_del", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "table_id" - ], - [ - "u8", - "is_ipv6" - ], - [ - "u8", - "is_add" - ], - [ - "u8", - "name", - 64 - ], - { - "crc": "0x0240c89d" - } - ], - [ - "ip_table_add_del_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "ip_fib_dump", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - { - "crc": "0x51077d14" - } - ], - [ - "ip_fib_details", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "u32", - "table_id" - ], - [ - "u8", - "table_name", - 64 - ], - [ - "u8", - "address_length" - ], - [ - "u8", - "address", - 4 - ], - [ - "u32", - "count" - ], - [ - "vl_api_fib_path_t", - "path", - 0, - "count" - ], - { - "crc": "0x99dfd73b" - } - ], - [ - "ip6_fib_dump", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - { - "crc": "0x51077d14" - } - ], - [ - "ip6_fib_details", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "u32", - "table_id" - ], - [ - "u8", - "table_name", - 64 - ], - [ - "u8", - "address_length" - ], - [ - "u8", - "address", - 16 - ], - [ - "u32", - "count" - ], - [ - "vl_api_fib_path_t", - "path", - 0, - "count" - ], - { - "crc": "0xabd0060e" - } - ], - [ - "ip_neighbor_dump", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u8", - "is_ipv6" - ], - { - "crc": "0x6b7bcd0a" - } - ], - [ - "ip_neighbor_details", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u8", - "is_static" - ], - [ - "u8", - "is_ipv6" - ], - [ - "u8", - "mac_address", - 6 - ], - [ - "u8", - "ip_address", - 16 - ], - { - "crc": "0x85e32a72" - } - ], - [ - "ip_neighbor_add_del", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u8", - "is_add" - ], - [ - "u8", - "is_ipv6" - ], - [ - "u8", - "is_static" - ], - [ - "u8", - "is_no_adj_fib" - ], - [ - "u8", - "mac_address", - 6 - ], - [ - "u8", - "dst_address", - 16 - ], - { - "crc": "0x4711eb25" - } - ], - [ - "ip_neighbor_add_del_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "set_ip_flow_hash", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "vrf_id" - ], - [ - "u8", - "is_ipv6" - ], - [ - "u8", - "src" - ], - [ - "u8", - "dst" - ], - [ - "u8", - "sport" - ], - [ - "u8", - "dport" - ], - [ - "u8", - "proto" - ], - [ - "u8", - "reverse" - ], - { - "crc": "0x32ebf737" - } - ], - [ - "set_ip_flow_hash_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "sw_interface_ip6nd_ra_config", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u8", - "suppress" - ], - [ - "u8", - "managed" - ], - [ - "u8", - "other" - ], - [ - "u8", - "ll_option" - ], - [ - "u8", - "send_unicast" - ], - [ - "u8", - "cease" - ], - [ - "u8", - "is_no" - ], - [ - "u8", - "default_router" - ], - [ - "u32", - "max_interval" - ], - [ - "u32", - "min_interval" - ], - [ - "u32", - "lifetime" - ], - [ - "u32", - "initial_count" - ], - [ - "u32", - "initial_interval" - ], - { - "crc": "0xc3f02daa" - } - ], - [ - "sw_interface_ip6nd_ra_config_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "sw_interface_ip6nd_ra_prefix", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u8", - "address", - 16 - ], - [ - "u8", - "address_length" - ], - [ - "u8", - "use_default" - ], - [ - "u8", - "no_advertise" - ], - [ - "u8", - "off_link" - ], - [ - "u8", - "no_autoconfig" - ], - [ - "u8", - "no_onlink" - ], - [ - "u8", - "is_no" - ], - [ - "u32", - "val_lifetime" - ], - [ - "u32", - "pref_lifetime" - ], - { - "crc": "0xca763c9a" - } - ], - [ - "sw_interface_ip6nd_ra_prefix_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "ip6nd_proxy_add_del", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u8", - "is_del" - ], - [ - "u8", - "address", - 16 - ], - { - "crc": "0xd95f0fa0" - } - ], - [ - "ip6nd_proxy_add_del_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "ip6nd_proxy_details", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u8", - "address", - 16 - ], - { - "crc": "0xd73bf1ab" - } - ], - [ - "ip6nd_proxy_dump", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - { - "crc": "0x51077d14" - } - ], - [ - "sw_interface_ip6_enable_disable", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u8", - "enable" - ], - { - "crc": "0xa36fadc0" - } - ], - [ - "sw_interface_ip6_enable_disable_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "sw_interface_ip6_set_link_local_address", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u8", - "address", - 16 - ], - { - "crc": "0xd73bf1ab" - } - ], - [ - "sw_interface_ip6_set_link_local_address_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "ip_add_del_route", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "next_hop_sw_if_index" - ], - [ - "u32", - "table_id" - ], - [ - "u32", - "classify_table_index" - ], - [ - "u32", - "next_hop_table_id" - ], - [ - "u32", - "next_hop_id" - ], - [ - "u8", - "is_add" - ], - [ - "u8", - "is_drop" - ], - [ - "u8", - "is_unreach" - ], - [ - "u8", - "is_prohibit" - ], - [ - "u8", - "is_ipv6" - ], - [ - "u8", - "is_local" - ], - [ - "u8", - "is_classify" - ], - [ - "u8", - "is_multipath" - ], - [ - "u8", - "is_resolve_host" - ], - [ - "u8", - "is_resolve_attached" - ], - [ - "u8", - "is_dvr" - ], - [ - "u8", - "is_source_lookup" - ], - [ - "u8", - "is_udp_encap" - ], - [ - "u8", - "next_hop_weight" - ], - [ - "u8", - "next_hop_preference" - ], - [ - "u8", - "next_hop_proto" - ], - [ - "u8", - "dst_address_length" - ], - [ - "u8", - "dst_address", - 16 - ], - [ - "u8", - "next_hop_address", - 16 - ], - [ - "u8", - "next_hop_n_out_labels" - ], - [ - "u32", - "next_hop_via_label" - ], - [ - "u32", - "next_hop_out_label_stack", - 0, - "next_hop_n_out_labels" - ], - { - "crc": "0xc85f8290" - } - ], - [ - "ip_add_del_route_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "ip_mroute_add_del", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "next_hop_sw_if_index" - ], - [ - "u32", - "table_id" - ], - [ - "u32", - "entry_flags" - ], - [ - "u32", - "itf_flags" - ], - [ - "u32", - "rpf_id" - ], - [ - "u32", - "bier_imp" - ], - [ - "u16", - "grp_address_length" - ], - [ - "u8", - "next_hop_afi" - ], - [ - "u8", - "is_add" - ], - [ - "u8", - "is_ipv6" - ], - [ - "u8", - "is_local" - ], - [ - "u8", - "grp_address", - 16 - ], - [ - "u8", - "src_address", - 16 - ], - { - "crc": "0xc37112f7" - } - ], - [ - "ip_mroute_add_del_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "ip_mfib_dump", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - { - "crc": "0x51077d14" - } - ], - [ - "ip_mfib_details", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "u32", - "table_id" - ], - [ - "u32", - "entry_flags" - ], - [ - "u32", - "rpf_id" - ], - [ - "u8", - "address_length" - ], - [ - "u8", - "grp_address", - 4 - ], - [ - "u8", - "src_address", - 4 - ], - [ - "u32", - "count" - ], - [ - "vl_api_fib_path_t", - "path", - 0, - "count" - ], - { - "crc": "0x5e530d5e" - } - ], - [ - "ip6_mfib_dump", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - { - "crc": "0x51077d14" - } - ], - [ - "ip6_mfib_details", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "u32", - "table_id" - ], - [ - "u8", - "address_length" - ], - [ - "u8", - "grp_address", - 16 - ], - [ - "u8", - "src_address", - 16 - ], - [ - "u32", - "count" - ], - [ - "vl_api_fib_path_t", - "path", - 0, - "count" - ], - { - "crc": "0xe02dcb4b" - } - ], - [ - "ip_address_details", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u8", - "ip", - 16 - ], - [ - "u8", - "prefix_length" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u8", - "is_ipv6" - ], - { - "crc": "0xbc7442f2" - } - ], - [ - "ip_address_dump", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u8", - "is_ipv6" - ], - { - "crc": "0x6b7bcd0a" - } - ], - [ - "ip_details", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u32", - "context" - ], - [ - "u8", - "is_ipv6" - ], - { - "crc": "0x452ffc5a" - } - ], - [ - "ip_dump", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u8", - "is_ipv6" - ], - { - "crc": "0xde883da4" - } - ], - [ - "mfib_signal_dump", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - { - "crc": "0x51077d14" - } - ], - [ - "mfib_signal_details", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u32", - "table_id" - ], - [ - "u16", - "grp_address_len" - ], - [ - "u8", - "grp_address", - 16 - ], - [ - "u8", - "src_address", - 16 - ], - [ - "u16", - "ip_packet_len" - ], - [ - "u8", - "ip_packet_data", - 256 - ], - { - "crc": "0x791bbeab" - } - ], - [ - "ip_punt_police", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "policer_index" - ], - [ - "u8", - "is_add" - ], - [ - "u8", - "is_ip6" - ], - { - "crc": "0x38691592" - } - ], - [ - "ip_punt_police_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "ip_punt_redirect", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "rx_sw_if_index" - ], - [ - "u32", - "tx_sw_if_index" - ], - [ - "u8", - "is_add" - ], - [ - "u8", - "is_ip6" - ], - [ - "u8", - "nh", - 16 - ], - { - "crc": "0x996b6603" - } - ], - [ - "ip_punt_redirect_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "ip_container_proxy_add_del", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u8", - "ip", - 16 - ], - [ - "u8", - "is_ip4" - ], - [ - "u8", - "plen" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u8", - "is_add" - ], - { - "crc": "0x0a355d39" - } - ], - [ - "ip_container_proxy_add_del_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "ip_source_and_port_range_check_add_del", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u8", - "is_ipv6" - ], - [ - "u8", - "is_add" - ], - [ - "u8", - "mask_length" - ], - [ - "u8", - "address", - 16 - ], - [ - "u8", - "number_of_ranges" - ], - [ - "u16", - "low_ports", - 32 - ], - [ - "u16", - "high_ports", - 32 - ], - [ - "u32", - "vrf_id" - ], - { - "crc": "0x03d6b03a" - } - ], - [ - "ip_source_and_port_range_check_add_del_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "ip_source_and_port_range_check_interface_add_del", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u8", - "is_add" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u32", - "tcp_in_vrf_id" - ], - [ - "u32", - "tcp_out_vrf_id" - ], - [ - "u32", - "udp_in_vrf_id" - ], - [ - "u32", - "udp_out_vrf_id" - ], - { - "crc": "0x6966bc44" - } - ], - [ - "ip_source_and_port_range_check_interface_add_del_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "want_ip4_arp_events", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u8", - "enable_disable" - ], - [ - "u32", - "pid" - ], - [ - "u32", - "address" - ], - { - "crc": "0x77e06379" - } - ], - [ - "want_ip4_arp_events_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "ip4_arp_event", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "address" - ], - [ - "u32", - "pid" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u8", - "new_mac", - 6 - ], - [ - "u8", - "mac_ip" - ], - { - "crc": "0xef7235f7" - } - ], - [ - "want_ip6_nd_events", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u8", - "enable_disable" - ], - [ - "u32", - "pid" - ], - [ - "u8", - "address", - 16 - ], - { - "crc": "0x1cf65fbb" - } - ], - [ - "want_ip6_nd_events_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "ip6_nd_event", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "pid" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u8", - "address", - 16 - ], - [ - "u8", - "new_mac", - 6 - ], - [ - "u8", - "mac_ip" - ], - { - "crc": "0x96ab2fdd" - } - ], - [ - "proxy_arp_add_del", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "vrf_id" - ], - [ - "u8", - "is_add" - ], - [ - "u8", - "low_address", - 4 - ], - [ - "u8", - "hi_address", - 4 - ], - { - "crc": "0xc2442918" - } - ], - [ - "proxy_arp_add_del_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "proxy_arp_intfc_enable_disable", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "sw_if_index" - ], - [ - "u8", - "enable_disable" - ], - { - "crc": "0x69d24598" - } - ], - [ - "proxy_arp_intfc_enable_disable_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "reset_fib", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u32", - "vrf_id" - ], - [ - "u8", - "is_ipv6" - ], - { - "crc": "0x8553ebd9" - } - ], - [ - "reset_fib_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "set_arp_neighbor_limit", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u8", - "is_ipv6" - ], - [ - "u32", - "arp_neighbor_limit" - ], - { - "crc": "0x97d01fd6" - } - ], - [ - "set_arp_neighbor_limit_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "ioam_enable", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u16", - "id" - ], - [ - "u8", - "seqno" - ], - [ - "u8", - "analyse" - ], - [ - "u8", - "pot_enable" - ], - [ - "u8", - "trace_enable" - ], - [ - "u32", - "node_id" - ], - { - "crc": "0x9392e032" - } - ], - [ - "ioam_enable_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ], - [ - "ioam_disable", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], - [ - "u16", - "id" - ], - { - "crc": "0x6b16a45e" - } - ], - [ - "ioam_disable_reply", - [ - "u16", - "_vl_msg_id" - ], - [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } - ] - ], - "types": [ - [ - "fib_path", - [ - "u32", - "sw_if_index" - ], - [ - "u32", - "table_id" - ], - [ - "u8", - "weight" - ], - [ - "u8", - "preference" - ], - [ - "u8", - "is_local" - ], - [ - "u8", - "is_drop" - ], - [ - "u8", - "is_unreach" - ], - [ - "u8", - "is_prohibit" - ], - [ - "u8", - "afi" - ], - [ - "u8", - "next_hop", - 16 - ], - { - "crc": "0xcd899e0a" - } - ] - ] -} diff --git a/cmd/binapi-generator/types.go b/cmd/binapi-generator/types.go deleted file mode 100644 index 90c890f0..00000000 --- a/cmd/binapi-generator/types.go +++ /dev/null @@ -1,147 +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 main - -import ( - "fmt" - "strconv" - "strings" - - "github.com/sirupsen/logrus" -) - -// toApiType returns name that is used as type reference in VPP binary API -func toApiType(name string) string { - return fmt.Sprintf("vl_api_%s_t", name) -} - -// binapiTypes is a set of types used VPP binary API for translation to Go types -var binapiTypes = map[string]string{ - "u8": "uint8", - "i8": "int8", - "u16": "uint16", - "i16": "int16", - "u32": "uint32", - "i32": "int32", - "u64": "uint64", - "i64": "int64", - "f64": "float64", -} - -func getBinapiTypeSize(binapiType string) int { - if _, ok := binapiTypes[binapiType]; ok { - b, err := strconv.Atoi(strings.TrimLeft(binapiType, "uif")) - if err == nil { - return b / 8 - } - } - return -1 -} - -// convertToGoType translates the VPP binary API type into Go type -func convertToGoType(ctx *context, binapiType string) (typ string) { - if t, ok := binapiTypes[binapiType]; ok { - // basic types - typ = t - } else if r, ok := ctx.packageData.RefMap[binapiType]; ok { - // specific types (enums/types/unions) - typ = camelCaseName(r) - } else { - switch binapiType { - case "bool", "string": - typ = binapiType - default: - // fallback type - logrus.Warnf("found unknown VPP binary API type %q, using byte", binapiType) - typ = "byte" - } - } - return typ -} - -func getSizeOfType(ctx *context, typ *Type) (size int) { - for _, field := range typ.Fields { - enum := getEnumByRef(ctx, field.Type) - if enum != nil { - size += getSizeOfBinapiTypeLength(enum.Type, field.Length) - continue - } - size += getSizeOfBinapiTypeLength(field.Type, field.Length) - } - return size -} - -func getSizeOfBinapiTypeLength(typ string, length int) (size int) { - if n := getBinapiTypeSize(typ); n > 0 { - if length > 0 { - return n * length - } else { - return n - } - } - - return -} - -func getEnumByRef(ctx *context, ref string) *Enum { - for _, typ := range ctx.packageData.Enums { - if ref == toApiType(typ.Name) { - return &typ - } - } - return nil -} - -func getTypeByRef(ctx *context, ref string) *Type { - for _, typ := range ctx.packageData.Types { - if ref == toApiType(typ.Name) { - return &typ - } - } - return nil -} - -func getAliasByRef(ctx *context, ref string) *Alias { - for _, alias := range ctx.packageData.Aliases { - if ref == toApiType(alias.Name) { - return &alias - } - } - return nil -} - -func getUnionSize(ctx *context, union *Union) (maxSize int) { - for _, field := range union.Fields { - typ := getTypeByRef(ctx, field.Type) - if typ != nil { - if size := getSizeOfType(ctx, typ); size > maxSize { - maxSize = size - } - continue - } - alias := getAliasByRef(ctx, field.Type) - if alias != nil { - if size := getSizeOfBinapiTypeLength(alias.Type, alias.Length); size > maxSize { - maxSize = size - } - continue - } else { - logf("no type or alias found for union %s field type %q", union.Name, field.Type) - continue - } - } - logf("getUnionSize: %s %+v max=%v", union.Name, union.Fields, maxSize) - return -} diff --git a/cmd/govpp/cli.go b/cmd/govpp/cli.go new file mode 100644 index 00000000..8707da1b --- /dev/null +++ b/cmd/govpp/cli.go @@ -0,0 +1,123 @@ +// Copyright (c) 2023 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 main + +import ( + "io" + + "github.com/docker/cli/cli/streams" + "github.com/moby/term" +) + +type Cli interface { + Out() *streams.Out + Err() io.Writer + In() *streams.In + Apply(...CliOption) error +} + +type AppCli struct { + out *streams.Out + err io.Writer + in *streams.In +} + +func NewCli(opt ...CliOption) (Cli, error) { + cli := new(AppCli) + if err := cli.Apply(opt...); err != nil { + return nil, err + } + if cli.out == nil || cli.in == nil || cli.err == nil { + stdin, stdout, stderr := term.StdStreams() + if cli.in == nil { + cli.in = streams.NewIn(stdin) + } + if cli.out == nil { + cli.out = streams.NewOut(stdout) + } + if cli.err == nil { + cli.err = stderr + } + } + return cli, nil +} + +func (cli *AppCli) Out() *streams.Out { + return cli.out +} + +func (cli *AppCli) Err() io.Writer { + return cli.err +} + +func (cli *AppCli) In() *streams.In { + return cli.in +} + +func (cli *AppCli) Apply(opt ...CliOption) error { + for _, o := range opt { + if err := o(cli); err != nil { + return err + } + } + return nil +} + +type CliOption func(cli *AppCli) error + +// WithStandardStreams sets a cli in, out and err streams with the standard streams. +func WithStandardStreams() CliOption { + return func(cli *AppCli) error { + // Set terminal emulation based on platform as required. + stdin, stdout, stderr := term.StdStreams() + cli.in = streams.NewIn(stdin) + cli.out = streams.NewOut(stdout) + cli.err = stderr + return nil + } +} + +// WithCombinedStreams uses the same stream for the output and error streams. +func WithCombinedStreams(combined io.Writer) CliOption { + return func(cli *AppCli) error { + cli.out = streams.NewOut(combined) + cli.err = combined + return nil + } +} + +// WithInputStream sets a cli input stream. +func WithInputStream(in io.ReadCloser) CliOption { + return func(cli *AppCli) error { + cli.in = streams.NewIn(in) + return nil + } +} + +// WithOutputStream sets a cli output stream. +func WithOutputStream(out io.Writer) CliOption { + return func(cli *AppCli) error { + cli.out = streams.NewOut(out) + return nil + } +} + +// WithErrorStream sets a cli error stream. +func WithErrorStream(err io.Writer) CliOption { + return func(cli *AppCli) error { + cli.err = err + return nil + } +} diff --git a/cmd/govpp/cmd.go b/cmd/govpp/cmd.go new file mode 100644 index 00000000..7ec3e90c --- /dev/null +++ b/cmd/govpp/cmd.go @@ -0,0 +1,87 @@ +// Copyright (c) 2023 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 main + +import ( + "github.com/gookit/color" + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + + "github.com/alkiranet/govpp/internal/version" +) + +const logo = ` + ______ _ _ _____ _____ %s + | ____ _____ \ / |_____] |_____] %s + |_____| [_____] \/ | | %s + +` + +func newRootCmd(cli Cli) *cobra.Command { + var ( + glob GlobalOptions + ) + + cmd := &cobra.Command{ + Use: "govpp [OPTIONS] COMMAND", + Short: "GoVPP CLI tool", + Long: color.Sprintf(logo, version.Short(), version.BuiltBy(), version.BuildTime()), + Version: version.String(), + PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + InitOptions(cli, &glob) + logrus.Tracef("global options: %+v", glob) + logrus.Tracef("args: %+v", args) + return nil + }, + SilenceUsage: true, + SilenceErrors: true, + TraverseChildren: true, + CompletionOptions: cobra.CompletionOptions{ + HiddenDefaultCmd: true, + }, + } + + // Setup options + cmd.Flags().SortFlags = false + cmd.PersistentFlags().SortFlags = false + + // Global options + glob.InstallFlags(cmd.PersistentFlags()) + + // Version option + cmd.InitDefaultVersionFlag() + cmd.Flags().Lookup("version").Shorthand = "" + // Help option + cmd.InitDefaultHelpFlag() + cmd.Flags().Lookup("help").Hidden = true + + // Commands + cmd.AddCommand( + newGenerateCmd(cli), + newVppapiCmd(cli), + newHttpCmd(cli), + newCliCommand(cli), + ) + + // Help command + cmd.InitDefaultHelpCmd() + for _, c := range cmd.Commands() { + if c.Name() == "help" { + c.Hidden = true + } + } + + return cmd +} diff --git a/cmd/govpp/cmd_cli.go b/cmd/govpp/cmd_cli.go new file mode 100644 index 00000000..3ea76ae4 --- /dev/null +++ b/cmd/govpp/cmd_cli.go @@ -0,0 +1,272 @@ +// Copyright (c) 2023 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 main + +import ( + "bufio" + "context" + "fmt" + "io" + "os" + "strings" + + "github.com/gookit/color" + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + + "github.com/alkiranet/govpp" + "github.com/alkiranet/govpp/adapter/socketclient" + "github.com/alkiranet/govpp/binapi/vlib" + "github.com/alkiranet/govpp/core" +) + +// TODO: +// - add option to allow connecting via CLI socket +// - try several ways to connect to VPP if not specified + +const exampleCliCommand = ` + # Execute 'show version' command + govpp cli show version + + # Enter REPL mode to send commands interactively + govpp cli + + # Read CLI command(s) from stdin + echo "show errors" | govpp cli + + # Execute commands and write output to file + govpp cli -o cli.log show version +` + +type CliOptions struct { + ApiSocket string + Force bool + Output string + + Stdin io.Reader + Stderr io.Writer + Stdout io.Writer +} + +func newCliCommand(Cli) *cobra.Command { + var ( + opts = CliOptions{ + ApiSocket: socketclient.DefaultSocketName, + } + ) + cmd := &cobra.Command{ + Use: "cli [COMMAND]", + Aliases: []string{"c"}, + Short: "Send CLI via VPP API", + Long: "Send VPP CLI command(s) via VPP API", + Example: color.Sprint(exampleCliCommand), + DisableFlagsInUseLine: true, + RunE: func(cmd *cobra.Command, args []string) error { + opts.Stdin = cmd.InOrStdin() + opts.Stderr = cmd.ErrOrStderr() + + // Setup output + if opts.Output != "" { + info, err := os.Stat(opts.Output) + if err != nil && !os.IsNotExist(err) { + return err + } else if err == nil { + if info.IsDir() { + return fmt.Errorf("output cannot be a directory") + } + if !opts.Force { + return fmt.Errorf("output file already exists (use --force to overwrite)") + } + } + file, err := os.Create(opts.Output) + if err != nil { + return fmt.Errorf("failed to create output file: %v", err) + } + opts.Stdout = file + } else { + opts.Stdout = cmd.OutOrStdout() + } + + var cmds []string + + // Check if there is any data sent to the program via stdin + stat, _ := os.Stdin.Stat() + if (stat.Mode() & os.ModeCharDevice) == 0 { + logrus.Debugf("stdin has input") + + if len(args) > 0 { + return fmt.Errorf("cannot use both arguments and stdin for the CLI commands") + } + + input, err := io.ReadAll(os.Stdin) + if err != nil { + return fmt.Errorf("error reading stdin: %w", err) + } + + // Split the input into lines and execute each line as a command + lines := strings.Split(string(input), "\n") + for _, line := range lines { + if line == "" { + continue + } + cmds = append(cmds, line) + } + } else if len(args) > 0 { + logrus.Debugf("provided %d args", len(args)) + + cmdArgs := strings.Join(args[:], " ") + lines := strings.Split(cmdArgs, "\n") + for _, line := range lines { + if line == "" { + continue + } + cmds = append(cmds, line) + } + } + + return runCliCmd(opts, cmds) + }, + } + + cmd.PersistentFlags().StringVar(&opts.ApiSocket, "apisock", opts.ApiSocket, "Path to VPP API socket") + cmd.PersistentFlags().StringVarP(&opts.Output, "output", "o", "", "Output location for the CLI reply") + cmd.PersistentFlags().BoolVarP(&opts.Force, "force", "f", false, "Force overwriting output file") + + return cmd +} + +const vppcliPrompt = "vpp# " + +func runCliCmd(opts CliOptions, cmds []string) error { + cli, err := connectBinapiVppCLI(opts.ApiSocket) + if err != nil { + return fmt.Errorf("connecting to CLI failed: %w", err) + } + defer cli.Close() + + if len(cmds) == 0 { + logrus.Debugf("entering REPL mode") + + fmt.Fprintln(opts.Stdout) + + scanner := bufio.NewScanner(opts.Stdin) + for { + fmt.Fprint(opts.Stdout, vppcliPrompt) + + if !scanner.Scan() { + return nil + } + line := scanner.Text() + if line == "" { + continue + } + + logrus.Debugf("executing CLI command: %v", line) + + reply, err := cli.Execute(line) + if err != nil { + logrus.Errorf("command error: %v", err) + } + + fmt.Fprint(opts.Stdout, reply) + fmt.Fprintln(opts.Stdout) + } + } else { + for _, cmd := range cmds { + fmt.Fprintln(opts.Stdout, vppcliPrompt+cmd) + + logrus.Debugf("executing CLI command: %v", cmd) + + reply, err := cli.Execute(cmd) + if err != nil { + return err + } + + fmt.Fprint(opts.Stdout, reply) + fmt.Fprintln(opts.Stdout) + } + } + + return nil +} + +func connectBinapiVppCLI(apiSock string) (VppCli, error) { + cli, err := newBinapiVppCli(apiSock) + if err != nil { + return nil, err + } + return cli, nil +} + +type VppCli interface { + Execute(args ...string) (string, error) + Close() error +} + +type vppcliBinapi struct { + apiSocket string + conn *core.Connection + client vlib.RPCService +} + +func newBinapiVppCli(apiSock string) (*vppcliBinapi, error) { + logrus.Tracef("connecting to VPP API socket %q", apiSock) + + conn, err := govpp.Connect(apiSock) + if err != nil { + return nil, fmt.Errorf("connecting to VPP failed: %w", err) + } + + ch, err := conn.NewAPIChannel() + if err != nil { + return nil, err + } + defer ch.Close() + + if err := ch.CheckCompatiblity(vlib.AllMessages()...); err != nil { + return nil, fmt.Errorf("compatibility check failed: %w", err) + } + + cli := &vppcliBinapi{ + apiSocket: apiSock, + conn: conn, + client: vlib.NewServiceClient(conn), + } + return cli, nil +} + +func (b *vppcliBinapi) Execute(args ...string) (string, error) { + cmd := strings.Join(args, " ") + + logrus.Tracef("sending CLI command: %q", cmd) + + reply, err := b.client.CliInband(context.Background(), &vlib.CliInband{ + Cmd: cmd, + }) + if err != nil { + return "", err + } + + return reply.Reply, nil +} + +func (b *vppcliBinapi) Close() error { + if b.conn != nil { + logrus.Debugf("disconnecting VPP API connection") + b.conn.Disconnect() + b.conn = nil + } + return nil +} diff --git a/cmd/govpp/cmd_generate.go b/cmd/govpp/cmd_generate.go new file mode 100644 index 00000000..335c27ab --- /dev/null +++ b/cmd/govpp/cmd_generate.go @@ -0,0 +1,99 @@ +// Copyright (c) 2023 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 main + +import ( + "os" + "path/filepath" + + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + + "github.com/alkiranet/govpp/binapigen" + "github.com/alkiranet/govpp/binapigen/vppapi" +) + +type GenerateOptions struct { + Input string + Output string + ImportPrefix string + NoVersionInfo bool + NoSourceInfo bool + RunPlugins []string +} + +func newGenerateCmd(cli Cli) *cobra.Command { + var ( + opts = GenerateOptions{ + RunPlugins: []string{"rpc"}, + } + ) + cmd := &cobra.Command{ + Use: "generate [apifile...]", + Aliases: []string{"gen"}, + Short: "Generate code", + Long: "Generates Go bindings for VPP API", + RunE: func(cmd *cobra.Command, args []string) error { + if opts.Input == "" { + opts.Input = detectVppApiInput() + } + return runGenerator(opts, args) + }, + } + + cmd.PersistentFlags().StringVar(&opts.Input, "input", "", "Input for VPP API (e.g. VPP API dir, VPP repository, ..)") + cmd.PersistentFlags().StringVarP(&opts.Output, "output", "o", "", "Output location for generated files") + cmd.PersistentFlags().StringVar(&opts.ImportPrefix, "import-prefix", "", "Prefix imports in the generated go code. \nE.g. other API Files (e.g. api_file.ba.go) will be imported with :\nimport (\n api_file \"/api_file\"\n)") + cmd.PersistentFlags().BoolVar(&opts.NoVersionInfo, "no-version-info", false, "Exclude version info.") + cmd.PersistentFlags().BoolVar(&opts.NoSourceInfo, "no-source-info", false, "Exclude source info.") + cmd.PersistentFlags().StringSliceVar(&opts.RunPlugins, "gen", opts.RunPlugins, "List of generator plugins to run for files.") + + return cmd +} + +const DefaultOutputDir = "binapi" + +func runGenerator(cmdOpts GenerateOptions, args []string) error { + + var filesToGen []string + filesToGen = append(filesToGen, args...) + + opts := binapigen.Options{ + ImportPrefix: cmdOpts.ImportPrefix, + OutputDir: cmdOpts.Output, + NoVersionInfo: cmdOpts.NoVersionInfo, + NoSourcePathInfo: cmdOpts.NoSourceInfo, + GenerateFiles: filesToGen, + } + + // generate in same directory when current dir is binapi + if opts.OutputDir == "" { + opts.OutputDir = DefaultOutputDir + } + if wd, _ := os.Getwd(); opts.OutputDir == DefaultOutputDir && filepath.Base(wd) == DefaultOutputDir { + opts.OutputDir = "." + } + + vppInput, err := vppapi.ResolveVppInput(cmdOpts.Input) + if err != nil { + logrus.Fatal(err) + } + logrus.Debugf("resolved VPP input: %+v", vppInput) + + genPlugins := cmdOpts.RunPlugins + binapigen.Run(vppInput, opts, binapigen.GeneratePlugins(genPlugins)) + + return nil +} diff --git a/cmd/govpp/cmd_http.go b/cmd/govpp/cmd_http.go new file mode 100644 index 00000000..6c6a6983 --- /dev/null +++ b/cmd/govpp/cmd_http.go @@ -0,0 +1,209 @@ +// Copyright (c) 2023 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 main + +import ( + "encoding/json" + "fmt" + "io" + "net/http" + "os" + "strings" + + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + + "github.com/alkiranet/govpp" + "github.com/alkiranet/govpp/adapter/socketclient" + "github.com/alkiranet/govpp/binapi/vpe" + "github.com/alkiranet/govpp/binapigen/vppapi" +) + +// TODO: +// - add option to allow server to start without VPP running +// - add option to set list of VPP APIs to serve +// - wait for SIGTERM/SIGINT signal and shutdown the server gracefully +// - add home page (/index.html) providing references and example links + +const ( + DefaultHttpServiceAddress = ":8000" +) + +type HttpCmdOptions struct { + Input string + ApiSocket string + Address string +} + +func newHttpCmd(Cli) *cobra.Command { + var opts = HttpCmdOptions{ + ApiSocket: socketclient.DefaultSocketName, + Address: DefaultHttpServiceAddress, + } + cmd := &cobra.Command{ + Use: "http", + Short: "VPP API as HTTP service", + Long: "Serves VPP API via HTTP service", + RunE: func(cmd *cobra.Command, args []string) error { + return runHttpCmd(opts) + }, + } + + cmd.PersistentFlags().StringVar(&opts.Input, "input", opts.Input, "Input for VPP API (e.g. path to VPP API directory, local VPP repo)") + cmd.PersistentFlags().StringVar(&opts.ApiSocket, "apisock", opts.ApiSocket, "Path to VPP API socket") + cmd.PersistentFlags().StringVar(&opts.Address, "addr", opts.Address, "HTTP service address") + + return cmd +} + +func runHttpCmd(opts HttpCmdOptions) error { + vppInput, err := resolveInput(opts.Input) + if err != nil { + return err + } + + logrus.Debugf("connecting to VPP socket %s", opts.ApiSocket) + + conn, err := govpp.Connect(opts.ApiSocket) + if err != nil { + return fmt.Errorf("govpp.Connect: %w", err) + } + + serveMux := http.NewServeMux() + + setupHttpAPIHandlers(vppInput.Schema.Files, serveMux) + + // TODO: register all api files automatically (requires some regisry for handlers or apifiles + c := vpe.HTTPHandler(vpe.NewServiceClient(conn)) + //c := memclnt.HTTPHandler(memclnt.NewServiceClient(conn)) + + serveMux.Handle("/", c) + + logrus.Infof("HTTP server listening on: %v", opts.Address) + + if err := http.ListenAndServe(opts.Address, serveMux); err != nil { + return err + } + + return nil +} + +func setupHttpAPIHandlers(apifiles []vppapi.File, mux *http.ServeMux) { + for _, apifile := range apifiles { + file := apifile + name := file.Name + mux.HandleFunc("/api/"+name, apiFileHandler(&file)) + mux.HandleFunc("/raw/"+name, apiRawHandler(&file)) + mux.HandleFunc("/vpp/"+name, reqHandler(&file)) + } + mux.HandleFunc("/api", apiFilesHandler(apifiles)) +} + +func reqHandler(apifile *vppapi.File) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, req *http.Request) { + // extract message name + msgName := strings.TrimPrefix(req.URL.Path, "/vpp/"+apifile.Name+"/") + if msgName == "" { + http.Error(w, "missing message name in URL", http.StatusBadRequest) + return + } + + // find message + var msg *vppapi.Message + for _, m := range apifile.Messages { + if m.Name == msgName { + msg = &m + break + } + } + if msg == nil { + http.Error(w, "message not found : "+msgName, http.StatusNotFound) + return + } + + if req.Method == http.MethodPost { + reqData := make(map[string]interface{}) + + // parse body data + body, err := io.ReadAll(req.Body) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + err = json.Unmarshal(body, &reqData) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + // TODO: unmarshal body data into message, send request to VPP, marshal it and send as response + http.Error(w, "Sending requests is not implemented yet", http.StatusNotImplemented) + } else if req.Method == http.MethodGet { + b, err := json.MarshalIndent(msg, "", " ") + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + _, err = w.Write(b) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } + } else { + http.Error(w, "GET or POST are allowed only", http.StatusMethodNotAllowed) + } + } +} + +func apiFilesHandler(apifiles []vppapi.File) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, req *http.Request) { + b, err := json.MarshalIndent(apifiles, "", " ") + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + _, err = w.Write(b) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } + } +} + +func apiFileHandler(apifile *vppapi.File) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, req *http.Request) { + b, err := json.MarshalIndent(apifile, "", " ") + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + _, err = w.Write(b) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } + } +} + +func apiRawHandler(apifile *vppapi.File) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, req *http.Request) { + b, err := os.ReadFile(apifile.Path) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + _, err = w.Write(b) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } + } +} diff --git a/cmd/govpp/cmd_vppapi.go b/cmd/govpp/cmd_vppapi.go new file mode 100644 index 00000000..e904d2eb --- /dev/null +++ b/cmd/govpp/cmd_vppapi.go @@ -0,0 +1,109 @@ +// Copyright (c) 2023 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 main + +import ( + "fmt" + + "github.com/gookit/color" + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + + "github.com/alkiranet/govpp/binapigen" + "github.com/alkiranet/govpp/binapigen/vppapi" +) + +const exampleVppapi = ` + # Specify input source of VPP API + govpp vppapi COMMAND [INPUT] + govpp vppapi COMMAND ./vpp + govpp vppapi COMMAND /usr/share/vpp/api + govpp vppapi COMMAND vppapi.tar.gz + govpp vppapi COMMAND http://github.com/FDio/vpp.git + + # List VPP API contents + govpp vppapi ls [INPUT] + govpp vppapi ls --show-contents + + # Export VPP API files + govpp vppapi export [INPUT] --output vppapi + govpp vppapi export [INPUT] --output vppapi.tar.gz + + # Lint VPP API definitions + govpp vppapi lint [INPUT] + + # Compare VPP API schemas + govpp vppapi diff [INPUT] --against http://github.com/FDio/vpp.git +` + +type VppApiCmdOptions struct { + Input string + Paths []string + Format string +} + +func newVppapiCmd(cli Cli) *cobra.Command { + var ( + opts VppApiCmdOptions + ) + cmd := &cobra.Command{ + Use: "vppapi", + Short: "Manage VPP API", + Long: "Manage VPP API development.", + Example: color.Sprint(exampleVppapi), + TraverseChildren: true, + } + + cmd.PersistentFlags().StringSliceVar(&opts.Paths, "path", nil, "Limit to specific files or directories.\nFor example: \"vpe\" or \"core/\".") + cmd.PersistentFlags().StringVarP(&opts.Format, "format", "f", "", "Format for the output (json, yaml, go-template..)") + + cmd.AddCommand( + newVppApiLsCmd(cli, &opts), + newVppApiExportCmd(cli, &opts), + newVppApiDiffCmd(cli, &opts), + newVppApiLintCmd(cli, &opts), + ) + + return cmd +} + +func prepareVppApiFiles(allapifiles []vppapi.File, paths []string, includeImported, sortByName bool) ([]vppapi.File, error) { + // remove imported types + if !includeImported { + binapigen.SortFilesByImports(allapifiles) + for i, apifile := range allapifiles { + f := apifile + binapigen.RemoveImportedTypes(allapifiles, &f) + allapifiles[i] = f + } + } + + apifiles := allapifiles + + // filter files + if len(paths) > 0 { + apifiles = filterFilesByPaths(allapifiles, paths) + if len(apifiles) == 0 { + return nil, fmt.Errorf("no files matching: %q", paths) + } + logrus.Tracef("filter (%d paths) matched %d/%d files", len(paths), len(apifiles), len(allapifiles)) + } + + if sortByName { + binapigen.SortFilesByName(apifiles) + } + + return apifiles, nil +} diff --git a/cmd/govpp/cmd_vppapi_diff.go b/cmd/govpp/cmd_vppapi_diff.go new file mode 100644 index 00000000..c2fde4eb --- /dev/null +++ b/cmd/govpp/cmd_vppapi_diff.go @@ -0,0 +1,159 @@ +// Copyright (c) 2023 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 main + +import ( + "fmt" + "io" + + "github.com/gookit/color" + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + + "github.com/alkiranet/govpp/binapigen/vppapi" +) + +// TODO: +// - table format for differences +// - option to exit with non-zero status on breaking changes + +const exampleVppApiDiffCommand = ` + # Compare VPP API schemas + govpp vppapi diff . --against https://github.com/FDio/vpp +` + +type VppApiDiffCmdOptions struct { + *VppApiCmdOptions + + Against string + Differences []string + CommentDiffs bool +} + +func newVppApiDiffCmd(cli Cli, vppapiOpts *VppApiCmdOptions) *cobra.Command { + var ( + opts = VppApiDiffCmdOptions{VppApiCmdOptions: vppapiOpts} + ) + cmd := &cobra.Command{ + Use: "diff [INPUT] --against AGAINST [--differences DIFF]...", + Aliases: []string{"cmp", "compare"}, + Short: "Compare VPP API schemas", + Long: "Compares two VPP API schemas and lists the differences.", + Example: color.Sprint(exampleVppApiDiffCommand), + Args: cobra.MaximumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) > 0 { + opts.Input = args[0] + } + return runVppApiDiffCmd(cmd.OutOrStdout(), opts) + }, + } + + cmd.PersistentFlags().BoolVar(&opts.CommentDiffs, "comments", false, "Include message comment differences") + cmd.PersistentFlags().StringSliceVar(&opts.Differences, "differences", nil, "List only specific differences") + cmd.PersistentFlags().StringVar(&opts.Against, "against", "", "The VPP API schema to compare against.") + must(cobra.MarkFlagRequired(cmd.PersistentFlags(), "against")) + + return cmd +} + +var ( + clrWhite = color.Style{color.White} + clrCyan = color.Style{color.Cyan} + clrDiffFile = color.Style{color.Yellow} +) + +func runVppApiDiffCmd(out io.Writer, opts VppApiDiffCmdOptions) error { + vppInput, err := resolveInput(opts.Input) + if err != nil { + return err + } + + vppAgainst, err := vppapi.ResolveVppInput(opts.Against) + if err != nil { + return err + } + logrus.Tracef("VPP against:\n - API dir: %s\n - VPP Version: %s\n - Files: %v", + vppAgainst.ApiDirectory, vppAgainst.Schema.Version, len(vppAgainst.Schema.Files)) + + // compare schemas + schema1 := vppInput.Schema + schema2 := vppAgainst.Schema + + logrus.Tracef("comparing schemas:\n\tSCHEMA 1: %+v\n\tSCHEMA 2: %+v\n", schema1, schema2) + + diffs := CompareSchemas(&schema1, &schema2) + + if !opts.CommentDiffs { + var filtered []Difference + for _, diff := range diffs { + if diff.Type != MessageCommentDifference { + filtered = append(filtered, diff) + } + } + diffs = filtered + } + + if len(opts.Differences) > 0 { + diffs, err = filterDiffs(diffs, opts.Differences) + if err != nil { + return err + } + } + + if opts.Format == "" { + printDifferencesSimple(out, diffs) + } else { + return formatAsTemplate(out, opts.Format, diffs) + } + + return nil +} + +func printDifferencesSimple(out io.Writer, diffs []Difference) { + if len(diffs) == 0 { + fmt.Fprintln(out, "No differences found.") + return + } + + fmt.Fprintf(out, "Listing %d differences:\n", len(diffs)) + for _, d := range diffs { + color.Fprintf(out, " - %s\n", d) + } +} + +func filterDiffs(diffs []Difference, differences []string) ([]Difference, error) { + wantDiffs := map[DifferenceType]bool{} + for _, d := range differences { + var ok bool + for _, diff := range differenceTypes { + if string(diff) == d { + ok = true + break + } + } + if !ok { + return nil, fmt.Errorf("unknown difference type: %s", d) + } + wantDiffs[DifferenceType(d)] = true + } + var list []Difference + for _, d := range diffs { + if want := wantDiffs[d.Type]; want { + list = append(list, d) + } + } + return list, nil +} diff --git a/cmd/govpp/cmd_vppapi_export.go b/cmd/govpp/cmd_vppapi_export.go new file mode 100644 index 00000000..02ddd38c --- /dev/null +++ b/cmd/govpp/cmd_vppapi_export.go @@ -0,0 +1,226 @@ +// Copyright (c) 2023 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 main + +import ( + "archive/tar" + "compress/gzip" + "fmt" + "io" + "os" + "path/filepath" + "strings" + + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + + "github.com/alkiranet/govpp/binapigen/vppapi" +) + +// TODO: +// - add option for exporting flat structure +// - embed VPP version into export somehow + +type VppApiExportCmdOptions struct { + *VppApiCmdOptions + + Output string + Targz bool +} + +func newVppApiExportCmd(cli Cli, vppapiOpts *VppApiCmdOptions) *cobra.Command { + var ( + opts = VppApiExportCmdOptions{VppApiCmdOptions: vppapiOpts} + ) + cmd := &cobra.Command{ + Use: "export [INPUT] --output OUTPUT [--targz]", + Short: "Export VPP API", + Long: "Export VPP API files from an input location to an output location.", + Args: cobra.MaximumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) > 0 { + opts.Input = args[0] + } + // auto-detect .tar.gz + if !cmd.Flags().Changed("targz") && strings.HasSuffix(opts.Output, ".tar.gz") { + opts.Targz = true + } + return runExportCmd(opts) + }, + } + + cmd.PersistentFlags().BoolVar(&opts.Targz, "targz", false, "Export to gzipped tarball") + cmd.PersistentFlags().StringVarP(&opts.Output, "output", "o", "", "Output directory for the exported files") + must(cobra.MarkFlagRequired(cmd.PersistentFlags(), "output")) + + return cmd +} + +func runExportCmd(opts VppApiExportCmdOptions) error { + vppInput, err := resolveInput(opts.Input) + if err != nil { + return err + } + + // collect files from input + logrus.Tracef("collecting files for export in API dir: %s", vppInput.ApiDirectory) + + files, err := vppapi.FindFiles(vppInput.ApiDirectory) + if err != nil { + return err + } + + logrus.Debugf("exporting %d files", len(files)) + + if opts.Targz { + temp, err := os.MkdirTemp("", "govpp-vppapi-export-*") + if err != nil { + return fmt.Errorf("creating temp dir failed: %w", err) + } + tmpDir := filepath.Join(temp, "vppapi") + err = exportFilesToDir(tmpDir, files, vppInput) + if err != nil { + return fmt.Errorf("exporting to directory failed: %w", err) + } + var files2 = []string{filepath.Join(tmpDir, "VPP_VERSION")} + for _, f := range files { + filerel, err := filepath.Rel(vppInput.ApiDirectory, f) + if err != nil { + filerel = strings.TrimPrefix(f, vppInput.ApiDirectory) + } + filename := filepath.Join(tmpDir, filerel) + files2 = append(files2, filename) + } + err = exportFilesToTarGz(opts.Output, files2, tmpDir) + if err != nil { + return fmt.Errorf("exporting to gzipped tarball failed: %w", err) + } + } else { + err = exportFilesToDir(opts.Output, files, vppInput) + if err != nil { + return fmt.Errorf("exporting failed: %w", err) + } + } + + logrus.Debugf("exported %d files to %s", len(files), opts.Output) + + return nil +} + +func exportFilesToTarGz(outputFile string, files []string, baseDir string) error { + logrus.Tracef("exporting %d files into tarball archive: %s", len(files), outputFile) + + // create the output file for writing + fw, err := os.Create(outputFile) + if err != nil { + return err + } + defer fw.Close() + + // create a new gzip writer + gw := gzip.NewWriter(fw) + defer gw.Close() + + // create a new tar writer + tw := tar.NewWriter(gw) + defer tw.Close() + + for _, file := range files { + // open the file for reading + fr, err := os.Open(file) + if err != nil { + return err + } + + fi, err := fr.Stat() + if err != nil { + fr.Close() + return err + } + + // create a new dir/file header + header, err := tar.FileInfoHeader(fi, fi.Name()) + if err != nil { + fr.Close() + return err + } + + // update the name to correctly reflect the desired destination when untaring + header.Name = strings.TrimPrefix(file, baseDir) + + logrus.Tracef("- exporting file: %q to: %s", file, header.Name) + + // write the header + if err := tw.WriteHeader(header); err != nil { + fr.Close() + return err + } + + // copy file data to tar writer + if _, err := io.Copy(tw, fr); err != nil { + fr.Close() + return err + } + + fr.Close() + } + + return nil +} + +func exportFilesToDir(outputDir string, files []string, vppInput *vppapi.VppInput) error { + logrus.Tracef("exporting files into directory: %s", outputDir) + + apiDir := vppInput.ApiDirectory + + // create the output directory for export + if err := os.Mkdir(outputDir, 0750); err != nil { + return err + } + + // export files to directory + for _, f := range files { + data, err := os.ReadFile(f) + if err != nil { + return err + } + filerel, err := filepath.Rel(apiDir, f) + if err != nil { + logrus.Debugf("filepath.Rel error: %v", err) + filerel = strings.TrimPrefix(f, apiDir) + } + filename := filepath.Join(outputDir, filerel) + dir := filepath.Dir(filename) + + if err := os.MkdirAll(dir, 0750); err != nil { + return err + } + + if err := os.WriteFile(filename, data, 0660); err != nil { + return err + } + + logrus.Tracef("file %s exported (%d bytes) to %s", filerel, len(data), dir) + } + + // write version + filename := filepath.Join(outputDir, "VPP_VERSION") + data := []byte(vppInput.Schema.Version) + if err := os.WriteFile(filename, data, 0660); err != nil { + return err + } + + return nil +} diff --git a/cmd/govpp/cmd_vppapi_lint.go b/cmd/govpp/cmd_vppapi_lint.go new file mode 100644 index 00000000..9afe07b2 --- /dev/null +++ b/cmd/govpp/cmd_vppapi_lint.go @@ -0,0 +1,163 @@ +// Copyright (c) 2023 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 main + +import ( + "fmt" + "io" + + "github.com/olekukonko/tablewriter" + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" +) + +// TODO: +// - consider adding categories for linter rules + +type VppApiLintCmdOptions struct { + *VppApiCmdOptions + + Rules []string + Except []string + ExitCode bool + ListRules bool +} + +func newVppApiLintCmd(cli Cli, vppapiOpts *VppApiCmdOptions) *cobra.Command { + var ( + opts = VppApiLintCmdOptions{VppApiCmdOptions: vppapiOpts} + ) + cmd := &cobra.Command{ + Use: "lint [INPUT] [--rules RULE]...", + Short: "Lint VPP API", + Long: "Run linter checks for VPP API files", + Args: cobra.MaximumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) > 0 { + opts.Input = args[0] + } + return runVppApiLintCmd(cmd.OutOrStdout(), opts) + }, + } + + cmd.PersistentFlags().StringSliceVar(&opts.Rules, "rules", nil, "Limit to specific linter rules") + cmd.PersistentFlags().StringSliceVar(&opts.Except, "except", nil, "Skip specific linter rules.") + cmd.PersistentFlags().BoolVar(&opts.ExitCode, "exit-code", false, "Exit with non-zero exit code if any issue is found") + cmd.PersistentFlags().BoolVar(&opts.ListRules, "list-rules", false, "List all known linter rules") + + return cmd +} + +func runVppApiLintCmd(out io.Writer, opts VppApiLintCmdOptions) error { + if opts.ListRules { + rules := LintRules(defaultLintRules...) + if opts.Format == "" { + printLintRulesAsTable(out, rules) + } else { + return formatAsTemplate(out, opts.Format, rules) + } + return nil + } + + vppInput, err := resolveInput(opts.Input) + if err != nil { + return err + } + + schema := vppInput.Schema + + // filter files + apifiles := filterFilesByPaths(schema.Files, opts.Paths) + if len(apifiles) == 0 { + return fmt.Errorf("filter matched no files") + } + logrus.Debugf("filtered %d/%d files", len(apifiles), len(schema.Files)) + + linter := NewLinter() + + if len(opts.Rules) > 0 { + logrus.Debugf("setting lint rules to: %v", opts.Rules) + linter.SetRules(opts.Rules) + } + if len(opts.Except) > 0 { + logrus.Debugf("disabling lint rules: %v", opts.Except) + linter.Disable(opts.Except...) + } + + if err := linter.Lint(&schema); err != nil { + if errs, ok := err.(LintIssues); ok { + if opts.Format == "" { + printLintErrorsAsTable(out, errs) + } else { + return formatAsTemplate(out, opts.Format, errs) + } + if opts.ExitCode { + return err + } else { + logrus.Errorln("Linter found:", err) + } + } else { + return fmt.Errorf("linter failure: %w", err) + } + } else { + if opts.Format == "" { + fmt.Fprintln(out, "No issues found") + } else { + return formatAsTemplate(out, opts.Format, nil) + } + } + + return nil +} + +func printLintRulesAsTable(out io.Writer, rules []*LintRule) { + table := tablewriter.NewWriter(out) + table.SetHeader([]string{ + "#", "Id", "Purpose", + }) + table.SetAutoMergeCells(false) + table.SetAutoWrapText(false) + table.SetRowLine(false) + table.SetBorder(false) + for i, r := range rules { + index := i + 1 + table.Append([]string{ + fmt.Sprint(index), r.Id, r.Purpose, + }) + } + table.Render() +} + +func printLintErrorsAsTable(out io.Writer, errs LintIssues) { + table := tablewriter.NewWriter(out) + table.SetHeader([]string{ + "#", "Rule", "Location", "Violation", + }) + table.SetAutoMergeCells(true) + table.SetAutoWrapText(false) + table.SetRowLine(true) + table.SetBorder(false) + for i, e := range errs { + index := i + 1 + loc := e.File + if e.Line > 0 { + loc += fmt.Sprintf(":%d", e.Line) + } + table.Append([]string{ + fmt.Sprint(index), e.RuleId, loc, e.Violation, + }) + } + table.Render() +} diff --git a/cmd/govpp/cmd_vppapi_ls.go b/cmd/govpp/cmd_vppapi_ls.go new file mode 100644 index 00000000..2df838d1 --- /dev/null +++ b/cmd/govpp/cmd_vppapi_ls.go @@ -0,0 +1,550 @@ +// Copyright (c) 2023 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 main + +import ( + "bytes" + "fmt" + "io" + "os" + "path" + "path/filepath" + "strconv" + "strings" + + "github.com/olekukonko/tablewriter" + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + + "github.com/alkiranet/govpp/binapigen/vppapi" +) + +type VppApiLsCmdOptions struct { + *VppApiCmdOptions + + Paths []string + + IncludeImported bool + IncludeFields bool + + ShowContents bool + ShowMessages bool + ShowRPC bool + ShowRaw bool + + SortByName bool +} + +func newVppApiLsCmd(cli Cli, vppapiOpts *VppApiCmdOptions) *cobra.Command { + var ( + opts = VppApiLsCmdOptions{VppApiCmdOptions: vppapiOpts} + ) + cmd := &cobra.Command{ + Use: "ls [INPUT] [--path PATH]... [--show-contents | --show-messages | --show-raw | --show-rpc]", + Aliases: []string{"l", "list"}, + Short: "Show VPP API contents", + Long: "Show VPP API files and their contents", + Args: cobra.MaximumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) > 0 { + opts.Input = args[0] + } + return runVppApiLsCmd(cmd.OutOrStdout(), opts) + }, + } + + cmd.PersistentFlags().BoolVar(&opts.IncludeImported, "include-imported", false, "Include imported types") + cmd.PersistentFlags().BoolVar(&opts.IncludeFields, "include-fields", false, "Include message fields") + cmd.PersistentFlags().BoolVar(&opts.ShowContents, "show-contents", false, "Show contents of VPP API file(s)") + cmd.PersistentFlags().BoolVar(&opts.ShowRPC, "show-rpc", false, "Show service RPCs of VPP API file(s)") + cmd.PersistentFlags().BoolVar(&opts.ShowMessages, "show-messages", false, "Show messages for VPP API file(s)") + cmd.PersistentFlags().BoolVar(&opts.ShowRaw, "show-raw", false, "Show raw VPP API file(s)") + cmd.PersistentFlags().BoolVar(&opts.SortByName, "sort-by-name", true, "Sort by name") + + return cmd +} + +func runVppApiLsCmd(out io.Writer, opts VppApiLsCmdOptions) error { + vppInput, err := resolveInput(opts.Input) + if err != nil { + return err + } + + allapifiles := vppInput.Schema.Files + + logrus.Debugf("processing %d files", len(allapifiles)) + + apifiles, err := prepareVppApiFiles(allapifiles, opts.Paths, opts.IncludeImported, opts.SortByName) + if err != nil { + return err + } + + // format output + if format := opts.Format; len(format) == 0 { + if opts.ShowMessages { + apimsgs := listVPPAPIMessages(apifiles) + showVPPAPIMessages(out, apimsgs, opts.IncludeFields) + } else if opts.ShowRPC { + showVPPAPIRPCs(out, apifiles) + } else if opts.ShowContents { + showVPPAPIContents(out, apifiles) + } else if opts.ShowRaw { + rawFiles := getVppApiRawFiles(vppInput.ApiDirectory, apifiles) + showVPPAPIRaw(out, rawFiles) + } else { + showVPPAPIList(out, apifiles) + } + } else { + if err := formatAsTemplate(out, format, apifiles); err != nil { + return err + } + } + + return nil +} + +type VppApiRawFile struct { + Name string + Path string + Content string +} + +func getVppApiRawFiles(apiDir string, files []vppapi.File) []VppApiRawFile { + var rawFiles []VppApiRawFile + for _, file := range files { + filePath := filepath.Join(apiDir, file.Path) + b, err := os.ReadFile(filePath) + if err != nil { + logrus.Errorf("failed to read file %q: %v", filePath, err) + continue + } + rawFiles = append(rawFiles, VppApiRawFile{ + Path: file.Path, + Name: file.Name, + Content: string(b), + }) + } + return rawFiles +} + +func showVPPAPIRaw(out io.Writer, rawFiles []VppApiRawFile) { + if len(rawFiles) == 0 { + logrus.Errorf("no files to show") + return + } + for _, f := range rawFiles { + fmt.Fprintf(out, "# %s (%v)\n", f.Name, f.Path) + fmt.Fprintf(out, "%s\n", f.Content) + fmt.Fprintln(out) + } +} + +type VppApiFile struct { + File string + Version string + CRC string + Options string + Path string + NumImports uint + NumMessages uint + NumTypes uint + NumRPCs uint +} + +func showVPPAPIList(out io.Writer, apifiles []vppapi.File) { + table := tablewriter.NewWriter(out) + table.SetHeader([]string{ + "#", "API", "Version", "CRC", "Path", "Imports", "Messages", "Types", "RPCs", "Options", + }) + //table.SetAutoMergeCells(true) + table.SetAutoWrapText(false) + table.SetRowLine(false) + table.SetBorder(false) + table.SetColumnAlignment([]int{ + tablewriter.ALIGN_RIGHT, 0, 0, tablewriter.ALIGN_LEFT, 0, tablewriter.ALIGN_RIGHT, tablewriter.ALIGN_RIGHT, tablewriter.ALIGN_RIGHT, tablewriter.ALIGN_RIGHT, tablewriter.ALIGN_LEFT, + }) + + for i, apifile := range apifiles { + index := i + 1 + + typesCount := getFileTypesCount(apifile) + apiVersion := getFileVersion(apifile) + apiCrc := getShortCrc(apifile.CRC) + options := strings.Join(getFileOptionsSlice(apifile), ", ") + apiDirPath := path.Dir(pathOfParentAndFile(apifile.Path)) + + var msgs string + if len(apifile.Messages) > 0 { + msgs = fmt.Sprintf("%3d", len(apifile.Messages)) + } else { + msgs = fmt.Sprintf("%3s", "-") + } + var types string + if typesCount > 0 { + types = fmt.Sprintf("%2d", typesCount) + } else { + types = fmt.Sprintf("%2s", "-") + } + var services string + if apifile.Service != nil { + services = fmt.Sprintf("%2d", len(apifile.Service.RPCs)) + } else { + services = fmt.Sprintf("%2s", "-") + } + var importCount string + if len(apifile.Imports) > 0 { + importCount = fmt.Sprintf("%2d", len(apifile.Imports)) + } else { + importCount = fmt.Sprintf("%2s", "-") + } + + row := []string{ + fmt.Sprint(index), apifile.Name, apiVersion, apiCrc, apiDirPath, importCount, msgs, types, services, options, + } + + table.Append(row) + } + table.Render() +} + +func pathOfParentAndFile(path string) string { + // Split the path into components separated by "/" + components := strings.Split(path, "/") + + // If there are less than 2 components, the output is the same as the input + if len(components) < 2 { + return path + } + + // Return the last two components joined by "/" + return strings.Join(components[len(components)-2:], "/") +} + +const maxCommentLengthInColumn = 80 + +func showVPPAPIContents(out io.Writer, apifiles []vppapi.File) { + var buf bytes.Buffer + + for _, apifile := range apifiles { + apiVersion := getFileVersion(apifile) + options := getFileOptionsSlice(apifile) + + // print file header + fmt.Fprintln(&buf, "--------------------------------------------------------------------------------") + fmt.Fprintf(&buf, "# %v (%s) %v (%v) \n", apifile.Name, apifile.Path, apiVersion, apifile.CRC) + if len(options) > 0 { + fmt.Fprintf(&buf, "# Options: %v\n", mapStr(apifile.Options)) + } + fmt.Fprintln(&buf, "--------------------------------------------------------------------------------") + fmt.Fprintln(&buf) + + // Messages + if len(apifile.Messages) > 0 { + table := tablewriter.NewWriter(&buf) + table.SetHeader([]string{"#", "Message", "CRC", "Fields", "Options", "Comment"}) + table.SetHeaderAlignment(tablewriter.ALIGN_LEFT) + table.SetAutoWrapText(false) + table.SetRowLine(false) + table.SetColumnSeparator(" ") + table.SetHeaderLine(false) + table.SetBorder(false) + + for i, msg := range apifile.Messages { + index := i + 1 + msgCrc := getShortCrc(msg.CRC) + msgFields := fmt.Sprintf("%v", len(msg.Fields)) + msgOptions := shorMessageOptions(msg.Options) + msgComment := normalizeMessageComment(msg.Comment) + row := []string{strconv.Itoa(index), msg.Name, msgCrc, msgFields, msgOptions, msgComment} + table.Append(row) + } + + table.Render() + buf.Write([]byte("\n")) + } + + // Structs + if len(apifile.StructTypes) > 0 { + table := tablewriter.NewWriter(&buf) + table.SetHeader([]string{"#", "Type", "Fields"}) + table.SetHeaderAlignment(tablewriter.ALIGN_LEFT) + table.SetAutoWrapText(false) + table.SetRowLine(false) + table.SetColumnSeparator(" ") + table.SetHeaderLine(false) + table.SetBorder(false) + + for i, typ := range apifile.StructTypes { + index := i + 1 + fields := fmt.Sprintf("%v", len(typ.Fields)) + row := []string{strconv.Itoa(index), typ.Name, fields} + table.Append(row) + } + + table.Render() + buf.Write([]byte("\n")) + } + + // Unions + if len(apifile.UnionTypes) > 0 { + table := tablewriter.NewWriter(&buf) + table.SetHeader([]string{"#", "UNION", "FIELDS"}) + table.SetHeaderAlignment(tablewriter.ALIGN_LEFT) + table.SetAutoWrapText(false) + table.SetRowLine(false) + table.SetColumnSeparator(" ") + table.SetHeaderLine(false) + table.SetBorder(false) + + for i, typ := range apifile.UnionTypes { + index := i + 1 + fields := fmt.Sprintf("%v", len(typ.Fields)) + row := []string{strconv.Itoa(index), typ.Name, fields} + table.Append(row) + } + + table.Render() + buf.Write([]byte("\n")) + } + + // Enums + if len(apifile.EnumTypes) > 0 || len(apifile.EnumflagTypes) > 0 { + table := tablewriter.NewWriter(&buf) + table.SetHeader([]string{"#", "Enum", "Type", "Kind", "Entries"}) + table.SetHeaderAlignment(tablewriter.ALIGN_LEFT) + table.SetAutoWrapText(false) + table.SetRowLine(false) + table.SetColumnSeparator(" ") + table.SetHeaderLine(false) + table.SetBorder(false) + + for i, typ := range apifile.EnumTypes { + index := i + 1 + typEntries := fmt.Sprintf("%v", len(typ.Entries)) + row := []string{strconv.Itoa(index), typ.Name, typ.Type, "enum", typEntries} + table.Append(row) + } + for i, typ := range apifile.EnumflagTypes { + index := i + 1 + typEntries := fmt.Sprintf("%v", len(typ.Entries)) + row := []string{strconv.Itoa(index), typ.Name, typ.Type, "flag", typEntries} + table.Append(row) + } + + table.Render() + buf.Write([]byte("\n")) + } + + // Aliases + if len(apifile.AliasTypes) > 0 { + table := tablewriter.NewWriter(&buf) + table.SetHeader([]string{"#", "Alias", "Type", "Length"}) + table.SetHeaderAlignment(tablewriter.ALIGN_LEFT) + table.SetAutoWrapText(false) + table.SetRowLine(false) + table.SetColumnSeparator(" ") + table.SetHeaderLine(false) + table.SetBorder(false) + + for i, typ := range apifile.AliasTypes { + index := i + 1 + row := []string{strconv.Itoa(index), typ.Name, typ.Type, strconv.Itoa(typ.Length)} + table.Append(row) + } + + table.Render() + buf.Write([]byte("\n")) + + } + + } + + fmt.Fprint(out, buf.String()) +} + +func getShortCrc(crc string) string { + return strings.TrimPrefix(crc, "0x") +} + +const maxLengthMsgOptionValue = 30 + +func shorMessageOptions(options map[string]string) string { + opts := make(map[string]string, len(options)) + for k, v := range options { + if len(v) > maxLengthMsgOptionValue { + opts[k] = v[:maxLengthMsgOptionValue] + "..." + } else { + opts[k] = v + } + } + return fmt.Sprintf("%v", mapStrOrdered(opts)) +} + +func normalizeMessageComment(comment string) string { + if comment == "" { + return "" + } + + // get first line + commentParts := strings.Split(comment, "\n") + if len(commentParts) > 1 && strings.TrimSpace(commentParts[0]) == "/*" { + commentParts = commentParts[1:] + } + + msgComment := strings.TrimSpace(commentParts[0]) + + // strip useless parts + msgComment = strings.TrimPrefix(msgComment, "*") + msgComment = strings.TrimPrefix(msgComment, "/**") + msgComment = strings.ReplaceAll(msgComment, "\\brief", "") + msgComment = strings.ReplaceAll(msgComment, "@brief", "") + msgComment = strings.TrimSpace(msgComment) + + // cut long comments + if len(msgComment) > maxCommentLengthInColumn { + msgComment = msgComment[:maxCommentLengthInColumn] + "..." + } + + return msgComment +} + +type VppApiFileMessage struct { + File *vppapi.File + vppapi.Message +} + +func listVPPAPIMessages(apifiles []vppapi.File) []VppApiFileMessage { + var msgs []VppApiFileMessage + for _, apifile := range apifiles { + file := apifile + for _, msg := range apifile.Messages { + msgs = append(msgs, VppApiFileMessage{ + File: &file, + Message: msg, + }) + } + } + return msgs +} + +func showVPPAPIMessages(out io.Writer, msgs []VppApiFileMessage, withFields bool) { + table := tablewriter.NewWriter(out) + table.SetHeader([]string{ + "#", "File", "Message", "Fields", "Options", + }) + table.SetAutoWrapText(false) + table.SetRowLine(true) + table.SetAutoWrapText(false) + table.SetRowLine(false) + table.SetColumnSeparator(" ") + table.SetHeaderLine(false) + table.SetBorder(false) + + for i, msg := range msgs { + index := fmt.Sprint(i + 1) + fileName := "" + if msg.File != nil { + fileName = msg.File.Name + } + msgFields := fmt.Sprintf("%d", len(msg.Fields)) + if withFields { + msgFields = strings.TrimSpace(yamlTmpl(msgFieldsStr(msg.Fields))) + } + msgOptions := shorMessageOptions(msg.Options) + + row := []string{ + index, fileName, msg.Name, msgFields, msgOptions, + } + table.Append(row) + } + table.Render() +} + +func showVPPAPIRPCs(out io.Writer, apifiles []vppapi.File) { + table := tablewriter.NewWriter(out) + table.SetHeader([]string{ + "API", "Request", "Reply", "Stream", "StreamMsg", "Events", + }) + table.SetAutoWrapText(false) + table.SetRowLine(true) + + for _, apifile := range apifiles { + if apifile.Service == nil { + continue + } + for _, rpc := range apifile.Service.RPCs { + rpcEvents := strings.Join(rpc.Events, ", ") + + row := []string{ + apifile.Name, rpc.Request, rpc.Reply, fmt.Sprint(rpc.Stream), rpc.StreamMsg, rpcEvents, + } + table.Append(row) + } + } + table.Render() +} + +func msgFieldsStr(fields []vppapi.Field) []string { + var list []string + for _, f := range fields { + var s string + meta := "" + if len(f.Meta) != 0 { + var metas []string + for k, v := range f.Meta { + metas = append(metas, fmt.Sprintf("%s=%v", k, v)) + } + meta = fmt.Sprintf("(%v)", strings.Join(metas, ", ")) + } + if f.Array { + length := fmt.Sprint(f.Length) + if f.SizeFrom != "" { + length = f.SizeFrom + } + s = fmt.Sprintf("%s [%v]%s", f.Name, length, f.Type) + } else { + s = fmt.Sprintf("%s %s", f.Name, f.Type) + } + if meta != "" { + s += fmt.Sprintf(" %v", meta) + } + list = append(list, s) + } + return list +} + +func getFileTypesCount(apifile vppapi.File) int { + return len(apifile.EnumTypes) + len(apifile.EnumflagTypes) + len(apifile.AliasTypes) + len(apifile.StructTypes) + len(apifile.UnionTypes) +} + +func getFileVersion(apifile vppapi.File) string { + for k, v := range apifile.Options { + if k == vppapi.OptFileVersion { + return v + } + } + return "0.0.0" +} + +func getFileOptionsSlice(apifile vppapi.File) []string { + var options []string + for k, v := range apifile.Options { + if k == vppapi.OptFileVersion { + continue + } + options = append(options, fmt.Sprintf("%s=%v", k, v)) + } + return options +} diff --git a/cmd/govpp/compare.go b/cmd/govpp/compare.go new file mode 100644 index 00000000..9b4fac83 --- /dev/null +++ b/cmd/govpp/compare.go @@ -0,0 +1,353 @@ +// Copyright (c) 2023 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 main + +import ( + "strings" + + "github.com/gookit/color" + "github.com/sirupsen/logrus" + + "github.com/alkiranet/govpp/binapigen/vppapi" +) + +// DifferenceType represents the type of difference found in the comparison. +type DifferenceType string + +const ( + VersionDifference DifferenceType = "Version" + TotalFilesDifference DifferenceType = "FilesCount" + + FileAddedDifference DifferenceType = "FileAdded" + FileRemovedDifference DifferenceType = "FileRemoved" + FileMovedDifference DifferenceType = "FileMoved" + FileVersionDifference DifferenceType = "FileVersion" + FileCrcDifference DifferenceType = "FileCRC" + FileContentsChangedDifference DifferenceType = "FileContentsChanged" + + MessageAddedDifference DifferenceType = "MessageAdded" + MessageRemovedDifference DifferenceType = "MessageRemoved" + MessageCrcDifference DifferenceType = "MessageCRC" + MessageCommentDifference DifferenceType = "MessageComment" + + MsgOptionChangedDifference DifferenceType = "MsgOptionChanged" + MsgOptionAddedDifference DifferenceType = "MsgOptionAdded" + MsgOptionRemovedDifference DifferenceType = "MsgOptionRemoved" +) + +var differenceTypes = []DifferenceType{ + VersionDifference, + TotalFilesDifference, + FileAddedDifference, + FileRemovedDifference, + FileMovedDifference, + FileVersionDifference, + FileCrcDifference, + FileContentsChangedDifference, + MessageAddedDifference, + MessageRemovedDifference, + MessageCrcDifference, + MsgOptionChangedDifference, + MsgOptionAddedDifference, + MsgOptionRemovedDifference, +} + +// Difference represents a difference between two API schemas. +type Difference struct { + Type DifferenceType + File string + Description string + Value1, Value2 any +} + +func (d Difference) String() string { + var b strings.Builder + color.Fprintf(&b, "[%v] ", clrWhite.Sprint(d.Type)) + if d.File != "" { + color.Fprintf(&b, "%s: ", clrDiffFile.Sprint(d.File)) + } + color.Fprintf(&b, "%v", d.Description) + return b.String() +} + +// CompareSchemas compares two API schemas and returns a list of differences. +func CompareSchemas(schema1, schema2 *vppapi.Schema) []Difference { + var differences []Difference + + // compare VPP version + if schema1.Version != schema2.Version { + differences = append(differences, Difference{ + Type: VersionDifference, + Description: color.Sprintf("Schema version is different: %s vs %s", + clrWhite.Sprint(schema1.Version), clrWhite.Sprint(schema2.Version)), + Value1: schema1.Version, + Value2: schema2.Version, + }) + } + // compare file count + if len(schema1.Files) != len(schema2.Files) { + differences = append(differences, Difference{ + Type: TotalFilesDifference, + Description: color.Sprintf("Total file count %s from %v to %v", + clrWhite.Sprint(numberChangeString(len(schema1.Files), len(schema2.Files))), clrWhite.Sprint(len(schema1.Files)), clrWhite.Sprint(len(schema2.Files))), + Value1: len(schema1.Files), + Value2: len(schema2.Files), + }) + } + + // compare schema files + fileMap1 := make(map[string]vppapi.File) + for _, file := range schema1.Files { + fileMap1[file.Name] = file + } + fileMap2 := make(map[string]vppapi.File) + for _, file := range schema2.Files { + fileMap2[file.Name] = file + } + // removed files + for fileName, file1 := range fileMap1 { + if file2, ok := fileMap2[fileName]; ok { + fileDiffs := compareFiles(file1, file2) + for _, fileDiff := range fileDiffs { + fileDiff.File = fileName + differences = append(differences, fileDiff) + } + } else { + differences = append(differences, Difference{ + Type: FileRemovedDifference, + File: fileName, + Description: "File removed", + Value1: file1, + Value2: nil, + }) + } + } + // added files + for fileName, file2 := range fileMap2 { + if _, ok := fileMap1[fileName]; !ok { + differences = append(differences, Difference{ + Type: FileAddedDifference, + File: fileName, + Description: "File added", + Value1: nil, + Value2: file2, + }) + } + } + return differences +} + +// compareFiles compares two files and returns a list of differences. +func compareFiles(file1, file2 vppapi.File) []Difference { + if file1.Name != file2.Name { + logrus.Fatalf("comparing different files (%s vs. %s)", file1.Name, file2.Name) + } + + var differences []Difference + + // Compare file properties + if file1.Path != file2.Path { + differences = append(differences, Difference{ + Type: FileMovedDifference, + Description: color.Sprintf("File moved from %s to %s", + clrWhite.Sprint(file1.Path), clrWhite.Sprint(file2.Path)), + Value1: file1.Path, + Value2: file2.Path, + }) + } + if fileVer1, fileVer2 := file1.Options[vppapi.OptFileVersion], file2.Options[vppapi.OptFileVersion]; fileVer1 != fileVer2 { + differences = append(differences, Difference{ + Type: FileVersionDifference, + Description: color.Sprintf("File version changed from %s to %s", + clrWhite.Sprint(fileVer1), clrWhite.Sprint(fileVer2)), + Value1: fileVer1, + Value2: fileVer2, + }) + } + if file1.CRC != file2.CRC { + differences = append(differences, Difference{ + Type: FileCrcDifference, + Description: color.Sprintf("File CRC changed from %s to %s", + clrWhite.Sprint(file1.CRC), clrWhite.Sprint(file2.CRC)), + Value1: file1.CRC, + Value2: file2.CRC, + }) + } + + // Compare number of messages and types + if len(file1.Messages) != len(file2.Messages) { + differences = append(differences, numberOfContentChangedDifference("Messages", len(file1.Messages), len(file2.Messages))) + } + if len(file1.StructTypes) != len(file2.StructTypes) { + differences = append(differences, numberOfContentChangedDifference("Types", len(file1.StructTypes), len(file2.StructTypes))) + } + if len(file1.UnionTypes) != len(file2.UnionTypes) { + differences = append(differences, numberOfContentChangedDifference("Unions", len(file1.UnionTypes), len(file2.UnionTypes))) + } + if len(file1.AliasTypes) != len(file2.AliasTypes) { + differences = append(differences, numberOfContentChangedDifference("Aliases", len(file1.AliasTypes), len(file2.AliasTypes))) + } + if len(file1.EnumTypes) != len(file2.EnumTypes) { + differences = append(differences, numberOfContentChangedDifference("Enums", len(file1.EnumTypes), len(file2.EnumTypes))) + } + if len(file1.EnumflagTypes) != len(file2.EnumflagTypes) { + differences = append(differences, numberOfContentChangedDifference("Enumflags", len(file1.EnumflagTypes), len(file2.EnumflagTypes))) + } + + // Compare file messages + msgMap1 := make(map[string]vppapi.Message) + for _, msg := range file1.Messages { + msgMap1[msg.Name] = msg + } + msgMap2 := make(map[string]vppapi.Message) + for _, msg := range file2.Messages { + msgMap2[msg.Name] = msg + } + // removed messages + for msgName, msg1 := range msgMap1 { + if msg2, ok := msgMap2[msgName]; ok { + msgDiffs := compareMessages(msg1, msg2) + for _, msgDiff := range msgDiffs { + if msgDiff.Value1 == nil { + msgDiff.Value1 = msg1 + } + if msgDiff.Value2 == nil { + msgDiff.Value2 = msg2 + } + differences = append(differences, msgDiff) + } + } else { + differences = append(differences, Difference{ + Type: MessageRemovedDifference, + Description: color.Sprintf("Message removed: %s", clrCyan.Sprint(msgName)), + Value1: msg1, + Value2: nil, + }) + } + } + // added messages + for msgName, msg := range msgMap2 { + if _, ok := msgMap1[msgName]; !ok { + differences = append(differences, Difference{ + Type: MessageAddedDifference, + Description: color.Sprintf("Message added: %s", clrCyan.Sprint(msgName)), + Value1: nil, + Value2: msg, + }) + } + } + + return differences +} + +func compareMessages(msg1 vppapi.Message, msg2 vppapi.Message) []Difference { + if msg1.Name != msg2.Name { + logrus.Fatalf("comparing different messages (%s vs. %s)", msg1.Name, msg2.Name) + } + + var differences []Difference + + // Compare message properties + if msg1.CRC != msg2.CRC { + differences = append(differences, Difference{ + Type: MessageCrcDifference, + Description: color.Sprintf("Message %s changed CRC from %s to %s", + clrCyan.Sprint(msg1.Name), clrWhite.Sprint(msg1.CRC), clrWhite.Sprint(msg2.CRC)), + Value1: msg1.CRC, + Value2: msg2.CRC, + }) + } + + // Compare message comments + if msg1.Comment != msg2.Comment { + desc := color.Sprintf("Message %s comment ", clrCyan.Sprint(msg1.Name)) + if msg1.Comment == "" { + desc += "added" + } else if msg2.Comment == "" { + desc += "removed" + } else { + desc += "changed" + } + differences = append(differences, Difference{ + Type: MessageCommentDifference, + Description: desc, + Value1: msg1.Comment, + Value2: msg2.Comment, + }) + } + + // removed options + for option, val1 := range msg1.Options { + if val2, ok := msg2.Options[option]; ok { + if val1 != val2 { + differences = append(differences, Difference{ + Type: MsgOptionChangedDifference, + Description: color.Sprintf("Message %s changed option %s from %q to %q", + clrCyan.Sprint(msg1.Name), clrWhite.Sprint(option), clrWhite.Sprint(val1), clrWhite.Sprint(val2)), + }) + } + } else { + differences = append(differences, Difference{ + Type: MsgOptionRemovedDifference, + Description: color.Sprintf("Message %s removed option: %s", + clrCyan.Sprint(msg1.Name), clrWhite.Sprint(option)), + Value1: keyValString(option, val1), + Value2: nil, + }) + } + } + // added options + for option, val := range msg2.Options { + if _, ok := msg1.Options[option]; !ok { + differences = append(differences, Difference{ + Type: MsgOptionAddedDifference, + Description: color.Sprintf("Message %s added option: %s", + clrCyan.Sprint(msg2.Name), clrWhite.Sprint(keyValString(option, val))), + Value1: nil, + Value2: keyValString(option, val), + }) + } + } + + return differences +} + +func numberOfContentChangedDifference(typ string, c1, c2 int) Difference { + return Difference{ + Type: FileContentsChangedDifference, + Description: color.Sprintf("Number of %s has %s from %v to %v", + clrWhite.Sprint(typ), clrWhite.Sprint(numberChangeString(c1, c2)), clrWhite.Sprint(c1), clrWhite.Sprint(c2)), + Value1: c1, + Value2: c2, + } +} + +func numberChangeString(n1, n2 int) string { + switch { + case n1 < n2: + return "increased" + case n1 > n2: + return "decreased" + default: + return "" + } +} + +func keyValString(k, v string) string { + if v == "" { + return k + } + return color.Sprintf("%s=%s", k, v) +} diff --git a/cmd/govpp/formatter.go b/cmd/govpp/formatter.go new file mode 100644 index 00000000..1895abfa --- /dev/null +++ b/cmd/govpp/formatter.go @@ -0,0 +1,125 @@ +// Copyright (c) 2023 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 main + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "strings" + "text/template" + "time" + + "gopkg.in/yaml.v3" +) + +var tmplFuncs = template.FuncMap{ + "json": jsonTmpl, + "yaml": yamlTmpl, + "epoch": epochTmpl, + "ago": agoTmpl, + "dur": shortHumanDuration, + "prefix": prefixTmpl, +} + +func formatAsTemplate(w io.Writer, format string, data interface{}) error { + var b bytes.Buffer + switch strings.ToLower(format) { + case "json": + s := jsonTmpl(data) + b.WriteString(s) + case "yaml", "yml": + b.WriteString(yamlTmpl(data)) + default: + t := template.New("format") + t.Funcs(tmplFuncs) + if _, err := t.Parse(format); err != nil { + return fmt.Errorf("parsing format template failed: %v", err) + } + if err := t.Execute(&b, data); err != nil { + return fmt.Errorf("executing format template failed: %v", err) + } + } + _, err := b.WriteTo(w) + return err +} + +func jsonTmpl(data interface{}) string { + b := encodeJson(data, " ") + return clearColorCode(string(b)) +} + +func yamlTmpl(data interface{}) string { + out := encodeJson(data, "") + bb, err := jsonToYaml(out) + if err != nil { + panic(err) + } + return clearColorCode(string(bb)) +} + +func encodeJson(data interface{}, ident string) []byte { + var b bytes.Buffer + encoder := json.NewEncoder(&b) + encoder.SetIndent("", ident) + if err := encoder.Encode(data); err != nil { + panic(err) + } + return b.Bytes() +} + +func jsonToYaml(j []byte) ([]byte, error) { + var jsonObj interface{} + err := yaml.Unmarshal(j, &jsonObj) + if err != nil { + return nil, err + } + return yaml.Marshal(jsonObj) +} + +func epochTmpl(s int64) time.Time { + return time.Unix(s, 0) +} + +func agoTmpl(t time.Time) time.Duration { + return time.Since(t).Round(time.Second) +} + +func shortHumanDuration(d time.Duration) string { + if seconds := int(d.Seconds()); seconds < -1 { + return "" + } else if seconds < 0 { + return "0s" + } else if seconds < 60 { + return fmt.Sprintf("%ds", seconds) + } else if minutes := int(d.Minutes()); minutes < 60 { + return fmt.Sprintf("%dm", minutes) + } else if hours := int(d.Hours()); hours < 24 { + return fmt.Sprintf("%dh", hours) + } else if hours < 24*365 { + return fmt.Sprintf("%dd", hours/24) + } + return fmt.Sprintf("%dy", int(d.Hours()/24/365)) +} + +func prefixTmpl(s string, prefix string) string { + ps := strings.TrimRight(s, "\n") + ps = strings.ReplaceAll(ps, "\n", "\n"+prefix) + if strings.HasSuffix(s, "\n") { + ps += "\n" + } + return prefix + ps +} diff --git a/cmd/govpp/input.go b/cmd/govpp/input.go new file mode 100644 index 00000000..0057a773 --- /dev/null +++ b/cmd/govpp/input.go @@ -0,0 +1,106 @@ +// Copyright (c) 2023 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 main + +import ( + "os" + "path" + "path/filepath" + "strings" + + "github.com/sirupsen/logrus" + + "github.com/alkiranet/govpp/binapigen/vppapi" +) + +func resolveInput(input string) (*vppapi.VppInput, error) { + if input == "" { + logrus.Tracef("input empty, trying to detect automatically") + input = detectVppApiInput() + } + + logrus.Tracef("resolving VPP input: %q", input) + + vppInput, err := vppapi.ResolveVppInput(input) + if err != nil { + return nil, err + } + + logrus.Tracef("resolved VPP input:\n - API dir: %s\n - VPP Version: %s\n - Files: %v", + vppInput.ApiDirectory, vppInput.Schema.Version, len(vppInput.Schema.Files)) + + return vppInput, nil +} + +func detectVppApiInput() string { + var ( + relPathSrcVpp = filepath.Join(".", "src", "vpp") + relPathBuildVppApi = filepath.Join(".", "build-root", "install-vpp-native", "vpp", "share", "vpp", "api") + ) + // check if VPP API files are built + if dirExists(relPathBuildVppApi) { + return relPathBuildVppApi + } + // check if within the VPP repository + if dirExists(relPathSrcVpp) { + return relPathBuildVppApi + } + // check if within VPP API directory + if dirExists("core", "plugins") { + return "." + } + // check if VPP is installed on the system + if dirExists(vppapi.DefaultDir) { + return vppapi.DefaultDir + } + // if none of the above conditions are met, return the current working directory + return "." +} + +func dirExists(dir ...string) bool { + for _, d := range dir { + if _, err := os.Stat(d); err != nil { + return false + } + } + return true +} + +func filterFilesByPaths(allapifiles []vppapi.File, paths []string) []vppapi.File { + var apifiles []vppapi.File + if len(paths) == 0 { + return allapifiles + } + added := make(map[string]bool) + // filter files + for _, arg := range paths { + var found bool + for _, apifile := range allapifiles { + if added[apifile.Path] { + continue + } + dir, file := path.Split(apifile.Path) + if apifile.Name == strings.TrimSuffix(arg, ".api") || apifile.Path == arg || file == arg || path.Clean(dir) == arg { + apifiles = append(apifiles, apifile) + found = true + added[apifile.Path] = true + } + } + if !found { + logrus.Warnf("path %q did not match any file", arg) + } + } + return apifiles +} diff --git a/cmd/govpp/linter.go b/cmd/govpp/linter.go new file mode 100644 index 00000000..d92d1b97 --- /dev/null +++ b/cmd/govpp/linter.go @@ -0,0 +1,441 @@ +// Copyright (c) 2023 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 main + +import ( + "fmt" + "regexp" + "strconv" + "strings" + + "github.com/gookit/color" + "github.com/sirupsen/logrus" + + "github.com/alkiranet/govpp/binapigen/vppapi" +) + +const ( + FILE_BASIC = "FILE_BASIC" + MESSAGE_DEPRECATE_OLDER_VERSIONS = "MESSAGE_DEPRECATE_OLDER_VERSIONS" + MESSAGE_SAME_STATUS = "MESSAGE_SAME_STATUS" +) + +var defaultLintRules = []string{ + FILE_BASIC, + MESSAGE_DEPRECATE_OLDER_VERSIONS, + MESSAGE_SAME_STATUS, +} + +type LintRule struct { + Id string + Purpose string + //Categories []string + check func(schema *vppapi.Schema) LintIssues +} + +func LintRules(ids ...string) []*LintRule { + var rules []*LintRule + for _, id := range ids { + rule := GetLintRule(id) + if rule != nil { + rules = append(rules, rule) + } + } + return rules +} + +func GetLintRule(id string) *LintRule { + rule, ok := lintRules[id] + if ok { + return &rule + } + return nil +} + +var lintRules = map[string]LintRule{ + FILE_BASIC: { + Id: FILE_BASIC, + Purpose: "File must have basic info defined", + check: checkFiles(checkFileBasic), + }, + MESSAGE_DEPRECATE_OLDER_VERSIONS: { + Id: MESSAGE_DEPRECATE_OLDER_VERSIONS, + Purpose: "Message should be marked as deprecated if newer version exists", + check: checkFiles(checkFileMessageDeprecateOldVersions), + }, + MESSAGE_SAME_STATUS: { + Id: MESSAGE_SAME_STATUS, + Purpose: "Message request and reply must have the same status", + check: checkFiles(checkFileMessageSameStatus), + }, +} + +func checkFileBasic(file *vppapi.File) LintIssues { + var issues LintIssues + if file.CRC == "" { + issues = issues.Append(fmt.Errorf("file %s must have CRC defined", file.Name)) + } + if file.Options != nil && file.Options[vppapi.OptFileVersion] == "" { + issues = issues.Append(fmt.Errorf("file %s must have version defined", file.Name)) + } + return issues +} + +func checkFileMessageDeprecateOldVersions(file *vppapi.File) LintIssues { + var issues LintIssues + + messageVersions := extractFileMessageVersions(file) + versionMessages := extractMessageVersions(file) + + for _, message := range file.Messages { + baseName, version := extractBaseNameAndVersion(message.Name) + + // if this is not the latest version of a message + if version < messageVersions[baseName] { + var newer vppapi.Message + if vers, ok := versionMessages[baseName]; ok { + if newVer, ok := vers[version+1]; ok { + newer = newVer + } + } + + // older messages should be marked as deprecated (if newer message version is not in progress) + if !isMessageDeprecated(message) && !isMessageInProgress(newer) { + issues = issues.Append(LintIssue{ + File: file.Path, + // TODO: Line: ?, + Object: map[string]any{ + "Message": message, + "Base": baseName, + "Version": version, + "Latest": messageVersions[baseName], + }, + Violation: color.Sprintf("message %s has newer version available (%v) but is not marked as deprecated", + color.Cyan.Sprint(message.Name), color.Cyan.Sprint(newer.Name)), + }) + } + } + } + + return issues +} + +func checkFileMessageSameStatus(file *vppapi.File) LintIssues { + var issues LintIssues + + for _, message := range file.Messages { + status := getMessageStatus(message) + relatedMsgs := getRelatedMessages(file, message.Name) + + for _, relatedMsg := range relatedMsgs { + relMsg, ok := getFileMessage(file, relatedMsg) + if !ok { + logrus.Warnf("could not find related message %s in file %s", relatedMsg, file.Path) + continue + } + if relStatus := getMessageStatus(relMsg); relStatus != status { + issues = issues.Append(LintIssue{ + File: file.Path, + Object: map[string]any{ + "Message": message, + "Related": relMsg, + "Status": status, + "RelatedStatus": relStatus, + }, + Violation: color.Sprintf("message %s does not have consistent status (%v) with related message: %v (%v)", + color.Cyan.Sprint(message.Name), clrWhite.Sprint(status), color.Cyan.Sprint(relatedMsg), clrWhite.Sprint(relStatus)), + }) + } + } + } + + return issues +} + +func checkFiles(checkFn func(file *vppapi.File) LintIssues) func(*vppapi.Schema) LintIssues { + return func(schema *vppapi.Schema) LintIssues { + var issues LintIssues + + logrus.Tracef("running checkFiles for %d files", len(schema.Files)) + + for _, file := range schema.Files { + e := checkFn(&file) + if e != nil { + logrus.Tracef("checked file: %v (%v)", file.Name, e) + } + issues = append(issues, e...) + } + + return issues + } +} + +type Linter struct { + rules []*LintRule +} + +func NewLinter() *Linter { + return &Linter{ + rules: LintRules(defaultLintRules...), + } +} + +func (l *Linter) Enable(rules ...*LintRule) { + for _, rule := range rules { + var found bool + for _, r := range l.rules { + if r.Id == rule.Id { + found = true + break + } + } + if !found { + l.rules = append(l.rules, rule) + } + } +} + +func (l *Linter) Disable(rules ...string) { + for _, rule := range rules { + for i, r := range l.rules { + if r.Id == rule { + l.rules = append(l.rules[:i], l.rules[i+1:]...) + break + } + } + } +} + +func (l *Linter) Lint(schema *vppapi.Schema) error { + logrus.Debugf("linter will run %d rule checks for %d files (schema version: %v)", len(l.rules), len(schema.Files), schema.Version) + + var allIssues LintIssues + + for _, rule := range l.rules { + log := logrus.WithField("rule", rule.Id) + log.Debugf("running linter rulecheck (purpose: %v)", rule.Purpose) + + issues := rule.check(schema) + if len(issues) > 0 { + log.Tracef("linter rule check failed, found %d issues", len(issues)) + + for _, issue := range issues { + if issue.RuleId == "" { + issue.RuleId = rule.Id + } + allIssues = allIssues.Append(issue) + } + } else { + log.Tracef("linter rule check passed") + } + } + + if len(allIssues) > 0 { + logrus.Debugf("found %d issues in %d files", len(allIssues), len(schema.Files)) + return allIssues + } else { + logrus.Debugf("no issues found in %d files", len(schema.Files)) + } + + return nil +} + +func (l *Linter) SetRules(rules []string) { + var list []*LintRule + for _, rule := range l.rules { + keep := false + for _, r := range rules { + if rule.Id == r { + keep = true + break + } + } + if keep { + list = append(list, rule) + } + } + l.rules = list +} + +type LintIssue struct { + RuleId string + + File string + Line int `json:",omitempty"` + + Object any `json:",omitempty"` + Violation string +} + +func createLintIssue(id string, err error) LintIssue { + return LintIssue{ + RuleId: id, + Violation: err.Error(), + } +} + +func (l LintIssue) Error() string { + return l.Violation +} + +type LintIssues []LintIssue + +func (le LintIssues) Error() string { + if len(le) == 0 { + return "no issues" + } + return fmt.Sprintf("%d issues", len(le)) +} + +func (le LintIssues) Append(errs ...error) LintIssues { + var r = le + for _, err := range errs { + if err == nil { + continue + } + switch e := err.(type) { + case LintIssue: + r = append(r, e) + //case LintIssues: + // r = append(r, e...) + default: + r = append(r, createLintIssue("", err)) + } + } + return r +} + +const ( + optionStatus = "status" + optionStatusInProgress = "in_progress" + optionStatusDeprecated = "deprecated" +) + +func getMessageStatus(message vppapi.Message) string { + if isMessageDeprecated(message) { + return optionStatusDeprecated + } + if isMessageInProgress(message) { + return optionStatusInProgress + } + if status, ok := message.Options[optionStatus]; ok { + return status + } + return "n/a" +} + +func isMessageDeprecated(message vppapi.Message) bool { + if _, ok := message.Options[optionStatusDeprecated]; ok { + return true + } + if val, ok := message.Options[optionStatus]; ok && strings.ToLower(val) == optionStatusDeprecated { + return true + } + return false +} + +func isMessageInProgress(message vppapi.Message) bool { + if _, ok := message.Options[optionStatusInProgress]; ok { + return true + } + if val, ok := message.Options[optionStatus]; ok && strings.ToLower(val) == optionStatusInProgress { + return true + } + return false +} + +func extractBaseNameAndVersion(messageName string) (string, int) { + re := regexp.MustCompile(`^(.+)_v(\d+)(_(?:reply|dump|details))?$`) + matches := re.FindStringSubmatch(messageName) + if len(matches) == 4 { + name := matches[1] + matches[3] + version, _ := strconv.Atoi(matches[2]) + return name, version + } else { + return messageName, 1 + } +} + +func getFileMessage(file *vppapi.File, msg string) (vppapi.Message, bool) { + for _, message := range file.Messages { + if message.Name == msg { + return message, true + } + } + return vppapi.Message{}, false +} + +func extractFileMessageVersions(file *vppapi.File) map[string]int { + messageVersions := make(map[string]int) + for _, message := range file.Messages { + baseName, version := extractBaseNameAndVersion(message.Name) + if version > messageVersions[baseName] { + messageVersions[baseName] = version + } + } + return messageVersions +} + +func extractMessageVersions(file *vppapi.File) map[string]map[int]vppapi.Message { + messageVersions := make(map[string]map[int]vppapi.Message) + for _, message := range file.Messages { + baseName, version := extractBaseNameAndVersion(message.Name) + if messageVersions[baseName] == nil { + messageVersions[baseName] = make(map[int]vppapi.Message) + } + messageVersions[baseName][version] = message + } + return messageVersions +} + +func extractMessagesRPC(file *vppapi.File) map[string]vppapi.RPC { + messagesRPC := make(map[string]vppapi.RPC) + if file.Service != nil { + for _, rpc := range file.Service.RPCs { + if m := rpc.Request; m != "" { + messagesRPC[m] = rpc + } + } + } + return messagesRPC +} + +func extractRPCMessages(rpc vppapi.RPC) []string { + var messages []string + if m := rpc.Request; m != "" { + messages = append(messages, m) + } + if m := rpc.Reply; m != "" && m != "null" { + messages = append(messages, m) + } + if m := rpc.StreamMsg; m != "" { + messages = append(messages, m) + } + messages = append(messages, rpc.Events...) + return messages +} + +func getRelatedMessages(file *vppapi.File, msg string) []string { + msgsRPC := extractMessagesRPC(file) + var related []string + if rpc, ok := msgsRPC[msg]; ok { + for _, m := range extractRPCMessages(rpc) { + if m != msg { + related = append(related, m) + } + } + } + return related +} diff --git a/cmd/govpp/log.go b/cmd/govpp/log.go new file mode 100644 index 00000000..06d9f2b7 --- /dev/null +++ b/cmd/govpp/log.go @@ -0,0 +1,75 @@ +// Copyright (c) 2023 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 main + +import ( + "bytes" + "fmt" + "path/filepath" + "runtime" + "strings" + + "github.com/gookit/color" + "github.com/sirupsen/logrus" +) + +const modulePath = "github.com/alkiranet/govpp" + +var ( + logstyleFilename = color.Style{color.LightWhite} + logstyleFilenum = color.Style{color.White} + logstyleFuncname = color.Style{color.LightBlue} + logstyleFuncpkg = color.Style{color.Blue} +) + +func init() { + formatter := &logFormatter{&logrus.TextFormatter{ + EnvironmentOverrideColors: true, + CallerPrettyfier: func(frame *runtime.Frame) (function string, file string) { + call := strings.TrimPrefix(frame.Function, modulePath) + parts := strings.SplitN(strings.TrimPrefix(call, "/"), ".", 2) + function = fmt.Sprintf("%s.%s()", logstyleFuncpkg.Sprint(parts[0]), logstyleFuncname.Sprint(parts[1])) + _, file = filepath.Split(frame.File) + file = fmt.Sprintf("%s:%s", logstyleFilename.Sprint(file), logstyleFilenum.Sprint(frame.Line)) + return function, file + }, + }} + logrus.SetFormatter(formatter) +} + +type logFormatter struct { + *logrus.TextFormatter +} + +const ( + traceLvlPrefix = "\x1b[37mTRAC" + debugLvlPrefix = "\x1b[37mDEBU" +) + +func (l *logFormatter) Format(entry *logrus.Entry) ([]byte, error) { + b, err := l.TextFormatter.Format(entry) + if err != nil { + return nil, err + } + //fmt.Printf("LOG: %q\n", string(b)) + if bytes.HasPrefix(b, []byte(traceLvlPrefix)) { + b[2] = '9' + b[3] = '0' + } else if bytes.HasPrefix(b, []byte(debugLvlPrefix)) { + b[2] = '3' + b[3] = '6' + } + return b, nil +} diff --git a/cmd/govpp/main.go b/cmd/govpp/main.go new file mode 100644 index 00000000..49b82870 --- /dev/null +++ b/cmd/govpp/main.go @@ -0,0 +1,35 @@ +// 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 main + +import ( + "github.com/sirupsen/logrus" +) + +func main() { + Execute() +} + +func Execute() { + cli, err := NewCli() + if err != nil { + logrus.Fatalf("CLI init error: %v", err) + } + root := newRootCmd(cli) + + if err := root.Execute(); err != nil { + logrus.Fatalf("ERROR: %v", err) + } +} diff --git a/cmd/govpp/options.go b/cmd/govpp/options.go new file mode 100644 index 00000000..ac227c56 --- /dev/null +++ b/cmd/govpp/options.go @@ -0,0 +1,83 @@ +// Copyright (c) 2023 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 main + +import ( + "os" + "strings" + + "github.com/gookit/color" + "github.com/sirupsen/logrus" + "github.com/spf13/pflag" +) + +const ( + defaultLogLevel = logrus.InfoLevel +) + +type GlobalOptions struct { + Debug bool + LogLevel string + Color string +} + +func (glob *GlobalOptions) InstallFlags(flags *pflag.FlagSet) { + flags.BoolVarP(&glob.Debug, "debug", "D", false, "Enable debug mode") + flags.StringVarP(&glob.LogLevel, "loglevel", "L", "", "Set logging level") + flags.StringVar(&glob.Color, "color", "", "Color mode; auto/always/never") +} + +func InitOptions(cli Cli, opts *GlobalOptions) { + // override + if opts.Color == "" && os.Getenv("NO_COLOR") != "" { + // https://no-color.org/ + opts.Color = "never" + } + if os.Getenv("DEBUG_GOVPP") != "" || os.Getenv("GOVPP_DEBUG") != "" { + opts.Debug = true + } + if loglvl := os.Getenv("GOVPP_LOGLEVEL"); loglvl != "" { + opts.LogLevel = loglvl + } + + switch strings.ToLower(opts.Color) { + case "auto", "": + if !cli.Out().IsTerminal() { + color.Disable() + } + case "on", "enabled", "always", "1", "true": + color.Enable = true + case "off", "disabled", "never", "0", "false": + color.Disable() + default: + logrus.Fatalf("invalid color mode: %q", opts.Color) + } + + if opts.LogLevel != "" { + if lvl, err := logrus.ParseLevel(opts.LogLevel); err == nil { + logrus.SetLevel(lvl) + if lvl >= logrus.TraceLevel { + logrus.SetReportCaller(true) + } + logrus.Tracef("log level set to: %v", lvl) + } else { + logrus.Fatalf("invalid log level: %v", err) + } + } else if opts.Debug { + logrus.SetLevel(logrus.DebugLevel) + } else { + logrus.SetLevel(defaultLogLevel) + } +} diff --git a/cmd/govpp/util.go b/cmd/govpp/util.go new file mode 100644 index 00000000..09c062f9 --- /dev/null +++ b/cmd/govpp/util.go @@ -0,0 +1,74 @@ +// Copyright (c) 2023 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 main + +import ( + "fmt" + "regexp" + "sort" + "strings" + + "github.com/sirupsen/logrus" +) + +const ( + codeSuffix = "[0m" + codeExpr = `(\\u001b|\033)\[[\d;?]+m` +) + +var codeRegex = regexp.MustCompile(codeExpr) + +func clearColorCode(str string) string { + if !strings.Contains(str, codeSuffix) { + return str + } + return codeRegex.ReplaceAllString(str, "") +} + +func mapStr(data map[string]string) string { + var str string + for k, v := range data { + if len(str) > 0 { + str += ", " + } + if v == "" { + str += k + } else { + str += fmt.Sprintf("%s: %q", k, v) + } + } + return str +} + +func mapStrOrdered(data map[string]string) string { + var strs []string + for k, v := range data { + var str string + if v == "" { + str = k + } else { + str = fmt.Sprintf("%s: %q", k, v) + } + strs = append(strs, str) + } + sort.Strings(strs) + return strings.Join(strs, ", ") +} + +func must(err error) { + if err != nil { + logrus.Fatal(err) + } +} diff --git a/cmd/vpp-proxy/main.go b/cmd/vpp-proxy/main.go index 331b32dc..c31cad3e 100644 --- a/cmd/vpp-proxy/main.go +++ b/cmd/vpp-proxy/main.go @@ -15,18 +15,17 @@ package main import ( - "context" "encoding/gob" "flag" - "io" "log" "github.com/alkiranet/govpp/adapter/socketclient" "github.com/alkiranet/govpp/adapter/statsclient" "github.com/alkiranet/govpp/api" + interfaces "github.com/alkiranet/govpp/binapi/interface" + "github.com/alkiranet/govpp/binapi/vlib" + "github.com/alkiranet/govpp/binapi/vpe" _ "github.com/alkiranet/govpp/core" - "github.com/alkiranet/govpp/examples/binapi/interfaces" - "github.com/alkiranet/govpp/examples/binapi/vpe" "github.com/alkiranet/govpp/proxy" ) @@ -37,8 +36,10 @@ var ( ) func init() { - for _, msg := range api.GetRegisteredMessages() { - gob.Register(msg) + for _, msgList := range api.GetRegisteredMessages() { + for _, msg := range msgList { + gob.Register(msg) + } } } @@ -93,30 +94,12 @@ func runClient() { panic(err) } - // - using binapi message directly - req := &vpe.CliInband{Cmd: "show version"} - reply := new(vpe.CliInbandReply) + req := &vlib.CliInband{Cmd: "show version"} + reply := new(vlib.CliInbandReply) if err := binapiChannel.SendRequest(req).ReceiveReply(reply); err != nil { log.Fatalln("binapi request failed:", err) } log.Printf("VPP version: %+v", reply.Reply) - - // - or using generated rpc service - svc := interfaces.NewServiceClient(binapiChannel) - stream, err := svc.DumpSwInterface(context.Background(), &interfaces.SwInterfaceDump{}) - if err != nil { - log.Fatalln("binapi request failed:", err) - } - for { - iface, err := stream.Recv() - if err == io.EOF { - break - } - if err != nil { - log.Fatalln(err) - } - log.Printf("- interface: %+v", iface) - } } func runServer() { diff --git a/codec/bench_test.go b/codec/bench_test.go new file mode 100644 index 00000000..0a6d37c8 --- /dev/null +++ b/codec/bench_test.go @@ -0,0 +1,75 @@ +// 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 codec_test + +/* +import ( + "testing" + + "github.com/alkiranet/govpp/codec" +) + +var Data []byte + +func BenchmarkEncodeNew(b *testing.B) { + m := NewTestAllMsg() + c := codec.DefaultCodec + + var err error + var data []byte + + b.ResetTimer() + for i := 0; i < b.N; i++ { + data, err = c.EncodeMsg(m, 100) + if err != nil { + b.Fatalf("expected nil error, got: %v", err) + } + } + Data = data +} + +func BenchmarkEncodeWrapper(b *testing.B) { + m := codec.Wrapper{NewTestAllMsg()} + c := codec.DefaultCodec + + var err error + var data []byte + + b.ResetTimer() + for i := 0; i < b.N; i++ { + data, err = c.EncodeMsg(m, 100) + if err != nil { + b.Fatalf("expected nil error, got: %v", err) + } + } + Data = data +} + +func BenchmarkEncodeHard(b *testing.B) { + m := NewTestAllMsg() + + var err error + var data []byte + + b.ResetTimer() + for i := 0; i < b.N; i++ { + data, err = m.Marshal(nil) + if err != nil { + b.Fatalf("expected nil error, got: %v", err) + } + } + Data = data +} +*/ diff --git a/codec/codec.go b/codec/codec.go new file mode 100644 index 00000000..21354a1d --- /dev/null +++ b/codec/codec.go @@ -0,0 +1,191 @@ +// 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 codec + +import ( + "bytes" + "encoding/binary" + "math" +) + +// Buffer provides buffer for encoding and decoding data on wire. +type Buffer struct { + buf []byte + pos int +} + +// NewBuffer creates new buffer using b as data. +func NewBuffer(b []byte) *Buffer { + return &Buffer{ + buf: b, + } +} + +// Bytes returns buffer data up to current position. +func (b *Buffer) Bytes() []byte { + return b.buf[:b.pos] +} + +func (b *Buffer) EncodeBytes(v []byte, length int) { + if length == 0 { + length = len(v) + } + copy(b.buf[b.pos:b.pos+length], v) + b.pos += length +} + +func (b *Buffer) DecodeBytes(length int) []byte { + v := b.buf[b.pos : b.pos+length] + b.pos += length + return v +} + +func (b *Buffer) EncodeBool(v bool) { + if v { + b.buf[b.pos] = 1 + } else { + b.buf[b.pos] = 0 + } + b.pos += 1 +} + +func (b *Buffer) DecodeBool() bool { + v := b.buf[b.pos] != 0 + b.pos += 1 + return v +} + +func (b *Buffer) EncodeUint8(v uint8) { + b.buf[b.pos] = byte(v) + b.pos += 1 +} + +func (b *Buffer) DecodeUint8() uint8 { + v := uint8(b.buf[b.pos]) + b.pos += 1 + return v +} + +func (b *Buffer) EncodeUint16(v uint16) { + binary.BigEndian.PutUint16(b.buf[b.pos:b.pos+2], v) + b.pos += 2 +} + +func (b *Buffer) DecodeUint16() uint16 { + v := binary.BigEndian.Uint16(b.buf[b.pos : b.pos+2]) + b.pos += 2 + return v +} + +func (b *Buffer) EncodeUint32(v uint32) { + binary.BigEndian.PutUint32(b.buf[b.pos:b.pos+4], v) + b.pos += 4 +} + +func (b *Buffer) DecodeUint32() uint32 { + v := binary.BigEndian.Uint32(b.buf[b.pos : b.pos+4]) + b.pos += 4 + return v +} + +func (b *Buffer) EncodeUint64(v uint64) { + binary.BigEndian.PutUint64(b.buf[b.pos:b.pos+8], v) + b.pos += 8 +} + +func (b *Buffer) DecodeUint64() uint64 { + v := binary.BigEndian.Uint64(b.buf[b.pos : b.pos+8]) + b.pos += 8 + return v +} + +func (b *Buffer) EncodeInt8(v int8) { + b.buf[b.pos] = byte(v) + b.pos += 1 +} + +func (b *Buffer) DecodeInt8() int8 { + v := int8(b.buf[b.pos]) + b.pos += 1 + return v +} + +func (b *Buffer) EncodeInt16(v int16) { + binary.BigEndian.PutUint16(b.buf[b.pos:b.pos+2], uint16(v)) + b.pos += 2 +} + +func (b *Buffer) DecodeInt16() int16 { + v := int16(binary.BigEndian.Uint16(b.buf[b.pos : b.pos+2])) + b.pos += 2 + return v +} + +func (b *Buffer) EncodeInt32(v int32) { + binary.BigEndian.PutUint32(b.buf[b.pos:b.pos+4], uint32(v)) + b.pos += 4 +} + +func (b *Buffer) DecodeInt32() int32 { + v := int32(binary.BigEndian.Uint32(b.buf[b.pos : b.pos+4])) + b.pos += 4 + return v +} + +func (b *Buffer) EncodeInt64(v int64) { + binary.BigEndian.PutUint64(b.buf[b.pos:b.pos+8], uint64(v)) + b.pos += 8 +} + +func (b *Buffer) DecodeInt64() int64 { + v := int64(binary.BigEndian.Uint64(b.buf[b.pos : b.pos+8])) + b.pos += 8 + return v +} + +func (b *Buffer) EncodeFloat64(v float64) { + binary.LittleEndian.PutUint64(b.buf[b.pos:b.pos+8], math.Float64bits(v)) + b.pos += 8 +} + +func (b *Buffer) DecodeFloat64() float64 { + v := math.Float64frombits(binary.LittleEndian.Uint64(b.buf[b.pos : b.pos+8])) + b.pos += 8 + return v +} + +func (b *Buffer) EncodeString(v string, length int) { + if length == 0 { + b.EncodeUint32(uint32(len(v))) + length = len(v) + } + copy(b.buf[b.pos:b.pos+length], v) + b.pos += length +} + +func (b *Buffer) DecodeString(length int) string { + var v []byte + if length == 0 { + length = int(b.DecodeUint32()) + v = b.buf[b.pos : b.pos+length] + } else { + v = b.buf[b.pos : b.pos+length] + if nul := bytes.Index(v, []byte{0x00}); nul >= 0 { + v = v[:nul] + } + } + b.pos += length + return string(v) +} diff --git a/codec/marshaler.go b/codec/marshaler.go new file mode 100644 index 00000000..d7fa7cf3 --- /dev/null +++ b/codec/marshaler.go @@ -0,0 +1,70 @@ +// 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 codec + +import ( + "bytes" + "reflect" + + "github.com/lunixbochs/struc" + + "github.com/alkiranet/govpp/api" +) + +// Marshaler is the interface implemented by the binary API messages that can +// marshal itself into binary form for the wire. +type Marshaler interface { + Size() int + Marshal([]byte) ([]byte, error) +} + +// Unmarshaler is the interface implemented by the binary API messages that can +// unmarshal a binary representation of itself from the wire. +type Unmarshaler interface { + Unmarshal([]byte) error +} + +type Wrapper struct { + api.Message +} + +func (w Wrapper) Size() int { + if size, err := struc.Sizeof(w.Message); err != nil { + return 0 + } else { + return size + } +} + +func (w Wrapper) Marshal(b []byte) ([]byte, error) { + buf := new(bytes.Buffer) + if reflect.TypeOf(w.Message).Elem().NumField() > 0 { + if err := struc.Pack(buf, w.Message); err != nil { + return nil, err + } + } + if b != nil { + copy(b, buf.Bytes()) + } + return buf.Bytes(), nil +} + +func (w Wrapper) Unmarshal(data []byte) error { + buf := bytes.NewReader(data) + if err := struc.Unpack(buf, w.Message); err != nil { + return err + } + return nil +} diff --git a/codec/marshaler_test.go b/codec/marshaler_test.go new file mode 100644 index 00000000..72879203 --- /dev/null +++ b/codec/marshaler_test.go @@ -0,0 +1,169 @@ +// 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 codec_test + +import ( + "bytes" + "reflect" + "testing" + + "github.com/alkiranet/govpp/api" + interfaces "github.com/alkiranet/govpp/binapi/interface" + "github.com/alkiranet/govpp/binapi/interface_types" + "github.com/alkiranet/govpp/binapi/ip_types" + "github.com/alkiranet/govpp/binapi/sr" + "github.com/alkiranet/govpp/codec" +) + +// 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 } + +func TestWrapperEncode(t *testing.T) { + msg := &CliInband{ + XXX_CmdLen: 5, + Cmd: "abcde", + } + expectedData := []byte{ + 0x00, 0x64, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x05, + 0x61, 0x62, 0x63, 0x64, 0x65, + } + + c := codec.DefaultCodec + + data, err := c.EncodeMsg(msg, 100) + if err != nil { + t.Fatalf("EncodeMsg failed: %v", err) + } + if !bytes.Equal(data, expectedData) { + t.Fatalf("unexpected encoded data,\nexpected: % 02x\n got: % 02x\n", expectedData, data) + } +} + +func TestWrapperDecode(t *testing.T) { + data := []byte{ + 0x00, 0x64, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x05, + 0x61, 0x62, 0x63, 0x64, 0x65, + } + expectedMsg := &CliInbandReply{ + Retval: 0, + XXX_ReplyLen: 5, + Reply: "abcde", + } + + c := codec.DefaultCodec + + msg := new(CliInbandReply) + err := c.DecodeMsg(data, msg) + if err != nil { + t.Fatalf("DecodeMsg failed: %v", err) + } + if !reflect.DeepEqual(msg, expectedMsg) { + t.Fatalf("unexpected decoded msg,\nexpected: %+v\n got: %+v\n", expectedMsg, msg) + } +} + +func TestNewCodecEncodeDecode4(t *testing.T) { + m := &interfaces.SwInterfaceSetRxMode{ + Mode: interface_types.RX_MODE_API_POLLING, + QueueID: 70000, + QueueIDValid: true, + SwIfIndex: 300, + } + + b := make([]byte, 2+m.Size()) + + data, err := m.Marshal(b[2:]) + if err != nil { + t.Fatalf("expected nil error, got: %v", err) + } + + t.Logf("ENCODED DATA(%d): % 03x", len(data), data) + + var m2 interfaces.SwInterfaceSetRxMode + if err := m2.Unmarshal(b[2:]); err != nil { + t.Fatalf("expected nil error, got: %v", err) + } + + t.Logf("Data:\nOLD: %+v\nNEW: %+v", m, &m2) + + if !reflect.DeepEqual(m, &m2) { + t.Fatalf("newData differs from oldData") + } +} + +func TestNewCodecEncodeDecode2(t *testing.T) { + m := &sr.SrPoliciesDetails{ + Bsid: ip_types.IP6Address{00, 11, 22, 33, 44, 55, 66, 77, 88, 99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}, + IsSpray: true, + IsEncap: false, + FibTable: 33, + NumSidLists: 1, + SidLists: []sr.Srv6SidList{ + { + Weight: 555, + NumSids: 2, + Sids: [16]ip_types.IP6Address{ + {99}, + {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, + }, + }, + }, + } + + b := make([]byte, m.Size()) + data, err := m.Marshal(b) + if err != nil { + t.Fatalf("expected nil error, got: %v", err) + } + + t.Logf("ENCODED DATA(%d): % 03x", len(data), data) + + var m2 sr.SrPoliciesDetails + if err := m2.Unmarshal(data); err != nil { + t.Fatalf("expected nil error, got: %v", err) + } + + t.Logf("Data:\nOLD: %+v\nNEW: %+v", m, &m2) + + if !reflect.DeepEqual(m, &m2) { + t.Fatalf("newData differs from oldData") + } +} diff --git a/codec/msg_codec.go b/codec/msg_codec.go index c6903ce3..8c59b20b 100644 --- a/codec/msg_codec.go +++ b/codec/msg_codec.go @@ -15,154 +15,116 @@ package codec import ( - "bytes" + "encoding/binary" "errors" "fmt" - "reflect" "github.com/alkiranet/govpp/api" - "github.com/lunixbochs/struc" ) -// MsgCodec provides encoding and decoding functionality of `api.Message` structs into/from -// binary format as accepted by VPP. -type MsgCodec struct{} +var DefaultCodec = new(MsgCodec) -// VppRequestHeader struct contains header fields implemented by all VPP requests. -type VppRequestHeader struct { - VlMsgID uint16 - ClientIndex uint32 - Context uint32 +func EncodeMsg(msg api.Message, msgID uint16) (data []byte, err error) { + return DefaultCodec.EncodeMsg(msg, msgID) } - -// VppReplyHeader struct contains header fields implemented by all VPP replies. -type VppReplyHeader struct { - VlMsgID uint16 - Context uint32 +func DecodeMsg(data []byte, msg api.Message) (err error) { + return DefaultCodec.DecodeMsg(data, msg) } - -// VppEventHeader struct contains header fields implemented by all VPP events. -type VppEventHeader struct { - VlMsgID uint16 - ClientIndex uint32 +func DecodeMsgContext(data []byte, msgType api.MessageType) (context uint32, err error) { + return DefaultCodec.DecodeMsgContext(data, msgType) } -// VppOtherHeader struct contains header fields implemented by other VPP messages (not requests nor replies). -type VppOtherHeader struct { - VlMsgID uint16 -} +// MsgCodec provides encoding and decoding functionality of `api.Message` structs into/from +// binary format as accepted by VPP. +type MsgCodec struct{} -// EncodeMsg encodes provided `Message` structure into its binary-encoded data representation. func (*MsgCodec) EncodeMsg(msg api.Message, msgID uint16) (data []byte, err error) { if msg == nil { return nil, errors.New("nil message passed in") } - // try to recover panic which might possibly occur in struc.Pack call + // try to recover panic which might possibly occur defer func() { if r := recover(); r != nil { var ok bool if err, ok = r.(error); !ok { err = fmt.Errorf("%v", r) } - err = fmt.Errorf("panic occurred: %v", err) + err = fmt.Errorf("panic occurred during encoding message %s: %v", msg.GetMessageName(), err) } }() - var header interface{} - - // encode message header - switch msg.GetMessageType() { - case api.RequestMessage: - header = &VppRequestHeader{VlMsgID: msgID} - case api.ReplyMessage: - header = &VppReplyHeader{VlMsgID: msgID} - case api.EventMessage: - header = &VppEventHeader{VlMsgID: msgID} - default: - header = &VppOtherHeader{VlMsgID: msgID} + marshaller, ok := msg.(Marshaler) + if !ok { + marshaller = Wrapper{msg} } - buf := new(bytes.Buffer) + size := marshaller.Size() + offset := getOffset(msg) - // encode message header - if err := struc.Pack(buf, header); err != nil { - return nil, fmt.Errorf("failed to encode message header: %+v, error: %v", header, err) - } + // encode msg ID + b := make([]byte, size+offset) + b[0] = byte(msgID >> 8) + b[1] = byte(msgID) - // encode message content - if reflect.TypeOf(msg).Elem().NumField() > 0 { - if err := struc.Pack(buf, msg); err != nil { - return nil, fmt.Errorf("failed to encode message data: %+v, error: %v", data, err) - } + data, err = marshaller.Marshal(b[offset:]) + if err != nil { + return nil, err } - return buf.Bytes(), nil + return b[0:len(b):len(b)], nil } -// DecodeMsg decodes binary-encoded data of a message into provided `Message` structure. -func (*MsgCodec) DecodeMsg(data []byte, msg api.Message) error { +func (*MsgCodec) DecodeMsg(data []byte, msg api.Message) (err error) { if msg == nil { return errors.New("nil message passed in") } - var header interface{} + // try to recover panic which might possibly occur + defer func() { + if r := recover(); r != nil { + var ok bool + if err, ok = r.(error); !ok { + err = fmt.Errorf("%v", r) + } + err = fmt.Errorf("panic occurred during decoding message %s: %v", msg.GetMessageName(), err) + } + }() - // check which header is expected - switch msg.GetMessageType() { - case api.RequestMessage: - header = new(VppRequestHeader) - case api.ReplyMessage: - header = new(VppReplyHeader) - case api.EventMessage: - header = new(VppEventHeader) - default: - header = new(VppOtherHeader) + marshaller, ok := msg.(Unmarshaler) + if !ok { + marshaller = Wrapper{msg} } - buf := bytes.NewReader(data) + offset := getOffset(msg) - // decode message header - if err := struc.Unpack(buf, header); err != nil { - return fmt.Errorf("failed to decode message header: %+v, error: %v", header, err) - } - - // decode message content - if err := struc.Unpack(buf, msg); err != nil { - return fmt.Errorf("failed to decode message data: %+v, error: %v", data, err) + err = marshaller.Unmarshal(data[offset:]) + if err != nil { + return err } return nil } -func (*MsgCodec) DecodeMsgContext(data []byte, msg api.Message) (uint32, error) { - if msg == nil { - return 0, errors.New("nil message passed in") +func (*MsgCodec) DecodeMsgContext(data []byte, msgType api.MessageType) (context uint32, err error) { + switch msgType { + case api.RequestMessage: + return binary.BigEndian.Uint32(data[6:10]), nil + case api.ReplyMessage: + return binary.BigEndian.Uint32(data[2:6]), nil } - var header interface{} - var getContext func() uint32 + return 0, nil +} - // check which header is expected +func getOffset(msg api.Message) (offset int) { switch msg.GetMessageType() { case api.RequestMessage: - header = new(VppRequestHeader) - getContext = func() uint32 { return header.(*VppRequestHeader).Context } - + return 10 case api.ReplyMessage: - header = new(VppReplyHeader) - getContext = func() uint32 { return header.(*VppReplyHeader).Context } - - default: - return 0, nil - } - - buf := bytes.NewReader(data) - - // decode message header - if err := struc.Unpack(buf, header); err != nil { - return 0, fmt.Errorf("decoding message header failed: %v", err) + return 6 + case api.EventMessage: + return 6 } - - return getContext(), nil + return 2 } diff --git a/codec/msg_codec_test.go b/codec/msg_codec_test.go index 2f14506c..37d24ae0 100644 --- a/codec/msg_codec_test.go +++ b/codec/msg_codec_test.go @@ -1,10 +1,15 @@ -package codec +package codec_test import ( "bytes" "testing" "github.com/alkiranet/govpp/api" + "github.com/alkiranet/govpp/binapi/ip" + "github.com/alkiranet/govpp/binapi/ip_types" + "github.com/alkiranet/govpp/binapi/sr" + "github.com/alkiranet/govpp/binapi/vpe" + "github.com/alkiranet/govpp/codec" ) type MyMsg struct { @@ -35,24 +40,57 @@ func TestEncode(t *testing.T) { msgID: 100, expData: []byte{0x00, 0x64, 0x00, 0x01, 0x41, 0x62, 0x63, 0x64, 0x65, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xE8}, }, + {name: "show version", + msg: &vpe.ShowVersion{}, + msgID: 743, + expData: []byte{0x02, 0xE7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + }, + {name: "ip route", + msg: &ip.IPRouteAddDel{ + IsAdd: true, + IsMultipath: true, + Route: ip.IPRoute{ + TableID: 0, + StatsIndex: 0, + Prefix: ip_types.Prefix{}, + NPaths: 0, + }, + }, + msgID: 743, + expData: []byte{0x02, 0xE7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + }, + {name: "sr", + msg: &sr.SrPolicyAdd{ + BsidAddr: ip_types.IP6Address{}, + Weight: 3, + IsEncap: false, + IsSpray: true, + FibTable: 5, + Sids: sr.Srv6SidList{Weight: 2}, + }, + msgID: 99, + expData: []byte{ + 0x00, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { - c := &MsgCodec{} + c := codec.DefaultCodec data, err := c.EncodeMsg(test.msg, test.msgID) if err != nil { t.Fatalf("expected nil error, got: %v", err) } if !bytes.Equal(data, test.expData) { - t.Fatalf("expected data: % 0X, got: % 0X", test.expData, data) + t.Fatalf("expected data:\n% 0X, got:\n% 0X", test.expData, data) } }) } } func TestEncodePanic(t *testing.T) { - c := &MsgCodec{} + c := codec.DefaultCodec msg := &MyMsg{Index: 1, Label: []byte("thisIsLongerThan16Bytes"), Port: 1000} @@ -60,4 +98,5 @@ func TestEncodePanic(t *testing.T) { if err == nil { t.Fatalf("expected non-nil error, got: %v", err) } + t.Logf("err: %v", err) } diff --git a/core/channel.go b/core/channel.go index e0fd1a0e..da62f40c 100644 --- a/core/channel.go +++ b/core/channel.go @@ -19,6 +19,7 @@ import ( "fmt" "reflect" "strings" + "sync" "time" "github.com/sirupsen/logrus" @@ -37,14 +38,18 @@ type MessageCodec interface { EncodeMsg(msg api.Message, msgID uint16) ([]byte, error) // DecodeMsg decodes binary-encoded data of a message into provided Message structure. DecodeMsg(data []byte, msg api.Message) error + // DecodeMsgContext decodes context from message data and type. + DecodeMsgContext(data []byte, msgType api.MessageType) (context uint32, err error) } // MessageIdentifier provides identification of generated API messages. type MessageIdentifier interface { // GetMessageID returns message identifier of given API message. GetMessageID(msg api.Message) (uint16, error) + // GetMessagePath returns path for the given message + GetMessagePath(msg api.Message) string // LookupByID looks up message name and crc by ID - LookupByID(msgID uint16) (api.Message, error) + LookupByID(path string, msgID uint16) (api.Message, error) } // vppRequest is a request that will be sent to VPP. @@ -77,14 +82,14 @@ type multiRequestCtx struct { // subscriptionCtx is a context of subscription for delivery of specific notification messages. type subscriptionCtx struct { - ch *Channel + conn *Connection notifChan chan api.Message // channel where notification messages will be delivered to msgID uint16 // message ID for the subscribed event message event api.Message // event message that this subscription is for msgFactory func() api.Message // function that returns a new instance of the specific message that is expected as a notification } -// channel is the main communication interface with govpp core. It contains four Go channels, one for sending the requests +// Channel is the main communication interface with govpp core. It contains four Go channels, one for sending the requests // to VPP, one for receiving the replies from it and the same set for notifications. The user can access the Go channels // via methods provided by Channel interface in this package. Do not use the same channel from multiple goroutines // concurrently, otherwise the responses could mix! Use multiple channels instead. @@ -100,48 +105,77 @@ type Channel struct { lastSeqNum uint16 // sequence number of the last sent request - delayedReply *vppReply // reply already taken from ReplyChan, buffered for later delivery - replyTimeout time.Duration // maximum time that the API waits for a reply from VPP before returning an error, can be set with SetReplyTimeout + delayedReply *vppReply // reply already taken from ReplyChan, buffered for later delivery + replyTimeout time.Duration // maximum time that the API waits for a reply from VPP before returning an error, can be set with SetReplyTimeout + receiveReplyTimeout time.Duration // maximum time that we wait for receiver to consume reply } -func newChannel(id uint16, conn *Connection, codec MessageCodec, identifier MessageIdentifier, reqSize, replySize int) *Channel { - return &Channel{ - id: id, - conn: conn, - msgCodec: codec, - msgIdentifier: identifier, - reqChan: make(chan *vppRequest, reqSize), - replyChan: make(chan *vppReply, replySize), - replyTimeout: DefaultReplyTimeout, +func (c *Connection) newChannel(reqChanBufSize, replyChanBufSize int) (*Channel, error) { + // get an ID from the ID pool + chID, err := c.channelIdPool.Get() + if err != nil { + return nil, err + } + l := log.WithField("id", chID) + if isDebugOn(debugOptChannels) { + l.Debugf("start preparing channel") + } + // get a channel from the channel pool + channel := c.channelPool.Get() + if channel == nil { + c.channelIdPool.Put(chID) + return nil, errors.New("no more channels in pool available") + } + // set channel ID + channel.id = chID + // recreate request/reply channels if not the right capacity + if cap(channel.reqChan) != reqChanBufSize { + channel.reqChan = make(chan *vppRequest, reqChanBufSize) } + if cap(channel.replyChan) != replyChanBufSize { + channel.replyChan = make(chan *vppReply, replyChanBufSize) + } + // store API channel within the client + c.channelsLock.Lock() + c.channels[channel.id] = channel + c.channelsLock.Unlock() + if isDebugOn(debugOptChannels) { + l.Debugf("done preparing channel") + } + return channel, nil +} + +func (ch *Channel) Close() { + close(ch.reqChan) } func (ch *Channel) GetID() uint16 { return ch.id } +func (ch *Channel) SendRequest(msg api.Message) api.RequestCtx { + req := ch.newRequest(msg, false) + ch.reqChan <- req + return &requestCtx{ch: ch, seqNum: req.seqNum} +} + +func (ch *Channel) SendMultiRequest(msg api.Message) api.MultiRequestCtx { + req := ch.newRequest(msg, true) + ch.reqChan <- req + return &multiRequestCtx{ch: ch, seqNum: req.seqNum} +} + func (ch *Channel) nextSeqNum() uint16 { ch.lastSeqNum++ return ch.lastSeqNum } -func (ch *Channel) SendRequest(msg api.Message) api.RequestCtx { - seqNum := ch.nextSeqNum() - ch.reqChan <- &vppRequest{ - msg: msg, - seqNum: seqNum, - } - return &requestCtx{ch: ch, seqNum: seqNum} -} - -func (ch *Channel) SendMultiRequest(msg api.Message) api.MultiRequestCtx { - seqNum := ch.nextSeqNum() - ch.reqChan <- &vppRequest{ +func (ch *Channel) newRequest(msg api.Message, multi bool) *vppRequest { + return &vppRequest{ msg: msg, - seqNum: seqNum, - multi: true, + seqNum: ch.nextSeqNum(), + multi: multi, } - return &multiRequestCtx{ch: ch, seqNum: seqNum} } func (ch *Channel) CheckCompatiblity(msgs ...api.Message) error { @@ -150,32 +184,41 @@ func (ch *Channel) CheckCompatiblity(msgs ...api.Message) error { _, err := ch.msgIdentifier.GetMessageID(msg) if err != nil { if uerr, ok := err.(*adapter.UnknownMsgError); ok { - m := fmt.Sprintf("%s_%s", uerr.MsgName, uerr.MsgCrc) - comperr.IncompatibleMessages = append(comperr.IncompatibleMessages, m) + comperr.IncompatibleMessages = append(comperr.IncompatibleMessages, getMsgID(uerr.MsgName, uerr.MsgCrc)) continue } // other errors return immediatelly return err } + comperr.CompatibleMessages = append(comperr.CompatibleMessages, getMsgNameWithCrc(msg)) } if len(comperr.IncompatibleMessages) == 0 { return nil } + if debugOn { + s := "" + for _, msg := range comperr.IncompatibleMessages { + s += fmt.Sprintf(" - %s\n", msg) + } + log.Debugf("ERROR: check compatibility: %v:\nIncompatible messages:\n%v", comperr, s) + } return &comperr } func (ch *Channel) SubscribeNotification(notifChan chan api.Message, event api.Message) (api.SubscriptionCtx, error) { msgID, err := ch.msgIdentifier.GetMessageID(event) if err != nil { - log.WithFields(logrus.Fields{ - "msg_name": event.GetMessageName(), - "msg_crc": event.GetCrcString(), - }).Errorf("unable to retrieve message ID: %v", err) + if debugOn { + log.WithFields(logrus.Fields{ + "msg_name": event.GetMessageName(), + "msg_crc": event.GetCrcString(), + }).Errorf("unable to retrieve message ID: %v", err) + } return nil, fmt.Errorf("unable to retrieve event message ID: %v", err) } sub := &subscriptionCtx{ - ch: ch, + conn: ch.conn, notifChan: notifChan, msgID: msgID, event: event, @@ -195,10 +238,6 @@ func (ch *Channel) SetReplyTimeout(timeout time.Duration) { ch.replyTimeout = timeout } -func (ch *Channel) Close() { - close(ch.reqChan) -} - func (req *requestCtx) ReceiveReply(msg api.Message) error { if req == nil || req.ch == nil { return ErrInvalidRequestCtx @@ -229,13 +268,15 @@ func (sub *subscriptionCtx) Unsubscribe() error { }).Debug("Removing notification subscription.") // remove the subscription from the map - sub.ch.conn.subscriptionsLock.Lock() - defer sub.ch.conn.subscriptionsLock.Unlock() + sub.conn.subscriptionsLock.Lock() + defer sub.conn.subscriptionsLock.Unlock() - for i, item := range sub.ch.conn.subscriptions[sub.msgID] { + for i, item := range sub.conn.subscriptions[sub.msgID] { if item == sub { + // close notification channel + close(sub.conn.subscriptions[sub.msgID][i].notifChan) // remove i-th item in the slice - sub.ch.conn.subscriptions[sub.msgID] = append(sub.ch.conn.subscriptions[sub.msgID][:i], sub.ch.conn.subscriptions[sub.msgID][i+1:]...) + sub.conn.subscriptions[sub.msgID] = append(sub.conn.subscriptions[sub.msgID][:i], sub.conn.subscriptions[sub.msgID][i+1:]...) return nil } } @@ -243,6 +284,8 @@ func (sub *subscriptionCtx) Unsubscribe() error { return fmt.Errorf("subscription for %q not found", sub.event.GetMessageName()) } +const maxInt64 = 1<<63 - 1 + // receiveReplyInternal receives a reply from the reply channel into the provided msg structure. func (ch *Channel) receiveReplyInternal(msg api.Message, expSeqNum uint16) (lastReplyReceived bool, err error) { if msg == nil { @@ -260,7 +303,17 @@ func (ch *Channel) receiveReplyInternal(msg api.Message, expSeqNum uint16) (last } } - timer := time.NewTimer(ch.replyTimeout) + slowReplyDur := WarnSlowReplyDuration + timeout := ch.replyTimeout + if timeout <= 0 { + timeout = maxInt64 + } + timeoutTimer := time.NewTimer(timeout) + slowTimer := time.NewTimer(slowReplyDur) + defer func() { + timeoutTimer.Stop() + slowTimer.Stop() + }() for { select { // blocks until a reply comes to ReplyChan or until timeout expires @@ -274,13 +327,18 @@ func (ch *Channel) receiveReplyInternal(msg api.Message, expSeqNum uint16) (last continue } return lastReplyReceived, err - - case <-timer.C: + case <-slowTimer.C: log.WithFields(logrus.Fields{ "expSeqNum": expSeqNum, "channel": ch.id, - }).Debugf("timeout (%v) waiting for reply: %s", ch.replyTimeout, msg.GetMessageName()) - err = fmt.Errorf("no reply received within the timeout period %s", ch.replyTimeout) + }).Warnf("reply is taking too long (>%v): %v ", slowReplyDur, msg.GetMessageName()) + continue + case <-timeoutTimer.C: + log.WithFields(logrus.Fields{ + "expSeqNum": expSeqNum, + "channel": ch.id, + }).Debugf("timeout (%v) waiting for reply: %s", timeout, msg.GetMessageName()) + err = fmt.Errorf("no reply received within the timeout period %s", timeout) return false, err } } @@ -322,15 +380,16 @@ func (ch *Channel) processReply(reply *vppReply, expSeqNum uint16, msg api.Messa if reply.msgID != expMsgID { var msgNameCrc string - if replyMsg, err := ch.msgIdentifier.LookupByID(reply.msgID); err != nil { + pkgPath := ch.msgIdentifier.GetMessagePath(msg) + if replyMsg, err := ch.msgIdentifier.LookupByID(pkgPath, reply.msgID); err != nil { msgNameCrc = err.Error() } else { msgNameCrc = getMsgNameWithCrc(replyMsg) } - err = fmt.Errorf("received invalid message ID (seqNum=%d), expected %d (%s), but got %d (%s) "+ + err = fmt.Errorf("received unexpected message (seqNum=%d), expected %s (ID %d), but got %s (ID %d) "+ "(check if multiple goroutines are not sharing single GoVPP channel)", - reply.seqNum, expMsgID, msg.GetMessageName(), reply.msgID, msgNameCrc) + reply.seqNum, msg.GetMessageName(), expMsgID, msgNameCrc, reply.msgID) return } @@ -343,10 +402,75 @@ func (ch *Channel) processReply(reply *vppReply, expSeqNum uint16, msg api.Messa if strings.HasSuffix(msg.GetMessageName(), "_reply") { // TODO: use categories for messages to avoid checking message name if f := reflect.Indirect(reflect.ValueOf(msg)).FieldByName("Retval"); f.IsValid() { - retval := int32(f.Int()) + var retval int32 + switch f.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + retval = int32(f.Int()) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + retval = int32(f.Uint()) + default: + logrus.Warnf("invalid kind (%v) for Retval field of message %v", f.Kind(), msg.GetMessageName()) + } err = api.RetvalToVPPApiError(retval) } } return } + +func (ch *Channel) Reset() { + if len(ch.reqChan) > 0 || len(ch.replyChan) > 0 { + log.WithField("channel", ch.id).Debugf("draining channel buffers (req: %d, reply: %d)", len(ch.reqChan), len(ch.replyChan)) + } + // Drain any lingering items in the buffers + for empty := false; !empty; { + // channels must be set to nil when closed to prevent + // select below to always run the case immediatelly + // which would make the loop run forever + select { + case _, ok := <-ch.reqChan: + if !ok { + ch.reqChan = nil + } + case _, ok := <-ch.replyChan: + if !ok { + ch.replyChan = nil + } + default: + empty = true + } + } +} + +type idPool struct { + ids []uint16 + lock sync.Mutex +} + +func newIDPool(maxID uint16) *idPool { + ids := make([]uint16, maxID) + for i := uint16(0); i < maxID; i++ { + ids[i] = i + 1 + } + return &idPool{ids: ids} +} + +func (p *idPool) Get() (uint16, error) { + p.lock.Lock() + defer p.lock.Unlock() + + if len(p.ids) == 0 { + return 0, errors.New("no more IDs available") + } + + id := p.ids[0] + p.ids = p.ids[1:] + + return id, nil +} + +func (p *idPool) Put(id uint16) { + p.lock.Lock() + p.ids = append(p.ids, id) + p.lock.Unlock() +} diff --git a/core/channel_test.go b/core/channel_test.go index 36a941f7..ff996323 100644 --- a/core/channel_test.go +++ b/core/channel_test.go @@ -22,10 +22,10 @@ import ( "github.com/alkiranet/govpp/adapter/mock" "github.com/alkiranet/govpp/api" - "github.com/alkiranet/govpp/examples/binapi/interface_types" - "github.com/alkiranet/govpp/examples/binapi/interfaces" - "github.com/alkiranet/govpp/examples/binapi/memif" - "github.com/alkiranet/govpp/examples/binapi/vpe" + interfaces "github.com/alkiranet/govpp/binapi/interface" + "github.com/alkiranet/govpp/binapi/interface_types" + "github.com/alkiranet/govpp/binapi/memif" + "github.com/alkiranet/govpp/binapi/vpe" ) type testCtx struct { @@ -48,14 +48,56 @@ func setupTest(t *testing.T) *testCtx { ctx.ch, err = ctx.conn.NewAPIChannel() Expect(err).ShouldNot(HaveOccurred()) + ctx.resetReplyTimeout() + return ctx } +func (ctx *testCtx) resetReplyTimeout() { + // setting reply timeout to non-zero value to fail fast on potential deadlocks + ctx.ch.SetReplyTimeout(time.Second * 5) +} + func (ctx *testCtx) teardownTest() { ctx.ch.Close() ctx.conn.Disconnect() } +func TestChannelReset(t *testing.T) { + RegisterTestingT(t) + + mockVpp := mock.NewVppAdapter() + + conn, err := Connect(mockVpp) + Expect(err).ShouldNot(HaveOccurred()) + + ch, err := conn.NewAPIChannel() + Expect(err).ShouldNot(HaveOccurred()) + + Ch := ch.(*Channel) + Ch.replyChan <- &vppReply{seqNum: 1} + + id := Ch.GetID() + Expect(id).To(BeNumerically(">", 0)) + + active := func() bool { + conn.channelsLock.RLock() + _, ok := conn.channels[id] + conn.channelsLock.RUnlock() + return ok + } + Expect(active()).To(BeTrue()) + + Expect(Ch.replyChan).To(HaveLen(1)) + + ch.Close() + + Eventually(active).Should(BeFalse()) + Eventually(func() int { + return len(Ch.replyChan) + }).Should(BeZero()) +} + func TestRequestReplyMemifCreate(t *testing.T) { ctx := setupTest(t) defer ctx.teardownTest() @@ -129,7 +171,7 @@ func TestMultiRequestReplySwInterfaceMemifDump(t *testing.T) { var msgs []api.Message for i := 1; i <= 10; i++ { msgs = append(msgs, &memif.MemifDetails{ - SwIfIndex: interfaces.InterfaceIndex(i), + SwIfIndex: interface_types.InterfaceIndex(i), }) } ctx.mockVpp.MockReply(msgs...) @@ -163,7 +205,8 @@ func TestNotificationEvent(t *testing.T) { SwIfIndex: 2, Flags: interface_types.IF_STATUS_API_FLAG_LINK_UP, }) - ctx.mockVpp.SendMsg(0, []byte("")) + err = ctx.mockVpp.SendMsg(0, []byte("")) + Expect(err).ShouldNot(HaveOccurred()) // receive the notification var notif *interfaces.SwInterfaceEvent @@ -189,8 +232,6 @@ func TestSetReplyTimeout(t *testing.T) { ctx := setupTest(t) defer ctx.teardownTest() - ctx.ch.SetReplyTimeout(time.Millisecond) - // mock reply ctx.mockVpp.MockReply(&ControlPingReply{}) @@ -198,6 +239,8 @@ func TestSetReplyTimeout(t *testing.T) { err := ctx.ch.SendRequest(&ControlPing{}).ReceiveReply(&ControlPingReply{}) Expect(err).ShouldNot(HaveOccurred()) + ctx.ch.SetReplyTimeout(time.Millisecond * 1) + // no other reply ready - expect timeout err = ctx.ch.SendRequest(&ControlPing{}).ReceiveReply(&ControlPingReply{}) Expect(err).Should(HaveOccurred()) @@ -208,8 +251,6 @@ func TestSetReplyTimeoutMultiRequest(t *testing.T) { ctx := setupTest(t) defer ctx.teardownTest() - ctx.ch.SetReplyTimeout(time.Millisecond * 100) - // mock reply ctx.mockVpp.MockReply( &interfaces.SwInterfaceDetails{ @@ -248,6 +289,8 @@ func TestSetReplyTimeoutMultiRequest(t *testing.T) { err := sendMultiRequest() Expect(err).ShouldNot(HaveOccurred()) + ctx.ch.SetReplyTimeout(time.Millisecond * 1) + // no other reply ready - expect timeout err = sendMultiRequest() Expect(err).Should(HaveOccurred()) @@ -288,7 +331,7 @@ func TestMultiRequestDouble(t *testing.T) { for i := 1; i <= 3; i++ { msgs = append(msgs, mock.MsgWithContext{ Msg: &interfaces.SwInterfaceDetails{ - SwIfIndex: interfaces.InterfaceIndex(i), + SwIfIndex: interface_types.InterfaceIndex(i), InterfaceName: "if-name-test", }, Multipart: true, @@ -301,7 +344,7 @@ func TestMultiRequestDouble(t *testing.T) { msgs = append(msgs, mock.MsgWithContext{ Msg: &interfaces.SwInterfaceDetails{ - SwIfIndex: interfaces.InterfaceIndex(i), + SwIfIndex: interface_types.InterfaceIndex(i), InterfaceName: "if-name-test", }, Multipart: true, @@ -342,21 +385,23 @@ func TestReceiveReplyAfterTimeout(t *testing.T) { ctx := setupTest(t) defer ctx.teardownTest() - ctx.ch.SetReplyTimeout(time.Millisecond) - // mock reply ctx.mockVpp.MockReplyWithContext(mock.MsgWithContext{Msg: &ControlPingReply{}, SeqNum: 1}) - // first one request should work + // first request should succeed err := ctx.ch.SendRequest(&ControlPing{}).ReceiveReply(&ControlPingReply{}) Expect(err).ShouldNot(HaveOccurred()) - err = ctx.ch.SendRequest(&ControlPing{}).ReceiveReply(&ControlPingReply{}) + // second request should fail with timeout + ctx.ch.SetReplyTimeout(time.Millisecond * 1) + req := ctx.ch.SendRequest(&ControlPing{}) + time.Sleep(time.Millisecond * 2) + err = req.ReceiveReply(&ControlPingReply{}) Expect(err).Should(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("timeout")) ctx.mockVpp.MockReplyWithContext( - // simulating late reply + // late reply from previous request mock.MsgWithContext{ Msg: &ControlPingReply{}, SeqNum: 2, @@ -368,14 +413,15 @@ func TestReceiveReplyAfterTimeout(t *testing.T) { }, ) - req := &interfaces.SwInterfaceSetFlags{ - SwIfIndex: 1, - Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, - } reply := &interfaces.SwInterfaceSetFlagsReply{} - // should succeed - err = ctx.ch.SendRequest(req).ReceiveReply(reply) + ctx.resetReplyTimeout() + + // third request should succeed + err = ctx.ch.SendRequest(&interfaces.SwInterfaceSetFlags{ + SwIfIndex: 1, + Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, + }).ReceiveReply(reply) Expect(err).ShouldNot(HaveOccurred()) } @@ -391,8 +437,6 @@ func TestReceiveReplyAfterTimeoutMultiRequest(t *testing.T) { ctx := setupTest(t) defer ctx.teardownTest() - ctx.ch.SetReplyTimeout(time.Millisecond * 100) - // mock reply ctx.mockVpp.MockReplyWithContext(mock.MsgWithContext{Msg: &ControlPingReply{}, SeqNum: 1}) @@ -400,6 +444,8 @@ func TestReceiveReplyAfterTimeoutMultiRequest(t *testing.T) { err := ctx.ch.SendRequest(&ControlPing{}).ReceiveReply(&ControlPingReply{}) Expect(err).ShouldNot(HaveOccurred()) + ctx.ch.SetReplyTimeout(time.Millisecond * 1) + cnt := 0 var sendMultiRequest = func() error { reqCtx := ctx.ch.SendMultiRequest(&interfaces.SwInterfaceDump{}) @@ -416,18 +462,19 @@ func TestReceiveReplyAfterTimeoutMultiRequest(t *testing.T) { } return nil } - err = sendMultiRequest() Expect(err).Should(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("timeout")) Expect(cnt).To(BeEquivalentTo(0)) + ctx.resetReplyTimeout() + // simulating late replies var msgs []mock.MsgWithContext for i := 1; i <= 3; i++ { msgs = append(msgs, mock.MsgWithContext{ Msg: &interfaces.SwInterfaceDetails{ - SwIfIndex: interfaces.InterfaceIndex(i), + SwIfIndex: interface_types.InterfaceIndex(i), InterfaceName: "if-name-test", }, Multipart: true, @@ -466,5 +513,5 @@ func TestInvalidMessageID(t *testing.T) { // second should fail with error invalid message ID err = ctx.ch.SendRequest(&ControlPing{}).ReceiveReply(&ControlPingReply{}) Expect(err).Should(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("invalid message ID")) + Expect(err.Error()).To(ContainSubstring("unexpected message")) } diff --git a/core/connection.go b/core/connection.go index 748ad8b7..f56406bb 100644 --- a/core/connection.go +++ b/core/connection.go @@ -17,16 +17,16 @@ package core import ( "errors" "fmt" + "path" "reflect" "sync" "sync/atomic" "time" - logger "github.com/sirupsen/logrus" - "github.com/alkiranet/govpp/adapter" "github.com/alkiranet/govpp/api" "github.com/alkiranet/govpp/codec" + "github.com/alkiranet/govpp/core/genericpool" ) const ( @@ -42,9 +42,13 @@ var ( var ( HealthCheckProbeInterval = time.Second // default health check probe interval - HealthCheckReplyTimeout = time.Millisecond * 100 // timeout for reply to a health check probe - HealthCheckThreshold = 1 // number of failed health checks until the error is reported - DefaultReplyTimeout = time.Second // default timeout for replies from VPP + HealthCheckReplyTimeout = time.Millisecond * 250 // timeout for reply to a health check probe + HealthCheckThreshold = 2 // number of failed health checks until the error is reported +) + +var ( + DefaultReplyTimeout = time.Duration(0) // default timeout for replies from VPP is disabled + WarnSlowReplyDuration = time.Second * 1 // duration of slow replies after which a warning is printed ) // ConnectionState represents the current state of the connection to VPP. @@ -54,7 +58,11 @@ const ( // Connected represents state in which the connection has been successfully established. Connected ConnectionState = iota - // Disconnected represents state in which the connection has been dropped. + // NotResponding represents a state where the VPP socket accepts messages but replies are received with delay, + // or not at all. GoVPP treats this state internally the same as disconnected. + NotResponding + + // Disconnected represents state in which the VPP socket is closed and the connection is considered dropped. Disconnected // Failed represents state in which the reconnecting failed after exceeding maximum number of attempts. @@ -65,6 +73,8 @@ func (s ConnectionState) String() string { switch s { case Connected: return "Connected" + case NotResponding: + return "NotResponding" case Disconnected: return "Disconnected" case Failed: @@ -95,13 +105,23 @@ type Connection struct { vppConnected uint32 // non-zero if the adapter is connected to VPP - codec *codec.MsgCodec // message codec - msgIDs map[string]uint16 // map of message IDs indexed by message name + CRC - msgMap map[uint16]api.Message // map of messages indexed by message ID + connChan chan ConnectionEvent // connection status events are sent to this channel + healthCheckDone chan struct{} // used to terminate connect/health check loop + backgroundLoopActive uint32 // used to guard background loop from double close errors + + async bool // connection to be operated in async mode + healthCheckExited chan struct{} // used to notify Disconnect() callers about healthcheck loop exit + + codec MessageCodec // message codec + msgIDs map[string]uint16 // map of message IDs indexed by message name + CRC - maxChannelID uint32 // maximum used channel ID (the real limit is 2^15, 32-bit is used for atomic operations) - channelsLock sync.RWMutex // lock for the channels map - channels map[uint16]*Channel // map of all API channels indexed by the channel ID + msgMapByPathLock sync.RWMutex // lock for the msgMapByPath map + msgMapByPath map[string]map[uint16]api.Message // map of messages indexed by message ID which are indexed by path + + channelsLock sync.RWMutex // lock for the channels map and the channel ID + channels map[uint16]*Channel // map of all API channels indexed by the channel ID + channelPool *genericpool.Pool[*Channel] + channelIdPool *idPool subscriptionsLock sync.RWMutex // lock for the subscriptions map subscriptions map[uint16][]*subscriptionCtx // map od all notification subscriptions indexed by message ID @@ -114,9 +134,18 @@ type Connection struct { msgControlPing api.Message msgControlPingReply api.Message + + apiTrace *trace // API tracer (disabled by default) } -func newConnection(binapi adapter.VppAPI, attempts int, interval time.Duration) *Connection { +type backgroundLoopStatus int + +const ( + terminate backgroundLoopStatus = iota + resume +) + +func newConnection(binapi adapter.VppAPI, attempts int, interval time.Duration, async bool) *Connection { if attempts == 0 { attempts = DefaultMaxReconnectAttempts } @@ -128,14 +157,39 @@ func newConnection(binapi adapter.VppAPI, attempts int, interval time.Duration) vppClient: binapi, maxAttempts: attempts, recInterval: interval, - codec: &codec.MsgCodec{}, + connChan: make(chan ConnectionEvent, NotificationChanBufSize), + healthCheckDone: make(chan struct{}), + healthCheckExited: make(chan struct{}), + async: async, + codec: codec.DefaultCodec, msgIDs: make(map[string]uint16), - msgMap: make(map[uint16]api.Message), + msgMapByPath: make(map[string]map[uint16]api.Message), channels: make(map[uint16]*Channel), subscriptions: make(map[uint16][]*subscriptionCtx), msgControlPing: msgControlPing, msgControlPingReply: msgControlPingReply, + apiTrace: &trace{ + list: make([]*api.Record, 0), + mux: &sync.Mutex{}, + }, + channelIdPool: newIDPool(0x7fff), } + c.channelPool = genericpool.New[*Channel](func() *Channel { + if isDebugOn(debugOptChannels) { + log.Debugf("allocating new channel") + } + // create new channel without ID + return &Channel{ + conn: c, + msgCodec: c.codec, + msgIdentifier: c, + reqChan: make(chan *vppRequest, RequestChanBufSize), + replyChan: make(chan *vppReply, ReplyChanBufSize), + replyTimeout: DefaultReplyTimeout, + receiveReplyTimeout: ReplyChannelTimeout, + } + }) + binapi.SetMsgCallback(c.msgCallback) return c } @@ -145,7 +199,7 @@ func newConnection(binapi adapter.VppAPI, attempts int, interval time.Duration) // Only one connection attempt will be performed. func Connect(binapi adapter.VppAPI) (*Connection, error) { // create new connection handle - c := newConnection(binapi, DefaultMaxReconnectAttempts, DefaultReconnectInterval) + c := newConnection(binapi, DefaultMaxReconnectAttempts, DefaultReconnectInterval, false) // blocking attempt to connect to VPP if err := c.connectVPP(); err != nil { @@ -160,14 +214,16 @@ func Connect(binapi adapter.VppAPI) (*Connection, error) { // returns immediately. The caller is supposed to watch the returned ConnectionState channel for // Connected/Disconnected events. In case of disconnect, the library will asynchronously try to reconnect. func AsyncConnect(binapi adapter.VppAPI, attempts int, interval time.Duration) (*Connection, chan ConnectionEvent, error) { + // create new connection handle - c := newConnection(binapi, attempts, interval) + conn := newConnection(binapi, attempts, interval, true) + + atomic.StoreUint32(&conn.backgroundLoopActive, 1) // asynchronously attempt to connect to VPP - connChan := make(chan ConnectionEvent, NotificationChanBufSize) - go c.connectLoop(connChan) + go conn.backgroudConnectionLoop() - return c, connChan, nil + return conn, conn.connChan, nil } // connectVPP performs blocking attempt to connect to VPP. @@ -198,12 +254,22 @@ func (c *Connection) Disconnect() { if c == nil { return } + + if c.async { + if atomic.CompareAndSwapUint32(&c.backgroundLoopActive, 1, 0) { + close(c.healthCheckDone) + } + + // Wait for the connect/healthcheck loop termination + <-c.healthCheckExited + } + if c.vppClient != nil { c.disconnectVPP() } } -// disconnectVPP disconnects from VPP in case it is connected. +// disconnectVPP disconnects from VPP in case it is connected func (c *Connection) disconnectVPP() { if atomic.CompareAndSwapUint32(&c.vppConnected, 1, 0) { log.Debug("Disconnecting from VPP..") @@ -230,14 +296,10 @@ func (c *Connection) newAPIChannel(reqChanBufSize, replyChanBufSize int) (*Chann return nil, errors.New("nil connection passed in") } - // create new channel - chID := uint16(atomic.AddUint32(&c.maxChannelID, 1) & 0x7fff) - channel := newChannel(chID, c, c.codec, c, reqChanBufSize, replyChanBufSize) - - // store API channel within the client - c.channelsLock.Lock() - c.channels[chID] = channel - c.channelsLock.Unlock() + channel, err := c.newChannel(reqChanBufSize, replyChanBufSize) + if err != nil { + return nil, err + } // start watching on the request channel go c.watchRequests(channel) @@ -247,19 +309,42 @@ func (c *Connection) newAPIChannel(reqChanBufSize, replyChanBufSize int) (*Chann // releaseAPIChannel releases API channel that needs to be closed. func (c *Connection) releaseAPIChannel(ch *Channel) { - log.WithFields(logger.Fields{ - "channel": ch.id, - }).Debug("API channel released") + l := log.WithField("id", ch.id) + if isDebugOn(debugOptChannels) { + l.Debug("releasing channel") + } // delete the channel from channels map c.channelsLock.Lock() delete(c.channels, ch.id) c.channelsLock.Unlock() + // return ID to the ID pool + c.channelIdPool.Put(ch.id) + if isDebugOn(debugOptChannels) { + l.Debug("channel ID returned to pool") + } + // return channel to the pool + go c.channelPool.Put(ch) +} + +// runs connectionLoop and healthCheckLoop until they fail +func (c *Connection) backgroudConnectionLoop() { + defer close(c.healthCheckExited) + + for { + if c.connectLoop() == terminate { + return + } + + if c.healthCheckLoop() == terminate { + return + } + } } // connectLoop attempts to connect to VPP until it succeeds. // Then it continues with healthCheckLoop. -func (c *Connection) connectLoop(connChan chan ConnectionEvent) { +func (c *Connection) connectLoop() backgroundLoopStatus { var reconnectAttempts int // loop until connected @@ -269,31 +354,36 @@ func (c *Connection) connectLoop(connChan chan ConnectionEvent) { } if err := c.connectVPP(); err == nil { // signal connected event - connChan <- ConnectionEvent{Timestamp: time.Now(), State: Connected} - break + c.sendConnEvent(ConnectionEvent{Timestamp: time.Now(), State: Connected}) + return resume } else if reconnectAttempts < c.maxAttempts { reconnectAttempts++ log.Warnf("connecting failed (attempt %d/%d): %v", reconnectAttempts, c.maxAttempts, err) - time.Sleep(c.recInterval) } else { - connChan <- ConnectionEvent{Timestamp: time.Now(), State: Failed, Error: err} - return + c.sendConnEvent(ConnectionEvent{Timestamp: time.Now(), State: Failed, Error: err}) + return terminate } - } - // we are now connected, continue with health check loop - c.healthCheckLoop(connChan) + select { + case <-c.healthCheckDone: + // Terminate the connect loop on connection disconnect + log.Debug("Disconnected on request, exiting connect loop.") + return terminate + case <-time.After(c.recInterval): + } + } } // healthCheckLoop checks whether connection to VPP is alive. In case of disconnect, // it continues with connectLoop and tries to reconnect. -func (c *Connection) healthCheckLoop(connChan chan ConnectionEvent) { +func (c *Connection) healthCheckLoop() backgroundLoopStatus { // create a separate API channel for health check probes ch, err := c.newAPIChannel(1, 1) if err != nil { log.Error("Failed to create health check API channel, health check will be disabled:", err) - return + return terminate } + defer ch.Close() var ( sinceLastReply time.Duration @@ -301,80 +391,84 @@ func (c *Connection) healthCheckLoop(connChan chan ConnectionEvent) { ) // send health check probes until an error or timeout occurs - for { - // sleep until next health check probe period - time.Sleep(HealthCheckProbeInterval) - - if atomic.LoadUint32(&c.vppConnected) == 0 { - // Disconnect has been called in the meantime, return the healthcheck - reconnect loop - log.Debug("Disconnected on request, exiting health check loop.") - return - } + probeInterval := time.NewTicker(HealthCheckProbeInterval) + defer probeInterval.Stop() - // try draining probe replies from previous request before sending next one +HealthCheck: + for { select { - case <-ch.replyChan: - log.Debug("drained old probe reply from reply channel") - default: - } + case <-c.healthCheckDone: + // Terminate the health check loop on connection disconnect + log.Debug("Disconnected on request, exiting health check loop.") + return terminate + case <-probeInterval.C: + // try draining probe replies from previous request before sending next one + select { + case <-ch.replyChan: + log.Debug("drained old probe reply from reply channel") + default: + } - // send the control ping request - ch.reqChan <- &vppRequest{msg: c.msgControlPing} + // send the control ping request + ch.reqChan <- &vppRequest{msg: c.msgControlPing} - for { - // expect response within timeout period - select { - case vppReply := <-ch.replyChan: - err = vppReply.err + for { + // expect response within timeout period + select { + case vppReply := <-ch.replyChan: + err = vppReply.err - case <-time.After(HealthCheckReplyTimeout): - err = ErrProbeTimeout + case <-time.After(HealthCheckReplyTimeout): + err = ErrProbeTimeout - // check if time since last reply from any other - // channel is less than health check reply timeout - c.lastReplyLock.Lock() - sinceLastReply = time.Since(c.lastReply) - c.lastReplyLock.Unlock() + // check if time since last reply from any other + // channel is less than health check reply timeout + c.lastReplyLock.Lock() + sinceLastReply = time.Since(c.lastReply) + c.lastReplyLock.Unlock() - if sinceLastReply < HealthCheckReplyTimeout { - log.Warnf("VPP health check probe timing out, but some request on other channel was received %v ago, continue waiting!", sinceLastReply) - continue + if sinceLastReply < HealthCheckReplyTimeout { + log.Warnf("VPP health check probe timing out, but some request on other channel was received %v ago, continue waiting!", sinceLastReply) + continue + } } + break } - break - } - if err == ErrProbeTimeout { - failedChecks++ - log.Warnf("VPP health check probe timed out after %v (%d. timeout)", HealthCheckReplyTimeout, failedChecks) - if failedChecks > HealthCheckThreshold { - // in case of exceeded failed check treshold, assume VPP disconnected - log.Errorf("VPP health check exceeded treshold for timeouts (>%d), assuming disconnect", HealthCheckThreshold) - connChan <- ConnectionEvent{Timestamp: time.Now(), State: Disconnected} - break + if err == ErrProbeTimeout { + failedChecks++ + log.Warnf("VPP health check probe timed out after %v (%d. timeout)", HealthCheckReplyTimeout, failedChecks) + if failedChecks > HealthCheckThreshold { + // in case of exceeded failed check threshold, assume VPP unresponsive + log.Errorf("VPP does not responding, the health check exceeded threshold for timeouts (>%d)", HealthCheckThreshold) + c.sendConnEvent(ConnectionEvent{Timestamp: time.Now(), State: NotResponding}) + break HealthCheck + } + } else if err != nil { + // in case of error, assume VPP disconnected + log.Errorf("VPP health check probe failed: %v", err) + c.sendConnEvent(ConnectionEvent{Timestamp: time.Now(), State: Disconnected, Error: err}) + break HealthCheck + } else if failedChecks > 0 { + // in case of success after failed checks, clear failed check counter + failedChecks = 0 + log.Infof("VPP health check probe OK") } - } else if err != nil { - // in case of error, assume VPP disconnected - log.Errorf("VPP health check probe failed: %v", err) - connChan <- ConnectionEvent{Timestamp: time.Now(), State: Disconnected, Error: err} - break - } else if failedChecks > 0 { - // in case of success after failed checks, clear failed check counter - failedChecks = 0 - log.Infof("VPP health check probe OK") } } // cleanup - ch.Close() c.disconnectVPP() - // we are now disconnected, start connect loop - c.connectLoop(connChan) + return resume } func getMsgNameWithCrc(x api.Message) string { - return x.GetMessageName() + "_" + x.GetCrcString() + return getMsgID(x.GetMessageName(), x.GetCrcString()) +} + +func getMsgID(name, crc string) string { + return name + "_" + crc } func getMsgFactory(msg api.Message) func() api.Message { @@ -388,63 +482,125 @@ func (c *Connection) GetMessageID(msg api.Message) (uint16, error) { if c == nil { return 0, errors.New("nil connection passed in") } - - if msgID, ok := c.msgIDs[getMsgNameWithCrc(msg)]; ok { - return msgID, nil - } - + pkgPath := c.GetMessagePath(msg) msgID, err := c.vppClient.GetMsgID(msg.GetMessageName(), msg.GetCrcString()) if err != nil { return 0, err } - + func() { + c.msgMapByPathLock.Lock() + defer c.msgMapByPathLock.Unlock() + + if pathMsgs, pathOk := c.msgMapByPath[pkgPath]; !pathOk { + c.msgMapByPath[pkgPath] = make(map[uint16]api.Message) + c.msgMapByPath[pkgPath][msgID] = msg + } else if _, msgOk := pathMsgs[msgID]; !msgOk { + c.msgMapByPath[pkgPath][msgID] = msg + } + }() + if _, ok := c.msgIDs[getMsgNameWithCrc(msg)]; ok { + return msgID, nil + } c.msgIDs[getMsgNameWithCrc(msg)] = msgID - c.msgMap[msgID] = msg - return msgID, nil } // LookupByID looks up message name and crc by ID. -func (c *Connection) LookupByID(msgID uint16) (api.Message, error) { +func (c *Connection) LookupByID(path string, msgID uint16) (api.Message, error) { if c == nil { return nil, errors.New("nil connection passed in") } - - if msg, ok := c.msgMap[msgID]; ok { + c.msgMapByPathLock.RLock() + defer c.msgMapByPathLock.RUnlock() + if msg, ok := c.msgMapByPath[path][msgID]; ok { return msg, nil } + return nil, fmt.Errorf("unknown message ID %d for path '%s'", msgID, path) +} - return nil, fmt.Errorf("unknown message ID: %d", msgID) +// GetMessagePath returns path for the given message +func (c *Connection) GetMessagePath(msg api.Message) string { + return path.Dir(reflect.TypeOf(msg).Elem().PkgPath()) } // retrieveMessageIDs retrieves IDs for all registered messages and stores them in map func (c *Connection) retrieveMessageIDs() (err error) { - t := time.Now() - - msgs := api.GetRegisteredMessages() + msgsByPath := api.GetRegisteredMessages() + t := time.Now() + debugMsgIDs := isDebugOn(debugOptMsgId) + if debugMsgIDs { + log.Debugf("start retrieving message IDs for %d pkg paths", len(msgsByPath)) + } var n int - for name, msg := range msgs { - msgID, err := c.GetMessageID(msg) - if err != nil { - log.Debugf("retrieving msgID for %s failed: %v", name, err) - continue - } - n++ - - if c.pingReqID == 0 && msg.GetMessageName() == c.msgControlPing.GetMessageName() { - c.pingReqID = msgID - c.msgControlPing = reflect.New(reflect.TypeOf(msg).Elem()).Interface().(api.Message) - } else if c.pingReplyID == 0 && msg.GetMessageName() == c.msgControlPingReply.GetMessageName() { - c.pingReplyID = msgID - c.msgControlPingReply = reflect.New(reflect.TypeOf(msg).Elem()).Interface().(api.Message) + for pkgPath, msgs := range msgsByPath { + l := log.WithField("pkgPath", pkgPath) + if debugMsgIDs { + l.Debugf("retrieving IDs for %d messages", len(msgs)) } + tt := time.Now() + var nn int + for _, msg := range msgs { + msgID, err := c.GetMessageID(msg) + if err != nil { + if debugMsgIDs { + l.Warnf("failed to retrieve message ID for %s: %v", msg.GetMessageName(), err) + } + continue + } + n++ + nn++ + + if c.pingReqID == 0 && msg.GetMessageName() == c.msgControlPing.GetMessageName() { + c.pingReqID = msgID + c.msgControlPing = reflect.New(reflect.TypeOf(msg).Elem()).Interface().(api.Message) + } else if c.pingReplyID == 0 && msg.GetMessageName() == c.msgControlPingReply.GetMessageName() { + c.pingReplyID = msgID + c.msgControlPingReply = reflect.New(reflect.TypeOf(msg).Elem()).Interface().(api.Message) + } + if debugMsgIDs { + l.Debugf(" - #%d message %q (%s) has ID: %d", n, msg.GetMessageName(), getMsgNameWithCrc(msg), msgID) + } + } if debugMsgIDs { - log.Debugf("message %q (%s) has ID: %d", name, getMsgNameWithCrc(msg), msgID) + l.WithField("took", time.Since(tt)). + Debugf("retrieved IDs for %d/%d messages", nn, len(msgs)) } } - log.Debugf("retrieved %d/%d msgIDs (took %s)", n, len(msgs), time.Since(t)) + if debugMsgIDs { + log.WithField("took", time.Since(t)). + Debugf("done retrieving IDs for %d messages", n) + } return nil } + +func (c *Connection) sendConnEvent(event ConnectionEvent) { + select { + case c.connChan <- event: + default: + log.Warn("Connection state channel is full, discarding value.") + } +} + +// Trace gives access to the API trace interface +func (c *Connection) Trace() api.Trace { + return c.apiTrace +} + +// trace records api message +func (c *Connection) trace(msg api.Message, chId uint16, t time.Time, isReceived bool) { + if atomic.LoadInt32(&c.apiTrace.isEnabled) == 0 { + return + } + entry := &api.Record{ + Message: msg, + Timestamp: t, + IsReceived: isReceived, + ChannelID: chId, + } + c.apiTrace.mux.Lock() + c.apiTrace.list = append(c.apiTrace.list, entry) + c.apiTrace.mux.Unlock() +} diff --git a/core/connection_test.go b/core/connection_test.go index 64e75b7a..32441993 100644 --- a/core/connection_test.go +++ b/core/connection_test.go @@ -15,16 +15,21 @@ package core_test import ( + "fmt" + "math" "testing" + "time" . "github.com/onsi/gomega" "github.com/alkiranet/govpp/adapter/mock" "github.com/alkiranet/govpp/api" + "github.com/alkiranet/govpp/binapi/ethernet_types" + interfaces "github.com/alkiranet/govpp/binapi/interface" + "github.com/alkiranet/govpp/binapi/interface_types" + "github.com/alkiranet/govpp/binapi/memclnt" "github.com/alkiranet/govpp/codec" "github.com/alkiranet/govpp/core" - "github.com/alkiranet/govpp/examples/binapi/interfaces" - "github.com/alkiranet/govpp/examples/binapi/vpe" ) type testCtx struct { @@ -51,9 +56,16 @@ func setupTest(t *testing.T, bufferedChan bool) *testCtx { } Expect(err).ShouldNot(HaveOccurred()) + ctx.resetReplyTimeout() + return ctx } +func (ctx *testCtx) resetReplyTimeout() { + // setting reply timeout to non-zero value to fail fast on potential deadlocks + ctx.ch.SetReplyTimeout(time.Second * 5) +} + func (ctx *testCtx) teardownTest() { ctx.ch.Close() ctx.conn.Disconnect() @@ -78,7 +90,120 @@ func TestAsyncConnection(t *testing.T) { ctx := setupTest(t, false) defer ctx.teardownTest() + var ( + connectCalled int + disconnectCalled int + ) + + ctx.conn.Disconnect() + + ctx.mockVpp.SetConnectCallback(func() { connectCalled++ }) + ctx.mockVpp.SetDisconnectCallback(func() { disconnectCalled++ }) + conn, statusChan, err := core.AsyncConnect(ctx.mockVpp, core.DefaultMaxReconnectAttempts, core.DefaultReconnectInterval) + ctx.conn = conn + + Expect(err).ShouldNot(HaveOccurred()) + Expect(conn).ShouldNot(BeNil()) + + ev := <-statusChan + Expect(ev.State).Should(BeEquivalentTo(core.Connected)) + + conn.Disconnect() + Expect(connectCalled).Should(BeEquivalentTo(1)) + Expect(disconnectCalled).Should(BeEquivalentTo(1)) +} + +func TestAsyncConnectionProcessesVppTimeout(t *testing.T) { + ctx := setupTest(t, false) + defer ctx.teardownTest() + + var ( + connectCalled int + disconnectCalled int + ) + + ctx.conn.Disconnect() + + ctx.mockVpp.SetConnectCallback(func() { + if connectCalled == 0 { + ctx.mockVpp.MockConnectError(fmt.Errorf("no VPP present")) + } else { + ctx.mockVpp.MockConnectError(nil) + } + connectCalled++ + }) + ctx.mockVpp.SetDisconnectCallback(func() { disconnectCalled++ }) + conn, statusChan, err := core.AsyncConnect(ctx.mockVpp, core.DefaultMaxReconnectAttempts, core.DefaultReconnectInterval) + ctx.conn = conn + + Expect(err).ShouldNot(HaveOccurred()) + Expect(conn).ShouldNot(BeNil()) + + ev := <-statusChan + Expect(ev.State).Should(BeEquivalentTo(core.Connected)) + + conn.Disconnect() + Expect(connectCalled).Should(BeEquivalentTo(2)) + Expect(disconnectCalled).Should(BeEquivalentTo(1)) +} + +func TestAsyncConnectionEarlyDisconnect(t *testing.T) { + ctx := setupTest(t, false) + defer ctx.teardownTest() + + var ( + connectCalled int + disconnectCalled int + ) + + timeout := 100 * time.Millisecond + + ctx.conn.Disconnect() + + ctx.mockVpp.MockConnectError(fmt.Errorf("no VPP present")) + ctx.mockVpp.SetConnectCallback(func() { connectCalled++ }) + ctx.mockVpp.SetDisconnectCallback(func() { disconnectCalled++ }) + + conn, statusChan, err := core.AsyncConnect(ctx.mockVpp, math.MaxInt, timeout) + ctx.conn = conn + + Expect(err).ShouldNot(HaveOccurred()) + Expect(conn).ShouldNot(BeNil()) + + timer := time.NewTimer(8 * timeout) + time.Sleep(3 * timeout) + conn.Disconnect() + + // Check if disconnect disconnects + ctx.mockVpp.MockConnectError(nil) + time.Sleep(2 * timeout) + + var connected bool + select { + case <-statusChan: + connected = true + case <-timer.C: + break + } + + Expect(connected).Should(BeFalse()) + Expect(connectCalled).Should(BeNumerically(">", 1)) + Expect(disconnectCalled).Should(BeEquivalentTo(0)) +} + +func TestAsyncConnectionDoubleDisconnect(t *testing.T) { + ctx := setupTest(t, false) + defer ctx.teardownTest() + + var ( + connectCalled int + disconnectCalled int + ) + ctx.conn.Disconnect() + + ctx.mockVpp.SetConnectCallback(func() { connectCalled++ }) + ctx.mockVpp.SetDisconnectCallback(func() { disconnectCalled++ }) conn, statusChan, err := core.AsyncConnect(ctx.mockVpp, core.DefaultMaxReconnectAttempts, core.DefaultReconnectInterval) ctx.conn = conn @@ -87,29 +212,34 @@ func TestAsyncConnection(t *testing.T) { ev := <-statusChan Expect(ev.State).Should(BeEquivalentTo(core.Connected)) + + conn.Disconnect() + conn.Disconnect() + Expect(connectCalled).Should(BeEquivalentTo(1)) + Expect(disconnectCalled).Should(BeEquivalentTo(1)) } func TestCodec(t *testing.T) { RegisterTestingT(t) - msgCodec := &codec.MsgCodec{} + var msgCodec = codec.DefaultCodec // request - data, err := msgCodec.EncodeMsg(&interfaces.CreateLoopback{MacAddress: interfaces.MacAddress{1, 2, 3, 4, 5, 6}}, 11) + data, err := msgCodec.EncodeMsg(&interfaces.CreateLoopback{MacAddress: ethernet_types.MacAddress{1, 2, 3, 4, 5, 6}}, 11) Expect(err).ShouldNot(HaveOccurred()) Expect(data).ShouldNot(BeEmpty()) msg1 := &interfaces.CreateLoopback{} err = msgCodec.DecodeMsg(data, msg1) Expect(err).ShouldNot(HaveOccurred()) - Expect(msg1.MacAddress).To(BeEquivalentTo(interfaces.MacAddress{1, 2, 3, 4, 5, 6})) + Expect(msg1.MacAddress).To(BeEquivalentTo(ethernet_types.MacAddress{1, 2, 3, 4, 5, 6})) // reply - data, err = msgCodec.EncodeMsg(&vpe.ControlPingReply{Retval: 55}, 22) + data, err = msgCodec.EncodeMsg(&memclnt.ControlPingReply{Retval: 55}, 22) Expect(err).ShouldNot(HaveOccurred()) Expect(data).ShouldNot(BeEmpty()) - msg2 := &vpe.ControlPingReply{} + msg2 := &memclnt.ControlPingReply{} err = msgCodec.DecodeMsg(data, msg2) Expect(err).ShouldNot(HaveOccurred()) Expect(msg2.Retval).To(BeEquivalentTo(55)) @@ -118,7 +248,7 @@ func TestCodec(t *testing.T) { func TestCodecNegative(t *testing.T) { RegisterTestingT(t) - msgCodec := &codec.MsgCodec{} + var msgCodec = codec.DefaultCodec // nil message for encoding data, err := msgCodec.EncodeMsg(nil, 15) @@ -132,9 +262,9 @@ func TestCodecNegative(t *testing.T) { Expect(err.Error()).To(ContainSubstring("nil message")) // nil data for decoding - err = msgCodec.DecodeMsg(nil, &vpe.ControlPingReply{}) + err = msgCodec.DecodeMsg(nil, &memclnt.ControlPingReply{}) Expect(err).Should(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("EOF")) + Expect(err.Error()).To(ContainSubstring("panic")) } func TestSimpleRequestsWithSequenceNumbers(t *testing.T) { @@ -143,13 +273,13 @@ func TestSimpleRequestsWithSequenceNumbers(t *testing.T) { var reqCtx []api.RequestCtx for i := 0; i < 10; i++ { - ctx.mockVpp.MockReply(&vpe.ControlPingReply{}) - req := &vpe.ControlPing{} + ctx.mockVpp.MockReply(&memclnt.ControlPingReply{}) + req := &memclnt.ControlPing{} reqCtx = append(reqCtx, ctx.ch.SendRequest(req)) } for i := 0; i < 10; i++ { - reply := &vpe.ControlPingReply{} + reply := &memclnt.ControlPingReply{} err := reqCtx[i].ReceiveReply(reply) Expect(err).ShouldNot(HaveOccurred()) } @@ -161,10 +291,10 @@ func TestMultiRequestsWithSequenceNumbers(t *testing.T) { var msgs []api.Message for i := 0; i < 10; i++ { - msgs = append(msgs, &interfaces.SwInterfaceDetails{SwIfIndex: interfaces.InterfaceIndex(i)}) + msgs = append(msgs, &interfaces.SwInterfaceDetails{SwIfIndex: interface_types.InterfaceIndex(i)}) } ctx.mockVpp.MockReply(msgs...) - ctx.mockVpp.MockReply(&vpe.ControlPingReply{}) + ctx.mockVpp.MockReply(&memclnt.ControlPingReply{}) // send multipart request reqCtx := ctx.ch.SendMultiRequest(&interfaces.SwInterfaceDump{}) @@ -196,15 +326,18 @@ func TestSimpleRequestWithTimeout(t *testing.T) { // reply for a previous timeouted requests to be ignored ctx.mockVpp.MockReplyWithContext(mock.MsgWithContext{ - Msg: &vpe.ControlPingReply{}, + Msg: &memclnt.ControlPingReply{}, SeqNum: 0, }) // send reply later - req1 := &vpe.ControlPing{} + req1 := &memclnt.ControlPing{} reqCtx1 := ctx.ch.SendRequest(req1) - reply := &vpe.ControlPingReply{} + ctx.ch.SetReplyTimeout(time.Millisecond) + time.Sleep(time.Millisecond) + + reply := &memclnt.ControlPingReply{} err := reqCtx1.ReceiveReply(reply) Expect(err).ToNot(BeNil()) Expect(err.Error()).To(HavePrefix("no reply received within the timeout period")) @@ -212,21 +345,23 @@ func TestSimpleRequestWithTimeout(t *testing.T) { ctx.mockVpp.MockReplyWithContext( // reply for the previous request mock.MsgWithContext{ - Msg: &vpe.ControlPingReply{}, + Msg: &memclnt.ControlPingReply{}, SeqNum: 1, }, // reply for the next request mock.MsgWithContext{ - Msg: &vpe.ControlPingReply{}, + Msg: &memclnt.ControlPingReply{}, SeqNum: 2, }) // next request - req2 := &vpe.ControlPing{} + req2 := &memclnt.ControlPing{} reqCtx2 := ctx.ch.SendRequest(req2) + ctx.resetReplyTimeout() + // second request should ignore the first reply and return the second one - reply = &vpe.ControlPingReply{} + reply = &memclnt.ControlPingReply{} err = reqCtx2.ReceiveReply(reply) Expect(err).To(BeNil()) } @@ -236,34 +371,34 @@ func TestSimpleRequestsWithMissingReply(t *testing.T) { defer ctx.teardownTest() // request without reply - req1 := &vpe.ControlPing{} + req1 := &memclnt.ControlPing{} reqCtx1 := ctx.ch.SendRequest(req1) // another request without reply - req2 := &vpe.ControlPing{} + req2 := &memclnt.ControlPing{} reqCtx2 := ctx.ch.SendRequest(req2) // third request with reply ctx.mockVpp.MockReplyWithContext(mock.MsgWithContext{ - Msg: &vpe.ControlPingReply{}, + Msg: &memclnt.ControlPingReply{}, SeqNum: 3, }) - req3 := &vpe.ControlPing{} + req3 := &memclnt.ControlPing{} reqCtx3 := ctx.ch.SendRequest(req3) // the first two should fail, but not consume reply for the 3rd - reply := &vpe.ControlPingReply{} + reply := &memclnt.ControlPingReply{} err := reqCtx1.ReceiveReply(reply) Expect(err).ToNot(BeNil()) Expect(err.Error()).To(Equal("missing binary API reply with sequence number: 1")) - reply = &vpe.ControlPingReply{} + reply = &memclnt.ControlPingReply{} err = reqCtx2.ReceiveReply(reply) Expect(err).ToNot(BeNil()) Expect(err.Error()).To(Equal("missing binary API reply with sequence number: 2")) // the second request should succeed - reply = &vpe.ControlPingReply{} + reply = &memclnt.ControlPingReply{} err = reqCtx3.ReceiveReply(reply) Expect(err).To(BeNil()) } @@ -274,13 +409,13 @@ func TestMultiRequestsWithErrors(t *testing.T) { // replies for a previous timeouted requests to be ignored msgs := []mock.MsgWithContext{ - {Msg: &vpe.ControlPingReply{}, SeqNum: 0xffff - 1}, - {Msg: &vpe.ControlPingReply{}, SeqNum: 0xffff}, - {Msg: &vpe.ControlPingReply{}, SeqNum: 0}, + {Msg: &memclnt.ControlPingReply{}, SeqNum: 0xffff - 1}, + {Msg: &memclnt.ControlPingReply{}, SeqNum: 0xffff}, + {Msg: &memclnt.ControlPingReply{}, SeqNum: 0}, } for i := 0; i < 10; i++ { msgs = append(msgs, mock.MsgWithContext{ - Msg: &interfaces.SwInterfaceDetails{SwIfIndex: interfaces.InterfaceIndex(i)}, + Msg: &interfaces.SwInterfaceDetails{SwIfIndex: interface_types.InterfaceIndex(i)}, SeqNum: 1, Multipart: true, }) @@ -289,7 +424,7 @@ func TestMultiRequestsWithErrors(t *testing.T) { // reply for a next request msgs = append(msgs, mock.MsgWithContext{ - Msg: &vpe.ControlPingReply{}, + Msg: &memclnt.ControlPingReply{}, SeqNum: 2, }) @@ -321,8 +456,8 @@ func TestMultiRequestsWithErrors(t *testing.T) { Expect(err.Error()).To(Equal("missing binary API reply with sequence number: 1")) // reply for the second request has not been consumed - reqCtx2 := ctx.ch.SendRequest(&vpe.ControlPing{}) - reply2 := &vpe.ControlPingReply{} + reqCtx2 := ctx.ch.SendRequest(&memclnt.ControlPing{}) + reply2 := &memclnt.ControlPingReply{} err = reqCtx2.ReceiveReply(reply2) Expect(err).To(BeNil()) } @@ -335,23 +470,25 @@ func TestRequestsOrdering(t *testing.T) { // some replies will get thrown away // first request - ctx.mockVpp.MockReply(&vpe.ControlPingReply{}) - req1 := &vpe.ControlPing{} + ctx.mockVpp.MockReply(&memclnt.ControlPingReply{}) + req1 := &memclnt.ControlPing{} reqCtx1 := ctx.ch.SendRequest(req1) // second request - ctx.mockVpp.MockReply(&vpe.ControlPingReply{}) - req2 := &vpe.ControlPing{} + ctx.mockVpp.MockReply(&memclnt.ControlPingReply{}) + req2 := &memclnt.ControlPing{} reqCtx2 := ctx.ch.SendRequest(req2) // if reply for the second request is read first, the reply for the first // request gets thrown away. - reply2 := &vpe.ControlPingReply{} + reply2 := &memclnt.ControlPingReply{} err := reqCtx2.ReceiveReply(reply2) Expect(err).To(BeNil()) + ctx.ch.SetReplyTimeout(time.Millisecond) + // first request has already been considered closed - reply1 := &vpe.ControlPingReply{} + reply1 := &memclnt.ControlPingReply{} err = reqCtx1.ReceiveReply(reply1) Expect(err).ToNot(BeNil()) Expect(err.Error()).To(HavePrefix("no reply received within the timeout period")) @@ -366,12 +503,12 @@ func TestCycleOverSetOfSequenceNumbers(t *testing.T) { for i := 0; i < numIters+30; i++ { if i < numIters { - ctx.mockVpp.MockReply(&vpe.ControlPingReply{}) - req := &vpe.ControlPing{} + ctx.mockVpp.MockReply(&memclnt.ControlPingReply{}) + req := &memclnt.ControlPing{} reqCtx[i] = ctx.ch.SendRequest(req) } if i > 30 { - reply := &vpe.ControlPingReply{} + reply := &memclnt.ControlPingReply{} err := reqCtx[i-30].ReceiveReply(reply) Expect(err).ShouldNot(HaveOccurred()) } diff --git a/core/control_ping.go b/core/control_ping.go index e899b396..738922a9 100644 --- a/core/control_ping.go +++ b/core/control_ping.go @@ -21,15 +21,9 @@ func SetControlPingReply(m api.Message) { type ControlPing struct{} -func (*ControlPing) GetMessageName() string { - return "control_ping" -} -func (*ControlPing) GetCrcString() string { - return "51077d14" -} -func (*ControlPing) GetMessageType() api.MessageType { - return api.RequestMessage -} +func (*ControlPing) GetMessageName() string { return "control_ping" } +func (*ControlPing) GetCrcString() string { return "51077d14" } +func (*ControlPing) GetMessageType() api.MessageType { return api.RequestMessage } type ControlPingReply struct { Retval int32 @@ -37,15 +31,9 @@ type ControlPingReply struct { VpePID uint32 } -func (*ControlPingReply) GetMessageName() string { - return "control_ping_reply" -} -func (*ControlPingReply) GetCrcString() string { - return "f6b0b8ca" -} -func (*ControlPingReply) GetMessageType() api.MessageType { - return api.ReplyMessage -} +func (*ControlPingReply) GetMessageName() string { return "control_ping_reply" } +func (*ControlPingReply) GetCrcString() string { return "f6b0b8ca" } +func (*ControlPingReply) GetMessageType() api.MessageType { return api.ReplyMessage } func init() { api.RegisterMessage((*ControlPing)(nil), "ControlPing") diff --git a/core/doc.go b/core/doc.go index 5b0b40e2..8a82085e 100644 --- a/core/doc.go +++ b/core/doc.go @@ -36,67 +36,63 @@ // } // defer ch.Close() // -// -// Simple Request-Reply API +// # Simple Request-Reply API // // The simple version of the API is based on blocking SendRequest / ReceiveReply calls, where a single request // message is sent to VPP and a single reply message is filled in when the reply comes from VPP: // -// req := &acl.ACLPluginGetVersion{} -// reply := &acl.ACLPluginGetVersionReply{} +// req := &acl.ACLPluginGetVersion{} +// reply := &acl.ACLPluginGetVersionReply{} // -// err := ch.SendRequest(req).ReceiveReply(reply) -// // process the reply +// err := ch.SendRequest(req).ReceiveReply(reply) +// // process the reply // // Note that if the reply message type that comes from VPP does not match with provided one, you'll get an error. // -// -// Multipart Reply API +// # Multipart Reply API // // If multiple messages are expected as a reply to a request, SendMultiRequest API must be used: // -// req := &interfaces.SwInterfaceDump{} -// reqCtx := ch.SendMultiRequest(req) +// req := &interfaces.SwInterfaceDump{} +// reqCtx := ch.SendMultiRequest(req) // // for { -// reply := &interfaces.SwInterfaceDetails{} -// stop, err := reqCtx.ReceiveReply(reply) -// if stop { -// break // break out of the loop +// reply := &interfaces.SwInterfaceDetails{} +// stop, err := reqCtx.ReceiveReply(reply) +// if stop { +// break // break out of the loop // } // // process the reply -// } +// } // // Note that if the last reply has been already consumed, stop boolean return value is set to true. // Do not use the message itself if stop is true - it won't be filled with actual data. // -// -// Go Channels API +// # Go Channels API // // The blocking API introduced above may be not sufficient for some management applications that strongly // rely on usage of Go channels. In this case, the API allows to access the underlying Go channels directly, e.g. // the following replacement of the SendRequest / ReceiveReply API: // -// req := &acl.ACLPluginGetVersion{} -// // send the request to the request go channel -// ch.GetRequestChannel <- &api.VppRequest{Message: req} -// -// // receive a reply from the reply go channel -// vppReply := <-ch.GetReplyChannel +// req := &acl.ACLPluginGetVersion{} +// // send the request to the request go channel +// ch.GetRequestChannel <- &api.VppRequest{Message: req} // -// // decode the message -// reply := &acl.ACLPluginGetVersionReply{} -// err := ch.MsgDecoder.DecodeMsg(vppReply.Data, reply) +// // receive a reply from the reply go channel +// vppReply := <-ch.GetReplyChannel // -// // process the reply +// // decode the message +// reply := &acl.ACLPluginGetVersionReply{} +// err := ch.MsgDecoder.DecodeMsg(vppReply.Data, reply) // +// // process the reply // -// Notifications API +// # Notifications API // // to subscribe for receiving of the specified notification messages via provided Go channel, use the // SubscribeNotification API: // -// // subscribe for specific notification message +// // subscribe for specific notification message // notifChan := make(chan api.Message, 100) // subs, _ := ch.SubscribeNotification(notifChan, interfaces.NewSwInterfaceSetFlags) // @@ -107,5 +103,4 @@ // // Note that the caller is responsible for creating the Go channel with preferred buffer size. If the channel's // buffer is full, the notifications will not be delivered into it. -// package core diff --git a/core/genericpool/generic_pool.go b/core/genericpool/generic_pool.go new file mode 100644 index 00000000..293d8c64 --- /dev/null +++ b/core/genericpool/generic_pool.go @@ -0,0 +1,32 @@ +package genericpool + +import ( + "sync" +) + +type Resettable interface { + Reset() +} + +type Pool[T any] struct { + p sync.Pool +} + +func (p *Pool[T]) Get() T { + return p.p.Get().(T) +} + +func (p *Pool[T]) Put(x T) { + if res, ok := any(x).(Resettable); ok { + res.Reset() + } + p.p.Put(x) +} + +func New[T any](f func() T) *Pool[T] { + return &Pool[T]{ + p: sync.Pool{ + New: func() any { return f() }, + }, + } +} diff --git a/core/log.go b/core/log.go index 5960d6b8..38256b2f 100644 --- a/core/log.go +++ b/core/log.go @@ -2,32 +2,73 @@ package core import ( "os" + "strings" - logger "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus" +) + +const ( + DebugEnvVar = "DEBUG_GOVPP" + + debugOptMsgId = "msgid" + debugOptChannels = "channels" ) var ( - debug = os.Getenv("DEBUG_GOVPP") != "" - debugMsgIDs = os.Getenv("DEBUG_GOVPP_MSGIDS") != "" + debugOn = os.Getenv(DebugEnvVar) != "" + debugMap = initDebugMap(os.Getenv(DebugEnvVar)) - log = logger.New() // global logger + log = logrus.New() ) -// init initializes global logger, which logs debug level messages to stdout. +// init initializes global logger func init() { - log.Out = os.Stdout - if debug { - log.Level = logger.DebugLevel - log.Debugf("govpp/core: debug mode enabled") + log.Formatter = &logrus.TextFormatter{ + EnvironmentOverrideColors: true, } + if debugOn { + log.Level = logrus.DebugLevel + log.Debugf("govpp: debug enabled %+v", debugMap) + } +} + +func isDebugOn(u string) bool { + _, ok := debugMap[u] + return ok +} + +func initDebugMap(s string) map[string]string { + debugMap := make(map[string]string) + for _, p := range splitString(s) { + var key, val string + kv := strings.SplitN(p, "=", 2) + key = kv[0] + if len(kv) > 1 { + val = kv[1] + } else { + val = "true" + } + debugMap[key] = val + } + return debugMap +} + +func splitString(s string) []string { + return strings.FieldsFunc(s, func(c rune) bool { + switch c { + case ';', ',', ' ': + return true + } + return false + }) } // SetLogger sets global logger to l. -func SetLogger(l *logger.Logger) { +func SetLogger(l *logrus.Logger) { log = l } // SetLogLevel sets global logger level to lvl. -func SetLogLevel(lvl logger.Level) { +func SetLogLevel(lvl logrus.Level) { log.Level = lvl } diff --git a/core/request_handler.go b/core/request_handler.go index ddd53075..8a07e307 100644 --- a/core/request_handler.go +++ b/core/request_handler.go @@ -17,10 +17,13 @@ package core import ( "errors" "fmt" + "reflect" "sync/atomic" "time" logger "github.com/sirupsen/logrus" + + "github.com/alkiranet/govpp/api" ) var ReplyChannelTimeout = time.Millisecond * 100 @@ -33,17 +36,18 @@ var ( // watchRequests watches for requests on the request API channel and forwards them as messages to VPP. func (c *Connection) watchRequests(ch *Channel) { for { - select { - case req, ok := <-ch.reqChan: - // new request on the request channel - if !ok { - // after closing the request channel, release API channel and return - c.releaseAPIChannel(ch) - return - } - if err := c.processRequest(ch, req); err != nil { - sendReplyError(ch, req, err) - } + req, ok := <-ch.reqChan + // new request on the request channel + if !ok { + // after closing the request channel, release API channel and return + c.releaseAPIChannel(ch) + return + } + if err := c.processRequest(ch, req); err != nil { + sendReply(ch, &vppReply{ + seqNum: req.seqNum, + err: fmt.Errorf("unable to process request: %w", err), + }) } } } @@ -53,7 +57,13 @@ func (c *Connection) processRequest(ch *Channel, req *vppRequest) error { // check whether we are connected to VPP if atomic.LoadUint32(&c.vppConnected) == 0 { err := ErrNotConnected - log.Errorf("processing request failed: %v", err) + log.WithFields(logger.Fields{ + "channel": ch.id, + "seq_num": req.seqNum, + "msg_name": req.msg.GetMessageName(), + "msg_crc": req.msg.GetCrcString(), + "error": err, + }).Warnf("Unable to process request") return err } @@ -61,12 +71,13 @@ func (c *Connection) processRequest(ch *Channel, req *vppRequest) error { msgID, err := c.GetMessageID(req.msg) if err != nil { log.WithFields(logger.Fields{ + "channel": ch.id, "msg_name": req.msg.GetMessageName(), "msg_crc": req.msg.GetCrcString(), "seq_num": req.seqNum, "error": err, - }).Errorf("failed to retrieve message ID") - return fmt.Errorf("unable to retrieve message ID: %v", err) + }).Warnf("Unable to retrieve message ID") + return err } // encode the message into binary @@ -76,57 +87,72 @@ func (c *Connection) processRequest(ch *Channel, req *vppRequest) error { "channel": ch.id, "msg_id": msgID, "msg_name": req.msg.GetMessageName(), + "msg_crc": req.msg.GetCrcString(), "seq_num": req.seqNum, "error": err, - }).Errorf("failed to encode message: %#v", req.msg) - return fmt.Errorf("unable to encode the message: %v", err) + }).Warnf("Unable to encode message: %T %+v", req.msg, req.msg) + return err } context := packRequestContext(ch.id, req.multi, req.seqNum) - if log.Level == logger.DebugLevel { // for performance reasons - logrus does some processing even if debugs are disabled + if log.Level >= logger.DebugLevel { // for performance reasons - logrus does some processing even if debugs are disabled log.WithFields(logger.Fields{ "channel": ch.id, - "context": context, - "is_multi": req.multi, "msg_id": msgID, - "msg_size": len(data), - "seq_num": req.seqNum, + "msg_name": req.msg.GetMessageName(), "msg_crc": req.msg.GetCrcString(), - }).Debugf("==> govpp send: %s: %+v", req.msg.GetMessageName(), req.msg) + "seq_num": req.seqNum, + "is_multi": req.multi, + "context": context, + "data_len": len(data), + }).Debugf("--> SEND MSG: %T %+v", req.msg, req.msg) } // send the request to VPP + t := time.Now() err = c.vppClient.SendMsg(context, data) if err != nil { - err = fmt.Errorf("unable to send the message: %v", err) log.WithFields(logger.Fields{ - "context": context, - "msg_id": msgID, - "seq_num": req.seqNum, - }).Error(err) + "channel": ch.id, + "msg_id": msgID, + "msg_name": req.msg.GetMessageName(), + "msg_crc": req.msg.GetCrcString(), + "seq_num": req.seqNum, + "is_multi": req.multi, + "context": context, + "data_len": len(data), + "error": err, + }).Warnf("Unable to send message") return err } + c.trace(req.msg, ch.id, t, false) if req.multi { // send a control ping to determine end of the multipart response pingData, _ := c.codec.EncodeMsg(c.msgControlPing, c.pingReqID) - log.WithFields(logger.Fields{ - "channel": ch.id, - "context": context, - "msg_id": c.pingReqID, - "msg_size": len(pingData), - "seq_num": req.seqNum, - }).Debug("--> sending control ping") + if log.Level >= logger.DebugLevel { + log.WithFields(logger.Fields{ + "channel": ch.id, + "msg_id": c.pingReqID, + "msg_name": c.msgControlPing.GetMessageName(), + "msg_crc": c.msgControlPing.GetCrcString(), + "seq_num": req.seqNum, + "context": context, + "data_len": len(pingData), + }).Debugf(" -> SEND MSG: %T", c.msgControlPing) + } + t = time.Now() if err := c.vppClient.SendMsg(context, pingData); err != nil { log.WithFields(logger.Fields{ "context": context, - "msg_id": msgID, "seq_num": req.seqNum, - }).Warnf("unable to send control ping: %v", err) + "error": err, + }).Warnf("unable to send control ping") } + c.trace(c.msgControlPing, ch.id, t, false) } return nil @@ -135,13 +161,15 @@ func (c *Connection) processRequest(ch *Channel, req *vppRequest) error { // msgCallback is called whenever any binary API message comes from VPP. func (c *Connection) msgCallback(msgID uint16, data []byte) { if c == nil { - log.Warn("Already disconnected, ignoring the message.") + log.WithField( + "msg_id", msgID, + ).Warn("Connection already disconnected, ignoring the message.") return } - msg, ok := c.msgMap[msgID] - if !ok { - log.Warnf("Unknown message received, ID: %d", msgID) + msg, err := c.getMessageByID(msgID) + if err != nil { + log.Warnln(err) return } @@ -150,12 +178,22 @@ func (c *Connection) msgCallback(msgID uint16, data []byte) { // - replies that don't have context as first field (comes as zero) // - events that don't have context at all (comes as non zero) // - context, err := c.codec.DecodeMsgContext(data, msg) + context, err := c.codec.DecodeMsgContext(data, msg.GetMessageType()) if err != nil { - log.Errorf("decoding context failed: %v", err) + log.WithField("msg_id", msgID).Warnf("Unable to decode message context: %v", err) + return } chanID, isMulti, seqNum := unpackRequestContext(context) + + // decode and trace the message + msg = reflect.New(reflect.TypeOf(msg).Elem()).Interface().(api.Message) + if err = c.codec.DecodeMsg(data, msg); err != nil { + log.WithField("msg", msg).Warnf("Unable to decode message: %v", err) + return + } + c.trace(msg, chanID, time.Now(), true) + if log.Level == logger.DebugLevel { // for performance reasons - logrus does some processing even if debugs are disabled log.WithFields(logger.Fields{ "context": context, @@ -165,7 +203,7 @@ func (c *Connection) msgCallback(msgID uint16, data []byte) { "is_multi": isMulti, "seq_num": seqNum, "msg_crc": msg.GetCrcString(), - }).Debugf("<== govpp recv: %s", msg.GetMessageName()) + }).Debugf("<-- govpp RECEIVE: %s", msg.GetMessageName()) } if context == 0 || c.isNotificationMessage(msgID) { @@ -208,23 +246,36 @@ func (c *Connection) msgCallback(msgID uint16, data []byte) { // sendReply sends the reply into the go channel, if it cannot be completed without blocking, otherwise // it logs the error and do not send the message. func sendReply(ch *Channel, reply *vppReply) { + // first try to avoid creating timer select { case ch.replyChan <- reply: - // reply sent successfully - case <-time.After(ReplyChannelTimeout): + return // reply sent ok + default: + // reply channel full + } + if ch.receiveReplyTimeout == 0 { + log.WithFields(logger.Fields{ + "channel": ch.id, + "msg_id": reply.msgID, + "seq_num": reply.seqNum, + "err": reply.err, + }).Warn("Reply channel full, dropping reply.") + return + } + select { + case ch.replyChan <- reply: + return // reply sent ok + case <-time.After(ch.receiveReplyTimeout): // receiver still not ready log.WithFields(logger.Fields{ - "channel": ch, + "channel": ch.id, "msg_id": reply.msgID, "seq_num": reply.seqNum, - }).Warn("Unable to send the reply, reciever end not ready.") + "err": reply.err, + }).Warnf("Unable to send reply (reciever end not ready in %v).", ch.receiveReplyTimeout) } } -func sendReplyError(ch *Channel, req *vppRequest, err error) { - sendReply(ch, &vppReply{seqNum: req.seqNum, err: err}) -} - // isNotificationMessage returns true if someone has subscribed to provided message ID. func (c *Connection) isNotificationMessage(msgID uint16) bool { c.subscriptionsLock.RLock() @@ -255,7 +306,8 @@ func (c *Connection) sendNotifications(msgID uint16, data []byte) { "msg_name": sub.event.GetMessageName(), "msg_id": msgID, "msg_size": len(data), - }).Errorf("Unable to decode the notification message: %v", err) + "error": err, + }).Warnf("Unable to decode the notification message") continue } @@ -324,3 +376,17 @@ func compareSeqNumbers(seqNum1, seqNum2 uint16) int { } return 1 } + +// Returns message based on the message ID not depending on message path. +func (c *Connection) getMessageByID(msgID uint16) (msg api.Message, err error) { + c.msgMapByPathLock.RLock() + defer c.msgMapByPathLock.RUnlock() + + var ok bool + for _, messages := range c.msgMapByPath { + if msg, ok = messages[msgID]; ok { + return msg, nil + } + } + return nil, fmt.Errorf("unknown message received, ID: %d", msgID) +} diff --git a/core/stats.go b/core/stats.go index 3284df78..ab92194b 100644 --- a/core/stats.go +++ b/core/stats.go @@ -3,7 +3,6 @@ package core import ( "path" "strings" - "sync/atomic" "time" "github.com/alkiranet/govpp/adapter" @@ -11,8 +10,9 @@ import ( ) var ( - RetryUpdateCount = 10 - RetryUpdateDelay = time.Millisecond * 10 + RetryUpdateCount = 10 + RetryUpdateDelay = time.Millisecond * 10 + HealthCheckInterval = time.Second // default health check probe interval ) const ( @@ -39,6 +39,12 @@ const ( CounterStatsPrefix = "/err/" + MemoryStatSegPrefix = "/mem/statseg" + MemoryStatSegment = "/mem/stat segment" + MemoryMainHeap = "/mem/main heap" + MemoryStats_Total = "total" + MemoryStats_Used = "used" + InterfaceStatsPrefix = "/if/" InterfaceStats_Names = InterfaceStatsPrefix + "names" InterfaceStats_Drops = InterfaceStatsPrefix + "drops" @@ -72,19 +78,34 @@ const ( type StatsConnection struct { statsClient adapter.StatsAPI - // connected is true if the adapter is connected to VPP - connected uint32 + maxAttempts int // interval for reconnect attempts + recInterval time.Duration // maximum number of reconnect attempts + + connChan chan ConnectionEvent // connection event channel + done chan struct{} // to terminate stats connection watcher errorStatsData *adapter.StatDir nodeStatsData *adapter.StatDir ifaceStatsData *adapter.StatDir sysStatsData *adapter.StatDir bufStatsData *adapter.StatDir + memStatsData *adapter.StatDir } -func newStatsConnection(stats adapter.StatsAPI) *StatsConnection { +func newStatsConnection(stats adapter.StatsAPI, attempts int, interval time.Duration) *StatsConnection { + if attempts == 0 { + attempts = DefaultMaxReconnectAttempts + } + if interval == 0 { + interval = DefaultReconnectInterval + } + return &StatsConnection{ statsClient: stats, + maxAttempts: attempts, + recInterval: interval, + connChan: make(chan ConnectionEvent, NotificationChanBufSize), + done: make(chan struct{}), } } @@ -92,28 +113,50 @@ func newStatsConnection(stats adapter.StatsAPI) *StatsConnection { // This call blocks until it is either connected, or an error occurs. // Only one connection attempt will be performed. func ConnectStats(stats adapter.StatsAPI) (*StatsConnection, error) { - c := newStatsConnection(stats) + log.Debug("Connecting to stats..") + c := newStatsConnection(stats, DefaultMaxReconnectAttempts, DefaultReconnectInterval) - if err := c.connectClient(); err != nil { + if err := c.statsClient.Connect(); err != nil { return nil, err } + log.Debugf("Connected to stats.") return c, nil } -func (c *StatsConnection) connectClient() error { - log.Debug("Connecting to stats..") +// AsyncConnectStats connects to the VPP stats socket asynchronously and returns the connection +// handle with state channel. The call is non-blocking and the caller is expected to watch ConnectionEvent +// values from the channel and wait for connect/disconnect events. Connection loop tries to reconnect the +// socket in case the session was disconnected. +func AsyncConnectStats(stats adapter.StatsAPI, attempts int, interval time.Duration) (*StatsConnection, chan ConnectionEvent, error) { + log.Debug("Connecting to stats asynchronously..") + c := newStatsConnection(stats, attempts, interval) - if err := c.statsClient.Connect(); err != nil { - return err - } + go c.connectLoop() - log.Debugf("Connected to stats.") + return c, c.connChan, nil +} - // store connected state - atomic.StoreUint32(&c.connected, 1) +func (c *StatsConnection) connectLoop() { + log.Debug("Asynchronously connecting to stats..") + var reconnectAttempts int - return nil + // loop until connected + for { + if err := c.statsClient.Connect(); err == nil { + c.sendStatsConnEvent(ConnectionEvent{Timestamp: time.Now(), State: Connected}) + break + } else if reconnectAttempts < c.maxAttempts { + reconnectAttempts++ + log.Warnf("connecting stats failed (attempt %d/%d): %v", reconnectAttempts, c.maxAttempts, err) + time.Sleep(c.recInterval) + } else { + c.sendStatsConnEvent(ConnectionEvent{Timestamp: time.Now(), State: Failed, Error: err}) + return + } + } + // start monitoring stats connection state + go c.monitorSocket() } // Disconnect disconnects from Stats API and releases all connection-related resources. @@ -122,14 +165,41 @@ func (c *StatsConnection) Disconnect() { return } if c.statsClient != nil { - c.disconnectClient() + if err := c.statsClient.Disconnect(); err != nil { + log.Debugf("disconnecting stats client failed: %v", err) + } } + close(c.connChan) + close(c.done) } -func (c *StatsConnection) disconnectClient() { - if atomic.CompareAndSwapUint32(&c.connected, 1, 0) { - if err := c.statsClient.Disconnect(); err != nil { - log.Debugf("disconnecting stats client failed: %v", err) +func (c *StatsConnection) monitorSocket() { + var state, lastState ConnectionState + ticker := time.NewTicker(HealthCheckInterval) + + for { + select { + case <-ticker.C: + _, err := c.statsClient.ListStats(SystemStats_Heartbeat) + state = Connected + if err == adapter.ErrStatsDataBusy { + state = NotResponding + } + if err == adapter.ErrStatsDisconnected { + state = Disconnected + } + if err == adapter.ErrStatsAccessFailed { + state = Failed + } + if state == lastState { + continue + } + lastState = state + c.sendStatsConnEvent(ConnectionEvent{Timestamp: time.Now(), State: state, Error: err}) + case <-c.done: + log.Debugf("health check watcher closed") + c.sendStatsConnEvent(ConnectionEvent{Timestamp: time.Now(), State: Disconnected, Error: nil}) + return } } } @@ -203,6 +273,9 @@ func (c *StatsConnection) GetSystemStats(sysStats *api.SystemStats) (err error) if ss, ok := stat.Data.(adapter.SimpleCounterStat); ok { vals = make([]uint64, len(ss)) for w := range ss { + if ss[w] == nil { + continue + } vals[w] = uint64(ss[w][0]) } } @@ -235,14 +308,23 @@ func (c *StatsConnection) GetErrorStats(errorStats *api.ErrorStats) (err error) } for i, stat := range c.errorStatsData.Entries { - if stat.Type != adapter.ErrorIndex { - continue - } if errStat, ok := stat.Data.(adapter.ErrorStat); ok { - errorStats.Errors[i].Value = uint64(errStat) + values := make([]uint64, len(errStat)) + for j, errStatW := range errStat { + values[j] = uint64(errStatW) + } + errorStats.Errors[i].Values = values + } + if errStat, ok := stat.Data.(adapter.SimpleCounterStat); ok { + values := make([]uint64, len(errStat)) + for j, errStatW := range errStat { + for _, val := range errStatW { + values[j] += uint64(val) + } + } + errorStats.Errors[i].Values = values } } - return nil } @@ -473,3 +555,61 @@ func (c *StatsConnection) GetBufferStats(bufStats *api.BufferStats) (err error) return nil } + +func (c *StatsConnection) GetMemoryStats(memStats *api.MemoryStats) (err error) { + if err := c.updateStats(&c.memStatsData, MemoryStatSegPrefix, MemoryStatSegment, MemoryMainHeap); err != nil { + return err + } + convertStats := func(stats []adapter.Counter) api.MemoryCounters { + memUsg := make([]adapter.Counter, 7) + copy(memUsg, stats) + return api.MemoryCounters{ + Total: uint64(memUsg[0]), Used: uint64(memUsg[1]), Free: uint64(memUsg[2]), UsedMMap: uint64(memUsg[3]), + TotalAlloc: uint64(memUsg[4]), FreeChunks: uint64(memUsg[5]), Releasable: uint64(memUsg[6]), + } + } + + for _, stat := range c.memStatsData.Entries { + if strings.Contains(string(stat.Name), MemoryStatSegPrefix) { + _, f := path.Split(string(stat.Name)) + var val float64 + m, ok := stat.Data.(adapter.ScalarStat) + if ok { + val = float64(m) + } + switch f { + case MemoryStats_Total: + memStats.Total = val //nolint:staticcheck + case MemoryStats_Used: + memStats.Used = val //nolint:staticcheck + } + } else if string(stat.Name) == MemoryStatSegment { + if perHeapStats, ok := stat.Data.(adapter.SimpleCounterStat); ok { + if memStats.Stat == nil { + memStats.Stat = make(map[int]api.MemoryCounters) + } + for heap, stats := range perHeapStats { + memStats.Stat[heap] = convertStats(stats) + } + } + } else if string(stat.Name) == MemoryMainHeap { + if perHeapStats, ok := stat.Data.(adapter.SimpleCounterStat); ok { + if memStats.Main == nil { + memStats.Main = make(map[int]api.MemoryCounters) + } + for heap, stats := range perHeapStats { + memStats.Main[heap] = convertStats(stats) + } + } + } + } + return nil +} + +func (c *StatsConnection) sendStatsConnEvent(event ConnectionEvent) { + select { + case c.connChan <- event: + default: + log.Warn("Stats connection state channel is full, discarding value.") + } +} diff --git a/core/stream.go b/core/stream.go new file mode 100644 index 00000000..154a66ea --- /dev/null +++ b/core/stream.go @@ -0,0 +1,270 @@ +// 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 core + +import ( + "context" + "errors" + "fmt" + "reflect" + "sync" + "time" + + "github.com/sirupsen/logrus" + + "github.com/alkiranet/govpp/api" +) + +type Stream struct { + conn *Connection + ctx context.Context + channel *Channel + // available options + requestSize int + replySize int + replyTimeout time.Duration + // per-request context + pkgPath string + sync.Mutex +} + +func (c *Connection) NewStream(ctx context.Context, options ...api.StreamOption) (api.Stream, error) { + if c == nil { + return nil, errors.New("nil connection passed in") + } + s := &Stream{ + conn: c, + ctx: ctx, + // default options + requestSize: RequestChanBufSize, + replySize: ReplyChanBufSize, + replyTimeout: DefaultReplyTimeout, + } + + // parse custom options + for _, option := range options { + option(s) + } + + ch, err := c.newChannel(s.requestSize, s.replySize) + if err != nil { + return nil, err + } + s.channel = ch + s.channel.SetReplyTimeout(s.replyTimeout) + + // Channel.watchRequests are not started here intentionally, because + // requests are sent directly by SendMsg. + + return s, nil +} + +func (c *Connection) Invoke(ctx context.Context, req api.Message, reply api.Message) error { + stream, err := c.NewStream(ctx) + if err != nil { + return err + } + defer func() { _ = stream.Close() }() + if err := stream.SendMsg(req); err != nil { + return err + } + s := stream.(*Stream) + rep, err := s.recvReply() + if err != nil { + return err + } + if err := s.channel.msgCodec.DecodeMsg(rep.data, reply); err != nil { + return err + } + return nil +} + +type watcher struct { + conn *Connection + ctx context.Context + sub *subscriptionCtx + events chan api.Message + cancel context.CancelFunc + quit chan struct{} +} + +func (w *watcher) Events() <-chan api.Message { + return w.events +} + +func (w *watcher) Close() { + w.cancel() +} + +func (w *watcher) watch() { + log.WithField("event", w.sub.event.GetMessageName()).Debugf("starting event watcher") + defer func() { + if err := w.sub.Unsubscribe(); err != nil { + log.Debugf("watcher unsubscribe error: %v", err) + } + close(w.events) + log.WithField("event", w.sub.event.GetMessageName()).Debugf("event watcher done") + }() + + for { + select { + case <-w.ctx.Done(): + return + case e := <-w.sub.notifChan: + // send to events + select { + case <-w.ctx.Done(): + return + case w.events <- e: + // received by events + } + } + } +} + +func (c *Connection) WatchEvent(ctx context.Context, event api.Message) (api.Watcher, error) { + msgID, err := c.GetMessageID(event) + if err != nil { + log.WithFields(logrus.Fields{ + "msg_name": event.GetMessageName(), + "msg_crc": event.GetCrcString(), + }).Debugf("unable to retrieve event message ID: %v", err) + return nil, fmt.Errorf("unable to retrieve event message ID: %v", err) + } + + cctx, cancel := context.WithCancel(ctx) + + w := &watcher{ + conn: c, + ctx: cctx, + cancel: cancel, + events: make(chan api.Message), + quit: make(chan struct{}), + } + + w.sub = &subscriptionCtx{ + conn: c, + notifChan: make(chan api.Message, 10), + msgID: msgID, + event: event, + msgFactory: getMsgFactory(event), + } + + go w.watch() + + // add the subscription into map + c.subscriptionsLock.Lock() + defer c.subscriptionsLock.Unlock() + + c.subscriptions[msgID] = append(c.subscriptions[msgID], w.sub) + + return w, nil +} + +func (s *Stream) Context() context.Context { + return s.ctx +} + +func (s *Stream) Close() error { + if s.conn == nil { + return errors.New("stream closed") + } + s.conn.releaseAPIChannel(s.channel) + s.conn = nil + return nil +} + +func (s *Stream) SendMsg(msg api.Message) error { + if s.conn == nil { + return errors.New("stream closed") + } + req := s.channel.newRequest(msg, false) + if err := s.conn.processRequest(s.channel, req); err != nil { + return err + } + s.Lock() + s.pkgPath = s.conn.GetMessagePath(msg) + s.Unlock() + return nil +} + +func (s *Stream) RecvMsg() (api.Message, error) { + reply, err := s.recvReply() + if err != nil { + return nil, err + } + // resolve message type + s.Lock() + path := s.pkgPath + s.Unlock() + msg, err := s.channel.msgIdentifier.LookupByID(path, reply.msgID) + if err != nil { + return nil, err + } + // allocate message instance + msg = reflect.New(reflect.TypeOf(msg).Elem()).Interface().(api.Message) + // decode message data + if err := s.channel.msgCodec.DecodeMsg(reply.data, msg); err != nil { + return nil, err + } + return msg, nil +} + +func WithRequestSize(size int) api.StreamOption { + return func(stream api.Stream) { + stream.(*Stream).requestSize = size + } +} + +func WithReplySize(size int) api.StreamOption { + return func(stream api.Stream) { + stream.(*Stream).replySize = size + } +} + +func WithReplyTimeout(timeout time.Duration) api.StreamOption { + return func(stream api.Stream) { + stream.(*Stream).replyTimeout = timeout + } +} + +func (s *Stream) recvReply() (*vppReply, error) { + if s.conn == nil { + return nil, errors.New("stream closed") + } + timeout := s.replyTimeout + if timeout <= 0 { + timeout = maxInt64 + } + timeoutTimer := time.NewTimer(timeout) + select { + case reply, ok := <-s.channel.replyChan: + if !ok { + return nil, fmt.Errorf("reply channel closed") + } + if reply.err != nil { + // this case should actually never happen for stream + // since reply.err is only filled in watchRequests + // and stream does not use it + return nil, reply.err + } + return reply, nil + case <-timeoutTimer.C: + err := fmt.Errorf("no reply received within the timeout period %s", timeout) + return nil, err + case <-s.ctx.Done(): + return nil, s.ctx.Err() + } +} diff --git a/core/stream_test.go b/core/stream_test.go new file mode 100644 index 00000000..5f01afb5 --- /dev/null +++ b/core/stream_test.go @@ -0,0 +1,64 @@ +package core + +import ( + "context" + "testing" + "time" + + . "github.com/onsi/gomega" + "github.com/alkiranet/govpp/adapter/mock" +) + +type streamCtx struct { + mockVpp *mock.VppAdapter + conn *Connection + stream *Stream +} + +func setupStreamTest(t *testing.T) *streamCtx { + RegisterTestingT(t) + + ctx := &streamCtx{ + mockVpp: mock.NewVppAdapter(), + } + + var err error + ctx.conn, err = Connect(ctx.mockVpp) + Expect(err).ShouldNot(HaveOccurred()) + + stream, err := ctx.conn.NewStream(context.TODO()) + Expect(err).ShouldNot(HaveOccurred()) + + ctx.stream = stream.(*Stream) + return ctx +} + +func (ctx *streamCtx) teardownTest() { + err := ctx.stream.Close() + Expect(err).ShouldNot(HaveOccurred()) + ctx.conn.Disconnect() +} + +func TestStreamReply(t *testing.T) { + t.Skip() + ctx := setupStreamTest(t) + defer ctx.teardownTest() + + ctx.stream.replyTimeout = time.Millisecond + + // mock reply + ctx.mockVpp.MockReply(&ControlPingReply{}) + + // first one request should work + err := ctx.stream.SendMsg(&ControlPing{}) + Expect(err).ShouldNot(HaveOccurred()) + _, err = ctx.stream.RecvMsg() + Expect(err).ShouldNot(HaveOccurred()) + + // no other reply ready - expect timeout + err = ctx.stream.SendMsg(&ControlPing{}) + Expect(err).ShouldNot(HaveOccurred()) + _, err = ctx.stream.RecvMsg() + Expect(err).Should(HaveOccurred()) + Expect(err.Error()).To(HavePrefix("no reply received within the timeout period")) +} diff --git a/core/trace.go b/core/trace.go new file mode 100644 index 00000000..3aa07b20 --- /dev/null +++ b/core/trace.go @@ -0,0 +1,68 @@ +// 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. +// 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 core + +import ( + "github.com/alkiranet/govpp/api" + "sort" + "sync" + "sync/atomic" +) + +// trace is the API tracer object synchronizing and keeping recoded messages. +type trace struct { + list []*api.Record + mux *sync.Mutex + + isEnabled int32 +} + +func (c *trace) Enable(enable bool) { + if enable && atomic.CompareAndSwapInt32(&c.isEnabled, 0, 1) { + log.Debugf("API trace enabled") + } else if atomic.CompareAndSwapInt32(&c.isEnabled, 1, 0) { + log.Debugf("API trace disabled") + } +} + +func (c *trace) GetRecords() (list []*api.Record) { + c.mux.Lock() + list = append(list, c.list...) + c.mux.Unlock() + sort.Slice(list, func(i, j int) bool { + return list[i].Timestamp.Before(list[j].Timestamp) + }) + return list +} + +func (c *trace) GetRecordsForChannel(chId uint16) (list []*api.Record) { + c.mux.Lock() + for _, entry := range c.list { + if entry.ChannelID == chId { + list = append(list, entry) + } + } + c.mux.Unlock() + sort.Slice(list, func(i, j int) bool { + return list[i].Timestamp.Before(list[j].Timestamp) + }) + return list +} + +func (c *trace) Clear() { + c.mux.Lock() + c.list = make([]*api.Record, 0) + c.mux.Unlock() +} diff --git a/core/trace_test.go b/core/trace_test.go new file mode 100644 index 00000000..c33285e6 --- /dev/null +++ b/core/trace_test.go @@ -0,0 +1,279 @@ +package core_test + +import ( + "strings" + "testing" + + . "github.com/onsi/gomega" + + "github.com/alkiranet/govpp/api" + interfaces "github.com/alkiranet/govpp/binapi/interface" + "github.com/alkiranet/govpp/binapi/ip" + "github.com/alkiranet/govpp/binapi/l2" + "github.com/alkiranet/govpp/binapi/memclnt" + "github.com/alkiranet/govpp/binapi/memif" + "github.com/alkiranet/govpp/core" +) + +func TestTraceEnabled(t *testing.T) { + t.Skipf("these randomly fail, see integration tests") + + ctx := setupTest(t, false) + defer ctx.teardownTest() + + Expect(ctx.conn.Trace()).ToNot(BeNil()) + ctx.conn.Trace().Enable(true) + + request := []api.Message{ + &interfaces.CreateLoopback{}, + &memif.MemifCreate{}, + &l2.BridgeDomainAddDel{}, + &ip.IPTableAddDel{}, + } + reply := []api.Message{ + &interfaces.CreateLoopbackReply{}, + &memif.MemifCreateReply{}, + &l2.BridgeDomainAddDelReply{}, + &ip.IPTableAddDelReply{}, + } + + for i := 0; i < len(request); i++ { + ctx.mockVpp.MockReply(reply[i]) + err := ctx.ch.SendRequest(request[i]).ReceiveReply(reply[i]) + Expect(err).To(BeNil()) + } + + traced := ctx.conn.Trace().GetRecords() + Expect(traced).ToNot(BeNil()) + Expect(traced).To(HaveLen(8)) + for i, entry := range traced { + Expect(entry.Timestamp).ToNot(BeNil()) + Expect(entry.Message.GetMessageName()).ToNot(Equal("")) + if strings.HasSuffix(entry.Message.GetMessageName(), "_reply") || + strings.HasSuffix(entry.Message.GetMessageName(), "_details") { + Expect(entry.IsReceived).To(BeTrue()) + } else { + Expect(entry.IsReceived).To(BeFalse()) + } + if i%2 == 0 { + Expect(request[i/2].GetMessageName()).To(Equal(entry.Message.GetMessageName())) + } else { + Expect(reply[i/2].GetMessageName()).To(Equal(entry.Message.GetMessageName())) + } + } +} + +func TestMultiRequestTraceEnabled(t *testing.T) { + t.Skipf("these randomly fail, see integration tests") + + ctx := setupTest(t, false) + defer ctx.teardownTest() + + ctx.conn.Trace().Enable(true) + + request := []api.Message{ + &interfaces.SwInterfaceDump{}, + } + reply := []api.Message{ + &interfaces.SwInterfaceDetails{ + SwIfIndex: 1, + }, + &interfaces.SwInterfaceDetails{ + SwIfIndex: 2, + }, + &interfaces.SwInterfaceDetails{ + SwIfIndex: 3, + }, + &memclnt.ControlPingReply{}, + } + + ctx.mockVpp.MockReply(reply[0 : len(reply)-1]...) + ctx.mockVpp.MockReply(reply[len(reply)-1]) + multiCtx := ctx.ch.SendMultiRequest(request[0]) + + i := 0 + for { + last, err := multiCtx.ReceiveReply(reply[i]) + Expect(err).ToNot(HaveOccurred()) + if last { + break + } + i++ + } + + traced := ctx.conn.Trace().GetRecords() + Expect(traced).ToNot(BeNil()) + Expect(traced).To(HaveLen(6)) + for _, entry := range traced { + Expect(entry.Timestamp).ToNot(BeNil()) + Expect(entry.Message.GetMessageName()).ToNot(Equal("")) + if strings.HasSuffix(entry.Message.GetMessageName(), "_reply") || + strings.HasSuffix(entry.Message.GetMessageName(), "_details") { + Expect(entry.IsReceived).To(BeTrue()) + } else { + Expect(entry.IsReceived).To(BeFalse()) + } + // FIXME: the way mock adapter works now prevents having the exact same order for each execution + /*if i == 0 { + Expect(request[0].GetMessageName()).To(Equal(entry.Message.GetMessageName())) + } else if i == len(traced)-1 { + msg := memclnt.ControlPing{} + Expect(msg.GetMessageName()).To(Equal(entry.Message.GetMessageName())) + } else { + Expect(reply[i-1].GetMessageName()).To(Equal(entry.Message.GetMessageName())) + }*/ + } +} + +func TestTraceDisabled(t *testing.T) { + t.Skipf("these randomly fail, see integration tests") + + ctx := setupTest(t, false) + defer ctx.teardownTest() + + ctx.conn.Trace().Enable(false) + + request := []api.Message{ + &interfaces.CreateLoopback{}, + &memif.MemifCreate{}, + &l2.BridgeDomainAddDel{}, + &ip.IPTableAddDel{}, + } + reply := []api.Message{ + &interfaces.CreateLoopbackReply{}, + &memif.MemifCreateReply{}, + &l2.BridgeDomainAddDelReply{}, + &ip.IPTableAddDelReply{}, + } + + for i := 0; i < len(request); i++ { + ctx.mockVpp.MockReply(reply[i]) + err := ctx.ch.SendRequest(request[i]).ReceiveReply(reply[i]) + Expect(err).To(BeNil()) + } + + traced := ctx.conn.Trace().GetRecords() + Expect(traced).To(BeNil()) +} + +func TestTracePerChannel(t *testing.T) { + t.Skipf("these randomly fail, see integration tests") + + ctx := setupTest(t, false) + defer ctx.teardownTest() + + ctx.conn.Trace().Enable(true) + + ch1 := ctx.ch + ch2, err := ctx.conn.NewAPIChannel() + Expect(err).ToNot(HaveOccurred()) + + requestCh1 := []api.Message{ + &interfaces.CreateLoopback{}, + &memif.MemifCreate{}, + &l2.BridgeDomainAddDel{}, + } + replyCh1 := []api.Message{ + &interfaces.CreateLoopbackReply{}, + &memif.MemifCreateReply{}, + &l2.BridgeDomainAddDelReply{}, + } + requestCh2 := []api.Message{ + &ip.IPTableAddDel{}, + } + replyCh2 := []api.Message{ + &ip.IPTableAddDelReply{}, + } + + for i := 0; i < len(requestCh1); i++ { + ctx.mockVpp.MockReply(replyCh1[i]) + err := ch1.SendRequest(requestCh1[i]).ReceiveReply(replyCh1[i]) + Expect(err).To(BeNil()) + } + for i := 0; i < len(requestCh2); i++ { + ctx.mockVpp.MockReply(replyCh2[i]) + err := ch2.SendRequest(requestCh2[i]).ReceiveReply(replyCh2[i]) + Expect(err).To(BeNil()) + } + + trace := ctx.conn.Trace().GetRecords() + Expect(trace).ToNot(BeNil()) + Expect(trace).To(HaveLen(8)) + + // per channel + channel1, ok := ch1.(*core.Channel) + Expect(ok).To(BeTrue()) + channel2, ok := ch2.(*core.Channel) + Expect(ok).To(BeTrue()) + + tracedCh1 := ctx.conn.Trace().GetRecordsForChannel(channel1.GetID()) + Expect(tracedCh1).ToNot(BeNil()) + Expect(tracedCh1).To(HaveLen(6)) + for i, entry := range tracedCh1 { + Expect(entry.Timestamp).ToNot(BeNil()) + Expect(entry.Message.GetMessageName()).ToNot(Equal("")) + if strings.HasSuffix(entry.Message.GetMessageName(), "_reply") || + strings.HasSuffix(entry.Message.GetMessageName(), "_details") { + Expect(entry.IsReceived).To(BeTrue()) + } else { + Expect(entry.IsReceived).To(BeFalse()) + } + if i%2 == 0 { + Expect(requestCh1[i/2].GetMessageName()).To(Equal(entry.Message.GetMessageName())) + } else { + Expect(replyCh1[i/2].GetMessageName()).To(Equal(entry.Message.GetMessageName())) + } + } + + tracedCh2 := ctx.conn.Trace().GetRecordsForChannel(channel2.GetID()) + Expect(tracedCh2).ToNot(BeNil()) + Expect(tracedCh2).To(HaveLen(2)) + for i, entry := range tracedCh2 { + Expect(entry.Timestamp).ToNot(BeNil()) + Expect(entry.Message.GetMessageName()).ToNot(Equal("")) + if strings.HasSuffix(entry.Message.GetMessageName(), "_reply") || + strings.HasSuffix(entry.Message.GetMessageName(), "_details") { + Expect(entry.IsReceived).To(BeTrue()) + } else { + Expect(entry.IsReceived).To(BeFalse()) + } + if i%2 == 0 { + Expect(requestCh2[i/2].GetMessageName()).To(Equal(entry.Message.GetMessageName())) + } else { + Expect(replyCh2[i/2].GetMessageName()).To(Equal(entry.Message.GetMessageName())) + } + } +} + +func TestTraceClear(t *testing.T) { + t.Skipf("these randomly fail, see integration tests") + + ctx := setupTest(t, false) + defer ctx.teardownTest() + + ctx.conn.Trace().Enable(true) + + request := []api.Message{ + &interfaces.CreateLoopback{}, + &memif.MemifCreate{}, + } + reply := []api.Message{ + &interfaces.CreateLoopbackReply{}, + &memif.MemifCreateReply{}, + } + + for i := 0; i < len(request); i++ { + ctx.mockVpp.MockReply(reply[i]) + err := ctx.ch.SendRequest(request[i]).ReceiveReply(reply[i]) + Expect(err).To(BeNil()) + } + + traced := ctx.conn.Trace().GetRecords() + Expect(traced).ToNot(BeNil()) + Expect(traced).To(HaveLen(4)) + + ctx.conn.Trace().Clear() + traced = ctx.conn.Trace().GetRecords() + Expect(traced).To(BeNil()) + Expect(traced).To(BeEmpty()) +} diff --git a/docs/GENERATOR.md b/docs/GENERATOR.md new file mode 100644 index 00000000..694c22ae --- /dev/null +++ b/docs/GENERATOR.md @@ -0,0 +1,89 @@ +# Generator + +This document contains information about GoVPP generator which is used for generating Go bindings for VPP binary API. + +## Installation + +### Prerequisites + +- Go 1.18+ ([download](https://golang.org/dl)) + +### Install via Go toolchain + +```shell +# Latest version (most recent tag) +go install github.com/alkiranet/govpp/cmd/binapi-generator@latest + +# Development version (master branch) +go install github.com/alkiranet/govpp/cmd/binapi-generator@master +``` + +### Install from source + +```sh +# Clone repository +git clone https://github.com/FDio/govpp +cd govpp + +# Install binapi-generator +make install-generator +``` + +### Generating binapi + +### Install vpp binary artifacts + +Build locally, or download from packagecloud. Read more: https://fd.io/docs/vpp/master/gettingstarted/installing + +### Generate binapi (Go bindings) + +Generating Go bindings for VPP binary API from the JSON files +installed with the vpp binary artifacts - located in `/usr/share/vpp/api/`. + +```sh +make generate-binapi +INFO[0000] found 110 files in API dir "/usr/share/vpp/api" +INFO[0000] Generating 203 files +``` + +The generated files will be generated under `binapi` directory. + +### Generate VPP binary API code (Go bindings) + +Once you have `binapi-generator` installed, you can use it to generate Go bindings for VPP binary API +using VPP APIs in JSON format. The JSON input can be specified as a single file (`input-file` argument), or +as a directory that will be scanned for all `.json` files (`input-dir`). The generated Go bindings will +be placed into `output-dir` (by default current working directory), where each Go package will be placed into +a separated directory, e.g.: + +```sh +binapi-generator --input-file=acl.api.json --output-dir=binapi +binapi-generator --input-dir=/usr/share/vpp/api/core --output-dir=binapi +``` + +In Go, [go generate](https://blog.golang.org/generate) tool can be leveraged to ease the code generation +process. It allows specifying generator instructions in any one of the regular (non-generated) `.go` files +that are dependent on generated code using special comments: + +```go +//go:generate binapi-generator --input-dir=bin_api --output-dir=bin_api +``` + +### Tracking down generated go code for a specific binary API + +Golang uses capitalization to indicate exported names, so you'll have +to divide through by binapi-generator transformations. Example: + +``` +define create_loopback -> type CreateLoopback struct ... + vpp binapi definition govpp exported type definition +``` +The droids you're looking for will be in a file named +.ba.go. Suggest: + +``` +find git.fd.io/govpp/binapi -name "*.ba.go" | xargs grep -n GoTypeName +``` + +Look at the indicated .ba.go file, deduce the package name +and import it. See the example above. diff --git a/docs/GOVPP_CLI.md b/docs/GOVPP_CLI.md new file mode 100644 index 00000000..eb76f711 --- /dev/null +++ b/docs/GOVPP_CLI.md @@ -0,0 +1,176 @@ +# GoVPP CLI + +This document provides guide for the GoVPP CLI app. + +--- + +## Installation + +To install GoVPP CLI it is currently required to have Go installed on your system. + +#### Prerequisites + +- **Go** 1.19+ ([installation](https://go.dev/doc/install)) + +### Install with Go + +To install from the latest GoVPP release, run: + +```shell +go install github.com/alkiranet/govpp/cmd/govpp@latest +``` + +To install the most recent development version, run: + +```shell +go install github.com/alkiranet/govpp/cmd/govpp@master +``` + +## Getting Started + +The GoVPP CLI is a powerful tool for managing your VPP API development, maintenance and integration. With features such as VPP API schema export, comparison, linting, breaking change detector, Go code bindings generation and running a proxy or HTTP service for the VPP API, the GoVPP CLI offers a comprehensive solution for the VPP API management. The GoVPP CLI is designed to integrate seamlessly with your existing workflow, so you can focus on what matters most: write _great VPP APIs_ and develop control-plane apps to use them. Whether you are working with a small, focused project or a large, complex system, the GoVPP CLI is the perfect choice. In the next few minutes, you will learn how to use the GoVPP CLI to easily execute VPP CLI commands, generate code, compare schemas, and serve VPP API as an HTTP service. + +> **Note** +> We will assume that you have already installed the GoVPP CLI and the necessary dependencies in your `$PATH`. If you haven't, head on over to our installation guide first. + +By the end of this Getting Started guide, you will have a strong understanding of the core components of the GoVPP CLI, including: + +- Methods for selecting input source of VPP API +- Browse VPP API schema definition and show its contents +- Run linter check and export VPP API schema +- Compare multiple VPP API schemas and detect breaking changes +- Code generation of Go bindings for VPP API + +## Before you begin + +Let's check the version of GoVPP CLI you'll be using is up-to-date. + +```sh +govpp --version +``` + +This will print the version of GoVPP CLI. + +## Usage + +The `govpp` command will print the usage help for the top-level commands and their subcommands by default. + +``` + ______ _ _ _____ _____ govpp v0.8.0 + | ____ _____ \ / |_____] |_____] user@machine (go1.20 linux/amd64) + |_____| [_____] \/ | | Mon Jul 3 12:13:24 CEST 2023 + +Usage: + govpp [command] + +Available Commands: + cli Send CLI via VPP API + generate Generate code + help Help about any command + http VPP API as HTTP service + vppapi Manage VPP API + +Flags: + -D, --debug Enable debug mode + -L, --loglevel string Set logging level + --color string Color mode; auto/always/never + --version version for govpp + +Use "govpp [command] --help" for more information about a command. +``` + +### Show VPP API contents + +The `vppapi ls` command allows you to print the VPP API files and their specific contents +in various formats. This can be useful for debugging or for generating documentation. + +Here's an example usage of the `vppapi ls` command: + +```sh +# List VPP API files for default input +govpp vppapi ls +``` + +You can use the `--input` flag to specify the input source for the VPP API files. + +```sh +# Use current directory as input source (local VPP repository) +govpp vppapi ls . +``` + +The default format prints the output data in a table, but you can also specify +other output formats such as JSON, YAML or Go template using the `--format` flag. + +```sh +# Print using common formats +govpp vppapi ls --format="json" +govpp vppapi ls --format="yaml" + +# Print using a Go template +govpp vppapi ls --format='{{ printf "%+v" . }}' +``` + +You can use the `--show-contents`, `--show-messages`, `--show-raw`, and `--show-rpc` +flags to show specific parts of the VPP API file(s). + +```sh +# List VPP API contents +govpp vppapi ls --show-contents + +# List VPP API messages +govpp vppapi ls --show-message + +# List RPC services +govpp vppapi ls --show-rpc + +# Print raw VPP API files +govpp vppapi ls --show-raw +``` + +You can also use the `--include-fields` and `--include-imported` flags to include +message fields and imported types, respectively. + +For more information on the available flags and options, use the `-h` or `--help` flag. + +### Run linter for VPP API definitions + +The `lint` command allows you to run linter checks for your VPP API files. This can help you catch issues early and ensure that your code follows best practices. + +Here's an example usage of the `lint` command: + +shell +```sh +govpp vppapi lint https://github.com/FDio/vpp.git +``` + +This command runs the linter checks on the `master` branch of official VPP repository and outputs any issues found. + +You can use the `--input` flag to specify the input location for your VPP API files, such as a path to a VPP API directory or a local VPP repository. + +You can use the `--help` flag to get more information about the available flags and options. + +### Compare VPP API schemas + +The `diff` command allows you to compare two VPP API schemas and lists the differences between them. This can be useful for detecting breaking changes between different versions of the API. + +Here's an example usage of the `diff` command: + +```sh +govpp vppapi diff "./vppapi2210" --against "./vppapi2302" +``` + +This command compares the VPP API schema from `vppapi2210` directory against the VPP API schema in `vppapi2302` and lists the differences between them. The output shows related information details for each difference. + +You can use the `--help` flag to get more information about the available flags and options. + +> **Note** +> The `--against` flag is required and should point to an input source for the schema to compare against. + +## Troubleshooting + +If you run into any problems when executing some commands, you can use the `--debug` option to increase log verbosity to help when debugging the issue. +For the highest verbosity use `--log-level=trace`. + + +> **Warning** +> Be sure to open an issue on GitHub for any bug that you may encounter. diff --git a/docs/RELEASE.md b/docs/RELEASE.md new file mode 100644 index 00000000..8bc7efcf --- /dev/null +++ b/docs/RELEASE.md @@ -0,0 +1,36 @@ +# Release + +This document desribes the GoVPP releases. + +## Versioning + +The GoVPP uses the [Semantic Versioning](https://semver.org/) for the release versions. + +The current MAJOR version of GoVPP is `0`, meaning it's still under development that might occasionally do larger breaking changes. However, we try to avoid this if possible to minimize the user impact. + +## Release Cycle + +The MINOR releases of GoVPP should be released **approximately 2 weeks after a VPP release** at minimum. Any additional MINOR releases for GoVPP can possibly happen between VPP releases if needed. + +The PATCH releases should be released whenever it is required to publish a fix to users. + +## Release Tracking + +Each release has its own [milestone](https://docs.github.com/en/issues/using-labels-and-milestones-to-track-work/about-milestones) created with a due date of the expected release date. List of milestones can be found here: https://github.com/FDio/govpp/milestones + +Every issue/PR that shoukd be part of a specific release should have milestone set. + +## Release Process + +1. Verify the state of `master` branch for the release: + - Check if all issues/PRs that are part of the release milestone are closed + - Check if the generated `binapi` is compatible with the lastest VPP release +2. Prepare the release in a PR with the following changes: + - Update [CHANGELOG.md](https://github.com/FDio/govpp/blob/master/CHANGELOG.md) with the list of changes for new version + - Update version in [version](https://github.com/FDio/govpp/blob/master/version/version.go) package to `v0.X.0` without any suffix (remove `-dev`) +3. Once PR merges to master, tag it with `v0.X.0` using annotated, signed tag & push the tag to repository + ```sh + git tag --sign --annotate --message "govpp v0.X.0" v0.X.0 + ``` +6. After the release tag is pushed, begin development of the next release using the following steps: + - Update version in [version](https://github.com/FDio/govpp/blob/master/version/version.go) package to `v0.X+1.0-dev` diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md new file mode 100644 index 00000000..fadf1262 --- /dev/null +++ b/docs/TROUBLESHOOTING.md @@ -0,0 +1,318 @@ +# Troubleshooting Guide + +This document provides guidance for troubleshooting issues or any debugging for GoVPP. + +--- + +**Table of contents** + +* [Debug Logging](#debug-logging) + + [Enable Debug](#enable-debug) + + [Debug Components](#debug-components) + - [Debug Message IDs](#debug-message-ids) + - [Debug Socket Client](#debug-socket-client) + - [Debug Binapi Generator](#debug-binapi-generator) + - [Debug Stats Client](#debug-stats-client) + - [Debug Proxy](#debug-proxy) +* [Connection Problems](#connection-problems) + + [Socket file does not exist](#socket-file-does-not-exist) + + [Connection refused](#connection-refused) + + [Permission denied](#permission-denied) + + [The socket is not ready](#the-socket-is-not-ready) +* [Problems with sending/receiving messages](#problems-with-sendingreceiving-messages) + + [Unknown message error](#unknown-message-error) + + [VPP not replying to some messages](#vpp-not-replying-to-some-messages) +* [Message versioning](#message-versioning) + + [Deprecated messages](#deprecated-messages) + + [In-progress messages](#in-progress-messages) + +--- + +## Debug Logging + +This section describes ways to enable debug logs for GoVPP and its components. +Most of the debug logs is controlled via the environment variable `DEBUG_GOVPP`. + +### Enable Debug + +To enable debug logs for GoVPP core, set the environment variable `DEBUG_GOVPP` to a **non-empty value**. + +```sh +DEBUG_GOVPP=y ./app +``` + +The following line will be printed to _stderr_ output during program initialization: + +``` +DEBU[0000] govpp: debug level enabled +``` + +### Debug Components + +The environment variable `DEBUG_GOVPP` can be used also to enable debug logs for other GoVPP components separately. + +> **Note** +> Multiple components can be enabled silmutaneously, by separating values with comma, e.g. `DEBUG_GOVPP=socketclient,msgtable` + +#### Debug Message IDs + +To enable debugging of message IDs, set `DEBUG_GOVPP=msgid`. + +*log output sample:* +``` +DEBU[0000] message "show_version" (show_version_51077d14) has ID: 1380 +``` + +#### Debug Socket Client + +To debug `socketclient` package, set `DEBUG_GOVPP=socketclient`. + +*log output sample:* +``` +DEBU[0000] govpp: debug level enabled for socketclient +``` + +Additionally, to debug the message table retrieved upon connecting to socket, set `DEBUG_GOVPP=socketclient,msgtable`. + +*log output sample:* +``` +DEBU[0000] - 1380: "show_version_51077d14" logger=govpp/socketclient +``` + +#### Debug Binapi Generator + +To enable the basic debug logs in the binapi generator, pass the flag `-debug` to the program. + +Additionaly, to enable debug logs for the _parser_, assign value `DEBUG_GOVPP=parser` and +to enable debug logs for the _generator_, set `DEBUG_GOVPP=binapigen`. + +Examples: +```bash +# Enable debug logs +./bin/binapi-generator -debug + +# Maximum verbosity +DEBUG_GOVPP=parser,binapigen ./binapi-generator +``` + +#### Debug Stats Client + +To enable debug logs for `statsclient` package, set `DEBUG_GOVPP_STATS` to a non-empty value. + +```sh +DEBUG_GOVPP_STATS=y ./stats-client +``` + +To verify that it works, check for the following line in the console output: +``` +DEBU[0000] govpp/statsclient: enabled debug mode +``` + +#### Debug Proxy + +To enable debug logs for `proxy` package, set `DEBUG_GOVPP_PROXY` to a non-empty value. + +```sh +DEBUG_GOVPP_PROXY=y ./vpp-proxy server +``` + +To verify that it works, check for the following line in the console output: + +``` +DEBU[0000] govpp/proxy: debug mode enabled +``` + +## Connection Problems + +This section describes various problems when GoVPP tries to connect to VPP. + +### Socket file does not exist + +**Symptoms**: You see the following error: + +``` +ERROR: connecting to VPP failed: VPP API socket file /run/vpp/api.sock does not exist +``` + +**Probable cause**: VPP is not running or it is configured to have the socket at non-default path. + +**Possible solutions**: + +- Check if the VPP is running. It may have exited unexpectedly. + +- Run the VPP with `sudo`. It may need root permissions to create the socket. + +- Configure the socket path in VPP configuration. Find the file `startup.conf` (default location: `/etc/vpp/startup.conf`) or create it if it does not exist and add there the following: + ``` + socksvr { + socket-name /path/to/api.sock + } + ``` + (change the path to the actual path, the default is `/run/vpp/api.sock`). Then run the VPP with the `-c` flag and specify the path to the configuration file. For example, with default locations: `/usr/bin/vpp -c /etc/vpp/startup.conf`. + + - If you built VPP from source, you can apply the configuration using `make` with `STARTUP_CONF` environment variable. For example: `STARTUP_CONF=/etc/vpp/startup.conf make run`. + + - If VPP outputs a line similar to this: `clib_socket_init: bind (fd 9, '/home/user/vpp/api.sock'): No such file or directory`, it likely means that the directory for the socket does not exist. If this happens, create the directory manually and restart VPP. + +- In GoVPP code that connects to the VPP, use the actual socket path configured by VPP: + ```go + govpp.Connect("/path/to/api.sock") + ``` + (change the path to the actual path). + + - In GoVPP examples, you can usually set the path with the flag `-socket` or similar (use `--help` to see the actual flag). For example: `./bin/rpc-service -sock /run/vpp/api.sock`. + +- If you are running VPP inside Docker container, mount the socket directory as a Docker volume so it can be used from the host. If you use configuration file, also mount the file. For example: `docker run -it -v /run/vpp:/run/vpp -v /home/user/vpp/startup.conf:/etc/vpp/startup.conf ligato/vpp-base:22.10` + +- Increase the number of connection retries or timeout. See the subsection *The socket is not ready*. + +### Connection refused + +**Symptoms**: You see the following error: + +``` +ERROR: connecting to VPP failed: dial unix /run/vpp/api.sock: connect: connection refused +``` + +**Probable cause**: VPP exited or its configuration changed and you are trying to connect to the now obsolete socket. + +**Possible solutions**: See the solutions in the previous subsection. + +### Permission denied + +**Symptoms**: You see the following error: + +``` +ERROR: connecting to VPP failed: dial unix /run/vpp/api.sock: connect: permission denied +``` + +**Probable cause**: The socket is owned by the `root` group. + +**Possible solutions**: + +- Configure the VPP to create the socket as current user's group. Add the following to the file `startup.conf`: + ``` + unix { + gid + } + ``` + (replace the `` with actual group ID; you can see the ID with `id -g`). + + - If you are running VPP inside Docker container, run the container as current user's group (but keep the user as root), for example `docker run -it -v /run/vpp:/run/vpp -u 0:$(id -g) ligato/vpp-base:22.10`. In this case, do NOT use the `unix { gid ... }` in `startup.conf`. +- Run GoVPP with `sudo`. + +- Manually change permissions or ownership of the socket file. + +### The socket is not ready + +**Example scenario**: User has built a Docker image with a VPP and a custom binary that uses GoVPP. When he runs it, the GoVPP binary starts up instantly, but it takes a long time for the VPP to apply initial configuration and start up. The GoVPP binary tries to connect before the VPP is ready, so it fails to connect and exits. When the user inspects it, he finds out that the VPP is running and the GoVPP binary is not, and may mistakenly think that the GoVPP binary is faulty. But actually the VPP was just not ready in time. + +**Possible solutions**: +- Increase the number of connection retries (the second argument, `attempts`, of the `govpp.AsyncConnect` function). +- Increase the interval between reconnects (the third argument, `interval`, of the `govpp.AsyncConnect` function). +- Increase the timeout for waiting for the socket existence (variable `MaxWaitReady` in the file `adapter/socketclient/socketclient.go`). + +> **Note** +> The solutions apply only if you use the function `govpp.AsyncConnect`. If you instead use the function `govpp.Connect`, then GoVPP tries to connect immediately and only once, and if the socket does not exist, it immediately throws error. In this case, you have to ensure that the socket is ready before starting GoVPP. + +## Problems with sending/receiving messages + +### Unknown message error + +**Symptoms**: When you try to send/receive a message, you see `unknown message: ...` error. + +**Cause**: Incompatibility of messages between VPP binary API and GoVPP's generated Go bindings for binary API (binapi). + +**Solution 1**: Regenerate binapi. Use make target `generate-binapi` (for VPP installed via package manager) or `gen-binapi-local` (for locally built VPP) or `gen-binapi-docker` (independent of local VPP). For more information about the generator, see [the generator documentation](GENERATOR.md). After generating binapi, rebuild GoVPP. + +**Solution 2**: Use VPP version that is compatible with GoVPP's binapi. To see for which VPP version the binapi was generated, look at the beginning of any `.ba.go` file (not `_rpc.ba.go`). + +### VPP not replying to some messages + +If VPP is not replying to a message, it is likely because one of the following reasons: +- The VPP has frozen or crashed. +- The VPP correctly processed the request and possibly applied the requested configuration (you may see the configured items in the VPP), but it did not send reply. This could be either because of a bug in VPP or because the message contains some illegal/unusual combination of parameters that VPP can not handle properly. + +To solve it, you can try the following: +- Check if the VPP is frozen or crashed. +- Try sending the message with different values. + +## Message versioning + +When a GoVPP's message is updated, the message itself is not changed. Instead, a new version of the message is added that has a `v2` (or `v3`, `v4`, ...) suffix to its name. The old version of the message is then marked as deprecated. + +### Deprecated messages + +If a message is marked as deprecated, it should no longer be used. The message works fine for now, but it may be removed in the future. When a message is deprecated, there is likely available a new version of the message or an another message with a similar behaviour which should be used instead. Also, if some message is not deprecated, but there already exists a new version of the message, the new version should be used, as the older version may soon become deprecated. + +For example, here is an excerpt from the file `binapi/vhost_user/vhost_user.ba.go` (as of 31-Oct-2022): + +```go +// CreateVhostUserIf defines message 'create_vhost_user_if'. +// Deprecated: the message will be removed in the future versions +type CreateVhostUserIf struct { + // ... +} + +// ... + +// CreateVhostUserIfReply defines message 'create_vhost_user_if_reply'. +// Deprecated: the message will be removed in the future versions +type CreateVhostUserIfReply struct { + // ... +} + +// ... + +// CreateVhostUserIfV2 defines message 'create_vhost_user_if_v2'. +type CreateVhostUserIfV2 struct { + // ... +} + +// ... + +// CreateVhostUserIfV2Reply defines message 'create_vhost_user_if_v2_reply'. +type CreateVhostUserIfV2Reply struct { + // ... +} +``` + +The messages `CreateVhostUserIf` and `CreateVhostUserIfReply` are deprecated and should not be used. Instead, there are new versions of the messages: `CreateVhostUserIfV2` and `CreateVhostUserIfV2Reply`, which should be used. + +### In-progress messages + +When a new message is added, usually it is initially experimental and is marked as in-progress. In this case, an older message should be preferrably used. Later, when the message will be considered stable, the in-progress label will be removed, the message will become recommended to use and the old message may become deprecated. + +For example, here is an excerpt from the file `binapi/ip/ip.ba.go` (as of 31-Oct-2022): + +```go +// IPRouteAddDel defines message 'ip_route_add_del'. +type IPRouteAddDel struct { + // ... +} + +// ... + +// IPRouteAddDelReply defines message 'ip_route_add_del_reply'. +type IPRouteAddDelReply struct { + // ... +} + +// ... + +// IPRouteAddDelV2 defines message 'ip_route_add_del_v2'. +// InProgress: the message form may change in the future versions +type IPRouteAddDelV2 struct { + // ... +} + +// ... + +// IPRouteAddDelV2Reply defines message 'ip_route_add_del_v2_reply'. +// InProgress: the message form may change in the future versions +type IPRouteAddDelV2Reply struct { + // ... +} +``` + +In this case, the messages `IPRouteAddDel` and `IPRouteAddDelReply` should be used; the messages `IPRouteAddDelV2` and `IPRouteAddDelV2Reply` are in-progress. diff --git a/docs/USER_GUIDE.md b/docs/USER_GUIDE.md new file mode 100644 index 00000000..793dd8f9 --- /dev/null +++ b/docs/USER_GUIDE.md @@ -0,0 +1,589 @@ +# GoVPP User Guide + +This section contains reference documentation for working with GoVPP, generating VPP binary API bindings, calling VPP API, retrieving VPP Stats data and other GoVPP features. + +--- + +**Table of Contents** + +* [Binary API Generator](#binary-api-generator) + * [Installation](#installation) + * [Using Generator](#using-generator) + * [Generator Plugins](#generator-plugins) +* [VPP API calls](#vpp-api-calls) + * [Connection](#connection) + * [Synchronous](#synchronous-connect) + * [Asynchronous](#asynchronous-connect) + * [Sending API messages](#sending-api-messages) + * [Channel](#channel) + * [Stream client](#stream-client) +* [The HTTP service](#http-service) +* [The RPC service](#rpc-client) +* [VPP stats](#vpp-stats) + * [Low-level API connection](#low-level-stats-api-connection) + * [Low-level API usage](#low-level-stats-api-usage) + +## Binary API Generator + +The binary API generator's purpose is to generate Go code bindings for the VPP API. It uses VPP API definitions from `*.api.json` files as source and generates a Go package for each VPP API file, where each package contains Go types for objects from the VPP API file (messages, types, enums..). + +### Installation + +#### Prerequisites + +- Go 1.18+ is required ([download](https://golang.org/dl)) + +Install binapi-generator into `$GOPATH/bin` (defaults to: `$HOME/go/bin`) using the Go toolchain: + +```sh +# Latest release +go install github.com/alkiranet/govpp/cmd/binapi-generator@latest + +# Specific version +go install github.com/alkiranet/govpp/cmd/binapi-generator@v0.7.0 + +# Development branch +go install github.com/alkiranet/govpp/cmd/binapi-generator@master +``` + +> **Note** +> Development branch might not have stable behavior. + +Print the version for the installed binapi-generator: + +```sh +$ binapi-generator -version +govpp v0.8.0-dev +``` + +### Using Generator + +#### Source of VPP API files + +To generate Go code bindings, you need to provide source of VPP API files in JSON format (`*.api.json`). There are several ways to get it: + +1. Download and install VPP from `packagecloud.io` ([learn more](https://fd.io/docs/vpp/master/gettingstarted/installing)). +2. Clone the VPP repository (`git clone https://github.com/FDio/vpp.git`) and run `make json-api-files`. + The VPP API files will be in: `./vpp/build-root/install-vpp-native/vpp/share/vpp/api/`. +3. If the VPP is already installed in your system, the default location for the VPP API files is: `/usr/share/vpp/api/` + +#### Generating Go Bindings + +If the VPP JSON API definitions are in the default directory `/usr/share/vpp/api`, call: + +```sh +binapi-generator --input "/usr/share/vpp/api" +``` + +Generated Go code bindings will be under `./binapi` directory. + +> **Note** +> The Go package path of generated files will be resolved automatically from the module path in `go.mod` file. +> To set the Go package path manually, use option `--import-prefix=PREFIX`. + +If you have a Go project (called `myproject` in `$HOME/myproject/vppbinapi`) with GoVPP as a dependency with both, the +binary API generator and the VPP connection client, generated bindings are required to be inside the project (for +example in `$HOME/myproject/vppbinapi`) + +To modify the VPP API input directory, use `-input-dir` option. To modify the output directory, use +the `-output` option. + +```sh +binapi-generator --input-dir="/path/to/vpp/api" --output-dir="/path/to/generated/bindings" +``` + +This option might require setting the correct`--import-prefix` as well. + +#### Options + +The list of binapi-generator optional arguments in form `binapi-generator [OPTIONS] ARGS` + +- `binapi-generator -version` prints the generator version, for example, `govpp v0.8.0-dev` +- `binapi-generator -gen=http` injects the `http` plugin to generate additional files. + More plugins are separated with comma, i.e. `-gen-http,rpc`. Note that `rpc` plugin is used by default +- `binapi-generator -import-prefix=/desired/prefix/path` sets the go package name to be used in the generated bindings ( + the string used in imports) +- `binapi-generator -input-dir=/vpp/api/input/dir` sets the custom input directory instead of the default +- `binapi-generator -output-dir=/bin/api/output/dir` sets the custom output directory. It may or may not match + the `-import-prefx`, based on go.mod. +- `binapi-generator -debug` prints some additional logs + +### Generator Plugins + +The binary API generator supports extending its functionality with plugins that can generate additional files. + +Available built-in plugins: + +- `http` generates HTTP handlers (more information in the [HTTP service part](#http-service)) +- `rpc` generates RPC services (more information in the [RPC service part](#rpc-client)) + +## VPP Startup + +Define the minimal `startup.conf`: + +```sh +unix {interactive} +socksvr { socket-name /var/run/vpp/api.sock } +``` + +Start with `startup.conf` if the VPP was installed from sources: + +```sh +/build-root/install-vpp_debug-native/vpp/bin/vpp -c /tmp/startup.conf +``` + +If it was installed from the package: + +```sh +vpp -c /tmp/startup.conf +``` + +## VPP API calls + +GoVPP client uses its own (pure Go) implementation to handle the low-level parts of the VPP API communication. + +### Connection + +Two connection types to the binary API socket are exist - synchronous and asynchronous. GoVPP can connect to more VPPs +by creating multiple connections (see the [multi-vpp example](../examples/multi-vpp/README.md)) + +#### Synchronous Connect + +The synchronous connecting creates a new adapter instance. The call blocks until the connection is established. + +```go +conn, err := govpp.Connect(socketPath) +if err != nil { + // handle the error +} +defer conn.Disconnect() +``` + +#### Asynchronous Connect + +The main difference between the synchronous and asynchronous connection is that the asynchronous connection does not +block until the connection is ready. Instead, the caller receives a channel to watch connection events. Asynchronous +connection defines additional parameters `attemptNum` and `interval` defining the number of reconnecting attempts, and +an interval (in seconds) between those attempts. + +```go +conn, connEv, err := govpp.AsyncConnect(socketPath, attemptNum, interval) +if err != nil { + // handle error +} +defer conn.Disconnect() + +// wait for the connection event +e := <-connEv +if e.State != core.Connected { + // handle error in e.Error +} +``` + +### Sending API messages + +Each binary API message in the Go-generated API is a data structure. The caller can send API messages either using +a `Channel` (legacy method) or a `Stream`. +In-depth discussion about differences between `Channel` and `Stream` can be found https://github.com/FDio/govpp/discussions/43. + +Messages can be requests, replies or events. The request might expect just one response (request), or more than one +response (multirequest). It is possible to determine the message type out of its name. + +> **Note** +> The naming might not be consistent across the VPP API. + +* *_Requests_* have no special suffix for the request, or `Dump` or `Get` for the multirequest. +* *_Responses_* have a `Reply` suffix for the request or `Details` for multirequest. + +#### Stream client + +The `Stream` is the new and preferred way to call VPP API. It provides a "low-level" API to allow complete control of +the communication process. This means that it requires the caller to handle all aspects of VPP API semantics, e.g. send +control ping after dump request, check the message type and value of `Retval` field in responses. + +*_Note: handling of the VPP API semantics mentioned above is only required when using `Stream` directly. Users should +use generated RPC clients which handle all of this automatically._* + +New `Stream` can be created by calling `Connection`'s method `NewStream`: + +```go +stream, err := conn.NewStream(context.Background(), options...) +if err != nil { + // handle error +} +``` + +The `NewStream` method also accepts following options: + +* `WithRequestSize(size int)` sets the size of the request channel buffer +* `WithReplySize(size int)` sets the size of the reply channel buffer +* `WithReplyTimeout(timeout time.Duration)` sets the reply timeout + +The single request procedure requires the user to convert the generic reply (the `Message` interface type) to the proper +reply type. + +```go +req := &interfaces.CreateLoopback{ + // fill with data +} +if err := stream.SendMsg(req); err != nil { + // handle error +} +replyMsg, err := stream.RecvMsg() +if err != nil { + // handle error +} +reply := replyMsg.(*interfaces.CreateLoopbackReply) +``` + +The simpler way is to use the `Invoke()` method, which does the same procedure as above. + +```go +req := &interfaces.CreateLoopback{ + // fill with data +} +var reply interfaces.CreateLoopbackReply +err := c.conn.Invoke(context.Background(), req, &reply) +if err != nil { + // handle error +} +``` + +The multirequest message must be followed up by the control ping request. The loop collecting replies must watch for the +control ping reply signalizing the end. + +```go + if err := stream.SendMsg(&interfaces.SwInterfaceDump{}); err != nil { + // handle error + } + if err := stream.SendMsg(&memclnt.ControlPing{}); err != nil { + // handle error + } + +Loop: + for { + reply, err := stream.RecvMsg() + if err != nil { + // handle error + } + switch reply.(type) { + case *interfaces.SwInterfaceDetails: + // handle the message + case *memclnt.ControlPingReply: + break Loop + default: + // unexpected message type + } + } +``` + +There is another type of the multirequest, and this one needs to be handled differently. It can be easily identified +with the `Get` suffix and the **cursor** parameter. This type of multirequest is read in batches. Each batch has a +number of data replies, and if the reader should continue with another batch, the cursor points to the next index. + +The user has to expect two reply types, the `Details` containing the data, and the `Reply` marking the end of the batch, +and the new cursor value. + +The initial batch always starts with zero. + +```go +cursor uint32 = 0 +for { + if cursor == ^uint32(0) { // cursor pointing to this value marks the end of the multirequest + return + } + if err := stream.SendMsg(&pnat.PnatBindingsGet{ + Cursor: cursor, + }); err != nil { + // handle error + } + // new batch loop + for { + msg, err := stream.RecvMsg() + if err != nil { + // handle error + } + switch reply := msg.(type) { + case *pnat.PnatBindingsDetails: + // handle the data + case *pnat.PnatBindingsGetReply: + cursor = reply.Cursor // the new cursor value + // handle error + break + default: + // unexpected reply type + } + } +} +``` + +#### Channel + +> **Warning** +> The Channel are planned to be deprecated in the future. + +The `Channel` is the main communication unit between the caller and the VPP. After the successful connection, the +channel is simply created from the connection object. + +```go +ch, err := conn.NewAPIChannel() +if err != nil { + // handle error +} +``` + +The new channel starts watching caller requests immediately. + +The channel can do a compatibility check for all the messages from any generated VPP API file. + +```go +if err := ch.CheckCompatiblity(vpe.AllMessages()...); err != nil { + // handle error +} +``` + +A single request is done by calling the asynchronous request/reply on a channel. The request returns the request context +allowing to receive the reply. + +```go +req := &interfaces.CreateLoopback{} // fill with data +reply := &interfaces.CreateLoopbackReply{} +if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { + // handler error +} +``` + +The multirequest expects more than one response. Its context contains information about the last item in the request +list. + +```go +req := &interfaces.SwInterfaceDump{} // fill with data +reqCtx := ch.SendMultiRequest(req) +for { + reply := &interfaces.SwInterfaceDetails{} + stop, err := reqCtx.ReceiveReply(reply) + if err != nil { + // handle error + } + if stop { + break + } + // handle the reply before the next iteration +} +``` + +> **Note** +> The multirequest message suffixed with `Get` needs a different type of handling using the stream client. + +## HTTP Service + +Before using the HTTP service, the VPP binary API binding must be generated with the `http` plugin to create HTTP files, +and the `rpc` plugin to create RPC files. RPC is used inside HTTP handler functions. + +Create the new HTTP handler and listener (requires the connection instance, and the RPC service client) + +```go +vpeRpcClient := vpe.NewServiceClient(conn) +vpeHttpClient := vpe.HTTPHandler(vpeRpcClient) +if err := http.ListenAndServe(":8000", vpeHttpClient); err != nil { + // handle error +} +``` + +With the http server running, you can use `curl` command to call VPP API via HTTP request: + +```sh +$ curl http://localhost:8000/show_version +{ + "program": "vpe", + "version": "23.06-rc0~71-g182d2b466", + "build_date": "2023-02-20T07:52:13", + "build_directory": "/home/go/src/git.fd.io/vpp" +} +``` + +## RPC Client + +The RPC client is a generated client implementation by generator plugin `rpc` in separate file named `*.rpc.ba` for each +generated file (package) of the VPP binary API. + +Each generated VPP binary API file (package) contains RPC service interface `RPCService` and RPC client `serviceClient` +that implements the RPC service interface. For each service RPC method defined in VPP API file, the RPC service +interface defines a method and the RPC client implements it according to the service definition of the VPP binary API +file. + +To create the new RPC service client, use function `NewServiceClient(conn api.Connection)`, which accepts the connection +instance. + +```go +nat64RpcClient := nat64.NewServiceClient(conn) +vpeRpcClient := vpe.NewServiceClient(conn) +``` + +Simple request: + +```go +c := memif.NewServiceClient(conn) +req := &memif.MemifCreate{} // fill with data +reply, err := c.MemifCreate(context.Background(), req) +if err != nil { + // handle error +} +``` + +Multirequest (the end of the multirequest is determined by checking the `EOF` error): + +```go +c := interfaces.NewServiceClient(conn) +stream, err := c.SwInterfaceDump(context.Background(), &interfaces.SwInterfaceDump{}) +if err != nil { + // handle error +} +for { + iface, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + // handle error + } +} +``` + +## VPP Stats + +The *_statsclient_* adapter connects to the VPP `stats.sock`. + +```go +statsClient = statsclient.NewStatsClient(socket, options...) +``` + +Supported options to customize the connection parameters. + +* `SetSocketRetryPeriod` - specifies a **time period between retries** +* `SetSocketRetryTimeout` - specifies a **timeout duration for retry** + +The stats connection can be done synchronously or asynchronously (as for the binary API socket). + +The synchronous connection: + +```go +statsConn, err = core.ConnectStats(statsClient) +if err != nil { + // handle error +} +defer c.Disconnect() +``` + +The asynchronous connection: + +```go +statsConn, statsChan, err = core.AsyncConnectStats(statsClient, attemptNum, interval) +if err != nil { + // handle error +} +e := <-statsChan +if e.State != core.Connected { + // handle error +} +defer statsConn.Disconnect() +``` + +The asynchronous connection comes with additional parameters `attemptNum` and `interval` defining the number of +reconnection attempts, and an interval (in seconds) between those attempts. + +The `stats` connection implements the `StatsProvider` interface and gives access to various stats getters. + +```go +systemStats := new(api.SystemStats) +if err := statsConn.GetSystemStats(systemStats); err != nil { + // handle error +} +nodeStats := new(api.NodeStats) +if err := statsConn.GetNodeStats(nodeStats); err != nil { + // handle error +} +... +``` + +### Low-level stats API connection + +The `StatsProvider` is considered the "high-level" API with easy access to VPP stats, but it might be restricted in +certain cases. Using the stats client directly is the solution. The stats client implements the `StatsAPI`, the kind of +low-level API with broader options for managing stats. + +In any case, make sure the stats client is connected. +The example above created the new stats client and used the GoVPP core method to connect, giving access to both, +the `statsClient` (low-level API) and the `statsConn` (high-level API). + +```go +statsClient = statsclient.NewStatsClient(socket, options...) +statsConn, err = core.ConnectStats(statsClient) // or core.AsyncConnectStats(statsClient, attemptNum, interval) + // handle error +} +defer statsConn.Disconnect() +``` + +If you do not need the `statsConn` instance and just use the low-level API, you must connect anyway. Either by ignoring +the instance, or calling the connect method directly. + +```go +statsClient = statsclient.NewStatsClient(socket, options...) +err = statsClient.Connect() +// handle error +} +defer statsClient.Disconnect() +``` + +### Low-level stats API usage + +List all indexed stats directories. Use patterns to filter the output. The `StatIdentifier` is a simple name to the +index value. + +```go +list, err = client.ListStats(patterns...) +if err != nil { + // handle error +} +``` + +Return values of stats directories. Use patterns to filter the output. The `StatEntry` is the combination of stat +identifier, type, data, and the symlink flag. + +```go +dump, err = client.DumpStats(patterns...) +if err != nil { + // handle error +} +``` + +Prepare the stat directory. Returns the directory instance with accessible stat entries. Use patterns or indexes as a +filter. + +```go +// pattern filter +dir, err := client.PrepareDir(patterns...) +if err != nil { + // handle error +} + +// index filter +dir, err := client.PrepareDirOnIndex(patterns...) +if err != nil { + // handle error +} +``` + +Update the previously prepared directory. Suitable for polling VPP stats. + +```go +if err := client.UpdateDir(dir); err != nil { + if err == adapter.ErrStatsDirStale { // if the directory is stale, re-load it + if dir, err = client.PrepareDir(patterns...); err != nil { + // handle error + } + continue + } + // handle error +} +``` diff --git a/docs/govpp-logo.png b/docs/govpp-logo.png new file mode 100644 index 00000000..8f98dc7f Binary files /dev/null and b/docs/govpp-logo.png differ diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 00000000..c891bef6 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,12 @@ +# Examples + +Here is a list of code examples demonstrating various GoVPP features: + +- [api-trace](examples/api-trace) - trace sent/received messages +- [binapi-types](examples/binapi-types) - using common types from generated code +- [multi-vpp](examples/multi-vpp) - connect to multiple VPP instances +- [perf-bench](examples/perf-bench) - very basic performance test for measuring throughput +- [rpc-service](examples/rpc-service) - effortless way to call VPP API via RPC client +- [simple-client](examples/simple-client) - send and receive VPP API messages using GoVPP API directly +- [stats-client](examples/stats-client) - client for retrieving VPP stats data +- [stream-client](examples/stream-client) - using new stream API to call VPP API diff --git a/examples/api-trace/README.md b/examples/api-trace/README.md new file mode 100644 index 00000000..6cb6ce88 --- /dev/null +++ b/examples/api-trace/README.md @@ -0,0 +1,17 @@ +# API trace example + +The example demonstrates how to use GoVPP API trace functionality. Connection object `core.Connection` contains +API tracer able to record API messages sent to and from VPP. + +Access to the tracer is done via `Trace()`. It allows accessing several methods to manage collected entries: +* `Enable()` either enables or disables the trace. Note that the trace is disabled by default and messages are not recorded while so. +* `GetRecords() []*api.Record` provide messages collected since the plugin was enabled or cleared. +* `GetRecordsForChannel() []*api.Record` provide messages collected on the given channel since the plugin was enabled or cleared. +* `Clear()` removes recorded messages. + +A record is represented by `Record` type. It contains information about the message, its direction, time and channel ID. Following fields are available: +* `Message api.Message` returns recorded entry as GoVPP Message. +* `Timestamp time.Time` is the message timestamp. +* `IsReceived bool` is true if the message is a reply or details message, false otherwise. +* `ChannelID uint16` is the ID of channel processing the traced message. + diff --git a/examples/api-trace/api-trace.go b/examples/api-trace/api-trace.go new file mode 100644 index 00000000..7dcb1e28 --- /dev/null +++ b/examples/api-trace/api-trace.go @@ -0,0 +1,353 @@ +// 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. +// 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. + +// api-trace is and example how to use the GoVPP API trace tool. + +package main + +import ( + "context" + "flag" + "fmt" + "log" + + "github.com/alkiranet/govpp" + "github.com/alkiranet/govpp/adapter/socketclient" + "github.com/alkiranet/govpp/api" + interfaces "github.com/alkiranet/govpp/binapi/interface" + "github.com/alkiranet/govpp/binapi/interface_types" + "github.com/alkiranet/govpp/binapi/ip_types" + "github.com/alkiranet/govpp/binapi/memclnt" + "github.com/alkiranet/govpp/binapi/vpe" + "github.com/alkiranet/govpp/core" +) + +var ( + sockAddr = flag.String("socket", socketclient.DefaultSocketName, "Path to VPP API socket file") +) + +func main() { + flag.Parse() + + fmt.Printf("Starting api-trace tool example\n\n") + + // make synchronous VPP connection + conn, err := govpp.Connect(*sockAddr) + if err != nil { + log.Fatalln("ERROR:", err) + } + defer conn.Disconnect() + + singleChannel(conn) + multiChannel(conn) + stream(conn) + + fmt.Printf("Api-trace tool example finished\n\n") +} + +func singleChannel(conn *core.Connection) { + // create new channel and perform simple compatibility check + ch, err := conn.NewAPIChannel() + if err != nil { + log.Fatalln("ERROR: creating channel failed:", err) + } + defer ch.Close() + + fmt.Printf("=> Example 1\n\nEnabling API trace...\n") + conn.Trace().Enable(true) + + if err := ch.CheckCompatiblity(vpe.AllMessages()...); err != nil { + log.Fatalf("compatibility check failed: %v", err) + } + if err := ch.CheckCompatiblity(interfaces.AllMessages()...); err != nil { + log.Printf("compatibility check failed: %v", err) + } + + // do some API calls + fmt.Printf("Calling VPP API...\n") + retrieveVersion(ch) + idx := createLoopback(ch) + addIPAddress("10.10.0.1/24", ch, idx) + interfaceDump(ch) + deleteLoopback(ch, idx) + fmt.Println() + + fmt.Printf("API trace (api calls: %d):\n", len(conn.Trace().GetRecords())) + fmt.Printf("--------------------\n") + for _, item := range conn.Trace().GetRecords() { + printTrace(item) + } + fmt.Printf("--------------------\n") + + fmt.Printf("Clearing API trace...\n\n") + conn.Trace().Clear() +} + +func multiChannel(conn *core.Connection) { + ch1, err := conn.NewAPIChannel() + if err != nil { + log.Fatalln("ERROR: creating channel failed:", err) + } + defer ch1.Close() + ch2, err := conn.NewAPIChannel() + if err != nil { + log.Fatalln("ERROR: creating channel failed:", err) + } + defer ch2.Close() + + //do API calls again + fmt.Printf("=> Example 2\n\nCalling VPP API (multi-channel)...\n") + retrieveVersion(ch1) + idx1 := createLoopback(ch1) + idx2 := createLoopback(ch2) + addIPAddress("20.10.0.1/24", ch1, idx1) + addIPAddress("30.10.0.1/24", ch2, idx2) + interfaceDump(ch1) + deleteLoopback(ch2, idx1) + deleteLoopback(ch1, idx2) + fmt.Println() + + chan1, ok := ch1.(*core.Channel) + if !ok { + log.Fatalln("ERROR: incorrect type of channel 1:", err) + } + chan2, ok := ch2.(*core.Channel) + if !ok { + log.Fatalln("ERROR: incorrect type of channel 2:", err) + } + + fmt.Printf("API trace for channel 1 (api calls: %d):\n", len(conn.Trace().GetRecordsForChannel(chan1.GetID()))) + fmt.Printf("--------------------\n") + for _, item := range conn.Trace().GetRecordsForChannel(chan1.GetID()) { + printTrace(item) + } + fmt.Printf("--------------------\n") + fmt.Printf("API trace for channel 2 (api calls: %d):\n", len(conn.Trace().GetRecordsForChannel(chan2.GetID()))) + fmt.Printf("--------------------\n") + for _, item := range conn.Trace().GetRecordsForChannel(chan2.GetID()) { + printTrace(item) + } + fmt.Printf("--------------------\n") + fmt.Printf("cumulative API trace (api calls: %d):\n", len(conn.Trace().GetRecords())) + fmt.Printf("--------------------\n") + for _, item := range conn.Trace().GetRecords() { + printTrace(item) + } + fmt.Printf("--------------------\n") + + fmt.Printf("Clearing API trace...\n\n") + conn.Trace().Clear() +} + +func stream(conn *core.Connection) { + // create new channel and perform simple compatibility check + s, err := conn.NewStream(context.Background()) + if err != nil { + log.Fatalln("ERROR: creating channel failed:", err) + } + defer func() { + if err := s.Close(); err != nil { + log.Fatalf("failed to close stream: %v", err) + } + }() + + // do some API calls + fmt.Printf("=> Example 3\n\nCalling VPP API (stream)...\n") + invokeRetrieveVersion(conn) + idx := invokeCreateLoopback(conn) + invokeAddIPAddress("40.10.0.1/24", conn, idx) + invokeInterfaceDump(conn) + invokeDeleteLoopback(conn, idx) + fmt.Println() + + fmt.Printf("stream API trace (api calls: %d):\n", len(conn.Trace().GetRecords())) + fmt.Printf("--------------------\n") + for _, item := range conn.Trace().GetRecords() { + printTrace(item) + } + fmt.Printf("--------------------\n") + + fmt.Printf("Clearing API trace...\n\n") + conn.Trace().GetRecords() +} + +func retrieveVersion(ch api.Channel) { + req := &vpe.ShowVersion{} + reply := &vpe.ShowVersionReply{} + + if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { + fmt.Printf("ERROR: %v\n", err) + return + } + fmt.Printf(" - retrieved VPP version: %s\n", reply.Version) +} + +func invokeRetrieveVersion(c api.Connection) { + req := &vpe.ShowVersion{} + reply := &vpe.ShowVersionReply{} + + if err := c.Invoke(context.Background(), req, reply); err != nil { + fmt.Printf("ERROR: %v\n", err) + } + fmt.Printf(" - retrieved VPP version: %s\n", reply.Version) +} + +func createLoopback(ch api.Channel) interface_types.InterfaceIndex { + req := &interfaces.CreateLoopback{} + reply := &interfaces.CreateLoopbackReply{} + + if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { + fmt.Printf("ERROR: %v\n", err) + return 0 + } + fmt.Printf(" - created loopback with index: %d\n", reply.SwIfIndex) + return reply.SwIfIndex +} + +func invokeCreateLoopback(c api.Connection) interface_types.InterfaceIndex { + req := &interfaces.CreateLoopback{} + reply := &interfaces.CreateLoopbackReply{} + + if err := c.Invoke(context.Background(), req, reply); err != nil { + fmt.Printf("ERROR: %v\n", err) + return 0 + } + fmt.Printf(" - created loopback with index: %d\n", reply.SwIfIndex) + return reply.SwIfIndex +} + +func deleteLoopback(ch api.Channel, index interface_types.InterfaceIndex) { + req := &interfaces.DeleteLoopback{ + SwIfIndex: index, + } + reply := &interfaces.DeleteLoopbackReply{} + + if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { + fmt.Printf("ERROR: %v\n", err) + return + } + fmt.Printf(" - deleted loopback with index: %d\n", index) +} + +func invokeDeleteLoopback(c api.Connection, index interface_types.InterfaceIndex) { + req := &interfaces.DeleteLoopback{ + SwIfIndex: index, + } + reply := &interfaces.DeleteLoopbackReply{} + + if err := c.Invoke(context.Background(), req, reply); err != nil { + fmt.Printf("ERROR: %v\n", err) + return + } + fmt.Printf(" - deleted loopback with index: %d\n", index) +} + +func addIPAddress(addr string, ch api.Channel, index interface_types.InterfaceIndex) { + ipAddr, err := ip_types.ParsePrefix(addr) + if err != nil { + fmt.Printf("ERROR: %v\n", err) + return + } + + req := &interfaces.SwInterfaceAddDelAddress{ + SwIfIndex: index, + IsAdd: true, + Prefix: ip_types.AddressWithPrefix(ipAddr), + } + reply := &interfaces.SwInterfaceAddDelAddressReply{} + + if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { + fmt.Printf("ERROR: %v\n", err) + return + } + fmt.Printf(" - IP address %s added to interface with index %d\n", addr, index) +} + +func invokeAddIPAddress(addr string, c api.Connection, index interface_types.InterfaceIndex) { + ipAddr, err := ip_types.ParsePrefix(addr) + if err != nil { + fmt.Printf("ERROR: %v\n", err) + return + } + + req := &interfaces.SwInterfaceAddDelAddress{ + SwIfIndex: index, + IsAdd: true, + Prefix: ip_types.AddressWithPrefix(ipAddr), + } + reply := &interfaces.SwInterfaceAddDelAddressReply{} + + if err := c.Invoke(context.Background(), req, reply); err != nil { + fmt.Printf("ERROR: %v\n", err) + return + } + fmt.Printf(" - IP address %s added to interface with index %d\n", addr, index) +} + +func interfaceDump(ch api.Channel) { + reqCtx := ch.SendMultiRequest(&interfaces.SwInterfaceDump{ + SwIfIndex: ^interface_types.InterfaceIndex(0), + }) + for { + msg := &interfaces.SwInterfaceDetails{} + stop, err := reqCtx.ReceiveReply(msg) + if stop { + break + } + if err != nil { + fmt.Printf("ERROR: %v\n", err) + return + } + fmt.Printf(" - retrieved interface: %v (idx: %d)\n", msg.InterfaceName, msg.SwIfIndex) + } +} + +func invokeInterfaceDump(c api.Connection) { + s, err := c.NewStream(context.Background()) + if err != nil { + fmt.Printf("ERROR: %v\n", err) + return + } + if err := s.SendMsg(&interfaces.SwInterfaceDump{}); err != nil { + fmt.Printf("ERROR: %v\n", err) + return + } + if err := s.SendMsg(&memclnt.ControlPing{}); err != nil { + fmt.Printf("ERROR: %v\n", err) + return + } + for { + reply, err := s.RecvMsg() + if err != nil { + fmt.Printf("ERROR: %v\n", err) + return + } + switch msg := reply.(type) { + case *interfaces.SwInterfaceDetails: + fmt.Printf(" - retrieved interface: %v (idx: %d)\n", msg.InterfaceName, msg.SwIfIndex) + case *memclnt.ControlPingReply: + return + } + } +} + +func printTrace(item *api.Record) { + h, m, s := item.Timestamp.Clock() + reply := "" + if item.IsReceived { + reply = "(reply)" + } + fmt.Printf("%dh:%dm:%ds:%dns %s %s\n", h, m, s, + item.Timestamp.Nanosecond(), item.Message.GetMessageName(), reply) +} diff --git a/examples/binapi-types/binapi_types.go b/examples/binapi-types/binapi_types.go new file mode 100644 index 00000000..0fcf0674 --- /dev/null +++ b/examples/binapi-types/binapi_types.go @@ -0,0 +1,147 @@ +// Copyright (c) 2018 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. + +// binapi-types is an example showing how to use and convert data with +// helper methods from *-types packages in VPP binary API. +package main + +import ( + "fmt" + "log" + "time" + + "github.com/alkiranet/govpp/binapi/ethernet_types" + "github.com/alkiranet/govpp/binapi/ip" + "github.com/alkiranet/govpp/binapi/ip_types" + "github.com/alkiranet/govpp/binapi/vpe_types" + "github.com/alkiranet/govpp/codec" +) + +func init() { +} + +func main() { + log.SetFlags(0) + + usageUnion() + usageAddress() + + // convert IP address in string form into ip_types.Address + convertIPAddress("10.10.1.1") + convertIPAddress("ff80::1") + + // convert IP address / CIDR in string form into ip_types.Prefix + convertIPPrefix("20.10.1.1/24") + convertIPPrefix("21.10.1.1") + convertIPPrefix("ff90::1/64") + convertIPPrefix("ff91::1") + + // convert MAC address in string form into ethernet_types.MacAddress + convertToMacAddress("00:10:ab:4f:00:01") + + // convert time.Time into vpe_types.Timestamp + convertToTimestamp(time.Now()) +} + +func usageUnion() { + var union ip_types.AddressUnion + + // initialize union using constructors + union = ip_types.AddressUnionIP4(ip_types.IP4Address{192, 168, 1, 10}) + union = ip_types.AddressUnionIP6(ip_types.IP6Address{0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x02}) + + // get union value using getters + ip4 := union.GetIP4() + ip6 := union.GetIP6() + + // set union value using setters + union.SetIP4(ip4) + union.SetIP6(ip6) +} + +func usageAddress() { + // parse string into IP address + addr, err := ip_types.ParseAddress("192.168.1.10") + if err != nil { + panic(err) + } + + var msg = ip.IPPuntRedirect{ + IsAdd: true, + Punt: ip.PuntRedirect{ + Nh: addr, + }, + } + + log.Printf("encoding message: %#v", msg) + + var c = codec.DefaultCodec + + b, err := c.EncodeMsg(&msg, 1) + if err != nil { + log.Fatal(err) + } + + // decode into this message + var msg2 ip.IPPuntRedirect + if err := c.DecodeMsg(b, &msg2); err != nil { + log.Fatal(err) + } + log.Printf("decoded message: %#v", msg2) + + // compare the messages + if !msg.Punt.Nh.ToIP().Equal(msg2.Punt.Nh.ToIP()) { + log.Fatal("messages are not equal") + } +} + +func convertIPAddress(ip string) { + addr, err := ip_types.ParseAddress(ip) + if err != nil { + log.Printf("error converting IP to Address: %v", err) + return + } + fmt.Printf("converted IP %q to: %#v\n", ip, addr) + + fmt.Printf("Address converted back to string IP %#v to: %s\n", addr, addr) +} + +func convertIPPrefix(ip string) { + prefix, err := ip_types.ParsePrefix(ip) + if err != nil { + log.Printf("error converting prefix to IP4Prefix: %v", err) + return + } + fmt.Printf("converted prefix %q to: %#v\n", ip, prefix) + + fmt.Printf("IP4Prefix converted back to string prefix %#v to: %s\n", prefix, prefix) +} + +func convertToMacAddress(mac string) { + parsedMac, err := ethernet_types.ParseMacAddress(mac) + if err != nil { + log.Printf("error converting MAC to MacAddress: %v", err) + return + } + fmt.Printf("converted mac %q to: %#v\n", mac, parsedMac) + + fmt.Printf("MacAddress converted back to string %#v to: %s\n", parsedMac, parsedMac) +} + +func convertToTimestamp(t time.Time) { + timestamp := vpe_types.NewTimestamp(t) + fmt.Printf("converted time %v to: %#v\n", t, timestamp) + + fmt.Printf("Timestamp converted back to string %#v to: %s\n", timestamp, timestamp) +} diff --git a/examples/binapi/acl/acl.ba.go b/examples/binapi/acl/acl.ba.go deleted file mode 100644 index 51ddecc4..00000000 --- a/examples/binapi/acl/acl.ba.go +++ /dev/null @@ -1,1015 +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 - 36 messages - 18 services -*/ -package acl - -import ( - bytes "bytes" - context "context" - api "github.com/alkiranet/govpp/api" - struc "github.com/lunixbochs/struc" - io "io" - strconv "strconv" -) - -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 = 0x8ed22cb9 -) - -// 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" -} -func (*ACLRule) GetCrcString() string { - return "6f99bf4d" -} - -// 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" -} -func (*MacipACLRule) GetCrcString() string { - return "70589f1e" -} - -// 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 (*ACLAddReplace) GetMessageName() string { - return "acl_add_replace" -} -func (*ACLAddReplace) GetCrcString() string { - return "e839997e" -} -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 (*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 (*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 (*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 (*ACLDetails) GetMessageName() string { - return "acl_details" -} -func (*ACLDetails) GetCrcString() string { - return "5bd895be" -} -func (*ACLDetails) GetMessageType() api.MessageType { - return api.ReplyMessage -} - -// ACLDump represents VPP binary API message 'acl_dump'. -type ACLDump struct { - ACLIndex uint32 -} - -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 (*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 (*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 (*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 (*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 (*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 (*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 (*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 (*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 (*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 (*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 (*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 (*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 (*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 (*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 (*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 (*ACLPluginGetVersionReply) GetMessageName() string { - return "acl_plugin_get_version_reply" -} -func (*ACLPluginGetVersionReply) GetCrcString() string { - return "9b32cf86" -} -func (*ACLPluginGetVersionReply) 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 (*MacipACLAdd) GetMessageName() string { - return "macip_acl_add" -} -func (*MacipACLAdd) GetCrcString() string { - return "b3d3d65a" -} -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 (*MacipACLAddReplace) GetMessageName() string { - return "macip_acl_add_replace" -} -func (*MacipACLAddReplace) GetCrcString() string { - return "a0e8c01b" -} -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 (*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 (*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 (*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 (*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 (*MacipACLDetails) GetMessageName() string { - return "macip_acl_details" -} -func (*MacipACLDetails) GetCrcString() string { - return "dd2b55ba" -} -func (*MacipACLDetails) GetMessageType() api.MessageType { - return api.ReplyMessage -} - -// MacipACLDump represents VPP binary API message 'macip_acl_dump'. -type MacipACLDump struct { - ACLIndex uint32 -} - -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 (*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 (*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 (*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 (*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 (*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 (*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((*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), - (*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) - 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) 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/examples/binapi/af_packet/af_packet.ba.go b/examples/binapi/af_packet/af_packet.ba.go deleted file mode 100644 index ac8c1e18..00000000 --- a/examples/binapi/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 "github.com/alkiranet/govpp/api" - struc "github.com/lunixbochs/struc" - - ethernet_types "github.com/alkiranet/govpp/examples/binapi/ethernet_types" - interface_types "github.com/alkiranet/govpp/examples/binapi/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/examples/binapi/ethernet_types/ethernet_types.ba.go b/examples/binapi/ethernet_types/ethernet_types.ba.go deleted file mode 100644 index 7b8929fe..00000000 --- a/examples/binapi/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 "github.com/alkiranet/govpp/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/examples/binapi/gen.go b/examples/binapi/gen.go deleted file mode 100644 index 20835fa9..00000000 --- a/examples/binapi/gen.go +++ /dev/null @@ -1,20 +0,0 @@ -package binapi - -// Generate Go code from the VPP APIs located in the /usr/share/vpp/api directory. - -//go:generate binapi-generator --output-dir=. --input-file=/usr/share/vpp/api/core/ethernet_types.api.json -//go:generate binapi-generator --output-dir=. --input-file=/usr/share/vpp/api/core/interface_types.api.json -//go:generate binapi-generator --output-dir=. --input-file=/usr/share/vpp/api/core/ip_types.api.json -//go:generate binapi-generator --output-dir=. --input-file=/usr/share/vpp/api/core/vpe_types.api.json - -//go:generate -command binapigen binapi-generator --output-dir=. --import-prefix=github.com/alkiranet/govpp/examples/binapi --input-types=/usr/share/vpp/api/core/ethernet_types.api.json,/usr/share/vpp/api/core/ip_types.api.json,/usr/share/vpp/api/core/interface_types.api.json,/usr/share/vpp/api/core/vpe_types.api.json - -//go:generate binapigen --input-file=/usr/share/vpp/api/core/af_packet.api.json -//go:generate binapigen --input-file=/usr/share/vpp/api/core/interface.api.json -//go:generate binapigen --input-file=/usr/share/vpp/api/core/ip.api.json -//go:generate binapigen --input-file=/usr/share/vpp/api/core/memclnt.api.json -//go:generate binapigen --input-file=/usr/share/vpp/api/core/vpe.api.json -//go:generate binapigen --input-file=/usr/share/vpp/api/plugins/memif.api.json - -// VPP version -///go:generate sh -c "dpkg-query -f '$DOLLAR{Version}' -W vpp > VPP_VERSION" diff --git a/examples/binapi/interface_types/interface_types.ba.go b/examples/binapi/interface_types/interface_types.ba.go deleted file mode 100644 index d638d369..00000000 --- a/examples/binapi/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 "github.com/alkiranet/govpp/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/examples/binapi/interfaces/interfaces.ba.go b/examples/binapi/interfaces/interfaces.ba.go deleted file mode 100644 index 20421b52..00000000 --- a/examples/binapi/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 "github.com/alkiranet/govpp/api" - struc "github.com/lunixbochs/struc" - - ethernet_types "github.com/alkiranet/govpp/examples/binapi/ethernet_types" - interface_types "github.com/alkiranet/govpp/examples/binapi/interface_types" - ip_types "github.com/alkiranet/govpp/examples/binapi/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/examples/binapi/ip/ip.ba.go b/examples/binapi/ip/ip.ba.go deleted file mode 100644 index 568cab91..00000000 --- a/examples/binapi/ip/ip.ba.go +++ /dev/null @@ -1,1672 +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 "github.com/alkiranet/govpp/api" - struc "github.com/lunixbochs/struc" - - ethernet_types "github.com/alkiranet/govpp/examples/binapi/ethernet_types" - interface_types "github.com/alkiranet/govpp/examples/binapi/interface_types" - ip_types "github.com/alkiranet/govpp/examples/binapi/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 - -// 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 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 - -// 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 - LabelStack []FibMplsLabel `struc:"[16]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 - -// 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/examples/binapi/ip_types/ip_types.ba.go b/examples/binapi/ip_types/ip_types.ba.go deleted file mode 100644 index 9cfb7a74..00000000 --- a/examples/binapi/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 "github.com/alkiranet/govpp/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/examples/binapi/memclnt/memclnt.ba.go b/examples/binapi/memclnt/memclnt.ba.go deleted file mode 100644 index a89f3da5..00000000 --- a/examples/binapi/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 "github.com/alkiranet/govpp/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/examples/binapi/memif/memif.ba.go b/examples/binapi/memif/memif.ba.go deleted file mode 100644 index d6d444f3..00000000 --- a/examples/binapi/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 "github.com/alkiranet/govpp/api" - struc "github.com/lunixbochs/struc" - - ethernet_types "github.com/alkiranet/govpp/examples/binapi/ethernet_types" - interface_types "github.com/alkiranet/govpp/examples/binapi/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/examples/binapi/vpe/vpe.ba.go b/examples/binapi/vpe/vpe.ba.go deleted file mode 100644 index d04554f7..00000000 --- a/examples/binapi/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 "github.com/alkiranet/govpp/api" - struc "github.com/lunixbochs/struc" - - vpe_types "github.com/alkiranet/govpp/examples/binapi/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/examples/binapi/vpe_types/vpe_types.ba.go b/examples/binapi/vpe_types/vpe_types.ba.go deleted file mode 100644 index 765d4304..00000000 --- a/examples/binapi/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 "github.com/alkiranet/govpp/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/examples/multi-vpp/README.md b/examples/multi-vpp/README.md new file mode 100644 index 00000000..2999ae9f --- /dev/null +++ b/examples/multi-vpp/README.md @@ -0,0 +1,52 @@ +# Multi-VPP example + +This example shows how to use GoVPP client to connect, configure and read stats from multiple VPPs simultaneously. + +# Requirements + +* VPP 19.08 or newer (required for stats client) +* VPP stats enabled + +The example requires two running VPP instances. VPPs can be simply started in the same machine with different startup configs. Note that the default path to binary API and stats sockets are `/run/vpp/api.sock` or `/run/vpp/stats.sock` respectively. The example always uses the default path if none is set. It means that at least one VPP must have the following fields redefined: + +``` +socksvr { + socket-name /run/custom-vpp-path/api.sock +} + +statseg { + socket-name /run/custom-vpp-path/stats.sock +} +``` + +And the custom path must be provided to the example. Four flags are available: +``` +-api-sock-1 string - Path to binary API socket file of the VPP1 (default "/run/vpp/api.sock") +-api-sock-2 string - Path to binary API socket file of the VPP2 (default "/run/vpp/api.sock") +-stats-sock-1 string - Path to stats socket file of the VPP1 (default "/run/vpp/stats.sock") +-stats-sock-2 string - Path to stats socket file of the VPP2 (default "/run/vpp/stats.sock") +``` +Let's say the VPP1 uses the default config, and the config above belongs to the VPP2. In that case, use the following command: +``` +sudo ./multi-vpp -api-sock-2=/run/custom-vpp-path/api.sock -stats-sock-2=/run/custom-vpp-path/stats.sock +``` + +# Running the example + +The example consists of the following steps: +* connects to both VPPs binary API socket and stats socket +* configures example interfaces with IP addresses +* dumps interface data via the binary API +* dumps interface data via socket client +* in case there are no errors, cleans up VPPs in order to be able running the example in a loop + + + + + + + + + + + diff --git a/examples/multi-vpp/multi_vpp.go b/examples/multi-vpp/multi_vpp.go new file mode 100644 index 00000000..953cfb07 --- /dev/null +++ b/examples/multi-vpp/multi_vpp.go @@ -0,0 +1,349 @@ +// 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. + +// multi-vpp is an example of managing multiple VPPs in single application. +package main + +import ( + "flag" + "fmt" + "log" + "os" + "strings" + + "github.com/alkiranet/govpp" + "github.com/alkiranet/govpp/adapter/socketclient" + "github.com/alkiranet/govpp/adapter/statsclient" + "github.com/alkiranet/govpp/api" + interfaces "github.com/alkiranet/govpp/binapi/interface" + "github.com/alkiranet/govpp/binapi/interface_types" + "github.com/alkiranet/govpp/binapi/ip" + "github.com/alkiranet/govpp/binapi/ip_types" + "github.com/alkiranet/govpp/binapi/vpe" + "github.com/alkiranet/govpp/core" +) + +var ( + binapiSockAddrVpp1 = flag.String("api-sock-1", socketclient.DefaultSocketName, "Path to binary API socket file of the VPP1") + statsSockAddrVpp1 = flag.String("stats-sock-1", statsclient.DefaultSocketName, "Path to stats socket file of the VPP1") + binapiSockAddrVpp2 = flag.String("api-sock-2", socketclient.DefaultSocketName, "Path to binary API socket file of the VPP2") + statsSockAddrVpp2 = flag.String("stats-sock-2", statsclient.DefaultSocketName, "Path to stats socket file of the VPP2") +) + +var errors []error + +func main() { + flag.Parse() + fmt.Println("Starting multi-vpp example") + + defer func() { + if len(errors) > 0 { + logInfo("Finished with %d errors\n", len(errors)) + os.Exit(1) + } else { + logInfo("Finished successfully\n") + } + }() + + // since sockets default to the same value + if *binapiSockAddrVpp1 == *binapiSockAddrVpp2 { + log.Println("ERROR: identical VPP binapi sockets defined, set at least one of them to a non-default path") + } + if *statsSockAddrVpp1 == *statsSockAddrVpp2 { + log.Println("ERROR: identical VPP stats sockets defined, set at least one of them to a non-default path") + } + var name1, name2 = "vpp1", "vpp2" + ch1, statsConn1, disconnect1 := connectVPP(name1, *binapiSockAddrVpp1, *statsSockAddrVpp1) + defer disconnect1() + + ch2, statsConn2, disconnect2 := connectVPP(name2, *binapiSockAddrVpp2, *statsSockAddrVpp2) + defer disconnect2() + + fmt.Println() + + // retrieve VPP1 version + logHeader("Retrieving %s version", name1) + getVppVersion(ch1, name1) + + // retrieve VPP2 version + logHeader("Retrieving %s version", name2) + getVppVersion(ch1, name2) + + // configure VPP1 + logHeader("Configuring %s", name1) + ifIdx1 := createLoopback(ch1, name1) + addIPsToInterface(ch1, ifIdx1, []string{"10.10.0.1/24", "15.10.0.1/24"}) + + // configure VPP2 + logHeader("Configuring %s", name2) + ifIdx2 := createLoopback(ch2, name2) + addIPsToInterface(ch2, ifIdx2, []string{"20.10.0.1/24", "25.10.0.1/24"}) + + // retrieve configuration from VPPs + retrieveIPAddresses(ch1, name1, ifIdx1) + retrieveIPAddresses(ch2, name2, ifIdx2) + + // retrieve stats from VPPs + retrieveStats(statsConn1, name1) + retrieveStats(statsConn2, name2) + + // cleanup + logHeader("Cleaning up %s", name1) + deleteIPsToInterface(ch1, ifIdx1, []string{"10.10.0.1/24", "15.10.0.1/24"}) + deleteLoopback(ch1, ifIdx1) + logHeader("Cleaning up %s", name2) + deleteIPsToInterface(ch2, ifIdx2, []string{"20.10.0.1/24", "25.10.0.1/24"}) + deleteLoopback(ch2, ifIdx2) +} + +func connectVPP(name, binapiSocket, statsSocket string) (api.Channel, api.StatsProvider, func()) { + fmt.Println() + logHeader("Connecting to %s", name) + + // connect VPP1 to the binapi socket + ch, disconnectBinapi, err := connectBinapi(binapiSocket, 1) + if err != nil { + log.Fatalf("ERROR: connecting VPP binapi failed (socket %s): %v\n", binapiSocket, err) + } + + // connect VPP1 to the stats socket + statsConn, disconnectStats, err := connectStats(name, statsSocket) + if err != nil { + disconnectBinapi() + log.Fatalf("ERROR: connecting VPP stats failed (socket %s): %v\n", statsSocket, err) + } + + logInfo("OK\n") + + return ch, statsConn, func() { + disconnectStats() + disconnectBinapi() + logInfo("VPP %s disconnected\n", name) + } +} + +// connectBinapi connects to the binary API socket and returns a communication channel +func connectBinapi(socket string, attempts int) (api.Channel, func(), error) { + logInfo("Attaching to the binapi socket %s\n", socket) + conn, event, err := govpp.AsyncConnect(socket, attempts, core.DefaultReconnectInterval) + if err != nil { + return nil, nil, err + } + e := <-event + if e.State != core.Connected { + return nil, nil, err + } + ch, err := getAPIChannel(conn) + if err != nil { + return nil, nil, err + } + disconnect := func() { + if ch != nil { + ch.Close() + } + if conn != nil { + conn.Disconnect() + } + } + return ch, disconnect, nil +} + +// connectStats connects to the stats socket and returns a stats provider +func connectStats(name, socket string) (api.StatsProvider, func(), error) { + logInfo("Attaching to the stats socket %s\n", socket) + sc := statsclient.NewStatsClient(socket) + conn, err := core.ConnectStats(sc) + if err != nil { + return nil, nil, err + } + disconnect := func() { + if err := sc.Disconnect(); err != nil { + logError(err, "failed to disconnect "+name+" stats socket") + } + } + return conn, disconnect, nil +} + +// getAPIChannel creates new API channel and verifies its compatibility +func getAPIChannel(c api.ChannelProvider) (api.Channel, error) { + ch, err := c.NewAPIChannel() + if err != nil { + return nil, err + } + if err := ch.CheckCompatiblity(vpe.AllMessages()...); err != nil { + return nil, fmt.Errorf("compatibility check failed: %w", err) + } + if err := ch.CheckCompatiblity(interfaces.AllMessages()...); err != nil { + logInfo("compatibility check failed: %v", err) + } + return ch, nil +} + +// getVppVersion returns VPP version (simple API usage) +func getVppVersion(ch api.Channel, name string) { + logInfo("Retrieving version of %s ..\n", name) + + req := &vpe.ShowVersion{} + reply := &vpe.ShowVersionReply{} + + if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { + logError(err, "retrieving version") + return + } + logInfo("Retrieved version is %q\n", reply.Version) + fmt.Println() +} + +// createLoopback sends request to create a loopback interface +func createLoopback(ch api.Channel, name string) interface_types.InterfaceIndex { + logInfo("Adding loopback interface ..\n") + + req := &interfaces.CreateLoopback{} + reply := &interfaces.CreateLoopbackReply{} + + if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { + logError(err, "adding loopback interface") + return 0 + } + logInfo("Interface index %d added to %s\n", reply.SwIfIndex, name) + + return reply.SwIfIndex +} + +// deleteLoopback removes created loopback interface +func deleteLoopback(ch api.Channel, ifIdx interface_types.InterfaceIndex) { + logInfo("Removing loopback interface ..\n") + req := &interfaces.DeleteLoopback{ + SwIfIndex: ifIdx, + } + reply := &interfaces.DeleteLoopbackReply{} + + if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { + logError(err, "removing loopback interface") + } + logInfo("OK\n") + fmt.Println() +} + +// addIPsToInterface sends request to add IP addresses to an interface. +func addIPsToInterface(ch api.Channel, index interface_types.InterfaceIndex, ips []string) { + for _, ipAddr := range ips { + logInfo("Adding IP address %s\n", ipAddr) + prefix, err := ip_types.ParsePrefix(ipAddr) + if err != nil { + logError(err, "attempt to add invalid IP address") + return + } + + req := &interfaces.SwInterfaceAddDelAddress{ + SwIfIndex: index, + IsAdd: true, + Prefix: ip_types.AddressWithPrefix(prefix), + } + reply := &interfaces.SwInterfaceAddDelAddressReply{} + + if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { + logError(err, "adding IP address to interface") + return + } + } + + logInfo("OK\n") + fmt.Println() +} + +// deleteIPsToInterface sends request to remove IP addresses from an interface. +func deleteIPsToInterface(ch api.Channel, index interface_types.InterfaceIndex, ips []string) { + for _, ipAddr := range ips { + logInfo("Removing IP address %s\n", ipAddr) + prefix, err := ip_types.ParsePrefix(ipAddr) + if err != nil { + logError(err, "attempt to remove invalid IP address") + return + } + + req := &interfaces.SwInterfaceAddDelAddress{ + SwIfIndex: index, + Prefix: ip_types.AddressWithPrefix(prefix), + } + reply := &interfaces.SwInterfaceAddDelAddressReply{} + + if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { + logError(err, "removing IP address to interface") + return + } + } +} + +// retrieveIPAddresses reads IP address from the interface +func retrieveIPAddresses(ch api.Channel, name string, index interface_types.InterfaceIndex) { + logHeader("Retrieving interface data from %s", name) + req := &ip.IPAddressDump{ + SwIfIndex: index, + } + reqCtx := ch.SendMultiRequest(req) + + logInfo("Dump IP addresses for interface index %d ..\n", index) + for { + msg := &ip.IPAddressDetails{} + stop, err := reqCtx.ReceiveReply(msg) + if err != nil { + logError(err, "dumping IP addresses") + return + } + if stop { + break + } + prefix := ip_types.Prefix(msg.Prefix) + logInfo(" - ip address: %v\n", prefix) + } + + logInfo("OK\n") + fmt.Println() +} + +// retrieveStats reads interface stats +func retrieveStats(s api.StatsProvider, name string) { + logHeader("Retrieving interface stats from %s", name) + ifStats := &api.InterfaceStats{} + err := s.GetInterfaceStats(ifStats) + if err != nil { + logError(err, "dumping interface stats") + return + } + logInfo("Dump interface stats ..\n") + for _, ifStats := range ifStats.Interfaces { + logInfo(" - %+v\n", ifStats) + } + + logInfo("OK\n") + fmt.Println() +} + +// logHeader prints underlined message (for better output segmentation) +func logHeader(format string, a ...interface{}) { + n, _ := fmt.Printf(format+"\n", a...) + fmt.Println(strings.Repeat("-", n-1)) +} + +// logInfo prints info message +func logInfo(format string, a ...interface{}) { + fmt.Printf(format, a...) +} + +// logError prints error message +func logError(err error, msg string) { + fmt.Printf("[ERROR]: %s: %v\n", msg, err) + errors = append(errors, err) +} diff --git a/examples/perf-bench/perf-bench.go b/examples/perf-bench/perf-bench.go index f4657aa4..6d51953b 100644 --- a/examples/perf-bench/perf-bench.go +++ b/examples/perf-bench/perf-bench.go @@ -17,9 +17,11 @@ package main import ( + "context" "flag" "fmt" "log" + "os" "time" "github.com/pkg/profile" @@ -28,8 +30,8 @@ import ( "github.com/alkiranet/govpp/adapter/socketclient" "github.com/alkiranet/govpp/adapter/statsclient" "github.com/alkiranet/govpp/api" + "github.com/alkiranet/govpp/binapi/memclnt" "github.com/alkiranet/govpp/core" - "github.com/alkiranet/govpp/examples/binapi/vpe" ) const ( @@ -39,14 +41,17 @@ const ( func main() { // parse optional flags - var sync, prof bool + var sync bool var cnt int - var sock string + var sock, prof string + var testV2, debugOn bool flag.BoolVar(&sync, "sync", false, "run synchronous perf test") - flag.StringVar(&sock, "socket", socketclient.DefaultSocketName, "Path to VPP API socket") - flag.String("socket", statsclient.DefaultSocketName, "Path to VPP stats socket") + flag.StringVar(&sock, "api-socket", socketclient.DefaultSocketName, "Path to VPP API socket") + flag.String("stats-socket", statsclient.DefaultSocketName, "Path to VPP stats socket") flag.IntVar(&cnt, "count", 0, "count of requests to be sent to VPP") - flag.BoolVar(&prof, "prof", false, "generate profile data") + flag.StringVar(&prof, "prof", "", "enable profiling mode [mem, cpu]") + flag.BoolVar(&testV2, "v2", false, "Use test function v2") + flag.BoolVar(&debugOn, "debug", false, "Enable debug mode") flag.Parse() if cnt == 0 { @@ -58,8 +63,16 @@ func main() { } } - if prof { - defer profile.Start().Stop() + switch prof { + case "mem": + defer profile.Start(profile.MemProfile, profile.MemProfileRate(1)).Stop() + case "cpu": + defer profile.Start(profile.CPUProfile).Stop() + case "": + default: + fmt.Printf("invalid profiling mode: %q\n", prof) + flag.Usage() + os.Exit(1) } a := socketclient.NewVppClient(sock) @@ -80,18 +93,26 @@ func main() { ch.SetReplyTimeout(time.Second * 2) - // log only errors - core.SetLogger(&logrus.Logger{Level: logrus.ErrorLevel}) + if !debugOn { + // log only errors + core.SetLogger(&logrus.Logger{Level: logrus.ErrorLevel}) + } // run the test & measure the time start := time.Now() - if sync { - // run synchronous test - syncTest(ch, cnt) + if testV2 { + if sync { + syncTest2(conn, cnt) + } else { + asyncTest2(conn, cnt) + } } else { - // run asynchronous test - asyncTest(ch, cnt) + if sync { + syncTest(ch, cnt) + } else { + asyncTest(ch, cnt) + } } elapsed := time.Since(start) @@ -105,8 +126,8 @@ func syncTest(ch api.Channel, cnt int) { fmt.Printf("Running synchronous perf test with %d requests...\n", cnt) for i := 0; i < cnt; i++ { - req := &vpe.ControlPing{} - reply := &vpe.ControlPingReply{} + req := &memclnt.ControlPing{} + reply := &memclnt.ControlPingReply{} if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { log.Fatalln("Error in reply:", err) @@ -114,6 +135,27 @@ func syncTest(ch api.Channel, cnt int) { } } +func syncTest2(conn api.Connection, cnt int) { + fmt.Printf("Running synchronous perf test with %d requests...\n", cnt) + + stream, err := conn.NewStream(context.Background()) + if err != nil { + log.Fatalln("Error NewStream:", err) + } + for i := 0; i < cnt; i++ { + if err := stream.SendMsg(&memclnt.ControlPing{}); err != nil { + log.Fatalln("Error SendMsg:", err) + } + if msg, err := stream.RecvMsg(); err != nil { + log.Fatalln("Error RecvMsg:", err) + } else if _, ok := msg.(*memclnt.ControlPingReply); ok { + // ok + } else { + log.Fatalf("unexpected reply: %v", msg.GetMessageName()) + } + } +} + func asyncTest(ch api.Channel, cnt int) { fmt.Printf("Running asynchronous perf test with %d requests...\n", cnt) @@ -121,16 +163,50 @@ func asyncTest(ch api.Channel, cnt int) { go func() { for i := 0; i < cnt; i++ { - ctxChan <- ch.SendRequest(&vpe.ControlPing{}) + ctxChan <- ch.SendRequest(&memclnt.ControlPing{}) } close(ctxChan) fmt.Printf("Sending asynchronous requests finished\n") }() for ctx := range ctxChan { - reply := &vpe.ControlPingReply{} + reply := &memclnt.ControlPingReply{} if err := ctx.ReceiveReply(reply); err != nil { log.Fatalln("Error in reply:", err) } } } + +func asyncTest2(conn api.Connection, cnt int) { + fmt.Printf("Running asynchronous perf test with %d requests...\n", cnt) + + ctxChan := make(chan api.Stream, cnt) + + go func() { + for i := 0; i < cnt; i++ { + stream, err := conn.NewStream(context.Background()) + if err != nil { + log.Fatalln("Error NewStream:", err) + } + if err := stream.SendMsg(&memclnt.ControlPing{}); err != nil { + log.Fatalln("Error SendMsg:", err) + } + ctxChan <- stream + } + close(ctxChan) + fmt.Printf("Sending asynchronous requests finished\n") + }() + + for ctx := range ctxChan { + if msg, err := ctx.RecvMsg(); err != nil { + log.Fatalln("Error RecvMsg:", err) + } else if _, ok := msg.(*memclnt.ControlPingReply); ok { + // ok + } else { + log.Fatalf("unexpected reply: %v", msg.GetMessageName()) + } + if err := ctx.Close(); err != nil { + log.Fatalf("Stream.Close error: %v", err) + } + } +} diff --git a/examples/rpc-service/rpc_service.go b/examples/rpc-service/rpc_service.go index 9bb49786..ba4ed300 100644 --- a/examples/rpc-service/rpc_service.go +++ b/examples/rpc-service/rpc_service.go @@ -27,8 +27,8 @@ import ( "github.com/alkiranet/govpp" "github.com/alkiranet/govpp/adapter/socketclient" "github.com/alkiranet/govpp/api" - "github.com/alkiranet/govpp/examples/binapi/interfaces" - "github.com/alkiranet/govpp/examples/binapi/vpe" + interfaces "github.com/alkiranet/govpp/binapi/interface" + "github.com/alkiranet/govpp/binapi/vpe" ) var ( @@ -47,20 +47,13 @@ func main() { } defer conn.Disconnect() - // create a channel - ch, err := conn.NewAPIChannel() - if err != nil { - log.Fatalln("ERROR: creating channel failed:", err) - } - defer ch.Close() - - showVersion(ch) - interfaceDump(ch) + showVersion(conn) + interfaceDump(conn) } // showVersion shows an example of simple request with services. -func showVersion(ch api.Channel) { - c := vpe.NewServiceClient(ch) +func showVersion(conn api.Connection) { + c := vpe.NewServiceClient(conn) version, err := c.ShowVersion(context.Background(), &vpe.ShowVersion{}) if err != nil { @@ -71,10 +64,10 @@ func showVersion(ch api.Channel) { } // interfaceDump shows an example of multi request with services. -func interfaceDump(ch api.Channel) { - c := interfaces.NewServiceClient(ch) +func interfaceDump(conn api.Connection) { + c := interfaces.NewServiceClient(conn) - stream, err := c.DumpSwInterface(context.Background(), &interfaces.SwInterfaceDump{}) + stream, err := c.SwInterfaceDump(context.Background(), &interfaces.SwInterfaceDump{}) if err != nil { log.Fatalln("ERROR: DumpSwInterface failed:", err) } diff --git a/examples/simple-client/simple_client.go b/examples/simple-client/simple_client.go index 18b0646d..11541077 100644 --- a/examples/simple-client/simple_client.go +++ b/examples/simple-client/simple_client.go @@ -17,21 +17,21 @@ package main import ( + "encoding/json" "flag" "fmt" "log" "os" - "strings" "github.com/alkiranet/govpp" "github.com/alkiranet/govpp/adapter/socketclient" "github.com/alkiranet/govpp/api" + interfaces "github.com/alkiranet/govpp/binapi/interface" + "github.com/alkiranet/govpp/binapi/interface_types" + "github.com/alkiranet/govpp/binapi/ip" + "github.com/alkiranet/govpp/binapi/ip_types" + "github.com/alkiranet/govpp/binapi/vpe" "github.com/alkiranet/govpp/core" - "github.com/alkiranet/govpp/examples/binapi/interface_types" - "github.com/alkiranet/govpp/examples/binapi/interfaces" - "github.com/alkiranet/govpp/examples/binapi/ip" - "github.com/alkiranet/govpp/examples/binapi/ip_types" - "github.com/alkiranet/govpp/examples/binapi/vpe" ) var ( @@ -42,145 +42,161 @@ func main() { flag.Parse() fmt.Println("Starting simple client example") + fmt.Println() // connect to VPP asynchronously - conn, conev, err := govpp.AsyncConnect(*sockAddr, core.DefaultMaxReconnectAttempts, core.DefaultReconnectInterval) + conn, connEv, err := govpp.AsyncConnect(*sockAddr, core.DefaultMaxReconnectAttempts, core.DefaultReconnectInterval) if err != nil { log.Fatalln("ERROR:", err) } defer conn.Disconnect() // wait for Connected event - select { - case e := <-conev: - if e.State != core.Connected { - log.Fatalln("ERROR: connecting to VPP failed:", e.Error) - } + e := <-connEv + if e.State != core.Connected { + log.Fatalln("ERROR: connecting to VPP failed:", e.Error) } - // create an API channel that will be used in the examples + // check compatibility of used messages ch, err := conn.NewAPIChannel() if err != nil { log.Fatalln("ERROR: creating channel failed:", err) } defer ch.Close() - - vppVersion(ch) - + if err := ch.CheckCompatiblity(vpe.AllMessages()...); err != nil { + log.Fatalf("compatibility check failed: %v", err) + } if err := ch.CheckCompatiblity(interfaces.AllMessages()...); err != nil { - log.Fatal(err) + log.Printf("compatibility check failed: %v", err) } - createLoopback(ch) - createLoopback(ch) + // process errors encountered during the example + defer func() { + if len(errors) > 0 { + fmt.Printf("finished with %d errors\n", len(errors)) + os.Exit(1) + } else { + fmt.Println("finished successfully") + } + }() + + // use request/reply (channel API) + getVppVersion(ch) + getSystemTime(ch) + idx := createLoopback(ch) interfaceDump(ch) + addIPAddress(ch, idx) + ipAddressDump(ch, idx) + interfaceNotifications(ch, idx) +} - addIPAddress(ch) - ipAddressDump(ch) +func getVppVersion(ch api.Channel) { + fmt.Println("Retrieving version..") - interfaceNotifications(ch) + req := &vpe.ShowVersion{} + reply := &vpe.ShowVersionReply{} - if len(Errors) > 0 { - fmt.Printf("finished with %d errors\n", len(Errors)) - os.Exit(1) - } else { - fmt.Println("finished successfully") + if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { + logError(err, "retrieving version") + return } -} - -var Errors []error -func logError(err error, msg string) { - fmt.Printf("ERROR: %s: %v\n", msg, err) - Errors = append(Errors, err) + fmt.Printf("VPP version: %q\n", reply.Version) + fmt.Println("OK") + fmt.Println() } -// vppVersion is the simplest API example - it retrieves VPP version. -func vppVersion(ch api.Channel) { - fmt.Println("Retrieving version") +func getSystemTime(ch api.Channel) { + fmt.Println("Retrieving system time..") - req := &vpe.ShowVersion{} - reply := &vpe.ShowVersionReply{} + req := &vpe.ShowVpeSystemTime{} + reply := &vpe.ShowVpeSystemTimeReply{} if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { - logError(err, "retrieving version") + logError(err, "retrieving system time") return } - fmt.Printf("reply: %+v\n", reply) - fmt.Printf("VPP version: %q\n", cleanString(reply.Version)) - fmt.Println("ok") + fmt.Printf("system time: %v\n", reply.VpeSystemTime) + fmt.Println("OK") + fmt.Println() } -// createLoopback sends request to create loopback interface. -func createLoopback(ch api.Channel) { - fmt.Println("Creating loopback interface") +func createLoopback(ch api.Channel) interface_types.InterfaceIndex { + fmt.Println("Creating loopback interface..") req := &interfaces.CreateLoopback{} reply := &interfaces.CreateLoopbackReply{} if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { logError(err, "creating loopback interface") - return + return 0 } - fmt.Printf("reply: %+v\n", reply) - fmt.Printf("loopback interface index: %v\n", reply.SwIfIndex) + fmt.Printf("interface index: %v\n", reply.SwIfIndex) fmt.Println("OK") + fmt.Println() + + return reply.SwIfIndex } -// interfaceDump shows an example of multipart request (multiple replies are expected). func interfaceDump(ch api.Channel) { - fmt.Println("Dumping interfaces") + fmt.Println("Dumping interfaces..") - reqCtx := ch.SendMultiRequest(&interfaces.SwInterfaceDump{}) + n := 0 + reqCtx := ch.SendMultiRequest(&interfaces.SwInterfaceDump{ + SwIfIndex: ^interface_types.InterfaceIndex(0), + }) for { msg := &interfaces.SwInterfaceDetails{} stop, err := reqCtx.ReceiveReply(msg) + if stop { + break + } if err != nil { logError(err, "dumping interfaces") return } - if stop { - break - } - fmt.Printf(" - interface: %+v\n", msg) + n++ + fmt.Printf(" - interface #%d: %+v\n", n, msg) + marshal(msg) } fmt.Println("OK") + fmt.Println() } -// addIPAddress sends request to add IP address to interface. -func addIPAddress(ch api.Channel) { - fmt.Println("Adding IP address to interface") +func addIPAddress(ch api.Channel, index interface_types.InterfaceIndex) { + fmt.Printf("Adding IP address to interface index %d\n", index) req := &interfaces.SwInterfaceAddDelAddress{ - SwIfIndex: 1, + SwIfIndex: index, IsAdd: true, Prefix: ip_types.AddressWithPrefix{ - Address: interfaces.Address{ + Address: ip_types.Address{ Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(interfaces.IP4Address{10, 10, 0, 1}), + Un: ip_types.AddressUnionIP4(ip_types.IP4Address{10, 10, 0, uint8(index)}), }, - Len: 24, + Len: 32, }, } + marshal(req) reply := &interfaces.SwInterfaceAddDelAddressReply{} if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { logError(err, "adding IP address to interface") return } - fmt.Printf("reply: %+v\n", reply) fmt.Println("OK") + fmt.Println() } -func ipAddressDump(ch api.Channel) { - fmt.Println("Dumping IP addresses") +func ipAddressDump(ch api.Channel, index interface_types.InterfaceIndex) { + fmt.Printf("Dumping IP addresses for interface index %d..\n", index) req := &ip.IPAddressDump{ - SwIfIndex: 1, + SwIfIndex: index, } reqCtx := ch.SendMultiRequest(req) @@ -195,16 +211,18 @@ func ipAddressDump(ch api.Channel) { break } fmt.Printf(" - ip address: %+v\n", msg) + marshal(msg) } fmt.Println("OK") + fmt.Println() } // interfaceNotifications shows the usage of notification API. Note that for notifications, // you are supposed to create your own Go channel with your preferred buffer size. If the channel's // buffer is full, the notifications will not be delivered into it. -func interfaceNotifications(ch api.Channel) { - fmt.Println("Subscribing to notificaiton events") +func interfaceNotifications(ch api.Channel, index interface_types.InterfaceIndex) { + fmt.Printf("Subscribing to notificaiton events for interface index %d\n", index) notifChan := make(chan api.Message, 100) @@ -225,27 +243,33 @@ func interfaceNotifications(ch api.Channel) { return } + // receive notifications + go func() { + for notif := range notifChan { + e := notif.(*interfaces.SwInterfaceEvent) + fmt.Printf("incoming event: %+v\n", e) + marshal(e) + } + }() + // generate some events in VPP err = ch.SendRequest(&interfaces.SwInterfaceSetFlags{ - SwIfIndex: 1, + SwIfIndex: index, + Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, }).ReceiveReply(&interfaces.SwInterfaceSetFlagsReply{}) if err != nil { logError(err, "setting interface flags") return } err = ch.SendRequest(&interfaces.SwInterfaceSetFlags{ - SwIfIndex: 1, - Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, + SwIfIndex: index, + Flags: 0, }).ReceiveReply(&interfaces.SwInterfaceSetFlagsReply{}) if err != nil { logError(err, "setting interface flags") return } - // receive one notification - notif := (<-notifChan).(*interfaces.SwInterfaceEvent) - fmt.Printf("incoming event: %+v\n", notif) - // disable interface events in VPP err = ch.SendRequest(&interfaces.WantInterfaceEvents{ PID: uint32(os.Getpid()), @@ -263,9 +287,22 @@ func interfaceNotifications(ch api.Channel) { return } + fmt.Println("OK") fmt.Println() } -func cleanString(str string) string { - return strings.Split(str, "\x00")[0] +func marshal(v interface{}) { + fmt.Printf("GO: %#v\n", v) + b, err := json.MarshalIndent(v, "", " ") + if err != nil { + panic(err) + } + fmt.Printf("JSON: %s\n", b) +} + +var errors []error + +func logError(err error, msg string) { + fmt.Printf("ERROR: %s: %v\n", msg, err) + errors = append(errors, err) } diff --git a/examples/stats-client/stats_api.go b/examples/stats-client/stats_api.go index cd039080..47516067 100644 --- a/examples/stats-client/stats_api.go +++ b/examples/stats-client/stats_api.go @@ -19,6 +19,7 @@ import ( "fmt" "log" "os" + "strconv" "strings" "time" @@ -39,11 +40,12 @@ var ( statsSocket = flag.String("socket", statsclient.DefaultSocketName, "Path to VPP stats socket") dumpAll = flag.Bool("all", false, "Dump all stats including ones with zero values") pollPeriod = flag.Duration("period", time.Second*5, "Polling interval period") + async = flag.Bool("async", false, "Use asynchronous connection") ) func init() { flag.Usage = func() { - fmt.Fprintf(os.Stderr, "%s: usage [ls|dump|poll|errors|interfaces|nodes|system|buffers] ...\n", os.Args[0]) + fmt.Fprintf(os.Stderr, "%s: usage [ls|dump|poll|errors|interfaces|nodes|system|buffers|memory|epoch] ...\n", os.Args[0]) flag.PrintDefaults() os.Exit(1) } @@ -53,16 +55,44 @@ func main() { flag.Parse() skipZeros := !*dumpAll - var patterns []string + patterns := make([]string, 0) + indexes := make([]uint32, 0) if flag.NArg() > 0 { - patterns = flag.Args()[1:] + for _, arg := range flag.Args()[1:] { + if index, err := strconv.Atoi(arg); err == nil { + indexes = append(indexes, uint32(index)) + continue + } + patterns = append(patterns, arg) + } } - client := statsclient.NewStatsClient(*statsSocket) - - c, err := core.ConnectStats(client) - if err != nil { - log.Fatalln("Connecting failed:", err) + var ( + client *statsclient.StatsClient + c *core.StatsConnection + err error + ) + + if *async { + var statsChan chan core.ConnectionEvent + client = statsclient.NewStatsClient(*statsSocket, statsclient.SetSocketRetryPeriod(1*time.Second), + statsclient.SetSocketRetryTimeout(10*time.Second)) + c, statsChan, err = core.AsyncConnectStats(client, core.DefaultMaxReconnectAttempts, core.DefaultReconnectInterval) + if err != nil { + log.Fatalln("Asynchronous connecting failed:", err) + } + e := <-statsChan + if e.State == core.Connected { + // OK + } else { + log.Fatalf("VPP stats asynchronous connection failed: %s\n", e.State.String()) + } + } else { + client = statsclient.NewStatsClient(*statsSocket) + c, err = core.ConnectStats(client) + if err != nil { + log.Fatalln("Connecting failed:", err) + } } defer c.Disconnect() @@ -114,10 +144,15 @@ func main() { } n := 0 for _, counter := range stats.Errors { - if skipZeros && counter.Value == 0 { + var sum uint32 + for _, valuePerWorker := range counter.Values { + sum += uint32(valuePerWorker) + } + + if skipZeros && sum == 0 { continue } - fmt.Printf(" - %v\n", counter) + fmt.Printf(" - %v %d (per worker: %v)\n", counter.CounterName, sum, counter.Values) n++ } fmt.Printf("Listed %d (%d) error counters\n", n, len(stats.Errors)) @@ -129,10 +164,17 @@ func main() { } fmt.Printf("Buffer stats: %+v\n", stats) + case "memory": + stats := new(api.MemoryStats) + if err := c.GetMemoryStats(stats); err != nil { + log.Fatalln("getting memory stats failed:", err) + } + fmt.Printf("Memory stats: %+v\n", stats) + case "dump": fmt.Printf("Dumping stats.. %s\n", strings.Join(patterns, " ")) - dumpStats(client, patterns, skipZeros) + dumpStats(client, patterns, indexes, skipZeros) case "poll": fmt.Printf("Polling stats.. %s\n", strings.Join(patterns, " ")) @@ -142,30 +184,67 @@ func main() { case "list", "ls", "": fmt.Printf("Listing stats.. %s\n", strings.Join(patterns, " ")) - listStats(client, patterns) + listStats(client, patterns, indexes) + + case "epoch", "e": + fmt.Printf("Getting epoch..\n") + + getEpoch(client) default: fmt.Printf("invalid command: %q\n", cmd) } } -func listStats(client adapter.StatsAPI, patterns []string) { - list, err := client.ListStats(patterns...) - if err != nil { - log.Fatalln("listing stats failed:", err) +func listStats(client adapter.StatsAPI, patterns []string, indexes []uint32) { + var err error + list := make([]adapter.StatIdentifier, 0) + if (len(patterns) == 0 && len(indexes) == 0) || len(patterns) != 0 { + list, err = client.ListStats(patterns...) + if err != nil { + log.Fatalln("listing stats failed:", err) + } + } + if len(indexes) != 0 { + dir, err := client.PrepareDirOnIndex(indexes...) + if err != nil { + log.Fatalln("listing stats failed:", err) + } + for _, onIndexSi := range dir.Entries { + list = append(list, onIndexSi.StatIdentifier) + } } - for _, stat := range list { - fmt.Printf(" - %v\n", stat) + fmt.Printf(" - %d\t %v\n", stat.Index, string(stat.Name)) } fmt.Printf("Listed %d stats\n", len(list)) } -func dumpStats(client adapter.StatsAPI, patterns []string, skipZeros bool) { - stats, err := client.DumpStats(patterns...) +func getEpoch(client adapter.StatsAPI) { + dir, err := client.PrepareDir() if err != nil { - log.Fatalln("dumping stats failed:", err) + log.Fatalln("failed to prepare dir in order to read epoch:", err) + } + d := *dir + fmt.Printf("Epoch %d\n", d.Epoch) +} + +func dumpStats(client adapter.StatsAPI, patterns []string, indexes []uint32, skipZeros bool) { + var err error + stats := make([]adapter.StatEntry, 0) + if (len(patterns) == 0 && len(indexes) == 0) || len(patterns) != 0 { + stats, err = client.DumpStats(patterns...) + if err != nil { + log.Fatalln("dumping stats failed:", err) + } + } + if len(indexes) != 0 { + dir, err := client.PrepareDirOnIndex(indexes...) + if err != nil { + log.Fatalln("dumping stats failed:", err) + } + stats = append(stats, dir.Entries...) } n := 0 @@ -199,17 +278,15 @@ func pollStats(client adapter.StatsAPI, patterns []string, skipZeros bool) { } fmt.Println() - select { - case <-tick: - if err := client.UpdateDir(dir); err != nil { - if err == adapter.ErrStatsDirStale { - if dir, err = client.PrepareDir(patterns...); err != nil { - log.Fatalln("preparing dir failed:", err) - } - continue + <-tick + if err := client.UpdateDir(dir); err != nil { + if err == adapter.ErrStatsDirStale { + if dir, err = client.PrepareDir(patterns...); err != nil { + log.Fatalln("preparing dir failed:", err) } - log.Fatalln("updating dir failed:", err) + continue } + log.Fatalln("updating dir failed:", err) } } } @@ -226,11 +303,9 @@ func pollSystem(client api.StatsProvider) { fmt.Printf("System stats: %+v\n", stats) fmt.Println() - select { - case <-tick: - if err := client.GetSystemStats(stats); err != nil { - log.Println("updating system stats failed:", err) - } + <-tick + if err := client.GetSystemStats(stats); err != nil { + log.Println("updating system stats failed:", err) } } } @@ -250,11 +325,9 @@ func pollInterfaces(client api.StatsProvider) { } fmt.Println() - select { - case <-tick: - if err := client.GetInterfaceStats(stats); err != nil { - log.Println("updating system stats failed:", err) - } + <-tick + if err := client.GetInterfaceStats(stats); err != nil { + log.Println("updating system stats failed:", err) } } } diff --git a/examples/stream-client/stream_client.go b/examples/stream-client/stream_client.go new file mode 100644 index 00000000..8f882bf8 --- /dev/null +++ b/examples/stream-client/stream_client.go @@ -0,0 +1,472 @@ +// Copyright (c) 2017 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. + +// stream-client is an example VPP management application that exercises the +// govpp API on real-world use-cases. +package main + +import ( + "context" + "flag" + "fmt" + "log" + "os" + "time" + + "github.com/alkiranet/govpp" + "github.com/alkiranet/govpp/adapter/socketclient" + "github.com/alkiranet/govpp/api" + interfaces "github.com/alkiranet/govpp/binapi/interface" + "github.com/alkiranet/govpp/binapi/interface_types" + "github.com/alkiranet/govpp/binapi/ip" + "github.com/alkiranet/govpp/binapi/ip_types" + "github.com/alkiranet/govpp/binapi/mactime" + "github.com/alkiranet/govpp/binapi/memclnt" + "github.com/alkiranet/govpp/binapi/vpe" + "github.com/alkiranet/govpp/core" +) + +var ( + sockAddr = flag.String("sock", socketclient.DefaultSocketName, "Path to VPP binary API socket file") +) + +func main() { + flag.Parse() + + fmt.Println("Starting stream client example") + fmt.Println() + + // connect to VPP asynchronously + conn, connEv, err := govpp.AsyncConnect(*sockAddr, core.DefaultMaxReconnectAttempts, core.DefaultReconnectInterval) + if err != nil { + log.Fatalln("ERROR:", err) + } + defer conn.Disconnect() + + // wait for Connected event + e := <-connEv + if e.State != core.Connected { + log.Fatalln("ERROR: connecting to VPP failed:", e.Error) + } + + // check compatibility of used messages + ch, err := conn.NewAPIChannel() + if err != nil { + log.Fatalln("ERROR: creating channel failed:", err) + } + defer ch.Close() + if err := ch.CheckCompatiblity(vpe.AllMessages()...); err != nil { + log.Fatalf("compatibility check failed: %v", err) + } + if err := ch.CheckCompatiblity(interfaces.AllMessages()...); err != nil { + log.Printf("compatibility check failed: %v", err) + } + + // process errors encountered during the example + defer func() { + if len(errors) > 0 { + fmt.Printf("finished with %d errors\n", len(errors)) + os.Exit(1) + } else { + fmt.Println("finished successfully") + } + }() + + // send and receive messages using stream (low-low level API) + stream, err := conn.NewStream(context.Background(), + core.WithRequestSize(50), + core.WithReplySize(50), + core.WithReplyTimeout(2*time.Second)) + if err != nil { + panic(err) + } + defer func() { + if err := stream.Close(); err != nil { + logError(err, "closing the stream") + } + }() + getVppVersion(stream) + idx := createLoopback(stream) + interfaceDump(stream) + addIPAddress(stream, idx) + //ipAddressDump(stream, idx) + //mactimeDump(stream) + interfaceNotifications(conn, stream, idx) +} + +func getVppVersion(stream api.Stream) { + fmt.Println("Retrieving version..") + + req := &vpe.ShowVersion{} + if err := stream.SendMsg(req); err != nil { + logError(err, "ShowVersion sending message") + return + } + recv, err := stream.RecvMsg() + if err != nil { + logError(err, "ShowVersion receive message") + return + } + recvMsg := recv.(*vpe.ShowVersionReply) + + fmt.Printf("Retrieved VPP version: %q\n", recvMsg.Version) + fmt.Println("OK") + fmt.Println() +} + +func createLoopback(stream api.Stream) (ifIdx interface_types.InterfaceIndex) { + fmt.Println("Creating the loopback interface..") + + req := &interfaces.CreateLoopback{} + if err := stream.SendMsg(req); err != nil { + logError(err, "CreateLoopback sending message") + return + } + recv, err := stream.RecvMsg() + if err != nil { + logError(err, "CreateLoopback receive message") + return + } + recvMsg := recv.(*interfaces.CreateLoopbackReply) + + fmt.Printf("Loopback interface index: %v\n", recvMsg.SwIfIndex) + fmt.Println("OK") + fmt.Println() + + return recvMsg.SwIfIndex +} + +func interfaceDump(stream api.Stream) { + fmt.Println("Dumping interfaces..") + + if err := stream.SendMsg(&interfaces.SwInterfaceDump{ + SwIfIndex: ^interface_types.InterfaceIndex(0), + }); err != nil { + logError(err, "SwInterfaceDump sending message") + return + } + if err := stream.SendMsg(&memclnt.ControlPing{}); err != nil { + logError(err, "ControlPing sending message") + return + } + +Loop: + for { + msg, err := stream.RecvMsg() + if err != nil { + logError(err, "SwInterfaceDump receiving message ") + return + } + + switch msg.(type) { + case *interfaces.SwInterfaceDetails: + fmt.Printf(" - SwInterfaceDetails: %+v\n", msg) + + case *memclnt.ControlPingReply: + fmt.Printf(" - ControlPingReply: %+v\n", msg) + break Loop + + default: + logError(err, "unexpected message") + return + } + } + + fmt.Println("OK") + fmt.Println() +} + +func addIPAddress(stream api.Stream, index interface_types.InterfaceIndex) { + fmt.Printf("Adding IP address to the interface index %d..\n", index) + + if err := stream.SendMsg(&interfaces.SwInterfaceAddDelAddress{ + SwIfIndex: index, + IsAdd: true, + Prefix: ip_types.AddressWithPrefix{ + Address: ip_types.Address{ + Af: ip_types.ADDRESS_IP4, + Un: ip_types.AddressUnionIP4(ip_types.IP4Address{10, 10, 0, uint8(index)}), + }, + Len: 32, + }, + }); err != nil { + logError(err, "SwInterfaceAddDelAddress sending message") + return + } + + recv, err := stream.RecvMsg() + if err != nil { + logError(err, "SwInterfaceAddDelAddressReply receiving message") + return + } + recvMsg := recv.(*interfaces.SwInterfaceAddDelAddressReply) + + fmt.Printf("Added IP address to interface: %v (return value: %d)\n", index, recvMsg.Retval) + fmt.Println("OK") + fmt.Println() +} + +func ipAddressDump(stream api.Stream, index interface_types.InterfaceIndex) { + fmt.Printf("Dumping IP addresses for interface index %d..\n", index) + + if err := stream.SendMsg(&ip.IPAddressDump{ + SwIfIndex: index, + }); err != nil { + logError(err, "IPAddressDump sending message") + return + } + if err := stream.SendMsg(&memclnt.ControlPing{}); err != nil { + logError(err, "ControlPing sending sending message") + return + } + +Loop: + for { + msg, err := stream.RecvMsg() + if err != nil { + logError(err, "IPAddressDump receiving message ") + return + } + + switch msg.(type) { + case *ip.IPAddressDetails: + fmt.Printf(" - IPAddressDetails: %+v\n", msg) + + case *memclnt.ControlPingReply: + fmt.Printf(" - ControlPingReply: %+v\n", msg) + break Loop + + default: + logError(err, "unexpected message") + return + } + } + + fmt.Println("OK") + fmt.Println() +} + +// Mactime dump uses MactimeDumpReply message as an end of the stream +// notification instead of the control ping. +func mactimeDump(stream api.Stream) { + fmt.Println("Sending mactime dump..") + + if err := stream.SendMsg(&mactime.MactimeDump{}); err != nil { + logError(err, "sending mactime dump") + return + } + +Loop: + for { + msg, err := stream.RecvMsg() + if err != nil { + logError(err, "MactimeDump receiving message") + return + } + + switch msg.(type) { + case *mactime.MactimeDetails: + fmt.Printf(" - MactimeDetails: %+v\n", msg) + + case *mactime.MactimeDumpReply: + fmt.Printf(" - MactimeDumpReply: %+v\n", msg) + break Loop + + default: + logError(err, "unexpected message") + return + } + } + + fmt.Println("OK") + fmt.Println() +} + +// interfaceNotifications shows the usage of notification API. Note that for notifications, +// you are supposed to create your own Go channel with your preferred buffer size. If the channel's +// buffer is full, the notifications will not be delivered into it. +func interfaceNotifications(conn api.Connection, stream api.Stream, index interface_types.InterfaceIndex) { + fmt.Printf("Subscribing to notificaiton events for interface index %d\n", index) + + ctx := context.Background() + + watcher, err := conn.WatchEvent(ctx, (*interfaces.SwInterfaceEvent)(nil)) + if err != nil { + logError(err, "watch interface events") + return + } else { + fmt.Println("watching events OK") + } + + //notifChan := make(chan api.Message, 100) + + // subscribe for specific notification message + /*sub, err := ch.SubscribeNotification(notifChan, (*interfaces.SwInterfaceEvent)(nil)) + if err != nil { + logError(err, "subscribing to interface events") + return + } else { + fmt.Println("subscribed to notifications OK") + }*/ + + // enable interface events in VPP + /*err = ch.SendRequest(&interfaces.WantInterfaceEvents{ + PID: 0, + EnableDisable: 1, + }).ReceiveReply(&interfaces.WantInterfaceEventsReply{}) + if err != nil { + logError(err, "enabling interface events") + return + } else { + fmt.Println("enabled interface events OK") + }*/ + // enable interface events in VPP + var reply interfaces.WantInterfaceEventsReply + if err := conn.Invoke(ctx, &interfaces.WantInterfaceEvents{ + //PID: uint32(os.Getpid()), + EnableDisable: 1, + }, &reply); err != nil { + logError(err, "enabling interface events") + return + } else { + fmt.Println("enabled interface events OK") + } + + /*err = ch.SendRequest(&interfaces.WantInterfaceEvents{ + //PID: uint32(os.Getpid()), + EnableDisable: 1, + }).ReceiveReply(&interfaces.WantInterfaceEventsReply{}) + if err != nil { + logError(err, "enabling interface events") + return + } else { + fmt.Println("enabled interface events OK") + }*/ + + // receive notifications + go func() { + for notif := range watcher.Events() { + e := notif.(*interfaces.SwInterfaceEvent) + fmt.Printf("incoming event: %+v\n", e) + } + fmt.Println("all events processed OK") + }() + + // generate some events in VPP + var setReply interfaces.SwInterfaceSetFlagsReply + if err := conn.Invoke(ctx, &interfaces.SwInterfaceSetFlags{ + SwIfIndex: index, + Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, + }, &setReply); err != nil { + logError(err, "setting interface flags") + return + } else if err = api.RetvalToVPPApiError(setReply.Retval); err != nil { + logError(err, "setting interface flags retval") + return + } + + setReply.Reset() + if err := conn.Invoke(ctx, &interfaces.SwInterfaceSetFlags{ + SwIfIndex: index, + Flags: 0, + }, &setReply); err != nil { + logError(err, "setting interface flags") + return + } else if err = api.RetvalToVPPApiError(setReply.Retval); err != nil { + logError(err, "setting interface flags retval") + return + } + + /*err = ch.SendRequest(&interfaces.SwInterfaceSetFlags{ + SwIfIndex: index, + Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, + }).ReceiveReply(&interfaces.SwInterfaceSetFlagsReply{}) + if err != nil { + logError(err, "setting interface flags") + return + } + err = ch.SendRequest(&interfaces.SwInterfaceSetFlags{ + SwIfIndex: index, + Flags: 0, + }).ReceiveReply(&interfaces.SwInterfaceSetFlagsReply{}) + if err != nil { + logError(err, "setting interface flags") + return + }*/ + + reply.Reset() + if err := conn.Invoke(ctx, &interfaces.WantInterfaceEvents{ + //PID: uint32(os.Getpid()), + EnableDisable: 0, + }, &reply); err != nil { + logError(err, "disabling interface events") + return + } else { + fmt.Println("disabling interface events OK") + } + + // disable interface events in VPP + /*err = ch.SendRequest(&interfaces.WantInterfaceEvents{ + //PID: uint32(os.Getpid()), + EnableDisable: 0, + }).ReceiveReply(&interfaces.WantInterfaceEventsReply{}) + if err != nil { + logError(err, "setting interface flags") + return + }*/ + + setReply.Reset() + if err := conn.Invoke(ctx, &interfaces.SwInterfaceSetFlags{ + SwIfIndex: index, + Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, + }, &setReply); err != nil { + logError(err, "setting interface flags") + return + } else if err = api.RetvalToVPPApiError(setReply.Retval); err != nil { + logError(err, "setting interface flags retval") + return + } + + /*err = ch.SendRequest(&interfaces.SwInterfaceSetFlags{ + SwIfIndex: index, + Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, + }).ReceiveReply(&interfaces.SwInterfaceSetFlagsReply{}) + if err != nil { + logError(err, "setting interface flags") + return + } else { + fmt.Println("disabled interface events OK") + }*/ + + // unsubscribe from delivery of the notifications + watcher.Close() + if err != nil { + logError(err, "closing interface events watcher") + return + } else { + fmt.Println("closing interface events watcher OK") + } + + fmt.Println("OK") + fmt.Println() + + time.Sleep(time.Second) +} + +var errors []error + +func logError(err error, msg string) { + fmt.Printf("ERROR: %s: %v\n", msg, err) + errors = append(errors, err) +} diff --git a/examples/union-example/union_example.go b/examples/union-example/union_example.go deleted file mode 100644 index eb629d4b..00000000 --- a/examples/union-example/union_example.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) 2018 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. - -// union-example is an example to show how to use unions in VPP binary API. -package main - -import ( - "bytes" - "fmt" - "log" - "net" - - "github.com/alkiranet/govpp/examples/binapi/ip" - "github.com/alkiranet/govpp/examples/binapi/ip_types" - - "github.com/lunixbochs/struc" -) - -func main() { - encodingExample() - usageExample() -} - -func encodingExample() { - // create union with IPv4 address - var unionIP4 ip.AddressUnion - unionIP4.SetIP4(ip.IP4Address{192, 168, 1, 10}) - - // use it in the Address type - addr := &ip.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(ip.IP4Address{192, 168, 1, 10}), - } - log.Printf("encoding union IPv4: %v", addr.Un.GetIP4()) - - // encode the address with union - data := encode(addr) - // decode the address with union - addr2 := decode(data) - - log.Printf("decoded union IPv4: %v", addr2.Un.GetIP4()) -} - -func encode(addr *ip.Address) []byte { - log.Printf("encoding address: %#v", addr) - buf := new(bytes.Buffer) - if err := struc.Pack(buf, addr); err != nil { - panic(err) - } - return buf.Bytes() -} - -func decode(data []byte) *ip.Address { - addr := new(ip.Address) - buf := bytes.NewReader(data) - if err := struc.Unpack(buf, addr); err != nil { - panic(err) - } - log.Printf("decoded address: %#v", addr) - return addr -} - -func usageExample() { - var convAddr = func(ip string) { - addr, err := ipToAddress(ip) - if err != nil { - log.Printf("converting ip %q failed: %v", ip, err) - } - fmt.Printf("% 0X\n", addr) - } - - convAddr("10.10.10.10") - convAddr("::1") - convAddr("") -} - -func ipToAddress(ipstr string) (addr ip.Address, err error) { - netIP := net.ParseIP(ipstr) - if netIP == nil { - return ip.Address{}, fmt.Errorf("invalid IP: %q", ipstr) - } - if ip4 := netIP.To4(); ip4 == nil { - addr.Af = ip_types.ADDRESS_IP6 - var ip6addr ip.IP6Address - copy(ip6addr[:], netIP.To16()) - addr.Un.SetIP6(ip6addr) - } else { - addr.Af = ip_types.ADDRESS_IP4 - var ip4addr ip.IP4Address - copy(ip4addr[:], ip4) - addr.Un.SetIP4(ip4addr) - } - return -} diff --git a/extras/.gitignore b/extras/.gitignore index 0647c0e4..d8134acb 100644 --- a/extras/.gitignore +++ b/extras/.gitignore @@ -3,3 +3,6 @@ libmemif/examples/gopacket/gopacket libmemif/examples/icmp-responder/icmp-responder libmemif/examples/jumbo-frames/jumbo-frames libmemif/examples/raw-data/raw-data +gomemif/examples/bridge/bridge +gomemif/examples/icmp_responder_cb/icmp_responder_cb +gomemif/examples/icmp_responder_poll/icmp_responder_poll diff --git a/extras/Makefile b/extras/Makefile index eae56276..bbd04d92 100644 --- a/extras/Makefile +++ b/extras/Makefile @@ -8,6 +8,9 @@ extras: cd libmemif/examples/icmp-responder && $(GO) build -v cd libmemif/examples/jumbo-frames && $(GO) build -v cd libmemif/examples/raw-data && $(GO) build -v + cd gomemif/examples/bridge && $(GO) build -v + cd gomemif/examples/icmp_responder_cb && $(GO) build -v + cd gomemif/examples/icmp_responder_poll && $(GO) build -v clean: @echo "=> cleaning extras" diff --git a/extras/go.mod b/extras/go.mod index cec17a93..27a9550c 100644 --- a/extras/go.mod +++ b/extras/go.mod @@ -1,8 +1,14 @@ module github.com/alkiranet/govpp/extras -go 1.12 +go 1.18 require ( github.com/google/gopacket v1.1.17 + github.com/pkg/profile v1.6.0 github.com/sirupsen/logrus v1.4.2 ) + +require ( + github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect + golang.org/x/sys v0.1.0 // indirect +) diff --git a/extras/go.sum b/extras/go.sum index 2bbea854..a197b63a 100644 --- a/extras/go.sum +++ b/extras/go.sum @@ -4,6 +4,8 @@ github.com/google/gopacket v1.1.17 h1:rMrlX2ZY2UbvT+sdz3+6J+pp2z+msCq9MxTU6ymxbB github.com/google/gopacket v1.1.17/go.mod h1:UdDNZ1OO62aGYVnPhxT1U6aI7ukYtA/kB8vaU0diBUM= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/pkg/profile v1.6.0 h1:hUDfIISABYI59DyeB3OTay/HxSRwTQ8rB/H83k6r5dM= +github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= @@ -15,6 +17,7 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190405154228-4b34438f7a67/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/extras/gomemif/README.rst b/extras/gomemif/README.rst new file mode 100644 index 00000000..d5554543 --- /dev/null +++ b/extras/gomemif/README.rst @@ -0,0 +1,50 @@ +.. _gomemif_doc: + +Gomemif library +======================= + +Memif library implemented in Go. The package contains 3 examples: Bridge and ICMP responder in interrupt and polling mode. + +setup and run +------------- +To Build all examples + +:: + + cd .. && make extras + +To Run ICMP responder in interrupt mode: + +:: + + DBGvpp# create interface memif id 0 master + DBGvpp# set int ip addr memif0/0 192.168.1.2/24 + DBGvpp# set int state memif0/0 up + + examples/icmp_responder_cb/icmp_responder_cb + gomemif# start + + DBGvpp# ping 192.168.1.1 + +To Run ICMP responder in polling mode: + +:: + + DBGvpp# create interface memif id 0 master + DBGvpp# set int ip addr memif0/0 192.168.1.2/24 + DBGvpp# set int state memif0/0 up + + examples/icmp_responder_poll/icmp_responder_poll + gomemif# start + + DBGvpp# ping 192.168.1.1 + +To Run Bridge: + +:: + + examples/bridge/bridge + gomemif# start + + + diff --git a/extras/gomemif/examples/bridge/bridge.go b/extras/gomemif/examples/bridge/bridge.go new file mode 100644 index 00000000..1cce483a --- /dev/null +++ b/extras/gomemif/examples/bridge/bridge.go @@ -0,0 +1,286 @@ +/* + *------------------------------------------------------------------ + * 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 main + +import ( + "bufio" + "flag" + "fmt" + "os" + "strings" + "sync" + "time" + + "github.com/pkg/profile" + "github.com/alkiranet/govpp/extras/gomemif/memif" +) + +func Disconnected(i *memif.Interface) error { + fmt.Println("Disconnected: ", i.GetName()) + + data, ok := i.GetPrivateData().(*interfaceData) + if !ok { + return fmt.Errorf("Invalid private data") + } + close(data.quitChan) // stop polling + close(data.errChan) + data.wg.Wait() // wait until polling stops, then continue disconnect + + return nil +} + +func Connected(i *memif.Interface) error { + fmt.Println("Connected: ", i.GetName()) + + data, ok := i.GetPrivateData().(*interfaceData) + if !ok { + return fmt.Errorf("Invalid private data") + } + data.errChan = make(chan error, 1) + data.quitChan = make(chan struct{}, 1) + data.wg.Add(1) + + go func(errChan chan<- error, quitChan <-chan struct{}, wg *sync.WaitGroup) { + defer wg.Done() + // allocate packet buffer + pkt := make([]byte, 2048) + // get rx queue + rxq0, err := i.GetRxQueue(0) + if err != nil { + errChan <- err + return + } + + // wait until both interfaces are connected + for !data.bri.IsConnected() { + time.Sleep(100 * time.Millisecond) + } + + // get bridged interfaces tx queue + txq0, err := data.bri.GetTxQueue(0) + if err != nil { + errChan <- err + return + } + for { + select { + case <-quitChan: // channel closed + return + default: + // read packet from shared memory + pktLen, err := rxq0.ReadPacket(pkt) + if pktLen > 0 { + // FIXME: prevent packet write if interface is disconencted + // write packet to shared memory + txq0.WritePacket(pkt[:pktLen]) + } else if err != nil { + errChan <- err + return + } + } + } + }(data.errChan, data.quitChan, &data.wg) + + return nil +} + +type interfaceData struct { + errChan chan error + quitChan chan struct{} + wg sync.WaitGroup + // bridged interface + bri *memif.Interface +} + +func interractiveHelp() { + fmt.Println("help - print this help") + fmt.Println("start - start connecting loop") + fmt.Println("show - print interface details") + fmt.Println("exit - exit the application") +} + +func newMemifInterface(socket *memif.Socket, id uint32, isMaster bool, name string) (*memif.Interface, *interfaceData, error) { + data := &interfaceData{} + args := &memif.Arguments{ + Id: id, + IsMaster: isMaster, + ConnectedFunc: Connected, + DisconnectedFunc: Disconnected, + PrivateData: data, + Name: name, + } + + i, err := socket.NewInterface(args) + if err != nil { + return nil, nil, fmt.Errorf("Failed to create interface on socket %s: %s", socket.GetFilename(), err) + } + + // slave attempts to connect to control socket + // to handle control communication call socket.StartPolling() + if !i.IsMaster() { + fmt.Println(args.Name, ": Connecting to control socket...") + for !i.IsConnecting() { + err = i.RequestConnection() + if err != nil { + /* TODO: check for ECONNREFUSED errno + * if error is ECONNREFUSED it may simply mean that master + * interface is not up yet, use i.RequestConnection() + */ + return nil, nil, fmt.Errorf("Failed to connect: ", err) + } + } + } + + return i, data, nil +} + +func printMemifInterfaceDetails(i *memif.Interface) { + fmt.Println(i.GetName(), ":") + fmt.Println("\trole: ", memif.RoleToString(i.IsMaster())) + fmt.Println("\tid: ", i.GetId()) + link := "down" + if i.IsConnected() { + link = "up" + } + fmt.Println("\tlink: ", link) + fmt.Println("\tremote: ", i.GetRemoteName()) + fmt.Println("\tpeer: ", i.GetPeerName()) + if i.IsConnected() { + mc := i.GetMemoryConfig() + fmt.Println("queue pairs: ", mc.NumQueuePairs) + fmt.Println("ring size: ", (1 << mc.Log2RingSize)) + fmt.Println("buffer size: ", mc.PacketBufferSize) + } +} + +func main() { + memifErrChan := make(chan error) + exitChan := make(chan struct{}) + var i0, i1 *memif.Interface + var d0, d1 *interfaceData + + cpuprof := flag.String("cpuprof", "", "cpu profiling output file") + memprof := flag.String("memprof", "", "mem profiling output file") + role := flag.String("role", "slave", "interface role") + name := flag.String("name", "gomemif", "interface name") + socketName := flag.String("socket", "", "control socket filename") + + flag.Parse() + + // profiling options + if *cpuprof != "" { + defer profile.Start(profile.CPUProfile, profile.ProfilePath(*cpuprof)).Stop() + } + if *memprof != "" { + defer profile.Start(profile.MemProfile, profile.ProfilePath(*memprof)).Stop() + } + + // memif options + var isMaster bool + switch *role { + case "slave": + isMaster = false + case "master": + isMaster = true + default: + fmt.Println("Invalid role") + return + } + + // create memif socket + socket, err := memif.NewSocket("gomemif_example", *socketName) + if err != nil { + fmt.Println("Failed to create socket: ", err) + return + } + + i0, d0, err = newMemifInterface(socket, 0, isMaster, *name) + if err != nil { + fmt.Println(err) + goto exit + } + + // TODO: update name + i1, d1, err = newMemifInterface(socket, 1, isMaster, *name) + if err != nil { + fmt.Println(err) + goto exit + } + + // set up bridge + d0.bri = i1 + d1.bri = i0 + + // user input goroutine + go func(exitChan chan<- struct{}) { + reader := bufio.NewReader(os.Stdin) + fmt.Println("GoMemif: Responder") + fmt.Println("-----------------------") + for { + fmt.Print("gomemif# ") + text, _ := reader.ReadString('\n') + // convert CRLF to LF + text = strings.Replace(text, "\n", "", -1) + switch text { + case "help": + interractiveHelp() + case "start": + // start polling for events on this socket + socket.StartPolling(memifErrChan) + case "show": + printMemifInterfaceDetails(i0) + printMemifInterfaceDetails(i1) + case "exit": + err = socket.StopPolling() + if err != nil { + fmt.Println("Failed to stop polling: ", err) + } + close(exitChan) + return + default: + fmt.Println("Unknown input") + } + } + }(exitChan) + + // main loop + for { + select { + case <-exitChan: + goto exit + case err, ok := <-memifErrChan: + if ok { + fmt.Println(err) + } + case err, ok := <-d0.errChan: + if ok { + fmt.Println(err) + } + case err, ok := <-d1.errChan: + if ok { + fmt.Println(err) + } + default: + continue + } + } + +exit: + socket.Delete() + close(memifErrChan) +} diff --git a/extras/gomemif/examples/icmp_responder_cb/icmp_responder_cb.go b/extras/gomemif/examples/icmp_responder_cb/icmp_responder_cb.go new file mode 100644 index 00000000..81cf89bf --- /dev/null +++ b/extras/gomemif/examples/icmp_responder_cb/icmp_responder_cb.go @@ -0,0 +1,331 @@ +/* + *------------------------------------------------------------------ + * 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 main + +import ( + "bufio" + "flag" + "fmt" + "net" + "os" + "strings" + "sync" + + "github.com/alkiranet/govpp/extras/gomemif/memif" + + "github.com/google/gopacket" + "github.com/google/gopacket/layers" + "github.com/pkg/profile" +) + +func Disconnected(i *memif.Interface) error { + fmt.Println("Disconnected: ", i.GetName()) + + data, ok := i.GetPrivateData().(*interfaceData) + if !ok { + return fmt.Errorf("Invalid private data") + } + close(data.quitChan) // stop polling + close(data.errChan) + data.wg.Wait() // wait until polling stops, then continue disconnect + + return nil +} + +func Responder(i *memif.Interface) error { + data, ok := i.GetPrivateData().(*interfaceData) + if !ok { + return fmt.Errorf("Invalid private data") + } + data.errChan = make(chan error, 1) + data.quitChan = make(chan struct{}, 1) + data.wg.Add(1) + + // allocate packet buffers + pkt := i.Pkt + var tx_bufs []memif.MemifPacketBuffer + for i := range pkt { + pkt[i].Buf = make([]byte, 2048) + pkt[i].Buflen = 2048 + } + // get rx queue + rxq0, err := i.GetRxQueue(0) + if err != nil { + return err + } + // get tx queue + txq0, err := i.GetTxQueue(0) + if err != nil { + return err + } + _ = txq0 + + nPackets, err := rxq0.Rx_burst(pkt) + if err != nil { + return err + } + + fmt.Println(nPackets) + rxq0.Refill(int(nPackets)) + _ = err + + for i := 0; i < int(nPackets); i++ { + gopkt := gopacket.NewPacket(pkt[i].Buf[:pkt[i].Buflen], layers.LayerTypeEthernet, gopacket.NoCopy) + etherLayer := gopkt.Layer(layers.LayerTypeEthernet) + + if etherLayer.(*layers.Ethernet).EthernetType == layers.EthernetTypeARP { + rEth := layers.Ethernet{ + SrcMAC: net.HardwareAddr{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}, + DstMAC: net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + + EthernetType: layers.EthernetTypeARP, + } + rArp := layers.ARP{ + AddrType: layers.LinkTypeEthernet, + Protocol: layers.EthernetTypeIPv4, + HwAddressSize: 6, + ProtAddressSize: 4, + Operation: layers.ARPReply, + SourceHwAddress: []byte(net.HardwareAddr{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}), + SourceProtAddress: []byte("\xc0\xa8\x01\x01"), + DstHwAddress: []byte(net.HardwareAddr{0x02, 0xfe, 0x08, 0x88, 0x45, 0x7f}), + DstProtAddress: []byte("\xc0\xa8\x01\x02"), + } + buf := gopacket.NewSerializeBuffer() + opts := gopacket.SerializeOptions{ + FixLengths: true, + ComputeChecksums: true, + } + gopacket.SerializeLayers(buf, opts, &rEth, &rArp) + // write packet to shared memory + txq0.WritePacket(buf.Bytes()) + } + if etherLayer.(*layers.Ethernet).EthernetType == layers.EthernetTypeIPv4 { + ipLayer := gopkt.Layer(layers.LayerTypeIPv4) + if ipLayer == nil { + fmt.Println("Missing IPv4 layer.") + + } + ipv4, _ := ipLayer.(*layers.IPv4) + if ipv4.Protocol != layers.IPProtocolICMPv4 { + fmt.Println("Not ICMPv4 protocol.") + } + icmpLayer := gopkt.Layer(layers.LayerTypeICMPv4) + if icmpLayer == nil { + fmt.Println("Missing ICMPv4 layer.") + } + icmp, _ := icmpLayer.(*layers.ICMPv4) + if icmp.TypeCode.Type() != layers.ICMPv4TypeEchoRequest { + fmt.Println("Not ICMPv4 echo request.") + } + + // Build packet layers. + ethResp := layers.Ethernet{ + DstMAC: net.HardwareAddr{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}, + SrcMAC: []byte(net.HardwareAddr{0x02, 0xfe, 0x08, 0x88, 0x45, 0x7f}), + + EthernetType: layers.EthernetTypeIPv4, + } + ipv4Resp := layers.IPv4{ + Version: 4, + IHL: 5, + TOS: 0, + Id: 0, + Flags: 0, + FragOffset: 0, + TTL: 255, + Protocol: layers.IPProtocolICMPv4, + SrcIP: []byte("\xc0\xa8\x01\x01"), + DstIP: []byte("\xc0\xa8\x01\x02"), + } + icmpResp := layers.ICMPv4{ + TypeCode: layers.CreateICMPv4TypeCode(layers.ICMPv4TypeEchoReply, 0), + Id: icmp.Id, + Seq: icmp.Seq, + } + + // Set up buffer and options for serialization. + buf := gopacket.NewSerializeBuffer() + opts := gopacket.SerializeOptions{ + FixLengths: true, + ComputeChecksums: true, + } + gopacket.SerializeLayers(buf, opts, ðResp, &ipv4Resp, &icmpResp, + gopacket.Payload(icmp.Payload)) + // write packet to shared memory + tx_bufs = append(tx_bufs, memif.MemifPacketBuffer{Buf: buf.Bytes(), Buflen: len(buf.Bytes())}) + + } + } + txq0.Tx_burst(tx_bufs) + return nil + +} +func Connected(i *memif.Interface) error { + data, ok := i.GetPrivateData().(*interfaceData) + _ = data + if !ok { + return fmt.Errorf("Invalid private data") + } + // allocate packet buffer + i.Pkt = make([]memif.MemifPacketBuffer, 64) + + // get rx queue + rxq0, err := i.GetRxQueue(0) + _ = err + rxq0.Refill(0) + + return nil +} + +type interfaceData struct { + errChan chan error + quitChan chan struct{} + wg sync.WaitGroup +} + +func interractiveHelp() { + fmt.Println("help - print this help") + fmt.Println("start - start connecting loop") + fmt.Println("show - print interface details") + fmt.Println("exit - exit the application") +} + +func main() { + cpuprof := flag.String("cpuprof", "", "cpu profiling output file") + memprof := flag.String("memprof", "", "mem profiling output file") + role := flag.String("role", "slave", "interface role") + name := flag.String("name", "gomemif", "interface name") + socketName := flag.String("socket", "/run/vpp/memif.sock", "control socket filename") + + flag.Parse() + + if *cpuprof != "" { + defer profile.Start(profile.CPUProfile, profile.ProfilePath(*cpuprof)).Stop() + } + if *memprof != "" { + defer profile.Start(profile.MemProfile, profile.ProfilePath(*memprof)).Stop() + } + + memifErrChan := make(chan error) + exitChan := make(chan struct{}) + + var isMaster bool + switch *role { + case "slave": + isMaster = false + case "master": + isMaster = true + default: + fmt.Println("Invalid role") + return + } + + fmt.Println("GoMemif: Responder") + fmt.Println("-----------------------") + + socket, err := memif.NewSocket("gomemif_example", *socketName) + if err != nil { + fmt.Println("Failed to create socket: ", err) + return + } + + data := interfaceData{} + args := &memif.Arguments{ + IsMaster: isMaster, + ConnectedFunc: Connected, + DisconnectedFunc: Disconnected, + PrivateData: &data, + Name: *name, + InterruptFunc: Responder, + } + + i, err := socket.NewInterface(args) + if err != nil { + fmt.Println("Failed to create interface on socket %s: %s", socket.GetFilename(), err) + goto exit + } + + // slave attempts to connect to control socket + // to handle control communication call socket.StartPolling() + if !i.IsMaster() { + fmt.Println(args.Name, ": Connecting to control socket...") + for !i.IsConnecting() { + err = i.RequestConnection() + if err != nil { + /* TODO: check for ECONNREFUSED errno + * if error is ECONNREFUSED it may simply mean that master + * interface is not up yet, use i.RequestConnection() + */ + fmt.Println("Failed to connect: ", err) + goto exit + } + } + } + + go func(exitChan chan<- struct{}) { + reader := bufio.NewReader(os.Stdin) + + for { + fmt.Print("gomemif# ") + text, _ := reader.ReadString('\n') + // convert CRLF to LF + text = strings.Replace(text, "\n", "", -1) + switch text { + case "help": + interractiveHelp() + case "start": + // start polling for events on this socket + socket.StartPolling(memifErrChan) + case "show": + fmt.Println("remote: ", i.GetRemoteName()) + fmt.Println("peer: ", i.GetPeerName()) + case "exit": + err = socket.StopPolling() + if err != nil { + fmt.Println("Failed to stop polling: ", err) + } + close(exitChan) + return + default: + fmt.Println("Unknown input") + } + } + }(exitChan) + + for { + select { + case <-exitChan: + goto exit + case err, ok := <-memifErrChan: + if ok { + fmt.Println(err) + } + case err, ok := <-data.errChan: + if ok { + fmt.Println(err) + } + default: + continue + } + } + +exit: + socket.Delete() + close(memifErrChan) +} diff --git a/extras/gomemif/examples/icmp_responder_poll/icmp_responder_poll.go b/extras/gomemif/examples/icmp_responder_poll/icmp_responder_poll.go new file mode 100644 index 00000000..9bbb79ab --- /dev/null +++ b/extras/gomemif/examples/icmp_responder_poll/icmp_responder_poll.go @@ -0,0 +1,317 @@ +/* + *------------------------------------------------------------------ + * 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 main + +import ( + "bufio" + "flag" + "fmt" + "net" + "os" + "strings" + "sync" + + "github.com/alkiranet/govpp/extras/gomemif/memif" + + "github.com/google/gopacket" + "github.com/google/gopacket/layers" + "github.com/pkg/profile" +) + +func Disconnected(i *memif.Interface) error { + fmt.Println("Disconnected: ", i.GetName()) + + data, ok := i.GetPrivateData().(*interfaceData) + if !ok { + return fmt.Errorf("Invalid private data") + } + close(data.quitChan) // stop polling + close(data.errChan) + data.wg.Wait() // wait until polling stops, then continue disconnect + + return nil +} + +func Connected(i *memif.Interface) error { + fmt.Println("Connected: ", i.GetName()) + + data, ok := i.GetPrivateData().(*interfaceData) + if !ok { + return fmt.Errorf("Invalid private data") + } + data.errChan = make(chan error, 1) + data.quitChan = make(chan struct{}, 1) + data.wg.Add(1) + + go func(errChan chan<- error, quitChan <-chan struct{}, wg *sync.WaitGroup) { + defer wg.Done() + // allocate packet buffer + pkt := make([]byte, 2048) + // get rx queue + rxq0, err := i.GetRxQueue(0) + if err != nil { + errChan <- err + return + } + // get tx queue + txq0, err := i.GetTxQueue(0) + if err != nil { + errChan <- err + return + } + for { + select { + case <-quitChan: // channel closed + return + default: + // read packet from shared memory + pktLen, err := rxq0.ReadPacket(pkt) + if pktLen > 0 { + fmt.Printf("pktLen: %d\n", pktLen) + gopkt := gopacket.NewPacket(pkt[:pktLen], layers.LayerTypeEthernet, gopacket.NoCopy) + etherLayer := gopkt.Layer(layers.LayerTypeEthernet) + if etherLayer.(*layers.Ethernet).EthernetType == layers.EthernetTypeARP { + + rEth := layers.Ethernet{ + SrcMAC: net.HardwareAddr{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}, + DstMAC: net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + EthernetType: layers.EthernetTypeARP, + } + rArp := layers.ARP{ + AddrType: layers.LinkTypeEthernet, + Protocol: layers.EthernetTypeIPv4, + HwAddressSize: 6, + ProtAddressSize: 4, + Operation: layers.ARPReply, + SourceHwAddress: []byte(net.HardwareAddr{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}), + SourceProtAddress: []byte("\xc0\xa8\x01\x01"), + DstHwAddress: []byte(net.HardwareAddr{0x02, 0xfe, 0x08, 0x88, 0x45, 0x7f}), + DstProtAddress: []byte("\xc0\xa8\x01\x02"), + } + buf := gopacket.NewSerializeBuffer() + opts := gopacket.SerializeOptions{ + FixLengths: true, + ComputeChecksums: true, + } + gopacket.SerializeLayers(buf, opts, &rEth, &rArp) + // write packet to shared memory + txq0.WritePacket(buf.Bytes()) + } + + if etherLayer.(*layers.Ethernet).EthernetType == layers.EthernetTypeIPv4 { + ipLayer := gopkt.Layer(layers.LayerTypeIPv4) + if ipLayer == nil { + fmt.Println("Missing IPv4 layer.") + + } + ipv4, _ := ipLayer.(*layers.IPv4) + if ipv4.Protocol != layers.IPProtocolICMPv4 { + fmt.Println("Not ICMPv4 protocol.") + } + icmpLayer := gopkt.Layer(layers.LayerTypeICMPv4) + if icmpLayer == nil { + fmt.Println("Missing ICMPv4 layer.") + } + icmp, _ := icmpLayer.(*layers.ICMPv4) + if icmp.TypeCode.Type() != layers.ICMPv4TypeEchoRequest { + fmt.Println("Not ICMPv4 echo request.") + } + fmt.Println("Received an ICMPv4 echo request.") + + // Build packet layers. + ethResp := layers.Ethernet{ + DstMAC: net.HardwareAddr{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}, + //DstMAC: net.HardwareAddr{0x02, 0xfe, 0xa8, 0x77, 0xaf, 0x20}, + SrcMAC: []byte(net.HardwareAddr{0x02, 0xfe, 0x08, 0x88, 0x45, 0x7f}), + + EthernetType: layers.EthernetTypeIPv4, + } + ipv4Resp := layers.IPv4{ + Version: 4, + IHL: 5, + TOS: 0, + Id: 0, + Flags: 0, + FragOffset: 0, + TTL: 255, + Protocol: layers.IPProtocolICMPv4, + SrcIP: []byte("\xc0\xa8\x01\x01"), + DstIP: []byte("\xc0\xa8\x01\x02"), + } + icmpResp := layers.ICMPv4{ + TypeCode: layers.CreateICMPv4TypeCode(layers.ICMPv4TypeEchoReply, 0), + Id: icmp.Id, + Seq: icmp.Seq, + } + + // Set up buffer and options for serialization. + buf := gopacket.NewSerializeBuffer() + opts := gopacket.SerializeOptions{ + FixLengths: true, + ComputeChecksums: true, + } + gopacket.SerializeLayers(buf, opts, ðResp, &ipv4Resp, &icmpResp, + gopacket.Payload(icmp.Payload)) + // write packet to shared memory + txq0.WritePacket(buf.Bytes()) + } + } else if err != nil { + errChan <- err + return + } + } + } + }(data.errChan, data.quitChan, &data.wg) + + return nil +} + +type interfaceData struct { + errChan chan error + quitChan chan struct{} + wg sync.WaitGroup +} + +func interractiveHelp() { + fmt.Println("help - print this help") + fmt.Println("start - start connecting loop") + fmt.Println("show - print interface details") + fmt.Println("exit - exit the application") +} + +func main() { + cpuprof := flag.String("cpuprof", "", "cpu profiling output file") + memprof := flag.String("memprof", "", "mem profiling output file") + role := flag.String("role", "slave", "interface role") + name := flag.String("name", "gomemif", "interface name") + socketName := flag.String("socket", "", "control socket filename") + + flag.Parse() + + if *cpuprof != "" { + defer profile.Start(profile.CPUProfile, profile.ProfilePath(*cpuprof)).Stop() + } + if *memprof != "" { + defer profile.Start(profile.MemProfile, profile.ProfilePath(*memprof)).Stop() + } + + memifErrChan := make(chan error) + exitChan := make(chan struct{}) + + var isMaster bool + switch *role { + case "slave": + isMaster = false + case "master": + isMaster = true + default: + fmt.Println("Invalid role") + return + } + + fmt.Println("GoMemif: Responder") + fmt.Println("-----------------------") + + socket, err := memif.NewSocket("gomemif_example", *socketName) + if err != nil { + fmt.Println("Failed to create socket: ", err) + return + } + + data := interfaceData{} + args := &memif.Arguments{ + IsMaster: isMaster, + ConnectedFunc: Connected, + DisconnectedFunc: Disconnected, + PrivateData: &data, + Name: *name, + } + + i, err := socket.NewInterface(args) + if err != nil { + fmt.Println("Failed to create interface on socket %s: %s", socket.GetFilename(), err) + goto exit + } + + // slave attempts to connect to control socket + // to handle control communication call socket.StartPolling() + if !i.IsMaster() { + fmt.Println(args.Name, ": Connecting to control socket...") + for !i.IsConnecting() { + err = i.RequestConnection() + if err != nil { + /* TODO: check for ECONNREFUSED errno + * if error is ECONNREFUSED it may simply mean that master + * interface is not up yet, use i.RequestConnection() + */ + fmt.Println("Failed to connect: ", err) + goto exit + } + } + } + + go func(exitChan chan<- struct{}) { + reader := bufio.NewReader(os.Stdin) + for { + fmt.Print("gomemif# ") + text, _ := reader.ReadString('\n') + // convert CRLF to LF + text = strings.Replace(text, "\n", "", -1) + switch text { + case "help": + interractiveHelp() + case "start": + // start polling for events on this socket + socket.StartPolling(memifErrChan) + case "show": + fmt.Println("remote: ", i.GetRemoteName()) + fmt.Println("peer: ", i.GetPeerName()) + case "exit": + err = socket.StopPolling() + if err != nil { + fmt.Println("Failed to stop polling: ", err) + } + close(exitChan) + return + default: + fmt.Println("Unknown input") + } + } + }(exitChan) + + for { + select { + case <-exitChan: + goto exit + case err, ok := <-memifErrChan: + if ok { + fmt.Println(err) + } + case err, ok := <-data.errChan: + if ok { + fmt.Println(err) + } + default: + continue + } + } + +exit: + socket.Delete() + close(memifErrChan) +} diff --git a/extras/gomemif/memif/control_channel.go b/extras/gomemif/memif/control_channel.go new file mode 100644 index 00000000..c7aa3c31 --- /dev/null +++ b/extras/gomemif/memif/control_channel.go @@ -0,0 +1,1017 @@ +/* + *------------------------------------------------------------------ + * 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 memif + +import ( + "bytes" + "container/list" + "encoding/binary" + "fmt" + "os" + "sync" + "syscall" +) + +const maxEpollEvents = 1 +const maxControlLen = 256 + +const errorFdNotFound = "fd not found" + +// controlMsg represents a message used in communication between memif peers +type controlMsg struct { + Buffer *bytes.Buffer + Fd int +} + +// listener represents a listener functionality of UNIX domain socket +type listener struct { + socket *Socket + event syscall.EpollEvent +} + +// controlChannel represents a communication channel between memif peers +// backed by UNIX domain socket +type controlChannel struct { + listRef *list.Element + socket *Socket + i *Interface + event syscall.EpollEvent + data [msgSize]byte + control [maxControlLen]byte + controlLen int + msgQueue []controlMsg + isConnected bool +} + +// Socket represents a UNIX domain socket used for communication +// between memif peers +type Socket struct { + appName string + filename string + listener *listener + interfaceList *list.List + ccList *list.List + epfd int + interruptfd int + wakeEvent syscall.EpollEvent + stopPollChan chan struct{} + wg sync.WaitGroup +} + +type interrupt struct { + socket *Socket + event syscall.EpollEvent +} + +type memifInterrupt struct { + connection *Socket + qid uint16 +} + +// StopPolling stops polling events on the socket +func (socket *Socket) StopPolling() error { + if socket.stopPollChan != nil { + // stop polling msg + close(socket.stopPollChan) + // wake epoll + buf := make([]byte, 8) + binary.PutUvarint(buf, 1) + n, err := syscall.Write(int(socket.wakeEvent.Fd), buf[:]) + if err != nil { + return err + } + if n != 8 { + return fmt.Errorf("Failed to write to eventfd") + } + // wait until polling is stopped + socket.wg.Wait() + } + + return nil +} + +// StartPolling starts polling and handling events on the socket, +// enabling communication between memif peers +func (socket *Socket) StartPolling(errChan chan<- error) { + socket.stopPollChan = make(chan struct{}) + socket.wg.Add(1) + go func() { + var events [maxEpollEvents]syscall.EpollEvent + defer socket.wg.Done() + + for { + select { + case <-socket.stopPollChan: + return + default: + num, err := syscall.EpollWait(socket.epfd, events[:], -1) + if err != nil { + if err == syscall.EINTR { + continue + } else { + errChan <- fmt.Errorf("EpollWait: ", err) + return + } + + } + + for ev := 0; ev < num; ev++ { + if events[0].Fd == socket.wakeEvent.Fd { + continue + } + err = socket.handleEvent(&events[0]) + if err != nil { + errChan <- fmt.Errorf("handleEvent: ", err) + } + } + } + } + }() +} + +// addEvent adds event to epoll instance associated with the socket +func (socket *Socket) addEvent(event *syscall.EpollEvent) error { + err := syscall.EpollCtl(socket.epfd, syscall.EPOLL_CTL_ADD, int(event.Fd), event) + if err != nil { + return fmt.Errorf("EpollCtl: %s", err) + } + return nil +} + +// addEvent deletes event to epoll instance associated with the socket +func (socket *Socket) delEvent(event *syscall.EpollEvent) error { + err := syscall.EpollCtl(socket.epfd, syscall.EPOLL_CTL_DEL, int(event.Fd), event) + if err != nil { + return fmt.Errorf("EpollCtl: %s", err) + } + return nil +} + +// Delete deletes the socket +func (socket *Socket) Delete() (err error) { + for elt := socket.ccList.Front(); elt != nil; elt = elt.Next() { + cc, ok := elt.Value.(*controlChannel) + if ok { + err = cc.close(true, "Socket deleted") + if err != nil { + return nil + } + } + } + for elt := socket.interfaceList.Front(); elt != nil; elt = elt.Next() { + i, ok := elt.Value.(*Interface) + if ok { + err = i.Delete() + if err != nil { + return err + } + } + } + + if socket.listener != nil { + err = socket.listener.close() + if err != nil { + return err + } + err = os.Remove(socket.filename) + if err != nil { + return nil + } + } + + err = socket.delEvent(&socket.wakeEvent) + if err != nil { + return fmt.Errorf("Failed to delete event: ", err) + } + + syscall.Close(socket.epfd) + + return nil +} + +// NewSocket returns a new Socket +func NewSocket(appName string, filename string) (socket *Socket, err error) { + socket = &Socket{ + appName: appName, + filename: filename, + interfaceList: list.New(), + ccList: list.New(), + } + if socket.filename == "" { + socket.filename = DefaultSocketFilename + } + + socket.epfd, _ = syscall.EpollCreate1(0) + + efd, err := eventFd() + socket.wakeEvent = syscall.EpollEvent{ + Events: syscall.EPOLLIN | syscall.EPOLLERR | syscall.EPOLLHUP, + Fd: int32(efd), + } + err = socket.addEvent(&socket.wakeEvent) + if err != nil { + return nil, fmt.Errorf("Failed to add event: ", err) + } + + return socket, nil +} + +// handleEvent handles epoll event +func (socket *Socket) handleEvent(event *syscall.EpollEvent) error { + if socket.listener != nil && socket.listener.event.Fd == event.Fd { + return socket.listener.handleEvent(event) + } + intf := socket.interfaceList.Back().Value.(*Interface) + if intf.args.InterruptFunc != nil { + if int(event.Fd) == int(intf.args.InterruptFd) { + intf.onInterrupt(intf) + return nil + } + } + + for elt := socket.ccList.Front(); elt != nil; elt = elt.Next() { + cc, ok := elt.Value.(*controlChannel) + if ok { + if cc.event.Fd == event.Fd { + return cc.handleEvent(event) + } + } + } + + return fmt.Errorf(errorFdNotFound) +} + +func (socket *Socket) addInterrupt(fd int) (err error) { + l := &interrupt{ + // we will need this to look up master interface by id + socket: socket, + } + + l.event = syscall.EpollEvent{ + Events: syscall.EPOLLIN, + Fd: int32(fd), + } + err = socket.addEvent(&l.event) + if err != nil { + return fmt.Errorf("Failed to add event: ", err) + } + + return nil + +} + +// handleEvent handles epoll event for listener +func (l *listener) handleEvent(event *syscall.EpollEvent) error { + // hang up + if (event.Events & syscall.EPOLLHUP) == syscall.EPOLLHUP { + err := l.close() + if err != nil { + return fmt.Errorf("Failed to close listener after hang up event: ", err) + } + return fmt.Errorf("Hang up: ", l.socket.filename) + } + + // error + if (event.Events & syscall.EPOLLERR) == syscall.EPOLLERR { + err := l.close() + if err != nil { + return fmt.Errorf("Failed to close listener after receiving an error event: ", err) + } + return fmt.Errorf("Received error event on listener ", l.socket.filename) + } + + // read message + if (event.Events & syscall.EPOLLIN) == syscall.EPOLLIN { + newFd, _, err := syscall.Accept(int(l.event.Fd)) + if err != nil { + return fmt.Errorf("Accept: %s", err) + } + + cc, err := l.socket.addControlChannel(newFd, nil) + if err != nil { + return fmt.Errorf("Failed to add control channel: %s", err) + } + + err = cc.msgEnqHello() + if err != nil { + return fmt.Errorf("msgEnqHello: %s", err) + } + + err = cc.sendMsg() + if err != nil { + return err + } + + return nil + } + + return fmt.Errorf("Unexpected event: ", event.Events) +} + +// handleEvent handles epoll event for control channel +func (cc *controlChannel) handleEvent(event *syscall.EpollEvent) error { + var size int + var err error + + // hang up + if (event.Events & syscall.EPOLLHUP) == syscall.EPOLLHUP { + // close cc, don't send msg + err := cc.close(false, "") + if err != nil { + return fmt.Errorf("Failed to close control channel after hang up event: ", err) + } + return fmt.Errorf("Hang up: ", cc.i.GetName()) + } + + if (event.Events & syscall.EPOLLERR) == syscall.EPOLLERR { + // close cc, don't send msg + err := cc.close(false, "") + if err != nil { + return fmt.Errorf("Failed to close control channel after receiving an error event: ", err) + } + return fmt.Errorf("Received error event on control channel ", cc.i.GetName()) + } + + if (event.Events & syscall.EPOLLIN) == syscall.EPOLLIN { + size, cc.controlLen, _, _, err = syscall.Recvmsg(int(cc.event.Fd), cc.data[:], cc.control[:], 0) + if err != nil { + return fmt.Errorf("recvmsg: %s", err) + } + if size != msgSize { + return fmt.Errorf("invalid message size %d", size) + } + + err = cc.parseMsg() + if err != nil { + return err + } + + err = cc.sendMsg() + if err != nil { + return err + } + + return nil + } + + return fmt.Errorf("Unexpected event: ", event.Events) +} + +// close closes the listener +func (l *listener) close() error { + err := l.socket.delEvent(&l.event) + if err != nil { + return fmt.Errorf("Failed to del event: ", err) + } + err = syscall.Close(int(l.event.Fd)) + if err != nil { + return fmt.Errorf("Failed to close socket: ", err) + } + return nil +} + +// AddListener adds a lisntener to the socket. The fd must describe a +// UNIX domain socket already bound to a UNIX domain filename and +// marked as listener +func (socket *Socket) AddListener(fd int) (err error) { + l := &listener{ + // we will need this to look up master interface by id + socket: socket, + } + + l.event = syscall.EpollEvent{ + Events: syscall.EPOLLIN | syscall.EPOLLERR | syscall.EPOLLHUP, + Fd: int32(fd), + } + err = socket.addEvent(&l.event) + if err != nil { + return fmt.Errorf("Failed to add event: ", err) + } + + socket.listener = l + + return nil +} + +// addListener creates new UNIX domain socket, binds it to the address +// and marks it as listener +func (socket *Socket) addListener() (err error) { + // create socket + fd, err := syscall.Socket(syscall.AF_UNIX, syscall.SOCK_SEQPACKET, 0) + if err != nil { + return fmt.Errorf("Failed to create UNIX domain socket") + } + usa := &syscall.SockaddrUnix{Name: socket.filename} + // Bind to address and start listening + err = syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_PASSCRED, 1) + if err != nil { + return fmt.Errorf("Failed to set socket option %s : %v", socket.filename, err) + } + err = syscall.Bind(fd, usa) + if err != nil { + return fmt.Errorf("Failed to bind socket %s : %v", socket.filename, err) + } + err = syscall.Listen(fd, syscall.SOMAXCONN) + if err != nil { + return fmt.Errorf("Failed to listen on socket %s : %v", socket.filename, err) + } + + return socket.AddListener(fd) +} + +// close closes a control channel, if the control channel is assigned an +// interface, the interface is disconnected +func (cc *controlChannel) close(sendMsg bool, str string) (err error) { + if sendMsg == true { + // first clear message queue so that the disconnect + // message is the only message in queue + cc.msgQueue = []controlMsg{} + cc.msgEnqDisconnect(str) + + err = cc.sendMsg() + if err != nil { + return err + } + } + + err = cc.socket.delEvent(&cc.event) + if err != nil { + return fmt.Errorf("Failed to del event: ", err) + } + + // remove referance form socket + cc.socket.ccList.Remove(cc.listRef) + + if cc.i != nil { + err = cc.i.disconnect() + if err != nil { + return fmt.Errorf("Interface Disconnect: ", err) + } + } + + return nil +} + +// addControlChannel returns a new controlChannel and adds it to the socket +func (socket *Socket) addControlChannel(fd int, i *Interface) (*controlChannel, error) { + cc := &controlChannel{ + socket: socket, + i: i, + isConnected: false, + } + + var err error + + cc.event = syscall.EpollEvent{ + Events: syscall.EPOLLIN | syscall.EPOLLERR | syscall.EPOLLHUP, + Fd: int32(fd), + } + err = socket.addEvent(&cc.event) + if err != nil { + return nil, fmt.Errorf("Failed to add event: ", err) + } + + cc.listRef = socket.ccList.PushBack(cc) + + return cc, nil +} + +func (cc *controlChannel) msgEnqAck() (err error) { + buf := new(bytes.Buffer) + err = binary.Write(buf, binary.LittleEndian, msgTypeAck) + + msg := controlMsg{ + Buffer: buf, + Fd: -1, + } + + cc.msgQueue = append(cc.msgQueue, msg) + + return nil +} + +func (cc *controlChannel) msgEnqHello() (err error) { + hello := MsgHello{ + VersionMin: Version, + VersionMax: Version, + MaxRegion: 255, + MaxRingM2S: 255, + MaxRingS2M: 255, + MaxLog2RingSize: 14, + } + + copy(hello.Name[:], []byte(cc.socket.appName)) + + buf := new(bytes.Buffer) + err = binary.Write(buf, binary.LittleEndian, msgTypeHello) + err = binary.Write(buf, binary.LittleEndian, hello) + + msg := controlMsg{ + Buffer: buf, + Fd: -1, + } + + cc.msgQueue = append(cc.msgQueue, msg) + + return nil +} + +func (cc *controlChannel) parseHello() (err error) { + var hello MsgHello + + buf := bytes.NewReader(cc.data[msgTypeSize:]) + err = binary.Read(buf, binary.LittleEndian, &hello) + if err != nil { + return + } + + if hello.VersionMin > Version || hello.VersionMax < Version { + return fmt.Errorf("Incompatible memif version") + } + + cc.i.run = cc.i.args.MemoryConfig + + cc.i.run.NumQueuePairs = min16(cc.i.args.MemoryConfig.NumQueuePairs, hello.MaxRingS2M) + cc.i.run.NumQueuePairs = min16(cc.i.args.MemoryConfig.NumQueuePairs, hello.MaxRingM2S) + cc.i.run.Log2RingSize = min8(cc.i.args.MemoryConfig.Log2RingSize, hello.MaxLog2RingSize) + + cc.i.remoteName = string(hello.Name[:]) + + return nil +} + +func (cc *controlChannel) msgEnqInit() (err error) { + init := MsgInit{ + Version: Version, + Id: cc.i.args.Id, + Mode: cc.i.args.Mode, + } + + copy(init.Name[:], []byte(cc.socket.appName)) + + buf := new(bytes.Buffer) + err = binary.Write(buf, binary.LittleEndian, msgTypeInit) + err = binary.Write(buf, binary.LittleEndian, init) + + msg := controlMsg{ + Buffer: buf, + Fd: -1, + } + + cc.msgQueue = append(cc.msgQueue, msg) + + return nil +} + +func (cc *controlChannel) parseInit() (err error) { + var init MsgInit + + buf := bytes.NewReader(cc.data[msgTypeSize:]) + err = binary.Read(buf, binary.LittleEndian, &init) + if err != nil { + return + } + + if init.Version != Version { + return fmt.Errorf("Incompatible memif driver version") + } + + // find peer interface + for elt := cc.socket.interfaceList.Front(); elt != nil; elt = elt.Next() { + i, ok := elt.Value.(*Interface) + if ok { + if i.args.Id == init.Id && i.args.IsMaster && i.cc == nil { + // verify secret + if i.args.Secret != init.Secret { + return fmt.Errorf("Invalid secret") + } + // interface is assigned to control channel + i.cc = cc + cc.i = i + cc.i.run = cc.i.args.MemoryConfig + cc.i.remoteName = string(init.Name[:]) + + return nil + } + } + } + + return fmt.Errorf("Invalid interface id") +} + +func (cc *controlChannel) msgEnqAddRegion(regionIndex uint16) (err error) { + if len(cc.i.regions) <= int(regionIndex) { + return fmt.Errorf("Invalid region index") + } + + addRegion := MsgAddRegion{ + Index: regionIndex, + Size: cc.i.regions[regionIndex].size, + } + + buf := new(bytes.Buffer) + err = binary.Write(buf, binary.LittleEndian, msgTypeAddRegion) + err = binary.Write(buf, binary.LittleEndian, addRegion) + + msg := controlMsg{ + Buffer: buf, + Fd: cc.i.regions[regionIndex].fd, + } + + cc.msgQueue = append(cc.msgQueue, msg) + + return nil +} + +func (cc *controlChannel) parseAddRegion() (err error) { + var addRegion MsgAddRegion + + buf := bytes.NewReader(cc.data[msgTypeSize:]) + err = binary.Read(buf, binary.LittleEndian, &addRegion) + if err != nil { + return + } + + fd, err := cc.parseControlMsg() + if err != nil { + return fmt.Errorf("parseControlMsg: %s", err) + } + + if addRegion.Index > 255 { + return fmt.Errorf("Invalid memory region index") + } + + region := memoryRegion{ + size: addRegion.Size, + fd: fd, + } + + cc.i.regions = append(cc.i.regions, region) + + return nil +} + +func (cc *controlChannel) msgEnqAddRing(ringType ringType, ringIndex uint16) (err error) { + var q Queue + var flags uint16 = 0 + + if ringType == ringTypeS2M { + q = cc.i.txQueues[ringIndex] + flags = msgAddRingFlagS2M + } else { + q = cc.i.rxQueues[ringIndex] + } + + addRing := MsgAddRing{ + Index: ringIndex, + Offset: uint32(q.ring.offset), + Region: uint16(q.ring.region), + RingSizeLog2: uint8(q.ring.log2Size), + Flags: flags, + PrivateHdrSize: 0, + } + + buf := new(bytes.Buffer) + err = binary.Write(buf, binary.LittleEndian, msgTypeAddRing) + err = binary.Write(buf, binary.LittleEndian, addRing) + + msg := controlMsg{ + Buffer: buf, + Fd: q.interruptFd, + } + + cc.msgQueue = append(cc.msgQueue, msg) + + return nil +} + +func (cc *controlChannel) parseAddRing() (err error) { + var addRing MsgAddRing + + buf := bytes.NewReader(cc.data[msgTypeSize:]) + err = binary.Read(buf, binary.LittleEndian, &addRing) + if err != nil { + return + } + + fd, err := cc.parseControlMsg() + if err != nil { + return err + } + + if addRing.Index >= cc.i.run.NumQueuePairs { + return fmt.Errorf("invalid ring index") + } + + q := Queue{ + i: cc.i, + interruptFd: fd, + } + + if (addRing.Flags & msgAddRingFlagS2M) == msgAddRingFlagS2M { + q.ring = newRing(int(addRing.Region), ringTypeS2M, int(addRing.Offset), int(addRing.RingSizeLog2)) + cc.i.rxQueues = append(cc.i.rxQueues, q) + } else { + q.ring = newRing(int(addRing.Region), ringTypeM2S, int(addRing.Offset), int(addRing.RingSizeLog2)) + cc.i.txQueues = append(cc.i.txQueues, q) + } + + return nil +} + +func (cc *controlChannel) msgEnqConnect() (err error) { + var connect MsgConnect + copy(connect.Name[:], []byte(cc.i.args.Name)) + + buf := new(bytes.Buffer) + err = binary.Write(buf, binary.LittleEndian, msgTypeConnect) + err = binary.Write(buf, binary.LittleEndian, connect) + + msg := controlMsg{ + Buffer: buf, + Fd: -1, + } + + cc.msgQueue = append(cc.msgQueue, msg) + + return nil +} + +func (cc *controlChannel) parseConnect() (err error) { + var connect MsgConnect + + buf := bytes.NewReader(cc.data[msgTypeSize:]) + err = binary.Read(buf, binary.LittleEndian, &connect) + if err != nil { + return + } + + cc.i.peerName = string(connect.Name[:]) + + err = cc.i.connect() + if err != nil { + return err + } + q, err := cc.i.GetRxQueue(0) + i := cc.i + if err != nil { + return err + } + if i.args.IsMaster { + i.args.InterruptFd = uint16(q.interruptFd) + + } + err = i.socket.addInterrupt(q.interruptFd) + if err != nil { + return err + } + cc.isConnected = true + + return nil +} + +func (cc *controlChannel) msgEnqConnected() (err error) { + var connected MsgConnected + copy(connected.Name[:], []byte(cc.i.args.Name)) + + buf := new(bytes.Buffer) + err = binary.Write(buf, binary.LittleEndian, msgTypeConnected) + err = binary.Write(buf, binary.LittleEndian, connected) + + msg := controlMsg{ + Buffer: buf, + Fd: -1, + } + + cc.msgQueue = append(cc.msgQueue, msg) + + return nil +} + +func (cc *controlChannel) parseConnected() (err error) { + var conn MsgConnected + + buf := bytes.NewReader(cc.data[msgTypeSize:]) + err = binary.Read(buf, binary.LittleEndian, &conn) + if err != nil { + return + } + + cc.i.peerName = string(conn.Name[:]) + + err = cc.i.connect() + if err != nil { + return err + } + cc.isConnected = true + + return nil +} + +func (cc *controlChannel) msgEnqDisconnect(str string) (err error) { + dc := MsgDisconnect{ + // not implemented + Code: 0, + } + copy(dc.String[:], str) + + buf := new(bytes.Buffer) + err = binary.Write(buf, binary.LittleEndian, msgTypeDisconnect) + err = binary.Write(buf, binary.LittleEndian, dc) + + msg := controlMsg{ + Buffer: buf, + Fd: -1, + } + + cc.msgQueue = append(cc.msgQueue, msg) + + return nil +} + +func (cc *controlChannel) parseDisconnect() (err error) { + var dc MsgDisconnect + + buf := bytes.NewReader(cc.data[msgTypeSize:]) + err = binary.Read(buf, binary.LittleEndian, &dc) + if err != nil { + return + } + + err = cc.close(false, string(dc.String[:])) + if err != nil { + return fmt.Errorf("Failed to disconnect control channel: ", err) + } + + return nil +} + +func (cc *controlChannel) parseMsg() error { + var msgType msgType + var err error + + buf := bytes.NewReader(cc.data[:]) + err = binary.Read(buf, binary.LittleEndian, &msgType) + + if msgType == msgTypeAck { + return nil + } else if msgType == msgTypeHello { + // Configure + err = cc.parseHello() + if err != nil { + goto error + } + // Initialize slave memif + err = cc.i.initializeRegions() + if err != nil { + goto error + } + err = cc.i.initializeQueues() + if err != nil { + goto error + } + // Enqueue messages + err = cc.msgEnqInit() + if err != nil { + goto error + } + for i := 0; i < len(cc.i.regions); i++ { + err = cc.msgEnqAddRegion(uint16(i)) + if err != nil { + goto error + } + } + for i := 0; uint16(i) < cc.i.run.NumQueuePairs; i++ { + err = cc.msgEnqAddRing(ringTypeS2M, uint16(i)) + if err != nil { + goto error + } + } + for i := 0; uint16(i) < cc.i.run.NumQueuePairs; i++ { + err = cc.msgEnqAddRing(ringTypeM2S, uint16(i)) + if err != nil { + goto error + } + } + err = cc.msgEnqConnect() + if err != nil { + goto error + } + } else if msgType == msgTypeInit { + err = cc.parseInit() + if err != nil { + goto error + } + + err = cc.msgEnqAck() + if err != nil { + goto error + } + } else if msgType == msgTypeAddRegion { + err = cc.parseAddRegion() + if err != nil { + goto error + } + + err = cc.msgEnqAck() + if err != nil { + goto error + } + } else if msgType == msgTypeAddRing { + err = cc.parseAddRing() + if err != nil { + goto error + } + + err = cc.msgEnqAck() + if err != nil { + goto error + } + } else if msgType == msgTypeConnect { + err = cc.parseConnect() + if err != nil { + goto error + } + + err = cc.msgEnqConnected() + if err != nil { + goto error + } + } else if msgType == msgTypeConnected { + err = cc.parseConnected() + if err != nil { + goto error + } + } else if msgType == msgTypeDisconnect { + err = cc.parseDisconnect() + if err != nil { + goto error + } + } else { + err = fmt.Errorf("unknown message %d", msgType) + goto error + } + + return nil + +error: + err1 := cc.close(true, err.Error()) + if err1 != nil { + return fmt.Errorf(err.Error(), ": Failed to close control channel: ", err1) + } + + return err +} + +// parseControlMsg parses control message and returns file descriptor +// if any +func (cc *controlChannel) parseControlMsg() (fd int, err error) { + // Assert only called when we require FD + fd = -1 + + controlMsgs, err := syscall.ParseSocketControlMessage(cc.control[:cc.controlLen]) + if err != nil { + return -1, fmt.Errorf("syscall.ParseSocketControlMessage: %s", err) + } + + if len(controlMsgs) == 0 { + return -1, fmt.Errorf("Missing control message") + } + + for _, cmsg := range controlMsgs { + if cmsg.Header.Level == syscall.SOL_SOCKET { + if cmsg.Header.Type == syscall.SCM_RIGHTS { + FDs, err := syscall.ParseUnixRights(&cmsg) + if err != nil { + return -1, fmt.Errorf("syscall.ParseUnixRights: %s", err) + } + if len(FDs) == 0 { + continue + } + // Only expect single FD + fd = FDs[0] + } + } + } + + if fd == -1 { + return -1, fmt.Errorf("Missing file descriptor") + } + + return fd, nil +} diff --git a/extras/gomemif/memif/control_channel_unsafe.go b/extras/gomemif/memif/control_channel_unsafe.go new file mode 100644 index 00000000..9e91297b --- /dev/null +++ b/extras/gomemif/memif/control_channel_unsafe.go @@ -0,0 +1,60 @@ +/* + *------------------------------------------------------------------ + * 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 memif + +import ( + "fmt" + "os" + "syscall" + "unsafe" +) + +// sendMsg sends a control message from contorl channels message queue +func (cc *controlChannel) sendMsg() (err error) { + if len(cc.msgQueue) < 1 { + return nil + } + // Get message buffer + msg := cc.msgQueue[0] + // Dequeue + cc.msgQueue = cc.msgQueue[1:] + + iov := &syscall.Iovec{ + Base: &msg.Buffer.Bytes()[0], + Len: msgSize, + } + + msgh := syscall.Msghdr{ + Iov: iov, + Iovlen: 1, + } + + if msg.Fd > 0 { + oob := syscall.UnixRights(msg.Fd) + msgh.Control = &oob[0] + msgh.Controllen = uint64(syscall.CmsgSpace(4)) + } + + _, _, errno := syscall.Syscall(syscall.SYS_SENDMSG, uintptr(cc.event.Fd), uintptr(unsafe.Pointer(&msgh)), uintptr(0)) + if errno != 0 { + err = os.NewSyscallError("sendmsg", errno) + return fmt.Errorf("SYS_SENDMSG: %s", errno) + } + + return nil +} diff --git a/extras/gomemif/memif/interface.go b/extras/gomemif/memif/interface.go new file mode 100644 index 00000000..929d5f2d --- /dev/null +++ b/extras/gomemif/memif/interface.go @@ -0,0 +1,543 @@ +/* + *------------------------------------------------------------------ + * 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 memif provides the implementation of shared memory interface (memif). +// +// Memif network interfaces communicate using UNIX domain socket. This socket +// must be first created using NewSocket(). Then interfaces can be added +// to this socket using NewInterface(). To start communication on each socket +// socket.StartPolling() must be called. socket.StopPolling() will stop +// the communication. When the interface changes link status Connected and +// Disconencted callbacks set in Arguments for each interface are called +// respectively. Once the interface is connected rx and tx queues can be +// aquired using interface.GetRxQueue() and interface.GetTxQueue(). +// Packets can be transmitted by calling queue.ReadPacket() on rx queues and +// queue.WritePacket() on tx queues. If the interface is disconnected +// queue.ReadPacket() and queue.WritePacket() MUST not be called. +// +// Data transmission is backed by shared memory. The driver works in +// promiscuous mode only. +package memif + +import ( + "container/list" + "fmt" + "os" + "syscall" + "unsafe" +) + +const ( + DefaultSocketFilename = "/run/vpp/memif.sock" + DefaultNumQueuePairs = 1 + DefaultLog2RingSize = 10 + DefaultPacketBufferSize = 2048 +) + +const mfd_allow_sealing = 2 +const sys_memfd_create = 319 +const f_add_seals = 1033 +const f_seal_shrink = 0x0002 + +const efd_nonblock = 04000 + +// ConnectedFunc is a callback called when an interface is connected +type ConnectedFunc func(i *Interface) error + +// DisconnectedFunc is a callback called when an interface is disconnected +type DisconnectedFunc func(i *Interface) error + +type InterruptFunc func(i *Interface) error + +// MemoryConfig represents shared memory configuration +type MemoryConfig struct { + NumQueuePairs uint16 // number of queue pairs + Log2RingSize uint8 // ring size as log2 + PacketBufferSize uint32 // size of single packet buffer +} + +// Arguments represent interface configuration +type Arguments struct { + Id uint32 // Interface identifier unique across socket. Used to identify peer interface when connecting + IsMaster bool // Interface role master/slave + Mode interfaceMode + Name string + Secret [24]byte // optional parameter, secrets of the interfaces must match if they are to connect + MemoryConfig MemoryConfig + ConnectedFunc ConnectedFunc // callback called when interface changes status to connected + DisconnectedFunc DisconnectedFunc // callback called when interface changes status to disconnected + InterruptFunc InterruptFunc + PrivateData interface{} // private data used by client program + InterruptFd uint16 +} + +// memoryRegion represents a shared memory mapped file +type memoryRegion struct { + data []byte + size uint64 + fd int + packetBufferOffset uint32 +} + +// Queue represents rx or tx queue +type Queue struct { + ring *ring + i *Interface + lastHead uint16 + lastTail uint16 + interruptFd int +} + +// Interface represents memif network interface +type Interface struct { + args Arguments + run MemoryConfig + privateData interface{} + listRef *list.Element + socket *Socket + cc *controlChannel + remoteName string + peerName string + regions []memoryRegion + txQueues []Queue + rxQueues []Queue + onInterrupt InterruptFunc + Pkt []MemifPacketBuffer +} + +// IsMaster returns true if the interfaces role is master, else returns false +func (i *Interface) IsMaster() bool { + return i.args.IsMaster +} + +// GetRemoteName returns the name of the application on which the peer +// interface exists +func (i *Interface) GetRemoteName() string { + return i.remoteName +} + +// GetPeerName returns peer interfaces name +func (i *Interface) GetPeerName() string { + return i.peerName +} + +// GetName returens interfaces name +func (i *Interface) GetName() string { + return i.args.Name +} + +// GetMemoryConfig returns interfaces active memory config. +// If interface is not connected the config is invalid. +func (i *Interface) GetMemoryConfig() MemoryConfig { + return i.run +} + +// GetRxQueue returns an rx queue specified by queue index +func (i *Interface) GetRxQueue(qid int) (*Queue, error) { + if qid >= len(i.rxQueues) { + return nil, fmt.Errorf("Invalid Queue index") + } + return &i.rxQueues[qid], nil +} + +// GetRxQueue returns a tx queue specified by queue index +func (i *Interface) GetTxQueue(qid int) (*Queue, error) { + if qid >= len(i.txQueues) { + return nil, fmt.Errorf("Invalid Queue index") + } + return &i.txQueues[qid], nil +} + +// GetEventFd returns queues interrupt event fd +func (q *Queue) GetEventFd() (int, error) { + return q.interruptFd, nil +} + +// GetFilename returns sockets filename +func (socket *Socket) GetFilename() string { + return socket.filename +} + +// close closes the queue +func (q *Queue) close() { + syscall.Close(q.interruptFd) +} + +// IsConnecting returns true if the interface is connecting +func (i *Interface) IsConnecting() bool { + if i.cc != nil { + return true + } + return false +} + +// IsConnected returns true if the interface is connected +func (i *Interface) IsConnected() bool { + if i.cc != nil && i.cc.isConnected { + return true + } + return false +} + +// Disconnect disconnects the interface +func (i *Interface) Disconnect() (err error) { + if i.cc != nil { + // close control and disconenct interface + return i.cc.close(true, "Interface disconnected") + } + return nil +} + +// disconnect finalizes interface disconnection +func (i *Interface) disconnect() (err error) { + if i.cc == nil { // disconnected + return nil + } + + err = i.args.DisconnectedFunc(i) + if err != nil { + return fmt.Errorf("DisconnectedFunc: ", err) + } + + for _, q := range i.txQueues { + q.close() + } + i.txQueues = []Queue{} + + for _, q := range i.rxQueues { + q.close() + } + i.rxQueues = []Queue{} + + // unmap regions + for _, r := range i.regions { + err = syscall.Munmap(r.data) + if err != nil { + return err + } + err = syscall.Close(r.fd) + if err != nil { + return err + } + } + i.regions = nil + i.cc = nil + + i.peerName = "" + i.remoteName = "" + + return nil +} + +// Delete deletes the interface +func (i *Interface) Delete() (err error) { + i.Disconnect() + + // remove referance on socket + i.socket.interfaceList.Remove(i.listRef) + i = nil + + return nil +} + +// GetSocket returns the socket the interface belongs to +func (i *Interface) GetSocket() *Socket { + return i.socket +} + +// GetPrivateDate returns interfaces private data +func (i *Interface) GetPrivateData() interface{} { + return i.args.PrivateData +} + +// GetId returns interfaces id +func (i *Interface) GetId() uint32 { + return i.args.Id +} + +// RoleToString returns 'Master' if isMaster os true, else returns 'Slave' +func RoleToString(isMaster bool) string { + if isMaster { + return "Master" + } + return "Slave" +} + +// RequestConnection is used by slave interface to connect to a socket and +// create a control channel +func (i *Interface) RequestConnection() error { + if i.IsMaster() { + return fmt.Errorf("Only slave can request connection") + } + // create socket + fd, err := syscall.Socket(syscall.AF_UNIX, syscall.SOCK_SEQPACKET, 0) + if err != nil { + return fmt.Errorf("Failed to create UNIX domain socket: %v", err) + } + usa := &syscall.SockaddrUnix{Name: i.socket.filename} + + // Connect to listener socket + err = syscall.Connect(fd, usa) + if err != nil { + return fmt.Errorf("Failed to connect socket %s : %v", i.socket.filename, err) + } + + // Create control channel + i.cc, err = i.socket.addControlChannel(fd, i) + if err != nil { + return fmt.Errorf("Failed to create control channel: %v", err) + } + + return nil +} + +// NewInterface returns a new memif network interface. When creating an interface +// it's id must be unique across socket with the exception of loopback interface +// in which case the id is the same but role differs +func (socket *Socket) NewInterface(args *Arguments) (*Interface, error) { + var err error + // make sure the ID is unique on this socket + for elt := socket.interfaceList.Front(); elt != nil; elt = elt.Next() { + i, ok := elt.Value.(*Interface) + if ok { + if i.args.Id == args.Id && i.args.IsMaster == args.IsMaster { + return nil, fmt.Errorf("Interface with id %u role %s already exists on this socket", args.Id, RoleToString(args.IsMaster)) + } + } + } + + // copy interface configuration + i := Interface{ + args: *args, + onInterrupt: args.InterruptFunc, + } + // set default values + if i.args.MemoryConfig.NumQueuePairs == 0 { + i.args.MemoryConfig.NumQueuePairs = DefaultNumQueuePairs + } + if i.args.MemoryConfig.Log2RingSize == 0 { + i.args.MemoryConfig.Log2RingSize = DefaultLog2RingSize + } + if i.args.MemoryConfig.PacketBufferSize == 0 { + i.args.MemoryConfig.PacketBufferSize = DefaultPacketBufferSize + } + + i.socket = socket + + // append interface to the list + i.listRef = socket.interfaceList.PushBack(&i) + + if i.args.IsMaster { + if socket.listener == nil { + err = socket.addListener() + if err != nil { + return nil, fmt.Errorf("Failed to create listener channel: %s", err) + } + } + } + + return &i, nil +} + +// eventFd returns an eventfd (SYS_EVENTFD2) +func eventFd() (efd int, err error) { + u_efd, _, errno := syscall.Syscall(syscall.SYS_EVENTFD2, uintptr(0), uintptr(efd_nonblock), 0) + if errno != 0 { + return -1, os.NewSyscallError("eventfd", errno) + } + return int(u_efd), nil +} + +// The function is preparation for potential replacement of EpollWait syscall +func EpollPWait(epfd int, events []syscall.EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(nil) + } + r0, _, e1 := syscall.Syscall6(syscall.SYS_EPOLL_PWAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +// addRegions creates and adds a new memory region to the interface (slave only) +func (i *Interface) addRegion(hasPacketBuffers bool, hasRings bool) (err error) { + var r memoryRegion + + if hasRings { + r.packetBufferOffset = uint32((i.run.NumQueuePairs + i.run.NumQueuePairs) * (ringSize + descSize*(1< 0; nSlots-- { + q.setDescLength(head&mask, int(q.i.run.PacketBufferSize)) + head++ + } + q.writeHead(head) + } + + return pktOffset, nil +} + +// ReadPacket reads one packet form the shared memory and +// returns the number of packets +func (q *Queue) Rx_burst(pkt []MemifPacketBuffer) (uint16, error) { + var mask int = q.ring.size - 1 + var slot int + var lastSlot int + var length int + var offset int + var nSlots uint16 + var desc descBuf = newDescBuf() + + if q.i.args.IsMaster { + slot = int(q.lastHead) + lastSlot = q.readHead() + } else { + slot = int(q.lastTail) + lastSlot = q.readTail() + } + + nSlots = uint16(lastSlot - slot) + if nSlots == 0 { + b := make([]byte, 8) + syscall.Read(int(q.interruptFd), b) + return 0, nil + } + + rx := 0 + for nSlots > 0 { + // copy descriptor from shm + q.getDescBuf(slot&mask, desc) + length = desc.getLength() + offset = desc.getOffset() + copy(pkt[rx].Buf[:], q.i.regions[desc.getRegion()].data[offset:offset+length]) + pkt[rx].Buflen = length + rx++ + nSlots-- + slot++ + } + + if q.i.args.IsMaster { + q.lastHead += uint16(rx) + } else { + q.lastTail += uint16(rx) + + } + + b := make([]byte, 8) + syscall.Read(int(q.interruptFd), b) + + return uint16(rx), nil +} + +func (q *Queue) Refill(count int) { + var mask int = q.ring.size - 1 + + counter := 0 + if q.i.args.IsMaster { + if q.readTail()+count <= int(q.lastHead) { + q.writeTail(q.readTail() + count) + } else { + q.writeTail(int(q.lastHead)) + } + } + + head := q.readHead() + slot := head + ns := (1 << q.ring.log2Size) - head + int(q.lastTail) + + if count >= ns { + count = ns + } + + for counter < count { + slot++ + counter++ + } + for nSlots := uint16(q.ring.size - head + int(q.lastTail)); nSlots > 0; nSlots-- { + q.setDescLength(head&mask, int(q.i.run.PacketBufferSize)) + head++ + } + + if !q.i.args.IsMaster { + q.writeHead(head) //slot + + } +} diff --git a/extras/gomemif/memif/packet_writer.go b/extras/gomemif/memif/packet_writer.go new file mode 100644 index 00000000..fb87a53e --- /dev/null +++ b/extras/gomemif/memif/packet_writer.go @@ -0,0 +1,171 @@ +/* + *------------------------------------------------------------------ + * 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 memif + +// WritePacket writes one packet to the shared memory and +// returns the number of bytes written +func (q *Queue) WritePacket(pkt []byte) int { + var mask int = q.ring.size - 1 + var slot int + var nFree uint16 + var packetBufferSize int = int(q.i.run.PacketBufferSize) + + if q.i.args.IsMaster { + slot = q.readTail() + nFree = uint16(q.readHead() - slot) + } else { + slot = q.readHead() + nFree = uint16(q.ring.size - slot + q.readTail()) + } + + if nFree == 0 { + q.interrupt() + return 0 + } + + // copy descriptor from shm + desc := newDescBuf() + q.getDescBuf(slot&mask, desc) + // reset flags + desc.setFlags(0) + // reset length + if q.i.args.IsMaster { + packetBufferSize = desc.getLength() + } + desc.setLength(0) + offset := desc.getOffset() + + // write packet into memif buffer + n := copy(q.i.regions[desc.getRegion()].data[offset:offset+packetBufferSize], pkt[:]) + desc.setLength(n) + for n < len(pkt) { + nFree-- + if nFree == 0 { + q.interrupt() + return 0 + } + desc.setFlags(descFlagNext) + q.putDescBuf(slot&mask, desc) + slot++ + + // copy descriptor from shm + q.getDescBuf(slot&mask, desc) + // reset flags + desc.setFlags(0) + // reset length + if q.i.args.IsMaster { + packetBufferSize = desc.getLength() + } + desc.setLength(0) + offset := desc.getOffset() + + tmp := copy(q.i.regions[desc.getRegion()].data[offset:offset+packetBufferSize], pkt[:]) + desc.setLength(tmp) + n += tmp + } + + // copy descriptor to shm + q.putDescBuf(slot&mask, desc) + slot++ + + if q.i.args.IsMaster { + q.writeTail(slot) + } else { + q.writeHead(slot) + } + + q.interrupt() + + return n +} + +func (q *Queue) Tx_burst(pkt []MemifPacketBuffer) int { + var mask int = q.ring.size - 1 + var slot int + var nFree uint16 + var packetBufferSize int = int(q.i.run.PacketBufferSize) + + if q.i.args.IsMaster { + slot = q.readTail() + nFree = uint16(q.readHead() - slot) + } else { + slot = q.readHead() + nFree = uint16(q.ring.size - slot + q.readTail()) + } + + if nFree == 0 { + q.interrupt() + return 0 + } + + var n int + for i := 0; i < len(pkt); i++ { + // copy descriptor from shm + desc := newDescBuf() + q.getDescBuf(slot&mask, desc) + // reset flags + desc.setFlags(0) + // reset length + if q.i.args.IsMaster { + packetBufferSize = desc.getLength() + } + desc.setLength(0) + offset := desc.getOffset() + // write packet into memif buffer + n = copy(q.i.regions[desc.getRegion()].data[offset:offset+packetBufferSize], pkt[i].Buf[:]) + desc.setLength(n) + for n < len(pkt[i].Buf) { + nFree-- + if nFree == 0 { + q.interrupt() + return 0 + } + desc.setFlags(descFlagNext) + q.putDescBuf(slot&mask, desc) + slot++ + + // copy descriptor from shm + q.getDescBuf(slot&mask, desc) + // reset flags + desc.setFlags(0) + // reset length + if q.i.args.IsMaster { + packetBufferSize = desc.getLength() + } + desc.setLength(0) + offset := desc.getOffset() + + tmp := copy(q.i.regions[desc.getRegion()].data[offset:offset+packetBufferSize], pkt[i].Buf[:]) + desc.setLength(tmp) + n += tmp + } + + // copy descriptor to shm + q.putDescBuf(slot&mask, desc) + slot++ + } + if q.i.args.IsMaster { + q.writeTail(slot) + } else { + q.writeHead(slot) + } + + q.interrupt() + + return n +} diff --git a/extras/libmemif/README.md b/extras/libmemif/README.md index 9459769c..093db396 100644 --- a/extras/libmemif/README.md +++ b/extras/libmemif/README.md @@ -7,9 +7,10 @@ labels `Go-libmemif` and `C-libmemif` are used in the documentation. ### Requirements +This version is compatible with libmemif v4.0 which is part of vpp v22.02 and newer. libmemif for Golang is build on the top of the original, C-written libmemif library using `cgo`. It is therefore necessary to have C-libmemif -header files and the library itself installed in locations known +header files, and the library itself installed in locations known to the compiler. For example, to install C-libmemif system-wide into the standard @@ -18,9 +19,10 @@ locations, execute: ``` $ git clone https://gerrit.fd.io/r/vpp $ cd vpp/extras/libmemif -$ ./bootstrap -$ ./configure -$ make install +$ mkdir build +$ cd build +$ cmake .. +$ sudo make install ``` ### Build @@ -80,7 +82,7 @@ Available callbacks are: **libmemif** was designed for a maximum possible performance. Packets are sent and received in bulks, rather than one-by-one, using `Memif.TxBurst(queueID, packets)` and `Memif.RxBurst(queueID, count)`, -respectively. Memif connection can consists of multiple queues in both +respectively. Memif connection can consist of multiple queues in both directions. A queue is one-directional wait-free ring buffer. It is the unit of parallelism for data transmission. The maximum possible lock-free granularity is therefore one go routine for one queue. @@ -124,7 +126,7 @@ The examples can be found in the subdirectory [examples](./examples). _raw-data_ is a basic example showing how to create a memif interface, handle events through callbacks and perform Rx/Tx of raw data. Before -handling an actual packets it is important to understand the skeleton +handling an actual packet it is important to understand the skeleton of libmemif-based applications. Since VPP expects proper packet data, it is not very useful to connect diff --git a/extras/libmemif/adapter.go b/extras/libmemif/adapter.go index 1bb92299..e664ea2e 100644 --- a/extras/libmemif/adapter.go +++ b/extras/libmemif/adapter.go @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !windows && !darwin // +build !windows,!darwin package libmemif @@ -50,7 +51,7 @@ memif_cancel_poll_event () // are much easier to work with in cgo. typedef struct { - char *socket_filename; + memif_socket_handle_t socket; char *secret; uint8_t num_s2m_rings; uint8_t num_m2s_rings; @@ -74,7 +75,7 @@ typedef struct char *secret; uint8_t role; uint8_t mode; - char *socket_filename; + char *socket_path; uint8_t regions_num; memif_region_details_t *regions; uint8_t rx_queues_num; @@ -84,6 +85,7 @@ typedef struct uint8_t link_up_down; } govpp_memif_details_t; + extern int go_on_connect_callback(void *privateCtx); extern int go_on_disconnect_callback(void *privateCtx); @@ -108,7 +110,7 @@ govpp_memif_create (memif_conn_handle_t *conn, govpp_memif_conn_args_t *go_args, { memif_conn_args_t args; memset (&args, 0, sizeof (args)); - args.socket_filename = (char *)go_args->socket_filename; + args.socket = (char *)go_args->socket; if (go_args->secret != NULL) { strncpy ((char *)args.secret, go_args->secret, @@ -132,6 +134,12 @@ govpp_memif_create (memif_conn_handle_t *conn, govpp_memif_conn_args_t *go_args, private_ctx); } +static int +govpp_memif_create_socket (memif_socket_handle_t *sock, memif_socket_args_t *args) +{ + return memif_create_socket(sock, args, NULL); +} + // govpp_memif_get_details keeps reallocating buffer until it is large enough. // The buffer is returned to be deallocated when it is no longer needed. static int @@ -168,7 +176,7 @@ govpp_memif_get_details (memif_conn_handle_t conn, govpp_memif_details_t *govpp_ govpp_md->secret = (char *)md.secret; govpp_md->role = md.role; govpp_md->mode = md.mode; - govpp_md->socket_filename = (char *)md.socket_filename; + govpp_md->socket_path = (char *)md.socket_path; govpp_md->regions_num = md.regions_num; govpp_md->regions = md.regions; govpp_md->rx_queues_num = md.rx_queues_num; @@ -308,6 +316,8 @@ type MemifMeta struct { // Mode is the mode (layer/behaviour) in which the memif operates. Mode IfMode + + AppName string } // MemifShmSpecs is used to store the specification of the shared memory segment @@ -365,14 +375,16 @@ type Memif struct { MemifMeta // Per-library references - ifIndex int // index used in the Go-libmemif context (Context.memifs) - cHandle C.memif_conn_handle_t // handle used in C-libmemif + ifIndex int // index used in the Go-libmemif context (Context.memifs) + cHandle C.memif_conn_handle_t // connection handle used in C-libmemif + sHandle C.memif_socket_handle_t // socket handle used in C-libmemif // Callbacks callbacks *MemifCallbacks // Interrupt intCh chan uint8 // memif-global interrupt channel (value = queue ID) + intErrCh chan error // triggered when interrupt error occurs queueIntCh []chan struct{} // per RX queue interrupt channel // Rx/Tx queues @@ -439,12 +451,24 @@ type txPacketBuffer struct { size int } +type MemifSocketArgs struct { + Path string + AppName string + + OnControlFdUpdate *C.memif_control_fd_update_t + Alloc *C.memif_alloc_t + Realloc *C.memif_realloc_t + Free *C.memif_free_t +} + var ( // logger used by the adapter. log *logger.Logger // Global Go-libmemif context. context = &Context{initialized: false} + + socketHandler C.memif_socket_handle_t ) // init initializes global logger, which logs debug level messages to stdout. @@ -475,16 +499,7 @@ func Init(appName string) error { log.Debug("Initializing libmemif library") - // Initialize C-libmemif. - var errCode int - if appName == "" { - errCode = int(C.memif_init(nil, nil, nil, nil, nil)) - } else { - appName := C.CString(appName) - defer C.free(unsafe.Pointer(appName)) - errCode = int(C.memif_init(nil, appName, nil, nil, nil)) - } - err := getMemifError(errCode) + err := getMemifError(0) if err != nil { return err } @@ -494,7 +509,7 @@ func Init(appName string) error { // Start event polling. context.wg.Add(1) - go pollEvents() + go pollEvents(&socketHandler, C.int(-1)) context.initialized = true log.Debug("libmemif library was initialized") @@ -518,8 +533,9 @@ func Cleanup() error { } // Stop the event loop (if supported by C-libmemif). - errCode := C.memif_cancel_poll_event() + errCode := C.memif_cancel_poll_event(socketHandler) err := getMemifError(int(errCode)) + if err == nil { log.Debug("Waiting for pollEvents() to stop...") context.wg.Wait() @@ -529,11 +545,12 @@ func Cleanup() error { } // Run cleanup for C-libmemif. - err = getMemifError(int(C.memif_cleanup())) + err = getMemifError(int(C.memif_delete_socket(&socketHandler))) if err == nil { context.initialized = false log.Debug("libmemif library was closed") } + return err } @@ -578,6 +595,7 @@ func CreateInterface(config *MemifConfig, callbacks *MemifCallbacks) (memif *Mem // Initialize memif-global interrupt channel. memif.intCh = make(chan uint8, 1<<6) + memif.intErrCh = make(chan error, 1<<6) // Initialize event file descriptor for stopping Rx/Tx queue polling. memif.stopQPollFd = int(C.eventfd(0, C.EFD_NONBLOCK)) @@ -587,11 +605,34 @@ func CreateInterface(config *MemifConfig, callbacks *MemifCallbacks) (memif *Mem // Initialize memif input arguments. args := &C.govpp_memif_conn_args_t{} + sockargs := &C.memif_socket_args_t{} + + C.strncpy((*C.char)(unsafe.Pointer(&sockargs.path)), C.CString(config.MemifMeta.SocketFilename), C.strlen(C.CString(config.MemifMeta.SocketFilename))) + C.strncpy((*C.char)(unsafe.Pointer(&sockargs.app_name)), C.CString(config.MemifMeta.AppName), C.strlen(C.CString(config.MemifMeta.AppName))) + + if !config.IsMaster { + sockargs.connection_request_timer.it_value.tv_sec = 2 + sockargs.connection_request_timer.it_value.tv_nsec = 0 + sockargs.connection_request_timer.it_interval.tv_sec = 2 + sockargs.connection_request_timer.it_interval.tv_nsec = 0 + } + /* + sockargs.connection_request_timer.it_value.tv_sec = 2 + sockargs.connection_request_timer.it_value.tv_nsec = 0 + sockargs.connection_request_timer.it_interval.tv_sec = 2 + sockargs.connection_request_timer.it_interval.tv_nsec = 0 + */ // - socket file name if config.SocketFilename != "" { - args.socket_filename = C.CString(config.SocketFilename) - defer C.free(unsafe.Pointer(args.socket_filename)) + log.WithField("name", config.SocketFilename).Debug("A new memif socket was created") + //errCode := C.govpp_memif_create_socket(&memif.sHandle, sockargs) + errCode := C.govpp_memif_create_socket(&socketHandler, sockargs) + if getMemifError(int(errCode)) != nil { + err = getMemifError(int(errCode)) + return nil, err + } } + args.socket = socketHandler // - interface ID args.interface_id = C.uint32_t(config.ConnID) // - interface name @@ -632,8 +673,8 @@ func CreateInterface(config *MemifConfig, callbacks *MemifCallbacks) (memif *Mem // Create memif in C-libmemif. errCode := C.govpp_memif_create(&memif.cHandle, args, unsafe.Pointer(uintptr(memif.ifIndex))) - err = getMemifError(int(errCode)) - if err != nil { + if getMemifError(int(errCode)) != nil { + err = getMemifError(int(errCode)) return nil, err } @@ -657,6 +698,12 @@ func (memif *Memif) GetInterruptChan() (ch <-chan uint8 /* queue ID */) { return memif.intCh } +// GetInterruptErrorChan returns an Error channel +// which fires if there are errors occurred while read data. +func (memif *Memif) GetInterruptErrorChan() (ch <-chan error /* The error */) { + return memif.intErrCh +} + // GetQueueInterruptChan returns an empty-data channel which fires every time // there are data to read on a given queue. // It is only valid to call this function if memif is in the connected state. @@ -711,7 +758,7 @@ func (memif *Memif) GetDetails() (details *MemifDetails, err error) { details.IfName = C.GoString(cDetails.if_name) details.InstanceName = C.GoString(cDetails.inst_name) details.ConnID = uint32(cDetails.id) - details.SocketFilename = C.GoString(cDetails.socket_filename) + details.SocketFilename = C.GoString(cDetails.socket_path) if cDetails.secret != nil { details.Secret = C.GoString(cDetails.secret) } @@ -771,7 +818,7 @@ func (memif *Memif) TxBurst(queueID uint8, packets []RawPacketData) (count uint1 } var bufCount int - var buffers []*txPacketBuffer + buffers := make([]*txPacketBuffer, 0) cQueueID := C.uint16_t(queueID) for _, packet := range packets { @@ -916,6 +963,7 @@ func (memif *Memif) TxBurst(queueID uint8, packets []RawPacketData) (count uint1 // Rx queue. func (memif *Memif) RxBurst(queueID uint8, count uint16) (packets []RawPacketData, err error) { var recvCount C.uint16_t + packets = make([]RawPacketData, 0) if count == 0 { return packets, nil @@ -1011,6 +1059,7 @@ func (memif *Memif) Close() error { if err != nil { // Close memif-global interrupt channel. close(memif.intCh) + close(memif.intErrCh) // Close file descriptor stopQPollFd. C.close(C.int(memif.stopQPollFd)) } @@ -1089,10 +1138,10 @@ func (memif *Memif) closeQueues() { } // pollEvents repeatedly polls for a libmemif event. -func pollEvents() { +func pollEvents(sock *C.memif_socket_handle_t, timeout C.int) { defer context.wg.Done() for { - errCode := C.memif_poll_event(C.int(-1)) + errCode := C.memif_poll_event(*sock, timeout) err := getMemifError(int(errCode)) if err == ErrPollCanceled { return @@ -1146,7 +1195,13 @@ func pollRxQueue(memif *Memif, queueID uint8) { for { _, err := syscall.EpollWait(epFd, event[:], -1) if err != nil { + errno, _ := err.(syscall.Errno) + //EINTR and EAGAIN should not be considered as a fatal error, try again + if errno == syscall.EINTR || errno == syscall.EAGAIN { + continue + } log.WithField("err", err).Error("epoll_wait() failed") + memif.intErrCh <- err return } diff --git a/extras/libmemif/error.go b/extras/libmemif/error.go index 58da7008..18efaf08 100644 --- a/extras/libmemif/error.go +++ b/extras/libmemif/error.go @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !windows && !darwin // +build !windows,!darwin package libmemif diff --git a/extras/libmemif/examples/gopacket/gopacket.go b/extras/libmemif/examples/gopacket/gopacket.go index 86c2303f..32bccc52 100644 --- a/extras/libmemif/examples/gopacket/gopacket.go +++ b/extras/libmemif/examples/gopacket/gopacket.go @@ -52,9 +52,9 @@ import ( "os" "os/signal" - "github.com/alkiranet/govpp/extras/libmemif" "github.com/google/gopacket" "github.com/google/gopacket/layers" + "github.com/alkiranet/govpp/extras/libmemif" ) var ( @@ -338,6 +338,7 @@ func main() { Secret: "secret", // Secret used to authenticate the memif connection. IsMaster: isMaster, Mode: libmemif.IfModeEthernet, + AppName: appName, }, MemifShmSpecs: libmemif.MemifShmSpecs{ NumRxQueues: 3, // NumQueues is the (configured!) number of queues for both Rx & Tx. diff --git a/extras/libmemif/examples/icmp-responder/icmp-responder.go b/extras/libmemif/examples/icmp-responder/icmp-responder.go index b3351c89..67ba0e66 100644 --- a/extras/libmemif/examples/icmp-responder/icmp-responder.go +++ b/extras/libmemif/examples/icmp-responder/icmp-responder.go @@ -3,34 +3,38 @@ // and construct packets. // // The appropriate VPP configuration for the opposite memif is: -// vpp$ create memif socket id 1 filename /tmp/icmp-responder-example -// vpp$ create interface memif id 1 socket-id 1 slave secret secret no-zero-copy -// vpp$ set int state memif1/1 up -// vpp$ set int ip address memif1/1 192.168.1.2/24 +// +// vpp$ create memif socket id 1 filename /tmp/icmp-responder-example +// vpp$ create interface memif id 1 socket-id 1 slave secret secret no-zero-copy +// vpp$ set int state memif1/1 up +// vpp$ set int ip address memif1/1 192.168.1.2/24 // // To start the example, simply type: -// root$ ./icmp-responder +// +// root$ ./icmp-responder // // icmp-responder needs to be run as root so that it can access the socket // created by VPP. // // Normally, the memif interface is in the master mode. Pass CLI flag "--slave" // to create memif in the slave mode: -// root$ ./icmp-responder --slave +// +// root$ ./icmp-responder --slave // // Don't forget to put the opposite memif into the master mode in that case. // // To verify the connection, run: -// vpp$ ping 192.168.1.1 -// 64 bytes from 192.168.1.1: icmp_seq=2 ttl=255 time=.6974 ms -// 64 bytes from 192.168.1.1: icmp_seq=3 ttl=255 time=.6310 ms -// 64 bytes from 192.168.1.1: icmp_seq=4 ttl=255 time=1.0350 ms -// 64 bytes from 192.168.1.1: icmp_seq=5 ttl=255 time=.5359 ms // -// Statistics: 5 sent, 4 received, 20% packet loss -// vpp$ sh ip arp -// Time IP4 Flags Ethernet Interface -// 68.5648 192.168.1.1 D aa:aa:aa:aa:aa:aa memif0/1 +// vpp$ ping 192.168.1.1 +// 64 bytes from 192.168.1.1: icmp_seq=2 ttl=255 time=.6974 ms +// 64 bytes from 192.168.1.1: icmp_seq=3 ttl=255 time=.6310 ms +// 64 bytes from 192.168.1.1: icmp_seq=4 ttl=255 time=1.0350 ms +// 64 bytes from 192.168.1.1: icmp_seq=5 ttl=255 time=.5359 ms +// +// Statistics: 5 sent, 4 received, 20% packet loss +// vpp$ sh ip arp +// Time IP4 Flags Ethernet Interface +// 68.5648 192.168.1.1 D aa:aa:aa:aa:aa:aa memif0/1 // // Note: it is expected that the first ping is shown as lost. It was actually // converted to an ARP request. This is a VPP feature common to all interface @@ -155,7 +159,7 @@ func IcmpResponder(memif *libmemif.Memif, queueID uint8) { break } // Generate response for each supported request. - responses := []libmemif.RawPacketData{} + var responses []libmemif.RawPacketData for _, packet := range packets { fmt.Println("Received new packet:") DumpPacket(packet) @@ -325,7 +329,7 @@ func main() { hwAddr, err = net.ParseMAC(MAC) if err != nil { - fmt.Println("Failed to parse the MAC address: %v", err) + fmt.Printf("Failed to parse the MAC address: %v", err) return } @@ -334,7 +338,7 @@ func main() { ipAddr = ip.To4() } if ipAddr == nil { - fmt.Println("Failed to parse the IP address: %v", err) + fmt.Printf("Failed to parse the IP address: %v", err) return } @@ -349,11 +353,13 @@ func main() { // Initialize libmemif first. appName := "ICMP-Responder" + appSuffix fmt.Println("Initializing libmemif as ", appName) + err = libmemif.Init(appName) if err != nil { fmt.Printf("libmemif.Init() error: %v\n", err) return } + // Schedule automatic cleanup. defer libmemif.Cleanup() @@ -375,6 +381,7 @@ func main() { Secret: Secret, IsMaster: isMaster, Mode: libmemif.IfModeEthernet, + AppName: appName, }, MemifShmSpecs: libmemif.MemifShmSpecs{ NumRxQueues: NumQueues, @@ -399,5 +406,13 @@ func main() { // Wait until an interrupt signal is received. sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, os.Interrupt) - <-sigChan + var intErrch = memif.GetInterruptErrorChan() + select { + case err = <-intErrch: + fmt.Printf("Exit due to interface error: %v\n", err) + return + case <-sigChan: + fmt.Printf("Exit by os.Interrupt") + return + } } diff --git a/extras/libmemif/examples/jumbo-frames/jumbo-frames.go b/extras/libmemif/examples/jumbo-frames/jumbo-frames.go index 2c11b742..939b6c53 100644 --- a/extras/libmemif/examples/jumbo-frames/jumbo-frames.go +++ b/extras/libmemif/examples/jumbo-frames/jumbo-frames.go @@ -151,6 +151,7 @@ func main() { Secret: Secret, IsMaster: isMaster, Mode: libmemif.IfModeEthernet, + AppName: appName, }, MemifShmSpecs: libmemif.MemifShmSpecs{ NumRxQueues: NumQueues, diff --git a/extras/libmemif/examples/raw-data/raw-data.go b/extras/libmemif/examples/raw-data/raw-data.go index cb75fbaa..e55dc91c 100644 --- a/extras/libmemif/examples/raw-data/raw-data.go +++ b/extras/libmemif/examples/raw-data/raw-data.go @@ -9,9 +9,9 @@ // // To create a connection of two raw-data instances, run two processes // concurrently: -// - master memif: +// - master memif: // $ ./raw-data -// - slave memif: +// - slave memif: // $ ./raw-data --slave // // Every 3 seconds both sides send 3 raw-data packets to the opposite end through @@ -212,6 +212,7 @@ func main() { Secret: Secret, IsMaster: isMaster, Mode: libmemif.IfModeEthernet, + AppName: appName, }, MemifShmSpecs: libmemif.MemifShmSpecs{ NumRxQueues: NumQueues, diff --git a/extras/libmemif/packethandle.go b/extras/libmemif/packethandle.go index 22a9c10b..75c4fa17 100644 --- a/extras/libmemif/packethandle.go +++ b/extras/libmemif/packethandle.go @@ -15,11 +15,10 @@ package libmemif import ( + "github.com/google/gopacket" "io" "sync" "time" - - "github.com/google/gopacket" ) type memoizedPacket struct { @@ -62,7 +61,7 @@ func NewPacketHandle(burstHandler BurstHandler, queueId uint8, rxCount uint16) * } } -// Reads packet data from memif in bursts, based on previously configured rxCount parameterer. Then caches the +// Reads packet data from memif in bursts, based on previously configured rxCount parameter. Then caches the // resulting packets and returns them 1 by 1 from this method until queue is empty then tries to call new rx burst // to read more data. If no data is returned, io.EOF error is thrown and caller should stop reading. func (handle *MemifPacketHandle) ReadPacketData() (data []byte, ci gopacket.CaptureInfo, err error) { diff --git a/adapter/vppapiclient/doc.go b/gen.go similarity index 63% rename from adapter/vppapiclient/doc.go rename to gen.go index 6505498e..92be0e2b 100644 --- a/adapter/vppapiclient/doc.go +++ b/gen.go @@ -1,4 +1,6 @@ -// Copyright (c) 2018 Cisco and/or its affiliates. +// Copyright (c) 2020 Cisco and/or its affiliates. +// +// SPDX-License-Identifier: Apache-2.0 // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package vppapiclient is the default VPP adapter being used for -// the connection to VPP binary & stats API via shared memory. -// It is essentially Go wrapper for the VPP vppapiclient library written in C. -package vppapiclient +package govpp + +//go:generate bash -c "docker run -e PKGPREFIX=$(go list)/binapi -v $(go list -f '{{ .Dir }}'):/gen $(docker build . -q --build-arg GOVPP_VERSION=$(go list -m -f '{{ .Version }}' github.com/alkiranet/govpp))" diff --git a/go.mod b/go.mod index 6672c3f7..c7029d53 100644 --- a/go.mod +++ b/go.mod @@ -3,21 +3,35 @@ module github.com/alkiranet/govpp go 1.18 require ( - github.com/bennyscetbun/jsongo v1.1.0 - github.com/fsnotify/fsnotify v0.0.0-20170329110642-4da3e2cfbabc + github.com/bennyscetbun/jsongo v1.1.1 + github.com/docker/cli v24.0.2+incompatible + github.com/fsnotify/fsnotify v1.4.9 github.com/ftrvxmtrx/fd v0.0.0-20150925145434-c6d800382fff - github.com/golang/protobuf v1.3.2 // indirect - github.com/hpcloud/tail v1.0.0 // indirect + github.com/gookit/color v1.5.2 + github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe + github.com/mitchellh/go-ps v1.0.0 + github.com/moby/term v0.5.0 + github.com/olekukonko/tablewriter v0.0.5 + github.com/onsi/gomega v1.19.0 + github.com/pkg/profile v1.5.0 + github.com/sirupsen/logrus v1.8.1 + github.com/spf13/cobra v1.6.1 + github.com/spf13/pflag v1.0.5 + golang.org/x/text v0.7.0 + gopkg.in/yaml.v3 v3.0.1 +) + +require ( + github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect + github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/kr/pretty v0.1.0 // indirect - github.com/lunixbochs/struc v0.0.0-20190916212049-a5c72983bc42 - github.com/onsi/ginkgo v1.8.0 // indirect - github.com/onsi/gomega v1.1.0 - github.com/pkg/profile v1.2.1 - github.com/sirupsen/logrus v1.0.0 - github.com/stretchr/testify v1.3.0 // indirect - golang.org/x/sys v0.0.0-20170427041856-9ccfe848b9db // indirect + github.com/mattn/go-runewidth v0.0.9 // indirect + github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect - gopkg.in/fsnotify.v1 v1.4.7 // indirect - gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect - gopkg.in/yaml.v2 v2.0.0-20170407172122-cd8b52f8269e // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect ) + +// Versions v0.5.0 and older use old module path git.fd.io/govpp.git +retract [v0.1.0, v0.5.0] diff --git a/go.sum b/go.sum index 78f56501..f58cf74b 100644 --- a/go.sum +++ b/go.sum @@ -1,42 +1,74 @@ -github.com/bennyscetbun/jsongo v1.1.0 h1:ZDSks3aLP13jhY139lWaUqZaU8G0tELMohzumut/KDM= -github.com/bennyscetbun/jsongo v1.1.0/go.mod h1:suxbVmjBV8+A2BBAM5EYVh6Uj8j3rqJhzWf3hv7Ff8U= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/bennyscetbun/jsongo v1.1.1 h1:ZlYkrwGtF5lKUOQh8t2Bn8XjCvwFI5Qdl6eBqZOtddE= +github.com/bennyscetbun/jsongo v1.1.1/go.mod h1:j5mIRkqjZ4eEoIKQyfVPQpv56ZX0rn+jPETkD/2dRqA= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fsnotify/fsnotify v0.0.0-20170329110642-4da3e2cfbabc h1:fqUzyjP8DApxXq0dOZJE/NvqQkyjxiTy9ARNyRwBPEw= -github.com/fsnotify/fsnotify v0.0.0-20170329110642-4da3e2cfbabc/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/docker/cli v24.0.2+incompatible h1:QdqR7znue1mtkXIJ+ruQMGQhpw2JzMJLRXp6zpzF6tM= +github.com/docker/cli v24.0.2+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/ftrvxmtrx/fd v0.0.0-20150925145434-c6d800382fff h1:zk1wwii7uXmI0znwU+lqg+wFL9G5+vm5I+9rv2let60= github.com/ftrvxmtrx/fd v0.0.0-20150925145434-c6d800382fff/go.mod h1:yUhRXHewUVJ1k89wHKP68xfzk7kwXUx/DV1nx4EBMbw= -github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/gookit/color v1.5.2 h1:uLnfXcaFjlrDnQDT+NCBcfhrXqYTx/rcCa6xn01Y8yI= +github.com/gookit/color v1.5.2/go.mod h1:w8h4bGiHeeBpvQVePTutdbERIUf3oJE5lZ8HM0UgXyg= +github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= +github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/lunixbochs/struc v0.0.0-20190916212049-a5c72983bc42 h1:PzBD7QuxXSgSu61TKXxRwVGzWO5d9QZ0HxFFpndZMCg= -github.com/lunixbochs/struc v0.0.0-20190916212049-a5c72983bc42/go.mod h1:vy1vK6wD6j7xX6O6hXe621WabdtNkou2h7uRtTfRMyg= -github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= -github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.1.0 h1:e3YP4dN/HYPpGh29X1ZkcxcEICsOls9huyVCRBaxjq8= -github.com/onsi/gomega v1.1.0/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/pkg/profile v1.2.1 h1:F++O52m40owAmADcojzM+9gyjmMOY/T4oYJkgFDH8RE= -github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= +github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe h1:ewr1srjRCmcQogPQ/NCx6XCk6LGVmsVCc9Y3vvPZj+Y= +github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe/go.mod h1:vy1vK6wD6j7xX6O6hXe621WabdtNkou2h7uRtTfRMyg= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc= +github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= +github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= +github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/onsi/ginkgo/v2 v2.1.3 h1:e/3Cwtogj0HA+25nMP1jCMDIf8RtRYbGwGGuBIFztkc= +github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= +github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= +github.com/pkg/profile v1.5.0 h1:042Buzk+NhDI+DeSAA62RwJL8VAuZUMQZUjCsRz1Mug= +github.com/pkg/profile v1.5.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.0.0 h1:XM8X4m/9ACaclZMs946FQNEZBZafvToJLTR4007drwo= -github.com/sirupsen/logrus v1.0.0/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= +github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -golang.org/x/sys v0.0.0-20170427041856-9ccfe848b9db h1:znurcNjtwV7XblDOBERYCP1TUjpwbp8bi3Szx8gbNBE= -golang.org/x/sys v0.0.0-20170427041856-9ccfe848b9db/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= +github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.0.0-20170407172122-cd8b52f8269e h1:o/mfNjxpTLivuKEfxzzwrJ8PmulH2wEp7t713uMwKAA= -gopkg.in/yaml.v2 v2.0.0-20170407172122-cd8b52f8269e/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/govpp.go b/govpp.go index 3c8229f7..76a72100 100644 --- a/govpp.go +++ b/govpp.go @@ -20,37 +20,33 @@ import ( "github.com/alkiranet/govpp/adapter" "github.com/alkiranet/govpp/adapter/socketclient" "github.com/alkiranet/govpp/core" + "github.com/alkiranet/govpp/internal/version" ) -var ( - // VPP binary API adapter that will be used in the subsequent Connect calls - vppAdapter adapter.VppAPI -) - -func getVppAdapter(addr string) adapter.VppAPI { - if vppAdapter == nil { - vppAdapter = socketclient.NewVppClient(addr) - } - return vppAdapter +// Connect connects to the VPP API using a new adapter instance created with NewVppAPIAdapter. +// +// This call blocks until VPP is connected, or an error occurs. +// Only one connection attempt will be performed. +func Connect(target string) (*core.Connection, error) { + return core.Connect(NewVppAdapter(target)) } -// SetVppAdapter sets the adapter that will be used for connections to VPP in the subsequent `Connect` calls. -func SetVppAdapter(a adapter.VppAPI) { - vppAdapter = a +// AsyncConnect asynchronously connects to the VPP API using a new adapter instance +// created with NewVppAPIAdapter. +// +// This call does not block until connection is established, it returns immediately. +// The caller is supposed to watch the returned ConnectionState channel for connection events. +// In case of disconnect, the library will asynchronously try to reconnect. +func AsyncConnect(target string, attempts int, interval time.Duration) (*core.Connection, chan core.ConnectionEvent, error) { + return core.AsyncConnect(NewVppAdapter(target), attempts, interval) } -// Connect connects the govpp core to VPP either using the default VPP Adapter, or using the adapter previously -// set by SetAdapter (useful mostly just for unit/integration tests with mocked VPP adapter). -// This call blocks until VPP is connected, or an error occurs. Only one connection attempt will be performed. -func Connect(shm string) (*core.Connection, error) { - return core.Connect(getVppAdapter(shm)) +// NewVppAdapter returns new instance of VPP adapter for connecting to VPP API. +var NewVppAdapter = func(target string) adapter.VppAPI { + return socketclient.NewVppClient(target) } -// AsyncConnect asynchronously connects the govpp core to VPP either using the default VPP Adapter, -// or using the adapter previously set by SetAdapter. -// This call does not block until connection is established, it returns immediately. The caller is -// supposed to watch the returned ConnectionState channel for Connected/Disconnected events. -// In case of disconnect, the library will asynchronously try to reconnect. -func AsyncConnect(shm string, attempts int, interval time.Duration) (*core.Connection, chan core.ConnectionEvent, error) { - return core.AsyncConnect(getVppAdapter(shm), attempts, interval) +// Version returns version of GoVPP. +func Version() string { + return version.String() } diff --git a/internal/version/version.go b/internal/version/version.go new file mode 100644 index 00000000..e624d4c8 --- /dev/null +++ b/internal/version/version.go @@ -0,0 +1,134 @@ +// 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 version keeps track of versioning info for GoVPP. +package version + +import ( + "fmt" + "os" + "runtime" + "strconv" + "time" +) + +const ( + Major = 0 + Minor = 8 + Patch = 0 + PreRelease = "" +) + +// String formats the version string using semver format. +func String() string { + v := fmt.Sprintf("v%d.%d.%d", Major, Minor, Patch) + if PreRelease != "" { + v += "-" + PreRelease + } + return v +} + +// Following variables should normally be updated via `-ldflags "-X ..."`. +// However, the version string is hard-coded to ensure it is always included +// even with bare go build/install. +var ( + name = "govpp" + version = "v0.8.0" + commit = "unknown" + branch = "HEAD" + buildStamp = "" + buildUser = "unknown" + buildHost = "unknown" + + buildDate time.Time +) + +func init() { + buildstampInt64, _ := strconv.ParseInt(buildStamp, 10, 64) + if buildstampInt64 == 0 { + modTime, _ := binaryModTime() + buildstampInt64 = modTime.Unix() + } + buildDate = time.Unix(buildstampInt64, 0) +} + +func binaryModTime() (time.Time, error) { + // Get the path of the currently running binary + binaryPath, err := os.Executable() + if err != nil { + return time.Time{}, fmt.Errorf("unable to get current binary path: %w", err) + } + + // Get the file info for the binary + fileInfo, err := os.Stat(binaryPath) + if err != nil { + return time.Time{}, fmt.Errorf("unable to get file info for binary: %w", err) + } + + // Return the modification time + return fileInfo.ModTime(), nil +} + +func Version() string { + return version +} + +func Info() string { + return fmt.Sprintf(`%s %s`, name, version) +} + +func Verbose() string { + return fmt.Sprintf(`%s + Version: %s + Branch: %s + Revision: %s + Built by: %s@%s + Build date: %s + Go runtime: %s (%s/%s)`, + name, + version, branch, commit, + buildUser, buildHost, buildDate.Format(time.UnixDate), + runtime.Version(), runtime.GOOS, runtime.GOARCH, + ) +} + +func Short() string { + return fmt.Sprintf(`%s %s`, name, version) +} + +func BuildTime() string { + stamp := buildDate.Format(time.UnixDate) + if !buildDate.IsZero() { + stamp += fmt.Sprintf(" (%s)", timeAgo(buildDate)) + } + return stamp +} + +func BuiltBy() string { + return fmt.Sprintf("%s@%s (%s %s/%s)", + buildUser, buildHost, runtime.Version(), runtime.GOOS, runtime.GOARCH, + ) +} + +func timeAgo(t time.Time) string { + const timeDay = time.Hour * 24 + if ago := time.Since(t); ago > timeDay { + return fmt.Sprintf("%v days ago", float64(ago.Round(timeDay)/timeDay)) + } else if ago > time.Hour { + return fmt.Sprintf("%v hours ago", ago.Round(time.Hour).Hours()) + } else if ago > time.Minute { + return fmt.Sprintf("%v minutes ago", ago.Round(time.Minute).Minutes()) + } + return "just now" +} diff --git a/proxy/client.go b/proxy/client.go index c7c45eb1..17fd04c3 100644 --- a/proxy/client.go +++ b/proxy/client.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,6 +15,7 @@ package proxy import ( + "context" "fmt" "net/rpc" "reflect" @@ -117,11 +118,87 @@ func (s *StatsClient) GetBufferStats(bufStats *api.BufferStats) error { return nil } +func (s *StatsClient) GetMemoryStats(memStats *api.MemoryStats) error { + req := StatsRequest{StatsType: "memory"} + resp := StatsResponse{MemStats: new(api.MemoryStats)} + if err := s.rpc.Call("StatsRPC.GetStats", req, &resp); err != nil { + return err + } + *memStats = *resp.MemStats + return nil +} + type BinapiClient struct { rpc *rpc.Client timeout time.Duration } +// RPCStream is a stream for forwarding requests to BinapiRPC's stream. +type RPCStream struct { + ctx context.Context + rpc *rpc.Client + id uint32 +} + +func (s *RPCStream) Context() context.Context { + return s.ctx +} + +func (s *RPCStream) SendMsg(msg api.Message) error { + req := RPCStreamReqResp{ + ID: s.id, + Msg: msg, + } + resp := RPCStreamReqResp{} + err := s.rpc.Call("BinapiRPC.SendMessage", req, &resp) + if err != nil { + return fmt.Errorf("RPC SendMessage call failed: %v", err) + } + return nil +} + +func (s *RPCStream) RecvMsg() (api.Message, error) { + req := RPCStreamReqResp{ + ID: s.id, + } + resp := RPCStreamReqResp{} + err := s.rpc.Call("BinapiRPC.ReceiveMessage", req, &resp) + if err != nil { + return nil, fmt.Errorf("RPC ReceiveMessage call failed: %v", err) + } + return resp.Msg, nil +} + +func (s *RPCStream) Close() error { + req := RPCStreamReqResp{ + ID: s.id, + } + resp := RPCStreamReqResp{} + err := s.rpc.Call("BinapiRPC.CloseStream", req, &resp) + if err != nil { + return fmt.Errorf("RPC CloseStream call failed: %v", err) + } + return nil +} + +func (b *BinapiClient) NewStream(_ context.Context, _ ...api.StreamOption) (api.Stream, error) { + stream := &RPCStream{ + rpc: b.rpc, + } + req := RPCStreamReqResp{} + resp := RPCStreamReqResp{} + err := stream.rpc.Call("BinapiRPC.NewAPIStream", req, &resp) + if err != nil { + return nil, fmt.Errorf("RPC NewAPIStream call failed: %v", err) + } + stream.id = resp.ID + return stream, err +} + +func (b *BinapiClient) Invoke(_ context.Context, request api.Message, reply api.Message) error { + return invokeInternal(b.rpc, request, reply, b.timeout) +} + func (b *BinapiClient) SendRequest(msg api.Message) api.RequestCtx { req := &requestCtx{ rpc: b.rpc, @@ -139,20 +216,24 @@ type requestCtx struct { } func (r *requestCtx) ReceiveReply(msg api.Message) error { + return invokeInternal(r.rpc, r.req, msg, r.timeout) +} + +func invokeInternal(rpc *rpc.Client, msgIn, msgOut api.Message, timeout time.Duration) error { req := BinapiRequest{ - Msg: r.req, - ReplyMsg: msg, - Timeout: r.timeout, + Msg: msgIn, + ReplyMsg: msgOut, + Timeout: timeout, } resp := BinapiResponse{} - err := r.rpc.Call("BinapiRPC.Invoke", req, &resp) + err := rpc.Call("BinapiRPC.Invoke", req, &resp) if err != nil { return fmt.Errorf("RPC call failed: %v", err) } // we set the value of msg to the value from response - reflect.ValueOf(msg).Elem().Set(reflect.ValueOf(resp.Msg).Elem()) + reflect.ValueOf(msgOut).Elem().Set(reflect.ValueOf(resp.Msg).Elem()) return nil } diff --git a/proxy/server.go b/proxy/server.go index eced14dd..81f893b1 100644 --- a/proxy/server.go +++ b/proxy/server.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,6 +15,7 @@ package proxy import ( + "context" "errors" "fmt" "reflect" @@ -55,6 +56,7 @@ type StatsResponse struct { IfaceStats *api.InterfaceStats ErrStats *api.ErrorStats BufStats *api.BufferStats + MemStats *api.MemoryStats } // StatsRPC is a RPC server for proxying client request to api.StatsProvider. @@ -84,7 +86,7 @@ func NewStatsRPC(stats adapter.StatsAPI) (*StatsRPC, error) { func (s *StatsRPC) watchConnection() { heartbeatTicker := time.NewTicker(10 * time.Second).C atomic.StoreUint32(&s.available, 1) - log.Println("enabling statsRPC service") + log.Debugln("enabling statsRPC service") count := 0 prev := new(api.SystemStats) @@ -176,7 +178,7 @@ func (s *StatsRPC) serviceAvailable() bool { func (s *StatsRPC) GetStats(req StatsRequest, resp *StatsResponse) error { if !s.serviceAvailable() { - log.Println(statsErrorMsg) + log.Print(statsErrorMsg) return errors.New("server does not support 'get stats' at this time, try again later") } log.Debugf("StatsRPC.GetStats - REQ: %+v", req) @@ -200,6 +202,9 @@ func (s *StatsRPC) GetStats(req StatsRequest, resp *StatsResponse) error { case "buffer": resp.BufStats = new(api.BufferStats) return s.statsConn.GetBufferStats(resp.BufStats) + case "memory": + resp.MemStats = new(api.MemoryStats) + return s.statsConn.GetMemoryStats(resp.MemStats) default: return fmt.Errorf("unknown stats type: %s", req.StatsType) } @@ -222,15 +227,21 @@ type BinapiCompatibilityRequest struct { } type BinapiCompatibilityResponse struct { - CompatibleMsgs []string - IncompatibleMsgs []string + CompatibleMsgs map[string][]string + IncompatibleMsgs map[string][]string } -// BinapiRPC is a RPC server for proxying client request to api.Channel. +// BinapiRPC is a RPC server for proxying client request to api.Channel +// or api.Stream. type BinapiRPC struct { binapiConn *core.Connection binapi adapter.VppAPI + streamsLock sync.Mutex + // local ID, different from api.Stream ID + maxStreamID uint32 + streams map[uint32]api.Stream + events chan core.ConnectionEvent done chan struct{} // non-zero if the RPC service is available @@ -263,7 +274,7 @@ func (s *BinapiRPC) watchConnection() { case core.Connected: if !s.serviceAvailable() { atomic.StoreUint32(&s.available, 1) - log.Println("enabling binapiRPC service") + log.Debugln("enabling binapiRPC service") } case core.Disconnected: if s.serviceAvailable() { @@ -320,9 +331,104 @@ func (s *BinapiRPC) serviceAvailable() bool { return atomic.LoadUint32(&s.available) == 1 } +type RPCStreamReqResp struct { + ID uint32 + Msg api.Message +} + +func (s *BinapiRPC) NewAPIStream(req RPCStreamReqResp, resp *RPCStreamReqResp) error { + if !s.serviceAvailable() { + log.Print(binapiErrorMsg) + return errors.New("server does not support RPC calls at this time, try again later") + } + log.Debugf("BinapiRPC.NewAPIStream - REQ: %#v", req) + + stream, err := s.binapiConn.NewStream(context.Background()) + if err != nil { + return err + } + + if s.streams == nil { + s.streams = make(map[uint32]api.Stream) + } + + s.streamsLock.Lock() + s.maxStreamID++ + s.streams[s.maxStreamID] = stream + resp.ID = s.maxStreamID + s.streamsLock.Unlock() + + return nil +} + +func (s *BinapiRPC) SendMessage(req RPCStreamReqResp, resp *RPCStreamReqResp) error { + if !s.serviceAvailable() { + log.Print(binapiErrorMsg) + return errors.New("server does not support RPC calls at this time, try again later") + } + log.Debugf("BinapiRPC.SendMessage - REQ: %#v", req) + + stream, err := s.getStream(req.ID) + if err != nil { + return err + } + + return stream.SendMsg(req.Msg) +} + +func (s *BinapiRPC) ReceiveMessage(req RPCStreamReqResp, resp *RPCStreamReqResp) error { + if !s.serviceAvailable() { + log.Print(binapiErrorMsg) + return errors.New("server does not support RPC calls at this time, try again later") + } + log.Debugf("BinapiRPC.ReceiveMessage - REQ: %#v", req) + + stream, err := s.getStream(req.ID) + if err != nil { + return err + } + + resp.Msg, err = stream.RecvMsg() + return err +} + +func (s *BinapiRPC) CloseStream(req RPCStreamReqResp, resp *RPCStreamReqResp) error { + if !s.serviceAvailable() { + log.Print(binapiErrorMsg) + return errors.New("server does not support RPC calls at this time, try again later") + } + log.Debugf("BinapiRPC.CloseStream - REQ: %#v", req) + + stream, err := s.getStream(req.ID) + if err != nil { + return err + } + + s.streamsLock.Lock() + delete(s.streams, req.ID) + s.streamsLock.Unlock() + + return stream.Close() +} + +func (s *BinapiRPC) getStream(id uint32) (api.Stream, error) { + s.streamsLock.Lock() + stream := s.streams[id] + s.streamsLock.Unlock() + + if stream == nil || reflect.ValueOf(stream).IsNil() { + s.streamsLock.Lock() + // delete the stream in case it is still in the map + delete(s.streams, id) + s.streamsLock.Unlock() + return nil, errors.New("BinapiRPC stream closed") + } + return stream, nil +} + func (s *BinapiRPC) Invoke(req BinapiRequest, resp *BinapiResponse) error { if !s.serviceAvailable() { - log.Println(binapiErrorMsg) + log.Print(binapiErrorMsg) return errors.New("server does not support 'invoke' at this time, try again later") } log.Debugf("BinapiRPC.Invoke - REQ: %#v", req) @@ -364,7 +470,7 @@ func (s *BinapiRPC) Invoke(req BinapiRequest, resp *BinapiResponse) error { func (s *BinapiRPC) Compatibility(req BinapiCompatibilityRequest, resp *BinapiCompatibilityResponse) error { if !s.serviceAvailable() { - log.Println(binapiErrorMsg) + log.Print(binapiErrorMsg) return errors.New("server does not support 'compatibility check' at this time, try again later") } log.Debugf("BinapiRPC.Compatiblity - REQ: %#v", req) @@ -375,25 +481,37 @@ func (s *BinapiRPC) Compatibility(req BinapiCompatibilityRequest, resp *BinapiCo } defer ch.Close() - resp.CompatibleMsgs = make([]string, 0, len(req.MsgNameCrcs)) - resp.IncompatibleMsgs = make([]string, 0, len(req.MsgNameCrcs)) + resp.CompatibleMsgs = make(map[string][]string) + resp.IncompatibleMsgs = make(map[string][]string) - for _, msg := range req.MsgNameCrcs { - val, ok := api.GetRegisteredMessages()[msg] - if !ok { - resp.IncompatibleMsgs = append(resp.IncompatibleMsgs, msg) - continue + for path, messages := range api.GetRegisteredMessages() { + resp.IncompatibleMsgs[path] = make([]string, 0, len(req.MsgNameCrcs)) + resp.CompatibleMsgs[path] = make([]string, 0, len(req.MsgNameCrcs)) + + for _, msg := range req.MsgNameCrcs { + val, ok := messages[msg] + if !ok { + resp.IncompatibleMsgs[path] = append(resp.IncompatibleMsgs[path], msg) + continue + } + if err = ch.CheckCompatiblity(val); err != nil { + resp.IncompatibleMsgs[path] = append(resp.IncompatibleMsgs[path], msg) + } else { + resp.CompatibleMsgs[path] = append(resp.CompatibleMsgs[path], msg) + } } + } - if err = ch.CheckCompatiblity(val); err != nil { - resp.IncompatibleMsgs = append(resp.IncompatibleMsgs, msg) + compatible := false + for path, incompatibleMsgs := range resp.IncompatibleMsgs { + if len(incompatibleMsgs) == 0 { + compatible = true } else { - resp.CompatibleMsgs = append(resp.CompatibleMsgs, msg) + log.Debugf("messages are incompatible for path %s", path) } } - - if len(resp.IncompatibleMsgs) > 0 { - return fmt.Errorf("compatibility check failed for messages: %v", resp.IncompatibleMsgs) + if !compatible { + return errors.New("compatibility check failed") } return nil diff --git a/test/build/Dockerfile.integration b/test/build/Dockerfile.integration new file mode 100644 index 00000000..b30f399d --- /dev/null +++ b/test/build/Dockerfile.integration @@ -0,0 +1,48 @@ +FROM buildpack-deps:20.04-scm + +# Install gotestsum +ARG GOTESTSUM_VERSION=1.10.0 +RUN set -eux; \ + curl -fsSL https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz -o gotestsum.tar.gz; \ + tar -xf gotestsum.tar.gz gotestsum; \ + mv gotestsum /usr/local/bin/gotestsum; \ + rm gotestsum.tar.gz; + +# Install Go +ENV GOLANG_VERSION 1.20 + +RUN set -eux; \ + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) goRelArch='linux-amd64'; ;; \ + armhf) goRelArch='linux-armv6l'; ;; \ + arm64) goRelArch='linux-arm64'; ;; \ + esac; \ + wget -nv -O go.tgz "https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \ + tar -C /usr/local -xzf go.tgz; \ + rm go.tgz; + +ENV GOPATH /go +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH + +RUN set -eux; \ + mkdir -p "$GOPATH/src" "$GOPATH/bin"; \ + chmod -R 777 "$GOPATH"; + +ARG VPP_REPO=release + +# Install VPP +RUN set -eux; \ + apt-get update; \ + curl -fsSL https://packagecloud.io/install/repositories/fdio/${VPP_REPO}/script.deb.sh | bash; \ + apt-get update && apt-get install -V -y \ + vpp \ + vpp-plugin-core \ + ; \ + rm -rf /var/lib/apt/lists/* + +COPY vpp.conf /etc/vpp/vpp.conf + +WORKDIR /src + +CMD ["/usr/bin/vpp", "-c", "/etc/vpp/vpp.conf"] diff --git a/test/build/vpp.conf b/test/build/vpp.conf new file mode 100644 index 00000000..baac81a0 --- /dev/null +++ b/test/build/vpp.conf @@ -0,0 +1,21 @@ +unix { + nodaemon + log /var/log/vpp.log + cli-listen /run/vpp/cli.sock + cli-no-pager + full-coredump + pidfile /run/vpp/vpp.pid +} +api-trace { + on +} +socksvr { + socket-name /run/vpp/api.sock +} +statseg { + socket-name /run/vpp/stats.sock + per-node-counters on +} +plugins { + plugin dpdk_plugin.so { disable } +} diff --git a/test/integration/README.md b/test/integration/README.md new file mode 100644 index 00000000..d19d443c --- /dev/null +++ b/test/integration/README.md @@ -0,0 +1,60 @@ +Integration Tests +================= + +The GoVPP integration testing suite runs each test case against real VPP instance. + +The integration tests cases are grouped by files: +- `binapi` - runs tests for VPP API +- `examples` - run examples as tests +- `stats` - runs tests for VPP Stats +- `trace` - runs tests for VPP API trace +- `*` (*other*) - runs specialized tests + +## Running Tests + +The recommended way to run the integration tests is to use a self-contained testing environment, which is managed from a helper bash script [`run_integration.sh`](../run_integration.sh). The script will build a special Docker image that includes testing suite and other requirements (e.g. VPP, gotestsum..) and then will run the integration tests inside a container. + +```shell +make test-integration +``` + +This will run the tests against latest VPP release by default. To run against specific VPP version, add `VPP_REPO=` where `` is name of VPP repostiroy on packagecloud. + +```shell +# Run against specific VPP version +make test-integration VPP_REPO=2306 + +# Run against VPP master branch +make test-integration VPP_REPO=master +``` + +The make target above simply runs a helper script which accepts additional arguments that are passed down directly to `go test ...`. + +```shell +# Usage: +# ./test/integration/run_integration.sh + +# Run with verbose mode +./test/integration/run_integration.sh -test.v +``` + +### Run Specific Test Case + +To run a specific integration test case(s): + +```shell +./test/integration/run_integration.sh -test.run="Interfaces" +``` + +## Running Tests on your Host + +If the script `run_integration.sh` is not used to run tests and the test cases +are directly used, the tests will try to start/stop VPP instance for each test +case individually. + +> **Warning** +> This method requires VPP to be installed on your host system. + +```shell +TEST=integration go test ./test/integration +``` diff --git a/test/integration/binapi_test.go b/test/integration/binapi_test.go new file mode 100644 index 00000000..778543b2 --- /dev/null +++ b/test/integration/binapi_test.go @@ -0,0 +1,91 @@ +// Copyright (c) 2022 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 integration + +import ( + "context" + "io" + "testing" + + interfaces "github.com/alkiranet/govpp/binapi/interface" + "github.com/alkiranet/govpp/binapi/vpe" + "github.com/alkiranet/govpp/test/vpptesting" +) + +// TestVersion tests that getting VPP version works. +func TestVersion(t *testing.T) { + test := vpptesting.SetupVPP(t) + + vpeRPC := vpe.NewServiceClient(test.Conn) + + versionInfo, err := vpeRPC.ShowVersion(context.Background(), &vpe.ShowVersion{}) + if err != nil { + t.Fatalf("getting version failed: %v", err) + } + + t.Logf("VPP version: %v", versionInfo.Version) + if versionInfo.Version == "" { + t.Fatal("expected VPP version to not be empty") + } +} + +// TestInterfacesLoopback tests that creating a loopback interface works and returns +// non-zero ID and that the interface will be listed in interface dump. +func TestInterfacesLoopback(t *testing.T) { + test := vpptesting.SetupVPP(t) + ctx := context.Background() + + ifacesRPC := interfaces.NewServiceClient(test.Conn) + + // create loopback interface + reply, err := ifacesRPC.CreateLoopback(ctx, &interfaces.CreateLoopback{}) + if err != nil { + t.Fatal("interfaces.CreateLoopback error:", err) + } + loopId := reply.SwIfIndex + t.Logf("loopback interface created (id: %v)", reply.SwIfIndex) + + // list interfaces + stream, err := ifacesRPC.SwInterfaceDump(ctx, &interfaces.SwInterfaceDump{}) + if err != nil { + t.Fatal("interfaces.SwInterfaceDump error:", err) + } + + t.Log("Dumping interfaces") + foundLoop := false + numIfaces := 0 + for { + iface, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + t.Fatal("interfaces.SwInterfaceDump/Recv error:", err) + } + numIfaces++ + t.Logf("- interface[%d]: %q\n", iface.SwIfIndex, iface.InterfaceName) + if iface.SwIfIndex == loopId { + foundLoop = true + } + } + + // verify expected + if !foundLoop { + t.Fatalf("loopback interface (id: %v) not found", loopId) + } + if numIfaces != 2 { + t.Errorf("expected 2 interfaces in dump, got %d", numIfaces) + } +} diff --git a/test/integration/examples_test.go b/test/integration/examples_test.go new file mode 100644 index 00000000..5975a10f --- /dev/null +++ b/test/integration/examples_test.go @@ -0,0 +1,53 @@ +// Copyright (c) 2022 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 integration + +import ( + "io/fs" + "os/exec" + "path/filepath" + "testing" + + "github.com/alkiranet/govpp/test/vpptesting" +) + +func TestExamples(t *testing.T) { + skipTestIfGoNotInstalled(t) + + if err := filepath.WalkDir("./examples", func(path string, d fs.DirEntry, err error) error { + if !d.IsDir() || filepath.Base(d.Name()) == "examples" { + return nil + } + example := filepath.Base(d.Name()) + t.Run(example, func(tt *testing.T) { + testExample(tt, example) + }) + return nil + }); err != nil { + t.Fatalf("walking examples dir error: %v", err) + } +} + +func testExample(t *testing.T, example string) { + vpptesting.SetupVPP(t) + + cmd := exec.Command("go", "run", "./examples/"+example) + t.Logf("executing command '%v'", cmd) + out, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("example %s failed: command '%s' error: %+v\n%s", example, cmd, err, out) + } + t.Logf("example %s output: %s", example, out) +} diff --git a/test/integration/main_test.go b/test/integration/main_test.go new file mode 100644 index 00000000..4c652601 --- /dev/null +++ b/test/integration/main_test.go @@ -0,0 +1,44 @@ +// Copyright (c) 2022 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 integration contains tests against running VPP instance. +// The test cases are only executed if env contains TEST=integration. +package integration + +import ( + "fmt" + "os" + "os/exec" + "testing" +) + +var ( + // IntegrationTestsActive is set to true if integration tests should run. + IntegrationTestsActive = os.Getenv("TEST") == "integration" +) + +func TestMain(m *testing.M) { + if IntegrationTestsActive { + os.Exit(m.Run()) + } + fmt.Fprintf(os.Stderr, "integration tests are NOT enabled (set TEST='integration' to enable)\n") + os.Exit(0) +} + +func skipTestIfGoNotInstalled(t *testing.T) { + _, err := exec.LookPath("go") + if err != nil { + t.Skipf("`go` command is not available, skipping test") + } +} diff --git a/test/integration/stats_integration_test.go b/test/integration/stats_integration_test.go deleted file mode 100644 index 57a79b45..00000000 --- a/test/integration/stats_integration_test.go +++ /dev/null @@ -1,176 +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. - -//go:build integration -// +build integration - -package integration - -import ( - "flag" - "testing" - - "github.com/alkiranet/govpp/adapter/statsclient" - "github.com/alkiranet/govpp/api" - "github.com/alkiranet/govpp/core" -) - -var ( - statsSocket = flag.String("socket", statsclient.DefaultSocketName, "Path to VPP stats socket") -) - -func TestStatClientAll(t *testing.T) { - client := statsclient.NewStatsClient(*statsSocket) - - c, err := core.ConnectStats(client) - if err != nil { - t.Fatal("Connecting failed:", err) - } - defer c.Disconnect() - - sysStats := new(api.SystemStats) - nodeStats := new(api.NodeStats) - errorStats := new(api.ErrorStats) - ifaceStats := new(api.InterfaceStats) - - if err = c.GetNodeStats(nodeStats); err != nil { - t.Fatal("updating node stats failed:", err) - } - if err = c.GetSystemStats(sysStats); err != nil { - t.Fatal("updating system stats failed:", err) - } - if err = c.GetErrorStats(errorStats); err != nil { - t.Fatal("updating error stats failed:", err) - } - if err = c.GetInterfaceStats(ifaceStats); err != nil { - t.Fatal("updating interface stats failed:", err) - } -} - -func TestStatClientNodeStats(t *testing.T) { - client := statsclient.NewStatsClient(*statsSocket) - - c, err := core.ConnectStats(client) - if err != nil { - t.Fatal("Connecting failed:", err) - } - defer c.Disconnect() - - stats := new(api.NodeStats) - - if err := c.GetNodeStats(stats); err != nil { - t.Fatal("getting node stats failed:", err) - } -} - -func TestStatClientNodeStatsAgain(t *testing.T) { - client := statsclient.NewStatsClient(*statsSocket) - c, err := core.ConnectStats(client) - if err != nil { - t.Fatal("Connecting failed:", err) - } - defer c.Disconnect() - - stats := new(api.NodeStats) - - if err := c.GetNodeStats(stats); err != nil { - t.Fatal("getting node stats failed:", err) - } - if err := c.GetNodeStats(stats); err != nil { - t.Fatal("getting node stats failed:", err) - } -} - -func BenchmarkStatClientNodeStatsGet1(b *testing.B) { benchStatClientNodeStatsGet(b, 1) } -func BenchmarkStatClientNodeStatsGet10(b *testing.B) { benchStatClientNodeStatsGet(b, 10) } - -func benchStatClientNodeStatsGet(b *testing.B, repeatN int) { - client := statsclient.NewStatsClient(*statsSocket) - c, err := core.ConnectStats(client) - if err != nil { - b.Fatal("Connecting failed:", err) - } - defer c.Disconnect() - - b.ResetTimer() - nodeStats := new(api.NodeStats) - for i := 0; i < b.N; i++ { - for r := 0; r < repeatN; r++ { - if err = c.GetNodeStats(nodeStats); err != nil { - b.Fatal("getting node stats failed:", err) - } - } - } - b.StopTimer() -} - -func BenchmarkStatClientNodeStatsUpdate1(b *testing.B) { benchStatClientNodeStatsLoad(b, 1) } -func BenchmarkStatClientNodeStatsUpdate10(b *testing.B) { benchStatClientNodeStatsLoad(b, 10) } - -func benchStatClientNodeStatsLoad(b *testing.B, repeatN int) { - client := statsclient.NewStatsClient(*statsSocket) - c, err := core.ConnectStats(client) - if err != nil { - b.Fatal("Connecting failed:", err) - } - defer c.Disconnect() - nodeStats := new(api.NodeStats) - - b.ResetTimer() - for i := 0; i < b.N; i++ { - for r := 0; r < repeatN; r++ { - if err = c.GetNodeStats(nodeStats); err != nil { - b.Fatal("getting node stats failed:", err) - } - } - } - b.StopTimer() -} - -func BenchmarkStatClientStatsUpdate1(b *testing.B) { benchStatClientStatsUpdate(b, 1) } -func BenchmarkStatClientStatsUpdate10(b *testing.B) { benchStatClientStatsUpdate(b, 10) } -func BenchmarkStatClientStatsUpdate100(b *testing.B) { benchStatClientStatsUpdate(b, 100) } - -func benchStatClientStatsUpdate(b *testing.B, repeatN int) { - client := statsclient.NewStatsClient(*statsSocket) - c, err := core.ConnectStats(client) - if err != nil { - b.Fatal("Connecting failed:", err) - } - defer c.Disconnect() - - sysStats := new(api.SystemStats) - nodeStats := new(api.NodeStats) - errorStats := new(api.ErrorStats) - ifaceStats := new(api.InterfaceStats) - - b.ResetTimer() - for i := 0; i < b.N; i++ { - for r := 0; r < repeatN; r++ { - if err = c.GetNodeStats(nodeStats); err != nil { - b.Fatal("updating node stats failed:", err) - } - if err = c.GetSystemStats(sysStats); err != nil { - b.Fatal("updating system stats failed:", err) - } - if err = c.GetErrorStats(errorStats); err != nil { - b.Fatal("updating error stats failed:", err) - } - if err = c.GetInterfaceStats(ifaceStats); err != nil { - b.Fatal("updating error stats failed:", err) - } - } - } - b.StopTimer() -} diff --git a/test/integration/stats_test.go b/test/integration/stats_test.go new file mode 100644 index 00000000..142723ee --- /dev/null +++ b/test/integration/stats_test.go @@ -0,0 +1,99 @@ +// Copyright (c) 2022 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 integration + +import ( + "testing" + + "github.com/alkiranet/govpp/api" + "github.com/alkiranet/govpp/test/vpptesting" +) + +func TestStatClientAll(t *testing.T) { + test := vpptesting.SetupVPP(t) + + c := test.StatsConn() + + var err error + t.Run("SystemStats", func(t *testing.T) { + stats := new(api.SystemStats) + if err = c.GetSystemStats(stats); err != nil { + t.Fatal("getting stats failed:", err) + } + t.Logf("%+v", stats) + }) + t.Run("NodeStats", func(t *testing.T) { + stats := new(api.NodeStats) + if err = c.GetNodeStats(stats); err != nil { + t.Fatal("getting stats failed:", err) + } + t.Logf("%d node stats", len(stats.Nodes)) + }) + t.Run("ErrorStats", func(t *testing.T) { + stats := new(api.ErrorStats) + if err = c.GetErrorStats(stats); err != nil { + t.Fatal("getting stats failed:", err) + } + t.Logf("%d error stats", len(stats.Errors)) + }) + t.Run("InterfaceStats", func(t *testing.T) { + stats := new(api.InterfaceStats) + if err = c.GetInterfaceStats(stats); err != nil { + t.Fatal("getting stats failed:", err) + } + t.Logf("%d interface stats", len(stats.Interfaces)) + }) + t.Run("MemoryStats", func(t *testing.T) { + stats := new(api.MemoryStats) + if err = c.GetMemoryStats(stats); err != nil { + t.Fatal("getting stats failed:", err) + } + t.Logf("%d main, %d stat memory stats", len(stats.Main), len(stats.Stat)) + }) + t.Run("BufferStats", func(t *testing.T) { + stats := new(api.BufferStats) + if err = c.GetBufferStats(stats); err != nil { + t.Fatal("getting stats failed:", err) + } + t.Logf("%d buffers stats", len(stats.Buffer)) + }) +} + +func TestStatClientNodeStats(t *testing.T) { + test := vpptesting.SetupVPP(t) + + c := test.StatsConn() + + stats := new(api.NodeStats) + + if err := c.GetNodeStats(stats); err != nil { + t.Fatal("getting node stats failed:", err) + } +} + +func TestStatClientNodeStatsAgain(t *testing.T) { + test := vpptesting.SetupVPP(t) + + c := test.StatsConn() + + stats := new(api.NodeStats) + + if err := c.GetNodeStats(stats); err != nil { + t.Fatal("getting node stats failed:", err) + } + if err := c.GetNodeStats(stats); err != nil { + t.Fatal("getting node stats failed:", err) + } +} diff --git a/test/integration/trace_test.go b/test/integration/trace_test.go new file mode 100644 index 00000000..162c5f28 --- /dev/null +++ b/test/integration/trace_test.go @@ -0,0 +1,65 @@ +// Copyright (c) 2023 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 integration + +import ( + "context" + "fmt" + "testing" + + "github.com/alkiranet/govpp/api" + "github.com/alkiranet/govpp/binapi/vpe" + "github.com/alkiranet/govpp/test/vpptesting" +) + +func TestTrace(t *testing.T) { + test := vpptesting.SetupVPP(t) + + test.Conn.Trace().Enable(true) + + runTraceRequests(t, test) + + records := test.Conn.Trace().GetRecords() + + if len(records) != 2 { + t.Fatalf("expected 2 records, got %d", len(records)) + } + + printTraceRecords(t, records) +} + +func printTraceRecords(t *testing.T, records []*api.Record) { + t.Logf("API trace (records: %d):\n", len(records)) + t.Logf("--------------------\n") + for _, item := range records { + h, m, s := item.Timestamp.Clock() + reply := "" + if item.IsReceived { + reply = "(reply)" + } + fmt.Printf("%dh:%dm:%ds:%dns %s %s\n", h, m, s, + item.Timestamp.Nanosecond(), item.Message.GetMessageName(), reply) + } + t.Logf("--------------------\n") +} + +func runTraceRequests(t *testing.T, test *vpptesting.TestCtx) { + vpeRPC := vpe.NewServiceClient(test.Conn) + + _, err := vpeRPC.ShowVersion(context.Background(), &vpe.ShowVersion{}) + if err != nil { + t.Fatalf("getting version failed: %v", err) + } +} diff --git a/test/performance/benchmark_test.go b/test/performance/benchmark_test.go new file mode 100644 index 00000000..0d6c39be --- /dev/null +++ b/test/performance/benchmark_test.go @@ -0,0 +1,141 @@ +// Copyright (c) 2022 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 performance + +import ( + "testing" + + "github.com/alkiranet/govpp/adapter" + "github.com/alkiranet/govpp/adapter/statsclient" + "github.com/alkiranet/govpp/api" + "github.com/alkiranet/govpp/core" + "github.com/alkiranet/govpp/test/vpptesting" +) + +func newStatsClient() adapter.StatsAPI { + return statsclient.NewStatsClient("") +} + +func BenchmarkStatClientNodeStatsGet(b *testing.B) { + ctx := vpptesting.SetupVPP(b) + defer ctx.TeardownVPP() + + b.Run("1", func(b *testing.B) { + benchStatClientNodeStatsGet(b, 1) + }) + b.Run("10", func(b *testing.B) { + benchStatClientNodeStatsGet(b, 10) + }) +} + +func benchStatClientNodeStatsGet(b *testing.B, repeatN int) { + client := newStatsClient() + c, err := core.ConnectStats(client) + if err != nil { + b.Fatal("Connecting failed:", err) + } + defer c.Disconnect() + + b.ResetTimer() + nodeStats := new(api.NodeStats) + for i := 0; i < b.N; i++ { + for r := 0; r < repeatN; r++ { + if err = c.GetNodeStats(nodeStats); err != nil { + b.Fatal("getting node stats failed:", err) + } + } + } + b.StopTimer() +} + +func BenchmarkStatClientNodeStatsUpdate(b *testing.B) { + ctx := vpptesting.SetupVPP(b) + defer ctx.TeardownVPP() + + b.Run("1", func(b *testing.B) { + benchStatClientNodeStatsLoad(b, 1) + }) + b.Run("10", func(b *testing.B) { + benchStatClientNodeStatsLoad(b, 10) + }) +} + +func benchStatClientNodeStatsLoad(b *testing.B, repeatN int) { + client := newStatsClient() + c, err := core.ConnectStats(client) + if err != nil { + b.Fatal("Connecting failed:", err) + } + defer c.Disconnect() + nodeStats := new(api.NodeStats) + + b.ResetTimer() + for i := 0; i < b.N; i++ { + for r := 0; r < repeatN; r++ { + if err = c.GetNodeStats(nodeStats); err != nil { + b.Fatal("getting node stats failed:", err) + } + } + } + b.StopTimer() +} + +func BenchmarkStatClientStatsUpdate(b *testing.B) { + ctx := vpptesting.SetupVPP(b) + defer ctx.TeardownVPP() + + b.Run("1", func(b *testing.B) { + benchStatClientStatsUpdate(b, 1) + }) + b.Run("10", func(b *testing.B) { + benchStatClientStatsUpdate(b, 10) + }) + b.Run("100", func(b *testing.B) { + benchStatClientStatsUpdate(b, 100) + }) +} + +func benchStatClientStatsUpdate(b *testing.B, repeatN int) { + client := newStatsClient() + c, err := core.ConnectStats(client) + if err != nil { + b.Fatal("Connecting failed:", err) + } + defer c.Disconnect() + + sysStats := new(api.SystemStats) + nodeStats := new(api.NodeStats) + errorStats := new(api.ErrorStats) + ifaceStats := new(api.InterfaceStats) + + b.ResetTimer() + for i := 0; i < b.N; i++ { + for r := 0; r < repeatN; r++ { + if err = c.GetNodeStats(nodeStats); err != nil { + b.Fatal("updating node stats failed:", err) + } + if err = c.GetSystemStats(sysStats); err != nil { + b.Fatal("updating system stats failed:", err) + } + if err = c.GetErrorStats(errorStats); err != nil { + b.Fatal("updating error stats failed:", err) + } + if err = c.GetInterfaceStats(ifaceStats); err != nil { + b.Fatal("updating error stats failed:", err) + } + } + } + b.StopTimer() +} diff --git a/test/run_integration.sh b/test/run_integration.sh new file mode 100755 index 00000000..2cc26e15 --- /dev/null +++ b/test/run_integration.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +# // Copyright (c) 2022 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. + +set -euo pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P )" + +args=($*) + +echo "Preparing integration tests.." + +VPP_REPO=${VPP_REPO:-release} + +export CGO_ENABLED=0 +export DOCKER_BUILDKIT=1 +export GOTESTSUM_FORMAT="${GOTESTSUM_FORMAT:-testname}" + +imgtag="govpp-integration" + +go test -c -o test/integration.test \ + -tags 'osusergo netgo e2e' \ + -ldflags '-w -s -extldflags "-static"' \ + -trimpath \ + "${SCRIPT_DIR}/integration" + +docker build --tag "${imgtag}" \ + -f "${SCRIPT_DIR}"/build/Dockerfile.integration \ + --build-arg VPP_REPO="${VPP_REPO}" \ + "${SCRIPT_DIR}"/build + +vppver=$(docker run --rm -i "${imgtag}" dpkg-query -f '${Version}' -W vpp) + +echo "==========================================================================" +echo " GOVPP INTEGRATION TEST - $(date) " +echo "==========================================================================" +echo "- VPP_REPO: $VPP_REPO" +echo "- VPP version: $vppver" +echo "--------------------------------------------------------------------------" + +if docker run -i --privileged \ + -e TEST=integration \ + -e CGO_ENABLED=0 \ + -e DEBUG_GOVPP \ + -e GOTESTSUM_FORMAT \ + -e CLICOLOR_FORCE \ + -v "$(cd "${SCRIPT_DIR}/.." && pwd)":/src \ + -w /src \ + "${imgtag}" gotestsum --raw-command -- go tool test2json -t -p integration ./test/integration.test -test.v ${args[@]:-} +then + echo >&2 "-------------------------------------------------------------" + echo >&2 -e " \e[32mPASSED\e[0m (took: ${SECONDS}s)" + echo >&2 "-------------------------------------------------------------" + exit 0 +else + res=$? + echo >&2 "-------------------------------------------------------------" + echo >&2 -e " \e[31mFAILED!\e[0m (exit code: $res)" + echo >&2 "-------------------------------------------------------------" + exit $res +fi diff --git a/test/vpptesting/vpplauncher/vpplauncher.go b/test/vpptesting/vpplauncher/vpplauncher.go new file mode 100644 index 00000000..052103ee --- /dev/null +++ b/test/vpptesting/vpplauncher/vpplauncher.go @@ -0,0 +1,269 @@ +// Copyright (c) 2022 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 vpplauncher + +import ( + "bytes" + "errors" + "fmt" + "os" + "os/exec" + "strconv" + "strings" + "syscall" + "time" +) + +const ( + defaultVppBinary = "/usr/bin/vpp" +) + +const ( + defaultRuntimeDir = "/run/vpp" + defaultAPISocket = "/run/vpp/api.sock" + defaultCLISocket = "/run/vpp/cli.sock" + defaultStatsSocket = "/run/vpp/stats.sock" + defaultPIDFile = "/run/vpp/vpp.pid" +) + +/*const ( + vppBuildDirRelease = "build-root/build-vpp-native/vpp/" + vppBuildDirDebug = "build-root/build-vpp_debug-native/vpp/" + vppInstallDirRelease = "build-root/install-vpp-native/vpp/" + vppInstallDirDebug = "build-root/install-vpp_debug-native/vpp/" +)*/ + +const defaultStartupConf = `unix { + nodaemon + log /tmp/vpp.log + cli-listen /run/vpp/cli.sock + cli-no-pager + cli-prompt vpp-test + full-coredump + coredump-size unlimited + nosyslog + gid vpp + pidfile /run/vpp/vpp.pid +} +api-trace { + on +} +api-segment { + gid vpp +} +logging { + size 1024 + default-log-level debug +} +socksvr { + socket-name /run/vpp/api.sock +} +statseg { + socket-name /run/vpp/stats.sock +} +plugins { + plugin dpdk_plugin.so { disable } +}` + +func LaunchVPP() (*VPP, error) { + opts := Options{} + vpp, err := NewVPP(opts) + if err != nil { + return nil, err + } + if vpp.CheckRunning() { + return nil, fmt.Errorf("already running") + } + if err := vpp.Start(); err != nil { + return nil, err + } + return vpp, vpp.WaitStarted() +} + +type Options struct { + Path string // path to executable + Config string // startup config contents + Pidfile string // path to pidfile +} + +func (opts *Options) fillDefaults() { + if opts.Path == "" { + opts.Path = defaultVppBinary + } + if opts.Config == "" { + opts.Config = defaultStartupConf + opts.Pidfile = defaultPIDFile + } +} + +type VPP struct { + opts Options + + cmd *exec.Cmd + stdout, stderr bytes.Buffer + exit chan struct{} + exitErr error +} + +func NewVPP(opts Options) (*VPP, error) { + p := &VPP{ + opts: opts, + } + p.opts.fillDefaults() + return p, nil +} + +func (p *VPP) CheckRunning() bool { + if p.opts.Pidfile == "" { + return false + } + if _, err := os.Stat(p.opts.Pidfile); err != nil { + return false + } + b, err := os.ReadFile(p.opts.Pidfile) + if err != nil { + return false + } + pid, err := strconv.Atoi(string(b)) + if err != nil { + return false + } + proc, err := os.FindProcess(pid) + if err != nil { + return false + } + return proc.Pid == pid +} + +const ( + checkPidfileDelay = time.Millisecond * 10 + checkPidfileRetry = 5000 +) + +func (p *VPP) WaitStarted() error { + if p.opts.Pidfile == "" { + return fmt.Errorf("no pidfile defined") + } + ch := make(chan error) + go func() { + for i := 0; i < checkPidfileRetry; i++ { + _, err := os.Stat(p.opts.Pidfile) + if os.IsNotExist(err) { + time.Sleep(checkPidfileDelay) + continue + } + ch <- err + return + } + ch <- fmt.Errorf("timeout waiting for pidfile") + }() + select { + case err := <-p.OnExit(): + return err + case err := <-ch: + return err + } +} + +func (p *VPP) Start() error { + if p.cmd != nil { + return fmt.Errorf("already started") + } + + // start process + p.cmd = exec.Command(p.opts.Path, p.opts.Config) + p.cmd.Stderr = &p.stderr + p.cmd.Stdout = &p.stdout + p.cmd.SysProcAttr = &syscall.SysProcAttr{ + Setpgid: true, // set process group ID + Pdeathsig: syscall.SIGKILL, // send kill to VPP process on exit + } + if err := p.cmd.Start(); err != nil { + return err + } + + // wait for exit in goroutine + p.exit = make(chan struct{}) + go func() { + err := p.cmd.Wait() + if err != nil { + var exiterr *exec.ExitError + if errors.As(err, &exiterr) { + if strings.Contains(exiterr.Error(), "core dumped") { + err = fmt.Errorf("VPP crashed (%w) stderr: %s", exiterr, exiterr.Stderr) + } else { + err = fmt.Errorf("VPP exited (%w) stderr: %s", exiterr, exiterr.Stderr) + } + } + } + p.exitErr = err + close(p.exit) + }() + + return nil +} + +func (p *VPP) PID() int { + if p.cmd == nil { + return 0 + } + return p.cmd.Process.Pid +} + +func (p *VPP) OnExit() <-chan error { + ch := make(chan error, 1) + if p.cmd == nil { + ch <- fmt.Errorf("not running") + close(ch) + } else { + go func() { + <-p.exit + ch <- p.exitErr + close(ch) + }() + } + return ch +} + +const ( + vppExitTimeout = time.Millisecond * 100 +) + +func (p *VPP) Stop() error { + if p.cmd == nil { + return fmt.Errorf("not running") + } + defer func() { + p.cmd = nil + }() + // send signal to stop + if err := p.cmd.Process.Signal(syscall.SIGTERM); err != nil { + return fmt.Errorf("sending TERM signal failed: %w", err) + } + // wait until exit or timeout + select { + case <-p.exit: + return p.exitErr + case <-time.After(vppExitTimeout): + return p.kill() + } +} + +func (p *VPP) kill() error { + if err := p.cmd.Process.Signal(syscall.SIGKILL); err != nil { + return fmt.Errorf("sending KILL signal VPP failed: %w", err) + } + return nil +} diff --git a/test/vpptesting/vpptest.go b/test/vpptesting/vpptest.go new file mode 100644 index 00000000..29e5abc9 --- /dev/null +++ b/test/vpptesting/vpptest.go @@ -0,0 +1,269 @@ +// Copyright (c) 2022 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 vpptesting + +import ( + "bytes" + "context" + "fmt" + "os" + "os/exec" + "strings" + "testing" + "time" + + "github.com/mitchellh/go-ps" + "github.com/sirupsen/logrus" + + "github.com/alkiranet/govpp/adapter/socketclient" + "github.com/alkiranet/govpp/adapter/statsclient" + govppapi "github.com/alkiranet/govpp/api" + "github.com/alkiranet/govpp/binapi/memclnt" + "github.com/alkiranet/govpp/binapi/vlib" + govppcore "github.com/alkiranet/govpp/core" + "github.com/alkiranet/govpp/test/vpptesting/vpplauncher" +) + +var ( + runDir = "/run/vpp" + apiSock = "/run/vpp/api.sock" + pidFile = "/run/vpp/vpp.pid" + statsSock = "/run/vpp/stats.sock" + //cliSock = "/run/vpp/cli.sock" +) + +const ( + vppConnectDelay = time.Millisecond * 50 + vppConnectRetryDelay = time.Millisecond * 50 + vppConnectRetryNum = 3 + vppStopDelay = time.Millisecond * 50 + vppDisconnectTimeout = time.Millisecond * 50 +) + +type TestCtx struct { + T testing.TB + vppCmd *vpplauncher.VPP + Conn *govppcore.Connection + statsConn *govppcore.StatsConnection + memclntRPC memclnt.RPCService + vlibRPC vlib.RPCService +} + +func SetupVPP(t testing.TB) (tc *TestCtx) { + // check VPP is not running + if err := vppAlreadyRunning(); err != nil { + t.Fatalf("%v", err) + } + + // remove files from previous run + removeFile(apiSock) + removeFile(statsSock) + removeFile(pidFile) + + // ensure VPP runtime directory exists + createDir(runDir) + + // start VPP process + vppCmd, err := vpplauncher.LaunchVPP() + if err != nil { + t.Fatalf("starting VPP failed: %v", err) + } + + defer func() { + if t.Failed() { + // if SetupVPP fails we need stop the VPP process + if err := vppCmd.Stop(); err != nil { + t.Errorf("stopping VPP failed: %v", err) + } + + } else { + // if not, we register a cleanup function to be called when the test completes + t.Cleanup(tc.TeardownVPP) + } + }() + + time.Sleep(vppConnectDelay) + + // connect to binapi + adapter := socketclient.NewVppClient(apiSock) + if err := adapter.WaitReady(); err != nil { + logrus.Warnf("WaitReady error: %v", err) + } + + var conn *govppcore.Connection + err = retry(vppConnectRetryNum, func() (err error) { + conn, err = govppcore.Connect(adapter) + return + }) + if err != nil { + t.Fatalf("connecting to VPP failed: %v", err) + } + + memclntRPC := memclnt.NewServiceClient(conn) + vlibRPC := vlib.NewServiceClient(conn) + + // send ping + vpeInfo, err := memclntRPC.ControlPing(context.Background(), &memclnt.ControlPing{}) + if err != nil { + t.Fatalf("getting vpp info failed: %v", err) + } + + // compare PID + vppPID := uint32(vppCmd.PID()) + if vpeInfo.VpePID != vppPID { + t.Fatalf("expected VPP PID to be %v, got %v", vppPID, vpeInfo.VpePID) + } + + return &TestCtx{ + T: t, + vppCmd: vppCmd, + Conn: conn, + memclntRPC: memclntRPC, + vlibRPC: vlibRPC, + } +} + +func vppAlreadyRunning() error { + processes, err := ps.Processes() + if err != nil { + return fmt.Errorf("listing processes failed: %v", err) + } + for _, process := range processes { + proc := process.Executable() + switch proc { + case "vpp", "vpp_main": + return fmt.Errorf("VPP is already running (PID: %v)", process.Pid()) + } + } + return nil +} + +func (ctx *TestCtx) StatsConn() *govppcore.StatsConnection { + if ctx.statsConn != nil { + return ctx.statsConn + } + statsClient := statsclient.NewStatsClient(statsSock) + var err error + ctx.statsConn, err = govppcore.ConnectStats(statsClient) + if err != nil { + ctx.T.Fatalf("connecting to stats failed: %v", err) + } + return ctx.statsConn +} + +func (ctx *TestCtx) TeardownVPP() { + // disconnect sometimes hangs + disconnected := make(chan struct{}) + go func() { + if ctx.statsConn != nil { + ctx.statsConn.Disconnect() + ctx.statsConn = nil + } + ctx.Conn.Disconnect() + close(disconnected) + }() + // wait until disconnected or timeout + select { + case <-disconnected: + time.Sleep(vppStopDelay) + case <-time.After(vppDisconnectTimeout): + logrus.Debugf("VPP disconnect timeout") + } + + if err := ctx.vppCmd.Stop(); err != nil { + ctx.T.Logf("stopping VPP failed: %v", err) + } +} + +func (ctx *TestCtx) MustCli(cmd ...string) { + for _, c := range cmd { + if _, err := ctx.RunCli(c); err != nil { + ctx.T.Fatal(err) + } + } +} + +func (ctx *TestCtx) RunCli(cmd string) (string, error) { + ctx.T.Helper() + logrus.Debugf("RunCli: %q", cmd) + reply, err := ctx.vlibRPC.CliInband(context.Background(), &vlib.CliInband{ + Cmd: cmd, + }) + if err != nil { + return "", fmt.Errorf("CLI '%v' failed: %v", cmd, err) + } + if strings.TrimSpace(reply.Reply) != "" { + logrus.Debugf(" cli reply: %s", reply.Reply) + } + if err := govppapi.RetvalToVPPApiError(reply.Retval); err != nil { + return "", fmt.Errorf("CLI '%v' error: %v", cmd, err) + } + return reply.Reply, nil +} + +func (ctx *TestCtx) RunCmd(cmd string, args ...string) (string, error) { + ctx.T.Helper() + stdout, stderr, err := ctx.execCmd(cmd, args...) + if err != nil { + return "", fmt.Errorf("command failed: %v\n%s", err, stderr) + } + return stdout, nil +} + +func (ctx *TestCtx) execCmd(cmd string, args ...string) (string, string, error) { + logrus.Debugf("exec: '%s %s'", cmd, strings.Join(args, " ")) + c := exec.Command(cmd, args...) + var stdout, stderr bytes.Buffer + c.Stdout = &stdout + c.Stderr = &stderr + err := c.Run() + if strings.TrimSpace(stdout.String()) != "" { + logrus.Debugf(" stdout:\n%s", stdout.String()) + } + if strings.TrimSpace(stderr.String()) != "" { + logrus.Debugf(" stderr:\n%s", stderr.String()) + } + return stdout.String(), stderr.String(), err +} + +func retry(retries int, fn func() error) (err error) { + for i := 1; true; i++ { + if err = fn(); err == nil { + logrus.Debugf("retry attempt #%d succeeded", i) + return nil + } else if i >= retries { + break + } + logrus.Debugf("retry attempt #%d failed: %v, retrying in %v", i, err, vppConnectRetryDelay) + time.Sleep(vppConnectRetryDelay) + } + return fmt.Errorf("%d retry attempts failed: %w", retries, err) +} + +func createDir(dir string) { + if err := os.Mkdir(dir, 0655); err == nil { + logrus.Debugf("created dir %s", dir) + } else if !os.IsExist(err) { + logrus.Warnf("creating dir %s failed: %v", dir, err) + } +} + +func removeFile(path string) { + if err := os.Remove(path); err == nil { + logrus.Debugf("removed file %s", path) + } else if !os.IsNotExist(err) { + logrus.Warnf("removing file %s failed: %v", path, err) + } +} diff --git a/version/version.go b/version/version.go deleted file mode 100644 index eb8063a9..00000000 --- a/version/version.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 version - -import ( - "fmt" - "runtime" - "strconv" - "time" -) - -var ( - name = "govpp" - version = "v0.3.5" - commitHash = "unknown" - buildBranch = "HEAD" - buildStamp = "" - buildUser = "" - buildHost = "" - - buildDate time.Time -) - -func init() { - buildstampInt64, _ := strconv.ParseInt(buildStamp, 10, 64) - if buildstampInt64 == 0 { - buildstampInt64 = time.Now().Unix() - } - buildDate = time.Unix(buildstampInt64, 0) -} - -func Info() string { - return fmt.Sprintf(`%s %s`, name, version) -} - -func Verbose() string { - return fmt.Sprintf(`%s - Version: %s - Branch: %s - Revision: %s - Built by: %s@%s - Build date: %s - Go runtime: %s (%s/%s)`, - name, - version, buildBranch, commitHash, - buildUser, buildHost, buildDate.Format(time.UnixDate), - runtime.Version(), runtime.GOOS, runtime.GOARCH, - ) -}