diff options
author | 2020-06-18 08:22:13 +0200 | |
---|---|---|
committer | 2020-06-22 14:37:14 +0200 | |
commit | 94620e85f0bdbb054af07ce3670fadc1f76cfdf0 (patch) | |
tree | 7784ddf381c4e08a6a1ece5b55911b47ea8395f3 | |
parent | 280b1c6c83b676ef4e592f4ecf60cb5b54b6a753 (diff) |
Refactored binapi generator with message encoding
Change-Id: I5a6abb68b9d058866f94818169300e5c2fc43895
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
61 files changed, 27510 insertions, 5232 deletions
@@ -97,11 +97,12 @@ 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 \ -u "$(shell id -u):$(shell id -g)" \ "${VPP_IMG}" \ - sh -exc "cd $(BINAPI_DIR) && $(cmds)" + sh -ec "cd $(BINAPI_DIR) && $(cmds)" extras: @make -C extras diff --git a/api/binapi.go b/api/binapi.go index 96eb3bf..20ddd28 100644 --- a/api/binapi.go +++ b/api/binapi.go @@ -163,3 +163,4 @@ func GetRegisteredMessageTypes() map[reflect.Type]string { // 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 +const GoVppAPIPackageIsVersion2 = true diff --git a/binapigen/binapigen.go b/binapigen/binapigen.go new file mode 100644 index 0000000..0178476 --- /dev/null +++ b/binapigen/binapigen.go @@ -0,0 +1,369 @@ +// 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" + "strings" + + "git.fd.io/govpp.git/binapigen/vppapi" +) + +type File struct { + vppapi.File + + Generate bool + + PackageName string + Imports []string + + Enums []*Enum + Unions []*Union + Structs []*Struct + Aliases []*Alias + Messages []*Message + + imports map[string]string + refmap map[string]string +} + +func newFile(gen *Generator, apifile *vppapi.File) (*File, error) { + file := &File{ + File: *apifile, + PackageName: sanitizedName(apifile.Name), + imports: make(map[string]string), + refmap: make(map[string]string), + } + + sortFileObjects(&file.File) + + for _, imp := range apifile.Imports { + file.Imports = append(file.Imports, normalizeImport(imp)) + } + for _, enum := range apifile.EnumTypes { + file.Enums = append(file.Enums, newEnum(gen, file, enum)) + } + for _, alias := range apifile.AliasTypes { + file.Aliases = append(file.Aliases, newAlias(gen, file, alias)) + } + for _, structType := range apifile.StructTypes { + file.Structs = append(file.Structs, newStruct(gen, file, structType)) + } + for _, union := range apifile.UnionTypes { + file.Unions = append(file.Unions, newUnion(gen, file, union)) + } + for _, msg := range apifile.Messages { + file.Messages = append(file.Messages, newMessage(gen, file, msg)) + } + + return file, nil +} + +func (file *File) isTypes() bool { + return strings.HasSuffix(file.File.Name, "_types") +} + +func (file *File) hasService() bool { + return file.Service != nil && len(file.Service.RPCs) > 0 +} + +func (file *File) addRef(typ string, name string, ref interface{}) { + apiName := toApiType(name) + if _, ok := file.refmap[apiName]; ok { + logf("%s type %v already in refmap", typ, apiName) + return + } + file.refmap[apiName] = name +} + +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.Name, imp) + continue + } + //if gen.ImportTypes || impFile.Generate { + files = append(files, impFile) + //} + } + return files +} + +func (file *File) loadTypeImports(gen *Generator, typeFiles []*File) { + if len(typeFiles) == 0 { + return + } + for _, t := range file.Structs { + for _, imp := range typeFiles { + if _, ok := file.imports[t.Name]; ok { + break + } + for _, at := range imp.File.StructTypes { + if at.Name != t.Name { + continue + } + if len(at.Fields) != len(t.Fields) { + continue + } + file.imports[t.Name] = imp.PackageName + } + } + } + for _, t := range file.AliasTypes { + for _, imp := range typeFiles { + if _, ok := file.imports[t.Name]; ok { + break + } + for _, at := range imp.File.AliasTypes { + if at.Name != t.Name { + continue + } + if at.Length != t.Length { + continue + } + if at.Type != t.Type { + continue + } + file.imports[t.Name] = imp.PackageName + } + } + } + for _, t := range file.EnumTypes { + for _, imp := range typeFiles { + if _, ok := file.imports[t.Name]; ok { + break + } + for _, at := range imp.File.EnumTypes { + if at.Name != t.Name { + continue + } + if at.Type != t.Type { + continue + } + file.imports[t.Name] = imp.PackageName + } + } + } + for _, t := range file.UnionTypes { + for _, imp := range typeFiles { + if _, ok := file.imports[t.Name]; ok { + break + } + for _, at := range imp.File.UnionTypes { + if at.Name != t.Name { + continue + } + file.imports[t.Name] = imp.PackageName + /*if gen.ImportTypes { + imp.Generate = true + }*/ + } + } + } +} + +type Enum struct { + vppapi.EnumType + + GoName string +} + +func newEnum(gen *Generator, file *File, apitype vppapi.EnumType) *Enum { + typ := &Enum{ + EnumType: apitype, + GoName: camelCaseName(apitype.Name), + } + gen.enumsByName[fmt.Sprintf("%s.%s", file.Name, typ.Name)] = typ + file.addRef("enum", typ.Name, typ) + return typ +} + +type Alias struct { + vppapi.AliasType + + GoName string +} + +func newAlias(gen *Generator, file *File, apitype vppapi.AliasType) *Alias { + typ := &Alias{ + AliasType: apitype, + GoName: camelCaseName(apitype.Name), + } + gen.aliasesByName[fmt.Sprintf("%s.%s", file.Name, typ.Name)] = typ + file.addRef("alias", typ.Name, typ) + return typ +} + +type Struct struct { + vppapi.StructType + + GoName string + + Fields []*Field +} + +func newStruct(gen *Generator, file *File, apitype vppapi.StructType) *Struct { + typ := &Struct{ + StructType: apitype, + GoName: camelCaseName(apitype.Name), + } + for _, fieldType := range apitype.Fields { + field := newField(gen, file, fieldType) + field.ParentStruct = typ + typ.Fields = append(typ.Fields, field) + } + gen.structsByName[fmt.Sprintf("%s.%s", file.Name, typ.Name)] = typ + file.addRef("struct", typ.Name, typ) + return typ +} + +type Union struct { + vppapi.UnionType + + GoName string + + Fields []*Field +} + +func newUnion(gen *Generator, file *File, apitype vppapi.UnionType) *Union { + typ := &Union{ + UnionType: apitype, + GoName: camelCaseName(apitype.Name), + } + gen.unionsByName[fmt.Sprintf("%s.%s", file.Name, typ.Name)] = typ + for _, fieldType := range apitype.Fields { + field := newField(gen, file, fieldType) + field.ParentUnion = typ + typ.Fields = append(typ.Fields, field) + } + file.addRef("union", typ.Name, typ) + return typ +} + +type Message struct { + vppapi.Message + + GoName string + + Fields []*Field +} + +func newMessage(gen *Generator, file *File, apitype vppapi.Message) *Message { + msg := &Message{ + Message: apitype, + GoName: camelCaseName(apitype.Name), + } + for _, fieldType := range apitype.Fields { + field := newField(gen, file, fieldType) + field.ParentMessage = msg + msg.Fields = append(msg.Fields, field) + } + return msg +} + +type Field struct { + vppapi.Field + + GoName string + + // Field parent + ParentMessage *Message + ParentStruct *Struct + ParentUnion *Union + + // Type reference + Enum *Enum + Alias *Alias + Struct *Struct + Union *Union +} + +func newField(gen *Generator, file *File, apitype vppapi.Field) *Field { + typ := &Field{ + Field: apitype, + GoName: camelCaseName(apitype.Name), + } + return typ +} + +func (f *Field) resolveType(gen *Generator) error { + switch { + + } + return nil +} + +type Service = vppapi.Service +type RPC = vppapi.RPC + +func sortFileObjects(file *vppapi.File) { + // sort imports + sort.SliceStable(file.Imports, func(i, j int) bool { + return file.Imports[i] < file.Imports[j] + }) + // sort enum types + sort.SliceStable(file.EnumTypes, func(i, j int) bool { + return file.EnumTypes[i].Name < file.EnumTypes[j].Name + }) + // sort alias types + sort.Slice(file.AliasTypes, func(i, j int) bool { + return file.AliasTypes[i].Name < file.AliasTypes[j].Name + }) + // sort struct types + sort.SliceStable(file.StructTypes, func(i, j int) bool { + return file.StructTypes[i].Name < file.StructTypes[j].Name + }) + // sort union types + sort.SliceStable(file.UnionTypes, func(i, j int) bool { + return file.UnionTypes[i].Name < file.UnionTypes[j].Name + }) + // sort messages + sort.SliceStable(file.Messages, func(i, j int) bool { + return file.Messages[i].Name < file.Messages[j].Name + }) + // sort services + if file.Service != nil { + sort.Slice(file.Service.RPCs, func(i, j int) bool { + // dumps first + if file.Service.RPCs[i].Stream != file.Service.RPCs[j].Stream { + return file.Service.RPCs[i].Stream + } + return file.Service.RPCs[i].RequestMsg < file.Service.RPCs[j].RequestMsg + }) + } +} + +func sanitizedName(name string) string { + switch name { + case "interface": + return "interfaces" + case "map": + return "maps" + default: + return name + } +} + +func normalizeImport(imp string) string { + imp = path.Base(imp) + if idx := strings.Index(imp, "."); idx >= 0 { + imp = imp[:idx] + } + return imp +} diff --git a/cmd/binapi-generator/definitions.go b/binapigen/definitions.go index 9bf9e53..3c8a874 100644 --- a/cmd/binapi-generator/definitions.go +++ b/binapigen/definitions.go @@ -1,18 +1,18 @@ -// 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 ( "strings" @@ -23,7 +23,10 @@ import ( 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,8 +71,6 @@ 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 { diff --git a/binapigen/definitions_test.go b/binapigen/definitions_test.go new file mode 100644 index 0000000..761c95f --- /dev/null +++ b/binapigen/definitions_test.go @@ -0,0 +1,39 @@ +// 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) + } + }) + } +} diff --git a/binapigen/generate.go b/binapigen/generate.go new file mode 100644 index 0000000..1f9b89a --- /dev/null +++ b/binapigen/generate.go @@ -0,0 +1,1241 @@ +// 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 ( + "bytes" + "fmt" + "io" + "os/exec" + "path" + "path/filepath" + "sort" + "strings" + + "git.fd.io/govpp.git/version" +) + +// 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 = 2 + +// message field names +const ( + msgIdField = "_vl_msg_id" + clientIndexField = "client_index" + contextField = "context" + retvalField = "retval" +) + +const ( + outputFileExt = ".ba.go" // file extension of the Go generated files + rpcFileSuffix = "_rpc" // file name suffix for the RPC services + + 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 + + // TODO: register service descriptor + //serviceDescType = "ServiceDesc" // name for service descriptor type + //serviceDescName = "_ServiceRPC_serviceDesc" // name for service descriptor var +) + +// 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 +) + +type GenFile struct { + *Generator + filename string + file *File + packageDir string + buf bytes.Buffer +} + +func generatePackage(ctx *GenFile, w io.Writer) { + logf("----------------------------") + logf("generating binapi package: %q", ctx.file.PackageName) + logf("----------------------------") + + 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.file.Name) + + if ctx.IncludeAPIVersion { + fmt.Fprintf(w, "\t// %s is the API version of this module.\n", constAPIVersion) + fmt.Fprintf(w, "\t%s = \"%s\"\n", constAPIVersion, ctx.file.Version()) + fmt.Fprintf(w, "\t// %s is the CRC of this module.\n", constVersionCrc) + fmt.Fprintf(w, "\t%s = %v\n", constVersionCrc, ctx.file.CRC) + } + fmt.Fprintln(w, ")") + fmt.Fprintln(w) + + // generate enums + if len(ctx.file.Enums) > 0 { + for _, enum := range ctx.file.Enums { + if imp, ok := ctx.file.imports[enum.Name]; ok { + generateImportedAlias(ctx, w, enum.GoName, imp) + continue + } + generateEnum(ctx, w, enum) + } + } + + // generate aliases + if len(ctx.file.Aliases) > 0 { + for _, alias := range ctx.file.Aliases { + if imp, ok := ctx.file.imports[alias.Name]; ok { + generateImportedAlias(ctx, w, alias.GoName, imp) + continue + } + generateAlias(ctx, w, alias) + } + } + + // generate types + if len(ctx.file.Structs) > 0 { + for _, typ := range ctx.file.Structs { + if imp, ok := ctx.file.imports[typ.Name]; ok { + generateImportedAlias(ctx, w, typ.GoName, imp) + continue + } + generateStruct(ctx, w, typ) + } + } + + // generate unions + if len(ctx.file.Unions) > 0 { + for _, union := range ctx.file.Unions { + if imp, ok := ctx.file.imports[union.Name]; ok { + generateImportedAlias(ctx, w, union.GoName, imp) + continue + } + generateUnion(ctx, w, union) + } + } + + // generate messages + if len(ctx.file.Messages) > 0 { + for _, msg := range ctx.file.Messages { + generateMessage(ctx, w, msg) + } + + initFnName := fmt.Sprintf("file_%s_binapi_init", ctx.file.PackageName) + + // generate message registrations + fmt.Fprintf(w, "func init() { %s() }\n", initFnName) + fmt.Fprintf(w, "func %s() {\n", initFnName) + for _, msg := range ctx.file.Messages { + fmt.Fprintf(w, "\tapi.RegisterMessage((*%s)(nil), \"%s\")\n", + msg.GoName, ctx.file.Name+"."+msg.GoName) + } + 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.file.Messages { + fmt.Fprintf(w, "\t(*%s)(nil),\n", msg.GoName) + } + fmt.Fprintln(w, "}") + fmt.Fprintln(w, "}") + } + + generateFooter(ctx, w) + +} + +func generateHeader(ctx *GenFile, w io.Writer) { + fmt.Fprintln(w, "// Code generated by GoVPP's binapi-generator. DO NOT EDIT.") + fmt.Fprintln(w, "// versions:") + fmt.Fprintf(w, "// binapi-generator: %s\n", version.Version()) + if ctx.IncludeVppVersion { + fmt.Fprintf(w, "// VPP: %s\n", ctx.VPPVersion) + } + fmt.Fprintf(w, "// source: %s\n", ctx.file.Path) + fmt.Fprintln(w) + + fmt.Fprintln(w, "/*") + fmt.Fprintf(w, "Package %s contains generated code for VPP binary API defined by %s.api (version %s).\n", + ctx.file.PackageName, ctx.file.Name, ctx.file.Version()) + 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("RPC", len(ctx.file.Service.RPCs)) + printObjNum("alias", len(ctx.file.Aliases)) + printObjNum("enum", len(ctx.file.Enums)) + printObjNum("message", len(ctx.file.Messages)) + printObjNum("type", len(ctx.file.Structs)) + printObjNum("union", len(ctx.file.Unions)) + fmt.Fprintln(w, "*/") + fmt.Fprintf(w, "package %s\n", ctx.file.PackageName) + fmt.Fprintln(w) +} + +func generateImports(ctx *GenFile, w io.Writer) { + fmt.Fprintln(w, "import (") + fmt.Fprintln(w, ` "bytes"`) + fmt.Fprintln(w, ` "context"`) + fmt.Fprintln(w, ` "encoding/binary"`) + fmt.Fprintln(w, ` "io"`) + fmt.Fprintln(w, ` "math"`) + fmt.Fprintln(w, ` "strconv"`) + fmt.Fprintln(w) + fmt.Fprintf(w, "\tapi \"%s\"\n", "git.fd.io/govpp.git/api") + fmt.Fprintf(w, "\tcodec \"%s\"\n", "git.fd.io/govpp.git/codec") + fmt.Fprintf(w, "\tstruc \"%s\"\n", "github.com/lunixbochs/struc") + if len(ctx.file.Imports) > 0 { + fmt.Fprintln(w) + for _, imp := range ctx.file.Imports { + importPath := path.Join(ctx.ImportPrefix, imp) + if ctx.ImportPrefix == "" { + importPath = getImportPath(ctx.packageDir, imp) + } + fmt.Fprintf(w, "\t%s \"%s\"\n", imp, strings.TrimSpace(importPath)) + } + } + fmt.Fprintln(w, ")") + fmt.Fprintln(w) + + 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) +} + +func getImportPath(outputDir string, pkg string) string { + absPath, err := filepath.Abs(filepath.Join(outputDir, "..", pkg)) + if err != nil { + panic(err) + } + 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 generateFooter(ctx *GenFile, w io.Writer) { + 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 _ = codec.DecodeString\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") + fmt.Fprintf(w, "var _ = binary.BigEndian\n") + fmt.Fprintf(w, "var _ = math.Float32bits\n") +} + +func generateComment(ctx *GenFile, 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.file.Name) + } else { + fmt.Fprintf(w, "// %s represents VPP binary API %s '%s'.\n", goName, objKind, vppName) + } +} + +func generateEnum(ctx *GenFile, w io.Writer, enum *Enum) { + name := enum.GoName + 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.Fprintln(w, "var (") + fmt.Fprintf(w, "%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.Fprintf(w, "%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.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 \"%s(\" + strconv.Itoa(int(x)) + \")\"\n", name) + fmt.Fprintln(w, "}") + fmt.Fprintln(w) +} + +func generateImportedAlias(ctx *GenFile, w io.Writer, name string, imp string) { + fmt.Fprintf(w, "type %s = %s.%s\n", name, imp, name) + fmt.Fprintln(w) +} + +func generateAlias(ctx *GenFile, w io.Writer, alias *Alias) { + name := alias.GoName + + logf(" writing ALIAS %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.file, alias.Type) + fmt.Fprintf(w, "%s\n", dataType) + + fmt.Fprintln(w) +} + +func generateStruct(ctx *GenFile, w io.Writer, typ *Struct) { + name := typ.GoName + + logf(" writing STRUCT %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 := range typ.Fields { + // skip internal fields + switch strings.ToLower(typ.Name) { + case msgIdField: + continue + } + + generateField(ctx, w, typ.Fields, i) + } + + // generate end of the struct + fmt.Fprintln(w, "}") + + // generate name getter + generateTypeNameGetter(w, name, typ.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 generateUnionGetterSetterNew(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) { + copy(u.%[4]s[:], a[:]) +} +func (u *%[1]s) Get%[2]s() (a %[3]s) { + copy(a[:], u.%[4]s[:]) + return +} +`, structName, getterField, getterStruct, unionDataField) +}*/ + +func generateUnion(ctx *GenFile, w io.Writer, union *Union) { + name := union.GoName + + 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.file, 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 getters for fields + for _, field := range union.Fields { + fieldType := convertToGoType(ctx.file, field.Type) + generateUnionGetterSetter(w, name, field.GoName, fieldType) + } + + // generate union methods + //generateUnionMethods(w, name) + + fmt.Fprintln(w) +} + +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 generateMessage(ctx *GenFile, w io.Writer, msg *Message) { + name := msg.GoName + + 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) + generateMessageSize(ctx, w, name, msg.Fields) + generateMessageMarshal(ctx, w, name, msg.Fields) + generateMessageUnmarshal(ctx, w, name, msg.Fields) + + fmt.Fprintln(w) +} + +func generateMessageSize(ctx *GenFile, w io.Writer, name string, fields []*Field) { + fmt.Fprintf(w, "func (m *%[1]s) Size() int {\n", name) + + fmt.Fprintf(w, "\tif m == nil { return 0 }\n") + fmt.Fprintf(w, "\tvar size int\n") + + encodeBaseType := func(typ, name string, length int, sizefrom string) bool { + t, ok := BaseTypeNames[typ] + if !ok { + return false + } + + var s = BaseTypeSizes[t] + switch t { + case STRING: + if length > 0 { + s = length + fmt.Fprintf(w, "\tsize += %d\n", s) + } else { + s = 4 + fmt.Fprintf(w, "\tsize += %d + len(%s)\n", s, name) + } + default: + if sizefrom != "" { + //fmt.Fprintf(w, "\tsize += %d * int(%s)\n", s, sizefrom) + fmt.Fprintf(w, "\tsize += %d * len(%s)\n", s, name) + } else { + if length > 0 { + s = BaseTypeSizes[t] * length + } + fmt.Fprintf(w, "\tsize += %d\n", s) + } + } + + return true + } + + lvl := 0 + var encodeFields func(fields []*Field, parentName string) + encodeFields = func(fields []*Field, parentName string) { + lvl++ + defer func() { lvl-- }() + + n := 0 + for _, field := range fields { + // skip internal fields + switch strings.ToLower(field.Name) { + case /*crcField,*/ msgIdField: + continue + case clientIndexField, contextField: + if n == 0 { + continue + } + } + n++ + + fieldName := field.GoName //camelCaseName(strings.TrimPrefix(field.Name, "_")) + name := fmt.Sprintf("%s.%s", parentName, fieldName) + sizeFrom := camelCaseName(strings.TrimPrefix(field.SizeFrom, "_")) + var sizeFromName string + if sizeFrom != "" { + sizeFromName = fmt.Sprintf("%s.%s", parentName, sizeFrom) + } + + fmt.Fprintf(w, "\t// field[%d] %s\n", lvl, name) + + if encodeBaseType(field.Type, name, field.Length, sizeFromName) { + continue + } + + char := fmt.Sprintf("s%d", lvl) + index := fmt.Sprintf("j%d", lvl) + + if field.Array { + if field.Length > 0 { + fmt.Fprintf(w, "\tfor %[2]s := 0; %[2]s < %[1]d; %[2]s ++ {\n", field.Length, index) + } else if field.SizeFrom != "" { + //fmt.Fprintf(w, "\tfor %[1]s := 0; %[1]s < int(%[2]s.%[3]s); %[1]s++ {\n", index, parentName, sizeFrom) + fmt.Fprintf(w, "\tfor %[1]s := 0; %[1]s < len(%[2]s); %[1]s++ {\n", index, name) + } + + fmt.Fprintf(w, "\tvar %[1]s %[2]s\n_ = %[1]s\n", char, convertToGoType(ctx.file, field.Type)) + fmt.Fprintf(w, "\tif %[1]s < len(%[2]s) { %[3]s = %[2]s[%[1]s] }\n", index, name, char) + name = char + } + + if enum := getEnumByRef(ctx.file, field.Type); enum != nil { + if encodeBaseType(enum.Type, name, 0, "") { + } else { + fmt.Fprintf(w, "\t// ??? ENUM %s %s\n", name, enum.Type) + } + } else if alias := getAliasByRef(ctx.file, field.Type); alias != nil { + if encodeBaseType(alias.Type, name, alias.Length, "") { + } else if typ := getTypeByRef(ctx.file, alias.Type); typ != nil { + encodeFields(typ.Fields, name) + } else { + fmt.Fprintf(w, "\t// ??? ALIAS %s %s\n", name, alias.Type) + } + } else if typ := getTypeByRef(ctx.file, field.Type); typ != nil { + encodeFields(typ.Fields, name) + } else if union := getUnionByRef(ctx.file, field.Type); union != nil { + maxSize := getUnionSize(ctx.file, union) + fmt.Fprintf(w, "\tsize += %d\n", maxSize) + } else { + fmt.Fprintf(w, "\t// ??? buf[pos] = (%s)\n", name) + } + + if field.Array { + fmt.Fprintf(w, "\t}\n") + } + } + } + + encodeFields(fields, "m") + + fmt.Fprintf(w, "return size\n") + + fmt.Fprintf(w, "}\n") +} + +func generateMessageMarshal(ctx *GenFile, w io.Writer, name string, fields []*Field) { + fmt.Fprintf(w, "func (m *%[1]s) Marshal(b []byte) ([]byte, error) {\n", name) + + fmt.Fprintf(w, "\to := binary.BigEndian\n") + fmt.Fprintf(w, "\t_ = o\n") + fmt.Fprintf(w, "\tpos := 0\n") + fmt.Fprintf(w, "\t_ = pos\n") + + var buf = new(strings.Builder) + + encodeBaseType := func(typ, name string, length int, sizefrom string) bool { + t, ok := BaseTypeNames[typ] + if !ok { + return false + } + + isArray := length > 0 || sizefrom != "" + + switch t { + case I8, U8, I16, U16, I32, U32, I64, U64, F64: + if isArray { + if length != 0 { + fmt.Fprintf(buf, "\tfor i := 0; i < %d; i++ {\n", length) + } else if sizefrom != "" { + //fmt.Fprintf(buf, "\tfor i := 0; i < int(%s); i++ {\n", sizefrom) + fmt.Fprintf(buf, "\tfor i := 0; i < len(%s); i++ {\n", name) + } + } + } + + switch t { + case I8, U8: + if isArray { + fmt.Fprintf(buf, "\tvar x uint8\n") + fmt.Fprintf(buf, "\tif i < len(%s) { x = uint8(%s[i]) }\n", name, name) + name = "x" + } + fmt.Fprintf(buf, "\tbuf[pos] = uint8(%s)\n", name) + fmt.Fprintf(buf, "\tpos += 1\n") + if isArray { + fmt.Fprintf(buf, "\t}\n") + } + case I16, U16: + if isArray { + fmt.Fprintf(buf, "\tvar x uint16\n") + fmt.Fprintf(buf, "\tif i < len(%s) { x = uint16(%s[i]) }\n", name, name) + name = "x" + } + fmt.Fprintf(buf, "\to.PutUint16(buf[pos:pos+2], uint16(%s))\n", name) + fmt.Fprintf(buf, "\tpos += 2\n") + if isArray { + fmt.Fprintf(buf, "\t}\n") + } + case I32, U32: + if isArray { + fmt.Fprintf(buf, "\tvar x uint32\n") + fmt.Fprintf(buf, "\tif i < len(%s) { x = uint32(%s[i]) }\n", name, name) + name = "x" + } + fmt.Fprintf(buf, "\to.PutUint32(buf[pos:pos+4], uint32(%s))\n", name) + fmt.Fprintf(buf, "\tpos += 4\n") + if isArray { + fmt.Fprintf(buf, "\t}\n") + } + case I64, U64: + if isArray { + fmt.Fprintf(buf, "\tvar x uint64\n") + fmt.Fprintf(buf, "\tif i < len(%s) { x = uint64(%s[i]) }\n", name, name) + name = "x" + } + fmt.Fprintf(buf, "\to.PutUint64(buf[pos:pos+8], uint64(%s))\n", name) + fmt.Fprintf(buf, "\tpos += 8\n") + if isArray { + fmt.Fprintf(buf, "\t}\n") + } + case F64: + if isArray { + fmt.Fprintf(buf, "\tvar x float64\n") + fmt.Fprintf(buf, "\tif i < len(%s) { x = float64(%s[i]) }\n", name, name) + name = "x" + } + fmt.Fprintf(buf, "\to.PutUint64(buf[pos:pos+8], math.Float64bits(float64(%s)))\n", name) + fmt.Fprintf(buf, "\tpos += 8\n") + if isArray { + fmt.Fprintf(buf, "\t}\n") + } + case BOOL: + fmt.Fprintf(buf, "\tif %s { buf[pos] = 1 }\n", name) + fmt.Fprintf(buf, "\tpos += 1\n") + case STRING: + if length != 0 { + fmt.Fprintf(buf, "\tcopy(buf[pos:pos+%d], %s)\n", length, name) + fmt.Fprintf(buf, "\tpos += %d\n", length) + } else { + fmt.Fprintf(buf, "\to.PutUint32(buf[pos:pos+4], uint32(len(%s)))\n", name) + fmt.Fprintf(buf, "\tpos += 4\n") + fmt.Fprintf(buf, "\tcopy(buf[pos:pos+len(%s)], %s[:])\n", name, name) + fmt.Fprintf(buf, "\tpos += len(%s)\n", name) + } + default: + fmt.Fprintf(buf, "\t// ??? %s %s\n", name, typ) + return false + } + return true + } + + lvl := 0 + var encodeFields func(fields []*Field, parentName string) + encodeFields = func(fields []*Field, parentName string) { + lvl++ + defer func() { lvl-- }() + + n := 0 + for _, field := range fields { + // skip internal fields + switch strings.ToLower(field.Name) { + case /*crcField,*/ msgIdField: + continue + case clientIndexField, contextField: + if n == 0 { + continue + } + } + n++ + + getFieldName := func(name string) string { + fieldName := camelCaseName(strings.TrimPrefix(name, "_")) + return fmt.Sprintf("%s.%s", parentName, fieldName) + } + + fieldName := camelCaseName(strings.TrimPrefix(field.Name, "_")) + name := fmt.Sprintf("%s.%s", parentName, fieldName) + sizeFrom := camelCaseName(strings.TrimPrefix(field.SizeFrom, "_")) + var sizeFromName string + if sizeFrom != "" { + sizeFromName = fmt.Sprintf("%s.%s", parentName, sizeFrom) + } + + fmt.Fprintf(buf, "\t// field[%d] %s\n", lvl, name) + + getSizeOfField := func() *Field { + for _, f := range fields { + if f.SizeFrom == field.Name { + return f + } + } + return nil + } + if f := getSizeOfField(); f != nil { + if encodeBaseType(field.Type, fmt.Sprintf("len(%s)", getFieldName(f.Name)), field.Length, "") { + continue + } + panic(fmt.Sprintf("failed to encode base type of sizefrom field: %s", field.Name)) + } + + if encodeBaseType(field.Type, name, field.Length, sizeFromName) { + continue + } + + char := fmt.Sprintf("v%d", lvl) + index := fmt.Sprintf("j%d", lvl) + + if field.Array { + if field.Length > 0 { + fmt.Fprintf(buf, "\tfor %[2]s := 0; %[2]s < %[1]d; %[2]s ++ {\n", field.Length, index) + } else if field.SizeFrom != "" { + //fmt.Fprintf(buf, "\tfor %[1]s := 0; %[1]s < int(%[2]s.%[3]s); %[1]s++ {\n", index, parentName, sizeFrom) + fmt.Fprintf(buf, "\tfor %[1]s := 0; %[1]s < len(%[2]s); %[1]s++ {\n", index, name) + } + + fmt.Fprintf(buf, "\tvar %s %s\n", char, convertToGoType(ctx.file, field.Type)) + fmt.Fprintf(buf, "\tif %[1]s < len(%[2]s) { %[3]s = %[2]s[%[1]s] }\n", index, name, char) + name = char + } + + if enum := getEnumByRef(ctx.file, field.Type); enum != nil { + if encodeBaseType(enum.Type, name, 0, "") { + } else { + fmt.Fprintf(buf, "\t// ??? ENUM %s %s\n", name, enum.Type) + } + } else if alias := getAliasByRef(ctx.file, field.Type); alias != nil { + if encodeBaseType(alias.Type, name, alias.Length, "") { + } else if typ := getTypeByRef(ctx.file, alias.Type); typ != nil { + encodeFields(typ.Fields, name) + } else { + fmt.Fprintf(buf, "\t// ??? ALIAS %s %s\n", name, alias.Type) + } + } else if typ := getTypeByRef(ctx.file, field.Type); typ != nil { + encodeFields(typ.Fields, name) + } else if union := getUnionByRef(ctx.file, field.Type); union != nil { + maxSize := getUnionSize(ctx.file, union) + fmt.Fprintf(buf, "\tcopy(buf[pos:pos+%d], %s.%s[:])\n", maxSize, name, unionDataField) + fmt.Fprintf(buf, "\tpos += %d\n", maxSize) + } else { + fmt.Fprintf(buf, "\t// ??? buf[pos] = (%s)\n", name) + } + + if field.Array { + fmt.Fprintf(buf, "\t}\n") + } + } + } + + encodeFields(fields, "m") + + fmt.Fprintf(w, "\tvar buf []byte\n") + fmt.Fprintf(w, "\tif b == nil {\n") + fmt.Fprintf(w, "\tbuf = make([]byte, m.Size())\n") + fmt.Fprintf(w, "\t} else {\n") + fmt.Fprintf(w, "\tbuf = b\n") + fmt.Fprintf(w, "\t}\n") + fmt.Fprint(w, buf.String()) + + fmt.Fprintf(w, "return buf, nil\n") + + fmt.Fprintf(w, "}\n") +} + +func generateMessageUnmarshal(ctx *GenFile, w io.Writer, name string, fields []*Field) { + fmt.Fprintf(w, "func (m *%[1]s) Unmarshal(tmp []byte) error {\n", name) + + fmt.Fprintf(w, "\to := binary.BigEndian\n") + fmt.Fprintf(w, "\t_ = o\n") + fmt.Fprintf(w, "\tpos := 0\n") + fmt.Fprintf(w, "\t_ = pos\n") + + decodeBaseType := func(typ, orig, name string, length int, sizefrom string, alloc bool) bool { + t, ok := BaseTypeNames[typ] + if !ok { + return false + } + + isArray := length > 0 || sizefrom != "" + + switch t { + case I8, U8, I16, U16, I32, U32, I64, U64, F64: + if isArray { + if alloc { + if length != 0 { + fmt.Fprintf(w, "\t%s = make([]%s, %d)\n", name, orig, length) + } else if sizefrom != "" { + fmt.Fprintf(w, "\t%s = make([]%s, %s)\n", name, orig, sizefrom) + } + } + fmt.Fprintf(w, "\tfor i := 0; i < len(%s); i++ {\n", name) + } + } + + switch t { + case I8, U8: + if isArray { + fmt.Fprintf(w, "\t%s[i] = %s(tmp[pos])\n", name, convertToGoType(ctx.file, typ)) + } else { + fmt.Fprintf(w, "\t%s = %s(tmp[pos])\n", name, orig) + } + fmt.Fprintf(w, "\tpos += 1\n") + if isArray { + fmt.Fprintf(w, "\t}\n") + } + case I16, U16: + if isArray { + fmt.Fprintf(w, "\t%s[i] = %s(o.Uint16(tmp[pos:pos+2]))\n", name, orig) + } else { + fmt.Fprintf(w, "\t%s = %s(o.Uint16(tmp[pos:pos+2]))\n", name, orig) + } + fmt.Fprintf(w, "\tpos += 2\n") + if isArray { + fmt.Fprintf(w, "\t}\n") + } + case I32, U32: + if isArray { + fmt.Fprintf(w, "\t%s[i] = %s(o.Uint32(tmp[pos:pos+4]))\n", name, orig) + } else { + fmt.Fprintf(w, "\t%s = %s(o.Uint32(tmp[pos:pos+4]))\n", name, orig) + } + fmt.Fprintf(w, "\tpos += 4\n") + if isArray { + fmt.Fprintf(w, "\t}\n") + } + case I64, U64: + if isArray { + fmt.Fprintf(w, "\t%s[i] = %s(o.Uint64(tmp[pos:pos+8]))\n", name, orig) + } else { + fmt.Fprintf(w, "\t%s = %s(o.Uint64(tmp[pos:pos+8]))\n", name, orig) + } + fmt.Fprintf(w, "\tpos += 8\n") + if isArray { + fmt.Fprintf(w, "\t}\n") + } + case F64: + if isArray { + fmt.Fprintf(w, "\t%s[i] = %s(math.Float64frombits(o.Uint64(tmp[pos:pos+8])))\n", name, orig) + } else { + fmt.Fprintf(w, "\t%s = %s(math.Float64frombits(o.Uint64(tmp[pos:pos+8])))\n", name, orig) + } + fmt.Fprintf(w, "\tpos += 8\n") + if isArray { + fmt.Fprintf(w, "\t}\n") + } + case BOOL: + fmt.Fprintf(w, "\t%s = tmp[pos] != 0\n", name) + fmt.Fprintf(w, "\tpos += 1\n") + case STRING: + if length != 0 { + fmt.Fprintf(w, "\t{\n") + fmt.Fprintf(w, "\tnul := bytes.Index(tmp[pos:pos+%d], []byte{0x00})\n", length) + fmt.Fprintf(w, "\t%[1]s = codec.DecodeString(tmp[pos:pos+nul])\n", name) + fmt.Fprintf(w, "\tpos += %d\n", length) + fmt.Fprintf(w, "\t}\n") + } else { + fmt.Fprintf(w, "\t{\n") + fmt.Fprintf(w, "\tsiz := o.Uint32(tmp[pos:pos+4])\n") + fmt.Fprintf(w, "\tpos += 4\n") + fmt.Fprintf(w, "\t%[1]s = codec.DecodeString(tmp[pos:pos+int(siz)])\n", name) + fmt.Fprintf(w, "\tpos += len(%s)\n", name) + fmt.Fprintf(w, "\t}\n") + } + default: + fmt.Fprintf(w, "\t// ??? %s %s\n", name, typ) + return false + } + return true + } + + lvl := 0 + var decodeFields func(fields []*Field, parentName string) + decodeFields = func(fields []*Field, parentName string) { + lvl++ + defer func() { lvl-- }() + + n := 0 + for _, field := range fields { + // skip internal fields + switch strings.ToLower(field.Name) { + case /*crcField,*/ msgIdField: + continue + case clientIndexField, contextField: + if n == 0 { + continue + } + } + n++ + + fieldName := camelCaseName(strings.TrimPrefix(field.Name, "_")) + name := fmt.Sprintf("%s.%s", parentName, fieldName) + sizeFrom := camelCaseName(strings.TrimPrefix(field.SizeFrom, "_")) + var sizeFromName string + if sizeFrom != "" { + sizeFromName = fmt.Sprintf("%s.%s", parentName, sizeFrom) + } + + fmt.Fprintf(w, "\t// field[%d] %s\n", lvl, name) + + if decodeBaseType(field.Type, convertToGoType(ctx.file, field.Type), name, field.Length, sizeFromName, true) { + continue + } + + //char := fmt.Sprintf("v%d", lvl) + index := fmt.Sprintf("j%d", lvl) + + if field.Array { + if field.Length > 0 { + fmt.Fprintf(w, "\tfor %[2]s := 0; %[2]s < %[1]d; %[2]s ++ {\n", field.Length, index) + } else if field.SizeFrom != "" { + fieldType := getFieldType(ctx, field) + if strings.HasPrefix(fieldType, "[]") { + fmt.Fprintf(w, "\t%s = make(%s, int(%s.%s))\n", name, fieldType, parentName, sizeFrom) + } + fmt.Fprintf(w, "\tfor %[1]s := 0; %[1]s < int(%[2]s.%[3]s); %[1]s++ {\n", index, parentName, sizeFrom) + } + + /*fmt.Fprintf(w, "\tvar %s %s\n", char, convertToGoType(ctx, field.Type)) + fmt.Fprintf(w, "\tif %[1]s < len(%[2]s) { %[3]s = %[2]s[%[1]s] }\n", index, name, char) + name = char*/ + name = fmt.Sprintf("%s[%s]", name, index) + } + + if enum := getEnumByRef(ctx.file, field.Type); enum != nil { + if decodeBaseType(enum.Type, convertToGoType(ctx.file, field.Type), name, 0, "", false) { + } else { + fmt.Fprintf(w, "\t// ??? ENUM %s %s\n", name, enum.Type) + } + } else if alias := getAliasByRef(ctx.file, field.Type); alias != nil { + if decodeBaseType(alias.Type, convertToGoType(ctx.file, field.Type), name, alias.Length, "", false) { + } else if typ := getTypeByRef(ctx.file, alias.Type); typ != nil { + decodeFields(typ.Fields, name) + } else { + fmt.Fprintf(w, "\t// ??? ALIAS %s %s\n", name, alias.Type) + } + } else if typ := getTypeByRef(ctx.file, field.Type); typ != nil { + decodeFields(typ.Fields, name) + } else if union := getUnionByRef(ctx.file, field.Type); union != nil { + maxSize := getUnionSize(ctx.file, union) + fmt.Fprintf(w, "\tcopy(%s.%s[:], tmp[pos:pos+%d])\n", name, unionDataField, maxSize) + fmt.Fprintf(w, "\tpos += %d\n", maxSize) + } else { + fmt.Fprintf(w, "\t// ??? buf[pos] = (%s)\n", name) + } + + if field.Array { + fmt.Fprintf(w, "\t}\n") + } + } + } + + decodeFields(fields, "m") + + fmt.Fprintf(w, "return nil\n") + + fmt.Fprintf(w, "}\n") +} + +func getFieldType(ctx *GenFile, field *Field) string { + //fieldName := strings.TrimPrefix(field.Name, "_") + //fieldName = camelCaseName(fieldName) + //fieldName := field.GoName + + dataType := convertToGoType(ctx.file, field.Type) + fieldType := dataType + + // check if it is array + if field.Length > 0 || field.SizeFrom != "" { + if dataType == "uint8" { + dataType = "byte" + } + if dataType == "string" && field.Array { + fieldType = "string" + dataType = "byte" + } else if _, ok := BaseTypeNames[field.Type]; !ok && field.SizeFrom == "" { + fieldType = fmt.Sprintf("[%d]%s", field.Length, dataType) + } else { + fieldType = "[]" + dataType + } + } + + return fieldType +} + +func generateField(ctx *GenFile, w io.Writer, fields []*Field, i int) { + field := fields[i] + + //fieldName := strings.TrimPrefix(field.Name, "_") + //fieldName = camelCaseName(fieldName) + fieldName := field.GoName + + dataType := convertToGoType(ctx.file, 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.Array { + fieldType = "string" + dataType = "byte" + } else if _, ok := BaseTypeNames[field.Type]; !ok && field.SizeFrom == "" { + fieldType = fmt.Sprintf("[%d]%s", field.Length, dataType) + } else { + fieldType = "[]" + dataType + } + } + fmt.Fprintf(w, "\t%s %s", fieldName, fieldType) + + fieldTags := map[string]string{} + + if field.Length > 0 && field.Array { + // 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", f.GoName) + } + } + } + + if ctx.IncludeBinapiNames { + typ := fromApiType(field.Type) + if field.Array { + if field.Length > 0 { + fieldTags["binapi"] = fmt.Sprintf("%s[%d],name=%s", typ, field.Length, field.Name) + } else if field.SizeFrom != "" { + fieldTags["binapi"] = fmt.Sprintf("%s[%s],name=%s", typ, field.SizeFrom, field.Name) + } + } else { + fieldTags["binapi"] = fmt.Sprintf("%s,name=%s", typ, field.Name) + } + } + if limit, ok := field.Meta["limit"]; ok && limit.(int) > 0 { + fieldTags["binapi"] = fmt.Sprintf("%s,limit=%d", fieldTags["binapi"], limit) + } + if def, ok := field.Meta["default"]; ok && def != nil { + actual := getActualType(ctx.file, fieldType) + if t, ok := binapiTypes[actual]; ok && t != "float64" { + defnum := int(def.(float64)) + fieldTags["binapi"] = fmt.Sprintf("%s,default=%d", fieldTags["binapi"], defnum) + } else { + fieldTags["binapi"] = fmt.Sprintf("%s,default=%v", fieldTags["binapi"], def) + } + } + + fieldTags["json"] = fmt.Sprintf("%s,omitempty", field.Name) + + 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) +} diff --git a/binapigen/generate_rpc.go b/binapigen/generate_rpc.go new file mode 100644 index 0000000..b480f4a --- /dev/null +++ b/binapigen/generate_rpc.go @@ -0,0 +1,188 @@ +// 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" + "io" + "strings" +) + +func generatePackageRPC(ctx *GenFile, w io.Writer) { + logf("----------------------------") + logf("generating RPC package: %q", ctx.file.PackageName) + logf("----------------------------") + + fmt.Fprintln(w, "// Code generated by GoVPP's binapi-generator. DO NOT EDIT.") + fmt.Fprintln(w) + + fmt.Fprintf(w, "package %s\n", ctx.file.PackageName) + fmt.Fprintln(w) + + fmt.Fprintln(w, "import (") + fmt.Fprintln(w, ` "context"`) + fmt.Fprintln(w, ` "io"`) + fmt.Fprintln(w) + fmt.Fprintf(w, "\tapi \"%s\"\n", "git.fd.io/govpp.git/api") + fmt.Fprintln(w, ")") + fmt.Fprintln(w) + + // generate services + if ctx.file.Service != nil && len(ctx.file.Service.RPCs) > 0 { + generateServiceMethods(ctx, w, ctx.file.Service.RPCs) + } + + // generate message registrations + /*fmt.Fprintln(w, "var _RPCService_desc = api.RPCDesc{") + + fmt.Fprintln(w, "}") + 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 _ = context.Background\n") + fmt.Fprintf(w, "var _ = io.Copy\n") + +} + +func generateServiceMethods(ctx *GenFile, w io.Writer, methods []RPC) { + // generate services comment + generateComment(ctx, w, serviceApiName, "services", "service") + + // generate service api + fmt.Fprintf(w, "type %s interface {\n", serviceApiName) + for _, svc := range methods { + 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 _, met := range methods { + method := camelCaseName(met.RequestMsg) + if m := strings.TrimSuffix(method, "Dump"); method != m { + method = "Dump" + m + } + + fmt.Fprintf(w, "func (c *%s) ", serviceImplName) + generateServiceMethod(ctx, w, &met) + fmt.Fprintln(w, " {") + if met.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(met.ReplyMsg); 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 met.Stream { + replyTyp := camelCaseName(met.ReplyMsg) + method := camelCaseName(met.RequestMsg) + 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) + } + } + + // 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 methods { + 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, "}")*/ + + fmt.Fprintln(w) +} + +func generateServiceMethod(ctx *GenFile, w io.Writer, rpc *RPC) { + reqTyp := camelCaseName(rpc.RequestMsg) + + logf(" writing RPC: %+v", reqTyp) + + // method name is same as parameter type name by default + method := reqTyp + if rpc.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(rpc.ReplyMsg); replyType != "" { + var replyTyp string + if rpc.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/generate_test.go b/binapigen/generate_test.go index 4bec874..5a2a07a 100644 --- a/cmd/binapi-generator/generate_test.go +++ b/binapigen/generate_test.go @@ -1,53 +1,67 @@ -// 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" + + "git.fd.io/govpp.git/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_directory" + +func GenerateFromFile(apiDir, outputDir string, opts Options) error { + // parse API files + apifiles, err := vppapi.ParseDir(apiDir) + if err != nil { + return err } -} -func TestGetInputFilesError(t *testing.T) { - RegisterTestingT(t) - result, err := getInputFiles("nonexisting_directory", 1) - Expect(err).Should(HaveOccurred()) - Expect(result).To(BeNil()) + g, err := New(opts, apifiles) + if err != nil { + return err + } + for _, file := range g.Files { + if !file.Generate { + continue + } + GenerateBinapiFile(g, file, outputDir) + if file.Service != nil { + GenerateRPC(g, file, outputDir) + } + } + + if err = g.Generate(); err != nil { + return err + } + + return nil } func TestGenerateFromFile(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) + + err := GenerateFromFile("testdata/acl.api.json", testOutputDir, Options{}) Expect(err).ShouldNot(HaveOccurred()) - fileInfo, err := os.Stat(outDir + "/acl/acl.ba.go") + 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")) @@ -55,35 +69,36 @@ func TestGenerateFromFile(t *testing.T) { func TestGenerateFromFileInputError(t *testing.T) { RegisterTestingT(t) - outDir := "test_output_directory" - err := generateFromFile("testdata/nonexisting.json", outDir, nil) + + err := GenerateFromFile("testdata/nonexisting.json", testOutputDir, Options{}) Expect(err).Should(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("invalid input file name")) } func TestGenerateFromFileReadJsonError(t *testing.T) { RegisterTestingT(t) - outDir := "test_output_directory" - err := generateFromFile("testdata/input-read-json-error.json", outDir, nil) + + err := GenerateFromFile("testdata/input-read-json-error.json", testOutputDir, Options{}) Expect(err).Should(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("invalid input file name")) } 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) + + err := GenerateFromFile("testdata/input-generate-error.json", testOutputDir, Options{}) Expect(err).Should(HaveOccurred()) } -func TestGetContext(t *testing.T) { +/*func TestGetContext(t *testing.T) { RegisterTestingT(t) outDir := "test_output_directory" result, err := newContext("testdata/af_packet.api.json", outDir) @@ -109,31 +124,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 +137,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) @@ -158,7 +154,7 @@ func TestGeneratePackage(t *testing.T) { 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 +165,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 { + for _, msg := range testCtx.file.Messages { generateMessage(testCtx, writer, &msg) Expect(writer.Buffered()).ToNot(BeZero()) } -} +}*/ /*func TestGenerateMessageName(t *testing.T) { RegisterTestingT(t) diff --git a/binapigen/generator.go b/binapigen/generator.go new file mode 100644 index 0000000..9471462 --- /dev/null +++ b/binapigen/generator.go @@ -0,0 +1,172 @@ +// 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 ( + "bytes" + "fmt" + "go/format" + "io/ioutil" + "os" + "path/filepath" + + "github.com/sirupsen/logrus" + + "git.fd.io/govpp.git/binapigen/vppapi" +) + +type Options struct { + VPPVersion string // version of VPP that produced API files + + FilesToGenerate []string // list of API files to generate + + ImportPrefix string // defines import path prefix for importing types + ImportTypes bool // generate packages for import types + 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 + IncludeVppVersion bool // include info about used VPP version +} + +type Generator struct { + Options + + Files []*File + FilesByPath map[string]*File + FilesByName map[string]*File + + enumsByName map[string]*Enum + aliasesByName map[string]*Alias + structsByName map[string]*Struct + unionsByName map[string]*Union + + genfiles []*GenFile +} + +func New(opts Options, apifiles []*vppapi.File) (*Generator, error) { + g := &Generator{ + Options: opts, + FilesByPath: make(map[string]*File), + FilesByName: make(map[string]*File), + enumsByName: map[string]*Enum{}, + aliasesByName: map[string]*Alias{}, + structsByName: map[string]*Struct{}, + unionsByName: map[string]*Union{}, + } + + logrus.Debugf("adding %d VPP API files to generator", len(apifiles)) + for _, apifile := range apifiles { + filename := apifile.Path + if filename == "" { + filename = apifile.Name + } + if _, ok := g.FilesByPath[filename]; ok { + return nil, fmt.Errorf("duplicate file name: %q", filename) + } + if _, ok := g.FilesByName[apifile.Name]; ok { + return nil, fmt.Errorf("duplicate file: %q", apifile.Name) + } + + file, err := newFile(g, apifile) + if err != nil { + return nil, err + } + g.Files = append(g.Files, file) + g.FilesByPath[filename] = file + g.FilesByName[apifile.Name] = file + + logrus.Debugf("added file %q (path: %v)", apifile.Name, apifile.Path) + if len(file.Imports) > 0 { + logrus.Debugf(" - %d imports: %v", len(file.Imports), file.Imports) + } + } + + logrus.Debugf("Checking %d files to generate: %v", len(opts.FilesToGenerate), opts.FilesToGenerate) + for _, genfile := range opts.FilesToGenerate { + file, ok := g.FilesByPath[genfile] + if !ok { + file, ok = g.FilesByName[genfile] + if !ok { + return nil, fmt.Errorf("no API file found for: %v", genfile) + } + } + file.Generate = true + if opts.ImportTypes { + for _, impFile := range file.importedFiles(g) { + impFile.Generate = true + } + } + } + + logrus.Debugf("Resolving imported types") + for _, file := range g.Files { + if !file.Generate { + continue + } + importedFiles := file.importedFiles(g) + file.loadTypeImports(g, importedFiles) + } + + return g, nil +} + +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 { + if err := writeSourceTo(genfile.filename, genfile.buf.Bytes()); err != nil { + return fmt.Errorf("writing source for RPC package %s failed: %v", genfile.filename, err) + } + } + return nil +} + +func (g *Generator) NewGenFile(filename string) *GenFile { + f := &GenFile{ + Generator: g, + filename: filename, + } + g.genfiles = append(g.genfiles, f) + return f +} + +func writeSourceTo(outputFile string, b []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) + } + + // format generated source code + gosrc, err := format.Source(b) + if err != nil { + _ = ioutil.WriteFile(outputFile, b, 0666) + return fmt.Errorf("formatting source code failed: %v", err) + } + + // write generated code to output file + if err := ioutil.WriteFile(outputFile, gosrc, 0666); err != nil { + return fmt.Errorf("writing to output file %s failed: %v", outputFile, err) + } + + lines := bytes.Count(gosrc, []byte("\n")) + logf("wrote %d lines (%d bytes) of code to: %q", lines, len(gosrc), outputFile) + + return nil +} diff --git a/cmd/binapi-generator/parse_test.go b/binapigen/generator_test.go index e145979..ddbda99 100644 --- a/cmd/binapi-generator/parse_test.go +++ b/binapigen/generator_test.go @@ -1,4 +1,18 @@ -package main +// 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" @@ -14,7 +28,8 @@ func TestBinapiTypeSizes(t *testing.T) { {name: "basic2", input: "i8", expsize: 1}, {name: "basic3", input: "u16", expsize: 2}, {name: "basic4", input: "i32", expsize: 4}, - {name: "invalid1", input: "x", expsize: -1}, + {name: "string", input: "string", expsize: 1}, + {name: "invalid1", input: "x", expsize: 0}, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { @@ -26,15 +41,15 @@ func TestBinapiTypeSizes(t *testing.T) { } } -func TestSizeOfType(t *testing.T) { +/*func TestSizeOfType(t *testing.T) { tests := []struct { name string - input Type + input StructType expsize int }{ { name: "basic1", - input: Type{ + input: StructType{ Fields: []Field{ {Type: "u8"}, }, @@ -81,17 +96,15 @@ func TestSizeOfType(t *testing.T) { } for _, test := range tests { t.Run(test.name, func(t *testing.T) { - ctx := &context{ - packageData: &Package{ - Enums: []Enum{ - {Name: "myenum", Type: "u32"}, - }, + module := &File{ + Enums: []Enum{ + {Name: "myenum", Type: "u32"}, }, } - size := getSizeOfType(ctx, &test.input) + size := getSizeOfType(module, &test.input) if size != test.expsize { t.Errorf("expected %d, got %d", test.expsize, size) } }) } -} +}*/ diff --git a/binapigen/run.go b/binapigen/run.go new file mode 100644 index 0000000..441c43d --- /dev/null +++ b/binapigen/run.go @@ -0,0 +1,89 @@ +// 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/filepath" + + "github.com/sirupsen/logrus" + + "git.fd.io/govpp.git/binapigen/vppapi" +) + +var debugMode = true + +func logf(f string, v ...interface{}) { + if debugMode { + logrus.Debugf(f, v...) + } +} + +func GenerateBinapiFile(gen *Generator, file *File, outputDir string) *GenFile { + packageDir := filepath.Join(outputDir, file.PackageName) + filename := filepath.Join(packageDir, file.PackageName+outputFileExt) + + g := gen.NewGenFile(filename) + g.file = file + g.packageDir = filepath.Join(outputDir, file.PackageName) + + generatePackage(g, &g.buf) + + return g +} + +func GenerateRPC(gen *Generator, file *File, outputDir string) *GenFile { + packageDir := filepath.Join(outputDir, file.PackageName) + filename := filepath.Join(packageDir, file.PackageName+rpcFileSuffix+outputFileExt) + + g := gen.NewGenFile(filename) + g.file = file + g.packageDir = filepath.Join(outputDir, file.PackageName) + + generatePackageRPC(g, &g.buf) + + return g +} + +func Run(apiDir string, opts Options, f func(*Generator) error) { + if err := run(apiDir, opts, f); err != nil { + fmt.Fprintf(os.Stderr, "%s: %v\n", filepath.Base(os.Args[0]), err) + os.Exit(1) + } +} + +func run(apiDir string, opts Options, f func(*Generator) error) error { + // parse API files + apifiles, err := vppapi.ParseDir(apiDir) + if err != nil { + return err + } + + g, err := New(opts, apifiles) + if err != nil { + return err + } + + if err := f(g); err != nil { + return err + } + + if err = g.Generate(); err != nil { + return err + } + + return nil +} diff --git a/binapigen/types.go b/binapigen/types.go new file mode 100644 index 0000000..0dbbeb1 --- /dev/null +++ b/binapigen/types.go @@ -0,0 +1,271 @@ +// 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" + + "github.com/sirupsen/logrus" +) + +// define api +const ( + defineApiPrefix = "vl_api_" + defineApiSuffix = "_t" +) + +// BaseType represents base types in VPP binary API. +type BaseType int + +const ( + U8 BaseType = iota + 1 + I8 + U16 + I16 + U32 + I32 + U64 + I64 + F64 + BOOL + STRING +) + +var ( + BaseTypes = map[BaseType]string{ + U8: "u8", + I8: "i8", + U16: "u16", + I16: "i16", + U32: "u32", + I32: "i32", + U64: "u64", + I64: "i64", + F64: "f64", + BOOL: "bool", + STRING: "string", + } + BaseTypeNames = map[string]BaseType{ + "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[BaseType]int{ + U8: 1, + I8: 1, + U16: 2, + I16: 2, + U32: 4, + I32: 4, + U64: 8, + I64: 8, + F64: 8, + BOOL: 1, + STRING: 1, +} + +type Kind int + +const ( + _ = iota + Uint8Kind + Int8Kind + Uint16Kind + Int16Kind + Uint32Kind + Int32Kind + Uint64Kind + Int64Kind + Float64Kind + BoolKind + StringKind + EnumKind + AliasKind + StructKind + UnionKind + MessageKind +) + +// toApiType returns name that is used as type reference in VPP binary API +func toApiType(name string) string { + return defineApiPrefix + name + defineApiSuffix +} + +func fromApiType(typ string) string { + name := typ + name = strings.TrimPrefix(name, defineApiPrefix) + name = strings.TrimSuffix(name, defineApiSuffix) + return name +} + +func getSizeOfType(module *File, typ *Struct) (size int) { + for _, field := range typ.Fields { + enum := getEnumByRef(module, field.Type) + if enum != nil { + size += getSizeOfBinapiTypeLength(enum.Type, field.Length) + continue + } + size += getSizeOfBinapiTypeLength(field.Type, field.Length) + } + return size +} + +func getEnumByRef(file *File, ref string) *Enum { + for _, typ := range file.Enums { + if ref == toApiType(typ.Name) { + return typ + } + } + return nil +} + +func getTypeByRef(file *File, ref string) *Struct { + for _, typ := range file.Structs { + if ref == toApiType(typ.Name) { + return typ + } + } + return nil +} + +func getAliasByRef(file *File, ref string) *Alias { + for _, alias := range file.Aliases { + if ref == toApiType(alias.Name) { + return alias + } + } + return nil +} + +func getUnionByRef(file *File, ref string) *Union { + for _, union := range file.Unions { + if ref == toApiType(union.Name) { + return union + } + } + return nil +} + +func getBinapiTypeSize(binapiType string) (size int) { + typName := BaseTypeNames[binapiType] + return BaseTypeSizes[typName] +} + +// 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", +} +var BaseTypesGo = map[BaseType]string{ + U8: "uint8", + I8: "int8", + U16: "uint16", + I16: "int16", + U32: "uint32", + I32: "int32", + U64: "uint64", + I64: "int64", + F64: "float64", + BOOL: "bool", + STRING: "string", +} + +func getActualType(file *File, typ string) (actual string) { + for _, enum := range file.Enums { + if enum.GoName == typ { + return enum.Type + } + } + for _, alias := range file.Aliases { + if alias.GoName == typ { + return alias.Type + } + } + return typ +} + +// convertToGoType translates the VPP binary API type into Go type +func convertToGoType(file *File, binapiType string) (typ string) { + if t, ok := binapiTypes[binapiType]; ok { + // basic types + typ = t + } else if r, ok := file.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 getSizeOfBinapiTypeLength(typ string, length int) (size int) { + if n := getBinapiTypeSize(typ); n > 0 { + if length > 0 { + return n * length + } else { + return n + } + } + + return +} + +func getUnionSize(file *File, union *Union) (maxSize int) { + for _, field := range union.Fields { + typ := getTypeByRef(file, field.Type) + if typ != nil { + if size := getSizeOfType(file, typ); size > maxSize { + maxSize = size + } + continue + } + alias := getAliasByRef(file, 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/binapigen/validate.go b/binapigen/validate.go new file mode 100644 index 0000000..2dae903 --- /dev/null +++ b/binapigen/validate.go @@ -0,0 +1,66 @@ +// 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" + + "git.fd.io/govpp.git/binapigen/vppapi" + "github.com/sirupsen/logrus" +) + +const ( + serviceEventPrefix = "want_" + serviceDumpSuffix = "_dump" + serviceDetailsSuffix = "_details" + serviceReplySuffix = "_reply" +) + +func validateService(svc vppapi.Service) { + for _, rpc := range svc.RPCs { + validateRPC(rpc) + } +} + +func validateRPC(rpc vppapi.RPC) { + if len(rpc.Events) > 0 { + // EVENT service + if !strings.HasPrefix(rpc.RequestMsg, serviceEventPrefix) { + logrus.Warnf("unusual EVENTS service: %+v\n"+ + "- events service %q does not have %q prefix in request.", + rpc, rpc.Name, serviceEventPrefix) + } + } else if rpc.Stream { + // STREAM service + if !strings.HasSuffix(rpc.RequestMsg, serviceDumpSuffix) { + logrus.Warnf("unusual STREAM service: %+v\n"+ + "- stream service %q does not have %q suffix in request.", + rpc, rpc.Name, serviceDumpSuffix) + } + if !strings.HasSuffix(rpc.ReplyMsg, serviceDetailsSuffix) && !strings.HasSuffix(rpc.StreamMsg, serviceDetailsSuffix) { + logrus.Warnf("unusual STREAM service: %+v\n"+ + "- stream service %q does not have %q suffix in reply or stream msg.", + rpc, rpc.Name, serviceDetailsSuffix) + } + } else if rpc.ReplyMsg != "" { + // REQUEST service + // some messages might have `null` reply (for example: memclnt) + if !strings.HasSuffix(rpc.ReplyMsg, serviceReplySuffix) { + logrus.Warnf("unusual REQUEST service: %+v\n"+ + "- service %q does not have %q suffix in reply.", + rpc, rpc.Name, serviceReplySuffix) + } + } +} diff --git a/binapigen/vppapi/api.go b/binapigen/vppapi/api.go new file mode 100644 index 0000000..06d9046 --- /dev/null +++ b/binapigen/vppapi/api.go @@ -0,0 +1,94 @@ +// 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 File struct { + Name string + Path string + + CRC string + Options map[string]string `json:",omitempty"` + + Imports []string `json:",omitempty"` + + AliasTypes []AliasType `json:",omitempty"` + EnumTypes []EnumType `json:",omitempty"` + StructTypes []StructType `json:",omitempty"` + UnionTypes []UnionType `json:",omitempty"` + Messages []Message `json:",omitempty"` + Service *Service `json:",omitempty"` +} + +func (x File) Version() string { + if x.Options != nil { + return x.Options[fileOptionVersion] + } + return "" +} + +type AliasType struct { + Name string + Type string + Length int `json:",omitempty"` +} + +type EnumType struct { + Name string + Type string + Entries []EnumEntry +} + +type EnumEntry struct { + Name string + Value uint32 +} + +type StructType struct { + Name string + Fields []Field +} + +type UnionType struct { + Name string + Fields []Field +} + +type Message struct { + Name string + Fields []Field + CRC string +} + +type Field struct { + Name string + Type string + Length int `json:",omitempty"` + Array bool `json:",omitempty"` + SizeFrom string `json:",omitempty"` + Meta map[string]interface{} `json:",omitempty"` +} + +type Service struct { + RPCs []RPC `json:",omitempty"` +} + +type RPC struct { + Name string + RequestMsg string + ReplyMsg string + Stream bool `json:",omitempty"` + StreamMsg string `json:",omitempty"` + Events []string `json:",omitempty"` +} diff --git a/binapigen/vppapi/integration_test.go b/binapigen/vppapi/integration_test.go new file mode 100644 index 0000000..142017a --- /dev/null +++ b/binapigen/vppapi/integration_test.go @@ -0,0 +1,43 @@ +// 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. + +// +build integration + +package vppapi_test + +import ( + "encoding/json" + "testing" + + "git.fd.io/govpp.git/binapigen/vppapi" +) + +func TestParse(t *testing.T) { + files, err := vppapi.Parse() + if err != nil { + t.Fatal(err) + } + + for _, file := range files { + //t.Logf(" - %s: %+v", path, module) + 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/parse_json.go b/binapigen/vppapi/parse_json.go new file mode 100644 index 0000000..45b5796 --- /dev/null +++ b/binapigen/vppapi/parse_json.go @@ -0,0 +1,552 @@ +// 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" + "os" + "strings" + + "github.com/bennyscetbun/jsongo" + "github.com/sirupsen/logrus" +) + +var Logger *logrus.Logger + +func init() { + if strings.Contains(os.Getenv("DEBUG_GOVPP"), "parser") { + Logger = logrus.StandardLogger() + } +} + +func logf(f string, v ...interface{}) { + if Logger != nil { + Logger.Debugf(f, v...) + } +} + +const ( + // file + objAPIVersion = "vl_api_version" + objTypes = "types" + objMessages = "messages" + objUnions = "unions" + objEnums = "enums" + objServices = "services" + objAliases = "aliases" + objOptions = "options" + objImports = "imports" + + // message + messageFieldCrc = "crc" + + // alias + aliasFieldLength = "length" + aliasFieldType = "type" + + // service + serviceFieldReply = "reply" + serviceFieldStream = "stream" + serviceFieldStreamMsg = "stream_msg" + serviceFieldEvents = "events" +) + +const ( + // file + fileOptionVersion = "version" + + // field + fieldOptionLimit = "limit" + fieldOptionDefault = "default" + + // service + serviceReplyNull = "null" +) + +func parseJSON(data []byte) (module *File, err error) { + defer func() { + if e := recover(); e != nil { + err = fmt.Errorf("recovered panic: %v", e) + } + }() + + // parse JSON data into objects + jsonRoot := new(jsongo.Node) + if err := json.Unmarshal(data, jsonRoot); err != nil { + return nil, fmt.Errorf("unmarshalling JSON failed: %v", err) + } + + logf("file contents:") + for _, key := range jsonRoot.GetKeys() { + if jsonRoot.At(key).Len() > 0 { + logf(" - %2d %s", jsonRoot.At(key).Len(), key) + } + } + + module = new(File) + + // parse CRC + if crc := jsonRoot.At(objAPIVersion); crc.GetType() == jsongo.TypeValue { + module.CRC = crc.Get().(string) + } + + // parse options + opt := jsonRoot.Map(objOptions) + if opt.GetType() == jsongo.TypeMap { + module.Options = make(map[string]string, 0) + for _, key := range opt.GetKeys() { + optionsNode := opt.At(key) + optionKey := key.(string) + optionValue := optionsNode.Get().(string) + module.Options[optionKey] = optionValue + } + } + + // parse imports + imports := jsonRoot.Map(objImports) + module.Imports = make([]string, 0) + imported := make(map[string]struct{}) + for i := 0; i < imports.Len(); i++ { + importNode := imports.At(i) + imp, err := parseImport(importNode) + if err != nil { + return nil, err + } + if _, ok := imported[*imp]; ok { + logf("duplicate import found: %v", *imp) + continue + } + imported[*imp] = struct{}{} + module.Imports = append(module.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 := jsonRoot.Map(objEnums) + module.EnumTypes = make([]EnumType, 0) + for i := 0; i < enumsNode.Len(); i++ { + enumNode := enumsNode.At(i) + enum, err := parseEnum(enumNode) + if err != nil { + return nil, err + } + if exists(enum.Name) { + continue + } + module.EnumTypes = append(module.EnumTypes, *enum) + } + + // parse alias types + aliasesNode := jsonRoot.Map(objAliases) + if aliasesNode.GetType() == jsongo.TypeMap { + module.AliasTypes = make([]AliasType, 0) + for _, key := range aliasesNode.GetKeys() { + aliasNode := aliasesNode.At(key) + aliasName := key.(string) + alias, err := parseAlias(aliasName, aliasNode) + if err != nil { + return nil, err + } + if exists(alias.Name) { + continue + } + module.AliasTypes = append(module.AliasTypes, *alias) + } + } + + // parse struct types + typesNode := jsonRoot.Map(objTypes) + module.StructTypes = make([]StructType, 0) + for i := 0; i < typesNode.Len(); i++ { + typNode := typesNode.At(i) + structyp, err := parseStruct(typNode) + if err != nil { + return nil, err + } + if exists(structyp.Name) { + continue + } + module.StructTypes = append(module.StructTypes, *structyp) + } + + // parse union types + unionsNode := jsonRoot.Map(objUnions) + module.UnionTypes = make([]UnionType, 0) + for i := 0; i < unionsNode.Len(); i++ { + unionNode := unionsNode.At(i) + union, err := parseUnion(unionNode) + if err != nil { + return nil, err + } + if exists(union.Name) { + continue + } + module.UnionTypes = append(module.UnionTypes, *union) + } + + // parse messages + messagesNode := jsonRoot.Map(objMessages) + if messagesNode.GetType() == jsongo.TypeArray { + module.Messages = make([]Message, messagesNode.Len()) + for i := 0; i < messagesNode.Len(); i++ { + msgNode := messagesNode.At(i) + msg, err := parseMessage(msgNode) + if err != nil { + return nil, err + } + module.Messages[i] = *msg + } + } + + // parse services + servicesNode := jsonRoot.Map(objServices) + if servicesNode.GetType() == jsongo.TypeMap { + module.Service = &Service{ + RPCs: make([]RPC, servicesNode.Len()), + } + for i, key := range servicesNode.GetKeys() { + rpcNode := servicesNode.At(key) + rpcName := key.(string) + svc, err := parseServiceRPC(rpcName, rpcNode) + if err != nil { + return nil, err + } + module.Service.RPCs[i] = *svc + } + } + + return module, nil +} + +// parseImport parses VPP binary API import from JSON node +func parseImport(importNode *jsongo.Node) (*string, error) { + if importNode.GetType() != jsongo.TypeValue { + return nil, errors.New("invalid JSON for import specified") + } + + importName, ok := importNode.Get().(string) + if !ok { + return nil, fmt.Errorf("import name is %T, not a string", importNode.Get()) + } + + return &importName, 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(aliasFieldType).GetType() != jsongo.TypeValue { + return nil, errors.New("invalid JSON for alias specified") + } + + alias := AliasType{ + Name: aliasName, + } + + if typeNode := aliasNode.At(aliasFieldType); 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(aliasFieldLength); 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() == 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(messageFieldCrc).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(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, + } + + 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) + + for _, key := range fieldMeta.GetKeys() { + metaNode := fieldMeta.At(key) + metaName := key.(string) + metaValue := metaNode.Get() + + switch metaName { + case fieldOptionLimit: + metaValue = int(metaNode.Get().(float64)) + case fieldOptionDefault: + metaValue = metaNode.Get() + default: + logrus.Warnf("unknown meta info (%s=%v) for field (%s)", metaName, metaValue, fieldName) + } + + if f.Meta == nil { + f.Meta = map[string]interface{}{} + } + f.Meta[metaName] = metaValue + } + 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 +} + +// 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(serviceFieldReply).GetType() != jsongo.TypeValue { + return nil, errors.New("invalid JSON for service RPC specified") + } + + rpc := RPC{ + Name: rpcName, + RequestMsg: rpcName, + } + + if replyNode := rpcNode.At(serviceFieldReply); 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()) + } + if reply != serviceReplyNull { + rpc.ReplyMsg = reply + } + } + + // is stream (dump) + if streamNode := rpcNode.At(serviceFieldStream); 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(serviceFieldStreamMsg); 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(serviceFieldEvents); 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 +} diff --git a/binapigen/vppapi/parser.go b/binapigen/vppapi/parser.go new file mode 100644 index 0000000..312dd0e --- /dev/null +++ b/binapigen/vppapi/parser.go @@ -0,0 +1,111 @@ +// 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 ( + "fmt" + "io/ioutil" + "path/filepath" + "strings" + + "github.com/sirupsen/logrus" +) + +const ( + DefaultAPIDir = "/usr/share/vpp/api" +) + +const apifileSuffixJson = ".api.json" + +// FindFiles returns all input files located in specified directory +func FindFiles(dir string, deep int) (paths []string, err error) { + entries, err := ioutil.ReadDir(dir) + if err != nil { + return nil, fmt.Errorf("reading directory %s failed: %v", dir, err) + } + for _, e := range entries { + if e.IsDir() && deep > 0 { + nestedDir := filepath.Join(dir, e.Name()) + if nested, err := FindFiles(nestedDir, deep-1); err != nil { + return nil, err + } else { + paths = append(paths, nested...) + } + } else if strings.HasSuffix(e.Name(), apifileSuffixJson) { + paths = append(paths, filepath.Join(dir, e.Name())) + } + } + return paths, nil +} + +func Parse() ([]*File, error) { + return ParseDir(DefaultAPIDir) +} + +func ParseDir(apidir string) ([]*File, error) { + files, err := FindFiles(apidir, 1) + if err != nil { + return nil, err + } + + logrus.Infof("found %d files in API dir %q", len(files), apidir) + + var modules []*File + + for _, file := range files { + module, err := ParseFile(file) + if err != nil { + return nil, err + } + modules = append(modules, module) + } + + return modules, nil +} + +// ParseFile parses API file contents and returns File. +func ParseFile(apifile string) (*File, error) { + if !strings.HasSuffix(apifile, apifileSuffixJson) { + return nil, fmt.Errorf("unsupported file format: %q", apifile) + } + + data, err := ioutil.ReadFile(apifile) + if err != nil { + return nil, fmt.Errorf("reading file %s failed: %v", apifile, err) + } + + base := filepath.Base(apifile) + name := base[:strings.Index(base, ".")] + + logf("parsing file %q", base) + + module, err := ParseRaw(data) + if err != nil { + return nil, fmt.Errorf("parsing file %s failed: %v", base, err) + } + module.Name = name + module.Path = apifile + + return module, nil +} + +func ParseRaw(data []byte) (file *File, err error) { + file, err = parseJSON(data) + if err != nil { + return nil, err + } + + return file, nil +} diff --git a/binapigen/vppapi/parser_test.go b/binapigen/vppapi/parser_test.go new file mode 100644 index 0000000..2dc82e4 --- /dev/null +++ b/binapigen/vppapi/parser_test.go @@ -0,0 +1,114 @@ +// 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" + "io/ioutil" + "testing" + + . "github.com/onsi/gomega" +) + +func TestGetInputFiles(t *testing.T) { + RegisterTestingT(t) + + result, err := FindFiles("testdata", 1) + Expect(err).ShouldNot(HaveOccurred()) + Expect(result).To(HaveLen(5)) + for _, file := range result { + Expect(file).To(BeAnExistingFile()) + } +} + +func TestGetInputFilesError(t *testing.T) { + RegisterTestingT(t) + + result, err := FindFiles("nonexisting_directory", 1) + Expect(err).Should(HaveOccurred()) + Expect(result).To(BeNil()) +} + +func TestReadJson(t *testing.T) { + RegisterTestingT(t) + + inputData, err := ioutil.ReadFile("testdata/af_packet.api.json") + Expect(err).ShouldNot(HaveOccurred()) + result, err := parseJSON(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 := ioutil.ReadFile("testdata/input-read-json-error.json") + Expect(err).ShouldNot(HaveOccurred()) + result, err := parseJSON(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.CRC != "0xbd2c94f4" { + t.Errorf("expected CRC=%s, got %v", "0xbd2c94f4", module.CRC) + } + if module.Version() != "1.6.1" { + t.Errorf("expected Version=%s, got %v", "1.6.1", module.Version()) + } + if len(module.Imports) == 0 { + t.Errorf("expected imports, got none") + } + if len(module.Options) == 0 { + t.Errorf("expected options, 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.Service.RPCs) == 0 { + t.Errorf("expected service method, got none") + } + if len(module.Messages) == 0 { + t.Errorf("expected messages, got none") + } +} + +func TestParseFileUnsupported(t *testing.T) { + _, err := ParseFile("testdata/input.txt") + if err == nil { + t.Fatal("expected error") + } +} diff --git a/cmd/binapi-generator/testdata/acl.api.json b/binapigen/vppapi/testdata/acl.api.json index 4c6653c..4c6653c 100644 --- a/cmd/binapi-generator/testdata/acl.api.json +++ b/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 index 81ee2f9..dc0de16 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 index d5df76e..d5df76e 100644 --- a/cmd/binapi-generator/testdata/input-generate-error.json +++ b/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 index 02691e3..02691e3 100644 --- a/cmd/binapi-generator/testdata/input-read-json-error.json +++ b/binapigen/vppapi/testdata/input-read-json-error.json diff --git a/cmd/binapi-generator/testdata/input.txt b/binapigen/vppapi/testdata/input.txt index e69de29..e69de29 100644 --- a/cmd/binapi-generator/testdata/input.txt +++ b/binapigen/vppapi/testdata/input.txt diff --git a/cmd/binapi-generator/testdata/ip.api.json b/binapigen/vppapi/testdata/ip.api.json index 530b6d6..530b6d6 100644 --- a/cmd/binapi-generator/testdata/ip.api.json +++ b/binapigen/vppapi/testdata/ip.api.json diff --git a/binapigen/vppapi/testdata/test-all.api.json b/binapigen/vppapi/testdata/test-all.api.json new file mode 100644 index 0000000..4e858b8 --- /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/vpe.api.json b/binapigen/vppapi/testdata/vpe.api.json new file mode 100644 index 0000000..960ba12 --- /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/cmd/binapi-generator/definitions_test.go b/cmd/binapi-generator/definitions_test.go deleted file mode 100644 index 30c85ae..0000000 --- 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 d74d47b..9be49e2 100644 --- a/cmd/binapi-generator/doc.go +++ b/cmd/binapi-generator/doc.go @@ -1,4 +1,18 @@ -// Generator of Go structs out of the VPP binary API definitions in JSON format. +// 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. + +// Context of Go structs out of the VPP binary API definitions in JSON format. // // 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 diff --git a/cmd/binapi-generator/generate.go b/cmd/binapi-generator/generate.go deleted file mode 100644 index 715836d..0000000 --- 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", "git.fd.io/govpp.git/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 fcd85ae..c0bdbb9 100644 --- a/cmd/binapi-generator/main.go +++ b/cmd/binapi-generator/main.go @@ -15,324 +15,102 @@ package main import ( - "bytes" - "encoding/json" "flag" "fmt" - "go/format" - "io/ioutil" "os" - "path/filepath" - "strings" - "github.com/bennyscetbun/jsongo" "github.com/sirupsen/logrus" + "git.fd.io/govpp.git/binapigen" + "git.fd.io/govpp.git/binapigen/vppapi" "git.fd.io/govpp.git/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.") - - 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.") - - continueOnError = flag.Bool("continue-onerror", false, "Continue with next file on error.") - debugMode = flag.Bool("debug", os.Getenv("GOVPP_DEBUG") != "", "Enable debug mode.") - - printVersion = flag.Bool("version", false, "Prints current version and exits.") -) +func init() { + flag.Usage = func() { + fmt.Fprintf(flag.CommandLine.Output(), "Usage: %s [OPTION]... [API]...\n", os.Args[0]) + fmt.Fprintln(flag.CommandLine.Output(), "Generate code for each API.") + fmt.Fprintf(flag.CommandLine.Output(), "Example: %s -output-dir=binapi acl interface l2\n", os.Args[0]) + fmt.Fprintln(flag.CommandLine.Output()) + fmt.Fprintln(flag.CommandLine.Output(), "Options:") + flag.CommandLine.PrintDefaults() + } +} func main() { + var ( + theInputFile = flag.String("input-file", "", "Input VPP API file. (DEPRECATED: Use program arguments to define VPP API files)") + theApiDir = flag.String("input-dir", vppapi.DefaultAPIDir, "Directory with VPP API files.") + theOutputDir = flag.String("output-dir", ".", "Output directory where code will be generated.") + + importPrefix = flag.String("import-prefix", "", "Define import path prefix to be used to import types.") + importTypes = flag.Bool("import-types", false, "Generate packages for imported types.") + 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", true, "Include binary API names in struct tag.") + includeVppVersion = flag.Bool("include-vpp-version", true, "Include version of the VPP that provided input files.") + + debugMode = flag.Bool("debug", os.Getenv("DEBUG_GOVPP") != "", "Enable debug mode.") + printVersion = flag.Bool("version", false, "Prints version and exits.") + ) flag.Parse() - if flag.NArg() > 1 { - flag.Usage() - os.Exit(1) - } - - 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) - } - } - if *printVersion { fmt.Fprintln(os.Stdout, version.Info()) os.Exit(0) } - if *debugMode { - 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) + if flag.NArg() == 1 && flag.Arg(0) == "version" { + fmt.Fprintln(os.Stdout, version.Verbose()) + os.Exit(0) } -} -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 opts binapigen.Options - 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) - } - } - - 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) + if *theInputFile != "" { + if flag.NArg() > 0 { + fmt.Fprintln(os.Stderr, "input-file cannot be combined with files to generate in arguments") + os.Exit(1) } + opts.FilesToGenerate = append(opts.FilesToGenerate, *theInputFile) } 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) - } - } - } - } - - 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())) - } - } - 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 + opts.FilesToGenerate = append(opts.FilesToGenerate, flag.Args()...) } - logf("------------------------------------------------------------") - logf("module: %s", ctx.moduleName) - logf(" - input: %s", ctx.inputFile) - logf(" - output: %s", ctx.outputFile) - logf("------------------------------------------------------------") - // 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) - } - } - - // 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()) - if err != nil { - return fmt.Errorf("formatting source code for package %s failed: %v", ctx.packageName, err) + if ver := os.Getenv("VPP_API_VERSION"); ver != "" { + // use version from env var if set + opts.VPPVersion = ver + } else { + opts.VPPVersion = ResolveVppVersion(*theApiDir) } + opts.IncludeAPIVersion = *includeAPIVer + opts.IncludeComments = *includeComments + opts.IncludeBinapiNames = *includeBinapiNames + opts.IncludeServices = *includeServices + opts.IncludeVppVersion = *includeVppVersion + opts.ImportPrefix = *importPrefix + opts.ImportTypes = *importTypes - // 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) + if *debugMode { + logrus.SetLevel(logrus.DebugLevel) + logrus.Debug("debug mode enabled") } - return nil -} + apiDir := *theApiDir + outputDir := *theOutputDir -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, - } - } - } - } - 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 + binapigen.Run(apiDir, opts, func(g *binapigen.Generator) error { + for _, file := range g.Files { + if !file.Generate { + continue } - 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, - } + binapigen.GenerateBinapiFile(g, file, outputDir) + if g.IncludeServices && file.Service != nil { + binapigen.GenerateRPC(g, file, outputDir) } } - } - 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 -} - -func logf(f string, v ...interface{}) { - if *debugMode { - logrus.Debugf(f, v...) - } + return nil + }) } diff --git a/cmd/binapi-generator/objects.go b/cmd/binapi-generator/objects.go deleted file mode 100644 index 9871abc..0000000 --- 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 6598b7b..0000000 --- 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/types.go b/cmd/binapi-generator/types.go deleted file mode 100644 index 90c890f..0000000 --- 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/binapi-generator/util.go b/cmd/binapi-generator/util.go new file mode 100644 index 0000000..8738963 --- /dev/null +++ b/cmd/binapi-generator/util.go @@ -0,0 +1,81 @@ +// 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 ( + "io/ioutil" + "os/exec" + "path" + "strings" + + "github.com/sirupsen/logrus" +) + +const ( + versionScriptPath = "./src/scripts/version" + defaultVppApiDir = "/usr/share/vpp/api" +) + +func ResolveVppVersion(inputDir string) string { + // assuming VPP package is installed + if inputDir == defaultVppApiDir { + // resolve VPP version using dpkg + cmd := exec.Command("dpkg-query", "-f", "${Version}", "-W", "vpp") + out, err := cmd.CombinedOutput() + if err != nil { + logrus.Warnf("resolving VPP version from installed package failed: %v", err) + logrus.Warnf("command output: %s", out) + } else { + version := strings.TrimSpace(string(out)) + logrus.Debugf("resolved VPP version from installed package: %v", version) + return version + } + } + // check if inside VPP git repo + if inputDir != "" { + repo := findVppGitRepo(inputDir) + if repo != "" { + cmd := exec.Command(versionScriptPath) + cmd.Dir = repo + out, err := cmd.CombinedOutput() + if err != nil { + logrus.Warnf("resolving VPP version from version script failed: %v", err) + logrus.Warnf("command output: %s", out) + } else { + version := strings.TrimSpace(string(out)) + logrus.Debugf("resolved VPP version from version script: %v", version) + return version + } + } + file, err := ioutil.ReadFile(path.Join(inputDir, "VPP_VERSION")) + if err == nil { + return strings.TrimSpace(string(file)) + } + } + logrus.Warnf("VPP version could not be resolved, you can set it manually using VPP_API_VERSION env var") + return "unknown" +} + +func findVppGitRepo(dir string) string { + cmd := exec.Command("git", "rev-parse", "--show-toplevel") + cmd.Dir = dir + out, err := cmd.CombinedOutput() + if err != nil { + logrus.Warnf("checking VPP git repo failed: %v", err) + logrus.Warnf("command output: %s", out) + return "" + } + return strings.TrimSpace(string(out)) +} diff --git a/codec/bench_test.go b/codec/bench_test.go new file mode 100644 index 0000000..6889fa7 --- /dev/null +++ b/codec/bench_test.go @@ -0,0 +1,90 @@ +// 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 ( + "fmt" + "testing" + + "git.fd.io/govpp.git/codec" +) + +var Data []byte + +func BenchmarkEncode(b *testing.B) { + m := NewTestAllMsg() + + var err error + var data []byte + + for i := 0; i < b.N; i++ { + c := codec.MsgCodec{} + data, err = c.EncodeMsg(m, 100) + if err != nil { + b.Fatalf("expected nil error, got: %v", err) + } + } + Data = data +} + +func BenchmarkEncodeStruc(b *testing.B) { + m := NewTestAllMsg() + c := codec.OldCodec{} + + var err error + var data []byte + + b.ResetTimer() + for i := 0; i < b.N; i++ { + data, err = c.Marshal(m) + if err != nil { + b.Fatalf("expected nil error, got: %v", err) + } + } + Data = data + fmt.Printf("DATA(%d): % 0X\n", len(Data), Data) +} + +/*func BenchmarkEncodeNew(b *testing.B) { + m := NewTestAllMsg() + + var err error + var data []byte + + for i := 0; i < b.N; i++ { + c := CodecNew{} + data, err = c.Marshal(m) + 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 + fmt.Printf("DATA(%d): % 0X\n", len(Data), Data) +} diff --git a/codec/marshaler.go b/codec/marshaler.go new file mode 100644 index 0000000..c6d33a3 --- /dev/null +++ b/codec/marshaler.go @@ -0,0 +1,229 @@ +// 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" + "errors" + "fmt" + "math" + "reflect" + "unsafe" + + "github.com/lunixbochs/struc" + + "git.fd.io/govpp.git/api" +) + +var DefaultCodec = &NewCodec{} // &MsgCodec{} + +// 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 NewCodec struct{} + +func (*NewCodec) EncodeMsg(msg api.Message, msgID uint16) (data []byte, err error) { + if msg == nil { + return nil, errors.New("nil message passed in") + } + marshaller, ok := msg.(Marshaler) + if !ok { + return nil, fmt.Errorf("message %s does not implement marshaller", msg.GetMessageName()) + } + + size := marshaller.Size() + offset := getOffset(msg) + //fmt.Printf("size=%d offset=%d\n", size, offset) + + b := make([]byte, size+offset) + b[0] = byte(msgID >> 8) + b[1] = byte(msgID) + + //fmt.Printf("len(b)=%d cap(b)=%d\n", len(b), cap(b)) + //b = append(b, byte(msgID>>8), byte(msgID)) + + //buf := new(bytes.Buffer) + //buf.Grow(size) + + // encode msg ID + //buf.WriteByte(byte(msgID >> 8)) + //buf.WriteByte(byte(msgID)) + + data, err = marshaller.Marshal(b[offset:]) + if err != nil { + return nil, err + } + //buf.Write(b) + + return b[0:len(b):len(b)], nil +} + +func getOffset(msg api.Message) (offset int) { + switch msg.GetMessageType() { + case api.RequestMessage: + return 10 + case api.ReplyMessage: + return 6 + case api.EventMessage: + return 6 + } + return 2 +} + +func (*NewCodec) DecodeMsg(data []byte, msg api.Message) (err error) { + if msg == nil { + return errors.New("nil message passed in") + } + marshaller, ok := msg.(Unmarshaler) + if !ok { + return fmt.Errorf("message %s does not implement marshaller", msg.GetMessageName()) + } + + offset := getOffset(msg) + + err = marshaller.Unmarshal(data[offset:len(data)]) + if err != nil { + return err + } + + return nil +} + +func (*NewCodec) DecodeMsgContext(data []byte, msg api.Message) (context uint32, err error) { + if msg == nil { + return 0, errors.New("nil message passed in") + } + + switch msg.GetMessageType() { + case api.RequestMessage: + return order.Uint32(data[6:10]), nil + case api.ReplyMessage: + return order.Uint32(data[2:6]), nil + } + + return 0, nil +} + +type OldCodec struct{} + +func (c *OldCodec) Marshal(v interface{}) (b []byte, err error) { + buf := new(bytes.Buffer) + if err := struc.Pack(buf, v); err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +func (c *OldCodec) Unmarshal(data []byte, v interface{}) error { + buf := bytes.NewReader(data) + if err := struc.Unpack(buf, v); err != nil { + return err + } + return nil +} + +/*type CodecNew struct{} + +func (c *CodecNew) Marshal(v interface{}) (b []byte, err error) { + buf := new(bytes.Buffer) + if err := binary.Write(buf, binary.BigEndian, v); err != nil { + return nil, err + } + return buf.Bytes(), nil +}*/ + +func EncodeBool(b bool) byte { + if b { + return 1 + } + return 0 +} + +func MarshalValue(value interface{}) []byte { + switch value.(type) { + case int8: + return []byte{byte(value.(int8))} + case uint8: + return []byte{byte(value.(uint8))} + } + return nil +} + +var order = binary.BigEndian + +type Buffer struct { + pos int + buf []byte +} + +func (b *Buffer) Bytes() []byte { + return b.buf[:b.pos] +} + +func (b *Buffer) EncodeUint8(v uint8) { + b.buf[b.pos] = v + b.pos += 1 +} + +func (b *Buffer) EncodeUint16(v uint16) { + order.PutUint16(b.buf[b.pos:b.pos+2], v) + b.pos += 2 +} + +func (b *Buffer) EncodeUint32(v uint32) { + order.PutUint32(b.buf[b.pos:b.pos+4], v) + b.pos += 4 +} + +func (b *Buffer) EncodeUint64(v uint64) { + order.PutUint64(b.buf[b.pos:b.pos+8], v) + b.pos += 8 +} + +func (b *Buffer) EncodeFloat64(v float64) { + order.PutUint64(b.buf[b.pos:b.pos+8], math.Float64bits(v)) + b.pos += 8 +} + +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) EncodeString(v string) { + + b.pos += 1 +} + +func DecodeString(b []byte) string { + sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&b)) + stringHeader := reflect.StringHeader{Data: sliceHeader.Data, Len: sliceHeader.Len} + return *(*string)(unsafe.Pointer(&stringHeader)) +} diff --git a/codec/marshaler_test.go b/codec/marshaler_test.go new file mode 100644 index 0000000..9a1887b --- /dev/null +++ b/codec/marshaler_test.go @@ -0,0 +1,712 @@ +// 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" + "encoding/binary" + "reflect" + "testing" + + "github.com/lunixbochs/struc" + + "git.fd.io/govpp.git/api" + "git.fd.io/govpp.git/codec" + "git.fd.io/govpp.git/examples/binapi/fib_types" + "git.fd.io/govpp.git/examples/binapi/interface_types" + "git.fd.io/govpp.git/examples/binapi/interfaces" + "git.fd.io/govpp.git/examples/binapi/ip" + "git.fd.io/govpp.git/examples/binapi/ip_types" + "git.fd.io/govpp.git/examples/binapi/sr" +) + +/*func TestNewCodecEncodeDecode(t *testing.T) { + tests := []struct { + name string + msg Codec + }{ + { + "", &TestAllMsg{ + Bool: true, + AliasUint32: 5, + AliasArray: MacAddress{0x11, 0x22, 0x33, 0x44, 0x55, 0x66}, + BaseArray: []uint32{0x00, 0x00, 0x00, 0x00}, + Enum: IF_STATUS_API_FLAG_LINK_UP, + Uint8: 8, + Uint16: 16, + Uint32: 32, + Int8: 88, + Int16: 1616, + Int32: 3232, + Slice: []byte{10, 20, 30, 40, 0, 0, 0}, + String: "abcdefghikl", + SizeOf: 2, + VariableSlice: []SliceType{ + {Proto: IP_API_PROTO_AH}, + {Proto: IP_API_PROTO_ESP}, + }, + TypeUnion: Address{ + Af: ADDRESS_IP4, + Un: AddressUnionIP4(IP4Address{1, 2, 3, 4}), + }, + }, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + data, err := test.msg.Marshal() + if err != nil { + t.Fatalf("expected nil error, got: %v", err) + } + + var m2 TestAllMsg + 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") + } + }) + } +}*/ + +func NewTestAllMsg() *TestAllMsg { + return &TestAllMsg{ + Bool: true, + AliasUint32: 5, + AliasArray: MacAddress{0x11, 0x22, 0x33, 0x44, 0x55, 0x66}, + BaseArray: []uint32{0x00, 0x00, 0x00, 0x00}, + Enum: IF_STATUS_API_FLAG_LINK_UP, + Uint8: 8, + Uint16: 16, + Uint32: 32, + Int8: 88, + Int16: 1616, + Int32: 3232, + Slice: []byte{10, 20, 30, 40, 0, 0, 0}, + String: "abcdefghikl", + SizeOf: 2, + VariableSlice: []SliceType{ + {Proto: IP_API_PROTO_AH}, + {Proto: IP_API_PROTO_ESP}, + }, + TypeUnion: Address{ + Af: ADDRESS_IP4, + Un: AddressUnionIP4(IP4Address{1, 2, 3, 4}), + }, + } +} + +func TestNewCodecEncodeDecode_(t *testing.T) { + m := NewTestAllMsg() + + data, err := m.Marshal(nil) + if err != nil { + t.Fatalf("expected nil error, got: %v", err) + } + + var m2 TestAllMsg + 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") + } +} + +// ------------- + +func TestNewCodecEncodeDecode3(t *testing.T) { + m := NewTestAllMsg() + data, err := m.Marshal(nil) + if err != nil { + t.Fatalf("expected nil error, got: %v", err) + } + + var m2 TestAllMsg + 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") + } +} +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: sr.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]sr.IP6Address{ + {99}, + {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, + }, + }, + }, + } + + b := make([]byte, 0, 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") + } +} + +func TestNewCodecEncode(t *testing.T) { + //m := NewIPRouteLookupReply() + m := &sr.SrPoliciesDetails{ + Bsid: sr.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]sr.IP6Address{ + {99}, + {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, + }, + }, + }, + } + + size := m.Size() + t.Logf("size: %d", size) + + var err error + var oldData, newData []byte + { + var c codec.OldCodec + oldData, err = c.Marshal(m) + if err != nil { + t.Fatalf("expected nil error, got: %v", err) + } + } + { + newData, err = m.Marshal(nil) + if err != nil { + t.Fatalf("expected nil error, got: %v", err) + } + } + t.Logf("Data:\nOLD[%d]: % 03x\nNEW[%d]: % 03x", len(oldData), oldData, len(newData), newData) + + if !bytes.Equal(oldData, newData) { + t.Fatalf("newData differs from oldData") + } +} + +func TestNewCodecDecode(t *testing.T) { + /*m := &ip.IPRouteLookupReply{} + size := m.Size() + t.Logf("size: %d", size)*/ + data := []byte{ + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, + 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, + 0x00, 0x00, 0x08, 0x09, 0x0a, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x02, 0x01, 0x09, 0x00, + 0x00, 0x00, 0x08, 0x07, 0x06, 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, + } + + var err error + var oldData, newData ip.IPRouteLookupReply + { + var c codec.OldCodec + err = c.Unmarshal(data, &oldData) + if err != nil { + t.Errorf("expected nil error, got: %v", err) + } + } + { + err = newData.Unmarshal(data) + if err != nil { + t.Errorf("expected nil error, got: %v", err) + } + } + t.Logf("Data:\nOLD: %+v\nNEW: %+v", oldData, newData) + + if !reflect.DeepEqual(oldData, newData) { + t.Fatalf("newData differs from oldData") + } +} + +func NewIPRouteLookupReply() *ip.IPRouteLookupReply { + return &ip.IPRouteLookupReply{ + Retval: 1, + Route: ip.IPRoute{ + TableID: 3, + StatsIndex: 5, + Prefix: ip.Prefix{ + Address: ip_types.Address{ + Af: fib_types.ADDRESS_IP6, + Un: ip_types.AddressUnion{}, + }, + Len: 24, + }, + NPaths: 2, + Paths: []ip.FibPath{ + { + SwIfIndex: 5, + TableID: 6, + RpfID: 8, + Weight: 9, + Preference: 10, + Type: 11, + Flags: 1, + Proto: 2, + Nh: ip.FibPathNh{ + Address: ip.AddressUnion{}, + ViaLabel: 3, + ObjID: 1, + ClassifyTableIndex: 2, + }, + NLabels: 1, + LabelStack: [16]ip.FibMplsLabel{ + { + IsUniform: 9, + Label: 8, + TTL: 7, + Exp: 6, + }, + }, + }, + { + SwIfIndex: 7, + TableID: 6, + RpfID: 8, + Weight: 9, + Preference: 10, + Type: 11, + Flags: 1, + Proto: 1, + Nh: ip.FibPathNh{ + Address: ip.AddressUnion{}, + ViaLabel: 3, + ObjID: 1, + ClassifyTableIndex: 2, + }, + NLabels: 2, + LabelStack: [16]ip.FibMplsLabel{ + { + IsUniform: 9, + Label: 8, + TTL: 7, + Exp: 6, + }, + { + IsUniform: 10, + Label: 8, + TTL: 7, + Exp: 6, + }, + }, + }, + }, + }, + } +} + +func TestSize(t *testing.T) { + m := NewTestAllMsg() + size := binary.Size(*m) + t.Logf("size: %v", size) +} + +func (m *TestAllMsg) Marshal(b []byte) ([]byte, error) { + order := binary.BigEndian + tmp := make([]byte, 143) + pos := 0 + + tmp[pos] = boolToUint(m.Bool) + pos += 1 + + tmp[pos] = m.Uint8 + pos += 1 + + order.PutUint16(tmp[pos:pos+2], m.Uint16) + pos += 2 + + order.PutUint32(tmp[pos:pos+4], m.Uint32) + pos += 4 + + tmp[pos] = byte(m.Int8) + pos += 1 + + order.PutUint16(tmp[pos:pos+2], uint16(m.Int16)) + pos += 2 + + order.PutUint32(tmp[pos:pos+4], uint32(m.Int32)) + pos += 4 + + order.PutUint32(tmp[pos:pos+4], uint32(m.AliasUint32)) + pos += 4 + + copy(tmp[pos:pos+6], m.AliasArray[:]) + pos += 6 + + order.PutUint32(tmp[pos:pos+4], uint32(m.Enum)) + pos += 4 + + for i := 0; i < 4; i++ { + var x uint32 + if i < len(m.BaseArray) { + x = m.BaseArray[i] + } + order.PutUint32(tmp[pos:pos+4], uint32(x)) + pos += 4 + } + + copy(tmp[pos:pos+7], m.Slice) + pos += 7 + + copy(tmp[pos:pos+64], m.String) + pos += 64 + + order.PutUint32(tmp[pos:pos+4], uint32(len(m.VlaStr)) /*m.SizeOf*/) + pos += 4 + + copy(tmp[pos:pos+len(m.VlaStr)], m.VlaStr[:]) + pos += len(m.VlaStr) + + order.PutUint32(tmp[pos:pos+4], uint32(len(m.VariableSlice)) /*m.SizeOf*/) + pos += 4 + + for i := range m.VariableSlice { + tmp[pos+i*1] = uint8(m.VariableSlice[i].Proto) + //copy(tmp[102+i:103+i], []byte{byte(m.VariableSlice[i].Proto)}) + } + pos += len(m.VariableSlice) * 1 + + tmp[pos] = uint8(m.TypeUnion.Af) + pos += 1 + + copy(tmp[pos:pos+16], m.TypeUnion.Un.XXX_UnionData[:]) + pos += 16 + + return tmp, nil + + /*_, err := buf.Write(tmp) + if err != nil { + return nil, err + } + return buf.Bytes(), nil*/ +} + +func (m *TestAllMsg) Unmarshal(tmp []byte) error { + order := binary.BigEndian + + //tmp := make([]byte, 143) + pos := 0 + + m.Bool = tmp[pos] != 0 + pos += 1 + + //tmp[pos] = m.Uint8 + m.Uint8 = tmp[pos] + pos += 1 + + //order.PutUint16(tmp[pos:pos+2], m.Uint16) + m.Uint16 = order.Uint16(tmp[pos : pos+2]) + pos += 2 + + //order.PutUint32(tmp[pos:pos+4], m.Uint32) + m.Uint32 = order.Uint32(tmp[pos : pos+4]) + pos += 4 + + //tmp[pos] = byte(m.Int8) + m.Int8 = int8(tmp[pos]) + pos += 1 + + //order.PutUint16(tmp[pos:pos+2], uint16(m.Int16)) + m.Int16 = int16(order.Uint16(tmp[pos : pos+2])) + pos += 2 + + //order.PutUint32(tmp[pos:pos+4], uint32(m.Int32)) + m.Int32 = int32(order.Uint32(tmp[pos : pos+4])) + pos += 4 + + //order.PutUint32(tmp[pos:pos+4], uint32(m.AliasUint32)) + m.AliasUint32 = InterfaceIndex(order.Uint32(tmp[pos : pos+4])) + pos += 4 + + //copy(tmp[pos:pos+6], m.AliasArray[:]) + copy(m.AliasArray[:], tmp[pos:pos+6]) + pos += 6 + + //order.PutUint32(tmp[pos:pos+4], uint32(m.Enum)) + m.Enum = IfStatusFlags(order.Uint32(tmp[pos : pos+4])) + pos += 4 + + m.BaseArray = make([]uint32, 4) + for i := 0; i < 4; i++ { + /*var x uint32 + if i < len(m.BaseArray) { + x = m.BaseArray[i] + } + order.PutUint32(tmp[pos:pos+4], uint32(x))*/ + m.BaseArray[i] = order.Uint32(tmp[pos : pos+4]) + pos += 4 + } + + m.Slice = make([]byte, 7) + copy(m.Slice[:7], tmp[pos:pos+7]) + //copy(tmp[pos:pos+7], m.Slice) + pos += 7 + + i := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.String = string(tmp[pos : pos+i]) + //copy(tmp[pos:pos+64], m.String) + pos += 64 + + //order.PutUint32(tmp[pos:pos+4], uint32(len(m.VlaStr)) /*m.SizeOf*/) + VlaStrLen := int(order.Uint32(tmp[pos : pos+4])) + pos += 4 + + m.VlaStr = string(tmp[pos : pos+VlaStrLen]) + //copy(m.VlaStr[pos:pos+VlaStrLen], tmp[pos:pos+64]) + pos += len(m.VlaStr) + + m.SizeOf = uint32(order.Uint32(tmp[pos : pos+4])) + pos += 4 + + /*order.PutUint32(tmp[pos:pos+4], uint32(len(m.VariableSlice))) + m.VariableSlice = IfStatusFlags(order.Uint32(tmp[pos : pos+4])) + pos += 4*/ + + m.VariableSlice = make([]SliceType, m.SizeOf) + for i := range m.VariableSlice { + //tmp[pos+i*1] = uint8(m.VariableSlice[i].Proto) + m.VariableSlice[i].Proto = IPProto(tmp[pos+i*1]) + //copy(tmp[102+i:103+i], []byte{byte(m.VariableSlice[i].Proto)}) + } + pos += len(m.VariableSlice) * 1 + + //tmp[pos] = uint8(m.TypeUnion.Af) + m.TypeUnion.Af = AddressFamily(tmp[pos]) + pos += 1 + + //copy(tmp[pos:pos+16], m.TypeUnion.Un.XXX_UnionData[:]) + copy(m.TypeUnion.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + + return nil + /*_, err := buf.Write(tmp) + if err != nil { + return nil, err + } + return buf.Bytes(), nil*/ +} + +func boolToUint(b bool) uint8 { + if b { + return 1 + } + return 0 +} + +// SwInterfaceDetails represents VPP binary API message 'sw_interface_details'. +type TestAllMsg struct { + Bool bool + Uint8 uint8 + Uint16 uint16 + Uint32 uint32 + Int8 int8 + Int16 int16 + Int32 int32 + AliasUint32 InterfaceIndex + AliasArray MacAddress + Enum IfStatusFlags + BaseArray []uint32 `struc:"[4]uint32"` + Slice []byte `struc:"[7]byte"` + String string `struc:"[64]byte"` + XXX_VlaStrLen uint32 `struc:"sizeof=VlaStr"` + VlaStr string + SizeOf uint32 `struc:"sizeof=VariableSlice"` + VariableSlice []SliceType + TypeUnion Address +} + +type InterfaceIndex uint32 +type MacAddress [6]uint8 +type IfStatusFlags uint32 + +const ( + IF_STATUS_API_FLAG_ADMIN_UP IfStatusFlags = 1 + IF_STATUS_API_FLAG_LINK_UP IfStatusFlags = 2 +) + +// Address represents VPP binary API type 'address'. +type Address struct { + Af AddressFamily + Un AddressUnion +} + +// AddressFamily represents VPP binary API enum 'address_family'. +type AddressFamily uint8 + +const ( + ADDRESS_IP4 AddressFamily = 0 + ADDRESS_IP6 AddressFamily = 1 +) + +// 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 +} + +// IP4Address represents VPP binary API alias 'ip4_address'. +type IP4Address [4]uint8 + +// IP6Address represents VPP binary API alias 'ip6_address'. +type IP6Address [16]uint8 + +type SliceType struct { + Proto IPProto +} + +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 +) + +func (m *TestAllMsg) Reset() { *m = TestAllMsg{} } +func (*TestAllMsg) GetMessageName() string { return "sw_interface_details" } +func (*TestAllMsg) GetCrcString() string { return "17b69fa2" } +func (*TestAllMsg) GetMessageType() api.MessageType { return api.ReplyMessage } diff --git a/codec/msg_codec_test.go b/codec/msg_codec_test.go index cd1240e..bf0695d 100644 --- a/codec/msg_codec_test.go +++ b/codec/msg_codec_test.go @@ -1,10 +1,16 @@ -package codec +package codec_test import ( "bytes" "testing" + "github.com/lunixbochs/struc" + "git.fd.io/govpp.git/api" + "git.fd.io/govpp.git/codec" + "git.fd.io/govpp.git/examples/binapi/ip" + "git.fd.io/govpp.git/examples/binapi/sr" + "git.fd.io/govpp.git/examples/binapi/vpe" ) type MyMsg struct { @@ -30,15 +36,69 @@ func TestEncode(t *testing.T) { msgID uint16 expData []byte }{ - {name: "basic", + /*{name: "basic", msg: &MyMsg{Index: 1, Label: []byte("Abcdef"), Port: 1000}, 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.Prefix{}, + NPaths: 0, + Paths: []ip.FibPath{ + { + SwIfIndex: 0, + TableID: 0, + RpfID: 0, + Weight: 0, + Preference: 0, + Type: 0, + Flags: 0, + Proto: 0, + Nh: ip.FibPathNh{}, + NLabels: 5, + LabelStack: [16]ip.FibMplsLabel{ + { + IsUniform: 1, + Label: 2, + TTL: 3, + Exp: 4, + }, + }, + }, + }, + }, + }, + msgID: 743, + expData: []byte{0x02, 0xE7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, }, + /*{name: "sr", + msg: &sr.SrPolicyAdd{ + BsidAddr: sr.IP6Address{}, + Weight: 0, + IsEncap: false, + IsSpray: false, + FibTable: 0, + Sids: sr.Srv6SidList{}, + }, + msgID: 99, + expData: []byte{0x00, 0x64, 0x00, 0x01, 0x41, 0x62, 0x63, 0x64, 0x65, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xE8}, + },*/ } for _, test := range tests { t.Run(test.name, func(t *testing.T) { - c := &MsgCodec{} + c := &codec.MsgCodec{} + //c := &codec.NewCodec{} data, err := c.EncodeMsg(test.msg, test.msgID) if err != nil { @@ -52,7 +112,7 @@ func TestEncode(t *testing.T) { } func TestEncodePanic(t *testing.T) { - c := &MsgCodec{} + c := &codec.MsgCodec{} msg := &MyMsg{Index: 1, Label: []byte("thisIsLongerThan16Bytes"), Port: 1000} @@ -61,3 +121,16 @@ func TestEncodePanic(t *testing.T) { t.Fatalf("expected non-nil error, got: %v", err) } } + +func TestEncodeSr(t *testing.T) { + msg := sr.Srv6SidList{ + NumSids: 0, + Weight: 0, + //Sids: nil, + } + buf := new(bytes.Buffer) + + if err := struc.Pack(buf, msg); err != nil { + t.Fatal(err) + } +} diff --git a/examples/binapi/acl/acl.ba.go b/examples/binapi/acl/acl.ba.go index 1f9528e..b42fb5f 100644 --- a/examples/binapi/acl/acl.ba.go +++ b/examples/binapi/acl/acl.ba.go @@ -1,648 +1,2794 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty +// VPP: 20.01-45~g7a071e370~b63 // source: /usr/share/vpp/api/plugins/acl.api.json /* -Package acl is a generated VPP binary API for 'acl' module. +Package acl contains generated code for VPP binary API defined by acl.api (version 1.0.1). It consists of: + 38 messages 2 types - 36 messages - 18 services */ package acl import ( - bytes "bytes" - context "context" + "bytes" + "context" + "encoding/binary" + "io" + "math" + "strconv" + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" struc "github.com/lunixbochs/struc" - io "io" - strconv "strconv" ) +// 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 // please upgrade the GoVPP api package + 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 + VersionCrc = 0x11c5c1e5 ) // ACLRule represents VPP binary API type 'acl_rule'. type ACLRule struct { - IsPermit uint8 - IsIPv6 uint8 - SrcIPAddr []byte `struc:"[16]byte"` - SrcIPPrefixLen uint8 - DstIPAddr []byte `struc:"[16]byte"` - DstIPPrefixLen uint8 - Proto uint8 - SrcportOrIcmptypeFirst uint16 - SrcportOrIcmptypeLast uint16 - DstportOrIcmpcodeFirst uint16 - DstportOrIcmpcodeLast uint16 - TCPFlagsMask uint8 - TCPFlagsValue uint8 -} - -func (*ACLRule) GetTypeName() string { - return "acl_rule" -} -func (*ACLRule) GetCrcString() string { - return "6f99bf4d" -} + IsPermit uint8 `binapi:"u8,name=is_permit" json:"is_permit,omitempty"` + IsIPv6 uint8 `binapi:"u8,name=is_ipv6" json:"is_ipv6,omitempty"` + SrcIPAddr []byte `binapi:"u8[16],name=src_ip_addr" json:"src_ip_addr,omitempty" struc:"[16]byte"` + SrcIPPrefixLen uint8 `binapi:"u8,name=src_ip_prefix_len" json:"src_ip_prefix_len,omitempty"` + DstIPAddr []byte `binapi:"u8[16],name=dst_ip_addr" json:"dst_ip_addr,omitempty" struc:"[16]byte"` + DstIPPrefixLen uint8 `binapi:"u8,name=dst_ip_prefix_len" json:"dst_ip_prefix_len,omitempty"` + Proto uint8 `binapi:"u8,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"` +} + +func (*ACLRule) GetTypeName() string { return "acl_rule" } // MacipACLRule represents VPP binary API type 'macip_acl_rule'. type MacipACLRule struct { - IsPermit uint8 - IsIPv6 uint8 - SrcMac []byte `struc:"[6]byte"` - SrcMacMask []byte `struc:"[6]byte"` - SrcIPAddr []byte `struc:"[16]byte"` - SrcIPPrefixLen uint8 + IsPermit uint8 `binapi:"u8,name=is_permit" json:"is_permit,omitempty"` + IsIPv6 uint8 `binapi:"u8,name=is_ipv6" json:"is_ipv6,omitempty"` + SrcMac []byte `binapi:"u8[6],name=src_mac" json:"src_mac,omitempty" struc:"[6]byte"` + SrcMacMask []byte `binapi:"u8[6],name=src_mac_mask" json:"src_mac_mask,omitempty" struc:"[6]byte"` + SrcIPAddr []byte `binapi:"u8[16],name=src_ip_addr" json:"src_ip_addr,omitempty" struc:"[16]byte"` + SrcIPPrefixLen uint8 `binapi:"u8,name=src_ip_prefix_len" json:"src_ip_prefix_len,omitempty"` } -func (*MacipACLRule) GetTypeName() string { - return "macip_acl_rule" -} -func (*MacipACLRule) GetCrcString() string { - return "70589f1e" -} +func (*MacipACLRule) GetTypeName() string { return "macip_acl_rule" } // ACLAddReplace represents VPP binary API message 'acl_add_replace'. type ACLAddReplace struct { - ACLIndex uint32 - Tag []byte `struc:"[64]byte"` - Count uint32 `struc:"sizeof=R"` - R []ACLRule + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + Tag []byte `binapi:"u8[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` + Count uint32 `binapi:"u32,name=count" json:"count,omitempty" struc:"sizeof=R"` + R []ACLRule `binapi:"acl_rule[count],name=r" json:"r,omitempty"` } -func (*ACLAddReplace) GetMessageName() string { - return "acl_add_replace" -} -func (*ACLAddReplace) GetCrcString() string { - return "e839997e" -} -func (*ACLAddReplace) GetMessageType() api.MessageType { - return api.RequestMessage +func (m *ACLAddReplace) Reset() { *m = ACLAddReplace{} } +func (*ACLAddReplace) GetMessageName() string { return "acl_add_replace" } +func (*ACLAddReplace) GetCrcString() string { return "13bc8539" } +func (*ACLAddReplace) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *ACLAddReplace) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.ACLIndex + size += 4 + // field[1] m.Tag + size += 64 + // field[1] m.Count + size += 4 + // field[1] m.R + for j1 := 0; j1 < len(m.R); j1++ { + var s1 ACLRule + _ = s1 + if j1 < len(m.R) { + s1 = m.R[j1] + } + // field[2] s1.IsPermit + size += 1 + // field[2] s1.IsIPv6 + size += 1 + // field[2] s1.SrcIPAddr + size += 16 + // field[2] s1.SrcIPPrefixLen + size += 1 + // field[2] s1.DstIPAddr + size += 16 + // field[2] s1.DstIPPrefixLen + size += 1 + // field[2] s1.Proto + size += 1 + // field[2] s1.SrcportOrIcmptypeFirst + size += 2 + // field[2] s1.SrcportOrIcmptypeLast + size += 2 + // field[2] s1.DstportOrIcmpcodeFirst + size += 2 + // field[2] s1.DstportOrIcmpcodeLast + size += 2 + // field[2] s1.TCPFlagsMask + size += 1 + // field[2] s1.TCPFlagsValue + size += 1 + } + return size +} +func (m *ACLAddReplace) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.ACLIndex + o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) + pos += 4 + // field[1] m.Tag + for i := 0; i < 64; i++ { + var x uint8 + if i < len(m.Tag) { + x = uint8(m.Tag[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.Count + o.PutUint32(buf[pos:pos+4], uint32(len(m.R))) + pos += 4 + // field[1] m.R + for j1 := 0; j1 < len(m.R); j1++ { + var v1 ACLRule + if j1 < len(m.R) { + v1 = m.R[j1] + } + // field[2] v1.IsPermit + buf[pos] = uint8(v1.IsPermit) + pos += 1 + // field[2] v1.IsIPv6 + buf[pos] = uint8(v1.IsIPv6) + pos += 1 + // field[2] v1.SrcIPAddr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(v1.SrcIPAddr) { + x = uint8(v1.SrcIPAddr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[2] v1.SrcIPPrefixLen + buf[pos] = uint8(v1.SrcIPPrefixLen) + pos += 1 + // field[2] v1.DstIPAddr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(v1.DstIPAddr) { + x = uint8(v1.DstIPAddr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[2] v1.DstIPPrefixLen + buf[pos] = uint8(v1.DstIPPrefixLen) + pos += 1 + // field[2] v1.Proto + buf[pos] = uint8(v1.Proto) + pos += 1 + // field[2] v1.SrcportOrIcmptypeFirst + o.PutUint16(buf[pos:pos+2], uint16(v1.SrcportOrIcmptypeFirst)) + pos += 2 + // field[2] v1.SrcportOrIcmptypeLast + o.PutUint16(buf[pos:pos+2], uint16(v1.SrcportOrIcmptypeLast)) + pos += 2 + // field[2] v1.DstportOrIcmpcodeFirst + o.PutUint16(buf[pos:pos+2], uint16(v1.DstportOrIcmpcodeFirst)) + pos += 2 + // field[2] v1.DstportOrIcmpcodeLast + o.PutUint16(buf[pos:pos+2], uint16(v1.DstportOrIcmpcodeLast)) + pos += 2 + // field[2] v1.TCPFlagsMask + buf[pos] = uint8(v1.TCPFlagsMask) + pos += 1 + // field[2] v1.TCPFlagsValue + buf[pos] = uint8(v1.TCPFlagsValue) + pos += 1 + } + return buf, nil +} +func (m *ACLAddReplace) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.ACLIndex + m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Tag + m.Tag = make([]uint8, 64) + for i := 0; i < len(m.Tag); i++ { + m.Tag[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.Count + m.Count = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.R + m.R = make([]ACLRule, int(m.Count)) + for j1 := 0; j1 < int(m.Count); j1++ { + // field[2] m.R[j1].IsPermit + m.R[j1].IsPermit = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].IsIPv6 + m.R[j1].IsIPv6 = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].SrcIPAddr + m.R[j1].SrcIPAddr = make([]uint8, 16) + for i := 0; i < len(m.R[j1].SrcIPAddr); i++ { + m.R[j1].SrcIPAddr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[2] m.R[j1].SrcIPPrefixLen + m.R[j1].SrcIPPrefixLen = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].DstIPAddr + m.R[j1].DstIPAddr = make([]uint8, 16) + for i := 0; i < len(m.R[j1].DstIPAddr); i++ { + m.R[j1].DstIPAddr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[2] m.R[j1].DstIPPrefixLen + m.R[j1].DstIPPrefixLen = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].Proto + m.R[j1].Proto = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].SrcportOrIcmptypeFirst + m.R[j1].SrcportOrIcmptypeFirst = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[2] m.R[j1].SrcportOrIcmptypeLast + m.R[j1].SrcportOrIcmptypeLast = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[2] m.R[j1].DstportOrIcmpcodeFirst + m.R[j1].DstportOrIcmpcodeFirst = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[2] m.R[j1].DstportOrIcmpcodeLast + m.R[j1].DstportOrIcmpcodeLast = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[2] m.R[j1].TCPFlagsMask + m.R[j1].TCPFlagsMask = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].TCPFlagsValue + m.R[j1].TCPFlagsValue = uint8(tmp[pos]) + pos += 1 + } + return nil } // ACLAddReplaceReply represents VPP binary API message 'acl_add_replace_reply'. type ACLAddReplaceReply struct { - ACLIndex uint32 - Retval int32 + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } -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) 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.ACLIndex + size += 4 + // field[1] m.Retval + size += 4 + return size +} +func (m *ACLAddReplaceReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.ACLIndex + o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) + pos += 4 + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *ACLAddReplaceReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.ACLIndex + m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // ACLDel represents VPP binary API message 'acl_del'. type ACLDel struct { - ACLIndex uint32 + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` } -func (*ACLDel) GetMessageName() string { - return "acl_del" -} -func (*ACLDel) GetCrcString() string { - return "ef34fea4" -} -func (*ACLDel) GetMessageType() api.MessageType { - return api.RequestMessage +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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.ACLIndex + size += 4 + return size +} +func (m *ACLDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.ACLIndex + o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) + pos += 4 + return buf, nil +} +func (m *ACLDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.ACLIndex + m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // ACLDelReply represents VPP binary API message 'acl_del_reply'. type ACLDelReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } -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) 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *ACLDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *ACLDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // 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 + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + Tag []byte `binapi:"u8[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` + Count uint32 `binapi:"u32,name=count" json:"count,omitempty" struc:"sizeof=R"` + R []ACLRule `binapi:"acl_rule[count],name=r" json:"r,omitempty"` } -func (*ACLDetails) GetMessageName() string { - return "acl_details" -} -func (*ACLDetails) GetCrcString() string { - return "5bd895be" -} -func (*ACLDetails) GetMessageType() api.MessageType { - return api.ReplyMessage +func (m *ACLDetails) Reset() { *m = ACLDetails{} } +func (*ACLDetails) GetMessageName() string { return "acl_details" } +func (*ACLDetails) GetCrcString() string { return "f89d7a88" } +func (*ACLDetails) GetMessageType() api.MessageType { return api.ReplyMessage } + +func (m *ACLDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.ACLIndex + size += 4 + // field[1] m.Tag + size += 64 + // field[1] m.Count + size += 4 + // field[1] m.R + for j1 := 0; j1 < len(m.R); j1++ { + var s1 ACLRule + _ = s1 + if j1 < len(m.R) { + s1 = m.R[j1] + } + // field[2] s1.IsPermit + size += 1 + // field[2] s1.IsIPv6 + size += 1 + // field[2] s1.SrcIPAddr + size += 16 + // field[2] s1.SrcIPPrefixLen + size += 1 + // field[2] s1.DstIPAddr + size += 16 + // field[2] s1.DstIPPrefixLen + size += 1 + // field[2] s1.Proto + size += 1 + // field[2] s1.SrcportOrIcmptypeFirst + size += 2 + // field[2] s1.SrcportOrIcmptypeLast + size += 2 + // field[2] s1.DstportOrIcmpcodeFirst + size += 2 + // field[2] s1.DstportOrIcmpcodeLast + size += 2 + // field[2] s1.TCPFlagsMask + size += 1 + // field[2] s1.TCPFlagsValue + size += 1 + } + return size +} +func (m *ACLDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.ACLIndex + o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) + pos += 4 + // field[1] m.Tag + for i := 0; i < 64; i++ { + var x uint8 + if i < len(m.Tag) { + x = uint8(m.Tag[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.Count + o.PutUint32(buf[pos:pos+4], uint32(len(m.R))) + pos += 4 + // field[1] m.R + for j1 := 0; j1 < len(m.R); j1++ { + var v1 ACLRule + if j1 < len(m.R) { + v1 = m.R[j1] + } + // field[2] v1.IsPermit + buf[pos] = uint8(v1.IsPermit) + pos += 1 + // field[2] v1.IsIPv6 + buf[pos] = uint8(v1.IsIPv6) + pos += 1 + // field[2] v1.SrcIPAddr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(v1.SrcIPAddr) { + x = uint8(v1.SrcIPAddr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[2] v1.SrcIPPrefixLen + buf[pos] = uint8(v1.SrcIPPrefixLen) + pos += 1 + // field[2] v1.DstIPAddr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(v1.DstIPAddr) { + x = uint8(v1.DstIPAddr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[2] v1.DstIPPrefixLen + buf[pos] = uint8(v1.DstIPPrefixLen) + pos += 1 + // field[2] v1.Proto + buf[pos] = uint8(v1.Proto) + pos += 1 + // field[2] v1.SrcportOrIcmptypeFirst + o.PutUint16(buf[pos:pos+2], uint16(v1.SrcportOrIcmptypeFirst)) + pos += 2 + // field[2] v1.SrcportOrIcmptypeLast + o.PutUint16(buf[pos:pos+2], uint16(v1.SrcportOrIcmptypeLast)) + pos += 2 + // field[2] v1.DstportOrIcmpcodeFirst + o.PutUint16(buf[pos:pos+2], uint16(v1.DstportOrIcmpcodeFirst)) + pos += 2 + // field[2] v1.DstportOrIcmpcodeLast + o.PutUint16(buf[pos:pos+2], uint16(v1.DstportOrIcmpcodeLast)) + pos += 2 + // field[2] v1.TCPFlagsMask + buf[pos] = uint8(v1.TCPFlagsMask) + pos += 1 + // field[2] v1.TCPFlagsValue + buf[pos] = uint8(v1.TCPFlagsValue) + pos += 1 + } + return buf, nil +} +func (m *ACLDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.ACLIndex + m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Tag + m.Tag = make([]uint8, 64) + for i := 0; i < len(m.Tag); i++ { + m.Tag[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.Count + m.Count = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.R + m.R = make([]ACLRule, int(m.Count)) + for j1 := 0; j1 < int(m.Count); j1++ { + // field[2] m.R[j1].IsPermit + m.R[j1].IsPermit = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].IsIPv6 + m.R[j1].IsIPv6 = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].SrcIPAddr + m.R[j1].SrcIPAddr = make([]uint8, 16) + for i := 0; i < len(m.R[j1].SrcIPAddr); i++ { + m.R[j1].SrcIPAddr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[2] m.R[j1].SrcIPPrefixLen + m.R[j1].SrcIPPrefixLen = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].DstIPAddr + m.R[j1].DstIPAddr = make([]uint8, 16) + for i := 0; i < len(m.R[j1].DstIPAddr); i++ { + m.R[j1].DstIPAddr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[2] m.R[j1].DstIPPrefixLen + m.R[j1].DstIPPrefixLen = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].Proto + m.R[j1].Proto = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].SrcportOrIcmptypeFirst + m.R[j1].SrcportOrIcmptypeFirst = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[2] m.R[j1].SrcportOrIcmptypeLast + m.R[j1].SrcportOrIcmptypeLast = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[2] m.R[j1].DstportOrIcmpcodeFirst + m.R[j1].DstportOrIcmpcodeFirst = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[2] m.R[j1].DstportOrIcmpcodeLast + m.R[j1].DstportOrIcmpcodeLast = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[2] m.R[j1].TCPFlagsMask + m.R[j1].TCPFlagsMask = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].TCPFlagsValue + m.R[j1].TCPFlagsValue = uint8(tmp[pos]) + pos += 1 + } + return nil } // ACLDump represents VPP binary API message 'acl_dump'. type ACLDump struct { - ACLIndex uint32 + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` } -func (*ACLDump) GetMessageName() string { - return "acl_dump" -} -func (*ACLDump) GetCrcString() string { - return "ef34fea4" -} -func (*ACLDump) GetMessageType() api.MessageType { - return api.RequestMessage +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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.ACLIndex + size += 4 + return size +} +func (m *ACLDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.ACLIndex + o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) + pos += 4 + return buf, nil +} +func (m *ACLDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.ACLIndex + m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // ACLInterfaceAddDel represents VPP binary API message 'acl_interface_add_del'. type ACLInterfaceAddDel struct { - IsAdd uint8 - IsInput uint8 - SwIfIndex uint32 - ACLIndex uint32 + IsAdd uint8 `binapi:"u8,name=is_add" json:"is_add,omitempty"` + IsInput uint8 `binapi:"u8,name=is_input" json:"is_input,omitempty"` + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` } -func (*ACLInterfaceAddDel) GetMessageName() string { - return "acl_interface_add_del" -} -func (*ACLInterfaceAddDel) GetCrcString() string { - return "0b2aedd1" -} -func (*ACLInterfaceAddDel) GetMessageType() api.MessageType { - return api.RequestMessage +func (m *ACLInterfaceAddDel) Reset() { *m = ACLInterfaceAddDel{} } +func (*ACLInterfaceAddDel) GetMessageName() string { return "acl_interface_add_del" } +func (*ACLInterfaceAddDel) GetCrcString() string { return "0b2aedd1" } +func (*ACLInterfaceAddDel) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *ACLInterfaceAddDel) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.IsAdd + size += 1 + // field[1] m.IsInput + size += 1 + // field[1] m.SwIfIndex + size += 4 + // field[1] m.ACLIndex + size += 4 + return size +} +func (m *ACLInterfaceAddDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.IsAdd + buf[pos] = uint8(m.IsAdd) + pos += 1 + // field[1] m.IsInput + buf[pos] = uint8(m.IsInput) + pos += 1 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.ACLIndex + o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) + pos += 4 + return buf, nil +} +func (m *ACLInterfaceAddDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.IsAdd + m.IsAdd = uint8(tmp[pos]) + pos += 1 + // field[1] m.IsInput + m.IsInput = uint8(tmp[pos]) + pos += 1 + // field[1] m.SwIfIndex + m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.ACLIndex + m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // ACLInterfaceAddDelReply represents VPP binary API message 'acl_interface_add_del_reply'. type ACLInterfaceAddDelReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } -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) 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *ACLInterfaceAddDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *ACLInterfaceAddDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // 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 + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + Count uint8 `binapi:"u8,name=count" json:"count,omitempty" struc:"sizeof=Whitelist"` + 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 "6a5d4e81" -} -func (*ACLInterfaceEtypeWhitelistDetails) GetMessageType() api.MessageType { - return api.ReplyMessage +func (*ACLInterfaceEtypeWhitelistDetails) GetCrcString() string { return "6a5d4e81" } +func (*ACLInterfaceEtypeWhitelistDetails) GetMessageType() api.MessageType { return api.ReplyMessage } + +func (m *ACLInterfaceEtypeWhitelistDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Count + size += 1 + // field[1] m.NInput + size += 1 + // field[1] m.Whitelist + size += 2 * len(m.Whitelist) + return size +} +func (m *ACLInterfaceEtypeWhitelistDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Count + buf[pos] = uint8(len(m.Whitelist)) + pos += 1 + // field[1] m.NInput + buf[pos] = uint8(m.NInput) + pos += 1 + // field[1] m.Whitelist + for i := 0; i < len(m.Whitelist); i++ { + var x uint16 + if i < len(m.Whitelist) { + x = uint16(m.Whitelist[i]) + } + o.PutUint16(buf[pos:pos+2], uint16(x)) + pos += 2 + } + return buf, nil +} +func (m *ACLInterfaceEtypeWhitelistDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Count + m.Count = uint8(tmp[pos]) + pos += 1 + // field[1] m.NInput + m.NInput = uint8(tmp[pos]) + pos += 1 + // field[1] m.Whitelist + m.Whitelist = make([]uint16, m.Count) + for i := 0; i < len(m.Whitelist); i++ { + m.Whitelist[i] = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + } + return nil } // ACLInterfaceEtypeWhitelistDump represents VPP binary API message 'acl_interface_etype_whitelist_dump'. type ACLInterfaceEtypeWhitelistDump struct { - SwIfIndex uint32 + SwIfIndex uint32 `binapi:"u32,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 "529cb13f" -} -func (*ACLInterfaceEtypeWhitelistDump) GetMessageType() api.MessageType { - return api.RequestMessage +func (*ACLInterfaceEtypeWhitelistDump) GetCrcString() string { return "529cb13f" } +func (*ACLInterfaceEtypeWhitelistDump) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *ACLInterfaceEtypeWhitelistDump) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *ACLInterfaceEtypeWhitelistDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *ACLInterfaceEtypeWhitelistDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // ACLInterfaceListDetails represents VPP binary API message 'acl_interface_list_details'. type ACLInterfaceListDetails struct { - SwIfIndex uint32 - Count uint8 `struc:"sizeof=Acls"` - NInput uint8 - Acls []uint32 + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + Count uint8 `binapi:"u8,name=count" json:"count,omitempty" struc:"sizeof=Acls"` + NInput uint8 `binapi:"u8,name=n_input" json:"n_input,omitempty"` + Acls []uint32 `binapi:"u32[count],name=acls" json:"acls,omitempty"` } -func (*ACLInterfaceListDetails) GetMessageName() string { - return "acl_interface_list_details" -} -func (*ACLInterfaceListDetails) GetCrcString() string { - return "d5e80809" -} -func (*ACLInterfaceListDetails) GetMessageType() api.MessageType { - return api.ReplyMessage +func (m *ACLInterfaceListDetails) Reset() { *m = ACLInterfaceListDetails{} } +func (*ACLInterfaceListDetails) GetMessageName() string { return "acl_interface_list_details" } +func (*ACLInterfaceListDetails) GetCrcString() string { return "d5e80809" } +func (*ACLInterfaceListDetails) GetMessageType() api.MessageType { return api.ReplyMessage } + +func (m *ACLInterfaceListDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Count + size += 1 + // field[1] m.NInput + size += 1 + // field[1] m.Acls + size += 4 * len(m.Acls) + return size +} +func (m *ACLInterfaceListDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Count + buf[pos] = uint8(len(m.Acls)) + pos += 1 + // field[1] m.NInput + buf[pos] = uint8(m.NInput) + pos += 1 + // field[1] m.Acls + for i := 0; i < len(m.Acls); i++ { + var x uint32 + if i < len(m.Acls) { + x = uint32(m.Acls[i]) + } + o.PutUint32(buf[pos:pos+4], uint32(x)) + pos += 4 + } + return buf, nil +} +func (m *ACLInterfaceListDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Count + m.Count = uint8(tmp[pos]) + pos += 1 + // field[1] m.NInput + m.NInput = uint8(tmp[pos]) + pos += 1 + // field[1] m.Acls + m.Acls = make([]uint32, m.Count) + for i := 0; i < len(m.Acls); i++ { + m.Acls[i] = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + } + return nil } // ACLInterfaceListDump represents VPP binary API message 'acl_interface_list_dump'. type ACLInterfaceListDump struct { - SwIfIndex uint32 + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` } -func (*ACLInterfaceListDump) GetMessageName() string { - return "acl_interface_list_dump" -} -func (*ACLInterfaceListDump) GetCrcString() string { - return "529cb13f" -} -func (*ACLInterfaceListDump) GetMessageType() api.MessageType { - return api.RequestMessage +func (m *ACLInterfaceListDump) Reset() { *m = ACLInterfaceListDump{} } +func (*ACLInterfaceListDump) GetMessageName() string { return "acl_interface_list_dump" } +func (*ACLInterfaceListDump) GetCrcString() string { return "529cb13f" } +func (*ACLInterfaceListDump) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *ACLInterfaceListDump) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *ACLInterfaceListDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *ACLInterfaceListDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // 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 + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + Count uint8 `binapi:"u8,name=count" json:"count,omitempty" struc:"sizeof=Acls"` + NInput uint8 `binapi:"u8,name=n_input" json:"n_input,omitempty"` + Acls []uint32 `binapi:"u32[count],name=acls" json:"acls,omitempty"` } -func (*ACLInterfaceSetACLList) GetMessageName() string { - return "acl_interface_set_acl_list" -} -func (*ACLInterfaceSetACLList) GetCrcString() string { - return "8baece38" -} -func (*ACLInterfaceSetACLList) GetMessageType() api.MessageType { - return api.RequestMessage +func (m *ACLInterfaceSetACLList) Reset() { *m = ACLInterfaceSetACLList{} } +func (*ACLInterfaceSetACLList) GetMessageName() string { return "acl_interface_set_acl_list" } +func (*ACLInterfaceSetACLList) GetCrcString() string { return "8baece38" } +func (*ACLInterfaceSetACLList) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *ACLInterfaceSetACLList) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Count + size += 1 + // field[1] m.NInput + size += 1 + // field[1] m.Acls + size += 4 * len(m.Acls) + return size +} +func (m *ACLInterfaceSetACLList) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Count + buf[pos] = uint8(len(m.Acls)) + pos += 1 + // field[1] m.NInput + buf[pos] = uint8(m.NInput) + pos += 1 + // field[1] m.Acls + for i := 0; i < len(m.Acls); i++ { + var x uint32 + if i < len(m.Acls) { + x = uint32(m.Acls[i]) + } + o.PutUint32(buf[pos:pos+4], uint32(x)) + pos += 4 + } + return buf, nil +} +func (m *ACLInterfaceSetACLList) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Count + m.Count = uint8(tmp[pos]) + pos += 1 + // field[1] m.NInput + m.NInput = uint8(tmp[pos]) + pos += 1 + // field[1] m.Acls + m.Acls = make([]uint32, m.Count) + for i := 0; i < len(m.Acls); i++ { + m.Acls[i] = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + } + return nil } // ACLInterfaceSetACLListReply represents VPP binary API message 'acl_interface_set_acl_list_reply'. type ACLInterfaceSetACLListReply struct { - Retval int32 + 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 (*ACLInterfaceSetACLListReply) GetCrcString() string { return "e8d4e804" } +func (*ACLInterfaceSetACLListReply) GetMessageType() api.MessageType { return api.ReplyMessage } + +func (m *ACLInterfaceSetACLListReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *ACLInterfaceSetACLListReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *ACLInterfaceSetACLListReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // 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 + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + Count uint8 `binapi:"u8,name=count" json:"count,omitempty" struc:"sizeof=Whitelist"` + 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 "f515efc5" -} -func (*ACLInterfaceSetEtypeWhitelist) GetMessageType() api.MessageType { - return api.RequestMessage +func (*ACLInterfaceSetEtypeWhitelist) GetCrcString() string { return "f515efc5" } +func (*ACLInterfaceSetEtypeWhitelist) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *ACLInterfaceSetEtypeWhitelist) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Count + size += 1 + // field[1] m.NInput + size += 1 + // field[1] m.Whitelist + size += 2 * len(m.Whitelist) + return size +} +func (m *ACLInterfaceSetEtypeWhitelist) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Count + buf[pos] = uint8(len(m.Whitelist)) + pos += 1 + // field[1] m.NInput + buf[pos] = uint8(m.NInput) + pos += 1 + // field[1] m.Whitelist + for i := 0; i < len(m.Whitelist); i++ { + var x uint16 + if i < len(m.Whitelist) { + x = uint16(m.Whitelist[i]) + } + o.PutUint16(buf[pos:pos+2], uint16(x)) + pos += 2 + } + return buf, nil +} +func (m *ACLInterfaceSetEtypeWhitelist) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Count + m.Count = uint8(tmp[pos]) + pos += 1 + // field[1] m.NInput + m.NInput = uint8(tmp[pos]) + pos += 1 + // field[1] m.Whitelist + m.Whitelist = make([]uint16, m.Count) + for i := 0; i < len(m.Whitelist); i++ { + m.Whitelist[i] = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + } + return nil } // ACLInterfaceSetEtypeWhitelistReply represents VPP binary API message 'acl_interface_set_etype_whitelist_reply'. type ACLInterfaceSetEtypeWhitelistReply struct { - Retval int32 + 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 (*ACLInterfaceSetEtypeWhitelistReply) GetCrcString() string { return "e8d4e804" } +func (*ACLInterfaceSetEtypeWhitelistReply) GetMessageType() api.MessageType { return api.ReplyMessage } + +func (m *ACLInterfaceSetEtypeWhitelistReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *ACLInterfaceSetEtypeWhitelistReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *ACLInterfaceSetEtypeWhitelistReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // 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 (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() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *ACLPluginControlPing) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil } -func (*ACLPluginControlPing) GetMessageType() api.MessageType { - return api.RequestMessage +func (m *ACLPluginControlPing) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil } // ACLPluginControlPingReply represents VPP binary API message 'acl_plugin_control_ping_reply'. type ACLPluginControlPingReply struct { - Retval int32 - ClientIndex uint32 - VpePID uint32 + 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 (*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) 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.ClientIndex + size += 4 + // field[1] m.VpePID + size += 4 + return size +} +func (m *ACLPluginControlPingReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.ClientIndex + o.PutUint32(buf[pos:pos+4], uint32(m.ClientIndex)) + pos += 4 + // field[1] m.VpePID + o.PutUint32(buf[pos:pos+4], uint32(m.VpePID)) + pos += 4 + return buf, nil +} +func (m *ACLPluginControlPingReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.ClientIndex + m.ClientIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.VpePID + m.VpePID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // ACLPluginGetConnTableMaxEntries represents VPP binary API message 'acl_plugin_get_conn_table_max_entries'. type ACLPluginGetConnTableMaxEntries struct{} +func (m *ACLPluginGetConnTableMaxEntries) Reset() { *m = ACLPluginGetConnTableMaxEntries{} } func (*ACLPluginGetConnTableMaxEntries) GetMessageName() string { return "acl_plugin_get_conn_table_max_entries" } -func (*ACLPluginGetConnTableMaxEntries) GetCrcString() string { - return "51077d14" +func (*ACLPluginGetConnTableMaxEntries) GetCrcString() string { return "51077d14" } +func (*ACLPluginGetConnTableMaxEntries) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *ACLPluginGetConnTableMaxEntries) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *ACLPluginGetConnTableMaxEntries) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil } -func (*ACLPluginGetConnTableMaxEntries) GetMessageType() api.MessageType { - return api.RequestMessage +func (m *ACLPluginGetConnTableMaxEntries) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil } // ACLPluginGetConnTableMaxEntriesReply represents VPP binary API message 'acl_plugin_get_conn_table_max_entries_reply'. type ACLPluginGetConnTableMaxEntriesReply struct { - ConnTableMaxEntries uint64 + 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) GetCrcString() string { return "7a096d3d" } func (*ACLPluginGetConnTableMaxEntriesReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *ACLPluginGetConnTableMaxEntriesReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.ConnTableMaxEntries + size += 8 + return size +} +func (m *ACLPluginGetConnTableMaxEntriesReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.ConnTableMaxEntries + o.PutUint64(buf[pos:pos+8], uint64(m.ConnTableMaxEntries)) + pos += 8 + return buf, nil +} +func (m *ACLPluginGetConnTableMaxEntriesReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.ConnTableMaxEntries + m.ConnTableMaxEntries = uint64(o.Uint64(tmp[pos : pos+8])) + pos += 8 + return nil +} + // 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 (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() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *ACLPluginGetVersion) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil } -func (*ACLPluginGetVersion) GetMessageType() api.MessageType { - return api.RequestMessage +func (m *ACLPluginGetVersion) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil } // ACLPluginGetVersionReply represents VPP binary API message 'acl_plugin_get_version_reply'. type ACLPluginGetVersionReply struct { - Major uint32 - Minor uint32 + Major uint32 `binapi:"u32,name=major" json:"major,omitempty"` + Minor uint32 `binapi:"u32,name=minor" json:"minor,omitempty"` } -func (*ACLPluginGetVersionReply) GetMessageName() string { - return "acl_plugin_get_version_reply" +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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Major + size += 4 + // field[1] m.Minor + size += 4 + return size +} +func (m *ACLPluginGetVersionReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Major + o.PutUint32(buf[pos:pos+4], uint32(m.Major)) + pos += 4 + // field[1] m.Minor + o.PutUint32(buf[pos:pos+4], uint32(m.Minor)) + pos += 4 + return buf, nil +} +func (m *ACLPluginGetVersionReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Major + m.Major = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Minor + m.Minor = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + +// ACLStatsIntfCountersEnable represents VPP binary API 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Enable + size += 1 + return size +} +func (m *ACLStatsIntfCountersEnable) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Enable + if m.Enable { + buf[pos] = 1 + } + pos += 1 + return buf, nil } -func (*ACLPluginGetVersionReply) GetCrcString() string { - return "9b32cf86" +func (m *ACLStatsIntfCountersEnable) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Enable + m.Enable = tmp[pos] != 0 + pos += 1 + return nil } -func (*ACLPluginGetVersionReply) GetMessageType() api.MessageType { - return api.ReplyMessage + +// ACLStatsIntfCountersEnableReply represents VPP binary API message 'acl_stats_intf_counters_enable_reply'. +type ACLStatsIntfCountersEnableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } -// MacipACLAdd represents VPP binary API message 'macip_acl_add'. -type MacipACLAdd struct { - Tag []byte `struc:"[64]byte"` - Count uint32 `struc:"sizeof=R"` - R []MacipACLRule +func (m *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 (*MacipACLAdd) GetMessageName() string { - return "macip_acl_add" +func (m *ACLStatsIntfCountersEnableReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *ACLStatsIntfCountersEnableReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *ACLStatsIntfCountersEnableReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } -func (*MacipACLAdd) GetCrcString() string { - return "b3d3d65a" + +// MacipACLAdd represents VPP binary API message 'macip_acl_add'. +type MacipACLAdd struct { + Tag []byte `binapi:"u8[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` + Count uint32 `binapi:"u32,name=count" json:"count,omitempty" struc:"sizeof=R"` + R []MacipACLRule `binapi:"macip_acl_rule[count],name=r" json:"r,omitempty"` } -func (*MacipACLAdd) GetMessageType() api.MessageType { - return api.RequestMessage + +func (m *MacipACLAdd) Reset() { *m = MacipACLAdd{} } +func (*MacipACLAdd) GetMessageName() string { return "macip_acl_add" } +func (*MacipACLAdd) GetCrcString() string { return "0c680ca5" } +func (*MacipACLAdd) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *MacipACLAdd) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Tag + size += 64 + // field[1] m.Count + size += 4 + // field[1] m.R + for j1 := 0; j1 < len(m.R); j1++ { + var s1 MacipACLRule + _ = s1 + if j1 < len(m.R) { + s1 = m.R[j1] + } + // field[2] s1.IsPermit + size += 1 + // field[2] s1.IsIPv6 + size += 1 + // field[2] s1.SrcMac + size += 6 + // field[2] s1.SrcMacMask + size += 6 + // field[2] s1.SrcIPAddr + size += 16 + // field[2] s1.SrcIPPrefixLen + size += 1 + } + return size +} +func (m *MacipACLAdd) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Tag + for i := 0; i < 64; i++ { + var x uint8 + if i < len(m.Tag) { + x = uint8(m.Tag[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.Count + o.PutUint32(buf[pos:pos+4], uint32(len(m.R))) + pos += 4 + // field[1] m.R + for j1 := 0; j1 < len(m.R); j1++ { + var v1 MacipACLRule + if j1 < len(m.R) { + v1 = m.R[j1] + } + // field[2] v1.IsPermit + buf[pos] = uint8(v1.IsPermit) + pos += 1 + // field[2] v1.IsIPv6 + buf[pos] = uint8(v1.IsIPv6) + pos += 1 + // field[2] v1.SrcMac + for i := 0; i < 6; i++ { + var x uint8 + if i < len(v1.SrcMac) { + x = uint8(v1.SrcMac[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[2] v1.SrcMacMask + for i := 0; i < 6; i++ { + var x uint8 + if i < len(v1.SrcMacMask) { + x = uint8(v1.SrcMacMask[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[2] v1.SrcIPAddr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(v1.SrcIPAddr) { + x = uint8(v1.SrcIPAddr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[2] v1.SrcIPPrefixLen + buf[pos] = uint8(v1.SrcIPPrefixLen) + pos += 1 + } + return buf, nil +} +func (m *MacipACLAdd) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Tag + m.Tag = make([]uint8, 64) + for i := 0; i < len(m.Tag); i++ { + m.Tag[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.Count + m.Count = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.R + m.R = make([]MacipACLRule, int(m.Count)) + for j1 := 0; j1 < int(m.Count); j1++ { + // field[2] m.R[j1].IsPermit + m.R[j1].IsPermit = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].IsIPv6 + m.R[j1].IsIPv6 = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].SrcMac + m.R[j1].SrcMac = make([]uint8, 6) + for i := 0; i < len(m.R[j1].SrcMac); i++ { + m.R[j1].SrcMac[i] = uint8(tmp[pos]) + pos += 1 + } + // field[2] m.R[j1].SrcMacMask + m.R[j1].SrcMacMask = make([]uint8, 6) + for i := 0; i < len(m.R[j1].SrcMacMask); i++ { + m.R[j1].SrcMacMask[i] = uint8(tmp[pos]) + pos += 1 + } + // field[2] m.R[j1].SrcIPAddr + m.R[j1].SrcIPAddr = make([]uint8, 16) + for i := 0; i < len(m.R[j1].SrcIPAddr); i++ { + m.R[j1].SrcIPAddr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[2] m.R[j1].SrcIPPrefixLen + m.R[j1].SrcIPPrefixLen = uint8(tmp[pos]) + pos += 1 + } + return nil } // 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 + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + Tag []byte `binapi:"u8[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` + Count uint32 `binapi:"u32,name=count" json:"count,omitempty" struc:"sizeof=R"` + R []MacipACLRule `binapi:"macip_acl_rule[count],name=r" json:"r,omitempty"` } -func (*MacipACLAddReplace) GetMessageName() string { - return "macip_acl_add_replace" -} -func (*MacipACLAddReplace) GetCrcString() string { - return "a0e8c01b" -} -func (*MacipACLAddReplace) GetMessageType() api.MessageType { - return api.RequestMessage +func (m *MacipACLAddReplace) Reset() { *m = MacipACLAddReplace{} } +func (*MacipACLAddReplace) GetMessageName() string { return "macip_acl_add_replace" } +func (*MacipACLAddReplace) GetCrcString() string { return "d3d313e7" } +func (*MacipACLAddReplace) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *MacipACLAddReplace) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.ACLIndex + size += 4 + // field[1] m.Tag + size += 64 + // field[1] m.Count + size += 4 + // field[1] m.R + for j1 := 0; j1 < len(m.R); j1++ { + var s1 MacipACLRule + _ = s1 + if j1 < len(m.R) { + s1 = m.R[j1] + } + // field[2] s1.IsPermit + size += 1 + // field[2] s1.IsIPv6 + size += 1 + // field[2] s1.SrcMac + size += 6 + // field[2] s1.SrcMacMask + size += 6 + // field[2] s1.SrcIPAddr + size += 16 + // field[2] s1.SrcIPPrefixLen + size += 1 + } + return size +} +func (m *MacipACLAddReplace) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.ACLIndex + o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) + pos += 4 + // field[1] m.Tag + for i := 0; i < 64; i++ { + var x uint8 + if i < len(m.Tag) { + x = uint8(m.Tag[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.Count + o.PutUint32(buf[pos:pos+4], uint32(len(m.R))) + pos += 4 + // field[1] m.R + for j1 := 0; j1 < len(m.R); j1++ { + var v1 MacipACLRule + if j1 < len(m.R) { + v1 = m.R[j1] + } + // field[2] v1.IsPermit + buf[pos] = uint8(v1.IsPermit) + pos += 1 + // field[2] v1.IsIPv6 + buf[pos] = uint8(v1.IsIPv6) + pos += 1 + // field[2] v1.SrcMac + for i := 0; i < 6; i++ { + var x uint8 + if i < len(v1.SrcMac) { + x = uint8(v1.SrcMac[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[2] v1.SrcMacMask + for i := 0; i < 6; i++ { + var x uint8 + if i < len(v1.SrcMacMask) { + x = uint8(v1.SrcMacMask[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[2] v1.SrcIPAddr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(v1.SrcIPAddr) { + x = uint8(v1.SrcIPAddr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[2] v1.SrcIPPrefixLen + buf[pos] = uint8(v1.SrcIPPrefixLen) + pos += 1 + } + return buf, nil +} +func (m *MacipACLAddReplace) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.ACLIndex + m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Tag + m.Tag = make([]uint8, 64) + for i := 0; i < len(m.Tag); i++ { + m.Tag[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.Count + m.Count = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.R + m.R = make([]MacipACLRule, int(m.Count)) + for j1 := 0; j1 < int(m.Count); j1++ { + // field[2] m.R[j1].IsPermit + m.R[j1].IsPermit = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].IsIPv6 + m.R[j1].IsIPv6 = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].SrcMac + m.R[j1].SrcMac = make([]uint8, 6) + for i := 0; i < len(m.R[j1].SrcMac); i++ { + m.R[j1].SrcMac[i] = uint8(tmp[pos]) + pos += 1 + } + // field[2] m.R[j1].SrcMacMask + m.R[j1].SrcMacMask = make([]uint8, 6) + for i := 0; i < len(m.R[j1].SrcMacMask); i++ { + m.R[j1].SrcMacMask[i] = uint8(tmp[pos]) + pos += 1 + } + // field[2] m.R[j1].SrcIPAddr + m.R[j1].SrcIPAddr = make([]uint8, 16) + for i := 0; i < len(m.R[j1].SrcIPAddr); i++ { + m.R[j1].SrcIPAddr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[2] m.R[j1].SrcIPPrefixLen + m.R[j1].SrcIPPrefixLen = uint8(tmp[pos]) + pos += 1 + } + return nil } // MacipACLAddReplaceReply represents VPP binary API message 'macip_acl_add_replace_reply'. type MacipACLAddReplaceReply struct { - ACLIndex uint32 - Retval int32 + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } -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) 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.ACLIndex + size += 4 + // field[1] m.Retval + size += 4 + return size +} +func (m *MacipACLAddReplaceReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.ACLIndex + o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) + pos += 4 + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *MacipACLAddReplaceReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.ACLIndex + m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // MacipACLAddReply represents VPP binary API message 'macip_acl_add_reply'. type MacipACLAddReply struct { - ACLIndex uint32 - Retval int32 + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } -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) 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.ACLIndex + size += 4 + // field[1] m.Retval + size += 4 + return size +} +func (m *MacipACLAddReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.ACLIndex + o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) + pos += 4 + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *MacipACLAddReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.ACLIndex + m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // MacipACLDel represents VPP binary API message 'macip_acl_del'. type MacipACLDel struct { - ACLIndex uint32 + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` } -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) 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.ACLIndex + size += 4 + return size +} +func (m *MacipACLDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.ACLIndex + o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) + pos += 4 + return buf, nil +} +func (m *MacipACLDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.ACLIndex + m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // MacipACLDelReply represents VPP binary API message 'macip_acl_del_reply'. type MacipACLDelReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } -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) 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *MacipACLDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *MacipACLDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // 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 + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + Tag []byte `binapi:"u8[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` + Count uint32 `binapi:"u32,name=count" json:"count,omitempty" struc:"sizeof=R"` + R []MacipACLRule `binapi:"macip_acl_rule[count],name=r" json:"r,omitempty"` } -func (*MacipACLDetails) GetMessageName() string { - return "macip_acl_details" -} -func (*MacipACLDetails) GetCrcString() string { - return "dd2b55ba" -} -func (*MacipACLDetails) GetMessageType() api.MessageType { - return api.ReplyMessage +func (m *MacipACLDetails) Reset() { *m = MacipACLDetails{} } +func (*MacipACLDetails) GetMessageName() string { return "macip_acl_details" } +func (*MacipACLDetails) GetCrcString() string { return "e164e69a" } +func (*MacipACLDetails) GetMessageType() api.MessageType { return api.ReplyMessage } + +func (m *MacipACLDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.ACLIndex + size += 4 + // field[1] m.Tag + size += 64 + // field[1] m.Count + size += 4 + // field[1] m.R + for j1 := 0; j1 < len(m.R); j1++ { + var s1 MacipACLRule + _ = s1 + if j1 < len(m.R) { + s1 = m.R[j1] + } + // field[2] s1.IsPermit + size += 1 + // field[2] s1.IsIPv6 + size += 1 + // field[2] s1.SrcMac + size += 6 + // field[2] s1.SrcMacMask + size += 6 + // field[2] s1.SrcIPAddr + size += 16 + // field[2] s1.SrcIPPrefixLen + size += 1 + } + return size +} +func (m *MacipACLDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.ACLIndex + o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) + pos += 4 + // field[1] m.Tag + for i := 0; i < 64; i++ { + var x uint8 + if i < len(m.Tag) { + x = uint8(m.Tag[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.Count + o.PutUint32(buf[pos:pos+4], uint32(len(m.R))) + pos += 4 + // field[1] m.R + for j1 := 0; j1 < len(m.R); j1++ { + var v1 MacipACLRule + if j1 < len(m.R) { + v1 = m.R[j1] + } + // field[2] v1.IsPermit + buf[pos] = uint8(v1.IsPermit) + pos += 1 + // field[2] v1.IsIPv6 + buf[pos] = uint8(v1.IsIPv6) + pos += 1 + // field[2] v1.SrcMac + for i := 0; i < 6; i++ { + var x uint8 + if i < len(v1.SrcMac) { + x = uint8(v1.SrcMac[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[2] v1.SrcMacMask + for i := 0; i < 6; i++ { + var x uint8 + if i < len(v1.SrcMacMask) { + x = uint8(v1.SrcMacMask[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[2] v1.SrcIPAddr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(v1.SrcIPAddr) { + x = uint8(v1.SrcIPAddr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[2] v1.SrcIPPrefixLen + buf[pos] = uint8(v1.SrcIPPrefixLen) + pos += 1 + } + return buf, nil +} +func (m *MacipACLDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.ACLIndex + m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Tag + m.Tag = make([]uint8, 64) + for i := 0; i < len(m.Tag); i++ { + m.Tag[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.Count + m.Count = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.R + m.R = make([]MacipACLRule, int(m.Count)) + for j1 := 0; j1 < int(m.Count); j1++ { + // field[2] m.R[j1].IsPermit + m.R[j1].IsPermit = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].IsIPv6 + m.R[j1].IsIPv6 = uint8(tmp[pos]) + pos += 1 + // field[2] m.R[j1].SrcMac + m.R[j1].SrcMac = make([]uint8, 6) + for i := 0; i < len(m.R[j1].SrcMac); i++ { + m.R[j1].SrcMac[i] = uint8(tmp[pos]) + pos += 1 + } + // field[2] m.R[j1].SrcMacMask + m.R[j1].SrcMacMask = make([]uint8, 6) + for i := 0; i < len(m.R[j1].SrcMacMask); i++ { + m.R[j1].SrcMacMask[i] = uint8(tmp[pos]) + pos += 1 + } + // field[2] m.R[j1].SrcIPAddr + m.R[j1].SrcIPAddr = make([]uint8, 16) + for i := 0; i < len(m.R[j1].SrcIPAddr); i++ { + m.R[j1].SrcIPAddr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[2] m.R[j1].SrcIPPrefixLen + m.R[j1].SrcIPPrefixLen = uint8(tmp[pos]) + pos += 1 + } + return nil } // MacipACLDump represents VPP binary API message 'macip_acl_dump'. type MacipACLDump struct { - ACLIndex uint32 + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` } -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) 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.ACLIndex + size += 4 + return size +} +func (m *MacipACLDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.ACLIndex + o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) + pos += 4 + return buf, nil +} +func (m *MacipACLDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.ACLIndex + m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // MacipACLInterfaceAddDel represents VPP binary API message 'macip_acl_interface_add_del'. type MacipACLInterfaceAddDel struct { - IsAdd uint8 - SwIfIndex uint32 - ACLIndex uint32 + IsAdd uint8 `binapi:"u8,name=is_add" json:"is_add,omitempty"` + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` } -func (*MacipACLInterfaceAddDel) GetMessageName() string { - return "macip_acl_interface_add_del" -} -func (*MacipACLInterfaceAddDel) GetCrcString() string { - return "6a6be97c" -} -func (*MacipACLInterfaceAddDel) GetMessageType() api.MessageType { - return api.RequestMessage +func (m *MacipACLInterfaceAddDel) Reset() { *m = MacipACLInterfaceAddDel{} } +func (*MacipACLInterfaceAddDel) GetMessageName() string { return "macip_acl_interface_add_del" } +func (*MacipACLInterfaceAddDel) GetCrcString() string { return "6a6be97c" } +func (*MacipACLInterfaceAddDel) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *MacipACLInterfaceAddDel) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.IsAdd + size += 1 + // field[1] m.SwIfIndex + size += 4 + // field[1] m.ACLIndex + size += 4 + return size +} +func (m *MacipACLInterfaceAddDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.IsAdd + buf[pos] = uint8(m.IsAdd) + pos += 1 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.ACLIndex + o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) + pos += 4 + return buf, nil +} +func (m *MacipACLInterfaceAddDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.IsAdd + m.IsAdd = uint8(tmp[pos]) + pos += 1 + // field[1] m.SwIfIndex + m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.ACLIndex + m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // MacipACLInterfaceAddDelReply represents VPP binary API message 'macip_acl_interface_add_del_reply'. type MacipACLInterfaceAddDelReply struct { - Retval int32 + 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 (*MacipACLInterfaceAddDelReply) GetCrcString() string { return "e8d4e804" } +func (*MacipACLInterfaceAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } + +func (m *MacipACLInterfaceAddDelReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *MacipACLInterfaceAddDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *MacipACLInterfaceAddDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil } // 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 (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() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *MacipACLInterfaceGet) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil } -func (*MacipACLInterfaceGet) GetMessageType() api.MessageType { - return api.RequestMessage +func (m *MacipACLInterfaceGet) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil } // MacipACLInterfaceGetReply represents VPP binary API message 'macip_acl_interface_get_reply'. type MacipACLInterfaceGetReply struct { - Count uint32 `struc:"sizeof=Acls"` - Acls []uint32 + Count uint32 `binapi:"u32,name=count" json:"count,omitempty" struc:"sizeof=Acls"` + Acls []uint32 `binapi:"u32[count],name=acls" json:"acls,omitempty"` } -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) 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Count + size += 4 + // field[1] m.Acls + size += 4 * len(m.Acls) + return size +} +func (m *MacipACLInterfaceGetReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Count + o.PutUint32(buf[pos:pos+4], uint32(len(m.Acls))) + pos += 4 + // field[1] m.Acls + for i := 0; i < len(m.Acls); i++ { + var x uint32 + if i < len(m.Acls) { + x = uint32(m.Acls[i]) + } + o.PutUint32(buf[pos:pos+4], uint32(x)) + pos += 4 + } + return buf, nil +} +func (m *MacipACLInterfaceGetReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Count + m.Count = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Acls + m.Acls = make([]uint32, m.Count) + for i := 0; i < len(m.Acls); i++ { + m.Acls[i] = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + } + return nil } // MacipACLInterfaceListDetails represents VPP binary API message 'macip_acl_interface_list_details'. type MacipACLInterfaceListDetails struct { - SwIfIndex uint32 - Count uint8 `struc:"sizeof=Acls"` - Acls []uint32 + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + Count uint8 `binapi:"u8,name=count" json:"count,omitempty" struc:"sizeof=Acls"` + 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 "29783fa0" -} -func (*MacipACLInterfaceListDetails) GetMessageType() api.MessageType { - return api.ReplyMessage +func (*MacipACLInterfaceListDetails) GetCrcString() string { return "29783fa0" } +func (*MacipACLInterfaceListDetails) GetMessageType() api.MessageType { return api.ReplyMessage } + +func (m *MacipACLInterfaceListDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Count + size += 1 + // field[1] m.Acls + size += 4 * len(m.Acls) + return size +} +func (m *MacipACLInterfaceListDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Count + buf[pos] = uint8(len(m.Acls)) + pos += 1 + // field[1] m.Acls + for i := 0; i < len(m.Acls); i++ { + var x uint32 + if i < len(m.Acls) { + x = uint32(m.Acls[i]) + } + o.PutUint32(buf[pos:pos+4], uint32(x)) + pos += 4 + } + return buf, nil +} +func (m *MacipACLInterfaceListDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Count + m.Count = uint8(tmp[pos]) + pos += 1 + // field[1] m.Acls + m.Acls = make([]uint32, m.Count) + for i := 0; i < len(m.Acls); i++ { + m.Acls[i] = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + } + return nil } // MacipACLInterfaceListDump represents VPP binary API message 'macip_acl_interface_list_dump'. type MacipACLInterfaceListDump struct { - SwIfIndex uint32 + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` } -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 (m *MacipACLInterfaceListDump) Reset() { *m = MacipACLInterfaceListDump{} } +func (*MacipACLInterfaceListDump) GetMessageName() string { return "macip_acl_interface_list_dump" } +func (*MacipACLInterfaceListDump) GetCrcString() string { return "529cb13f" } +func (*MacipACLInterfaceListDump) GetMessageType() api.MessageType { return api.RequestMessage } -func init() { +func (m *MacipACLInterfaceListDump) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *MacipACLInterfaceListDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *MacipACLInterfaceListDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + +func init() { file_acl_binapi_init() } +func file_acl_binapi_init() { api.RegisterMessage((*ACLAddReplace)(nil), "acl.ACLAddReplace") api.RegisterMessage((*ACLAddReplaceReply)(nil), "acl.ACLAddReplaceReply") api.RegisterMessage((*ACLDel)(nil), "acl.ACLDel") @@ -665,6 +2811,8 @@ func init() { api.RegisterMessage((*ACLPluginGetConnTableMaxEntriesReply)(nil), "acl.ACLPluginGetConnTableMaxEntriesReply") api.RegisterMessage((*ACLPluginGetVersion)(nil), "acl.ACLPluginGetVersion") api.RegisterMessage((*ACLPluginGetVersionReply)(nil), "acl.ACLPluginGetVersionReply") + api.RegisterMessage((*ACLStatsIntfCountersEnable)(nil), "acl.ACLStatsIntfCountersEnable") + api.RegisterMessage((*ACLStatsIntfCountersEnableReply)(nil), "acl.ACLStatsIntfCountersEnableReply") api.RegisterMessage((*MacipACLAdd)(nil), "acl.MacipACLAdd") api.RegisterMessage((*MacipACLAddReplace)(nil), "acl.MacipACLAddReplace") api.RegisterMessage((*MacipACLAddReplaceReply)(nil), "acl.MacipACLAddReplaceReply") @@ -706,6 +2854,8 @@ func AllMessages() []api.Message { (*ACLPluginGetConnTableMaxEntriesReply)(nil), (*ACLPluginGetVersion)(nil), (*ACLPluginGetVersionReply)(nil), + (*ACLStatsIntfCountersEnable)(nil), + (*ACLStatsIntfCountersEnableReply)(nil), (*MacipACLAdd)(nil), (*MacipACLAddReplace)(nil), (*MacipACLAddReplaceReply)(nil), @@ -723,293 +2873,13 @@ func AllMessages() []api.Message { } } -// 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 _ = codec.DecodeString var _ = bytes.NewBuffer var _ = context.Background var _ = io.Copy var _ = strconv.Itoa var _ = struc.Pack +var _ = binary.BigEndian +var _ = math.Float32bits diff --git a/examples/binapi/acl/acl_rpc.ba.go b/examples/binapi/acl/acl_rpc.ba.go new file mode 100644 index 0000000..62b10c3 --- /dev/null +++ b/examples/binapi/acl/acl_rpc.ba.go @@ -0,0 +1,302 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package acl + +import ( + "context" + "io" + + api "git.fd.io/govpp.git/api" +) + +// RPCService represents RPC service API for acl module. +type RPCService interface { + DumpACL(ctx context.Context, in *ACLDump) (RPCService_DumpACLClient, error) + DumpACLInterfaceEtypeWhitelist(ctx context.Context, in *ACLInterfaceEtypeWhitelistDump) (RPCService_DumpACLInterfaceEtypeWhitelistClient, error) + DumpACLInterfaceList(ctx context.Context, in *ACLInterfaceListDump) (RPCService_DumpACLInterfaceListClient, error) + DumpMacipACL(ctx context.Context, in *MacipACLDump) (RPCService_DumpMacipACLClient, error) + DumpMacipACLInterfaceList(ctx context.Context, in *MacipACLInterfaceListDump) (RPCService_DumpMacipACLInterfaceListClient, error) + ACLAddReplace(ctx context.Context, in *ACLAddReplace) (*ACLAddReplaceReply, error) + ACLDel(ctx context.Context, in *ACLDel) (*ACLDelReply, error) + ACLInterfaceAddDel(ctx context.Context, in *ACLInterfaceAddDel) (*ACLInterfaceAddDelReply, error) + ACLInterfaceSetACLList(ctx context.Context, in *ACLInterfaceSetACLList) (*ACLInterfaceSetACLListReply, error) + ACLInterfaceSetEtypeWhitelist(ctx context.Context, in *ACLInterfaceSetEtypeWhitelist) (*ACLInterfaceSetEtypeWhitelistReply, error) + ACLPluginControlPing(ctx context.Context, in *ACLPluginControlPing) (*ACLPluginControlPingReply, error) + ACLPluginGetConnTableMaxEntries(ctx context.Context, in *ACLPluginGetConnTableMaxEntries) (*ACLPluginGetConnTableMaxEntriesReply, error) + ACLPluginGetVersion(ctx context.Context, in *ACLPluginGetVersion) (*ACLPluginGetVersionReply, error) + ACLStatsIntfCountersEnable(ctx context.Context, in *ACLStatsIntfCountersEnable) (*ACLStatsIntfCountersEnableReply, error) + MacipACLAdd(ctx context.Context, in *MacipACLAdd) (*MacipACLAddReply, error) + MacipACLAddReplace(ctx context.Context, in *MacipACLAddReplace) (*MacipACLAddReplaceReply, error) + MacipACLDel(ctx context.Context, in *MacipACLDel) (*MacipACLDelReply, error) + MacipACLInterfaceAddDel(ctx context.Context, in *MacipACLInterfaceAddDel) (*MacipACLInterfaceAddDelReply, error) + MacipACLInterfaceGet(ctx context.Context, in *MacipACLInterfaceGet) (*MacipACLInterfaceGetReply, error) +} + +type serviceClient struct { + ch api.Channel +} + +func NewServiceClient(ch api.Channel) RPCService { + return &serviceClient{ch} +} + +func (c *serviceClient) DumpACL(ctx context.Context, in *ACLDump) (RPCService_DumpACLClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpACLClient{stream} + return x, nil +} + +type RPCService_DumpACLClient interface { + Recv() (*ACLDetails, error) +} + +type serviceClient_DumpACLClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpACLClient) Recv() (*ACLDetails, error) { + m := new(ACLDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpACLInterfaceEtypeWhitelist(ctx context.Context, in *ACLInterfaceEtypeWhitelistDump) (RPCService_DumpACLInterfaceEtypeWhitelistClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpACLInterfaceEtypeWhitelistClient{stream} + return x, nil +} + +type RPCService_DumpACLInterfaceEtypeWhitelistClient interface { + Recv() (*ACLInterfaceEtypeWhitelistDetails, error) +} + +type serviceClient_DumpACLInterfaceEtypeWhitelistClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpACLInterfaceEtypeWhitelistClient) Recv() (*ACLInterfaceEtypeWhitelistDetails, error) { + m := new(ACLInterfaceEtypeWhitelistDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpACLInterfaceList(ctx context.Context, in *ACLInterfaceListDump) (RPCService_DumpACLInterfaceListClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpACLInterfaceListClient{stream} + return x, nil +} + +type RPCService_DumpACLInterfaceListClient interface { + Recv() (*ACLInterfaceListDetails, error) +} + +type serviceClient_DumpACLInterfaceListClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpACLInterfaceListClient) Recv() (*ACLInterfaceListDetails, error) { + m := new(ACLInterfaceListDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpMacipACL(ctx context.Context, in *MacipACLDump) (RPCService_DumpMacipACLClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpMacipACLClient{stream} + return x, nil +} + +type RPCService_DumpMacipACLClient interface { + Recv() (*MacipACLDetails, error) +} + +type serviceClient_DumpMacipACLClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpMacipACLClient) Recv() (*MacipACLDetails, error) { + m := new(MacipACLDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpMacipACLInterfaceList(ctx context.Context, in *MacipACLInterfaceListDump) (RPCService_DumpMacipACLInterfaceListClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpMacipACLInterfaceListClient{stream} + return x, nil +} + +type RPCService_DumpMacipACLInterfaceListClient interface { + Recv() (*MacipACLInterfaceListDetails, error) +} + +type serviceClient_DumpMacipACLInterfaceListClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpMacipACLInterfaceListClient) Recv() (*MacipACLInterfaceListDetails, error) { + m := new(MacipACLInterfaceListDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) ACLAddReplace(ctx context.Context, in *ACLAddReplace) (*ACLAddReplaceReply, error) { + out := new(ACLAddReplaceReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) ACLDel(ctx context.Context, in *ACLDel) (*ACLDelReply, error) { + out := new(ACLDelReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) ACLInterfaceAddDel(ctx context.Context, in *ACLInterfaceAddDel) (*ACLInterfaceAddDelReply, error) { + out := new(ACLInterfaceAddDelReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) ACLInterfaceSetACLList(ctx context.Context, in *ACLInterfaceSetACLList) (*ACLInterfaceSetACLListReply, error) { + out := new(ACLInterfaceSetACLListReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) ACLInterfaceSetEtypeWhitelist(ctx context.Context, in *ACLInterfaceSetEtypeWhitelist) (*ACLInterfaceSetEtypeWhitelistReply, error) { + out := new(ACLInterfaceSetEtypeWhitelistReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) ACLPluginControlPing(ctx context.Context, in *ACLPluginControlPing) (*ACLPluginControlPingReply, error) { + out := new(ACLPluginControlPingReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) ACLPluginGetConnTableMaxEntries(ctx context.Context, in *ACLPluginGetConnTableMaxEntries) (*ACLPluginGetConnTableMaxEntriesReply, error) { + out := new(ACLPluginGetConnTableMaxEntriesReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) ACLPluginGetVersion(ctx context.Context, in *ACLPluginGetVersion) (*ACLPluginGetVersionReply, error) { + out := new(ACLPluginGetVersionReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) ACLStatsIntfCountersEnable(ctx context.Context, in *ACLStatsIntfCountersEnable) (*ACLStatsIntfCountersEnableReply, error) { + out := new(ACLStatsIntfCountersEnableReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) MacipACLAdd(ctx context.Context, in *MacipACLAdd) (*MacipACLAddReply, error) { + out := new(MacipACLAddReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) MacipACLAddReplace(ctx context.Context, in *MacipACLAddReplace) (*MacipACLAddReplaceReply, error) { + out := new(MacipACLAddReplaceReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) MacipACLDel(ctx context.Context, in *MacipACLDel) (*MacipACLDelReply, error) { + out := new(MacipACLDelReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) MacipACLInterfaceAddDel(ctx context.Context, in *MacipACLInterfaceAddDel) (*MacipACLInterfaceAddDelReply, error) { + out := new(MacipACLInterfaceAddDelReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) MacipACLInterfaceGet(ctx context.Context, in *MacipACLInterfaceGet) (*MacipACLInterfaceGetReply, error) { + out := new(MacipACLInterfaceGetReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = context.Background +var _ = io.Copy diff --git a/examples/binapi/af_packet/af_packet.ba.go b/examples/binapi/af_packet/af_packet.ba.go index 9660114..ab57c62 100644 --- a/examples/binapi/af_packet/af_packet.ba.go +++ b/examples/binapi/af_packet/af_packet.ba.go @@ -1,30 +1,38 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty +// VPP: 20.01-45~g7a071e370~b63 // source: /usr/share/vpp/api/core/af_packet.api.json /* -Package af_packet is a generated VPP binary API for 'af_packet' module. +Package af_packet contains generated code for VPP binary API defined by af_packet.api (version 2.0.0). It consists of: - 6 enums 2 aliases + 6 enums 8 messages - 4 services */ package af_packet import ( "bytes" "context" + "encoding/binary" "io" + "math" "strconv" api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" struc "github.com/lunixbochs/struc" - - ethernet_types "git.fd.io/govpp.git/examples/binapi/ethernet_types" - interface_types "git.fd.io/govpp.git/examples/binapi/interface_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 // please upgrade the GoVPP api package + const ( // ModuleName is the name of this module. ModuleName = "af_packet" @@ -34,27 +42,230 @@ const ( VersionCrc = 0xba745e20 ) -type IfStatusFlags = interface_types.IfStatusFlags +// IfStatusFlags represents VPP binary API enum 'if_status_flags'. +type IfStatusFlags uint32 -type IfType = interface_types.IfType +const ( + IF_STATUS_API_FLAG_ADMIN_UP IfStatusFlags = 1 + IF_STATUS_API_FLAG_LINK_UP IfStatusFlags = 2 +) -type LinkDuplex = interface_types.LinkDuplex +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, + } +) -type MtuProto = interface_types.MtuProto +func (x IfStatusFlags) String() string { + s, ok := IfStatusFlags_name[uint32(x)] + if ok { + return s + } + return "IfStatusFlags(" + strconv.Itoa(int(x)) + ")" +} -type RxMode = interface_types.RxMode +// IfType represents VPP binary API enum 'if_type'. +type IfType uint32 -type SubIfFlags = interface_types.SubIfFlags +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 +) -type InterfaceIndex = interface_types.InterfaceIndex +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", + } + 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, + } +) -type MacAddress = ethernet_types.MacAddress +func (x IfType) String() string { + s, ok := IfType_name[uint32(x)] + if ok { + return s + } + return "IfType(" + 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", + } + 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 "LinkDuplex(" + 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", + } + 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 "MtuProto(" + 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", + } + 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 "RxMode(" + 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", + } + 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 "SubIfFlags(" + strconv.Itoa(int(x)) + ")" +} + +// InterfaceIndex represents VPP binary API alias 'interface_index'. +type InterfaceIndex uint32 + +// MacAddress represents VPP binary API alias 'mac_address'. +type MacAddress [6]uint8 // AfPacketCreate represents VPP binary API message 'af_packet_create'. type AfPacketCreate struct { - HwAddr MacAddress - UseRandomHwAddr bool - HostIfName string `struc:"[64]byte"` + HwAddr MacAddress `binapi:"mac_address,name=hw_addr" json:"hw_addr,omitempty"` + UseRandomHwAddr bool `binapi:"bool,name=use_random_hw_addr" json:"use_random_hw_addr,omitempty"` + HostIfName string `binapi:"string[64],name=host_if_name" json:"host_if_name,omitempty" struc:"[64]byte"` } func (m *AfPacketCreate) Reset() { *m = AfPacketCreate{} } @@ -62,10 +273,75 @@ func (*AfPacketCreate) GetMessageName() string { return "af_packet_crea func (*AfPacketCreate) GetCrcString() string { return "a190415f" } func (*AfPacketCreate) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *AfPacketCreate) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.HwAddr + size += 6 + // field[1] m.UseRandomHwAddr + size += 1 + // field[1] m.HostIfName + size += 64 + return size +} +func (m *AfPacketCreate) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.HwAddr + for i := 0; i < 6; i++ { + var x uint8 + if i < len(m.HwAddr) { + x = uint8(m.HwAddr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.UseRandomHwAddr + if m.UseRandomHwAddr { + buf[pos] = 1 + } + pos += 1 + // field[1] m.HostIfName + copy(buf[pos:pos+64], m.HostIfName) + pos += 64 + return buf, nil +} +func (m *AfPacketCreate) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.HwAddr + for i := 0; i < len(m.HwAddr); i++ { + m.HwAddr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.UseRandomHwAddr + m.UseRandomHwAddr = tmp[pos] != 0 + pos += 1 + // field[1] m.HostIfName + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.HostIfName = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // AfPacketCreateReply represents VPP binary API message 'af_packet_create_reply'. type AfPacketCreateReply struct { - Retval int32 - SwIfIndex InterfaceIndex + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *AfPacketCreateReply) Reset() { *m = AfPacketCreateReply{} } @@ -73,9 +349,53 @@ func (*AfPacketCreateReply) GetMessageName() string { return "af_packet func (*AfPacketCreateReply) GetCrcString() string { return "5383d31f" } func (*AfPacketCreateReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *AfPacketCreateReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *AfPacketCreateReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *AfPacketCreateReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // AfPacketDelete represents VPP binary API message 'af_packet_delete'. type AfPacketDelete struct { - HostIfName string `struc:"[64]byte"` + HostIfName string `binapi:"string[64],name=host_if_name" json:"host_if_name,omitempty" struc:"[64]byte"` } func (m *AfPacketDelete) Reset() { *m = AfPacketDelete{} } @@ -83,9 +403,48 @@ func (*AfPacketDelete) GetMessageName() string { return "af_packet_dele func (*AfPacketDelete) GetCrcString() string { return "863fa648" } func (*AfPacketDelete) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *AfPacketDelete) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.HostIfName + size += 64 + return size +} +func (m *AfPacketDelete) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.HostIfName + copy(buf[pos:pos+64], m.HostIfName) + pos += 64 + return buf, nil +} +func (m *AfPacketDelete) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.HostIfName + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.HostIfName = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // AfPacketDeleteReply represents VPP binary API message 'af_packet_delete_reply'. type AfPacketDeleteReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *AfPacketDeleteReply) Reset() { *m = AfPacketDeleteReply{} } @@ -93,10 +452,46 @@ func (*AfPacketDeleteReply) GetMessageName() string { return "af_packet func (*AfPacketDeleteReply) GetCrcString() string { return "e8d4e804" } func (*AfPacketDeleteReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *AfPacketDeleteReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *AfPacketDeleteReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *AfPacketDeleteReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // AfPacketDetails represents VPP binary API message 'af_packet_details'. type AfPacketDetails struct { - SwIfIndex InterfaceIndex - HostIfName string `struc:"[64]byte"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + HostIfName string `binapi:"string[64],name=host_if_name" json:"host_if_name,omitempty" struc:"[64]byte"` } func (m *AfPacketDetails) Reset() { *m = AfPacketDetails{} } @@ -104,6 +499,53 @@ func (*AfPacketDetails) GetMessageName() string { return "af_packet_det func (*AfPacketDetails) GetCrcString() string { return "58c7c042" } func (*AfPacketDetails) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *AfPacketDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.HostIfName + size += 64 + return size +} +func (m *AfPacketDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.HostIfName + copy(buf[pos:pos+64], m.HostIfName) + pos += 64 + return buf, nil +} +func (m *AfPacketDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.HostIfName + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.HostIfName = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // AfPacketDump represents VPP binary API message 'af_packet_dump'. type AfPacketDump struct{} @@ -112,10 +554,38 @@ func (*AfPacketDump) GetMessageName() string { return "af_packet_dump" func (*AfPacketDump) GetCrcString() string { return "51077d14" } func (*AfPacketDump) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *AfPacketDump) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *AfPacketDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *AfPacketDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + // AfPacketSetL4CksumOffload represents VPP binary API message 'af_packet_set_l4_cksum_offload'. type AfPacketSetL4CksumOffload struct { - SwIfIndex InterfaceIndex - Set bool + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Set bool `binapi:"bool,name=set" json:"set,omitempty"` } func (m *AfPacketSetL4CksumOffload) Reset() { *m = AfPacketSetL4CksumOffload{} } @@ -123,9 +593,55 @@ func (*AfPacketSetL4CksumOffload) GetMessageName() string { return "af_ func (*AfPacketSetL4CksumOffload) GetCrcString() string { return "319cd5c8" } func (*AfPacketSetL4CksumOffload) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *AfPacketSetL4CksumOffload) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Set + size += 1 + return size +} +func (m *AfPacketSetL4CksumOffload) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Set + if m.Set { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *AfPacketSetL4CksumOffload) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Set + m.Set = tmp[pos] != 0 + pos += 1 + return nil +} + // AfPacketSetL4CksumOffloadReply represents VPP binary API message 'af_packet_set_l4_cksum_offload_reply'. type AfPacketSetL4CksumOffloadReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *AfPacketSetL4CksumOffloadReply) Reset() { *m = AfPacketSetL4CksumOffloadReply{} } @@ -135,7 +651,44 @@ func (*AfPacketSetL4CksumOffloadReply) GetMessageName() string { func (*AfPacketSetL4CksumOffloadReply) GetCrcString() string { return "e8d4e804" } func (*AfPacketSetL4CksumOffloadReply) GetMessageType() api.MessageType { return api.ReplyMessage } -func init() { +func (m *AfPacketSetL4CksumOffloadReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *AfPacketSetL4CksumOffloadReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *AfPacketSetL4CksumOffloadReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + +func init() { file_af_packet_binapi_init() } +func file_af_packet_binapi_init() { api.RegisterMessage((*AfPacketCreate)(nil), "af_packet.AfPacketCreate") api.RegisterMessage((*AfPacketCreateReply)(nil), "af_packet.AfPacketCreateReply") api.RegisterMessage((*AfPacketDelete)(nil), "af_packet.AfPacketDelete") @@ -160,85 +713,13 @@ func AllMessages() []api.Message { } } -// 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 _ = codec.DecodeString var _ = bytes.NewBuffer var _ = context.Background var _ = io.Copy var _ = strconv.Itoa var _ = struc.Pack +var _ = binary.BigEndian +var _ = math.Float32bits diff --git a/examples/binapi/af_packet/af_packet_rpc.ba.go b/examples/binapi/af_packet/af_packet_rpc.ba.go new file mode 100644 index 0000000..d2df47a --- /dev/null +++ b/examples/binapi/af_packet/af_packet_rpc.ba.go @@ -0,0 +1,84 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package af_packet + +import ( + "context" + "io" + + api "git.fd.io/govpp.git/api" +) + +// 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 +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = context.Background +var _ = io.Copy 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 fffa6b1..0000000 --- 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 "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "ethernet_types" - // VersionCrc is the CRC of this module. - VersionCrc = 0xd4ff2808 -) - -// MacAddress represents VPP binary API alias 'mac_address'. -type MacAddress [6]uint8 - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/examples/binapi/fib_types/fib_types.ba.go b/examples/binapi/fib_types/fib_types.ba.go new file mode 100644 index 0000000..dd725b6 --- /dev/null +++ b/examples/binapi/fib_types/fib_types.ba.go @@ -0,0 +1,522 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty +// VPP: 20.01-45~g7a071e370~b63 +// source: /usr/share/vpp/api/core/fib_types.api.json + +/* +Package fib_types contains generated code for VPP binary API defined by fib_types.api (version 2.0.0). + +It consists of: + 5 aliases + 7 enums + 9 types + 1 union +*/ +package fib_types + +import ( + "bytes" + "context" + "encoding/binary" + "io" + "math" + "strconv" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" + struc "github.com/lunixbochs/struc" +) + +// 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 // please upgrade the GoVPP api package + +const ( + // ModuleName is the name of this module. + ModuleName = "fib_types" + // APIVersion is the API version of this module. + APIVersion = "2.0.0" + // VersionCrc is the CRC of this module. + VersionCrc = 0x57387845 +) + +// 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", + } + 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 "AddressFamily(" + strconv.Itoa(int(x)) + ")" +} + +// 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", + } + 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 "FibPathFlags(" + 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", + } + 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 "FibPathNhProto(" + 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", + } + 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 "FibPathType(" + 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", + } + 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 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", + } + 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)) + ")" +} + +// 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", + } + 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 "IPProto(" + 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 `binapi:"address_family,name=af" json:"af,omitempty"` + Un AddressUnion `binapi:"address_union,name=un" json:"un,omitempty"` +} + +func (*Address) GetTypeName() string { return "address" } + +// FibMplsLabel represents VPP binary API type 'fib_mpls_label'. +type FibMplsLabel struct { + IsUniform uint8 `binapi:"u8,name=is_uniform" json:"is_uniform,omitempty"` + Label uint32 `binapi:"u32,name=label" json:"label,omitempty"` + TTL uint8 `binapi:"u8,name=ttl" json:"ttl,omitempty"` + Exp uint8 `binapi:"u8,name=exp" json:"exp,omitempty"` +} + +func (*FibMplsLabel) GetTypeName() string { return "fib_mpls_label" } + +// FibPath represents VPP binary API type 'fib_path'. +type FibPath struct { + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + RpfID uint32 `binapi:"u32,name=rpf_id" json:"rpf_id,omitempty"` + Weight uint8 `binapi:"u8,name=weight" json:"weight,omitempty"` + Preference uint8 `binapi:"u8,name=preference" json:"preference,omitempty"` + Type FibPathType `binapi:"fib_path_type,name=type" json:"type,omitempty"` + Flags FibPathFlags `binapi:"fib_path_flags,name=flags" json:"flags,omitempty"` + Proto FibPathNhProto `binapi:"fib_path_nh_proto,name=proto" json:"proto,omitempty"` + Nh FibPathNh `binapi:"fib_path_nh,name=nh" json:"nh,omitempty"` + NLabels uint8 `binapi:"u8,name=n_labels" json:"n_labels,omitempty"` + LabelStack [16]FibMplsLabel `binapi:"fib_mpls_label[16],name=label_stack" json:"label_stack,omitempty" struc:"[16]FibMplsLabel"` +} + +func (*FibPath) GetTypeName() string { return "fib_path" } + +// FibPathNh represents VPP binary API type 'fib_path_nh'. +type FibPathNh struct { + Address AddressUnion `binapi:"address_union,name=address" json:"address,omitempty"` + ViaLabel uint32 `binapi:"u32,name=via_label" json:"via_label,omitempty"` + ObjID uint32 `binapi:"u32,name=obj_id" json:"obj_id,omitempty"` + ClassifyTableIndex uint32 `binapi:"u32,name=classify_table_index" json:"classify_table_index,omitempty"` +} + +func (*FibPathNh) GetTypeName() string { return "fib_path_nh" } + +// IP4Prefix represents VPP binary API 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 (*IP4Prefix) GetTypeName() string { return "ip4_prefix" } + +// IP6Prefix represents VPP binary API 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 (*IP6Prefix) GetTypeName() string { return "ip6_prefix" } + +// Mprefix represents VPP binary API 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"` +} + +func (*Mprefix) GetTypeName() string { return "mprefix" } + +// Prefix represents VPP binary API type 'prefix'. +type Prefix struct { + Address Address `binapi:"address,name=address" json:"address,omitempty"` + Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` +} + +func (*Prefix) GetTypeName() string { return "prefix" } + +// PrefixMatcher represents VPP binary API type 'prefix_matcher'. +type PrefixMatcher struct { + Le uint8 `binapi:"u8,name=le" json:"le,omitempty"` + Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"` +} + +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 +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = codec.DecodeString +var _ = bytes.NewBuffer +var _ = context.Background +var _ = io.Copy +var _ = strconv.Itoa +var _ = struc.Pack +var _ = binary.BigEndian +var _ = math.Float32bits diff --git a/examples/binapi/gen.go b/examples/binapi/gen.go index 7c2030c..a19ca34 100644 --- a/examples/binapi/gen.go +++ b/examples/binapi/gen.go @@ -2,19 +2,4 @@ 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=git.fd.io/govpp.git/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" +//go:generate binapi-generator --import-prefix=git.fd.io/govpp.git/examples/binapi af_packet interface ip memclnt vpe sr acl memif ip_types fib_types 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 a9a34d1..0000000 --- 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 "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "interface_types" - // VersionCrc is the CRC of this module. - VersionCrc = 0xc97be83d -) - -// IfStatusFlags represents VPP binary API enum 'if_status_flags'. -type IfStatusFlags uint32 - -const ( - IF_STATUS_API_FLAG_ADMIN_UP IfStatusFlags = 1 - IF_STATUS_API_FLAG_LINK_UP IfStatusFlags = 2 -) - -var IfStatusFlags_name = map[uint32]string{ - 1: "IF_STATUS_API_FLAG_ADMIN_UP", - 2: "IF_STATUS_API_FLAG_LINK_UP", -} - -var IfStatusFlags_value = map[string]uint32{ - "IF_STATUS_API_FLAG_ADMIN_UP": 1, - "IF_STATUS_API_FLAG_LINK_UP": 2, -} - -func (x IfStatusFlags) String() string { - s, ok := IfStatusFlags_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// IfType represents VPP binary API enum 'if_type'. -type IfType uint32 - -const ( - IF_API_TYPE_HARDWARE IfType = 1 - IF_API_TYPE_SUB IfType = 2 - IF_API_TYPE_P2P IfType = 3 - IF_API_TYPE_PIPE IfType = 4 -) - -var IfType_name = map[uint32]string{ - 1: "IF_API_TYPE_HARDWARE", - 2: "IF_API_TYPE_SUB", - 3: "IF_API_TYPE_P2P", - 4: "IF_API_TYPE_PIPE", -} - -var IfType_value = map[string]uint32{ - "IF_API_TYPE_HARDWARE": 1, - "IF_API_TYPE_SUB": 2, - "IF_API_TYPE_P2P": 3, - "IF_API_TYPE_PIPE": 4, -} - -func (x IfType) String() string { - s, ok := IfType_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// LinkDuplex represents VPP binary API enum 'link_duplex'. -type LinkDuplex uint32 - -const ( - LINK_DUPLEX_API_UNKNOWN LinkDuplex = 0 - LINK_DUPLEX_API_HALF LinkDuplex = 1 - LINK_DUPLEX_API_FULL LinkDuplex = 2 -) - -var LinkDuplex_name = map[uint32]string{ - 0: "LINK_DUPLEX_API_UNKNOWN", - 1: "LINK_DUPLEX_API_HALF", - 2: "LINK_DUPLEX_API_FULL", -} - -var LinkDuplex_value = map[string]uint32{ - "LINK_DUPLEX_API_UNKNOWN": 0, - "LINK_DUPLEX_API_HALF": 1, - "LINK_DUPLEX_API_FULL": 2, -} - -func (x LinkDuplex) String() string { - s, ok := LinkDuplex_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// MtuProto represents VPP binary API enum 'mtu_proto'. -type MtuProto uint32 - -const ( - MTU_PROTO_API_L3 MtuProto = 1 - MTU_PROTO_API_IP4 MtuProto = 2 - MTU_PROTO_API_IP6 MtuProto = 3 - MTU_PROTO_API_MPLS MtuProto = 4 - MTU_PROTO_API_N MtuProto = 5 -) - -var MtuProto_name = map[uint32]string{ - 1: "MTU_PROTO_API_L3", - 2: "MTU_PROTO_API_IP4", - 3: "MTU_PROTO_API_IP6", - 4: "MTU_PROTO_API_MPLS", - 5: "MTU_PROTO_API_N", -} - -var MtuProto_value = map[string]uint32{ - "MTU_PROTO_API_L3": 1, - "MTU_PROTO_API_IP4": 2, - "MTU_PROTO_API_IP6": 3, - "MTU_PROTO_API_MPLS": 4, - "MTU_PROTO_API_N": 5, -} - -func (x MtuProto) String() string { - s, ok := MtuProto_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// RxMode represents VPP binary API enum 'rx_mode'. -type RxMode uint32 - -const ( - RX_MODE_API_UNKNOWN RxMode = 0 - RX_MODE_API_POLLING RxMode = 1 - RX_MODE_API_INTERRUPT RxMode = 2 - RX_MODE_API_ADAPTIVE RxMode = 3 - RX_MODE_API_DEFAULT RxMode = 4 -) - -var RxMode_name = map[uint32]string{ - 0: "RX_MODE_API_UNKNOWN", - 1: "RX_MODE_API_POLLING", - 2: "RX_MODE_API_INTERRUPT", - 3: "RX_MODE_API_ADAPTIVE", - 4: "RX_MODE_API_DEFAULT", -} - -var RxMode_value = map[string]uint32{ - "RX_MODE_API_UNKNOWN": 0, - "RX_MODE_API_POLLING": 1, - "RX_MODE_API_INTERRUPT": 2, - "RX_MODE_API_ADAPTIVE": 3, - "RX_MODE_API_DEFAULT": 4, -} - -func (x RxMode) String() string { - s, ok := RxMode_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// SubIfFlags represents VPP binary API enum 'sub_if_flags'. -type SubIfFlags uint32 - -const ( - SUB_IF_API_FLAG_NO_TAGS SubIfFlags = 1 - SUB_IF_API_FLAG_ONE_TAG SubIfFlags = 2 - SUB_IF_API_FLAG_TWO_TAGS SubIfFlags = 4 - SUB_IF_API_FLAG_DOT1AD SubIfFlags = 8 - SUB_IF_API_FLAG_EXACT_MATCH SubIfFlags = 16 - SUB_IF_API_FLAG_DEFAULT SubIfFlags = 32 - SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY SubIfFlags = 64 - SUB_IF_API_FLAG_INNER_VLAN_ID_ANY SubIfFlags = 128 - SUB_IF_API_FLAG_MASK_VNET SubIfFlags = 254 - SUB_IF_API_FLAG_DOT1AH SubIfFlags = 256 -) - -var SubIfFlags_name = map[uint32]string{ - 1: "SUB_IF_API_FLAG_NO_TAGS", - 2: "SUB_IF_API_FLAG_ONE_TAG", - 4: "SUB_IF_API_FLAG_TWO_TAGS", - 8: "SUB_IF_API_FLAG_DOT1AD", - 16: "SUB_IF_API_FLAG_EXACT_MATCH", - 32: "SUB_IF_API_FLAG_DEFAULT", - 64: "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY", - 128: "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY", - 254: "SUB_IF_API_FLAG_MASK_VNET", - 256: "SUB_IF_API_FLAG_DOT1AH", -} - -var SubIfFlags_value = map[string]uint32{ - "SUB_IF_API_FLAG_NO_TAGS": 1, - "SUB_IF_API_FLAG_ONE_TAG": 2, - "SUB_IF_API_FLAG_TWO_TAGS": 4, - "SUB_IF_API_FLAG_DOT1AD": 8, - "SUB_IF_API_FLAG_EXACT_MATCH": 16, - "SUB_IF_API_FLAG_DEFAULT": 32, - "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY": 64, - "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY": 128, - "SUB_IF_API_FLAG_MASK_VNET": 254, - "SUB_IF_API_FLAG_DOT1AH": 256, -} - -func (x SubIfFlags) String() string { - s, ok := SubIfFlags_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// InterfaceIndex represents VPP binary API alias 'interface_index'. -type InterfaceIndex uint32 - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/examples/binapi/interfaces/interfaces.ba.go b/examples/binapi/interfaces/interfaces.ba.go index 7d4031f..82e8f3c 100644 --- a/examples/binapi/interfaces/interfaces.ba.go +++ b/examples/binapi/interfaces/interfaces.ba.go @@ -1,33 +1,40 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty +// VPP: 20.01-45~g7a071e370~b63 // source: /usr/share/vpp/api/core/interface.api.json /* -Package interfaces is a generated VPP binary API for 'interface' module. +Package interfaces contains generated code for VPP binary API defined by interface.api (version 3.2.2). It consists of: - 10 enums 7 aliases + 10 enums + 53 messages 6 types 1 union - 53 messages - 26 services */ package interfaces import ( "bytes" "context" + "encoding/binary" "io" + "math" "strconv" api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" struc "github.com/lunixbochs/struc" - - ethernet_types "git.fd.io/govpp.git/examples/binapi/ethernet_types" - interface_types "git.fd.io/govpp.git/examples/binapi/interface_types" - ip_types "git.fd.io/govpp.git/examples/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 // please upgrade the GoVPP api package + const ( // ModuleName is the name of this module. ModuleName = "interface" @@ -37,58 +44,536 @@ const ( VersionCrc = 0xfebc3ffa ) -type AddressFamily = ip_types.AddressFamily +// 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", + } + 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 "AddressFamily(" + strconv.Itoa(int(x)) + ")" +} + +// 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", + } + 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 "IfStatusFlags(" + 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", + } + 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 "IfType(" + 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", + } + 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 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", + } + 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)) + ")" +} -type IfStatusFlags = interface_types.IfStatusFlags +// IPProto represents VPP binary API enum 'ip_proto'. +type IPProto uint32 -type IfType = interface_types.IfType +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 +) -type IPDscp = ip_types.IPDscp +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", + } + 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, + } +) -type IPEcn = ip_types.IPEcn +func (x IPProto) String() string { + s, ok := IPProto_name[uint32(x)] + if ok { + return s + } + return "IPProto(" + strconv.Itoa(int(x)) + ")" +} -type IPProto = ip_types.IPProto +// LinkDuplex represents VPP binary API enum 'link_duplex'. +type LinkDuplex uint32 -type LinkDuplex = interface_types.LinkDuplex +const ( + LINK_DUPLEX_API_UNKNOWN LinkDuplex = 0 + LINK_DUPLEX_API_HALF LinkDuplex = 1 + LINK_DUPLEX_API_FULL LinkDuplex = 2 +) -type MtuProto = interface_types.MtuProto +var ( + LinkDuplex_name = map[uint32]string{ + 0: "LINK_DUPLEX_API_UNKNOWN", + 1: "LINK_DUPLEX_API_HALF", + 2: "LINK_DUPLEX_API_FULL", + } + LinkDuplex_value = map[string]uint32{ + "LINK_DUPLEX_API_UNKNOWN": 0, + "LINK_DUPLEX_API_HALF": 1, + "LINK_DUPLEX_API_FULL": 2, + } +) -type RxMode = interface_types.RxMode +func (x LinkDuplex) String() string { + s, ok := LinkDuplex_name[uint32(x)] + if ok { + return s + } + return "LinkDuplex(" + strconv.Itoa(int(x)) + ")" +} -type SubIfFlags = interface_types.SubIfFlags +// MtuProto represents VPP binary API enum 'mtu_proto'. +type MtuProto uint32 -type AddressWithPrefix = ip_types.AddressWithPrefix +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 +) -type InterfaceIndex = interface_types.InterfaceIndex +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", + } + 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, + } +) -type IP4Address = ip_types.IP4Address +func (x MtuProto) String() string { + s, ok := MtuProto_name[uint32(x)] + if ok { + return s + } + return "MtuProto(" + strconv.Itoa(int(x)) + ")" +} -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix +// RxMode represents VPP binary API enum 'rx_mode'. +type RxMode uint32 -type IP6Address = ip_types.IP6Address +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 +) -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix +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", + } + 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, + } +) -type MacAddress = ethernet_types.MacAddress +func (x RxMode) String() string { + s, ok := RxMode_name[uint32(x)] + if ok { + return s + } + return "RxMode(" + strconv.Itoa(int(x)) + ")" +} -type Address = ip_types.Address +// SubIfFlags represents VPP binary API enum 'sub_if_flags'. +type SubIfFlags uint32 -type IP4Prefix = ip_types.IP4Prefix +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", + } + 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 "SubIfFlags(" + strconv.Itoa(int(x)) + ")" +} + +// AddressWithPrefix represents VPP binary API alias 'address_with_prefix'. +type AddressWithPrefix Prefix + +// InterfaceIndex represents VPP binary API alias 'interface_index'. +type InterfaceIndex uint32 + +// 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 -type IP6Prefix = ip_types.IP6Prefix +// MacAddress represents VPP binary API alias 'mac_address'. +type MacAddress [6]uint8 -type Mprefix = ip_types.Mprefix +// Address represents VPP binary API 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 (*Address) GetTypeName() string { return "address" } + +// IP4Prefix represents VPP binary API 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"` +} -type Prefix = ip_types.Prefix +func (*IP4Prefix) GetTypeName() string { return "ip4_prefix" } -type PrefixMatcher = ip_types.PrefixMatcher +// IP6Prefix represents VPP binary API 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 (*IP6Prefix) GetTypeName() string { return "ip6_prefix" } + +// Mprefix represents VPP binary API 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"` +} -type AddressUnion = ip_types.AddressUnion +func (*Mprefix) GetTypeName() string { return "mprefix" } + +// Prefix represents VPP binary API type 'prefix'. +type Prefix struct { + Address Address `binapi:"address,name=address" json:"address,omitempty"` + Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` +} + +func (*Prefix) GetTypeName() string { return "prefix" } + +// PrefixMatcher represents VPP binary API type 'prefix_matcher'. +type PrefixMatcher struct { + Le uint8 `binapi:"u8,name=le" json:"le,omitempty"` + Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"` +} + +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 +} // CollectDetailedInterfaceStats represents VPP binary API message 'collect_detailed_interface_stats'. type CollectDetailedInterfaceStats struct { - SwIfIndex InterfaceIndex - EnableDisable bool + SwIfIndex 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 *CollectDetailedInterfaceStats) Reset() { *m = CollectDetailedInterfaceStats{} } @@ -98,9 +583,55 @@ func (*CollectDetailedInterfaceStats) GetMessageName() string { func (*CollectDetailedInterfaceStats) GetCrcString() string { return "5501adee" } func (*CollectDetailedInterfaceStats) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *CollectDetailedInterfaceStats) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.EnableDisable + size += 1 + return size +} +func (m *CollectDetailedInterfaceStats) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.EnableDisable + if m.EnableDisable { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *CollectDetailedInterfaceStats) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.EnableDisable + m.EnableDisable = tmp[pos] != 0 + pos += 1 + return nil +} + // CollectDetailedInterfaceStatsReply represents VPP binary API message 'collect_detailed_interface_stats_reply'. type CollectDetailedInterfaceStatsReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *CollectDetailedInterfaceStatsReply) Reset() { *m = CollectDetailedInterfaceStatsReply{} } @@ -110,9 +641,45 @@ func (*CollectDetailedInterfaceStatsReply) GetMessageName() string { func (*CollectDetailedInterfaceStatsReply) GetCrcString() string { return "e8d4e804" } func (*CollectDetailedInterfaceStatsReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *CollectDetailedInterfaceStatsReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *CollectDetailedInterfaceStatsReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *CollectDetailedInterfaceStatsReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // CreateLoopback represents VPP binary API message 'create_loopback'. type CreateLoopback struct { - MacAddress MacAddress + MacAddress MacAddress `binapi:"mac_address,name=mac_address" json:"mac_address,omitempty"` } func (m *CreateLoopback) Reset() { *m = CreateLoopback{} } @@ -120,11 +687,55 @@ func (*CreateLoopback) GetMessageName() string { return "create_loopbac func (*CreateLoopback) GetCrcString() string { return "42bb5d22" } func (*CreateLoopback) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *CreateLoopback) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.MacAddress + size += 6 + return size +} +func (m *CreateLoopback) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.MacAddress + for i := 0; i < 6; i++ { + var x uint8 + if i < len(m.MacAddress) { + x = uint8(m.MacAddress[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + return buf, nil +} +func (m *CreateLoopback) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.MacAddress + for i := 0; i < len(m.MacAddress); i++ { + m.MacAddress[i] = uint8(tmp[pos]) + pos += 1 + } + return nil +} + // CreateLoopbackInstance represents VPP binary API message 'create_loopback_instance'. type CreateLoopbackInstance struct { - MacAddress MacAddress - IsSpecified bool - UserInstance uint32 + MacAddress 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{} } @@ -132,10 +743,72 @@ func (*CreateLoopbackInstance) GetMessageName() string { return "create func (*CreateLoopbackInstance) GetCrcString() string { return "d36a3ee2" } func (*CreateLoopbackInstance) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *CreateLoopbackInstance) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.MacAddress + size += 6 + // field[1] m.IsSpecified + size += 1 + // field[1] m.UserInstance + size += 4 + return size +} +func (m *CreateLoopbackInstance) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.MacAddress + for i := 0; i < 6; i++ { + var x uint8 + if i < len(m.MacAddress) { + x = uint8(m.MacAddress[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.IsSpecified + if m.IsSpecified { + buf[pos] = 1 + } + pos += 1 + // field[1] m.UserInstance + o.PutUint32(buf[pos:pos+4], uint32(m.UserInstance)) + pos += 4 + return buf, nil +} +func (m *CreateLoopbackInstance) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.MacAddress + for i := 0; i < len(m.MacAddress); i++ { + m.MacAddress[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.IsSpecified + m.IsSpecified = tmp[pos] != 0 + pos += 1 + // field[1] m.UserInstance + m.UserInstance = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // CreateLoopbackInstanceReply represents VPP binary API message 'create_loopback_instance_reply'. type CreateLoopbackInstanceReply struct { - Retval int32 - SwIfIndex InterfaceIndex + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *CreateLoopbackInstanceReply) Reset() { *m = CreateLoopbackInstanceReply{} } @@ -143,10 +816,54 @@ func (*CreateLoopbackInstanceReply) GetMessageName() string { return "c func (*CreateLoopbackInstanceReply) GetCrcString() string { return "5383d31f" } func (*CreateLoopbackInstanceReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *CreateLoopbackInstanceReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *CreateLoopbackInstanceReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *CreateLoopbackInstanceReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // CreateLoopbackReply represents VPP binary API message 'create_loopback_reply'. type CreateLoopbackReply struct { - Retval int32 - SwIfIndex InterfaceIndex + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *CreateLoopbackReply) Reset() { *m = CreateLoopbackReply{} } @@ -154,13 +871,57 @@ func (*CreateLoopbackReply) GetMessageName() string { return "create_lo func (*CreateLoopbackReply) GetCrcString() string { return "5383d31f" } func (*CreateLoopbackReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *CreateLoopbackReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *CreateLoopbackReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *CreateLoopbackReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // CreateSubif represents VPP binary API message 'create_subif'. type CreateSubif struct { - SwIfIndex InterfaceIndex - SubID uint32 - SubIfFlags SubIfFlags - OuterVlanID uint16 - InnerVlanID uint16 + SwIfIndex 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 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{} } @@ -168,10 +929,78 @@ func (*CreateSubif) GetMessageName() string { return "create_subif" } func (*CreateSubif) GetCrcString() string { return "cb371063" } func (*CreateSubif) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *CreateSubif) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.SubID + size += 4 + // field[1] m.SubIfFlags + size += 4 + // field[1] m.OuterVlanID + size += 2 + // field[1] m.InnerVlanID + size += 2 + return size +} +func (m *CreateSubif) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.SubID + o.PutUint32(buf[pos:pos+4], uint32(m.SubID)) + pos += 4 + // field[1] m.SubIfFlags + o.PutUint32(buf[pos:pos+4], uint32(m.SubIfFlags)) + pos += 4 + // field[1] m.OuterVlanID + o.PutUint16(buf[pos:pos+2], uint16(m.OuterVlanID)) + pos += 2 + // field[1] m.InnerVlanID + o.PutUint16(buf[pos:pos+2], uint16(m.InnerVlanID)) + pos += 2 + return buf, nil +} +func (m *CreateSubif) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SubID + m.SubID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SubIfFlags + m.SubIfFlags = SubIfFlags(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.OuterVlanID + m.OuterVlanID = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[1] m.InnerVlanID + m.InnerVlanID = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + return nil +} + // CreateSubifReply represents VPP binary API message 'create_subif_reply'. type CreateSubifReply struct { - Retval int32 - SwIfIndex InterfaceIndex + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *CreateSubifReply) Reset() { *m = CreateSubifReply{} } @@ -179,10 +1008,54 @@ func (*CreateSubifReply) GetMessageName() string { return "create_subif func (*CreateSubifReply) GetCrcString() string { return "5383d31f" } func (*CreateSubifReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *CreateSubifReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *CreateSubifReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *CreateSubifReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // CreateVlanSubif represents VPP binary API message 'create_vlan_subif'. type CreateVlanSubif struct { - SwIfIndex InterfaceIndex - VlanID uint32 + SwIfIndex 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{} } @@ -190,10 +1063,54 @@ func (*CreateVlanSubif) GetMessageName() string { return "create_vlan_s func (*CreateVlanSubif) GetCrcString() string { return "af34ac8b" } func (*CreateVlanSubif) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *CreateVlanSubif) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.VlanID + size += 4 + return size +} +func (m *CreateVlanSubif) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.VlanID + o.PutUint32(buf[pos:pos+4], uint32(m.VlanID)) + pos += 4 + return buf, nil +} +func (m *CreateVlanSubif) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.VlanID + m.VlanID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // CreateVlanSubifReply represents VPP binary API message 'create_vlan_subif_reply'. type CreateVlanSubifReply struct { - Retval int32 - SwIfIndex InterfaceIndex + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *CreateVlanSubifReply) Reset() { *m = CreateVlanSubifReply{} } @@ -201,9 +1118,53 @@ func (*CreateVlanSubifReply) GetMessageName() string { return "create_v func (*CreateVlanSubifReply) GetCrcString() string { return "5383d31f" } func (*CreateVlanSubifReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *CreateVlanSubifReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *CreateVlanSubifReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *CreateVlanSubifReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // DeleteLoopback represents VPP binary API message 'delete_loopback'. type DeleteLoopback struct { - SwIfIndex InterfaceIndex + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *DeleteLoopback) Reset() { *m = DeleteLoopback{} } @@ -211,9 +1172,45 @@ func (*DeleteLoopback) GetMessageName() string { return "delete_loopbac func (*DeleteLoopback) GetCrcString() string { return "f9e6675e" } func (*DeleteLoopback) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *DeleteLoopback) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *DeleteLoopback) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *DeleteLoopback) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // DeleteLoopbackReply represents VPP binary API message 'delete_loopback_reply'. type DeleteLoopbackReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *DeleteLoopbackReply) Reset() { *m = DeleteLoopbackReply{} } @@ -221,9 +1218,45 @@ func (*DeleteLoopbackReply) GetMessageName() string { return "delete_lo func (*DeleteLoopbackReply) GetCrcString() string { return "e8d4e804" } func (*DeleteLoopbackReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *DeleteLoopbackReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *DeleteLoopbackReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *DeleteLoopbackReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // DeleteSubif represents VPP binary API message 'delete_subif'. type DeleteSubif struct { - SwIfIndex InterfaceIndex + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *DeleteSubif) Reset() { *m = DeleteSubif{} } @@ -231,9 +1264,45 @@ 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *DeleteSubif) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *DeleteSubif) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // DeleteSubifReply represents VPP binary API message 'delete_subif_reply'. type DeleteSubifReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *DeleteSubifReply) Reset() { *m = DeleteSubifReply{} } @@ -241,10 +1310,46 @@ func (*DeleteSubifReply) GetMessageName() string { return "delete_subif func (*DeleteSubifReply) GetCrcString() string { return "e8d4e804" } func (*DeleteSubifReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *DeleteSubifReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *DeleteSubifReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *DeleteSubifReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // HwInterfaceSetMtu represents VPP binary API message 'hw_interface_set_mtu'. type HwInterfaceSetMtu struct { - SwIfIndex InterfaceIndex - Mtu uint16 + SwIfIndex 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{} } @@ -252,9 +1357,53 @@ func (*HwInterfaceSetMtu) GetMessageName() string { return "hw_interfac func (*HwInterfaceSetMtu) GetCrcString() string { return "e6746899" } func (*HwInterfaceSetMtu) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *HwInterfaceSetMtu) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Mtu + size += 2 + return size +} +func (m *HwInterfaceSetMtu) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Mtu + o.PutUint16(buf[pos:pos+2], uint16(m.Mtu)) + pos += 2 + return buf, nil +} +func (m *HwInterfaceSetMtu) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Mtu + m.Mtu = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + return nil +} + // HwInterfaceSetMtuReply represents VPP binary API message 'hw_interface_set_mtu_reply'. type HwInterfaceSetMtuReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *HwInterfaceSetMtuReply) Reset() { *m = HwInterfaceSetMtuReply{} } @@ -262,10 +1411,46 @@ func (*HwInterfaceSetMtuReply) GetMessageName() string { return "hw_int func (*HwInterfaceSetMtuReply) GetCrcString() string { return "e8d4e804" } func (*HwInterfaceSetMtuReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *HwInterfaceSetMtuReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *HwInterfaceSetMtuReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *HwInterfaceSetMtuReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // InterfaceNameRenumber represents VPP binary API message 'interface_name_renumber'. type InterfaceNameRenumber struct { - SwIfIndex InterfaceIndex - NewShowDevInstance uint32 + SwIfIndex 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{} } @@ -273,9 +1458,53 @@ func (*InterfaceNameRenumber) GetMessageName() string { return "interfa func (*InterfaceNameRenumber) GetCrcString() string { return "2b8858b8" } func (*InterfaceNameRenumber) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *InterfaceNameRenumber) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.NewShowDevInstance + size += 4 + return size +} +func (m *InterfaceNameRenumber) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.NewShowDevInstance + o.PutUint32(buf[pos:pos+4], uint32(m.NewShowDevInstance)) + pos += 4 + return buf, nil +} +func (m *InterfaceNameRenumber) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.NewShowDevInstance + m.NewShowDevInstance = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // InterfaceNameRenumberReply represents VPP binary API message 'interface_name_renumber_reply'. type InterfaceNameRenumberReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *InterfaceNameRenumberReply) Reset() { *m = InterfaceNameRenumberReply{} } @@ -283,12 +1512,48 @@ func (*InterfaceNameRenumberReply) GetMessageName() string { return "in func (*InterfaceNameRenumberReply) GetCrcString() string { return "e8d4e804" } func (*InterfaceNameRenumberReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *InterfaceNameRenumberReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *InterfaceNameRenumberReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *InterfaceNameRenumberReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceAddDelAddress represents VPP binary API message 'sw_interface_add_del_address'. type SwInterfaceAddDelAddress struct { - SwIfIndex InterfaceIndex - IsAdd bool - DelAll bool - Prefix AddressWithPrefix + SwIfIndex 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 AddressWithPrefix `binapi:"address_with_prefix,name=prefix" json:"prefix,omitempty"` } func (m *SwInterfaceAddDelAddress) Reset() { *m = SwInterfaceAddDelAddress{} } @@ -296,9 +1561,95 @@ func (*SwInterfaceAddDelAddress) GetMessageName() string { return "sw_i func (*SwInterfaceAddDelAddress) GetCrcString() string { return "5803d5c4" } func (*SwInterfaceAddDelAddress) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceAddDelAddress) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.IsAdd + size += 1 + // field[1] m.DelAll + size += 1 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + size += 4 + // field[3] m.Prefix.Address.Un + size += 16 + // field[2] m.Prefix.Len + size += 1 + return size +} +func (m *SwInterfaceAddDelAddress) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.IsAdd + if m.IsAdd { + buf[pos] = 1 + } + pos += 1 + // field[1] m.DelAll + if m.DelAll { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + o.PutUint32(buf[pos:pos+4], uint32(m.Prefix.Address.Af)) + pos += 4 + // field[3] m.Prefix.Address.Un + copy(buf[pos:pos+16], m.Prefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[2] m.Prefix.Len + buf[pos] = uint8(m.Prefix.Len) + pos += 1 + return buf, nil +} +func (m *SwInterfaceAddDelAddress) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IsAdd + m.IsAdd = tmp[pos] != 0 + pos += 1 + // field[1] m.DelAll + m.DelAll = tmp[pos] != 0 + pos += 1 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + m.Prefix.Address.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Prefix.Address.Un + copy(m.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[2] m.Prefix.Len + m.Prefix.Len = uint8(tmp[pos]) + pos += 1 + return nil +} + // SwInterfaceAddDelAddressReply represents VPP binary API message 'sw_interface_add_del_address_reply'. type SwInterfaceAddDelAddressReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SwInterfaceAddDelAddressReply) Reset() { *m = SwInterfaceAddDelAddressReply{} } @@ -308,11 +1659,47 @@ func (*SwInterfaceAddDelAddressReply) GetMessageName() string { func (*SwInterfaceAddDelAddressReply) GetCrcString() string { return "e8d4e804" } func (*SwInterfaceAddDelAddressReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SwInterfaceAddDelAddressReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceAddDelAddressReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceAddDelAddressReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceAddDelMacAddress represents VPP binary API message 'sw_interface_add_del_mac_address'. type SwInterfaceAddDelMacAddress struct { - SwIfIndex uint32 - Addr MacAddress - IsAdd uint8 + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + Addr 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{} } @@ -322,9 +1709,69 @@ func (*SwInterfaceAddDelMacAddress) GetMessageName() string { func (*SwInterfaceAddDelMacAddress) GetCrcString() string { return "638bb9f4" } func (*SwInterfaceAddDelMacAddress) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceAddDelMacAddress) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Addr + size += 6 + // field[1] m.IsAdd + size += 1 + return size +} +func (m *SwInterfaceAddDelMacAddress) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Addr + for i := 0; i < 6; i++ { + var x uint8 + if i < len(m.Addr) { + x = uint8(m.Addr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.IsAdd + buf[pos] = uint8(m.IsAdd) + pos += 1 + return buf, nil +} +func (m *SwInterfaceAddDelMacAddress) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Addr + for i := 0; i < len(m.Addr); i++ { + m.Addr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.IsAdd + m.IsAdd = uint8(tmp[pos]) + pos += 1 + return nil +} + // SwInterfaceAddDelMacAddressReply represents VPP binary API message 'sw_interface_add_del_mac_address_reply'. type SwInterfaceAddDelMacAddressReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SwInterfaceAddDelMacAddressReply) Reset() { *m = SwInterfaceAddDelMacAddressReply{} } @@ -334,9 +1781,45 @@ func (*SwInterfaceAddDelMacAddressReply) GetMessageName() string { func (*SwInterfaceAddDelMacAddressReply) GetCrcString() string { return "e8d4e804" } func (*SwInterfaceAddDelMacAddressReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SwInterfaceAddDelMacAddressReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceAddDelMacAddressReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceAddDelMacAddressReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceClearStats represents VPP binary API message 'sw_interface_clear_stats'. type SwInterfaceClearStats struct { - SwIfIndex InterfaceIndex + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *SwInterfaceClearStats) Reset() { *m = SwInterfaceClearStats{} } @@ -344,9 +1827,45 @@ func (*SwInterfaceClearStats) GetMessageName() string { return "sw_inte func (*SwInterfaceClearStats) GetCrcString() string { return "f9e6675e" } func (*SwInterfaceClearStats) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceClearStats) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *SwInterfaceClearStats) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceClearStats) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceClearStatsReply represents VPP binary API message 'sw_interface_clear_stats_reply'. type SwInterfaceClearStatsReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SwInterfaceClearStatsReply) Reset() { *m = SwInterfaceClearStatsReply{} } @@ -354,34 +1873,70 @@ func (*SwInterfaceClearStatsReply) GetMessageName() string { return "sw func (*SwInterfaceClearStatsReply) GetCrcString() string { return "e8d4e804" } func (*SwInterfaceClearStatsReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SwInterfaceClearStatsReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceClearStatsReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceClearStatsReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // 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"` + SwIfIndex 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 MacAddress `binapi:"mac_address,name=l2_address" json:"l2_address,omitempty"` + Flags IfStatusFlags `binapi:"if_status_flags,name=flags" json:"flags,omitempty"` + Type IfType `binapi:"if_type,name=type" json:"type,omitempty"` + LinkDuplex 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" struc:"[4]uint32"` + 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 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 MacAddress `binapi:"mac_address,name=b_dmac" json:"b_dmac,omitempty"` + BSmac 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" struc:"[64]byte"` + InterfaceDevType string `binapi:"string[64],name=interface_dev_type" json:"interface_dev_type,omitempty" struc:"[64]byte"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` } func (m *SwInterfaceDetails) Reset() { *m = SwInterfaceDetails{} } @@ -389,12 +1944,290 @@ func (*SwInterfaceDetails) GetMessageName() string { return "sw_interfa func (*SwInterfaceDetails) GetCrcString() string { return "17b69fa2" } func (*SwInterfaceDetails) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SwInterfaceDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.SupSwIfIndex + size += 4 + // field[1] m.L2Address + size += 6 + // field[1] m.Flags + size += 4 + // field[1] m.Type + size += 4 + // field[1] m.LinkDuplex + size += 4 + // field[1] m.LinkSpeed + size += 4 + // field[1] m.LinkMtu + size += 2 + // field[1] m.Mtu + size += 16 + // field[1] m.SubID + size += 4 + // field[1] m.SubNumberOfTags + size += 1 + // field[1] m.SubOuterVlanID + size += 2 + // field[1] m.SubInnerVlanID + size += 2 + // field[1] m.SubIfFlags + size += 4 + // field[1] m.VtrOp + size += 4 + // field[1] m.VtrPushDot1q + size += 4 + // field[1] m.VtrTag1 + size += 4 + // field[1] m.VtrTag2 + size += 4 + // field[1] m.OuterTag + size += 2 + // field[1] m.BDmac + size += 6 + // field[1] m.BSmac + size += 6 + // field[1] m.BVlanid + size += 2 + // field[1] m.ISid + size += 4 + // field[1] m.InterfaceName + size += 64 + // field[1] m.InterfaceDevType + size += 64 + // field[1] m.Tag + size += 64 + return size +} +func (m *SwInterfaceDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.SupSwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SupSwIfIndex)) + pos += 4 + // field[1] m.L2Address + for i := 0; i < 6; i++ { + var x uint8 + if i < len(m.L2Address) { + x = uint8(m.L2Address[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.Flags + o.PutUint32(buf[pos:pos+4], uint32(m.Flags)) + pos += 4 + // field[1] m.Type + o.PutUint32(buf[pos:pos+4], uint32(m.Type)) + pos += 4 + // field[1] m.LinkDuplex + o.PutUint32(buf[pos:pos+4], uint32(m.LinkDuplex)) + pos += 4 + // field[1] m.LinkSpeed + o.PutUint32(buf[pos:pos+4], uint32(m.LinkSpeed)) + pos += 4 + // field[1] m.LinkMtu + o.PutUint16(buf[pos:pos+2], uint16(m.LinkMtu)) + pos += 2 + // field[1] m.Mtu + for i := 0; i < 4; i++ { + var x uint32 + if i < len(m.Mtu) { + x = uint32(m.Mtu[i]) + } + o.PutUint32(buf[pos:pos+4], uint32(x)) + pos += 4 + } + // field[1] m.SubID + o.PutUint32(buf[pos:pos+4], uint32(m.SubID)) + pos += 4 + // field[1] m.SubNumberOfTags + buf[pos] = uint8(m.SubNumberOfTags) + pos += 1 + // field[1] m.SubOuterVlanID + o.PutUint16(buf[pos:pos+2], uint16(m.SubOuterVlanID)) + pos += 2 + // field[1] m.SubInnerVlanID + o.PutUint16(buf[pos:pos+2], uint16(m.SubInnerVlanID)) + pos += 2 + // field[1] m.SubIfFlags + o.PutUint32(buf[pos:pos+4], uint32(m.SubIfFlags)) + pos += 4 + // field[1] m.VtrOp + o.PutUint32(buf[pos:pos+4], uint32(m.VtrOp)) + pos += 4 + // field[1] m.VtrPushDot1q + o.PutUint32(buf[pos:pos+4], uint32(m.VtrPushDot1q)) + pos += 4 + // field[1] m.VtrTag1 + o.PutUint32(buf[pos:pos+4], uint32(m.VtrTag1)) + pos += 4 + // field[1] m.VtrTag2 + o.PutUint32(buf[pos:pos+4], uint32(m.VtrTag2)) + pos += 4 + // field[1] m.OuterTag + o.PutUint16(buf[pos:pos+2], uint16(m.OuterTag)) + pos += 2 + // field[1] m.BDmac + for i := 0; i < 6; i++ { + var x uint8 + if i < len(m.BDmac) { + x = uint8(m.BDmac[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.BSmac + for i := 0; i < 6; i++ { + var x uint8 + if i < len(m.BSmac) { + x = uint8(m.BSmac[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.BVlanid + o.PutUint16(buf[pos:pos+2], uint16(m.BVlanid)) + pos += 2 + // field[1] m.ISid + o.PutUint32(buf[pos:pos+4], uint32(m.ISid)) + pos += 4 + // field[1] m.InterfaceName + copy(buf[pos:pos+64], m.InterfaceName) + pos += 64 + // field[1] m.InterfaceDevType + copy(buf[pos:pos+64], m.InterfaceDevType) + pos += 64 + // field[1] m.Tag + copy(buf[pos:pos+64], m.Tag) + pos += 64 + return buf, nil +} +func (m *SwInterfaceDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SupSwIfIndex + m.SupSwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.L2Address + for i := 0; i < len(m.L2Address); i++ { + m.L2Address[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.Flags + m.Flags = IfStatusFlags(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Type + m.Type = IfType(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.LinkDuplex + m.LinkDuplex = LinkDuplex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.LinkSpeed + m.LinkSpeed = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.LinkMtu + m.LinkMtu = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[1] m.Mtu + m.Mtu = make([]uint32, 4) + for i := 0; i < len(m.Mtu); i++ { + m.Mtu[i] = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + } + // field[1] m.SubID + m.SubID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SubNumberOfTags + m.SubNumberOfTags = uint8(tmp[pos]) + pos += 1 + // field[1] m.SubOuterVlanID + m.SubOuterVlanID = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[1] m.SubInnerVlanID + m.SubInnerVlanID = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[1] m.SubIfFlags + m.SubIfFlags = SubIfFlags(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.VtrOp + m.VtrOp = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.VtrPushDot1q + m.VtrPushDot1q = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.VtrTag1 + m.VtrTag1 = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.VtrTag2 + m.VtrTag2 = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.OuterTag + m.OuterTag = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[1] m.BDmac + for i := 0; i < len(m.BDmac); i++ { + m.BDmac[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.BSmac + for i := 0; i < len(m.BSmac); i++ { + m.BSmac[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.BVlanid + m.BVlanid = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[1] m.ISid + m.ISid = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.InterfaceName + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.InterfaceName = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + // field[1] m.InterfaceDevType + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.InterfaceDevType = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + // field[1] m.Tag + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Tag = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // SwInterfaceDump represents VPP binary API message 'sw_interface_dump'. type SwInterfaceDump struct { - SwIfIndex InterfaceIndex - NameFilterValid bool - XXX_NameFilterLen uint32 `struc:"sizeof=NameFilter"` - NameFilter string + SwIfIndex 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"` + XXX_NameFilterLen uint32 `struc:"sizeof=NameFilter"` + NameFilter string `json:"name_filter,omitempty"` } func (m *SwInterfaceDump) Reset() { *m = SwInterfaceDump{} } @@ -402,12 +2235,72 @@ func (*SwInterfaceDump) GetMessageName() string { return "sw_interface_ func (*SwInterfaceDump) GetCrcString() string { return "aa610c27" } func (*SwInterfaceDump) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceDump) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.NameFilterValid + size += 1 + // field[1] m.NameFilter + size += 4 + len(m.NameFilter) + return size +} +func (m *SwInterfaceDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.NameFilterValid + if m.NameFilterValid { + buf[pos] = 1 + } + pos += 1 + // field[1] m.NameFilter + o.PutUint32(buf[pos:pos+4], uint32(len(m.NameFilter))) + pos += 4 + copy(buf[pos:pos+len(m.NameFilter)], m.NameFilter[:]) + pos += len(m.NameFilter) + return buf, nil +} +func (m *SwInterfaceDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.NameFilterValid + m.NameFilterValid = tmp[pos] != 0 + pos += 1 + // field[1] m.NameFilter + { + siz := o.Uint32(tmp[pos : pos+4]) + pos += 4 + m.NameFilter = codec.DecodeString(tmp[pos : pos+int(siz)]) + pos += len(m.NameFilter) + } + return nil +} + // SwInterfaceEvent represents VPP binary API message 'sw_interface_event'. type SwInterfaceEvent struct { - PID uint32 - SwIfIndex InterfaceIndex - Flags IfStatusFlags - Deleted bool + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Flags 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{} } @@ -415,9 +2308,71 @@ func (*SwInterfaceEvent) GetMessageName() string { return "sw_interface func (*SwInterfaceEvent) GetCrcString() string { return "f709f78d" } func (*SwInterfaceEvent) GetMessageType() api.MessageType { return api.EventMessage } +func (m *SwInterfaceEvent) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.PID + size += 4 + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Flags + size += 4 + // field[1] m.Deleted + size += 1 + return size +} +func (m *SwInterfaceEvent) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.PID + o.PutUint32(buf[pos:pos+4], uint32(m.PID)) + pos += 4 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Flags + o.PutUint32(buf[pos:pos+4], uint32(m.Flags)) + pos += 4 + // field[1] m.Deleted + if m.Deleted { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *SwInterfaceEvent) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.PID + m.PID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Flags + m.Flags = IfStatusFlags(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Deleted + m.Deleted = tmp[pos] != 0 + pos += 1 + return nil +} + // SwInterfaceGetMacAddress represents VPP binary API message 'sw_interface_get_mac_address'. type SwInterfaceGetMacAddress struct { - SwIfIndex InterfaceIndex + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *SwInterfaceGetMacAddress) Reset() { *m = SwInterfaceGetMacAddress{} } @@ -425,10 +2380,46 @@ func (*SwInterfaceGetMacAddress) GetMessageName() string { return "sw_i func (*SwInterfaceGetMacAddress) GetCrcString() string { return "f9e6675e" } func (*SwInterfaceGetMacAddress) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceGetMacAddress) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *SwInterfaceGetMacAddress) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceGetMacAddress) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceGetMacAddressReply represents VPP binary API message 'sw_interface_get_mac_address_reply'. type SwInterfaceGetMacAddressReply struct { - Retval int32 - MacAddress MacAddress + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + MacAddress MacAddress `binapi:"mac_address,name=mac_address" json:"mac_address,omitempty"` } func (m *SwInterfaceGetMacAddressReply) Reset() { *m = SwInterfaceGetMacAddressReply{} } @@ -438,10 +2429,62 @@ func (*SwInterfaceGetMacAddressReply) GetMessageName() string { func (*SwInterfaceGetMacAddressReply) GetCrcString() string { return "40ef2c08" } func (*SwInterfaceGetMacAddressReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SwInterfaceGetMacAddressReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.MacAddress + size += 6 + return size +} +func (m *SwInterfaceGetMacAddressReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.MacAddress + for i := 0; i < 6; i++ { + var x uint8 + if i < len(m.MacAddress) { + x = uint8(m.MacAddress[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + return buf, nil +} +func (m *SwInterfaceGetMacAddressReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.MacAddress + for i := 0; i < len(m.MacAddress); i++ { + m.MacAddress[i] = uint8(tmp[pos]) + pos += 1 + } + return nil +} + // SwInterfaceGetTable represents VPP binary API message 'sw_interface_get_table'. type SwInterfaceGetTable struct { - SwIfIndex InterfaceIndex - IsIPv6 bool + SwIfIndex 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{} } @@ -449,10 +2492,56 @@ func (*SwInterfaceGetTable) GetMessageName() string { return "sw_interf func (*SwInterfaceGetTable) GetCrcString() string { return "2d033de4" } func (*SwInterfaceGetTable) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceGetTable) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.IsIPv6 + size += 1 + return size +} +func (m *SwInterfaceGetTable) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.IsIPv6 + if m.IsIPv6 { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *SwInterfaceGetTable) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IsIPv6 + m.IsIPv6 = tmp[pos] != 0 + pos += 1 + return nil +} + // SwInterfaceGetTableReply represents VPP binary API message 'sw_interface_get_table_reply'. type SwInterfaceGetTableReply struct { - Retval int32 - VrfID uint32 + 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{} } @@ -460,12 +2549,56 @@ func (*SwInterfaceGetTableReply) GetMessageName() string { return "sw_i func (*SwInterfaceGetTableReply) GetCrcString() string { return "a6eb0109" } func (*SwInterfaceGetTableReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SwInterfaceGetTableReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.VrfID + size += 4 + return size +} +func (m *SwInterfaceGetTableReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.VrfID + o.PutUint32(buf[pos:pos+4], uint32(m.VrfID)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceGetTableReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.VrfID + m.VrfID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceRxPlacementDetails represents VPP binary API message 'sw_interface_rx_placement_details'. type SwInterfaceRxPlacementDetails struct { - SwIfIndex InterfaceIndex - QueueID uint32 - WorkerID uint32 - Mode RxMode + SwIfIndex 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 RxMode `binapi:"rx_mode,name=mode" json:"mode,omitempty"` } func (m *SwInterfaceRxPlacementDetails) Reset() { *m = SwInterfaceRxPlacementDetails{} } @@ -475,9 +2608,69 @@ func (*SwInterfaceRxPlacementDetails) GetMessageName() string { func (*SwInterfaceRxPlacementDetails) GetCrcString() string { return "f6d7d024" } func (*SwInterfaceRxPlacementDetails) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceRxPlacementDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.QueueID + size += 4 + // field[1] m.WorkerID + size += 4 + // field[1] m.Mode + size += 4 + return size +} +func (m *SwInterfaceRxPlacementDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.QueueID + o.PutUint32(buf[pos:pos+4], uint32(m.QueueID)) + pos += 4 + // field[1] m.WorkerID + o.PutUint32(buf[pos:pos+4], uint32(m.WorkerID)) + pos += 4 + // field[1] m.Mode + o.PutUint32(buf[pos:pos+4], uint32(m.Mode)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceRxPlacementDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.QueueID + m.QueueID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.WorkerID + m.WorkerID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Mode + m.Mode = RxMode(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceRxPlacementDump represents VPP binary API message 'sw_interface_rx_placement_dump'. type SwInterfaceRxPlacementDump struct { - SwIfIndex InterfaceIndex + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *SwInterfaceRxPlacementDump) Reset() { *m = SwInterfaceRxPlacementDump{} } @@ -485,10 +2678,46 @@ func (*SwInterfaceRxPlacementDump) GetMessageName() string { return "sw func (*SwInterfaceRxPlacementDump) GetCrcString() string { return "f9e6675e" } func (*SwInterfaceRxPlacementDump) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceRxPlacementDump) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *SwInterfaceRxPlacementDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceRxPlacementDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceSetFlags represents VPP binary API message 'sw_interface_set_flags'. type SwInterfaceSetFlags struct { - SwIfIndex InterfaceIndex - Flags IfStatusFlags + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Flags IfStatusFlags `binapi:"if_status_flags,name=flags" json:"flags,omitempty"` } func (m *SwInterfaceSetFlags) Reset() { *m = SwInterfaceSetFlags{} } @@ -496,9 +2725,53 @@ func (*SwInterfaceSetFlags) GetMessageName() string { return "sw_interf func (*SwInterfaceSetFlags) GetCrcString() string { return "6a2b491a" } func (*SwInterfaceSetFlags) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceSetFlags) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Flags + size += 4 + return size +} +func (m *SwInterfaceSetFlags) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Flags + o.PutUint32(buf[pos:pos+4], uint32(m.Flags)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceSetFlags) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Flags + m.Flags = IfStatusFlags(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceSetFlagsReply represents VPP binary API message 'sw_interface_set_flags_reply'. type SwInterfaceSetFlagsReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SwInterfaceSetFlagsReply) Reset() { *m = SwInterfaceSetFlagsReply{} } @@ -506,10 +2779,46 @@ func (*SwInterfaceSetFlagsReply) GetMessageName() string { return "sw_i func (*SwInterfaceSetFlagsReply) GetCrcString() string { return "e8d4e804" } func (*SwInterfaceSetFlagsReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SwInterfaceSetFlagsReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceSetFlagsReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceSetFlagsReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceSetIPDirectedBroadcast represents VPP binary API message 'sw_interface_set_ip_directed_broadcast'. type SwInterfaceSetIPDirectedBroadcast struct { - SwIfIndex InterfaceIndex - Enable bool + SwIfIndex 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{} } @@ -519,9 +2828,55 @@ func (*SwInterfaceSetIPDirectedBroadcast) GetMessageName() string { func (*SwInterfaceSetIPDirectedBroadcast) GetCrcString() string { return "ae6cfcfb" } func (*SwInterfaceSetIPDirectedBroadcast) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceSetIPDirectedBroadcast) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Enable + size += 1 + return size +} +func (m *SwInterfaceSetIPDirectedBroadcast) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Enable + if m.Enable { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *SwInterfaceSetIPDirectedBroadcast) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Enable + m.Enable = tmp[pos] != 0 + pos += 1 + return nil +} + // SwInterfaceSetIPDirectedBroadcastReply represents VPP binary API message 'sw_interface_set_ip_directed_broadcast_reply'. type SwInterfaceSetIPDirectedBroadcastReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SwInterfaceSetIPDirectedBroadcastReply) Reset() { @@ -535,10 +2890,46 @@ func (*SwInterfaceSetIPDirectedBroadcastReply) GetMessageType() api.MessageType return api.ReplyMessage } +func (m *SwInterfaceSetIPDirectedBroadcastReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceSetIPDirectedBroadcastReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceSetIPDirectedBroadcastReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceSetMacAddress represents VPP binary API message 'sw_interface_set_mac_address'. type SwInterfaceSetMacAddress struct { - SwIfIndex InterfaceIndex - MacAddress MacAddress + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + MacAddress MacAddress `binapi:"mac_address,name=mac_address" json:"mac_address,omitempty"` } func (m *SwInterfaceSetMacAddress) Reset() { *m = SwInterfaceSetMacAddress{} } @@ -546,9 +2937,61 @@ func (*SwInterfaceSetMacAddress) GetMessageName() string { return "sw_i func (*SwInterfaceSetMacAddress) GetCrcString() string { return "6aca746a" } func (*SwInterfaceSetMacAddress) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceSetMacAddress) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.MacAddress + size += 6 + return size +} +func (m *SwInterfaceSetMacAddress) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.MacAddress + for i := 0; i < 6; i++ { + var x uint8 + if i < len(m.MacAddress) { + x = uint8(m.MacAddress[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + return buf, nil +} +func (m *SwInterfaceSetMacAddress) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.MacAddress + for i := 0; i < len(m.MacAddress); i++ { + m.MacAddress[i] = uint8(tmp[pos]) + pos += 1 + } + return nil +} + // SwInterfaceSetMacAddressReply represents VPP binary API message 'sw_interface_set_mac_address_reply'. type SwInterfaceSetMacAddressReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SwInterfaceSetMacAddressReply) Reset() { *m = SwInterfaceSetMacAddressReply{} } @@ -558,10 +3001,46 @@ func (*SwInterfaceSetMacAddressReply) GetMessageName() string { func (*SwInterfaceSetMacAddressReply) GetCrcString() string { return "e8d4e804" } func (*SwInterfaceSetMacAddressReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SwInterfaceSetMacAddressReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceSetMacAddressReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceSetMacAddressReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceSetMtu represents VPP binary API message 'sw_interface_set_mtu'. type SwInterfaceSetMtu struct { - SwIfIndex InterfaceIndex - Mtu []uint32 `struc:"[4]uint32"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Mtu []uint32 `binapi:"u32[4],name=mtu" json:"mtu,omitempty" struc:"[4]uint32"` } func (m *SwInterfaceSetMtu) Reset() { *m = SwInterfaceSetMtu{} } @@ -569,9 +3048,62 @@ func (*SwInterfaceSetMtu) GetMessageName() string { return "sw_interfac func (*SwInterfaceSetMtu) GetCrcString() string { return "5cbe85e5" } func (*SwInterfaceSetMtu) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceSetMtu) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Mtu + size += 16 + return size +} +func (m *SwInterfaceSetMtu) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Mtu + for i := 0; i < 4; i++ { + var x uint32 + if i < len(m.Mtu) { + x = uint32(m.Mtu[i]) + } + o.PutUint32(buf[pos:pos+4], uint32(x)) + pos += 4 + } + return buf, nil +} +func (m *SwInterfaceSetMtu) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Mtu + m.Mtu = make([]uint32, 4) + for i := 0; i < len(m.Mtu); i++ { + m.Mtu[i] = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + } + return nil +} + // SwInterfaceSetMtuReply represents VPP binary API message 'sw_interface_set_mtu_reply'. type SwInterfaceSetMtuReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SwInterfaceSetMtuReply) Reset() { *m = SwInterfaceSetMtuReply{} } @@ -579,12 +3111,48 @@ func (*SwInterfaceSetMtuReply) GetMessageName() string { return "sw_int func (*SwInterfaceSetMtuReply) GetCrcString() string { return "e8d4e804" } func (*SwInterfaceSetMtuReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SwInterfaceSetMtuReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceSetMtuReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceSetMtuReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceSetRxMode represents VPP binary API message 'sw_interface_set_rx_mode'. type SwInterfaceSetRxMode struct { - SwIfIndex InterfaceIndex - QueueIDValid bool - QueueID uint32 - Mode RxMode + SwIfIndex 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 RxMode `binapi:"rx_mode,name=mode" json:"mode,omitempty"` } func (m *SwInterfaceSetRxMode) Reset() { *m = SwInterfaceSetRxMode{} } @@ -592,9 +3160,71 @@ func (*SwInterfaceSetRxMode) GetMessageName() string { return "sw_inter func (*SwInterfaceSetRxMode) GetCrcString() string { return "780f5cee" } func (*SwInterfaceSetRxMode) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceSetRxMode) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.QueueIDValid + size += 1 + // field[1] m.QueueID + size += 4 + // field[1] m.Mode + size += 4 + return size +} +func (m *SwInterfaceSetRxMode) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.QueueIDValid + if m.QueueIDValid { + buf[pos] = 1 + } + pos += 1 + // field[1] m.QueueID + o.PutUint32(buf[pos:pos+4], uint32(m.QueueID)) + pos += 4 + // field[1] m.Mode + o.PutUint32(buf[pos:pos+4], uint32(m.Mode)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceSetRxMode) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.QueueIDValid + m.QueueIDValid = tmp[pos] != 0 + pos += 1 + // field[1] m.QueueID + m.QueueID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Mode + m.Mode = RxMode(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceSetRxModeReply represents VPP binary API message 'sw_interface_set_rx_mode_reply'. type SwInterfaceSetRxModeReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SwInterfaceSetRxModeReply) Reset() { *m = SwInterfaceSetRxModeReply{} } @@ -602,12 +3232,48 @@ func (*SwInterfaceSetRxModeReply) GetMessageName() string { return "sw_ func (*SwInterfaceSetRxModeReply) GetCrcString() string { return "e8d4e804" } func (*SwInterfaceSetRxModeReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SwInterfaceSetRxModeReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceSetRxModeReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceSetRxModeReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceSetRxPlacement represents VPP binary API message 'sw_interface_set_rx_placement'. type SwInterfaceSetRxPlacement struct { - SwIfIndex InterfaceIndex - QueueID uint32 - WorkerID uint32 - IsMain bool + SwIfIndex 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{} } @@ -615,9 +3281,71 @@ func (*SwInterfaceSetRxPlacement) GetMessageName() string { return "sw_ func (*SwInterfaceSetRxPlacement) GetCrcString() string { return "db65f3c9" } func (*SwInterfaceSetRxPlacement) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceSetRxPlacement) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.QueueID + size += 4 + // field[1] m.WorkerID + size += 4 + // field[1] m.IsMain + size += 1 + return size +} +func (m *SwInterfaceSetRxPlacement) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.QueueID + o.PutUint32(buf[pos:pos+4], uint32(m.QueueID)) + pos += 4 + // field[1] m.WorkerID + o.PutUint32(buf[pos:pos+4], uint32(m.WorkerID)) + pos += 4 + // field[1] m.IsMain + if m.IsMain { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *SwInterfaceSetRxPlacement) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.QueueID + m.QueueID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.WorkerID + m.WorkerID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IsMain + m.IsMain = tmp[pos] != 0 + pos += 1 + return nil +} + // SwInterfaceSetRxPlacementReply represents VPP binary API message 'sw_interface_set_rx_placement_reply'. type SwInterfaceSetRxPlacementReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SwInterfaceSetRxPlacementReply) Reset() { *m = SwInterfaceSetRxPlacementReply{} } @@ -627,11 +3355,47 @@ func (*SwInterfaceSetRxPlacementReply) GetMessageName() string { func (*SwInterfaceSetRxPlacementReply) GetCrcString() string { return "e8d4e804" } func (*SwInterfaceSetRxPlacementReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SwInterfaceSetRxPlacementReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceSetRxPlacementReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceSetRxPlacementReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceSetTable represents VPP binary API message 'sw_interface_set_table'. type SwInterfaceSetTable struct { - SwIfIndex InterfaceIndex - IsIPv6 bool - VrfID uint32 + SwIfIndex 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{} } @@ -639,9 +3403,63 @@ func (*SwInterfaceSetTable) GetMessageName() string { return "sw_interf func (*SwInterfaceSetTable) GetCrcString() string { return "df42a577" } func (*SwInterfaceSetTable) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceSetTable) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.IsIPv6 + size += 1 + // field[1] m.VrfID + size += 4 + return size +} +func (m *SwInterfaceSetTable) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.IsIPv6 + if m.IsIPv6 { + buf[pos] = 1 + } + pos += 1 + // field[1] m.VrfID + o.PutUint32(buf[pos:pos+4], uint32(m.VrfID)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceSetTable) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IsIPv6 + m.IsIPv6 = tmp[pos] != 0 + pos += 1 + // field[1] m.VrfID + m.VrfID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceSetTableReply represents VPP binary API message 'sw_interface_set_table_reply'. type SwInterfaceSetTableReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SwInterfaceSetTableReply) Reset() { *m = SwInterfaceSetTableReply{} } @@ -649,11 +3467,47 @@ func (*SwInterfaceSetTableReply) GetMessageName() string { return "sw_i func (*SwInterfaceSetTableReply) GetCrcString() string { return "e8d4e804" } func (*SwInterfaceSetTableReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SwInterfaceSetTableReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceSetTableReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceSetTableReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceSetUnnumbered represents VPP binary API message 'sw_interface_set_unnumbered'. type SwInterfaceSetUnnumbered struct { - SwIfIndex InterfaceIndex - UnnumberedSwIfIndex InterfaceIndex - IsAdd bool + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + UnnumberedSwIfIndex 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{} } @@ -661,9 +3515,63 @@ func (*SwInterfaceSetUnnumbered) GetMessageName() string { return "sw_i func (*SwInterfaceSetUnnumbered) GetCrcString() string { return "938ef33b" } func (*SwInterfaceSetUnnumbered) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceSetUnnumbered) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.UnnumberedSwIfIndex + size += 4 + // field[1] m.IsAdd + size += 1 + return size +} +func (m *SwInterfaceSetUnnumbered) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.UnnumberedSwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.UnnumberedSwIfIndex)) + pos += 4 + // field[1] m.IsAdd + if m.IsAdd { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *SwInterfaceSetUnnumbered) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.UnnumberedSwIfIndex + m.UnnumberedSwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IsAdd + m.IsAdd = tmp[pos] != 0 + pos += 1 + return nil +} + // SwInterfaceSetUnnumberedReply represents VPP binary API message 'sw_interface_set_unnumbered_reply'. type SwInterfaceSetUnnumberedReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SwInterfaceSetUnnumberedReply) Reset() { *m = SwInterfaceSetUnnumberedReply{} } @@ -673,11 +3581,47 @@ func (*SwInterfaceSetUnnumberedReply) GetMessageName() string { func (*SwInterfaceSetUnnumberedReply) GetCrcString() string { return "e8d4e804" } func (*SwInterfaceSetUnnumberedReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SwInterfaceSetUnnumberedReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceSetUnnumberedReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceSetUnnumberedReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceTagAddDel represents VPP binary API message 'sw_interface_tag_add_del'. type SwInterfaceTagAddDel struct { - IsAdd bool - SwIfIndex InterfaceIndex - Tag string `struc:"[64]byte"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` } func (m *SwInterfaceTagAddDel) Reset() { *m = SwInterfaceTagAddDel{} } @@ -685,9 +3629,66 @@ func (*SwInterfaceTagAddDel) GetMessageName() string { return "sw_inter func (*SwInterfaceTagAddDel) GetCrcString() string { return "426f8bc1" } func (*SwInterfaceTagAddDel) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceTagAddDel) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.IsAdd + size += 1 + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Tag + size += 64 + return size +} +func (m *SwInterfaceTagAddDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.IsAdd + if m.IsAdd { + buf[pos] = 1 + } + pos += 1 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Tag + copy(buf[pos:pos+64], m.Tag) + pos += 64 + return buf, nil +} +func (m *SwInterfaceTagAddDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.IsAdd + m.IsAdd = tmp[pos] != 0 + pos += 1 + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Tag + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Tag = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // SwInterfaceTagAddDelReply represents VPP binary API message 'sw_interface_tag_add_del_reply'. type SwInterfaceTagAddDelReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SwInterfaceTagAddDelReply) Reset() { *m = SwInterfaceTagAddDelReply{} } @@ -695,10 +3696,46 @@ func (*SwInterfaceTagAddDelReply) GetMessageName() string { return "sw_ func (*SwInterfaceTagAddDelReply) GetCrcString() string { return "e8d4e804" } func (*SwInterfaceTagAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SwInterfaceTagAddDelReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceTagAddDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceTagAddDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // WantInterfaceEvents represents VPP binary API message 'want_interface_events'. type WantInterfaceEvents struct { - EnableDisable uint32 - PID uint32 + 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{} } @@ -706,9 +3743,53 @@ func (*WantInterfaceEvents) GetMessageName() string { return "want_inte func (*WantInterfaceEvents) GetCrcString() string { return "476f5a08" } func (*WantInterfaceEvents) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *WantInterfaceEvents) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.EnableDisable + size += 4 + // field[1] m.PID + size += 4 + return size +} +func (m *WantInterfaceEvents) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.EnableDisable + o.PutUint32(buf[pos:pos+4], uint32(m.EnableDisable)) + pos += 4 + // field[1] m.PID + o.PutUint32(buf[pos:pos+4], uint32(m.PID)) + pos += 4 + return buf, nil +} +func (m *WantInterfaceEvents) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.EnableDisable + m.EnableDisable = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.PID + m.PID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // WantInterfaceEventsReply represents VPP binary API message 'want_interface_events_reply'. type WantInterfaceEventsReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *WantInterfaceEventsReply) Reset() { *m = WantInterfaceEventsReply{} } @@ -716,7 +3797,44 @@ func (*WantInterfaceEventsReply) GetMessageName() string { return "want func (*WantInterfaceEventsReply) GetCrcString() string { return "e8d4e804" } func (*WantInterfaceEventsReply) GetMessageType() api.MessageType { return api.ReplyMessage } -func init() { +func (m *WantInterfaceEventsReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *WantInterfaceEventsReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *WantInterfaceEventsReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + +func init() { file_interfaces_binapi_init() } +func file_interfaces_binapi_init() { api.RegisterMessage((*CollectDetailedInterfaceStats)(nil), "interface.CollectDetailedInterfaceStats") api.RegisterMessage((*CollectDetailedInterfaceStatsReply)(nil), "interface.CollectDetailedInterfaceStatsReply") api.RegisterMessage((*CreateLoopback)(nil), "interface.CreateLoopback") @@ -831,322 +3949,13 @@ func AllMessages() []api.Message { } } -// 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 _ = codec.DecodeString var _ = bytes.NewBuffer var _ = context.Background var _ = io.Copy var _ = strconv.Itoa var _ = struc.Pack +var _ = binary.BigEndian +var _ = math.Float32bits diff --git a/examples/binapi/interfaces/interfaces_rpc.ba.go b/examples/binapi/interfaces/interfaces_rpc.ba.go new file mode 100644 index 0000000..e30aed9 --- /dev/null +++ b/examples/binapi/interfaces/interfaces_rpc.ba.go @@ -0,0 +1,321 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package interfaces + +import ( + "context" + "io" + + api "git.fd.io/govpp.git/api" +) + +// 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 +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = context.Background +var _ = io.Copy diff --git a/examples/binapi/ip/ip.ba.go b/examples/binapi/ip/ip.ba.go index f02cc9e..b15a489 100644 --- a/examples/binapi/ip/ip.ba.go +++ b/examples/binapi/ip/ip.ba.go @@ -1,33 +1,40 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty +// VPP: 20.01-45~g7a071e370~b63 // source: /usr/share/vpp/api/core/ip.api.json /* -Package ip is a generated VPP binary API for 'ip' module. +Package ip contains generated code for VPP binary API defined by ip.api (version 3.0.1). It consists of: - 15 enums 7 aliases + 15 enums + 60 messages 14 types 1 union - 60 messages - 30 services */ package ip import ( "bytes" "context" + "encoding/binary" "io" + "math" "strconv" api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" struc "github.com/lunixbochs/struc" - - ethernet_types "git.fd.io/govpp.git/examples/binapi/ethernet_types" - interface_types "git.fd.io/govpp.git/examples/binapi/interface_types" - ip_types "git.fd.io/govpp.git/examples/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 // please upgrade the GoVPP api package + const ( // ModuleName is the name of this module. ModuleName = "ip" @@ -37,7 +44,32 @@ const ( VersionCrc = 0xfc3fea46 ) -type AddressFamily = ip_types.AddressFamily +// 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", + } + 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 "AddressFamily(" + strconv.Itoa(int(x)) + ")" +} // FibPathFlags represents VPP binary API enum 'fib_path_flags'. type FibPathFlags uint32 @@ -49,26 +81,27 @@ const ( 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, -} +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 } - return strconv.Itoa(int(x)) + return "FibPathFlags(" + strconv.Itoa(int(x)) + ")" } // FibPathNhProto represents VPP binary API enum 'fib_path_nh_proto'. @@ -82,28 +115,29 @@ const ( 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, -} +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", + } + 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)) + return "FibPathNhProto(" + strconv.Itoa(int(x)) + ")" } // FibPathType represents VPP binary API enum 'fib_path_type'. @@ -123,51 +157,276 @@ const ( 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, -} +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", + } + 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)) + return "FibPathType(" + strconv.Itoa(int(x)) + ")" +} + +// 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", + } + 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 "IfStatusFlags(" + 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", + } + 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 "IfType(" + strconv.Itoa(int(x)) + ")" } -type IfStatusFlags = interface_types.IfStatusFlags +// IPDscp represents VPP binary API enum 'ip_dscp'. +type IPDscp uint8 -type IfType = interface_types.IfType +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 +) -type IPDscp = ip_types.IPDscp +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, + } +) -type IPEcn = ip_types.IPEcn +func (x IPDscp) String() string { + s, ok := IPDscp_name[uint8(x)] + if ok { + return s + } + return "IPDscp(" + strconv.Itoa(int(x)) + ")" +} -type IPProto = ip_types.IPProto +// 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", + } + 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)) + ")" +} + +// 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", + } + 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 "IPProto(" + strconv.Itoa(int(x)) + ")" +} // IPReassType represents VPP binary API enum 'ip_reass_type'. type IPReassType uint32 @@ -177,25 +436,54 @@ const ( 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, -} +var ( + IPReassType_name = map[uint32]string{ + 0: "IP_REASS_TYPE_FULL", + 1: "IP_REASS_TYPE_SHALLOW_VIRTUAL", + } + 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)) + return "IPReassType(" + strconv.Itoa(int(x)) + ")" } -type LinkDuplex = interface_types.LinkDuplex +// 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", + } + 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 "LinkDuplex(" + strconv.Itoa(int(x)) + ")" +} // MfibItfFlags represents VPP binary API enum 'mfib_itf_flags'. type MfibItfFlags uint32 @@ -209,155 +497,357 @@ const ( 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_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", + } + 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 "MfibItfFlags(" + strconv.Itoa(int(x)) + ")" } -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, +// 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", + } + 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 "MtuProto(" + strconv.Itoa(int(x)) + ")" } -func (x MfibItfFlags) String() string { - s, ok := MfibItfFlags_name[uint32(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", + } + 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)) + return "RxMode(" + strconv.Itoa(int(x)) + ")" } -type MtuProto = interface_types.MtuProto +// SubIfFlags represents VPP binary API enum 'sub_if_flags'. +type SubIfFlags uint32 -type RxMode = interface_types.RxMode +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", + } + 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 "SubIfFlags(" + strconv.Itoa(int(x)) + ")" +} -type SubIfFlags = interface_types.SubIfFlags +// AddressWithPrefix represents VPP binary API alias 'address_with_prefix'. +type AddressWithPrefix Prefix -type AddressWithPrefix = ip_types.AddressWithPrefix +// InterfaceIndex represents VPP binary API alias 'interface_index'. +type InterfaceIndex uint32 -type InterfaceIndex = interface_types.InterfaceIndex +// IP4Address represents VPP binary API alias 'ip4_address'. +type IP4Address [4]uint8 -type IP4Address = ip_types.IP4Address +// IP4AddressWithPrefix represents VPP binary API alias 'ip4_address_with_prefix'. +type IP4AddressWithPrefix IP4Prefix -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix +// IP6Address represents VPP binary API alias 'ip6_address'. +type IP6Address [16]uint8 -type IP6Address = ip_types.IP6Address +// IP6AddressWithPrefix represents VPP binary API alias 'ip6_address_with_prefix'. +type IP6AddressWithPrefix IP6Prefix -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix +// MacAddress represents VPP binary API alias 'mac_address'. +type MacAddress [6]uint8 -type MacAddress = ethernet_types.MacAddress +// Address represents VPP binary API 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"` +} -type Address = ip_types.Address +func (*Address) GetTypeName() string { return "address" } // FibMplsLabel represents VPP binary API type 'fib_mpls_label'. type FibMplsLabel struct { - IsUniform uint8 - Label uint32 - TTL uint8 - Exp uint8 + IsUniform uint8 `binapi:"u8,name=is_uniform" json:"is_uniform,omitempty"` + Label uint32 `binapi:"u32,name=label" json:"label,omitempty"` + TTL uint8 `binapi:"u8,name=ttl" json:"ttl,omitempty"` + Exp uint8 `binapi:"u8,name=exp" json:"exp,omitempty"` } 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"` + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + RpfID uint32 `binapi:"u32,name=rpf_id" json:"rpf_id,omitempty"` + Weight uint8 `binapi:"u8,name=weight" json:"weight,omitempty"` + Preference uint8 `binapi:"u8,name=preference" json:"preference,omitempty"` + Type FibPathType `binapi:"fib_path_type,name=type" json:"type,omitempty"` + Flags FibPathFlags `binapi:"fib_path_flags,name=flags" json:"flags,omitempty"` + Proto FibPathNhProto `binapi:"fib_path_nh_proto,name=proto" json:"proto,omitempty"` + Nh FibPathNh `binapi:"fib_path_nh,name=nh" json:"nh,omitempty"` + NLabels uint8 `binapi:"u8,name=n_labels" json:"n_labels,omitempty"` + LabelStack [16]FibMplsLabel `binapi:"fib_mpls_label[16],name=label_stack" json:"label_stack,omitempty" 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 + Address AddressUnion `binapi:"address_union,name=address" json:"address,omitempty"` + ViaLabel uint32 `binapi:"u32,name=via_label" json:"via_label,omitempty"` + ObjID uint32 `binapi:"u32,name=obj_id" json:"obj_id,omitempty"` + ClassifyTableIndex uint32 `binapi:"u32,name=classify_table_index" json:"classify_table_index,omitempty"` } func (*FibPathNh) GetTypeName() string { return "fib_path_nh" } -type IP4Prefix = ip_types.IP4Prefix +// IP4Prefix represents VPP binary API 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 (*IP4Prefix) GetTypeName() string { return "ip4_prefix" } + +// IP6Prefix represents VPP binary API 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"` +} -type IP6Prefix = ip_types.IP6Prefix +func (*IP6Prefix) GetTypeName() string { return "ip6_prefix" } // 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 + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + EntryFlags uint32 `binapi:"u32,name=entry_flags" json:"entry_flags,omitempty"` + RpfID uint32 `binapi:"u32,name=rpf_id" json:"rpf_id,omitempty"` + Prefix Mprefix `binapi:"mprefix,name=prefix" json:"prefix,omitempty"` + NPaths uint8 `binapi:"u8,name=n_paths" json:"n_paths,omitempty" struc:"sizeof=Paths"` + Paths []MfibPath `binapi:"mfib_path[n_paths],name=paths" json:"paths,omitempty"` } 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 + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + StatsIndex uint32 `binapi:"u32,name=stats_index" json:"stats_index,omitempty"` + Prefix Prefix `binapi:"prefix,name=prefix" json:"prefix,omitempty"` + NPaths uint8 `binapi:"u8,name=n_paths" json:"n_paths,omitempty" struc:"sizeof=Paths"` + Paths []FibPath `binapi:"fib_path[n_paths],name=paths" json:"paths,omitempty"` } 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"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + IsIP6 bool `binapi:"bool,name=is_ip6" json:"is_ip6,omitempty"` + Name string `binapi:"string[64],name=name" json:"name,omitempty" 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 + ItfFlags MfibItfFlags `binapi:"mfib_itf_flags,name=itf_flags" json:"itf_flags,omitempty"` + Path FibPath `binapi:"fib_path,name=path" json:"path,omitempty"` } func (*MfibPath) GetTypeName() string { return "mfib_path" } -type Mprefix = ip_types.Mprefix +// Mprefix represents VPP binary API 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"` +} + +func (*Mprefix) GetTypeName() string { return "mprefix" } -type Prefix = ip_types.Prefix +// Prefix represents VPP binary API type 'prefix'. +type Prefix struct { + Address Address `binapi:"address,name=address" json:"address,omitempty"` + Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` +} -type PrefixMatcher = ip_types.PrefixMatcher +func (*Prefix) GetTypeName() string { return "prefix" } + +// PrefixMatcher represents VPP binary API type 'prefix_matcher'. +type PrefixMatcher struct { + Le uint8 `binapi:"u8,name=le" json:"le,omitempty"` + Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"` +} + +func (*PrefixMatcher) GetTypeName() string { return "prefix_matcher" } // PuntRedirect represents VPP binary API type 'punt_redirect'. type PuntRedirect struct { - RxSwIfIndex InterfaceIndex - TxSwIfIndex InterfaceIndex - Nh Address + RxSwIfIndex InterfaceIndex `binapi:"interface_index,name=rx_sw_if_index" json:"rx_sw_if_index,omitempty"` + TxSwIfIndex InterfaceIndex `binapi:"interface_index,name=tx_sw_if_index" json:"tx_sw_if_index,omitempty"` + Nh Address `binapi:"address,name=nh" json:"nh,omitempty"` } func (*PuntRedirect) GetTypeName() string { return "punt_redirect" } -type AddressUnion = ip_types.AddressUnion +// 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 +} // IoamDisable represents VPP binary API message 'ioam_disable'. type IoamDisable struct { - ID uint16 + ID uint16 `binapi:"u16,name=id" json:"id,omitempty"` } func (m *IoamDisable) Reset() { *m = IoamDisable{} } @@ -365,9 +855,45 @@ func (*IoamDisable) GetMessageName() string { return "ioam_disable" } func (*IoamDisable) GetCrcString() string { return "6b16a45e" } func (*IoamDisable) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IoamDisable) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.ID + size += 2 + return size +} +func (m *IoamDisable) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.ID + o.PutUint16(buf[pos:pos+2], uint16(m.ID)) + pos += 2 + return buf, nil +} +func (m *IoamDisable) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.ID + m.ID = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + return nil +} + // IoamDisableReply represents VPP binary API message 'ioam_disable_reply'. type IoamDisableReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *IoamDisableReply) Reset() { *m = IoamDisableReply{} } @@ -375,14 +901,50 @@ func (*IoamDisableReply) GetMessageName() string { return "ioam_disable func (*IoamDisableReply) GetCrcString() string { return "e8d4e804" } func (*IoamDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IoamDisableReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *IoamDisableReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *IoamDisableReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IoamEnable represents VPP binary API message 'ioam_enable'. type IoamEnable struct { - ID uint16 - Seqno bool - Analyse bool - PotEnable bool - TraceEnable bool - NodeID uint32 + ID uint16 `binapi:"u16,name=id" json:"id,omitempty"` + Seqno bool `binapi:"bool,name=seqno" json:"seqno,omitempty"` + Analyse bool `binapi:"bool,name=analyse" json:"analyse,omitempty"` + PotEnable bool `binapi:"bool,name=pot_enable" json:"pot_enable,omitempty"` + TraceEnable bool `binapi:"bool,name=trace_enable" json:"trace_enable,omitempty"` + NodeID uint32 `binapi:"u32,name=node_id" json:"node_id,omitempty"` } func (m *IoamEnable) Reset() { *m = IoamEnable{} } @@ -390,9 +952,93 @@ func (*IoamEnable) GetMessageName() string { return "ioam_enable" } func (*IoamEnable) GetCrcString() string { return "51ccd868" } func (*IoamEnable) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IoamEnable) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.ID + size += 2 + // field[1] m.Seqno + size += 1 + // field[1] m.Analyse + size += 1 + // field[1] m.PotEnable + size += 1 + // field[1] m.TraceEnable + size += 1 + // field[1] m.NodeID + size += 4 + return size +} +func (m *IoamEnable) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.ID + o.PutUint16(buf[pos:pos+2], uint16(m.ID)) + pos += 2 + // field[1] m.Seqno + if m.Seqno { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Analyse + if m.Analyse { + buf[pos] = 1 + } + pos += 1 + // field[1] m.PotEnable + if m.PotEnable { + buf[pos] = 1 + } + pos += 1 + // field[1] m.TraceEnable + if m.TraceEnable { + buf[pos] = 1 + } + pos += 1 + // field[1] m.NodeID + o.PutUint32(buf[pos:pos+4], uint32(m.NodeID)) + pos += 4 + return buf, nil +} +func (m *IoamEnable) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.ID + m.ID = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[1] m.Seqno + m.Seqno = tmp[pos] != 0 + pos += 1 + // field[1] m.Analyse + m.Analyse = tmp[pos] != 0 + pos += 1 + // field[1] m.PotEnable + m.PotEnable = tmp[pos] != 0 + pos += 1 + // field[1] m.TraceEnable + m.TraceEnable = tmp[pos] != 0 + pos += 1 + // field[1] m.NodeID + m.NodeID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IoamEnableReply represents VPP binary API message 'ioam_enable_reply'. type IoamEnableReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *IoamEnableReply) Reset() { *m = IoamEnableReply{} } @@ -400,10 +1046,46 @@ func (*IoamEnableReply) GetMessageName() string { return "ioam_enable_r func (*IoamEnableReply) GetCrcString() string { return "e8d4e804" } func (*IoamEnableReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IoamEnableReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *IoamEnableReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *IoamEnableReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPAddressDetails represents VPP binary API message 'ip_address_details'. type IPAddressDetails struct { - SwIfIndex InterfaceIndex - Prefix AddressWithPrefix + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Prefix AddressWithPrefix `binapi:"address_with_prefix,name=prefix" json:"prefix,omitempty"` } func (m *IPAddressDetails) Reset() { *m = IPAddressDetails{} } @@ -411,10 +1093,76 @@ func (*IPAddressDetails) GetMessageName() string { return "ip_address_d func (*IPAddressDetails) GetCrcString() string { return "b1199745" } func (*IPAddressDetails) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPAddressDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + size += 4 + // field[3] m.Prefix.Address.Un + size += 16 + // field[2] m.Prefix.Len + size += 1 + return size +} +func (m *IPAddressDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + o.PutUint32(buf[pos:pos+4], uint32(m.Prefix.Address.Af)) + pos += 4 + // field[3] m.Prefix.Address.Un + copy(buf[pos:pos+16], m.Prefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[2] m.Prefix.Len + buf[pos] = uint8(m.Prefix.Len) + pos += 1 + return buf, nil +} +func (m *IPAddressDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + m.Prefix.Address.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Prefix.Address.Un + copy(m.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[2] m.Prefix.Len + m.Prefix.Len = uint8(tmp[pos]) + pos += 1 + return nil +} + // IPAddressDump represents VPP binary API message 'ip_address_dump'. type IPAddressDump struct { - SwIfIndex InterfaceIndex - IsIPv6 bool + SwIfIndex 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 *IPAddressDump) Reset() { *m = IPAddressDump{} } @@ -422,11 +1170,57 @@ func (*IPAddressDump) GetMessageName() string { return "ip_address_dump func (*IPAddressDump) GetCrcString() string { return "2d033de4" } func (*IPAddressDump) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPAddressDump) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.IsIPv6 + size += 1 + return size +} +func (m *IPAddressDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.IsIPv6 + if m.IsIPv6 { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *IPAddressDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IsIPv6 + m.IsIPv6 = tmp[pos] != 0 + pos += 1 + return nil +} + // IPContainerProxyAddDel represents VPP binary API message 'ip_container_proxy_add_del'. type IPContainerProxyAddDel struct { - Pfx Prefix - SwIfIndex InterfaceIndex - IsAdd bool + Pfx Prefix `binapi:"prefix,name=pfx" json:"pfx,omitempty"` + SwIfIndex 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"` } func (m *IPContainerProxyAddDel) Reset() { *m = IPContainerProxyAddDel{} } @@ -434,9 +1228,85 @@ func (*IPContainerProxyAddDel) GetMessageName() string { return "ip_con func (*IPContainerProxyAddDel) GetCrcString() string { return "91189f40" } func (*IPContainerProxyAddDel) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPContainerProxyAddDel) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Pfx + // field[2] m.Pfx.Address + // field[3] m.Pfx.Address.Af + size += 4 + // field[3] m.Pfx.Address.Un + size += 16 + // field[2] m.Pfx.Len + size += 1 + // field[1] m.SwIfIndex + size += 4 + // field[1] m.IsAdd + size += 1 + return size +} +func (m *IPContainerProxyAddDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Pfx + // field[2] m.Pfx.Address + // field[3] m.Pfx.Address.Af + o.PutUint32(buf[pos:pos+4], uint32(m.Pfx.Address.Af)) + pos += 4 + // field[3] m.Pfx.Address.Un + copy(buf[pos:pos+16], m.Pfx.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[2] m.Pfx.Len + buf[pos] = uint8(m.Pfx.Len) + pos += 1 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.IsAdd + if m.IsAdd { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *IPContainerProxyAddDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Pfx + // field[2] m.Pfx.Address + // field[3] m.Pfx.Address.Af + m.Pfx.Address.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Pfx.Address.Un + copy(m.Pfx.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[2] m.Pfx.Len + m.Pfx.Len = uint8(tmp[pos]) + pos += 1 + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IsAdd + m.IsAdd = tmp[pos] != 0 + pos += 1 + return nil +} + // IPContainerProxyAddDelReply represents VPP binary API message 'ip_container_proxy_add_del_reply'. type IPContainerProxyAddDelReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *IPContainerProxyAddDelReply) Reset() { *m = IPContainerProxyAddDelReply{} } @@ -446,10 +1316,46 @@ func (*IPContainerProxyAddDelReply) GetMessageName() string { func (*IPContainerProxyAddDelReply) GetCrcString() string { return "e8d4e804" } func (*IPContainerProxyAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPContainerProxyAddDelReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *IPContainerProxyAddDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *IPContainerProxyAddDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPContainerProxyDetails represents VPP binary API message 'ip_container_proxy_details'. type IPContainerProxyDetails struct { - SwIfIndex InterfaceIndex - Prefix Prefix + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Prefix Prefix `binapi:"prefix,name=prefix" json:"prefix,omitempty"` } func (m *IPContainerProxyDetails) Reset() { *m = IPContainerProxyDetails{} } @@ -457,6 +1363,72 @@ func (*IPContainerProxyDetails) GetMessageName() string { return "ip_co func (*IPContainerProxyDetails) GetCrcString() string { return "0ee460e8" } func (*IPContainerProxyDetails) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPContainerProxyDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + size += 4 + // field[3] m.Prefix.Address.Un + size += 16 + // field[2] m.Prefix.Len + size += 1 + return size +} +func (m *IPContainerProxyDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + o.PutUint32(buf[pos:pos+4], uint32(m.Prefix.Address.Af)) + pos += 4 + // field[3] m.Prefix.Address.Un + copy(buf[pos:pos+16], m.Prefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[2] m.Prefix.Len + buf[pos] = uint8(m.Prefix.Len) + pos += 1 + return buf, nil +} +func (m *IPContainerProxyDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + m.Prefix.Address.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Prefix.Address.Un + copy(m.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[2] m.Prefix.Len + m.Prefix.Len = uint8(tmp[pos]) + pos += 1 + return nil +} + // IPContainerProxyDump represents VPP binary API message 'ip_container_proxy_dump'. type IPContainerProxyDump struct{} @@ -465,10 +1437,38 @@ func (*IPContainerProxyDump) GetMessageName() string { return "ip_conta func (*IPContainerProxyDump) GetCrcString() string { return "51077d14" } func (*IPContainerProxyDump) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPContainerProxyDump) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *IPContainerProxyDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *IPContainerProxyDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + // IPDetails represents VPP binary API message 'ip_details'. type IPDetails struct { - SwIfIndex InterfaceIndex - IsIPv6 bool + SwIfIndex 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 *IPDetails) Reset() { *m = IPDetails{} } @@ -476,9 +1476,55 @@ func (*IPDetails) GetMessageName() string { return "ip_details" } func (*IPDetails) GetCrcString() string { return "eb152d07" } func (*IPDetails) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.IsIPv6 + size += 1 + return size +} +func (m *IPDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.IsIPv6 + if m.IsIPv6 { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *IPDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IsIPv6 + m.IsIPv6 = tmp[pos] != 0 + pos += 1 + return nil +} + // IPDump represents VPP binary API message 'ip_dump'. type IPDump struct { - IsIPv6 bool + IsIPv6 bool `binapi:"bool,name=is_ipv6" json:"is_ipv6,omitempty"` } func (m *IPDump) Reset() { *m = IPDump{} } @@ -486,11 +1532,49 @@ func (*IPDump) GetMessageName() string { return "ip_dump" } func (*IPDump) GetCrcString() string { return "98d231ca" } func (*IPDump) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPDump) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.IsIPv6 + size += 1 + return size +} +func (m *IPDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.IsIPv6 + if m.IsIPv6 { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *IPDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.IsIPv6 + m.IsIPv6 = tmp[pos] != 0 + pos += 1 + return nil +} + // IPMrouteAddDel represents VPP binary API message 'ip_mroute_add_del'. type IPMrouteAddDel struct { - IsAdd bool - IsMultipath bool - Route IPMroute + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + IsMultipath bool `binapi:"bool,name=is_multipath" json:"is_multipath,omitempty"` + Route IPMroute `binapi:"ip_mroute,name=route" json:"route,omitempty"` } func (m *IPMrouteAddDel) Reset() { *m = IPMrouteAddDel{} } @@ -498,10 +1582,315 @@ func (*IPMrouteAddDel) GetMessageName() string { return "ip_mroute_add_ func (*IPMrouteAddDel) GetCrcString() string { return "f6627d17" } func (*IPMrouteAddDel) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPMrouteAddDel) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.IsAdd + size += 1 + // field[1] m.IsMultipath + size += 1 + // field[1] m.Route + // field[2] m.Route.TableID + size += 4 + // field[2] m.Route.EntryFlags + size += 4 + // field[2] m.Route.RpfID + size += 4 + // field[2] m.Route.Prefix + // field[3] m.Route.Prefix.Af + size += 4 + // field[3] m.Route.Prefix.GrpAddressLength + size += 2 + // field[3] m.Route.Prefix.GrpAddress + size += 16 + // field[3] m.Route.Prefix.SrcAddress + size += 16 + // field[2] m.Route.NPaths + size += 1 + // field[2] m.Route.Paths + for j2 := 0; j2 < len(m.Route.Paths); j2++ { + var s2 MfibPath + _ = s2 + if j2 < len(m.Route.Paths) { + s2 = m.Route.Paths[j2] + } + // field[3] s2.ItfFlags + size += 4 + // field[3] s2.Path + // field[4] s2.Path.SwIfIndex + size += 4 + // field[4] s2.Path.TableID + size += 4 + // field[4] s2.Path.RpfID + size += 4 + // field[4] s2.Path.Weight + size += 1 + // field[4] s2.Path.Preference + size += 1 + // field[4] s2.Path.Type + size += 4 + // field[4] s2.Path.Flags + size += 4 + // field[4] s2.Path.Proto + size += 4 + // field[4] s2.Path.Nh + // field[5] s2.Path.Nh.Address + size += 16 + // field[5] s2.Path.Nh.ViaLabel + size += 4 + // field[5] s2.Path.Nh.ObjID + size += 4 + // field[5] s2.Path.Nh.ClassifyTableIndex + size += 4 + // field[4] s2.Path.NLabels + size += 1 + // field[4] s2.Path.LabelStack + for j4 := 0; j4 < 16; j4++ { + var s4 FibMplsLabel + _ = s4 + if j4 < len(s2.Path.LabelStack) { + s4 = s2.Path.LabelStack[j4] + } + // field[5] s4.IsUniform + size += 1 + // field[5] s4.Label + size += 4 + // field[5] s4.TTL + size += 1 + // field[5] s4.Exp + size += 1 + } + } + return size +} +func (m *IPMrouteAddDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.IsAdd + if m.IsAdd { + buf[pos] = 1 + } + pos += 1 + // field[1] m.IsMultipath + if m.IsMultipath { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Route + // field[2] m.Route.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.Route.TableID)) + pos += 4 + // field[2] m.Route.EntryFlags + o.PutUint32(buf[pos:pos+4], uint32(m.Route.EntryFlags)) + pos += 4 + // field[2] m.Route.RpfID + o.PutUint32(buf[pos:pos+4], uint32(m.Route.RpfID)) + pos += 4 + // field[2] m.Route.Prefix + // field[3] m.Route.Prefix.Af + o.PutUint32(buf[pos:pos+4], uint32(m.Route.Prefix.Af)) + pos += 4 + // field[3] m.Route.Prefix.GrpAddressLength + o.PutUint16(buf[pos:pos+2], uint16(m.Route.Prefix.GrpAddressLength)) + pos += 2 + // field[3] m.Route.Prefix.GrpAddress + copy(buf[pos:pos+16], m.Route.Prefix.GrpAddress.XXX_UnionData[:]) + pos += 16 + // field[3] m.Route.Prefix.SrcAddress + copy(buf[pos:pos+16], m.Route.Prefix.SrcAddress.XXX_UnionData[:]) + pos += 16 + // field[2] m.Route.NPaths + buf[pos] = uint8(len(m.Route.Paths)) + pos += 1 + // field[2] m.Route.Paths + for j2 := 0; j2 < len(m.Route.Paths); j2++ { + var v2 MfibPath + if j2 < len(m.Route.Paths) { + v2 = m.Route.Paths[j2] + } + // field[3] v2.ItfFlags + o.PutUint32(buf[pos:pos+4], uint32(v2.ItfFlags)) + pos += 4 + // field[3] v2.Path + // field[4] v2.Path.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.SwIfIndex)) + pos += 4 + // field[4] v2.Path.TableID + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.TableID)) + pos += 4 + // field[4] v2.Path.RpfID + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.RpfID)) + pos += 4 + // field[4] v2.Path.Weight + buf[pos] = uint8(v2.Path.Weight) + pos += 1 + // field[4] v2.Path.Preference + buf[pos] = uint8(v2.Path.Preference) + pos += 1 + // field[4] v2.Path.Type + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.Type)) + pos += 4 + // field[4] v2.Path.Flags + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.Flags)) + pos += 4 + // field[4] v2.Path.Proto + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.Proto)) + pos += 4 + // field[4] v2.Path.Nh + // field[5] v2.Path.Nh.Address + copy(buf[pos:pos+16], v2.Path.Nh.Address.XXX_UnionData[:]) + pos += 16 + // field[5] v2.Path.Nh.ViaLabel + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.Nh.ViaLabel)) + pos += 4 + // field[5] v2.Path.Nh.ObjID + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.Nh.ObjID)) + pos += 4 + // field[5] v2.Path.Nh.ClassifyTableIndex + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.Nh.ClassifyTableIndex)) + pos += 4 + // field[4] v2.Path.NLabels + buf[pos] = uint8(v2.Path.NLabels) + pos += 1 + // field[4] v2.Path.LabelStack + for j4 := 0; j4 < 16; j4++ { + var v4 FibMplsLabel + if j4 < len(v2.Path.LabelStack) { + v4 = v2.Path.LabelStack[j4] + } + // field[5] v4.IsUniform + buf[pos] = uint8(v4.IsUniform) + pos += 1 + // field[5] v4.Label + o.PutUint32(buf[pos:pos+4], uint32(v4.Label)) + pos += 4 + // field[5] v4.TTL + buf[pos] = uint8(v4.TTL) + pos += 1 + // field[5] v4.Exp + buf[pos] = uint8(v4.Exp) + pos += 1 + } + } + return buf, nil +} +func (m *IPMrouteAddDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.IsAdd + m.IsAdd = tmp[pos] != 0 + pos += 1 + // field[1] m.IsMultipath + m.IsMultipath = tmp[pos] != 0 + pos += 1 + // field[1] m.Route + // field[2] m.Route.TableID + m.Route.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Route.EntryFlags + m.Route.EntryFlags = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Route.RpfID + m.Route.RpfID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Route.Prefix + // field[3] m.Route.Prefix.Af + m.Route.Prefix.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Prefix.GrpAddressLength + m.Route.Prefix.GrpAddressLength = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[3] m.Route.Prefix.GrpAddress + copy(m.Route.Prefix.GrpAddress.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[3] m.Route.Prefix.SrcAddress + copy(m.Route.Prefix.SrcAddress.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[2] m.Route.NPaths + m.Route.NPaths = uint8(tmp[pos]) + pos += 1 + // field[2] m.Route.Paths + m.Route.Paths = make([]MfibPath, int(m.Route.NPaths)) + for j2 := 0; j2 < int(m.Route.NPaths); j2++ { + // field[3] m.Route.Paths[j2].ItfFlags + m.Route.Paths[j2].ItfFlags = MfibItfFlags(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].Path + // field[4] m.Route.Paths[j2].Path.SwIfIndex + m.Route.Paths[j2].Path.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Path.TableID + m.Route.Paths[j2].Path.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Path.RpfID + m.Route.Paths[j2].Path.RpfID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Path.Weight + m.Route.Paths[j2].Path.Weight = uint8(tmp[pos]) + pos += 1 + // field[4] m.Route.Paths[j2].Path.Preference + m.Route.Paths[j2].Path.Preference = uint8(tmp[pos]) + pos += 1 + // field[4] m.Route.Paths[j2].Path.Type + m.Route.Paths[j2].Path.Type = FibPathType(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Path.Flags + m.Route.Paths[j2].Path.Flags = FibPathFlags(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Path.Proto + m.Route.Paths[j2].Path.Proto = FibPathNhProto(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Path.Nh + // field[5] m.Route.Paths[j2].Path.Nh.Address + copy(m.Route.Paths[j2].Path.Nh.Address.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[5] m.Route.Paths[j2].Path.Nh.ViaLabel + m.Route.Paths[j2].Path.Nh.ViaLabel = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[5] m.Route.Paths[j2].Path.Nh.ObjID + m.Route.Paths[j2].Path.Nh.ObjID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[5] m.Route.Paths[j2].Path.Nh.ClassifyTableIndex + m.Route.Paths[j2].Path.Nh.ClassifyTableIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Path.NLabels + m.Route.Paths[j2].Path.NLabels = uint8(tmp[pos]) + pos += 1 + // field[4] m.Route.Paths[j2].Path.LabelStack + for j4 := 0; j4 < 16; j4++ { + // field[5] m.Route.Paths[j2].Path.LabelStack[j4].IsUniform + m.Route.Paths[j2].Path.LabelStack[j4].IsUniform = uint8(tmp[pos]) + pos += 1 + // field[5] m.Route.Paths[j2].Path.LabelStack[j4].Label + m.Route.Paths[j2].Path.LabelStack[j4].Label = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[5] m.Route.Paths[j2].Path.LabelStack[j4].TTL + m.Route.Paths[j2].Path.LabelStack[j4].TTL = uint8(tmp[pos]) + pos += 1 + // field[5] m.Route.Paths[j2].Path.LabelStack[j4].Exp + m.Route.Paths[j2].Path.LabelStack[j4].Exp = uint8(tmp[pos]) + pos += 1 + } + } + return nil +} + // IPMrouteAddDelReply represents VPP binary API message 'ip_mroute_add_del_reply'. type IPMrouteAddDelReply struct { - Retval int32 - StatsIndex uint32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + StatsIndex uint32 `binapi:"u32,name=stats_index" json:"stats_index,omitempty"` } func (m *IPMrouteAddDelReply) Reset() { *m = IPMrouteAddDelReply{} } @@ -509,9 +1898,53 @@ func (*IPMrouteAddDelReply) GetMessageName() string { return "ip_mroute func (*IPMrouteAddDelReply) GetCrcString() string { return "1992deab" } func (*IPMrouteAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPMrouteAddDelReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.StatsIndex + size += 4 + return size +} +func (m *IPMrouteAddDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.StatsIndex + o.PutUint32(buf[pos:pos+4], uint32(m.StatsIndex)) + pos += 4 + return buf, nil +} +func (m *IPMrouteAddDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.StatsIndex + m.StatsIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPMrouteDetails represents VPP binary API message 'ip_mroute_details'. type IPMrouteDetails struct { - Route IPMroute + Route IPMroute `binapi:"ip_mroute,name=route" json:"route,omitempty"` } func (m *IPMrouteDetails) Reset() { *m = IPMrouteDetails{} } @@ -519,9 +1952,294 @@ func (*IPMrouteDetails) GetMessageName() string { return "ip_mroute_det func (*IPMrouteDetails) GetCrcString() string { return "c1cb4b44" } func (*IPMrouteDetails) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPMrouteDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Route + // field[2] m.Route.TableID + size += 4 + // field[2] m.Route.EntryFlags + size += 4 + // field[2] m.Route.RpfID + size += 4 + // field[2] m.Route.Prefix + // field[3] m.Route.Prefix.Af + size += 4 + // field[3] m.Route.Prefix.GrpAddressLength + size += 2 + // field[3] m.Route.Prefix.GrpAddress + size += 16 + // field[3] m.Route.Prefix.SrcAddress + size += 16 + // field[2] m.Route.NPaths + size += 1 + // field[2] m.Route.Paths + for j2 := 0; j2 < len(m.Route.Paths); j2++ { + var s2 MfibPath + _ = s2 + if j2 < len(m.Route.Paths) { + s2 = m.Route.Paths[j2] + } + // field[3] s2.ItfFlags + size += 4 + // field[3] s2.Path + // field[4] s2.Path.SwIfIndex + size += 4 + // field[4] s2.Path.TableID + size += 4 + // field[4] s2.Path.RpfID + size += 4 + // field[4] s2.Path.Weight + size += 1 + // field[4] s2.Path.Preference + size += 1 + // field[4] s2.Path.Type + size += 4 + // field[4] s2.Path.Flags + size += 4 + // field[4] s2.Path.Proto + size += 4 + // field[4] s2.Path.Nh + // field[5] s2.Path.Nh.Address + size += 16 + // field[5] s2.Path.Nh.ViaLabel + size += 4 + // field[5] s2.Path.Nh.ObjID + size += 4 + // field[5] s2.Path.Nh.ClassifyTableIndex + size += 4 + // field[4] s2.Path.NLabels + size += 1 + // field[4] s2.Path.LabelStack + for j4 := 0; j4 < 16; j4++ { + var s4 FibMplsLabel + _ = s4 + if j4 < len(s2.Path.LabelStack) { + s4 = s2.Path.LabelStack[j4] + } + // field[5] s4.IsUniform + size += 1 + // field[5] s4.Label + size += 4 + // field[5] s4.TTL + size += 1 + // field[5] s4.Exp + size += 1 + } + } + return size +} +func (m *IPMrouteDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Route + // field[2] m.Route.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.Route.TableID)) + pos += 4 + // field[2] m.Route.EntryFlags + o.PutUint32(buf[pos:pos+4], uint32(m.Route.EntryFlags)) + pos += 4 + // field[2] m.Route.RpfID + o.PutUint32(buf[pos:pos+4], uint32(m.Route.RpfID)) + pos += 4 + // field[2] m.Route.Prefix + // field[3] m.Route.Prefix.Af + o.PutUint32(buf[pos:pos+4], uint32(m.Route.Prefix.Af)) + pos += 4 + // field[3] m.Route.Prefix.GrpAddressLength + o.PutUint16(buf[pos:pos+2], uint16(m.Route.Prefix.GrpAddressLength)) + pos += 2 + // field[3] m.Route.Prefix.GrpAddress + copy(buf[pos:pos+16], m.Route.Prefix.GrpAddress.XXX_UnionData[:]) + pos += 16 + // field[3] m.Route.Prefix.SrcAddress + copy(buf[pos:pos+16], m.Route.Prefix.SrcAddress.XXX_UnionData[:]) + pos += 16 + // field[2] m.Route.NPaths + buf[pos] = uint8(len(m.Route.Paths)) + pos += 1 + // field[2] m.Route.Paths + for j2 := 0; j2 < len(m.Route.Paths); j2++ { + var v2 MfibPath + if j2 < len(m.Route.Paths) { + v2 = m.Route.Paths[j2] + } + // field[3] v2.ItfFlags + o.PutUint32(buf[pos:pos+4], uint32(v2.ItfFlags)) + pos += 4 + // field[3] v2.Path + // field[4] v2.Path.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.SwIfIndex)) + pos += 4 + // field[4] v2.Path.TableID + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.TableID)) + pos += 4 + // field[4] v2.Path.RpfID + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.RpfID)) + pos += 4 + // field[4] v2.Path.Weight + buf[pos] = uint8(v2.Path.Weight) + pos += 1 + // field[4] v2.Path.Preference + buf[pos] = uint8(v2.Path.Preference) + pos += 1 + // field[4] v2.Path.Type + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.Type)) + pos += 4 + // field[4] v2.Path.Flags + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.Flags)) + pos += 4 + // field[4] v2.Path.Proto + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.Proto)) + pos += 4 + // field[4] v2.Path.Nh + // field[5] v2.Path.Nh.Address + copy(buf[pos:pos+16], v2.Path.Nh.Address.XXX_UnionData[:]) + pos += 16 + // field[5] v2.Path.Nh.ViaLabel + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.Nh.ViaLabel)) + pos += 4 + // field[5] v2.Path.Nh.ObjID + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.Nh.ObjID)) + pos += 4 + // field[5] v2.Path.Nh.ClassifyTableIndex + o.PutUint32(buf[pos:pos+4], uint32(v2.Path.Nh.ClassifyTableIndex)) + pos += 4 + // field[4] v2.Path.NLabels + buf[pos] = uint8(v2.Path.NLabels) + pos += 1 + // field[4] v2.Path.LabelStack + for j4 := 0; j4 < 16; j4++ { + var v4 FibMplsLabel + if j4 < len(v2.Path.LabelStack) { + v4 = v2.Path.LabelStack[j4] + } + // field[5] v4.IsUniform + buf[pos] = uint8(v4.IsUniform) + pos += 1 + // field[5] v4.Label + o.PutUint32(buf[pos:pos+4], uint32(v4.Label)) + pos += 4 + // field[5] v4.TTL + buf[pos] = uint8(v4.TTL) + pos += 1 + // field[5] v4.Exp + buf[pos] = uint8(v4.Exp) + pos += 1 + } + } + return buf, nil +} +func (m *IPMrouteDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Route + // field[2] m.Route.TableID + m.Route.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Route.EntryFlags + m.Route.EntryFlags = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Route.RpfID + m.Route.RpfID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Route.Prefix + // field[3] m.Route.Prefix.Af + m.Route.Prefix.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Prefix.GrpAddressLength + m.Route.Prefix.GrpAddressLength = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[3] m.Route.Prefix.GrpAddress + copy(m.Route.Prefix.GrpAddress.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[3] m.Route.Prefix.SrcAddress + copy(m.Route.Prefix.SrcAddress.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[2] m.Route.NPaths + m.Route.NPaths = uint8(tmp[pos]) + pos += 1 + // field[2] m.Route.Paths + m.Route.Paths = make([]MfibPath, int(m.Route.NPaths)) + for j2 := 0; j2 < int(m.Route.NPaths); j2++ { + // field[3] m.Route.Paths[j2].ItfFlags + m.Route.Paths[j2].ItfFlags = MfibItfFlags(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].Path + // field[4] m.Route.Paths[j2].Path.SwIfIndex + m.Route.Paths[j2].Path.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Path.TableID + m.Route.Paths[j2].Path.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Path.RpfID + m.Route.Paths[j2].Path.RpfID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Path.Weight + m.Route.Paths[j2].Path.Weight = uint8(tmp[pos]) + pos += 1 + // field[4] m.Route.Paths[j2].Path.Preference + m.Route.Paths[j2].Path.Preference = uint8(tmp[pos]) + pos += 1 + // field[4] m.Route.Paths[j2].Path.Type + m.Route.Paths[j2].Path.Type = FibPathType(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Path.Flags + m.Route.Paths[j2].Path.Flags = FibPathFlags(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Path.Proto + m.Route.Paths[j2].Path.Proto = FibPathNhProto(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Path.Nh + // field[5] m.Route.Paths[j2].Path.Nh.Address + copy(m.Route.Paths[j2].Path.Nh.Address.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[5] m.Route.Paths[j2].Path.Nh.ViaLabel + m.Route.Paths[j2].Path.Nh.ViaLabel = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[5] m.Route.Paths[j2].Path.Nh.ObjID + m.Route.Paths[j2].Path.Nh.ObjID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[5] m.Route.Paths[j2].Path.Nh.ClassifyTableIndex + m.Route.Paths[j2].Path.Nh.ClassifyTableIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Path.NLabels + m.Route.Paths[j2].Path.NLabels = uint8(tmp[pos]) + pos += 1 + // field[4] m.Route.Paths[j2].Path.LabelStack + for j4 := 0; j4 < 16; j4++ { + // field[5] m.Route.Paths[j2].Path.LabelStack[j4].IsUniform + m.Route.Paths[j2].Path.LabelStack[j4].IsUniform = uint8(tmp[pos]) + pos += 1 + // field[5] m.Route.Paths[j2].Path.LabelStack[j4].Label + m.Route.Paths[j2].Path.LabelStack[j4].Label = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[5] m.Route.Paths[j2].Path.LabelStack[j4].TTL + m.Route.Paths[j2].Path.LabelStack[j4].TTL = uint8(tmp[pos]) + pos += 1 + // field[5] m.Route.Paths[j2].Path.LabelStack[j4].Exp + m.Route.Paths[j2].Path.LabelStack[j4].Exp = uint8(tmp[pos]) + pos += 1 + } + } + return nil +} + // IPMrouteDump represents VPP binary API message 'ip_mroute_dump'. type IPMrouteDump struct { - Table IPTable + Table IPTable `binapi:"ip_table,name=table" json:"table,omitempty"` } func (m *IPMrouteDump) Reset() { *m = IPMrouteDump{} } @@ -529,9 +2247,69 @@ func (*IPMrouteDump) GetMessageName() string { return "ip_mroute_dump" func (*IPMrouteDump) GetCrcString() string { return "b9d2e09e" } func (*IPMrouteDump) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPMrouteDump) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Table + // field[2] m.Table.TableID + size += 4 + // field[2] m.Table.IsIP6 + size += 1 + // field[2] m.Table.Name + size += 64 + return size +} +func (m *IPMrouteDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Table + // field[2] m.Table.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.Table.TableID)) + pos += 4 + // field[2] m.Table.IsIP6 + if m.Table.IsIP6 { + buf[pos] = 1 + } + pos += 1 + // field[2] m.Table.Name + copy(buf[pos:pos+64], m.Table.Name) + pos += 64 + return buf, nil +} +func (m *IPMrouteDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Table + // field[2] m.Table.TableID + m.Table.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Table.IsIP6 + m.Table.IsIP6 = tmp[pos] != 0 + pos += 1 + // field[2] m.Table.Name + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Table.Name = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // IPMtableDetails represents VPP binary API message 'ip_mtable_details'. type IPMtableDetails struct { - Table IPTable + Table IPTable `binapi:"ip_table,name=table" json:"table,omitempty"` } func (m *IPMtableDetails) Reset() { *m = IPMtableDetails{} } @@ -539,6 +2317,66 @@ func (*IPMtableDetails) GetMessageName() string { return "ip_mtable_det func (*IPMtableDetails) GetCrcString() string { return "b9d2e09e" } func (*IPMtableDetails) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPMtableDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Table + // field[2] m.Table.TableID + size += 4 + // field[2] m.Table.IsIP6 + size += 1 + // field[2] m.Table.Name + size += 64 + return size +} +func (m *IPMtableDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Table + // field[2] m.Table.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.Table.TableID)) + pos += 4 + // field[2] m.Table.IsIP6 + if m.Table.IsIP6 { + buf[pos] = 1 + } + pos += 1 + // field[2] m.Table.Name + copy(buf[pos:pos+64], m.Table.Name) + pos += 64 + return buf, nil +} +func (m *IPMtableDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Table + // field[2] m.Table.TableID + m.Table.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Table.IsIP6 + m.Table.IsIP6 = tmp[pos] != 0 + pos += 1 + // field[2] m.Table.Name + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Table.Name = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // IPMtableDump represents VPP binary API message 'ip_mtable_dump'. type IPMtableDump struct{} @@ -547,11 +2385,39 @@ func (*IPMtableDump) GetMessageName() string { return "ip_mtable_dump" func (*IPMtableDump) GetCrcString() string { return "51077d14" } func (*IPMtableDump) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPMtableDump) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *IPMtableDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *IPMtableDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + // IPPuntPolice represents VPP binary API message 'ip_punt_police'. type IPPuntPolice struct { - PolicerIndex uint32 - IsAdd bool - IsIP6 bool + PolicerIndex uint32 `binapi:"u32,name=policer_index" json:"policer_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + IsIP6 bool `binapi:"bool,name=is_ip6" json:"is_ip6,omitempty"` } func (m *IPPuntPolice) Reset() { *m = IPPuntPolice{} } @@ -559,9 +2425,65 @@ func (*IPPuntPolice) GetMessageName() string { return "ip_punt_police" func (*IPPuntPolice) GetCrcString() string { return "db867cea" } func (*IPPuntPolice) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPPuntPolice) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.PolicerIndex + size += 4 + // field[1] m.IsAdd + size += 1 + // field[1] m.IsIP6 + size += 1 + return size +} +func (m *IPPuntPolice) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.PolicerIndex + o.PutUint32(buf[pos:pos+4], uint32(m.PolicerIndex)) + pos += 4 + // field[1] m.IsAdd + if m.IsAdd { + buf[pos] = 1 + } + pos += 1 + // field[1] m.IsIP6 + if m.IsIP6 { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *IPPuntPolice) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.PolicerIndex + m.PolicerIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IsAdd + m.IsAdd = tmp[pos] != 0 + pos += 1 + // field[1] m.IsIP6 + m.IsIP6 = tmp[pos] != 0 + pos += 1 + return nil +} + // IPPuntPoliceReply represents VPP binary API message 'ip_punt_police_reply'. type IPPuntPoliceReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *IPPuntPoliceReply) Reset() { *m = IPPuntPoliceReply{} } @@ -569,10 +2491,46 @@ func (*IPPuntPoliceReply) GetMessageName() string { return "ip_punt_pol func (*IPPuntPoliceReply) GetCrcString() string { return "e8d4e804" } func (*IPPuntPoliceReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPPuntPoliceReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *IPPuntPoliceReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *IPPuntPoliceReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPPuntRedirect represents VPP binary API message 'ip_punt_redirect'. type IPPuntRedirect struct { - Punt PuntRedirect - IsAdd bool + Punt PuntRedirect `binapi:"punt_redirect,name=punt" json:"punt,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` } func (m *IPPuntRedirect) Reset() { *m = IPPuntRedirect{} } @@ -580,9 +2538,85 @@ func (*IPPuntRedirect) GetMessageName() string { return "ip_punt_redire func (*IPPuntRedirect) GetCrcString() string { return "a9a5592c" } func (*IPPuntRedirect) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPPuntRedirect) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Punt + // field[2] m.Punt.RxSwIfIndex + size += 4 + // field[2] m.Punt.TxSwIfIndex + size += 4 + // field[2] m.Punt.Nh + // field[3] m.Punt.Nh.Af + size += 4 + // field[3] m.Punt.Nh.Un + size += 16 + // field[1] m.IsAdd + size += 1 + return size +} +func (m *IPPuntRedirect) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Punt + // field[2] m.Punt.RxSwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.Punt.RxSwIfIndex)) + pos += 4 + // field[2] m.Punt.TxSwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.Punt.TxSwIfIndex)) + pos += 4 + // field[2] m.Punt.Nh + // field[3] m.Punt.Nh.Af + o.PutUint32(buf[pos:pos+4], uint32(m.Punt.Nh.Af)) + pos += 4 + // field[3] m.Punt.Nh.Un + copy(buf[pos:pos+16], m.Punt.Nh.Un.XXX_UnionData[:]) + pos += 16 + // field[1] m.IsAdd + if m.IsAdd { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *IPPuntRedirect) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Punt + // field[2] m.Punt.RxSwIfIndex + m.Punt.RxSwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Punt.TxSwIfIndex + m.Punt.TxSwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Punt.Nh + // field[3] m.Punt.Nh.Af + m.Punt.Nh.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Punt.Nh.Un + copy(m.Punt.Nh.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[1] m.IsAdd + m.IsAdd = tmp[pos] != 0 + pos += 1 + return nil +} + // IPPuntRedirectDetails represents VPP binary API message 'ip_punt_redirect_details'. type IPPuntRedirectDetails struct { - Punt PuntRedirect + Punt PuntRedirect `binapi:"punt_redirect,name=punt" json:"punt,omitempty"` } func (m *IPPuntRedirectDetails) Reset() { *m = IPPuntRedirectDetails{} } @@ -590,10 +2624,76 @@ func (*IPPuntRedirectDetails) GetMessageName() string { return "ip_punt func (*IPPuntRedirectDetails) GetCrcString() string { return "3924f5d3" } func (*IPPuntRedirectDetails) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPPuntRedirectDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Punt + // field[2] m.Punt.RxSwIfIndex + size += 4 + // field[2] m.Punt.TxSwIfIndex + size += 4 + // field[2] m.Punt.Nh + // field[3] m.Punt.Nh.Af + size += 4 + // field[3] m.Punt.Nh.Un + size += 16 + return size +} +func (m *IPPuntRedirectDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Punt + // field[2] m.Punt.RxSwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.Punt.RxSwIfIndex)) + pos += 4 + // field[2] m.Punt.TxSwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.Punt.TxSwIfIndex)) + pos += 4 + // field[2] m.Punt.Nh + // field[3] m.Punt.Nh.Af + o.PutUint32(buf[pos:pos+4], uint32(m.Punt.Nh.Af)) + pos += 4 + // field[3] m.Punt.Nh.Un + copy(buf[pos:pos+16], m.Punt.Nh.Un.XXX_UnionData[:]) + pos += 16 + return buf, nil +} +func (m *IPPuntRedirectDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Punt + // field[2] m.Punt.RxSwIfIndex + m.Punt.RxSwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Punt.TxSwIfIndex + m.Punt.TxSwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Punt.Nh + // field[3] m.Punt.Nh.Af + m.Punt.Nh.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Punt.Nh.Un + copy(m.Punt.Nh.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + return nil +} + // IPPuntRedirectDump represents VPP binary API message 'ip_punt_redirect_dump'. type IPPuntRedirectDump struct { - SwIfIndex InterfaceIndex - IsIPv6 bool + SwIfIndex 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 *IPPuntRedirectDump) Reset() { *m = IPPuntRedirectDump{} } @@ -601,9 +2701,55 @@ func (*IPPuntRedirectDump) GetMessageName() string { return "ip_punt_re func (*IPPuntRedirectDump) GetCrcString() string { return "2d033de4" } func (*IPPuntRedirectDump) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPPuntRedirectDump) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.IsIPv6 + size += 1 + return size +} +func (m *IPPuntRedirectDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.IsIPv6 + if m.IsIPv6 { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *IPPuntRedirectDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IsIPv6 + m.IsIPv6 = tmp[pos] != 0 + pos += 1 + return nil +} + // IPPuntRedirectReply represents VPP binary API message 'ip_punt_redirect_reply'. type IPPuntRedirectReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *IPPuntRedirectReply) Reset() { *m = IPPuntRedirectReply{} } @@ -611,12 +2757,48 @@ func (*IPPuntRedirectReply) GetMessageName() string { return "ip_punt_r func (*IPPuntRedirectReply) GetCrcString() string { return "e8d4e804" } func (*IPPuntRedirectReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPPuntRedirectReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *IPPuntRedirectReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *IPPuntRedirectReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPReassemblyEnableDisable represents VPP binary API message 'ip_reassembly_enable_disable'. type IPReassemblyEnableDisable struct { - SwIfIndex InterfaceIndex - EnableIP4 bool - EnableIP6 bool - Type IPReassType + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + EnableIP4 bool `binapi:"bool,name=enable_ip4" json:"enable_ip4,omitempty"` + EnableIP6 bool `binapi:"bool,name=enable_ip6" json:"enable_ip6,omitempty"` + Type IPReassType `binapi:"ip_reass_type,name=type" json:"type,omitempty"` } func (m *IPReassemblyEnableDisable) Reset() { *m = IPReassemblyEnableDisable{} } @@ -624,9 +2806,73 @@ func (*IPReassemblyEnableDisable) GetMessageName() string { return "ip_ func (*IPReassemblyEnableDisable) GetCrcString() string { return "885c85a6" } func (*IPReassemblyEnableDisable) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPReassemblyEnableDisable) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.EnableIP4 + size += 1 + // field[1] m.EnableIP6 + size += 1 + // field[1] m.Type + size += 4 + return size +} +func (m *IPReassemblyEnableDisable) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.EnableIP4 + if m.EnableIP4 { + buf[pos] = 1 + } + pos += 1 + // field[1] m.EnableIP6 + if m.EnableIP6 { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Type + o.PutUint32(buf[pos:pos+4], uint32(m.Type)) + pos += 4 + return buf, nil +} +func (m *IPReassemblyEnableDisable) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.EnableIP4 + m.EnableIP4 = tmp[pos] != 0 + pos += 1 + // field[1] m.EnableIP6 + m.EnableIP6 = tmp[pos] != 0 + pos += 1 + // field[1] m.Type + m.Type = IPReassType(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPReassemblyEnableDisableReply represents VPP binary API message 'ip_reassembly_enable_disable_reply'. type IPReassemblyEnableDisableReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *IPReassemblyEnableDisableReply) Reset() { *m = IPReassemblyEnableDisableReply{} } @@ -636,10 +2882,46 @@ func (*IPReassemblyEnableDisableReply) GetMessageName() string { func (*IPReassemblyEnableDisableReply) GetCrcString() string { return "e8d4e804" } func (*IPReassemblyEnableDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPReassemblyEnableDisableReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *IPReassemblyEnableDisableReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *IPReassemblyEnableDisableReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPReassemblyGet represents VPP binary API message 'ip_reassembly_get'. type IPReassemblyGet struct { - IsIP6 bool - Type IPReassType + IsIP6 bool `binapi:"bool,name=is_ip6" json:"is_ip6,omitempty"` + Type IPReassType `binapi:"ip_reass_type,name=type" json:"type,omitempty"` } func (m *IPReassemblyGet) Reset() { *m = IPReassemblyGet{} } @@ -647,14 +2929,60 @@ func (*IPReassemblyGet) GetMessageName() string { return "ip_reassembly func (*IPReassemblyGet) GetCrcString() string { return "ea13ff63" } func (*IPReassemblyGet) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPReassemblyGet) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.IsIP6 + size += 1 + // field[1] m.Type + size += 4 + return size +} +func (m *IPReassemblyGet) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.IsIP6 + if m.IsIP6 { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Type + o.PutUint32(buf[pos:pos+4], uint32(m.Type)) + pos += 4 + return buf, nil +} +func (m *IPReassemblyGet) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.IsIP6 + m.IsIP6 = tmp[pos] != 0 + pos += 1 + // field[1] m.Type + m.Type = IPReassType(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // 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 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TimeoutMs uint32 `binapi:"u32,name=timeout_ms" json:"timeout_ms,omitempty"` + MaxReassemblies uint32 `binapi:"u32,name=max_reassemblies" json:"max_reassemblies,omitempty"` + MaxReassemblyLength uint32 `binapi:"u32,name=max_reassembly_length" json:"max_reassembly_length,omitempty"` + ExpireWalkIntervalMs uint32 `binapi:"u32,name=expire_walk_interval_ms" json:"expire_walk_interval_ms,omitempty"` + IsIP6 bool `binapi:"bool,name=is_ip6" json:"is_ip6,omitempty"` } func (m *IPReassemblyGetReply) Reset() { *m = IPReassemblyGetReply{} } @@ -662,14 +2990,92 @@ func (*IPReassemblyGetReply) GetMessageName() string { return "ip_reass func (*IPReassemblyGetReply) GetCrcString() string { return "d5eb8d34" } func (*IPReassemblyGetReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPReassemblyGetReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.TimeoutMs + size += 4 + // field[1] m.MaxReassemblies + size += 4 + // field[1] m.MaxReassemblyLength + size += 4 + // field[1] m.ExpireWalkIntervalMs + size += 4 + // field[1] m.IsIP6 + size += 1 + return size +} +func (m *IPReassemblyGetReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.TimeoutMs + o.PutUint32(buf[pos:pos+4], uint32(m.TimeoutMs)) + pos += 4 + // field[1] m.MaxReassemblies + o.PutUint32(buf[pos:pos+4], uint32(m.MaxReassemblies)) + pos += 4 + // field[1] m.MaxReassemblyLength + o.PutUint32(buf[pos:pos+4], uint32(m.MaxReassemblyLength)) + pos += 4 + // field[1] m.ExpireWalkIntervalMs + o.PutUint32(buf[pos:pos+4], uint32(m.ExpireWalkIntervalMs)) + pos += 4 + // field[1] m.IsIP6 + if m.IsIP6 { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *IPReassemblyGetReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.TimeoutMs + m.TimeoutMs = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.MaxReassemblies + m.MaxReassemblies = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.MaxReassemblyLength + m.MaxReassemblyLength = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.ExpireWalkIntervalMs + m.ExpireWalkIntervalMs = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IsIP6 + m.IsIP6 = tmp[pos] != 0 + pos += 1 + return nil +} + // IPReassemblySet represents VPP binary API message 'ip_reassembly_set'. type IPReassemblySet struct { - TimeoutMs uint32 - MaxReassemblies uint32 - MaxReassemblyLength uint32 - ExpireWalkIntervalMs uint32 - IsIP6 bool - Type IPReassType + TimeoutMs uint32 `binapi:"u32,name=timeout_ms" json:"timeout_ms,omitempty"` + MaxReassemblies uint32 `binapi:"u32,name=max_reassemblies" json:"max_reassemblies,omitempty"` + MaxReassemblyLength uint32 `binapi:"u32,name=max_reassembly_length" json:"max_reassembly_length,omitempty"` + ExpireWalkIntervalMs uint32 `binapi:"u32,name=expire_walk_interval_ms" json:"expire_walk_interval_ms,omitempty"` + IsIP6 bool `binapi:"bool,name=is_ip6" json:"is_ip6,omitempty"` + Type IPReassType `binapi:"ip_reass_type,name=type" json:"type,omitempty"` } func (m *IPReassemblySet) Reset() { *m = IPReassemblySet{} } @@ -677,9 +3083,87 @@ func (*IPReassemblySet) GetMessageName() string { return "ip_reassembly func (*IPReassemblySet) GetCrcString() string { return "16467d25" } func (*IPReassemblySet) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPReassemblySet) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.TimeoutMs + size += 4 + // field[1] m.MaxReassemblies + size += 4 + // field[1] m.MaxReassemblyLength + size += 4 + // field[1] m.ExpireWalkIntervalMs + size += 4 + // field[1] m.IsIP6 + size += 1 + // field[1] m.Type + size += 4 + return size +} +func (m *IPReassemblySet) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.TimeoutMs + o.PutUint32(buf[pos:pos+4], uint32(m.TimeoutMs)) + pos += 4 + // field[1] m.MaxReassemblies + o.PutUint32(buf[pos:pos+4], uint32(m.MaxReassemblies)) + pos += 4 + // field[1] m.MaxReassemblyLength + o.PutUint32(buf[pos:pos+4], uint32(m.MaxReassemblyLength)) + pos += 4 + // field[1] m.ExpireWalkIntervalMs + o.PutUint32(buf[pos:pos+4], uint32(m.ExpireWalkIntervalMs)) + pos += 4 + // field[1] m.IsIP6 + if m.IsIP6 { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Type + o.PutUint32(buf[pos:pos+4], uint32(m.Type)) + pos += 4 + return buf, nil +} +func (m *IPReassemblySet) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.TimeoutMs + m.TimeoutMs = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.MaxReassemblies + m.MaxReassemblies = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.MaxReassemblyLength + m.MaxReassemblyLength = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.ExpireWalkIntervalMs + m.ExpireWalkIntervalMs = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IsIP6 + m.IsIP6 = tmp[pos] != 0 + pos += 1 + // field[1] m.Type + m.Type = IPReassType(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPReassemblySetReply represents VPP binary API message 'ip_reassembly_set_reply'. type IPReassemblySetReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *IPReassemblySetReply) Reset() { *m = IPReassemblySetReply{} } @@ -687,11 +3171,47 @@ func (*IPReassemblySetReply) GetMessageName() string { return "ip_reass func (*IPReassemblySetReply) GetCrcString() string { return "e8d4e804" } func (*IPReassemblySetReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPReassemblySetReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *IPReassemblySetReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *IPReassemblySetReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPRouteAddDel represents VPP binary API message 'ip_route_add_del'. type IPRouteAddDel struct { - IsAdd bool - IsMultipath bool - Route IPRoute + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + IsMultipath bool `binapi:"bool,name=is_multipath" json:"is_multipath,omitempty"` + Route IPRoute `binapi:"ip_route,name=route" json:"route,omitempty"` } func (m *IPRouteAddDel) Reset() { *m = IPRouteAddDel{} } @@ -699,10 +3219,291 @@ func (*IPRouteAddDel) GetMessageName() string { return "ip_route_add_de func (*IPRouteAddDel) GetCrcString() string { return "c1ff832d" } func (*IPRouteAddDel) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPRouteAddDel) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.IsAdd + size += 1 + // field[1] m.IsMultipath + size += 1 + // field[1] m.Route + // field[2] m.Route.TableID + size += 4 + // field[2] m.Route.StatsIndex + size += 4 + // field[2] m.Route.Prefix + // field[3] m.Route.Prefix.Address + // field[4] m.Route.Prefix.Address.Af + size += 4 + // field[4] m.Route.Prefix.Address.Un + size += 16 + // field[3] m.Route.Prefix.Len + size += 1 + // field[2] m.Route.NPaths + size += 1 + // field[2] m.Route.Paths + for j2 := 0; j2 < len(m.Route.Paths); j2++ { + var s2 FibPath + _ = s2 + if j2 < len(m.Route.Paths) { + s2 = m.Route.Paths[j2] + } + // field[3] s2.SwIfIndex + size += 4 + // field[3] s2.TableID + size += 4 + // field[3] s2.RpfID + size += 4 + // field[3] s2.Weight + size += 1 + // field[3] s2.Preference + size += 1 + // field[3] s2.Type + size += 4 + // field[3] s2.Flags + size += 4 + // field[3] s2.Proto + size += 4 + // field[3] s2.Nh + // field[4] s2.Nh.Address + size += 16 + // field[4] s2.Nh.ViaLabel + size += 4 + // field[4] s2.Nh.ObjID + size += 4 + // field[4] s2.Nh.ClassifyTableIndex + size += 4 + // field[3] s2.NLabels + size += 1 + // field[3] s2.LabelStack + for j3 := 0; j3 < 16; j3++ { + var s3 FibMplsLabel + _ = s3 + if j3 < len(s2.LabelStack) { + s3 = s2.LabelStack[j3] + } + // field[4] s3.IsUniform + size += 1 + // field[4] s3.Label + size += 4 + // field[4] s3.TTL + size += 1 + // field[4] s3.Exp + size += 1 + } + } + return size +} +func (m *IPRouteAddDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.IsAdd + if m.IsAdd { + buf[pos] = 1 + } + pos += 1 + // field[1] m.IsMultipath + if m.IsMultipath { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Route + // field[2] m.Route.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.Route.TableID)) + pos += 4 + // field[2] m.Route.StatsIndex + o.PutUint32(buf[pos:pos+4], uint32(m.Route.StatsIndex)) + pos += 4 + // field[2] m.Route.Prefix + // field[3] m.Route.Prefix.Address + // field[4] m.Route.Prefix.Address.Af + o.PutUint32(buf[pos:pos+4], uint32(m.Route.Prefix.Address.Af)) + pos += 4 + // field[4] m.Route.Prefix.Address.Un + copy(buf[pos:pos+16], m.Route.Prefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[3] m.Route.Prefix.Len + buf[pos] = uint8(m.Route.Prefix.Len) + pos += 1 + // field[2] m.Route.NPaths + buf[pos] = uint8(len(m.Route.Paths)) + pos += 1 + // field[2] m.Route.Paths + for j2 := 0; j2 < len(m.Route.Paths); j2++ { + var v2 FibPath + if j2 < len(m.Route.Paths) { + v2 = m.Route.Paths[j2] + } + // field[3] v2.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(v2.SwIfIndex)) + pos += 4 + // field[3] v2.TableID + o.PutUint32(buf[pos:pos+4], uint32(v2.TableID)) + pos += 4 + // field[3] v2.RpfID + o.PutUint32(buf[pos:pos+4], uint32(v2.RpfID)) + pos += 4 + // field[3] v2.Weight + buf[pos] = uint8(v2.Weight) + pos += 1 + // field[3] v2.Preference + buf[pos] = uint8(v2.Preference) + pos += 1 + // field[3] v2.Type + o.PutUint32(buf[pos:pos+4], uint32(v2.Type)) + pos += 4 + // field[3] v2.Flags + o.PutUint32(buf[pos:pos+4], uint32(v2.Flags)) + pos += 4 + // field[3] v2.Proto + o.PutUint32(buf[pos:pos+4], uint32(v2.Proto)) + pos += 4 + // field[3] v2.Nh + // field[4] v2.Nh.Address + copy(buf[pos:pos+16], v2.Nh.Address.XXX_UnionData[:]) + pos += 16 + // field[4] v2.Nh.ViaLabel + o.PutUint32(buf[pos:pos+4], uint32(v2.Nh.ViaLabel)) + pos += 4 + // field[4] v2.Nh.ObjID + o.PutUint32(buf[pos:pos+4], uint32(v2.Nh.ObjID)) + pos += 4 + // field[4] v2.Nh.ClassifyTableIndex + o.PutUint32(buf[pos:pos+4], uint32(v2.Nh.ClassifyTableIndex)) + pos += 4 + // field[3] v2.NLabels + buf[pos] = uint8(v2.NLabels) + pos += 1 + // field[3] v2.LabelStack + for j3 := 0; j3 < 16; j3++ { + var v3 FibMplsLabel + if j3 < len(v2.LabelStack) { + v3 = v2.LabelStack[j3] + } + // field[4] v3.IsUniform + buf[pos] = uint8(v3.IsUniform) + pos += 1 + // field[4] v3.Label + o.PutUint32(buf[pos:pos+4], uint32(v3.Label)) + pos += 4 + // field[4] v3.TTL + buf[pos] = uint8(v3.TTL) + pos += 1 + // field[4] v3.Exp + buf[pos] = uint8(v3.Exp) + pos += 1 + } + } + return buf, nil +} +func (m *IPRouteAddDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.IsAdd + m.IsAdd = tmp[pos] != 0 + pos += 1 + // field[1] m.IsMultipath + m.IsMultipath = tmp[pos] != 0 + pos += 1 + // field[1] m.Route + // field[2] m.Route.TableID + m.Route.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Route.StatsIndex + m.Route.StatsIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Route.Prefix + // field[3] m.Route.Prefix.Address + // field[4] m.Route.Prefix.Address.Af + m.Route.Prefix.Address.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Prefix.Address.Un + copy(m.Route.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[3] m.Route.Prefix.Len + m.Route.Prefix.Len = uint8(tmp[pos]) + pos += 1 + // field[2] m.Route.NPaths + m.Route.NPaths = uint8(tmp[pos]) + pos += 1 + // field[2] m.Route.Paths + m.Route.Paths = make([]FibPath, int(m.Route.NPaths)) + for j2 := 0; j2 < int(m.Route.NPaths); j2++ { + // field[3] m.Route.Paths[j2].SwIfIndex + m.Route.Paths[j2].SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].TableID + m.Route.Paths[j2].TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].RpfID + m.Route.Paths[j2].RpfID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].Weight + m.Route.Paths[j2].Weight = uint8(tmp[pos]) + pos += 1 + // field[3] m.Route.Paths[j2].Preference + m.Route.Paths[j2].Preference = uint8(tmp[pos]) + pos += 1 + // field[3] m.Route.Paths[j2].Type + m.Route.Paths[j2].Type = FibPathType(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].Flags + m.Route.Paths[j2].Flags = FibPathFlags(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].Proto + m.Route.Paths[j2].Proto = FibPathNhProto(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].Nh + // field[4] m.Route.Paths[j2].Nh.Address + copy(m.Route.Paths[j2].Nh.Address.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[4] m.Route.Paths[j2].Nh.ViaLabel + m.Route.Paths[j2].Nh.ViaLabel = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Nh.ObjID + m.Route.Paths[j2].Nh.ObjID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Nh.ClassifyTableIndex + m.Route.Paths[j2].Nh.ClassifyTableIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].NLabels + m.Route.Paths[j2].NLabels = uint8(tmp[pos]) + pos += 1 + // field[3] m.Route.Paths[j2].LabelStack + for j3 := 0; j3 < 16; j3++ { + // field[4] m.Route.Paths[j2].LabelStack[j3].IsUniform + m.Route.Paths[j2].LabelStack[j3].IsUniform = uint8(tmp[pos]) + pos += 1 + // field[4] m.Route.Paths[j2].LabelStack[j3].Label + m.Route.Paths[j2].LabelStack[j3].Label = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].LabelStack[j3].TTL + m.Route.Paths[j2].LabelStack[j3].TTL = uint8(tmp[pos]) + pos += 1 + // field[4] m.Route.Paths[j2].LabelStack[j3].Exp + m.Route.Paths[j2].LabelStack[j3].Exp = uint8(tmp[pos]) + pos += 1 + } + } + return nil +} + // IPRouteAddDelReply represents VPP binary API message 'ip_route_add_del_reply'. type IPRouteAddDelReply struct { - Retval int32 - StatsIndex uint32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + StatsIndex uint32 `binapi:"u32,name=stats_index" json:"stats_index,omitempty"` } func (m *IPRouteAddDelReply) Reset() { *m = IPRouteAddDelReply{} } @@ -710,9 +3511,53 @@ func (*IPRouteAddDelReply) GetMessageName() string { return "ip_route_a func (*IPRouteAddDelReply) GetCrcString() string { return "1992deab" } func (*IPRouteAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPRouteAddDelReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.StatsIndex + size += 4 + return size +} +func (m *IPRouteAddDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.StatsIndex + o.PutUint32(buf[pos:pos+4], uint32(m.StatsIndex)) + pos += 4 + return buf, nil +} +func (m *IPRouteAddDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.StatsIndex + m.StatsIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPRouteDetails represents VPP binary API message 'ip_route_details'. type IPRouteDetails struct { - Route IPRoute + Route IPRoute `binapi:"ip_route,name=route" json:"route,omitempty"` } func (m *IPRouteDetails) Reset() { *m = IPRouteDetails{} } @@ -720,9 +3565,270 @@ func (*IPRouteDetails) GetMessageName() string { return "ip_route_detai func (*IPRouteDetails) GetCrcString() string { return "d1ffaae1" } func (*IPRouteDetails) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPRouteDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Route + // field[2] m.Route.TableID + size += 4 + // field[2] m.Route.StatsIndex + size += 4 + // field[2] m.Route.Prefix + // field[3] m.Route.Prefix.Address + // field[4] m.Route.Prefix.Address.Af + size += 4 + // field[4] m.Route.Prefix.Address.Un + size += 16 + // field[3] m.Route.Prefix.Len + size += 1 + // field[2] m.Route.NPaths + size += 1 + // field[2] m.Route.Paths + for j2 := 0; j2 < len(m.Route.Paths); j2++ { + var s2 FibPath + _ = s2 + if j2 < len(m.Route.Paths) { + s2 = m.Route.Paths[j2] + } + // field[3] s2.SwIfIndex + size += 4 + // field[3] s2.TableID + size += 4 + // field[3] s2.RpfID + size += 4 + // field[3] s2.Weight + size += 1 + // field[3] s2.Preference + size += 1 + // field[3] s2.Type + size += 4 + // field[3] s2.Flags + size += 4 + // field[3] s2.Proto + size += 4 + // field[3] s2.Nh + // field[4] s2.Nh.Address + size += 16 + // field[4] s2.Nh.ViaLabel + size += 4 + // field[4] s2.Nh.ObjID + size += 4 + // field[4] s2.Nh.ClassifyTableIndex + size += 4 + // field[3] s2.NLabels + size += 1 + // field[3] s2.LabelStack + for j3 := 0; j3 < 16; j3++ { + var s3 FibMplsLabel + _ = s3 + if j3 < len(s2.LabelStack) { + s3 = s2.LabelStack[j3] + } + // field[4] s3.IsUniform + size += 1 + // field[4] s3.Label + size += 4 + // field[4] s3.TTL + size += 1 + // field[4] s3.Exp + size += 1 + } + } + return size +} +func (m *IPRouteDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Route + // field[2] m.Route.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.Route.TableID)) + pos += 4 + // field[2] m.Route.StatsIndex + o.PutUint32(buf[pos:pos+4], uint32(m.Route.StatsIndex)) + pos += 4 + // field[2] m.Route.Prefix + // field[3] m.Route.Prefix.Address + // field[4] m.Route.Prefix.Address.Af + o.PutUint32(buf[pos:pos+4], uint32(m.Route.Prefix.Address.Af)) + pos += 4 + // field[4] m.Route.Prefix.Address.Un + copy(buf[pos:pos+16], m.Route.Prefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[3] m.Route.Prefix.Len + buf[pos] = uint8(m.Route.Prefix.Len) + pos += 1 + // field[2] m.Route.NPaths + buf[pos] = uint8(len(m.Route.Paths)) + pos += 1 + // field[2] m.Route.Paths + for j2 := 0; j2 < len(m.Route.Paths); j2++ { + var v2 FibPath + if j2 < len(m.Route.Paths) { + v2 = m.Route.Paths[j2] + } + // field[3] v2.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(v2.SwIfIndex)) + pos += 4 + // field[3] v2.TableID + o.PutUint32(buf[pos:pos+4], uint32(v2.TableID)) + pos += 4 + // field[3] v2.RpfID + o.PutUint32(buf[pos:pos+4], uint32(v2.RpfID)) + pos += 4 + // field[3] v2.Weight + buf[pos] = uint8(v2.Weight) + pos += 1 + // field[3] v2.Preference + buf[pos] = uint8(v2.Preference) + pos += 1 + // field[3] v2.Type + o.PutUint32(buf[pos:pos+4], uint32(v2.Type)) + pos += 4 + // field[3] v2.Flags + o.PutUint32(buf[pos:pos+4], uint32(v2.Flags)) + pos += 4 + // field[3] v2.Proto + o.PutUint32(buf[pos:pos+4], uint32(v2.Proto)) + pos += 4 + // field[3] v2.Nh + // field[4] v2.Nh.Address + copy(buf[pos:pos+16], v2.Nh.Address.XXX_UnionData[:]) + pos += 16 + // field[4] v2.Nh.ViaLabel + o.PutUint32(buf[pos:pos+4], uint32(v2.Nh.ViaLabel)) + pos += 4 + // field[4] v2.Nh.ObjID + o.PutUint32(buf[pos:pos+4], uint32(v2.Nh.ObjID)) + pos += 4 + // field[4] v2.Nh.ClassifyTableIndex + o.PutUint32(buf[pos:pos+4], uint32(v2.Nh.ClassifyTableIndex)) + pos += 4 + // field[3] v2.NLabels + buf[pos] = uint8(v2.NLabels) + pos += 1 + // field[3] v2.LabelStack + for j3 := 0; j3 < 16; j3++ { + var v3 FibMplsLabel + if j3 < len(v2.LabelStack) { + v3 = v2.LabelStack[j3] + } + // field[4] v3.IsUniform + buf[pos] = uint8(v3.IsUniform) + pos += 1 + // field[4] v3.Label + o.PutUint32(buf[pos:pos+4], uint32(v3.Label)) + pos += 4 + // field[4] v3.TTL + buf[pos] = uint8(v3.TTL) + pos += 1 + // field[4] v3.Exp + buf[pos] = uint8(v3.Exp) + pos += 1 + } + } + return buf, nil +} +func (m *IPRouteDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Route + // field[2] m.Route.TableID + m.Route.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Route.StatsIndex + m.Route.StatsIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Route.Prefix + // field[3] m.Route.Prefix.Address + // field[4] m.Route.Prefix.Address.Af + m.Route.Prefix.Address.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Prefix.Address.Un + copy(m.Route.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[3] m.Route.Prefix.Len + m.Route.Prefix.Len = uint8(tmp[pos]) + pos += 1 + // field[2] m.Route.NPaths + m.Route.NPaths = uint8(tmp[pos]) + pos += 1 + // field[2] m.Route.Paths + m.Route.Paths = make([]FibPath, int(m.Route.NPaths)) + for j2 := 0; j2 < int(m.Route.NPaths); j2++ { + // field[3] m.Route.Paths[j2].SwIfIndex + m.Route.Paths[j2].SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].TableID + m.Route.Paths[j2].TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].RpfID + m.Route.Paths[j2].RpfID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].Weight + m.Route.Paths[j2].Weight = uint8(tmp[pos]) + pos += 1 + // field[3] m.Route.Paths[j2].Preference + m.Route.Paths[j2].Preference = uint8(tmp[pos]) + pos += 1 + // field[3] m.Route.Paths[j2].Type + m.Route.Paths[j2].Type = FibPathType(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].Flags + m.Route.Paths[j2].Flags = FibPathFlags(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].Proto + m.Route.Paths[j2].Proto = FibPathNhProto(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].Nh + // field[4] m.Route.Paths[j2].Nh.Address + copy(m.Route.Paths[j2].Nh.Address.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[4] m.Route.Paths[j2].Nh.ViaLabel + m.Route.Paths[j2].Nh.ViaLabel = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Nh.ObjID + m.Route.Paths[j2].Nh.ObjID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Nh.ClassifyTableIndex + m.Route.Paths[j2].Nh.ClassifyTableIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].NLabels + m.Route.Paths[j2].NLabels = uint8(tmp[pos]) + pos += 1 + // field[3] m.Route.Paths[j2].LabelStack + for j3 := 0; j3 < 16; j3++ { + // field[4] m.Route.Paths[j2].LabelStack[j3].IsUniform + m.Route.Paths[j2].LabelStack[j3].IsUniform = uint8(tmp[pos]) + pos += 1 + // field[4] m.Route.Paths[j2].LabelStack[j3].Label + m.Route.Paths[j2].LabelStack[j3].Label = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].LabelStack[j3].TTL + m.Route.Paths[j2].LabelStack[j3].TTL = uint8(tmp[pos]) + pos += 1 + // field[4] m.Route.Paths[j2].LabelStack[j3].Exp + m.Route.Paths[j2].LabelStack[j3].Exp = uint8(tmp[pos]) + pos += 1 + } + } + return nil +} + // IPRouteDump represents VPP binary API message 'ip_route_dump'. type IPRouteDump struct { - Table IPTable + Table IPTable `binapi:"ip_table,name=table" json:"table,omitempty"` } func (m *IPRouteDump) Reset() { *m = IPRouteDump{} } @@ -730,14 +3836,74 @@ func (*IPRouteDump) GetMessageName() string { return "ip_route_dump" } func (*IPRouteDump) GetCrcString() string { return "b9d2e09e" } func (*IPRouteDump) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPRouteDump) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Table + // field[2] m.Table.TableID + size += 4 + // field[2] m.Table.IsIP6 + size += 1 + // field[2] m.Table.Name + size += 64 + return size +} +func (m *IPRouteDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Table + // field[2] m.Table.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.Table.TableID)) + pos += 4 + // field[2] m.Table.IsIP6 + if m.Table.IsIP6 { + buf[pos] = 1 + } + pos += 1 + // field[2] m.Table.Name + copy(buf[pos:pos+64], m.Table.Name) + pos += 64 + return buf, nil +} +func (m *IPRouteDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Table + // field[2] m.Table.TableID + m.Table.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Table.IsIP6 + m.Table.IsIP6 = tmp[pos] != 0 + pos += 1 + // field[2] m.Table.Name + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Table.Name = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // 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 + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + Prefix Prefix `binapi:"prefix,name=prefix" json:"prefix,omitempty"` + NumberOfRanges uint8 `binapi:"u8,name=number_of_ranges" json:"number_of_ranges,omitempty"` + LowPorts []uint16 `binapi:"u16[32],name=low_ports" json:"low_ports,omitempty" struc:"[32]uint16"` + HighPorts []uint16 `binapi:"u16[32],name=high_ports" json:"high_ports,omitempty" struc:"[32]uint16"` + VrfID uint32 `binapi:"u32,name=vrf_id" json:"vrf_id,omitempty"` } func (m *IPSourceAndPortRangeCheckAddDel) Reset() { *m = IPSourceAndPortRangeCheckAddDel{} } @@ -747,9 +3913,127 @@ func (*IPSourceAndPortRangeCheckAddDel) GetMessageName() string { func (*IPSourceAndPortRangeCheckAddDel) GetCrcString() string { return "8bfc76f2" } func (*IPSourceAndPortRangeCheckAddDel) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPSourceAndPortRangeCheckAddDel) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.IsAdd + size += 1 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + size += 4 + // field[3] m.Prefix.Address.Un + size += 16 + // field[2] m.Prefix.Len + size += 1 + // field[1] m.NumberOfRanges + size += 1 + // field[1] m.LowPorts + size += 64 + // field[1] m.HighPorts + size += 64 + // field[1] m.VrfID + size += 4 + return size +} +func (m *IPSourceAndPortRangeCheckAddDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.IsAdd + if m.IsAdd { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + o.PutUint32(buf[pos:pos+4], uint32(m.Prefix.Address.Af)) + pos += 4 + // field[3] m.Prefix.Address.Un + copy(buf[pos:pos+16], m.Prefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[2] m.Prefix.Len + buf[pos] = uint8(m.Prefix.Len) + pos += 1 + // field[1] m.NumberOfRanges + buf[pos] = uint8(m.NumberOfRanges) + pos += 1 + // field[1] m.LowPorts + for i := 0; i < 32; i++ { + var x uint16 + if i < len(m.LowPorts) { + x = uint16(m.LowPorts[i]) + } + o.PutUint16(buf[pos:pos+2], uint16(x)) + pos += 2 + } + // field[1] m.HighPorts + for i := 0; i < 32; i++ { + var x uint16 + if i < len(m.HighPorts) { + x = uint16(m.HighPorts[i]) + } + o.PutUint16(buf[pos:pos+2], uint16(x)) + pos += 2 + } + // field[1] m.VrfID + o.PutUint32(buf[pos:pos+4], uint32(m.VrfID)) + pos += 4 + return buf, nil +} +func (m *IPSourceAndPortRangeCheckAddDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.IsAdd + m.IsAdd = tmp[pos] != 0 + pos += 1 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + m.Prefix.Address.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Prefix.Address.Un + copy(m.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[2] m.Prefix.Len + m.Prefix.Len = uint8(tmp[pos]) + pos += 1 + // field[1] m.NumberOfRanges + m.NumberOfRanges = uint8(tmp[pos]) + pos += 1 + // field[1] m.LowPorts + m.LowPorts = make([]uint16, 32) + for i := 0; i < len(m.LowPorts); i++ { + m.LowPorts[i] = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + } + // field[1] m.HighPorts + m.HighPorts = make([]uint16, 32) + for i := 0; i < len(m.HighPorts); i++ { + m.HighPorts[i] = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + } + // field[1] m.VrfID + m.VrfID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPSourceAndPortRangeCheckAddDelReply represents VPP binary API message 'ip_source_and_port_range_check_add_del_reply'. type IPSourceAndPortRangeCheckAddDelReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *IPSourceAndPortRangeCheckAddDelReply) Reset() { *m = IPSourceAndPortRangeCheckAddDelReply{} } @@ -761,14 +4045,50 @@ func (*IPSourceAndPortRangeCheckAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPSourceAndPortRangeCheckAddDelReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *IPSourceAndPortRangeCheckAddDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *IPSourceAndPortRangeCheckAddDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // 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 + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + TCPInVrfID uint32 `binapi:"u32,name=tcp_in_vrf_id" json:"tcp_in_vrf_id,omitempty"` + TCPOutVrfID uint32 `binapi:"u32,name=tcp_out_vrf_id" json:"tcp_out_vrf_id,omitempty"` + UDPInVrfID uint32 `binapi:"u32,name=udp_in_vrf_id" json:"udp_in_vrf_id,omitempty"` + UDPOutVrfID uint32 `binapi:"u32,name=udp_out_vrf_id" json:"udp_out_vrf_id,omitempty"` } func (m *IPSourceAndPortRangeCheckInterfaceAddDel) Reset() { @@ -782,9 +4102,87 @@ func (*IPSourceAndPortRangeCheckInterfaceAddDel) GetMessageType() api.MessageTyp return api.RequestMessage } +func (m *IPSourceAndPortRangeCheckInterfaceAddDel) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.IsAdd + size += 1 + // field[1] m.SwIfIndex + size += 4 + // field[1] m.TCPInVrfID + size += 4 + // field[1] m.TCPOutVrfID + size += 4 + // field[1] m.UDPInVrfID + size += 4 + // field[1] m.UDPOutVrfID + size += 4 + return size +} +func (m *IPSourceAndPortRangeCheckInterfaceAddDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.IsAdd + if m.IsAdd { + buf[pos] = 1 + } + pos += 1 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.TCPInVrfID + o.PutUint32(buf[pos:pos+4], uint32(m.TCPInVrfID)) + pos += 4 + // field[1] m.TCPOutVrfID + o.PutUint32(buf[pos:pos+4], uint32(m.TCPOutVrfID)) + pos += 4 + // field[1] m.UDPInVrfID + o.PutUint32(buf[pos:pos+4], uint32(m.UDPInVrfID)) + pos += 4 + // field[1] m.UDPOutVrfID + o.PutUint32(buf[pos:pos+4], uint32(m.UDPOutVrfID)) + pos += 4 + return buf, nil +} +func (m *IPSourceAndPortRangeCheckInterfaceAddDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.IsAdd + m.IsAdd = tmp[pos] != 0 + pos += 1 + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.TCPInVrfID + m.TCPInVrfID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.TCPOutVrfID + m.TCPOutVrfID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.UDPInVrfID + m.UDPInVrfID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.UDPOutVrfID + m.UDPOutVrfID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPSourceAndPortRangeCheckInterfaceAddDelReply represents VPP binary API message 'ip_source_and_port_range_check_interface_add_del_reply'. type IPSourceAndPortRangeCheckInterfaceAddDelReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *IPSourceAndPortRangeCheckInterfaceAddDelReply) Reset() { @@ -798,11 +4196,47 @@ func (*IPSourceAndPortRangeCheckInterfaceAddDelReply) GetMessageType() api.Messa return api.ReplyMessage } +func (m *IPSourceAndPortRangeCheckInterfaceAddDelReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *IPSourceAndPortRangeCheckInterfaceAddDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *IPSourceAndPortRangeCheckInterfaceAddDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPSourceCheckInterfaceAddDel represents VPP binary API message 'ip_source_check_interface_add_del'. type IPSourceCheckInterfaceAddDel struct { - IsAdd bool - Loose bool - SwIfIndex InterfaceIndex + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + Loose bool `binapi:"bool,name=loose" json:"loose,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *IPSourceCheckInterfaceAddDel) Reset() { *m = IPSourceCheckInterfaceAddDel{} } @@ -812,9 +4246,65 @@ func (*IPSourceCheckInterfaceAddDel) GetMessageName() string { func (*IPSourceCheckInterfaceAddDel) GetCrcString() string { return "6612356b" } func (*IPSourceCheckInterfaceAddDel) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPSourceCheckInterfaceAddDel) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.IsAdd + size += 1 + // field[1] m.Loose + size += 1 + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *IPSourceCheckInterfaceAddDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.IsAdd + if m.IsAdd { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Loose + if m.Loose { + buf[pos] = 1 + } + pos += 1 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *IPSourceCheckInterfaceAddDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.IsAdd + m.IsAdd = tmp[pos] != 0 + pos += 1 + // field[1] m.Loose + m.Loose = tmp[pos] != 0 + pos += 1 + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPSourceCheckInterfaceAddDelReply represents VPP binary API message 'ip_source_check_interface_add_del_reply'. type IPSourceCheckInterfaceAddDelReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *IPSourceCheckInterfaceAddDelReply) Reset() { *m = IPSourceCheckInterfaceAddDelReply{} } @@ -824,10 +4314,46 @@ func (*IPSourceCheckInterfaceAddDelReply) GetMessageName() string { func (*IPSourceCheckInterfaceAddDelReply) GetCrcString() string { return "e8d4e804" } func (*IPSourceCheckInterfaceAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPSourceCheckInterfaceAddDelReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *IPSourceCheckInterfaceAddDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *IPSourceCheckInterfaceAddDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPTableAddDel represents VPP binary API message 'ip_table_add_del'. type IPTableAddDel struct { - IsAdd bool - Table IPTable + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + Table IPTable `binapi:"ip_table,name=table" json:"table,omitempty"` } func (m *IPTableAddDel) Reset() { *m = IPTableAddDel{} } @@ -835,9 +4361,79 @@ func (*IPTableAddDel) GetMessageName() string { return "ip_table_add_de func (*IPTableAddDel) GetCrcString() string { return "0ffdaec0" } func (*IPTableAddDel) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPTableAddDel) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.IsAdd + size += 1 + // field[1] m.Table + // field[2] m.Table.TableID + size += 4 + // field[2] m.Table.IsIP6 + size += 1 + // field[2] m.Table.Name + size += 64 + return size +} +func (m *IPTableAddDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.IsAdd + if m.IsAdd { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Table + // field[2] m.Table.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.Table.TableID)) + pos += 4 + // field[2] m.Table.IsIP6 + if m.Table.IsIP6 { + buf[pos] = 1 + } + pos += 1 + // field[2] m.Table.Name + copy(buf[pos:pos+64], m.Table.Name) + pos += 64 + return buf, nil +} +func (m *IPTableAddDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.IsAdd + m.IsAdd = tmp[pos] != 0 + pos += 1 + // field[1] m.Table + // field[2] m.Table.TableID + m.Table.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Table.IsIP6 + m.Table.IsIP6 = tmp[pos] != 0 + pos += 1 + // field[2] m.Table.Name + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Table.Name = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // IPTableAddDelReply represents VPP binary API message 'ip_table_add_del_reply'. type IPTableAddDelReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *IPTableAddDelReply) Reset() { *m = IPTableAddDelReply{} } @@ -845,9 +4441,45 @@ func (*IPTableAddDelReply) GetMessageName() string { return "ip_table_a func (*IPTableAddDelReply) GetCrcString() string { return "e8d4e804" } func (*IPTableAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPTableAddDelReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *IPTableAddDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *IPTableAddDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPTableDetails represents VPP binary API message 'ip_table_details'. type IPTableDetails struct { - Table IPTable + Table IPTable `binapi:"ip_table,name=table" json:"table,omitempty"` } func (m *IPTableDetails) Reset() { *m = IPTableDetails{} } @@ -855,6 +4487,66 @@ func (*IPTableDetails) GetMessageName() string { return "ip_table_detai func (*IPTableDetails) GetCrcString() string { return "c79fca0f" } func (*IPTableDetails) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPTableDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Table + // field[2] m.Table.TableID + size += 4 + // field[2] m.Table.IsIP6 + size += 1 + // field[2] m.Table.Name + size += 64 + return size +} +func (m *IPTableDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Table + // field[2] m.Table.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.Table.TableID)) + pos += 4 + // field[2] m.Table.IsIP6 + if m.Table.IsIP6 { + buf[pos] = 1 + } + pos += 1 + // field[2] m.Table.Name + copy(buf[pos:pos+64], m.Table.Name) + pos += 64 + return buf, nil +} +func (m *IPTableDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Table + // field[2] m.Table.TableID + m.Table.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Table.IsIP6 + m.Table.IsIP6 = tmp[pos] != 0 + pos += 1 + // field[2] m.Table.Name + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Table.Name = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // IPTableDump represents VPP binary API message 'ip_table_dump'. type IPTableDump struct{} @@ -863,9 +4555,37 @@ func (*IPTableDump) GetMessageName() string { return "ip_table_dump" } func (*IPTableDump) GetCrcString() string { return "51077d14" } func (*IPTableDump) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPTableDump) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *IPTableDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *IPTableDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + // IPTableFlush represents VPP binary API message 'ip_table_flush'. type IPTableFlush struct { - Table IPTable + Table IPTable `binapi:"ip_table,name=table" json:"table,omitempty"` } func (m *IPTableFlush) Reset() { *m = IPTableFlush{} } @@ -873,9 +4593,69 @@ func (*IPTableFlush) GetMessageName() string { return "ip_table_flush" func (*IPTableFlush) GetCrcString() string { return "b9d2e09e" } func (*IPTableFlush) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPTableFlush) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Table + // field[2] m.Table.TableID + size += 4 + // field[2] m.Table.IsIP6 + size += 1 + // field[2] m.Table.Name + size += 64 + return size +} +func (m *IPTableFlush) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Table + // field[2] m.Table.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.Table.TableID)) + pos += 4 + // field[2] m.Table.IsIP6 + if m.Table.IsIP6 { + buf[pos] = 1 + } + pos += 1 + // field[2] m.Table.Name + copy(buf[pos:pos+64], m.Table.Name) + pos += 64 + return buf, nil +} +func (m *IPTableFlush) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Table + // field[2] m.Table.TableID + m.Table.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Table.IsIP6 + m.Table.IsIP6 = tmp[pos] != 0 + pos += 1 + // field[2] m.Table.Name + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Table.Name = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // IPTableFlushReply represents VPP binary API message 'ip_table_flush_reply'. type IPTableFlushReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *IPTableFlushReply) Reset() { *m = IPTableFlushReply{} } @@ -883,9 +4663,45 @@ func (*IPTableFlushReply) GetMessageName() string { return "ip_table_fl func (*IPTableFlushReply) GetCrcString() string { return "e8d4e804" } func (*IPTableFlushReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPTableFlushReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *IPTableFlushReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *IPTableFlushReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPTableReplaceBegin represents VPP binary API message 'ip_table_replace_begin'. type IPTableReplaceBegin struct { - Table IPTable + Table IPTable `binapi:"ip_table,name=table" json:"table,omitempty"` } func (m *IPTableReplaceBegin) Reset() { *m = IPTableReplaceBegin{} } @@ -893,9 +4709,69 @@ func (*IPTableReplaceBegin) GetMessageName() string { return "ip_table_ func (*IPTableReplaceBegin) GetCrcString() string { return "b9d2e09e" } func (*IPTableReplaceBegin) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPTableReplaceBegin) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Table + // field[2] m.Table.TableID + size += 4 + // field[2] m.Table.IsIP6 + size += 1 + // field[2] m.Table.Name + size += 64 + return size +} +func (m *IPTableReplaceBegin) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Table + // field[2] m.Table.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.Table.TableID)) + pos += 4 + // field[2] m.Table.IsIP6 + if m.Table.IsIP6 { + buf[pos] = 1 + } + pos += 1 + // field[2] m.Table.Name + copy(buf[pos:pos+64], m.Table.Name) + pos += 64 + return buf, nil +} +func (m *IPTableReplaceBegin) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Table + // field[2] m.Table.TableID + m.Table.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Table.IsIP6 + m.Table.IsIP6 = tmp[pos] != 0 + pos += 1 + // field[2] m.Table.Name + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Table.Name = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // IPTableReplaceBeginReply represents VPP binary API message 'ip_table_replace_begin_reply'. type IPTableReplaceBeginReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *IPTableReplaceBeginReply) Reset() { *m = IPTableReplaceBeginReply{} } @@ -903,9 +4779,45 @@ func (*IPTableReplaceBeginReply) GetMessageName() string { return "ip_t func (*IPTableReplaceBeginReply) GetCrcString() string { return "e8d4e804" } func (*IPTableReplaceBeginReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPTableReplaceBeginReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *IPTableReplaceBeginReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *IPTableReplaceBeginReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPTableReplaceEnd represents VPP binary API message 'ip_table_replace_end'. type IPTableReplaceEnd struct { - Table IPTable + Table IPTable `binapi:"ip_table,name=table" json:"table,omitempty"` } func (m *IPTableReplaceEnd) Reset() { *m = IPTableReplaceEnd{} } @@ -913,9 +4825,69 @@ func (*IPTableReplaceEnd) GetMessageName() string { return "ip_table_re func (*IPTableReplaceEnd) GetCrcString() string { return "b9d2e09e" } func (*IPTableReplaceEnd) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPTableReplaceEnd) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Table + // field[2] m.Table.TableID + size += 4 + // field[2] m.Table.IsIP6 + size += 1 + // field[2] m.Table.Name + size += 64 + return size +} +func (m *IPTableReplaceEnd) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Table + // field[2] m.Table.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.Table.TableID)) + pos += 4 + // field[2] m.Table.IsIP6 + if m.Table.IsIP6 { + buf[pos] = 1 + } + pos += 1 + // field[2] m.Table.Name + copy(buf[pos:pos+64], m.Table.Name) + pos += 64 + return buf, nil +} +func (m *IPTableReplaceEnd) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Table + // field[2] m.Table.TableID + m.Table.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Table.IsIP6 + m.Table.IsIP6 = tmp[pos] != 0 + pos += 1 + // field[2] m.Table.Name + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Table.Name = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // IPTableReplaceEndReply represents VPP binary API message 'ip_table_replace_end_reply'. type IPTableReplaceEndReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *IPTableReplaceEndReply) Reset() { *m = IPTableReplaceEndReply{} } @@ -923,10 +4895,46 @@ func (*IPTableReplaceEndReply) GetMessageName() string { return "ip_tab func (*IPTableReplaceEndReply) GetCrcString() string { return "e8d4e804" } func (*IPTableReplaceEndReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPTableReplaceEndReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *IPTableReplaceEndReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *IPTableReplaceEndReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPUnnumberedDetails represents VPP binary API message 'ip_unnumbered_details'. type IPUnnumberedDetails struct { - SwIfIndex InterfaceIndex - IPSwIfIndex InterfaceIndex + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IPSwIfIndex InterfaceIndex `binapi:"interface_index,name=ip_sw_if_index" json:"ip_sw_if_index,omitempty"` } func (m *IPUnnumberedDetails) Reset() { *m = IPUnnumberedDetails{} } @@ -934,9 +4942,53 @@ func (*IPUnnumberedDetails) GetMessageName() string { return "ip_unnumb func (*IPUnnumberedDetails) GetCrcString() string { return "aa12a483" } func (*IPUnnumberedDetails) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *IPUnnumberedDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.IPSwIfIndex + size += 4 + return size +} +func (m *IPUnnumberedDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.IPSwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.IPSwIfIndex)) + pos += 4 + return buf, nil +} +func (m *IPUnnumberedDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IPSwIfIndex + m.IPSwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // IPUnnumberedDump represents VPP binary API message 'ip_unnumbered_dump'. type IPUnnumberedDump struct { - SwIfIndex InterfaceIndex + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *IPUnnumberedDump) Reset() { *m = IPUnnumberedDump{} } @@ -944,13 +4996,49 @@ func (*IPUnnumberedDump) GetMessageName() string { return "ip_unnumbere func (*IPUnnumberedDump) GetCrcString() string { return "f9e6675e" } func (*IPUnnumberedDump) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *IPUnnumberedDump) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *IPUnnumberedDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *IPUnnumberedDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // 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"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + Prefix Mprefix `binapi:"mprefix,name=prefix" json:"prefix,omitempty"` + IPPacketLen uint16 `binapi:"u16,name=ip_packet_len" json:"ip_packet_len,omitempty"` + IPPacketData []byte `binapi:"u8[256],name=ip_packet_data" json:"ip_packet_data,omitempty" struc:"[256]byte"` } func (m *MfibSignalDetails) Reset() { *m = MfibSignalDetails{} } @@ -958,6 +5046,110 @@ func (*MfibSignalDetails) GetMessageName() string { return "mfib_signal func (*MfibSignalDetails) GetCrcString() string { return "64398a9a" } func (*MfibSignalDetails) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *MfibSignalDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.TableID + size += 4 + // field[1] m.Prefix + // field[2] m.Prefix.Af + size += 4 + // field[2] m.Prefix.GrpAddressLength + size += 2 + // field[2] m.Prefix.GrpAddress + size += 16 + // field[2] m.Prefix.SrcAddress + size += 16 + // field[1] m.IPPacketLen + size += 2 + // field[1] m.IPPacketData + size += 256 + return size +} +func (m *MfibSignalDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.TableID)) + pos += 4 + // field[1] m.Prefix + // field[2] m.Prefix.Af + o.PutUint32(buf[pos:pos+4], uint32(m.Prefix.Af)) + pos += 4 + // field[2] m.Prefix.GrpAddressLength + o.PutUint16(buf[pos:pos+2], uint16(m.Prefix.GrpAddressLength)) + pos += 2 + // field[2] m.Prefix.GrpAddress + copy(buf[pos:pos+16], m.Prefix.GrpAddress.XXX_UnionData[:]) + pos += 16 + // field[2] m.Prefix.SrcAddress + copy(buf[pos:pos+16], m.Prefix.SrcAddress.XXX_UnionData[:]) + pos += 16 + // field[1] m.IPPacketLen + o.PutUint16(buf[pos:pos+2], uint16(m.IPPacketLen)) + pos += 2 + // field[1] m.IPPacketData + for i := 0; i < 256; i++ { + var x uint8 + if i < len(m.IPPacketData) { + x = uint8(m.IPPacketData[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + return buf, nil +} +func (m *MfibSignalDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.TableID + m.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Prefix + // field[2] m.Prefix.Af + m.Prefix.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Prefix.GrpAddressLength + m.Prefix.GrpAddressLength = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[2] m.Prefix.GrpAddress + copy(m.Prefix.GrpAddress.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[2] m.Prefix.SrcAddress + copy(m.Prefix.SrcAddress.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[1] m.IPPacketLen + m.IPPacketLen = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[1] m.IPPacketData + m.IPPacketData = make([]uint8, 256) + for i := 0; i < len(m.IPPacketData); i++ { + m.IPPacketData[i] = uint8(tmp[pos]) + pos += 1 + } + return nil +} + // MfibSignalDump represents VPP binary API message 'mfib_signal_dump'. type MfibSignalDump struct{} @@ -966,17 +5158,45 @@ func (*MfibSignalDump) GetMessageName() string { return "mfib_signal_du func (*MfibSignalDump) GetCrcString() string { return "51077d14" } func (*MfibSignalDump) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *MfibSignalDump) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *MfibSignalDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *MfibSignalDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + // 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 + VrfID uint32 `binapi:"u32,name=vrf_id" json:"vrf_id,omitempty"` + IsIPv6 bool `binapi:"bool,name=is_ipv6" json:"is_ipv6,omitempty"` + Src bool `binapi:"bool,name=src" json:"src,omitempty"` + Dst bool `binapi:"bool,name=dst" json:"dst,omitempty"` + Sport bool `binapi:"bool,name=sport" json:"sport,omitempty"` + Dport bool `binapi:"bool,name=dport" json:"dport,omitempty"` + Proto bool `binapi:"bool,name=proto" json:"proto,omitempty"` + Reverse bool `binapi:"bool,name=reverse" json:"reverse,omitempty"` + Symmetric bool `binapi:"bool,name=symmetric" json:"symmetric,omitempty"` } func (m *SetIPFlowHash) Reset() { *m = SetIPFlowHash{} } @@ -984,9 +5204,125 @@ func (*SetIPFlowHash) GetMessageName() string { return "set_ip_flow_has func (*SetIPFlowHash) GetCrcString() string { return "084ee09e" } func (*SetIPFlowHash) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SetIPFlowHash) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.VrfID + size += 4 + // field[1] m.IsIPv6 + size += 1 + // field[1] m.Src + size += 1 + // field[1] m.Dst + size += 1 + // field[1] m.Sport + size += 1 + // field[1] m.Dport + size += 1 + // field[1] m.Proto + size += 1 + // field[1] m.Reverse + size += 1 + // field[1] m.Symmetric + size += 1 + return size +} +func (m *SetIPFlowHash) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.VrfID + o.PutUint32(buf[pos:pos+4], uint32(m.VrfID)) + pos += 4 + // field[1] m.IsIPv6 + if m.IsIPv6 { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Src + if m.Src { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Dst + if m.Dst { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Sport + if m.Sport { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Dport + if m.Dport { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Proto + if m.Proto { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Reverse + if m.Reverse { + buf[pos] = 1 + } + pos += 1 + // field[1] m.Symmetric + if m.Symmetric { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *SetIPFlowHash) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.VrfID + m.VrfID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IsIPv6 + m.IsIPv6 = tmp[pos] != 0 + pos += 1 + // field[1] m.Src + m.Src = tmp[pos] != 0 + pos += 1 + // field[1] m.Dst + m.Dst = tmp[pos] != 0 + pos += 1 + // field[1] m.Sport + m.Sport = tmp[pos] != 0 + pos += 1 + // field[1] m.Dport + m.Dport = tmp[pos] != 0 + pos += 1 + // field[1] m.Proto + m.Proto = tmp[pos] != 0 + pos += 1 + // field[1] m.Reverse + m.Reverse = tmp[pos] != 0 + pos += 1 + // field[1] m.Symmetric + m.Symmetric = tmp[pos] != 0 + pos += 1 + return nil +} + // SetIPFlowHashReply represents VPP binary API message 'set_ip_flow_hash_reply'. type SetIPFlowHashReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SetIPFlowHashReply) Reset() { *m = SetIPFlowHashReply{} } @@ -994,10 +5330,46 @@ func (*SetIPFlowHashReply) GetMessageName() string { return "set_ip_flo func (*SetIPFlowHashReply) GetCrcString() string { return "e8d4e804" } func (*SetIPFlowHashReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SetIPFlowHashReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SetIPFlowHashReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SetIPFlowHashReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceIP6EnableDisable represents VPP binary API message 'sw_interface_ip6_enable_disable'. type SwInterfaceIP6EnableDisable struct { - SwIfIndex InterfaceIndex - Enable bool + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Enable bool `binapi:"bool,name=enable" json:"enable,omitempty"` } func (m *SwInterfaceIP6EnableDisable) Reset() { *m = SwInterfaceIP6EnableDisable{} } @@ -1005,9 +5377,55 @@ func (*SwInterfaceIP6EnableDisable) GetMessageName() string { return "s func (*SwInterfaceIP6EnableDisable) GetCrcString() string { return "ae6cfcfb" } func (*SwInterfaceIP6EnableDisable) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceIP6EnableDisable) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Enable + size += 1 + return size +} +func (m *SwInterfaceIP6EnableDisable) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Enable + if m.Enable { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *SwInterfaceIP6EnableDisable) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Enable + m.Enable = tmp[pos] != 0 + pos += 1 + return nil +} + // SwInterfaceIP6EnableDisableReply represents VPP binary API message 'sw_interface_ip6_enable_disable_reply'. type SwInterfaceIP6EnableDisableReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SwInterfaceIP6EnableDisableReply) Reset() { *m = SwInterfaceIP6EnableDisableReply{} } @@ -1017,10 +5435,46 @@ func (*SwInterfaceIP6EnableDisableReply) GetMessageName() string { func (*SwInterfaceIP6EnableDisableReply) GetCrcString() string { return "e8d4e804" } func (*SwInterfaceIP6EnableDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SwInterfaceIP6EnableDisableReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceIP6EnableDisableReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceIP6EnableDisableReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceIP6SetLinkLocalAddress represents VPP binary API message 'sw_interface_ip6_set_link_local_address'. type SwInterfaceIP6SetLinkLocalAddress struct { - SwIfIndex InterfaceIndex - IP IP6Address + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IP IP6Address `binapi:"ip6_address,name=ip" json:"ip,omitempty"` } func (m *SwInterfaceIP6SetLinkLocalAddress) Reset() { *m = SwInterfaceIP6SetLinkLocalAddress{} } @@ -1030,9 +5484,61 @@ func (*SwInterfaceIP6SetLinkLocalAddress) GetMessageName() string { func (*SwInterfaceIP6SetLinkLocalAddress) GetCrcString() string { return "2931d9fa" } func (*SwInterfaceIP6SetLinkLocalAddress) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SwInterfaceIP6SetLinkLocalAddress) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.IP + size += 16 + return size +} +func (m *SwInterfaceIP6SetLinkLocalAddress) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.IP + for i := 0; i < 16; i++ { + var x uint8 + if i < len(m.IP) { + x = uint8(m.IP[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + return buf, nil +} +func (m *SwInterfaceIP6SetLinkLocalAddress) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IP + for i := 0; i < len(m.IP); i++ { + m.IP[i] = uint8(tmp[pos]) + pos += 1 + } + return nil +} + // SwInterfaceIP6SetLinkLocalAddressReply represents VPP binary API message 'sw_interface_ip6_set_link_local_address_reply'. type SwInterfaceIP6SetLinkLocalAddressReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SwInterfaceIP6SetLinkLocalAddressReply) Reset() { @@ -1046,7 +5552,44 @@ func (*SwInterfaceIP6SetLinkLocalAddressReply) GetMessageType() api.MessageType return api.ReplyMessage } -func init() { +func (m *SwInterfaceIP6SetLinkLocalAddressReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceIP6SetLinkLocalAddressReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceIP6SetLinkLocalAddressReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + +func init() { file_ip_binapi_init() } +func file_ip_binapi_init() { api.RegisterMessage((*IoamDisable)(nil), "ip.IoamDisable") api.RegisterMessage((*IoamDisableReply)(nil), "ip.IoamDisableReply") api.RegisterMessage((*IoamEnable)(nil), "ip.IoamEnable") @@ -1175,498 +5718,13 @@ func AllMessages() []api.Message { } } -// 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 _ = codec.DecodeString var _ = bytes.NewBuffer var _ = context.Background var _ = io.Copy var _ = strconv.Itoa var _ = struc.Pack +var _ = binary.BigEndian +var _ = math.Float32bits diff --git a/examples/binapi/ip/ip_rpc.ba.go b/examples/binapi/ip/ip_rpc.ba.go new file mode 100644 index 0000000..e0580d5 --- /dev/null +++ b/examples/binapi/ip/ip_rpc.ba.go @@ -0,0 +1,497 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package ip + +import ( + "context" + "io" + + api "git.fd.io/govpp.git/api" +) + +// 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 +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = context.Background +var _ = io.Copy diff --git a/examples/binapi/ip_types/ip_types.ba.go b/examples/binapi/ip_types/ip_types.ba.go index e812b8b..9335060 100644 --- a/examples/binapi/ip_types/ip_types.ba.go +++ b/examples/binapi/ip_types/ip_types.ba.go @@ -1,12 +1,15 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty +// VPP: 20.01-45~g7a071e370~b63 // source: /usr/share/vpp/api/core/ip_types.api.json /* -Package ip_types is a generated VPP binary API for 'ip_types' module. +Package ip_types contains generated code for VPP binary API defined by ip_types.api (version 3.0.0). It consists of: - 4 enums 5 aliases + 4 enums 6 types 1 union */ @@ -15,13 +18,22 @@ package ip_types import ( "bytes" "context" + "encoding/binary" "io" + "math" "strconv" api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" struc "github.com/lunixbochs/struc" ) +// 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 // please upgrade the GoVPP api package + const ( // ModuleName is the name of this module. ModuleName = "ip_types" @@ -39,22 +51,23 @@ const ( 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, -} +var ( + AddressFamily_name = map[uint32]string{ + 0: "ADDRESS_IP4", + 1: "ADDRESS_IP6", + } + 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)) + return "AddressFamily(" + strconv.Itoa(int(x)) + ")" } // IPDscp represents VPP binary API enum 'ip_dscp'. @@ -84,60 +97,61 @@ const ( 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, -} +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 strconv.Itoa(int(x)) + return "IPDscp(" + strconv.Itoa(int(x)) + ")" } // IPEcn represents VPP binary API enum 'ip_ecn'. @@ -150,26 +164,27 @@ const ( 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, -} +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 strconv.Itoa(int(x)) + return "IPEcn(" + strconv.Itoa(int(x)) + ")" } // IPProto represents VPP binary API enum 'ip_proto'. @@ -190,42 +205,43 @@ const ( 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, -} +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", + } + 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)) + return "IPProto(" + strconv.Itoa(int(x)) + ")" } // AddressWithPrefix represents VPP binary API alias 'address_with_prefix'. @@ -245,50 +261,50 @@ type IP6AddressWithPrefix IP6Prefix // Address represents VPP binary API type 'address'. type Address struct { - Af AddressFamily - Un AddressUnion + Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` + Un AddressUnion `binapi:"address_union,name=un" json:"un,omitempty"` } func (*Address) GetTypeName() string { return "address" } // IP4Prefix represents VPP binary API type 'ip4_prefix'. type IP4Prefix struct { - Address IP4Address - Len uint8 + Address IP4Address `binapi:"ip4_address,name=address" json:"address,omitempty"` + Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` } func (*IP4Prefix) GetTypeName() string { return "ip4_prefix" } // IP6Prefix represents VPP binary API type 'ip6_prefix'. type IP6Prefix struct { - Address IP6Address - Len uint8 + Address IP6Address `binapi:"ip6_address,name=address" json:"address,omitempty"` + Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` } 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 + 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"` } func (*Mprefix) GetTypeName() string { return "mprefix" } // Prefix represents VPP binary API type 'prefix'. type Prefix struct { - Address Address - Len uint8 + Address Address `binapi:"address,name=address" json:"address,omitempty"` + Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` } func (*Prefix) GetTypeName() string { return "prefix" } // PrefixMatcher represents VPP binary API type 'prefix_matcher'. type PrefixMatcher struct { - Le uint8 - Ge uint8 + Le uint8 `binapi:"u8,name=le" json:"le,omitempty"` + Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"` } func (*PrefixMatcher) GetTypeName() string { return "prefix_matcher" } @@ -334,16 +350,13 @@ func (u *AddressUnion) GetIP6() (a IP6Address) { 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 _ = codec.DecodeString var _ = bytes.NewBuffer var _ = context.Background var _ = io.Copy var _ = strconv.Itoa var _ = struc.Pack +var _ = binary.BigEndian +var _ = math.Float32bits diff --git a/examples/binapi/memclnt/memclnt.ba.go b/examples/binapi/memclnt/memclnt.ba.go index a3ca389..c6b1256 100644 --- a/examples/binapi/memclnt/memclnt.ba.go +++ b/examples/binapi/memclnt/memclnt.ba.go @@ -1,26 +1,37 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty +// VPP: 20.01-45~g7a071e370~b63 // source: /usr/share/vpp/api/core/memclnt.api.json /* -Package memclnt is a generated VPP binary API for 'memclnt' module. +Package memclnt contains generated code for VPP binary API defined by memclnt.api (version 2.1.0). It consists of: - 2 types 22 messages - 13 services + 2 types */ package memclnt import ( "bytes" "context" + "encoding/binary" "io" + "math" "strconv" api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" struc "github.com/lunixbochs/struc" ) +// 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 // please upgrade the GoVPP api package + const ( // ModuleName is the name of this module. ModuleName = "memclnt" @@ -32,18 +43,18 @@ const ( // MessageTableEntry represents VPP binary API type 'message_table_entry'. type MessageTableEntry struct { - Index uint16 - Name string `struc:"[64]byte"` + Index uint16 `binapi:"u16,name=index" json:"index,omitempty"` + Name string `binapi:"string[64],name=name" json:"name,omitempty" 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"` + 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" struc:"[64]byte"` } func (*ModuleVersion) GetTypeName() string { return "module_version" } @@ -56,11 +67,39 @@ 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() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *APIVersions) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *APIVersions) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + // APIVersionsReply represents VPP binary API message 'api_versions_reply'. type APIVersionsReply struct { - Retval int32 - Count uint32 `struc:"sizeof=APIVersions"` - APIVersions []ModuleVersion + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"count,omitempty" struc:"sizeof=APIVersions"` + APIVersions []ModuleVersion `binapi:"module_version[count],name=api_versions" json:"api_versions,omitempty"` } func (m *APIVersionsReply) Reset() { *m = APIVersionsReply{} } @@ -68,9 +107,107 @@ func (*APIVersionsReply) GetMessageName() string { return "api_versions func (*APIVersionsReply) GetCrcString() string { return "5f0d99d6" } func (*APIVersionsReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *APIVersionsReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.Count + size += 4 + // field[1] m.APIVersions + for j1 := 0; j1 < len(m.APIVersions); j1++ { + var s1 ModuleVersion + _ = s1 + if j1 < len(m.APIVersions) { + s1 = m.APIVersions[j1] + } + // field[2] s1.Major + size += 4 + // field[2] s1.Minor + size += 4 + // field[2] s1.Patch + size += 4 + // field[2] s1.Name + size += 64 + } + return size +} +func (m *APIVersionsReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.Count + o.PutUint32(buf[pos:pos+4], uint32(len(m.APIVersions))) + pos += 4 + // field[1] m.APIVersions + for j1 := 0; j1 < len(m.APIVersions); j1++ { + var v1 ModuleVersion + if j1 < len(m.APIVersions) { + v1 = m.APIVersions[j1] + } + // field[2] v1.Major + o.PutUint32(buf[pos:pos+4], uint32(v1.Major)) + pos += 4 + // field[2] v1.Minor + o.PutUint32(buf[pos:pos+4], uint32(v1.Minor)) + pos += 4 + // field[2] v1.Patch + o.PutUint32(buf[pos:pos+4], uint32(v1.Patch)) + pos += 4 + // field[2] v1.Name + copy(buf[pos:pos+64], v1.Name) + pos += 64 + } + return buf, nil +} +func (m *APIVersionsReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Count + m.Count = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.APIVersions + m.APIVersions = make([]ModuleVersion, int(m.Count)) + for j1 := 0; j1 < int(m.Count); j1++ { + // field[2] m.APIVersions[j1].Major + m.APIVersions[j1].Major = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.APIVersions[j1].Minor + m.APIVersions[j1].Minor = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.APIVersions[j1].Patch + m.APIVersions[j1].Patch = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.APIVersions[j1].Name + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.APIVersions[j1].Name = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + } + return nil +} + // GetFirstMsgID represents VPP binary API message 'get_first_msg_id'. type GetFirstMsgID struct { - Name string `struc:"[64]byte"` + Name string `binapi:"string[64],name=name" json:"name,omitempty" struc:"[64]byte"` } func (m *GetFirstMsgID) Reset() { *m = GetFirstMsgID{} } @@ -78,10 +215,49 @@ func (*GetFirstMsgID) GetMessageName() string { return "get_first_msg_i func (*GetFirstMsgID) GetCrcString() string { return "ebf79a66" } func (*GetFirstMsgID) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *GetFirstMsgID) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Name + size += 64 + return size +} +func (m *GetFirstMsgID) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Name + copy(buf[pos:pos+64], m.Name) + pos += 64 + return buf, nil +} +func (m *GetFirstMsgID) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Name + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Name = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // GetFirstMsgIDReply represents VPP binary API message 'get_first_msg_id_reply'. type GetFirstMsgIDReply struct { - Retval int32 - FirstMsgID uint16 + 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{} } @@ -89,12 +265,56 @@ func (*GetFirstMsgIDReply) GetMessageName() string { return "get_first_ func (*GetFirstMsgIDReply) GetCrcString() string { return "7d337472" } func (*GetFirstMsgIDReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *GetFirstMsgIDReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.FirstMsgID + size += 2 + return size +} +func (m *GetFirstMsgIDReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.FirstMsgID + o.PutUint16(buf[pos:pos+2], uint16(m.FirstMsgID)) + pos += 2 + return buf, nil +} +func (m *GetFirstMsgIDReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.FirstMsgID + m.FirstMsgID = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + return nil +} + // 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"` + 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" struc:"[64]byte"` + APIVersions []uint32 `binapi:"u32[8],name=api_versions" json:"api_versions,omitempty" struc:"[8]uint32"` } func (m *MemclntCreate) Reset() { *m = MemclntCreate{} } @@ -102,12 +322,84 @@ 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.CtxQuota + size += 4 + // field[1] m.InputQueue + size += 8 + // field[1] m.Name + size += 64 + // field[1] m.APIVersions + size += 32 + return size +} +func (m *MemclntCreate) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.CtxQuota + o.PutUint32(buf[pos:pos+4], uint32(m.CtxQuota)) + pos += 4 + // field[1] m.InputQueue + o.PutUint64(buf[pos:pos+8], uint64(m.InputQueue)) + pos += 8 + // field[1] m.Name + copy(buf[pos:pos+64], m.Name) + pos += 64 + // field[1] m.APIVersions + for i := 0; i < 8; i++ { + var x uint32 + if i < len(m.APIVersions) { + x = uint32(m.APIVersions[i]) + } + o.PutUint32(buf[pos:pos+4], uint32(x)) + pos += 4 + } + return buf, nil +} +func (m *MemclntCreate) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.CtxQuota + m.CtxQuota = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.InputQueue + m.InputQueue = uint64(o.Uint64(tmp[pos : pos+8])) + pos += 8 + // field[1] m.Name + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Name = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + // field[1] m.APIVersions + m.APIVersions = make([]uint32, 8) + for i := 0; i < len(m.APIVersions); i++ { + m.APIVersions[i] = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + } + return nil +} + // MemclntCreateReply represents VPP binary API message 'memclnt_create_reply'. type MemclntCreateReply struct { - Response int32 - Handle uint64 - Index uint32 - MessageTable uint64 + 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{} } @@ -115,11 +407,71 @@ func (*MemclntCreateReply) GetMessageName() string { return "memclnt_cr func (*MemclntCreateReply) GetCrcString() string { return "42ec4560" } func (*MemclntCreateReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *MemclntCreateReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Response + size += 4 + // field[1] m.Handle + size += 8 + // field[1] m.Index + size += 4 + // field[1] m.MessageTable + size += 8 + return size +} +func (m *MemclntCreateReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Response + o.PutUint32(buf[pos:pos+4], uint32(m.Response)) + pos += 4 + // field[1] m.Handle + o.PutUint64(buf[pos:pos+8], uint64(m.Handle)) + pos += 8 + // field[1] m.Index + o.PutUint32(buf[pos:pos+4], uint32(m.Index)) + pos += 4 + // field[1] m.MessageTable + o.PutUint64(buf[pos:pos+8], uint64(m.MessageTable)) + pos += 8 + return buf, nil +} +func (m *MemclntCreateReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Response + m.Response = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Handle + m.Handle = uint64(o.Uint64(tmp[pos : pos+8])) + pos += 8 + // field[1] m.Index + m.Index = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.MessageTable + m.MessageTable = uint64(o.Uint64(tmp[pos : pos+8])) + pos += 8 + return nil +} + // MemclntDelete represents VPP binary API message 'memclnt_delete'. type MemclntDelete struct { - Index uint32 - Handle uint64 - DoCleanup bool + 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{} } @@ -127,10 +479,64 @@ 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Index + size += 4 + // field[1] m.Handle + size += 8 + // field[1] m.DoCleanup + size += 1 + return size +} +func (m *MemclntDelete) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Index + o.PutUint32(buf[pos:pos+4], uint32(m.Index)) + pos += 4 + // field[1] m.Handle + o.PutUint64(buf[pos:pos+8], uint64(m.Handle)) + pos += 8 + // field[1] m.DoCleanup + if m.DoCleanup { + buf[pos] = 1 + } + pos += 1 + return buf, nil +} +func (m *MemclntDelete) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Index + m.Index = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Handle + m.Handle = uint64(o.Uint64(tmp[pos : pos+8])) + pos += 8 + // field[1] m.DoCleanup + m.DoCleanup = tmp[pos] != 0 + pos += 1 + return nil +} + // MemclntDeleteReply represents VPP binary API message 'memclnt_delete_reply'. type MemclntDeleteReply struct { - Response int32 - Handle uint64 + Response int32 `binapi:"i32,name=response" json:"response,omitempty"` + Handle uint64 `binapi:"u64,name=handle" json:"handle,omitempty"` } func (m *MemclntDeleteReply) Reset() { *m = MemclntDeleteReply{} } @@ -138,6 +544,50 @@ func (*MemclntDeleteReply) GetMessageName() string { return "memclnt_de func (*MemclntDeleteReply) GetCrcString() string { return "3d3b6312" } func (*MemclntDeleteReply) GetMessageType() api.MessageType { return api.OtherMessage } +func (m *MemclntDeleteReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Response + size += 4 + // field[1] m.Handle + size += 8 + return size +} +func (m *MemclntDeleteReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Response + o.PutUint32(buf[pos:pos+4], uint32(m.Response)) + pos += 4 + // field[1] m.Handle + o.PutUint64(buf[pos:pos+8], uint64(m.Handle)) + pos += 8 + return buf, nil +} +func (m *MemclntDeleteReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Response + m.Response = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Handle + m.Handle = uint64(o.Uint64(tmp[pos : pos+8])) + pos += 8 + return nil +} + // MemclntKeepalive represents VPP binary API message 'memclnt_keepalive'. type MemclntKeepalive struct{} @@ -146,9 +596,37 @@ func (*MemclntKeepalive) GetMessageName() string { return "memclnt_keep func (*MemclntKeepalive) GetCrcString() string { return "51077d14" } func (*MemclntKeepalive) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *MemclntKeepalive) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *MemclntKeepalive) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *MemclntKeepalive) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + // MemclntKeepaliveReply represents VPP binary API message 'memclnt_keepalive_reply'. type MemclntKeepaliveReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *MemclntKeepaliveReply) Reset() { *m = MemclntKeepaliveReply{} } @@ -156,9 +634,45 @@ func (*MemclntKeepaliveReply) GetMessageName() string { return "memclnt func (*MemclntKeepaliveReply) GetCrcString() string { return "e8d4e804" } func (*MemclntKeepaliveReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *MemclntKeepaliveReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *MemclntKeepaliveReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *MemclntKeepaliveReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // MemclntReadTimeout represents VPP binary API message 'memclnt_read_timeout'. type MemclntReadTimeout struct { - Dummy uint8 + Dummy uint8 `binapi:"u8,name=dummy" json:"dummy,omitempty"` } func (m *MemclntReadTimeout) Reset() { *m = MemclntReadTimeout{} } @@ -166,9 +680,45 @@ func (*MemclntReadTimeout) GetMessageName() string { return "memclnt_re func (*MemclntReadTimeout) GetCrcString() string { return "c3a3a452" } func (*MemclntReadTimeout) GetMessageType() api.MessageType { return api.OtherMessage } +func (m *MemclntReadTimeout) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Dummy + size += 1 + return size +} +func (m *MemclntReadTimeout) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Dummy + buf[pos] = uint8(m.Dummy) + pos += 1 + return buf, nil +} +func (m *MemclntReadTimeout) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Dummy + m.Dummy = uint8(tmp[pos]) + pos += 1 + return nil +} + // MemclntRxThreadSuspend represents VPP binary API message 'memclnt_rx_thread_suspend'. type MemclntRxThreadSuspend struct { - Dummy uint8 + Dummy uint8 `binapi:"u8,name=dummy" json:"dummy,omitempty"` } func (m *MemclntRxThreadSuspend) Reset() { *m = MemclntRxThreadSuspend{} } @@ -176,14 +726,50 @@ func (*MemclntRxThreadSuspend) GetMessageName() string { return "memcln func (*MemclntRxThreadSuspend) GetCrcString() string { return "c3a3a452" } func (*MemclntRxThreadSuspend) GetMessageType() api.MessageType { return api.OtherMessage } +func (m *MemclntRxThreadSuspend) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Dummy + size += 1 + return size +} +func (m *MemclntRxThreadSuspend) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Dummy + buf[pos] = uint8(m.Dummy) + pos += 1 + return buf, nil +} +func (m *MemclntRxThreadSuspend) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Dummy + m.Dummy = uint8(tmp[pos]) + pos += 1 + return nil +} + // 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 + 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_len,omitempty" struc:"sizeof=Data"` + Data []byte `binapi:"u8[data_len],name=data" json:"data,omitempty"` } func (m *RPCCall) Reset() { *m = RPCCall{} } @@ -191,9 +777,94 @@ 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Function + size += 8 + // field[1] m.Multicast + size += 1 + // field[1] m.NeedBarrierSync + size += 1 + // field[1] m.SendReply + size += 1 + // field[1] m.DataLen + size += 4 + // field[1] m.Data + size += 1 * len(m.Data) + return size +} +func (m *RPCCall) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Function + o.PutUint64(buf[pos:pos+8], uint64(m.Function)) + pos += 8 + // field[1] m.Multicast + buf[pos] = uint8(m.Multicast) + pos += 1 + // field[1] m.NeedBarrierSync + buf[pos] = uint8(m.NeedBarrierSync) + pos += 1 + // field[1] m.SendReply + buf[pos] = uint8(m.SendReply) + pos += 1 + // field[1] m.DataLen + o.PutUint32(buf[pos:pos+4], uint32(len(m.Data))) + pos += 4 + // field[1] m.Data + for i := 0; i < len(m.Data); i++ { + var x uint8 + if i < len(m.Data) { + x = uint8(m.Data[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + return buf, nil +} +func (m *RPCCall) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Function + m.Function = uint64(o.Uint64(tmp[pos : pos+8])) + pos += 8 + // field[1] m.Multicast + m.Multicast = uint8(tmp[pos]) + pos += 1 + // field[1] m.NeedBarrierSync + m.NeedBarrierSync = uint8(tmp[pos]) + pos += 1 + // field[1] m.SendReply + m.SendReply = uint8(tmp[pos]) + pos += 1 + // field[1] m.DataLen + m.DataLen = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Data + m.Data = make([]uint8, m.DataLen) + for i := 0; i < len(m.Data); i++ { + m.Data[i] = uint8(tmp[pos]) + pos += 1 + } + return nil +} + // RPCCallReply represents VPP binary API message 'rpc_call_reply'. type RPCCallReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *RPCCallReply) Reset() { *m = RPCCallReply{} } @@ -201,9 +872,45 @@ 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *RPCCallReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *RPCCallReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // RxThreadExit represents VPP binary API message 'rx_thread_exit'. type RxThreadExit struct { - Dummy uint8 + Dummy uint8 `binapi:"u8,name=dummy" json:"dummy,omitempty"` } func (m *RxThreadExit) Reset() { *m = RxThreadExit{} } @@ -211,11 +918,47 @@ 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Dummy + size += 1 + return size +} +func (m *RxThreadExit) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Dummy + buf[pos] = uint8(m.Dummy) + pos += 1 + return buf, nil +} +func (m *RxThreadExit) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Dummy + m.Dummy = uint8(tmp[pos]) + pos += 1 + return nil +} + // SockInitShm represents VPP binary API message 'sock_init_shm'. type SockInitShm struct { - RequestedSize uint32 - Nitems uint8 `struc:"sizeof=Configs"` - Configs []uint64 + RequestedSize uint32 `binapi:"u32,name=requested_size" json:"requested_size,omitempty"` + Nitems uint8 `binapi:"u8,name=nitems" json:"nitems,omitempty" struc:"sizeof=Configs"` + Configs []uint64 `binapi:"u64[nitems],name=configs" json:"configs,omitempty"` } func (m *SockInitShm) Reset() { *m = SockInitShm{} } @@ -223,9 +966,70 @@ 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.RequestedSize + size += 4 + // field[1] m.Nitems + size += 1 + // field[1] m.Configs + size += 8 * len(m.Configs) + return size +} +func (m *SockInitShm) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.RequestedSize + o.PutUint32(buf[pos:pos+4], uint32(m.RequestedSize)) + pos += 4 + // field[1] m.Nitems + buf[pos] = uint8(len(m.Configs)) + pos += 1 + // field[1] m.Configs + for i := 0; i < len(m.Configs); i++ { + var x uint64 + if i < len(m.Configs) { + x = uint64(m.Configs[i]) + } + o.PutUint64(buf[pos:pos+8], uint64(x)) + pos += 8 + } + return buf, nil +} +func (m *SockInitShm) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.RequestedSize + m.RequestedSize = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Nitems + m.Nitems = uint8(tmp[pos]) + pos += 1 + // field[1] m.Configs + m.Configs = make([]uint64, m.Nitems) + for i := 0; i < len(m.Configs); i++ { + m.Configs[i] = uint64(o.Uint64(tmp[pos : pos+8])) + pos += 8 + } + return nil +} + // SockInitShmReply represents VPP binary API message 'sock_init_shm_reply'. type SockInitShmReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *SockInitShmReply) Reset() { *m = SockInitShmReply{} } @@ -233,9 +1037,45 @@ func (*SockInitShmReply) GetMessageName() string { return "sock_init_sh func (*SockInitShmReply) GetCrcString() string { return "e8d4e804" } func (*SockInitShmReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SockInitShmReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SockInitShmReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SockInitShmReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SockclntCreate represents VPP binary API message 'sockclnt_create'. type SockclntCreate struct { - Name string `struc:"[64]byte"` + Name string `binapi:"string[64],name=name" json:"name,omitempty" struc:"[64]byte"` } func (m *SockclntCreate) Reset() { *m = SockclntCreate{} } @@ -243,12 +1083,51 @@ func (*SockclntCreate) GetMessageName() string { return "sockclnt_creat func (*SockclntCreate) GetCrcString() string { return "455fb9c4" } func (*SockclntCreate) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SockclntCreate) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Name + size += 64 + return size +} +func (m *SockclntCreate) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Name + copy(buf[pos:pos+64], m.Name) + pos += 64 + return buf, nil +} +func (m *SockclntCreate) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Name + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Name = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // SockclntCreateReply represents VPP binary API message 'sockclnt_create_reply'. type SockclntCreateReply struct { - Response int32 - Index uint32 - Count uint16 `struc:"sizeof=MessageTable"` - MessageTable []MessageTableEntry + 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:"count,omitempty" struc:"sizeof=MessageTable"` + MessageTable []MessageTableEntry `binapi:"message_table_entry[count],name=message_table" json:"message_table,omitempty"` } func (m *SockclntCreateReply) Reset() { *m = SockclntCreateReply{} } @@ -256,9 +1135,99 @@ func (*SockclntCreateReply) GetMessageName() string { return "sockclnt_ func (*SockclntCreateReply) GetCrcString() string { return "35166268" } func (*SockclntCreateReply) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SockclntCreateReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Response + size += 4 + // field[1] m.Index + size += 4 + // field[1] m.Count + size += 2 + // field[1] m.MessageTable + for j1 := 0; j1 < len(m.MessageTable); j1++ { + var s1 MessageTableEntry + _ = s1 + if j1 < len(m.MessageTable) { + s1 = m.MessageTable[j1] + } + // field[2] s1.Index + size += 2 + // field[2] s1.Name + size += 64 + } + return size +} +func (m *SockclntCreateReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Response + o.PutUint32(buf[pos:pos+4], uint32(m.Response)) + pos += 4 + // field[1] m.Index + o.PutUint32(buf[pos:pos+4], uint32(m.Index)) + pos += 4 + // field[1] m.Count + o.PutUint16(buf[pos:pos+2], uint16(len(m.MessageTable))) + pos += 2 + // field[1] m.MessageTable + for j1 := 0; j1 < len(m.MessageTable); j1++ { + var v1 MessageTableEntry + if j1 < len(m.MessageTable) { + v1 = m.MessageTable[j1] + } + // field[2] v1.Index + o.PutUint16(buf[pos:pos+2], uint16(v1.Index)) + pos += 2 + // field[2] v1.Name + copy(buf[pos:pos+64], v1.Name) + pos += 64 + } + return buf, nil +} +func (m *SockclntCreateReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Response + m.Response = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Index + m.Index = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Count + m.Count = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[1] m.MessageTable + m.MessageTable = make([]MessageTableEntry, int(m.Count)) + for j1 := 0; j1 < int(m.Count); j1++ { + // field[2] m.MessageTable[j1].Index + m.MessageTable[j1].Index = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[2] m.MessageTable[j1].Name + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.MessageTable[j1].Name = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + } + return nil +} + // SockclntDelete represents VPP binary API message 'sockclnt_delete'. type SockclntDelete struct { - Index uint32 + Index uint32 `binapi:"u32,name=index" json:"index,omitempty"` } func (m *SockclntDelete) Reset() { *m = SockclntDelete{} } @@ -266,9 +1235,45 @@ func (*SockclntDelete) GetMessageName() string { return "sockclnt_delet func (*SockclntDelete) GetCrcString() string { return "8ac76db6" } func (*SockclntDelete) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *SockclntDelete) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Index + size += 4 + return size +} +func (m *SockclntDelete) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Index + o.PutUint32(buf[pos:pos+4], uint32(m.Index)) + pos += 4 + return buf, nil +} +func (m *SockclntDelete) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Index + m.Index = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SockclntDeleteReply represents VPP binary API message 'sockclnt_delete_reply'. type SockclntDeleteReply struct { - Response int32 + Response int32 `binapi:"i32,name=response" json:"response,omitempty"` } func (m *SockclntDeleteReply) Reset() { *m = SockclntDeleteReply{} } @@ -276,11 +1281,47 @@ func (*SockclntDeleteReply) GetMessageName() string { return "sockclnt_ func (*SockclntDeleteReply) GetCrcString() string { return "8f38b1ee" } func (*SockclntDeleteReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *SockclntDeleteReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Response + size += 4 + return size +} +func (m *SockclntDeleteReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Response + o.PutUint32(buf[pos:pos+4], uint32(m.Response)) + pos += 4 + return buf, nil +} +func (m *SockclntDeleteReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Response + m.Response = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // TracePluginMsgIds represents VPP binary API message 'trace_plugin_msg_ids'. type TracePluginMsgIds struct { - PluginName string `struc:"[128]byte"` - FirstMsgID uint16 - LastMsgID uint16 + PluginName string `binapi:"string[128],name=plugin_name" json:"plugin_name,omitempty" struc:"[128]byte"` + 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{} } @@ -288,7 +1329,63 @@ func (*TracePluginMsgIds) GetMessageName() string { return "trace_plugi func (*TracePluginMsgIds) GetCrcString() string { return "f476d3ce" } func (*TracePluginMsgIds) GetMessageType() api.MessageType { return api.RequestMessage } -func init() { +func (m *TracePluginMsgIds) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.PluginName + size += 128 + // field[1] m.FirstMsgID + size += 2 + // field[1] m.LastMsgID + size += 2 + return size +} +func (m *TracePluginMsgIds) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.PluginName + copy(buf[pos:pos+128], m.PluginName) + pos += 128 + // field[1] m.FirstMsgID + o.PutUint16(buf[pos:pos+2], uint16(m.FirstMsgID)) + pos += 2 + // field[1] m.LastMsgID + o.PutUint16(buf[pos:pos+2], uint16(m.LastMsgID)) + pos += 2 + return buf, nil +} +func (m *TracePluginMsgIds) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.PluginName + { + nul := bytes.Index(tmp[pos:pos+128], []byte{0x00}) + m.PluginName = codec.DecodeString(tmp[pos : pos+nul]) + pos += 128 + } + // field[1] m.FirstMsgID + m.FirstMsgID = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[1] m.LastMsgID + m.LastMsgID = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + return nil +} + +func init() { file_memclnt_binapi_init() } +func file_memclnt_binapi_init() { api.RegisterMessage((*APIVersions)(nil), "memclnt.APIVersions") api.RegisterMessage((*APIVersionsReply)(nil), "memclnt.APIVersionsReply") api.RegisterMessage((*GetFirstMsgID)(nil), "memclnt.GetFirstMsgID") @@ -341,142 +1438,13 @@ func AllMessages() []api.Message { } } -// 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 _ = codec.DecodeString var _ = bytes.NewBuffer var _ = context.Background var _ = io.Copy var _ = strconv.Itoa var _ = struc.Pack +var _ = binary.BigEndian +var _ = math.Float32bits diff --git a/examples/binapi/memclnt/memclnt_rpc.ba.go b/examples/binapi/memclnt/memclnt_rpc.ba.go new file mode 100644 index 0000000..05dfc28 --- /dev/null +++ b/examples/binapi/memclnt/memclnt_rpc.ba.go @@ -0,0 +1,141 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package memclnt + +import ( + "context" + "io" + + api "git.fd.io/govpp.git/api" +) + +// 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 +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = context.Background +var _ = io.Copy diff --git a/examples/binapi/memif/memif.ba.go b/examples/binapi/memif/memif.ba.go index 2388cc2..60aadf3 100644 --- a/examples/binapi/memif/memif.ba.go +++ b/examples/binapi/memif/memif.ba.go @@ -1,30 +1,38 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty +// VPP: 20.01-45~g7a071e370~b63 // source: /usr/share/vpp/api/plugins/memif.api.json /* -Package memif is a generated VPP binary API for 'memif' module. +Package memif contains generated code for VPP binary API defined by memif.api (version 3.0.0). It consists of: - 8 enums 2 aliases + 8 enums 10 messages - 5 services */ package memif import ( "bytes" "context" + "encoding/binary" "io" + "math" "strconv" api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" struc "github.com/lunixbochs/struc" - - ethernet_types "git.fd.io/govpp.git/examples/binapi/ethernet_types" - interface_types "git.fd.io/govpp.git/examples/binapi/interface_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 // please upgrade the GoVPP api package + const ( // ModuleName is the name of this module. ModuleName = "memif" @@ -34,11 +42,95 @@ const ( VersionCrc = 0x88dc56c9 ) -type IfStatusFlags = interface_types.IfStatusFlags +// 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", + } + 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 "IfStatusFlags(" + strconv.Itoa(int(x)) + ")" +} -type IfType = interface_types.IfType +// IfType represents VPP binary API enum 'if_type'. +type IfType uint32 -type LinkDuplex = interface_types.LinkDuplex +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", + } + 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 "IfType(" + 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", + } + 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 "LinkDuplex(" + strconv.Itoa(int(x)) + ")" +} // MemifMode represents VPP binary API enum 'memif_mode'. type MemifMode uint32 @@ -49,24 +141,25 @@ const ( 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, -} +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 strconv.Itoa(int(x)) + return "MemifMode(" + strconv.Itoa(int(x)) + ")" } // MemifRole represents VPP binary API enum 'memif_role'. @@ -77,47 +170,167 @@ const ( MEMIF_ROLE_API_SLAVE MemifRole = 1 ) -var MemifRole_name = map[uint32]string{ - 0: "MEMIF_ROLE_API_MASTER", - 1: "MEMIF_ROLE_API_SLAVE", +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)) + ")" } -var MemifRole_value = map[string]uint32{ - "MEMIF_ROLE_API_MASTER": 0, - "MEMIF_ROLE_API_SLAVE": 1, +// 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", + } + 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 "MtuProto(" + strconv.Itoa(int(x)) + ")" } -func (x MemifRole) String() string { - s, ok := MemifRole_name[uint32(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", + } + 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)) + return "RxMode(" + strconv.Itoa(int(x)) + ")" } -type MtuProto = interface_types.MtuProto +// SubIfFlags represents VPP binary API enum 'sub_if_flags'. +type SubIfFlags uint32 -type RxMode = interface_types.RxMode +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 +) -type SubIfFlags = interface_types.SubIfFlags +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", + } + 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, + } +) -type InterfaceIndex = interface_types.InterfaceIndex +func (x SubIfFlags) String() string { + s, ok := SubIfFlags_name[uint32(x)] + if ok { + return s + } + return "SubIfFlags(" + strconv.Itoa(int(x)) + ")" +} -type MacAddress = ethernet_types.MacAddress +// InterfaceIndex represents VPP binary API alias 'interface_index'. +type InterfaceIndex uint32 + +// MacAddress represents VPP binary API alias 'mac_address'. +type MacAddress [6]uint8 // 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"` + 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 MacAddress `binapi:"mac_address,name=hw_addr" json:"hw_addr,omitempty"` + Secret string `binapi:"string[24],name=secret" json:"secret,omitempty" struc:"[24]byte"` } func (m *MemifCreate) Reset() { *m = MemifCreate{} } @@ -125,10 +338,139 @@ 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Role + size += 4 + // field[1] m.Mode + size += 4 + // field[1] m.RxQueues + size += 1 + // field[1] m.TxQueues + size += 1 + // field[1] m.ID + size += 4 + // field[1] m.SocketID + size += 4 + // field[1] m.RingSize + size += 4 + // field[1] m.BufferSize + size += 2 + // field[1] m.NoZeroCopy + size += 1 + // field[1] m.HwAddr + size += 6 + // field[1] m.Secret + size += 24 + return size +} +func (m *MemifCreate) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Role + o.PutUint32(buf[pos:pos+4], uint32(m.Role)) + pos += 4 + // field[1] m.Mode + o.PutUint32(buf[pos:pos+4], uint32(m.Mode)) + pos += 4 + // field[1] m.RxQueues + buf[pos] = uint8(m.RxQueues) + pos += 1 + // field[1] m.TxQueues + buf[pos] = uint8(m.TxQueues) + pos += 1 + // field[1] m.ID + o.PutUint32(buf[pos:pos+4], uint32(m.ID)) + pos += 4 + // field[1] m.SocketID + o.PutUint32(buf[pos:pos+4], uint32(m.SocketID)) + pos += 4 + // field[1] m.RingSize + o.PutUint32(buf[pos:pos+4], uint32(m.RingSize)) + pos += 4 + // field[1] m.BufferSize + o.PutUint16(buf[pos:pos+2], uint16(m.BufferSize)) + pos += 2 + // field[1] m.NoZeroCopy + if m.NoZeroCopy { + buf[pos] = 1 + } + pos += 1 + // field[1] m.HwAddr + for i := 0; i < 6; i++ { + var x uint8 + if i < len(m.HwAddr) { + x = uint8(m.HwAddr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.Secret + copy(buf[pos:pos+24], m.Secret) + pos += 24 + return buf, nil +} +func (m *MemifCreate) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Role + m.Role = MemifRole(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Mode + m.Mode = MemifMode(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.RxQueues + m.RxQueues = uint8(tmp[pos]) + pos += 1 + // field[1] m.TxQueues + m.TxQueues = uint8(tmp[pos]) + pos += 1 + // field[1] m.ID + m.ID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SocketID + m.SocketID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.RingSize + m.RingSize = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.BufferSize + m.BufferSize = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[1] m.NoZeroCopy + m.NoZeroCopy = tmp[pos] != 0 + pos += 1 + // field[1] m.HwAddr + for i := 0; i < len(m.HwAddr); i++ { + m.HwAddr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.Secret + { + nul := bytes.Index(tmp[pos:pos+24], []byte{0x00}) + m.Secret = codec.DecodeString(tmp[pos : pos+nul]) + pos += 24 + } + return nil +} + // MemifCreateReply represents VPP binary API message 'memif_create_reply'. type MemifCreateReply struct { - Retval int32 - SwIfIndex InterfaceIndex + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *MemifCreateReply) Reset() { *m = MemifCreateReply{} } @@ -136,9 +478,53 @@ func (*MemifCreateReply) GetMessageName() string { return "memif_create func (*MemifCreateReply) GetCrcString() string { return "5383d31f" } func (*MemifCreateReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *MemifCreateReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *MemifCreateReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *MemifCreateReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // MemifDelete represents VPP binary API message 'memif_delete'. type MemifDelete struct { - SwIfIndex InterfaceIndex + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *MemifDelete) Reset() { *m = MemifDelete{} } @@ -146,9 +532,45 @@ 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + return size +} +func (m *MemifDelete) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + return buf, nil +} +func (m *MemifDelete) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // MemifDeleteReply represents VPP binary API message 'memif_delete_reply'. type MemifDeleteReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *MemifDeleteReply) Reset() { *m = MemifDeleteReply{} } @@ -156,19 +578,55 @@ func (*MemifDeleteReply) GetMessageName() string { return "memif_delete func (*MemifDeleteReply) GetCrcString() string { return "e8d4e804" } func (*MemifDeleteReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *MemifDeleteReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *MemifDeleteReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *MemifDeleteReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // 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"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + HwAddr 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 IfStatusFlags `binapi:"if_status_flags,name=flags" json:"flags,omitempty"` + IfName string `binapi:"string[64],name=if_name" json:"if_name,omitempty" struc:"[64]byte"` } func (m *MemifDetails) Reset() { *m = MemifDetails{} } @@ -176,6 +634,135 @@ func (*MemifDetails) GetMessageName() string { return "memif_details" } func (*MemifDetails) GetCrcString() string { return "d0382c4c" } func (*MemifDetails) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *MemifDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SwIfIndex + size += 4 + // field[1] m.HwAddr + size += 6 + // field[1] m.ID + size += 4 + // field[1] m.Role + size += 4 + // field[1] m.Mode + size += 4 + // field[1] m.ZeroCopy + size += 1 + // field[1] m.SocketID + size += 4 + // field[1] m.RingSize + size += 4 + // field[1] m.BufferSize + size += 2 + // field[1] m.Flags + size += 4 + // field[1] m.IfName + size += 64 + return size +} +func (m *MemifDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.HwAddr + for i := 0; i < 6; i++ { + var x uint8 + if i < len(m.HwAddr) { + x = uint8(m.HwAddr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.ID + o.PutUint32(buf[pos:pos+4], uint32(m.ID)) + pos += 4 + // field[1] m.Role + o.PutUint32(buf[pos:pos+4], uint32(m.Role)) + pos += 4 + // field[1] m.Mode + o.PutUint32(buf[pos:pos+4], uint32(m.Mode)) + pos += 4 + // field[1] m.ZeroCopy + if m.ZeroCopy { + buf[pos] = 1 + } + pos += 1 + // field[1] m.SocketID + o.PutUint32(buf[pos:pos+4], uint32(m.SocketID)) + pos += 4 + // field[1] m.RingSize + o.PutUint32(buf[pos:pos+4], uint32(m.RingSize)) + pos += 4 + // field[1] m.BufferSize + o.PutUint16(buf[pos:pos+2], uint16(m.BufferSize)) + pos += 2 + // field[1] m.Flags + o.PutUint32(buf[pos:pos+4], uint32(m.Flags)) + pos += 4 + // field[1] m.IfName + copy(buf[pos:pos+64], m.IfName) + pos += 64 + return buf, nil +} +func (m *MemifDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SwIfIndex + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.HwAddr + for i := 0; i < len(m.HwAddr); i++ { + m.HwAddr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.ID + m.ID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Role + m.Role = MemifRole(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Mode + m.Mode = MemifMode(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.ZeroCopy + m.ZeroCopy = tmp[pos] != 0 + pos += 1 + // field[1] m.SocketID + m.SocketID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.RingSize + m.RingSize = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.BufferSize + m.BufferSize = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[1] m.Flags + m.Flags = IfStatusFlags(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IfName + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.IfName = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 + } + return nil +} + // MemifDump represents VPP binary API message 'memif_dump'. type MemifDump struct{} @@ -184,11 +771,39 @@ 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() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *MemifDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *MemifDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + // MemifSocketFilenameAddDel represents VPP binary API message 'memif_socket_filename_add_del'. type MemifSocketFilenameAddDel struct { - IsAdd bool - SocketID uint32 - SocketFilename string `struc:"[108]byte"` + 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" struc:"[108]byte"` } func (m *MemifSocketFilenameAddDel) Reset() { *m = MemifSocketFilenameAddDel{} } @@ -196,9 +811,66 @@ func (*MemifSocketFilenameAddDel) GetMessageName() string { return "mem func (*MemifSocketFilenameAddDel) GetCrcString() string { return "a2ce1a10" } func (*MemifSocketFilenameAddDel) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *MemifSocketFilenameAddDel) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.IsAdd + size += 1 + // field[1] m.SocketID + size += 4 + // field[1] m.SocketFilename + size += 108 + return size +} +func (m *MemifSocketFilenameAddDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.IsAdd + if m.IsAdd { + buf[pos] = 1 + } + pos += 1 + // field[1] m.SocketID + o.PutUint32(buf[pos:pos+4], uint32(m.SocketID)) + pos += 4 + // field[1] m.SocketFilename + copy(buf[pos:pos+108], m.SocketFilename) + pos += 108 + return buf, nil +} +func (m *MemifSocketFilenameAddDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.IsAdd + m.IsAdd = tmp[pos] != 0 + pos += 1 + // field[1] m.SocketID + m.SocketID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SocketFilename + { + nul := bytes.Index(tmp[pos:pos+108], []byte{0x00}) + m.SocketFilename = codec.DecodeString(tmp[pos : pos+nul]) + pos += 108 + } + return nil +} + // MemifSocketFilenameAddDelReply represents VPP binary API message 'memif_socket_filename_add_del_reply'. type MemifSocketFilenameAddDelReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } func (m *MemifSocketFilenameAddDelReply) Reset() { *m = MemifSocketFilenameAddDelReply{} } @@ -208,10 +880,46 @@ func (*MemifSocketFilenameAddDelReply) GetMessageName() string { func (*MemifSocketFilenameAddDelReply) GetCrcString() string { return "e8d4e804" } func (*MemifSocketFilenameAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *MemifSocketFilenameAddDelReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *MemifSocketFilenameAddDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *MemifSocketFilenameAddDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // MemifSocketFilenameDetails represents VPP binary API message 'memif_socket_filename_details'. type MemifSocketFilenameDetails struct { - SocketID uint32 - SocketFilename string `struc:"[108]byte"` + SocketID uint32 `binapi:"u32,name=socket_id" json:"socket_id,omitempty"` + SocketFilename string `binapi:"string[108],name=socket_filename" json:"socket_filename,omitempty" struc:"[108]byte"` } func (m *MemifSocketFilenameDetails) Reset() { *m = MemifSocketFilenameDetails{} } @@ -219,6 +927,53 @@ func (*MemifSocketFilenameDetails) GetMessageName() string { return "me func (*MemifSocketFilenameDetails) GetCrcString() string { return "7ff326f7" } func (*MemifSocketFilenameDetails) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *MemifSocketFilenameDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.SocketID + size += 4 + // field[1] m.SocketFilename + size += 108 + return size +} +func (m *MemifSocketFilenameDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.SocketID + o.PutUint32(buf[pos:pos+4], uint32(m.SocketID)) + pos += 4 + // field[1] m.SocketFilename + copy(buf[pos:pos+108], m.SocketFilename) + pos += 108 + return buf, nil +} +func (m *MemifSocketFilenameDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.SocketID + m.SocketID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SocketFilename + { + nul := bytes.Index(tmp[pos:pos+108], []byte{0x00}) + m.SocketFilename = codec.DecodeString(tmp[pos : pos+nul]) + pos += 108 + } + return nil +} + // MemifSocketFilenameDump represents VPP binary API message 'memif_socket_filename_dump'. type MemifSocketFilenameDump struct{} @@ -227,7 +982,36 @@ func (*MemifSocketFilenameDump) GetMessageName() string { return "memif func (*MemifSocketFilenameDump) GetCrcString() string { return "51077d14" } func (*MemifSocketFilenameDump) GetMessageType() api.MessageType { return api.RequestMessage } -func init() { +func (m *MemifSocketFilenameDump) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *MemifSocketFilenameDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *MemifSocketFilenameDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + +func init() { file_memif_binapi_init() } +func file_memif_binapi_init() { api.RegisterMessage((*MemifCreate)(nil), "memif.MemifCreate") api.RegisterMessage((*MemifCreateReply)(nil), "memif.MemifCreateReply") api.RegisterMessage((*MemifDelete)(nil), "memif.MemifDelete") @@ -256,112 +1040,13 @@ func AllMessages() []api.Message { } } -// 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 _ = codec.DecodeString var _ = bytes.NewBuffer var _ = context.Background var _ = io.Copy var _ = strconv.Itoa var _ = struc.Pack +var _ = binary.BigEndian +var _ = math.Float32bits diff --git a/examples/binapi/memif/memif_rpc.ba.go b/examples/binapi/memif/memif_rpc.ba.go new file mode 100644 index 0000000..8eda8f1 --- /dev/null +++ b/examples/binapi/memif/memif_rpc.ba.go @@ -0,0 +1,111 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package memif + +import ( + "context" + "io" + + api "git.fd.io/govpp.git/api" +) + +// 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 +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = context.Background +var _ = io.Copy diff --git a/examples/binapi/sr/sr.ba.go b/examples/binapi/sr/sr.ba.go new file mode 100644 index 0000000..b870456 --- /dev/null +++ b/examples/binapi/sr/sr.ba.go @@ -0,0 +1,1716 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty +// VPP: 20.01-45~g7a071e370~b63 +// source: /usr/share/vpp/api/core/sr.api.json + +/* +Package sr contains generated code for VPP binary API defined by sr.api (version 1.2.0). + +It consists of: + 20 messages + 3 types +*/ +package sr + +import ( + "bytes" + "context" + "encoding/binary" + "io" + "math" + "strconv" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" + struc "github.com/lunixbochs/struc" +) + +// 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 // please upgrade the GoVPP api package + +const ( + // ModuleName is the name of this module. + ModuleName = "sr" + // APIVersion is the API version of this module. + APIVersion = "1.2.0" + // VersionCrc is the CRC of this module. + VersionCrc = 0xbf277f96 +) + +// SrIP6Address represents VPP binary API type 'sr_ip6_address'. +type SrIP6Address struct { + Data []byte `binapi:"u8[16],name=data" json:"data,omitempty" struc:"[16]byte"` +} + +func (*SrIP6Address) GetTypeName() string { return "sr_ip6_address" } + +// Srv6Sid represents VPP binary API type 'srv6_sid'. +type Srv6Sid struct { + Addr []byte `binapi:"u8[16],name=addr" json:"addr,omitempty" struc:"[16]byte"` +} + +func (*Srv6Sid) GetTypeName() string { return "srv6_sid" } + +// Srv6SidList represents VPP binary API 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]Srv6Sid `binapi:"srv6_sid[16],name=sids" json:"sids,omitempty" struc:"[16]Srv6Sid"` +} + +func (*Srv6SidList) GetTypeName() string { return "srv6_sid_list" } + +// SrLocalsidAddDel represents VPP binary API message 'sr_localsid_add_del'. +type SrLocalsidAddDel struct { + IsDel uint8 `binapi:"u8,name=is_del" json:"is_del,omitempty"` + Localsid Srv6Sid `binapi:"srv6_sid,name=localsid" json:"localsid,omitempty"` + EndPsp uint8 `binapi:"u8,name=end_psp" json:"end_psp,omitempty"` + Behavior uint8 `binapi:"u8,name=behavior" json:"behavior,omitempty"` + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" 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"` + NhAddr6 []byte `binapi:"u8[16],name=nh_addr6" json:"nh_addr6,omitempty" struc:"[16]byte"` + NhAddr4 []byte `binapi:"u8[4],name=nh_addr4" json:"nh_addr4,omitempty" struc:"[4]byte"` +} + +func (m *SrLocalsidAddDel) Reset() { *m = SrLocalsidAddDel{} } +func (*SrLocalsidAddDel) GetMessageName() string { return "sr_localsid_add_del" } +func (*SrLocalsidAddDel) GetCrcString() string { return "b30489eb" } +func (*SrLocalsidAddDel) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *SrLocalsidAddDel) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.IsDel + size += 1 + // field[1] m.Localsid + // field[2] m.Localsid.Addr + size += 16 + // field[1] m.EndPsp + size += 1 + // field[1] m.Behavior + size += 1 + // field[1] m.SwIfIndex + size += 4 + // field[1] m.VlanIndex + size += 4 + // field[1] m.FibTable + size += 4 + // field[1] m.NhAddr6 + size += 16 + // field[1] m.NhAddr4 + size += 4 + return size +} +func (m *SrLocalsidAddDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.IsDel + buf[pos] = uint8(m.IsDel) + pos += 1 + // field[1] m.Localsid + // field[2] m.Localsid.Addr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(m.Localsid.Addr) { + x = uint8(m.Localsid.Addr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.EndPsp + buf[pos] = uint8(m.EndPsp) + pos += 1 + // field[1] m.Behavior + buf[pos] = uint8(m.Behavior) + pos += 1 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.VlanIndex + o.PutUint32(buf[pos:pos+4], uint32(m.VlanIndex)) + pos += 4 + // field[1] m.FibTable + o.PutUint32(buf[pos:pos+4], uint32(m.FibTable)) + pos += 4 + // field[1] m.NhAddr6 + for i := 0; i < 16; i++ { + var x uint8 + if i < len(m.NhAddr6) { + x = uint8(m.NhAddr6[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.NhAddr4 + for i := 0; i < 4; i++ { + var x uint8 + if i < len(m.NhAddr4) { + x = uint8(m.NhAddr4[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + return buf, nil +} +func (m *SrLocalsidAddDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.IsDel + m.IsDel = uint8(tmp[pos]) + pos += 1 + // field[1] m.Localsid + // field[2] m.Localsid.Addr + m.Localsid.Addr = make([]uint8, 16) + for i := 0; i < len(m.Localsid.Addr); i++ { + m.Localsid.Addr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.EndPsp + m.EndPsp = uint8(tmp[pos]) + pos += 1 + // field[1] m.Behavior + m.Behavior = uint8(tmp[pos]) + pos += 1 + // field[1] m.SwIfIndex + m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.VlanIndex + m.VlanIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.FibTable + m.FibTable = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.NhAddr6 + m.NhAddr6 = make([]uint8, 16) + for i := 0; i < len(m.NhAddr6); i++ { + m.NhAddr6[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.NhAddr4 + m.NhAddr4 = make([]uint8, 4) + for i := 0; i < len(m.NhAddr4); i++ { + m.NhAddr4[i] = uint8(tmp[pos]) + pos += 1 + } + return nil +} + +// SrLocalsidAddDelReply represents VPP binary API 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SrLocalsidAddDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SrLocalsidAddDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + +// SrLocalsidsDetails represents VPP binary API message 'sr_localsids_details'. +type SrLocalsidsDetails struct { + Addr Srv6Sid `binapi:"srv6_sid,name=addr" json:"addr,omitempty"` + EndPsp uint8 `binapi:"u8,name=end_psp" json:"end_psp,omitempty"` + Behavior uint16 `binapi:"u16,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"` + XconnectNhAddr6 []byte `binapi:"u8[16],name=xconnect_nh_addr6" json:"xconnect_nh_addr6,omitempty" struc:"[16]byte"` + XconnectNhAddr4 []byte `binapi:"u8[4],name=xconnect_nh_addr4" json:"xconnect_nh_addr4,omitempty" struc:"[4]byte"` + 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 "0791babc" } +func (*SrLocalsidsDetails) GetMessageType() api.MessageType { return api.ReplyMessage } + +func (m *SrLocalsidsDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Addr + // field[2] m.Addr.Addr + size += 16 + // field[1] m.EndPsp + size += 1 + // field[1] m.Behavior + size += 2 + // field[1] m.FibTable + size += 4 + // field[1] m.VlanIndex + size += 4 + // field[1] m.XconnectNhAddr6 + size += 16 + // field[1] m.XconnectNhAddr4 + size += 4 + // field[1] m.XconnectIfaceOrVrfTable + size += 4 + return size +} +func (m *SrLocalsidsDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Addr + // field[2] m.Addr.Addr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(m.Addr.Addr) { + x = uint8(m.Addr.Addr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.EndPsp + buf[pos] = uint8(m.EndPsp) + pos += 1 + // field[1] m.Behavior + o.PutUint16(buf[pos:pos+2], uint16(m.Behavior)) + pos += 2 + // field[1] m.FibTable + o.PutUint32(buf[pos:pos+4], uint32(m.FibTable)) + pos += 4 + // field[1] m.VlanIndex + o.PutUint32(buf[pos:pos+4], uint32(m.VlanIndex)) + pos += 4 + // field[1] m.XconnectNhAddr6 + for i := 0; i < 16; i++ { + var x uint8 + if i < len(m.XconnectNhAddr6) { + x = uint8(m.XconnectNhAddr6[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.XconnectNhAddr4 + for i := 0; i < 4; i++ { + var x uint8 + if i < len(m.XconnectNhAddr4) { + x = uint8(m.XconnectNhAddr4[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.XconnectIfaceOrVrfTable + o.PutUint32(buf[pos:pos+4], uint32(m.XconnectIfaceOrVrfTable)) + pos += 4 + return buf, nil +} +func (m *SrLocalsidsDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Addr + // field[2] m.Addr.Addr + m.Addr.Addr = make([]uint8, 16) + for i := 0; i < len(m.Addr.Addr); i++ { + m.Addr.Addr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.EndPsp + m.EndPsp = uint8(tmp[pos]) + pos += 1 + // field[1] m.Behavior + m.Behavior = uint16(o.Uint16(tmp[pos : pos+2])) + pos += 2 + // field[1] m.FibTable + m.FibTable = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.VlanIndex + m.VlanIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.XconnectNhAddr6 + m.XconnectNhAddr6 = make([]uint8, 16) + for i := 0; i < len(m.XconnectNhAddr6); i++ { + m.XconnectNhAddr6[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.XconnectNhAddr4 + m.XconnectNhAddr4 = make([]uint8, 4) + for i := 0; i < len(m.XconnectNhAddr4); i++ { + m.XconnectNhAddr4[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.XconnectIfaceOrVrfTable + m.XconnectIfaceOrVrfTable = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + +// SrLocalsidsDump represents VPP binary API message 'sr_localsids_dump'. +type SrLocalsidsDump struct{} + +func (m *SrLocalsidsDump) Reset() { *m = SrLocalsidsDump{} } +func (*SrLocalsidsDump) GetMessageName() string { return "sr_localsids_dump" } +func (*SrLocalsidsDump) GetCrcString() string { return "51077d14" } +func (*SrLocalsidsDump) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *SrLocalsidsDump) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *SrLocalsidsDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *SrLocalsidsDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + +// SrPoliciesDetails represents VPP binary API message 'sr_policies_details'. +type SrPoliciesDetails struct { + Bsid Srv6Sid `binapi:"srv6_sid,name=bsid" json:"bsid,omitempty"` + Type uint8 `binapi:"u8,name=type" json:"type,omitempty"` + IsEncap uint8 `binapi:"u8,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:"num_sid_lists,omitempty" struc:"sizeof=SidLists"` + 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 "5087f460" } +func (*SrPoliciesDetails) GetMessageType() api.MessageType { return api.ReplyMessage } + +func (m *SrPoliciesDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Bsid + // field[2] m.Bsid.Addr + size += 16 + // field[1] m.Type + size += 1 + // field[1] m.IsEncap + size += 1 + // field[1] m.FibTable + size += 4 + // field[1] m.NumSidLists + size += 1 + // field[1] m.SidLists + for j1 := 0; j1 < len(m.SidLists); j1++ { + var s1 Srv6SidList + _ = s1 + if j1 < len(m.SidLists) { + s1 = m.SidLists[j1] + } + // field[2] s1.NumSids + size += 1 + // field[2] s1.Weight + size += 4 + // field[2] s1.Sids + for j2 := 0; j2 < 16; j2++ { + var s2 Srv6Sid + _ = s2 + if j2 < len(s1.Sids) { + s2 = s1.Sids[j2] + } + // field[3] s2.Addr + size += 16 + } + } + return size +} +func (m *SrPoliciesDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Bsid + // field[2] m.Bsid.Addr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(m.Bsid.Addr) { + x = uint8(m.Bsid.Addr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.Type + buf[pos] = uint8(m.Type) + pos += 1 + // field[1] m.IsEncap + buf[pos] = uint8(m.IsEncap) + pos += 1 + // field[1] m.FibTable + o.PutUint32(buf[pos:pos+4], uint32(m.FibTable)) + pos += 4 + // field[1] m.NumSidLists + buf[pos] = uint8(len(m.SidLists)) + pos += 1 + // field[1] m.SidLists + for j1 := 0; j1 < len(m.SidLists); j1++ { + var v1 Srv6SidList + if j1 < len(m.SidLists) { + v1 = m.SidLists[j1] + } + // field[2] v1.NumSids + buf[pos] = uint8(v1.NumSids) + pos += 1 + // field[2] v1.Weight + o.PutUint32(buf[pos:pos+4], uint32(v1.Weight)) + pos += 4 + // field[2] v1.Sids + for j2 := 0; j2 < 16; j2++ { + var v2 Srv6Sid + if j2 < len(v1.Sids) { + v2 = v1.Sids[j2] + } + // field[3] v2.Addr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(v2.Addr) { + x = uint8(v2.Addr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + } + } + return buf, nil +} +func (m *SrPoliciesDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Bsid + // field[2] m.Bsid.Addr + m.Bsid.Addr = make([]uint8, 16) + for i := 0; i < len(m.Bsid.Addr); i++ { + m.Bsid.Addr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.Type + m.Type = uint8(tmp[pos]) + pos += 1 + // field[1] m.IsEncap + m.IsEncap = uint8(tmp[pos]) + pos += 1 + // field[1] m.FibTable + m.FibTable = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.NumSidLists + m.NumSidLists = uint8(tmp[pos]) + pos += 1 + // field[1] m.SidLists + m.SidLists = make([]Srv6SidList, int(m.NumSidLists)) + for j1 := 0; j1 < int(m.NumSidLists); j1++ { + // field[2] m.SidLists[j1].NumSids + m.SidLists[j1].NumSids = uint8(tmp[pos]) + pos += 1 + // field[2] m.SidLists[j1].Weight + m.SidLists[j1].Weight = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.SidLists[j1].Sids + for j2 := 0; j2 < 16; j2++ { + // field[3] m.SidLists[j1].Sids[j2].Addr + m.SidLists[j1].Sids[j2].Addr = make([]uint8, 16) + for i := 0; i < len(m.SidLists[j1].Sids[j2].Addr); i++ { + m.SidLists[j1].Sids[j2].Addr[i] = uint8(tmp[pos]) + pos += 1 + } + } + } + return nil +} + +// SrPoliciesDump represents VPP binary API message 'sr_policies_dump'. +type SrPoliciesDump struct{} + +func (m *SrPoliciesDump) Reset() { *m = SrPoliciesDump{} } +func (*SrPoliciesDump) GetMessageName() string { return "sr_policies_dump" } +func (*SrPoliciesDump) GetCrcString() string { return "51077d14" } +func (*SrPoliciesDump) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *SrPoliciesDump) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *SrPoliciesDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *SrPoliciesDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + +// SrPolicyAdd represents VPP binary API message 'sr_policy_add'. +type SrPolicyAdd struct { + BsidAddr []byte `binapi:"u8[16],name=bsid_addr" json:"bsid_addr,omitempty" struc:"[16]byte"` + Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` + IsEncap uint8 `binapi:"u8,name=is_encap" json:"is_encap,omitempty"` + Type uint8 `binapi:"u8,name=type" 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"` +} + +func (m *SrPolicyAdd) Reset() { *m = SrPolicyAdd{} } +func (*SrPolicyAdd) GetMessageName() string { return "sr_policy_add" } +func (*SrPolicyAdd) GetCrcString() string { return "4b6e2484" } +func (*SrPolicyAdd) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *SrPolicyAdd) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.BsidAddr + size += 16 + // field[1] m.Weight + size += 4 + // field[1] m.IsEncap + size += 1 + // field[1] m.Type + size += 1 + // field[1] m.FibTable + size += 4 + // field[1] m.Sids + // field[2] m.Sids.NumSids + size += 1 + // field[2] m.Sids.Weight + size += 4 + // field[2] m.Sids.Sids + for j2 := 0; j2 < 16; j2++ { + var s2 Srv6Sid + _ = s2 + if j2 < len(m.Sids.Sids) { + s2 = m.Sids.Sids[j2] + } + // field[3] s2.Addr + size += 16 + } + return size +} +func (m *SrPolicyAdd) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.BsidAddr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(m.BsidAddr) { + x = uint8(m.BsidAddr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.Weight + o.PutUint32(buf[pos:pos+4], uint32(m.Weight)) + pos += 4 + // field[1] m.IsEncap + buf[pos] = uint8(m.IsEncap) + pos += 1 + // field[1] m.Type + buf[pos] = uint8(m.Type) + pos += 1 + // field[1] m.FibTable + o.PutUint32(buf[pos:pos+4], uint32(m.FibTable)) + pos += 4 + // field[1] m.Sids + // field[2] m.Sids.NumSids + buf[pos] = uint8(m.Sids.NumSids) + pos += 1 + // field[2] m.Sids.Weight + o.PutUint32(buf[pos:pos+4], uint32(m.Sids.Weight)) + pos += 4 + // field[2] m.Sids.Sids + for j2 := 0; j2 < 16; j2++ { + var v2 Srv6Sid + if j2 < len(m.Sids.Sids) { + v2 = m.Sids.Sids[j2] + } + // field[3] v2.Addr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(v2.Addr) { + x = uint8(v2.Addr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + } + return buf, nil +} +func (m *SrPolicyAdd) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.BsidAddr + m.BsidAddr = make([]uint8, 16) + for i := 0; i < len(m.BsidAddr); i++ { + m.BsidAddr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.Weight + m.Weight = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.IsEncap + m.IsEncap = uint8(tmp[pos]) + pos += 1 + // field[1] m.Type + m.Type = uint8(tmp[pos]) + pos += 1 + // field[1] m.FibTable + m.FibTable = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Sids + // field[2] m.Sids.NumSids + m.Sids.NumSids = uint8(tmp[pos]) + pos += 1 + // field[2] m.Sids.Weight + m.Sids.Weight = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Sids.Sids + for j2 := 0; j2 < 16; j2++ { + // field[3] m.Sids.Sids[j2].Addr + m.Sids.Sids[j2].Addr = make([]uint8, 16) + for i := 0; i < len(m.Sids.Sids[j2].Addr); i++ { + m.Sids.Sids[j2].Addr[i] = uint8(tmp[pos]) + pos += 1 + } + } + return nil +} + +// SrPolicyAddReply represents VPP binary API 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SrPolicyAddReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SrPolicyAddReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + +// SrPolicyDel represents VPP binary API message 'sr_policy_del'. +type SrPolicyDel struct { + BsidAddr Srv6Sid `binapi:"srv6_sid,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 "e4133171" } +func (*SrPolicyDel) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *SrPolicyDel) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.BsidAddr + // field[2] m.BsidAddr.Addr + size += 16 + // field[1] m.SrPolicyIndex + size += 4 + return size +} +func (m *SrPolicyDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.BsidAddr + // field[2] m.BsidAddr.Addr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(m.BsidAddr.Addr) { + x = uint8(m.BsidAddr.Addr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.SrPolicyIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SrPolicyIndex)) + pos += 4 + return buf, nil +} +func (m *SrPolicyDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.BsidAddr + // field[2] m.BsidAddr.Addr + m.BsidAddr.Addr = make([]uint8, 16) + for i := 0; i < len(m.BsidAddr.Addr); i++ { + m.BsidAddr.Addr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.SrPolicyIndex + m.SrPolicyIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + +// SrPolicyDelReply represents VPP binary API 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SrPolicyDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SrPolicyDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + +// SrPolicyMod represents VPP binary API message 'sr_policy_mod'. +type SrPolicyMod struct { + BsidAddr []byte `binapi:"u8[16],name=bsid_addr" json:"bsid_addr,omitempty" struc:"[16]byte"` + 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 uint8 `binapi:"u8,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 "c1dfaee0" } +func (*SrPolicyMod) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *SrPolicyMod) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.BsidAddr + size += 16 + // field[1] m.SrPolicyIndex + size += 4 + // field[1] m.FibTable + size += 4 + // field[1] m.Operation + size += 1 + // field[1] m.SlIndex + size += 4 + // field[1] m.Weight + size += 4 + // field[1] m.Sids + // field[2] m.Sids.NumSids + size += 1 + // field[2] m.Sids.Weight + size += 4 + // field[2] m.Sids.Sids + for j2 := 0; j2 < 16; j2++ { + var s2 Srv6Sid + _ = s2 + if j2 < len(m.Sids.Sids) { + s2 = m.Sids.Sids[j2] + } + // field[3] s2.Addr + size += 16 + } + return size +} +func (m *SrPolicyMod) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.BsidAddr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(m.BsidAddr) { + x = uint8(m.BsidAddr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.SrPolicyIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SrPolicyIndex)) + pos += 4 + // field[1] m.FibTable + o.PutUint32(buf[pos:pos+4], uint32(m.FibTable)) + pos += 4 + // field[1] m.Operation + buf[pos] = uint8(m.Operation) + pos += 1 + // field[1] m.SlIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SlIndex)) + pos += 4 + // field[1] m.Weight + o.PutUint32(buf[pos:pos+4], uint32(m.Weight)) + pos += 4 + // field[1] m.Sids + // field[2] m.Sids.NumSids + buf[pos] = uint8(m.Sids.NumSids) + pos += 1 + // field[2] m.Sids.Weight + o.PutUint32(buf[pos:pos+4], uint32(m.Sids.Weight)) + pos += 4 + // field[2] m.Sids.Sids + for j2 := 0; j2 < 16; j2++ { + var v2 Srv6Sid + if j2 < len(m.Sids.Sids) { + v2 = m.Sids.Sids[j2] + } + // field[3] v2.Addr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(v2.Addr) { + x = uint8(v2.Addr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + } + return buf, nil +} +func (m *SrPolicyMod) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.BsidAddr + m.BsidAddr = make([]uint8, 16) + for i := 0; i < len(m.BsidAddr); i++ { + m.BsidAddr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.SrPolicyIndex + m.SrPolicyIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.FibTable + m.FibTable = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Operation + m.Operation = uint8(tmp[pos]) + pos += 1 + // field[1] m.SlIndex + m.SlIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Weight + m.Weight = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Sids + // field[2] m.Sids.NumSids + m.Sids.NumSids = uint8(tmp[pos]) + pos += 1 + // field[2] m.Sids.Weight + m.Sids.Weight = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Sids.Sids + for j2 := 0; j2 < 16; j2++ { + // field[3] m.Sids.Sids[j2].Addr + m.Sids.Sids[j2].Addr = make([]uint8, 16) + for i := 0; i < len(m.Sids.Sids[j2].Addr); i++ { + m.Sids.Sids[j2].Addr[i] = uint8(tmp[pos]) + pos += 1 + } + } + return nil +} + +// SrPolicyModReply represents VPP binary API 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SrPolicyModReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SrPolicyModReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + +// SrSetEncapHopLimit represents VPP binary API 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.HopLimit + size += 1 + return size +} +func (m *SrSetEncapHopLimit) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.HopLimit + buf[pos] = uint8(m.HopLimit) + pos += 1 + return buf, nil +} +func (m *SrSetEncapHopLimit) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.HopLimit + m.HopLimit = uint8(tmp[pos]) + pos += 1 + return nil +} + +// SrSetEncapHopLimitReply represents VPP binary API 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SrSetEncapHopLimitReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SrSetEncapHopLimitReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + +// SrSetEncapSource represents VPP binary API message 'sr_set_encap_source'. +type SrSetEncapSource struct { + EncapsSource []byte `binapi:"u8[16],name=encaps_source" json:"encaps_source,omitempty" struc:"[16]byte"` +} + +func (m *SrSetEncapSource) Reset() { *m = SrSetEncapSource{} } +func (*SrSetEncapSource) GetMessageName() string { return "sr_set_encap_source" } +func (*SrSetEncapSource) GetCrcString() string { return "d05bb4de" } +func (*SrSetEncapSource) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *SrSetEncapSource) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.EncapsSource + size += 16 + return size +} +func (m *SrSetEncapSource) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.EncapsSource + for i := 0; i < 16; i++ { + var x uint8 + if i < len(m.EncapsSource) { + x = uint8(m.EncapsSource[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + return buf, nil +} +func (m *SrSetEncapSource) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.EncapsSource + m.EncapsSource = make([]uint8, 16) + for i := 0; i < len(m.EncapsSource); i++ { + m.EncapsSource[i] = uint8(tmp[pos]) + pos += 1 + } + return nil +} + +// SrSetEncapSourceReply represents VPP binary API 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SrSetEncapSourceReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SrSetEncapSourceReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + +// SrSteeringAddDel represents VPP binary API message 'sr_steering_add_del'. +type SrSteeringAddDel struct { + IsDel uint8 `binapi:"u8,name=is_del" json:"is_del,omitempty"` + BsidAddr []byte `binapi:"u8[16],name=bsid_addr" json:"bsid_addr,omitempty" struc:"[16]byte"` + SrPolicyIndex uint32 `binapi:"u32,name=sr_policy_index" json:"sr_policy_index,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + PrefixAddr []byte `binapi:"u8[16],name=prefix_addr" json:"prefix_addr,omitempty" struc:"[16]byte"` + MaskWidth uint32 `binapi:"u32,name=mask_width" json:"mask_width,omitempty"` + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + TrafficType uint8 `binapi:"u8,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 "28b5dcab" } +func (*SrSteeringAddDel) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *SrSteeringAddDel) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.IsDel + size += 1 + // field[1] m.BsidAddr + size += 16 + // field[1] m.SrPolicyIndex + size += 4 + // field[1] m.TableID + size += 4 + // field[1] m.PrefixAddr + size += 16 + // field[1] m.MaskWidth + size += 4 + // field[1] m.SwIfIndex + size += 4 + // field[1] m.TrafficType + size += 1 + return size +} +func (m *SrSteeringAddDel) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.IsDel + buf[pos] = uint8(m.IsDel) + pos += 1 + // field[1] m.BsidAddr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(m.BsidAddr) { + x = uint8(m.BsidAddr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.SrPolicyIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SrPolicyIndex)) + pos += 4 + // field[1] m.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.TableID)) + pos += 4 + // field[1] m.PrefixAddr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(m.PrefixAddr) { + x = uint8(m.PrefixAddr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.MaskWidth + o.PutUint32(buf[pos:pos+4], uint32(m.MaskWidth)) + pos += 4 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.TrafficType + buf[pos] = uint8(m.TrafficType) + pos += 1 + return buf, nil +} +func (m *SrSteeringAddDel) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.IsDel + m.IsDel = uint8(tmp[pos]) + pos += 1 + // field[1] m.BsidAddr + m.BsidAddr = make([]uint8, 16) + for i := 0; i < len(m.BsidAddr); i++ { + m.BsidAddr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.SrPolicyIndex + m.SrPolicyIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.TableID + m.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.PrefixAddr + m.PrefixAddr = make([]uint8, 16) + for i := 0; i < len(m.PrefixAddr); i++ { + m.PrefixAddr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.MaskWidth + m.MaskWidth = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SwIfIndex + m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.TrafficType + m.TrafficType = uint8(tmp[pos]) + pos += 1 + return nil +} + +// SrSteeringAddDelReply represents VPP binary API 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() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SrSteeringAddDelReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SrSteeringAddDelReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + +// SrSteeringPolDetails represents VPP binary API message 'sr_steering_pol_details'. +type SrSteeringPolDetails struct { + TrafficType uint8 `binapi:"u8,name=traffic_type" json:"traffic_type,omitempty"` + FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` + PrefixAddr []byte `binapi:"u8[16],name=prefix_addr" json:"prefix_addr,omitempty" struc:"[16]byte"` + MaskWidth uint32 `binapi:"u32,name=mask_width" json:"mask_width,omitempty"` + SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + Bsid Srv6Sid `binapi:"srv6_sid,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 "5627d483" } +func (*SrSteeringPolDetails) GetMessageType() api.MessageType { return api.ReplyMessage } + +func (m *SrSteeringPolDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.TrafficType + size += 1 + // field[1] m.FibTable + size += 4 + // field[1] m.PrefixAddr + size += 16 + // field[1] m.MaskWidth + size += 4 + // field[1] m.SwIfIndex + size += 4 + // field[1] m.Bsid + // field[2] m.Bsid.Addr + size += 16 + return size +} +func (m *SrSteeringPolDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.TrafficType + buf[pos] = uint8(m.TrafficType) + pos += 1 + // field[1] m.FibTable + o.PutUint32(buf[pos:pos+4], uint32(m.FibTable)) + pos += 4 + // field[1] m.PrefixAddr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(m.PrefixAddr) { + x = uint8(m.PrefixAddr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.MaskWidth + o.PutUint32(buf[pos:pos+4], uint32(m.MaskWidth)) + pos += 4 + // field[1] m.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) + pos += 4 + // field[1] m.Bsid + // field[2] m.Bsid.Addr + for i := 0; i < 16; i++ { + var x uint8 + if i < len(m.Bsid.Addr) { + x = uint8(m.Bsid.Addr[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + return buf, nil +} +func (m *SrSteeringPolDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.TrafficType + m.TrafficType = uint8(tmp[pos]) + pos += 1 + // field[1] m.FibTable + m.FibTable = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.PrefixAddr + m.PrefixAddr = make([]uint8, 16) + for i := 0; i < len(m.PrefixAddr); i++ { + m.PrefixAddr[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.MaskWidth + m.MaskWidth = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.SwIfIndex + m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Bsid + // field[2] m.Bsid.Addr + m.Bsid.Addr = make([]uint8, 16) + for i := 0; i < len(m.Bsid.Addr); i++ { + m.Bsid.Addr[i] = uint8(tmp[pos]) + pos += 1 + } + return nil +} + +// SrSteeringPolDump represents VPP binary API message 'sr_steering_pol_dump'. +type SrSteeringPolDump struct{} + +func (m *SrSteeringPolDump) Reset() { *m = SrSteeringPolDump{} } +func (*SrSteeringPolDump) GetMessageName() string { return "sr_steering_pol_dump" } +func (*SrSteeringPolDump) GetCrcString() string { return "51077d14" } +func (*SrSteeringPolDump) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *SrSteeringPolDump) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *SrSteeringPolDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *SrSteeringPolDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + +func init() { file_sr_binapi_init() } +func file_sr_binapi_init() { + api.RegisterMessage((*SrLocalsidAddDel)(nil), "sr.SrLocalsidAddDel") + api.RegisterMessage((*SrLocalsidAddDelReply)(nil), "sr.SrLocalsidAddDelReply") + api.RegisterMessage((*SrLocalsidsDetails)(nil), "sr.SrLocalsidsDetails") + api.RegisterMessage((*SrLocalsidsDump)(nil), "sr.SrLocalsidsDump") + api.RegisterMessage((*SrPoliciesDetails)(nil), "sr.SrPoliciesDetails") + api.RegisterMessage((*SrPoliciesDump)(nil), "sr.SrPoliciesDump") + api.RegisterMessage((*SrPolicyAdd)(nil), "sr.SrPolicyAdd") + api.RegisterMessage((*SrPolicyAddReply)(nil), "sr.SrPolicyAddReply") + api.RegisterMessage((*SrPolicyDel)(nil), "sr.SrPolicyDel") + api.RegisterMessage((*SrPolicyDelReply)(nil), "sr.SrPolicyDelReply") + api.RegisterMessage((*SrPolicyMod)(nil), "sr.SrPolicyMod") + api.RegisterMessage((*SrPolicyModReply)(nil), "sr.SrPolicyModReply") + api.RegisterMessage((*SrSetEncapHopLimit)(nil), "sr.SrSetEncapHopLimit") + api.RegisterMessage((*SrSetEncapHopLimitReply)(nil), "sr.SrSetEncapHopLimitReply") + api.RegisterMessage((*SrSetEncapSource)(nil), "sr.SrSetEncapSource") + api.RegisterMessage((*SrSetEncapSourceReply)(nil), "sr.SrSetEncapSourceReply") + api.RegisterMessage((*SrSteeringAddDel)(nil), "sr.SrSteeringAddDel") + api.RegisterMessage((*SrSteeringAddDelReply)(nil), "sr.SrSteeringAddDelReply") + api.RegisterMessage((*SrSteeringPolDetails)(nil), "sr.SrSteeringPolDetails") + api.RegisterMessage((*SrSteeringPolDump)(nil), "sr.SrSteeringPolDump") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*SrLocalsidAddDel)(nil), + (*SrLocalsidAddDelReply)(nil), + (*SrLocalsidsDetails)(nil), + (*SrLocalsidsDump)(nil), + (*SrPoliciesDetails)(nil), + (*SrPoliciesDump)(nil), + (*SrPolicyAdd)(nil), + (*SrPolicyAddReply)(nil), + (*SrPolicyDel)(nil), + (*SrPolicyDelReply)(nil), + (*SrPolicyMod)(nil), + (*SrPolicyModReply)(nil), + (*SrSetEncapHopLimit)(nil), + (*SrSetEncapHopLimitReply)(nil), + (*SrSetEncapSource)(nil), + (*SrSetEncapSourceReply)(nil), + (*SrSteeringAddDel)(nil), + (*SrSteeringAddDelReply)(nil), + (*SrSteeringPolDetails)(nil), + (*SrSteeringPolDump)(nil), + } +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = codec.DecodeString +var _ = bytes.NewBuffer +var _ = context.Background +var _ = io.Copy +var _ = strconv.Itoa +var _ = struc.Pack +var _ = binary.BigEndian +var _ = math.Float32bits diff --git a/examples/binapi/sr/sr_rpc.ba.go b/examples/binapi/sr/sr_rpc.ba.go new file mode 100644 index 0000000..aeb3cde --- /dev/null +++ b/examples/binapi/sr/sr_rpc.ba.go @@ -0,0 +1,178 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package sr + +import ( + "context" + "io" + + api "git.fd.io/govpp.git/api" +) + +// RPCService represents RPC service API for sr module. +type RPCService interface { + DumpSrLocalsids(ctx context.Context, in *SrLocalsidsDump) (RPCService_DumpSrLocalsidsClient, error) + DumpSrPolicies(ctx context.Context, in *SrPoliciesDump) (RPCService_DumpSrPoliciesClient, error) + DumpSrSteeringPol(ctx context.Context, in *SrSteeringPolDump) (RPCService_DumpSrSteeringPolClient, error) + SrLocalsidAddDel(ctx context.Context, in *SrLocalsidAddDel) (*SrLocalsidAddDelReply, error) + SrPolicyAdd(ctx context.Context, in *SrPolicyAdd) (*SrPolicyAddReply, error) + SrPolicyDel(ctx context.Context, in *SrPolicyDel) (*SrPolicyDelReply, error) + SrPolicyMod(ctx context.Context, in *SrPolicyMod) (*SrPolicyModReply, error) + SrSetEncapHopLimit(ctx context.Context, in *SrSetEncapHopLimit) (*SrSetEncapHopLimitReply, error) + SrSetEncapSource(ctx context.Context, in *SrSetEncapSource) (*SrSetEncapSourceReply, error) + SrSteeringAddDel(ctx context.Context, in *SrSteeringAddDel) (*SrSteeringAddDelReply, error) +} + +type serviceClient struct { + ch api.Channel +} + +func NewServiceClient(ch api.Channel) RPCService { + return &serviceClient{ch} +} + +func (c *serviceClient) DumpSrLocalsids(ctx context.Context, in *SrLocalsidsDump) (RPCService_DumpSrLocalsidsClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpSrLocalsidsClient{stream} + return x, nil +} + +type RPCService_DumpSrLocalsidsClient interface { + Recv() (*SrLocalsidsDetails, error) +} + +type serviceClient_DumpSrLocalsidsClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpSrLocalsidsClient) Recv() (*SrLocalsidsDetails, error) { + m := new(SrLocalsidsDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpSrPolicies(ctx context.Context, in *SrPoliciesDump) (RPCService_DumpSrPoliciesClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpSrPoliciesClient{stream} + return x, nil +} + +type RPCService_DumpSrPoliciesClient interface { + Recv() (*SrPoliciesDetails, error) +} + +type serviceClient_DumpSrPoliciesClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpSrPoliciesClient) Recv() (*SrPoliciesDetails, error) { + m := new(SrPoliciesDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpSrSteeringPol(ctx context.Context, in *SrSteeringPolDump) (RPCService_DumpSrSteeringPolClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpSrSteeringPolClient{stream} + return x, nil +} + +type RPCService_DumpSrSteeringPolClient interface { + Recv() (*SrSteeringPolDetails, error) +} + +type serviceClient_DumpSrSteeringPolClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpSrSteeringPolClient) Recv() (*SrSteeringPolDetails, error) { + m := new(SrSteeringPolDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) SrLocalsidAddDel(ctx context.Context, in *SrLocalsidAddDel) (*SrLocalsidAddDelReply, error) { + out := new(SrLocalsidAddDelReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) SrPolicyAdd(ctx context.Context, in *SrPolicyAdd) (*SrPolicyAddReply, error) { + out := new(SrPolicyAddReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) SrPolicyDel(ctx context.Context, in *SrPolicyDel) (*SrPolicyDelReply, error) { + out := new(SrPolicyDelReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) SrPolicyMod(ctx context.Context, in *SrPolicyMod) (*SrPolicyModReply, error) { + out := new(SrPolicyModReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) SrSetEncapHopLimit(ctx context.Context, in *SrSetEncapHopLimit) (*SrSetEncapHopLimitReply, error) { + out := new(SrSetEncapHopLimitReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) SrSetEncapSource(ctx context.Context, in *SrSetEncapSource) (*SrSetEncapSourceReply, error) { + out := new(SrSetEncapSourceReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) SrSteeringAddDel(ctx context.Context, in *SrSteeringAddDel) (*SrSteeringAddDelReply, error) { + out := new(SrSteeringAddDelReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = context.Background +var _ = io.Copy diff --git a/examples/binapi/vpe/vpe.ba.go b/examples/binapi/vpe/vpe.ba.go index 48b6389..4c00c86 100644 --- a/examples/binapi/vpe/vpe.ba.go +++ b/examples/binapi/vpe/vpe.ba.go @@ -1,30 +1,39 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty +// VPP: 20.01-45~g7a071e370~b63 // source: /usr/share/vpp/api/core/vpe.api.json /* -Package vpe is a generated VPP binary API for 'vpe' module. +Package vpe contains generated code for VPP binary API defined by vpe.api (version 1.6.0). It consists of: - 1 enum 2 aliases - 2 types + 1 enum 26 messages - 13 services + 2 types */ package vpe import ( "bytes" "context" + "encoding/binary" "io" + "math" "strconv" api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" struc "github.com/lunixbochs/struc" - - vpe_types "git.fd.io/govpp.git/examples/binapi/vpe_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 // please upgrade the GoVPP api package + const ( // ModuleName is the name of this module. ModuleName = "vpe" @@ -34,31 +43,88 @@ const ( VersionCrc = 0xc6c0bcf6 ) -type LogLevel = vpe_types.LogLevel +// 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", + } + 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 "LogLevel(" + strconv.Itoa(int(x)) + ")" +} -type Timedelta = vpe_types.Timedelta +// Timedelta represents VPP binary API alias 'timedelta'. +type Timedelta float64 -type Timestamp = vpe_types.Timestamp +// Timestamp represents VPP binary API alias 'timestamp'. +type Timestamp float64 // 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 + ID uint32 `binapi:"u32,name=id" json:"id,omitempty"` + Name []byte `binapi:"u8[64],name=name" json:"name,omitempty" struc:"[64]byte"` + Type []byte `binapi:"u8[64],name=type" json:"type,omitempty" struc:"[64]byte"` + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` + CPUID uint32 `binapi:"u32,name=cpu_id" json:"cpu_id,omitempty"` + Core uint32 `binapi:"u32,name=core" json:"core,omitempty"` + CPUSocket uint32 `binapi:"u32,name=cpu_socket" json:"cpu_socket,omitempty"` } func (*ThreadData) GetTypeName() string { return "thread_data" } -type Version = vpe_types.Version +// Version represents VPP binary API type 'version'. +type Version 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"` + PreRelease []byte `binapi:"u8[17],name=pre_release" json:"pre_release,omitempty" struc:"[17]byte"` + BuildMetadata []byte `binapi:"u8[17],name=build_metadata" json:"build_metadata,omitempty" struc:"[17]byte"` +} + +func (*Version) GetTypeName() string { return "version" } // AddNodeNext represents VPP binary API message 'add_node_next'. type AddNodeNext struct { - NodeName []byte `struc:"[64]byte"` - NextName []byte `struc:"[64]byte"` + NodeName []byte `binapi:"u8[64],name=node_name" json:"node_name,omitempty" struc:"[64]byte"` + NextName []byte `binapi:"u8[64],name=next_name" json:"next_name,omitempty" struc:"[64]byte"` } func (m *AddNodeNext) Reset() { *m = AddNodeNext{} } @@ -66,10 +132,72 @@ func (*AddNodeNext) GetMessageName() string { return "add_node_next" } func (*AddNodeNext) GetCrcString() string { return "9ab92f7a" } func (*AddNodeNext) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *AddNodeNext) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.NodeName + size += 64 + // field[1] m.NextName + size += 64 + return size +} +func (m *AddNodeNext) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.NodeName + for i := 0; i < 64; i++ { + var x uint8 + if i < len(m.NodeName) { + x = uint8(m.NodeName[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.NextName + for i := 0; i < 64; i++ { + var x uint8 + if i < len(m.NextName) { + x = uint8(m.NextName[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + return buf, nil +} +func (m *AddNodeNext) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.NodeName + m.NodeName = make([]uint8, 64) + for i := 0; i < len(m.NodeName); i++ { + m.NodeName[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.NextName + m.NextName = make([]uint8, 64) + for i := 0; i < len(m.NextName); i++ { + m.NextName[i] = uint8(tmp[pos]) + pos += 1 + } + return nil +} + // AddNodeNextReply represents VPP binary API message 'add_node_next_reply'. type AddNodeNextReply struct { - Retval int32 - NextIndex uint32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + NextIndex uint32 `binapi:"u32,name=next_index" json:"next_index,omitempty"` } func (m *AddNodeNextReply) Reset() { *m = AddNodeNextReply{} } @@ -77,9 +205,53 @@ func (*AddNodeNextReply) GetMessageName() string { return "add_node_nex func (*AddNodeNextReply) GetCrcString() string { return "2ed75f32" } func (*AddNodeNextReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *AddNodeNextReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.NextIndex + size += 4 + return size +} +func (m *AddNodeNextReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.NextIndex + o.PutUint32(buf[pos:pos+4], uint32(m.NextIndex)) + pos += 4 + return buf, nil +} +func (m *AddNodeNextReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.NextIndex + m.NextIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // Cli represents VPP binary API message 'cli'. type Cli struct { - CmdInShmem uint64 + CmdInShmem uint64 `binapi:"u64,name=cmd_in_shmem" json:"cmd_in_shmem,omitempty"` } func (m *Cli) Reset() { *m = Cli{} } @@ -87,10 +259,46 @@ func (*Cli) GetMessageName() string { return "cli" } func (*Cli) GetCrcString() string { return "23bfbfff" } func (*Cli) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *Cli) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.CmdInShmem + size += 8 + return size +} +func (m *Cli) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.CmdInShmem + o.PutUint64(buf[pos:pos+8], uint64(m.CmdInShmem)) + pos += 8 + return buf, nil +} +func (m *Cli) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.CmdInShmem + m.CmdInShmem = uint64(o.Uint64(tmp[pos : pos+8])) + pos += 8 + return nil +} + // CliInband represents VPP binary API message 'cli_inband'. type CliInband struct { XXX_CmdLen uint32 `struc:"sizeof=Cmd"` - Cmd string + Cmd string `json:"cmd,omitempty"` } func (m *CliInband) Reset() { *m = CliInband{} } @@ -98,11 +306,53 @@ func (*CliInband) GetMessageName() string { return "cli_inband" } func (*CliInband) GetCrcString() string { return "f8377302" } func (*CliInband) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *CliInband) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Cmd + size += 4 + len(m.Cmd) + return size +} +func (m *CliInband) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Cmd + o.PutUint32(buf[pos:pos+4], uint32(len(m.Cmd))) + pos += 4 + copy(buf[pos:pos+len(m.Cmd)], m.Cmd[:]) + pos += len(m.Cmd) + return buf, nil +} +func (m *CliInband) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Cmd + { + siz := o.Uint32(tmp[pos : pos+4]) + pos += 4 + m.Cmd = codec.DecodeString(tmp[pos : pos+int(siz)]) + pos += len(m.Cmd) + } + return nil +} + // CliInbandReply represents VPP binary API message 'cli_inband_reply'. type CliInbandReply struct { - Retval int32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` XXX_ReplyLen uint32 `struc:"sizeof=Reply"` - Reply string + Reply string `json:"reply,omitempty"` } func (m *CliInbandReply) Reset() { *m = CliInbandReply{} } @@ -110,10 +360,60 @@ func (*CliInbandReply) GetMessageName() string { return "cli_inband_rep func (*CliInbandReply) GetCrcString() string { return "05879051" } func (*CliInbandReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *CliInbandReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.Reply + size += 4 + len(m.Reply) + return size +} +func (m *CliInbandReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.Reply + o.PutUint32(buf[pos:pos+4], uint32(len(m.Reply))) + pos += 4 + copy(buf[pos:pos+len(m.Reply)], m.Reply[:]) + pos += len(m.Reply) + return buf, nil +} +func (m *CliInbandReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Reply + { + siz := o.Uint32(tmp[pos : pos+4]) + pos += 4 + m.Reply = codec.DecodeString(tmp[pos : pos+int(siz)]) + pos += len(m.Reply) + } + return nil +} + // CliReply represents VPP binary API message 'cli_reply'. type CliReply struct { - Retval int32 - ReplyInShmem uint64 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + ReplyInShmem uint64 `binapi:"u64,name=reply_in_shmem" json:"reply_in_shmem,omitempty"` } func (m *CliReply) Reset() { *m = CliReply{} } @@ -121,6 +421,50 @@ func (*CliReply) GetMessageName() string { return "cli_reply" } func (*CliReply) GetCrcString() string { return "06d68297" } func (*CliReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *CliReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.ReplyInShmem + size += 8 + return size +} +func (m *CliReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.ReplyInShmem + o.PutUint64(buf[pos:pos+8], uint64(m.ReplyInShmem)) + pos += 8 + return buf, nil +} +func (m *CliReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.ReplyInShmem + m.ReplyInShmem = uint64(o.Uint64(tmp[pos : pos+8])) + pos += 8 + return nil +} + // ControlPing represents VPP binary API message 'control_ping'. type ControlPing struct{} @@ -129,11 +473,39 @@ 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() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *ControlPing) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *ControlPing) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + // ControlPingReply represents VPP binary API message 'control_ping_reply'. type ControlPingReply struct { - Retval int32 - ClientIndex uint32 - VpePID uint32 + 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{} } @@ -141,9 +513,61 @@ func (*ControlPingReply) GetMessageName() string { return "control_ping func (*ControlPingReply) GetCrcString() string { return "f6b0b8ca" } func (*ControlPingReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *ControlPingReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.ClientIndex + size += 4 + // field[1] m.VpePID + size += 4 + return size +} +func (m *ControlPingReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.ClientIndex + o.PutUint32(buf[pos:pos+4], uint32(m.ClientIndex)) + pos += 4 + // field[1] m.VpePID + o.PutUint32(buf[pos:pos+4], uint32(m.VpePID)) + pos += 4 + return buf, nil +} +func (m *ControlPingReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.ClientIndex + m.ClientIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.VpePID + m.VpePID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // GetF64EndianValue represents VPP binary API message 'get_f64_endian_value'. type GetF64EndianValue struct { - F64One float64 + F64One float64 `binapi:"f64,name=f64_one,default=1" json:"f64_one,omitempty"` } func (m *GetF64EndianValue) Reset() { *m = GetF64EndianValue{} } @@ -151,10 +575,46 @@ func (*GetF64EndianValue) GetMessageName() string { return "get_f64_end func (*GetF64EndianValue) GetCrcString() string { return "809fcd44" } func (*GetF64EndianValue) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *GetF64EndianValue) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.F64One + size += 8 + return size +} +func (m *GetF64EndianValue) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.F64One + o.PutUint64(buf[pos:pos+8], math.Float64bits(float64(m.F64One))) + pos += 8 + return buf, nil +} +func (m *GetF64EndianValue) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.F64One + m.F64One = float64(math.Float64frombits(o.Uint64(tmp[pos : pos+8]))) + pos += 8 + return nil +} + // GetF64EndianValueReply represents VPP binary API message 'get_f64_endian_value_reply'. type GetF64EndianValueReply struct { - Retval uint32 - F64OneResult float64 + Retval uint32 `binapi:"u32,name=retval" json:"retval,omitempty"` + F64OneResult float64 `binapi:"f64,name=f64_one_result" json:"f64_one_result,omitempty"` } func (m *GetF64EndianValueReply) Reset() { *m = GetF64EndianValueReply{} } @@ -162,9 +622,53 @@ func (*GetF64EndianValueReply) GetMessageName() string { return "get_f6 func (*GetF64EndianValueReply) GetCrcString() string { return "7e02e404" } func (*GetF64EndianValueReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *GetF64EndianValueReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.F64OneResult + size += 8 + return size +} +func (m *GetF64EndianValueReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.F64OneResult + o.PutUint64(buf[pos:pos+8], math.Float64bits(float64(m.F64OneResult))) + pos += 8 + return buf, nil +} +func (m *GetF64EndianValueReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.F64OneResult + m.F64OneResult = float64(math.Float64frombits(o.Uint64(tmp[pos : pos+8]))) + pos += 8 + return nil +} + // GetF64IncrementByOne represents VPP binary API message 'get_f64_increment_by_one'. type GetF64IncrementByOne struct { - F64Value float64 + F64Value float64 `binapi:"f64,name=f64_value,default=1" json:"f64_value,omitempty"` } func (m *GetF64IncrementByOne) Reset() { *m = GetF64IncrementByOne{} } @@ -172,10 +676,46 @@ func (*GetF64IncrementByOne) GetMessageName() string { return "get_f64_ func (*GetF64IncrementByOne) GetCrcString() string { return "b64f027e" } func (*GetF64IncrementByOne) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *GetF64IncrementByOne) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.F64Value + size += 8 + return size +} +func (m *GetF64IncrementByOne) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.F64Value + o.PutUint64(buf[pos:pos+8], math.Float64bits(float64(m.F64Value))) + pos += 8 + return buf, nil +} +func (m *GetF64IncrementByOne) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.F64Value + m.F64Value = float64(math.Float64frombits(o.Uint64(tmp[pos : pos+8]))) + pos += 8 + return nil +} + // GetF64IncrementByOneReply represents VPP binary API message 'get_f64_increment_by_one_reply'. type GetF64IncrementByOneReply struct { - Retval uint32 - F64Value float64 + Retval uint32 `binapi:"u32,name=retval" json:"retval,omitempty"` + F64Value float64 `binapi:"f64,name=f64_value" json:"f64_value,omitempty"` } func (m *GetF64IncrementByOneReply) Reset() { *m = GetF64IncrementByOneReply{} } @@ -183,10 +723,54 @@ func (*GetF64IncrementByOneReply) GetMessageName() string { return "get func (*GetF64IncrementByOneReply) GetCrcString() string { return "d25dbaa3" } func (*GetF64IncrementByOneReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *GetF64IncrementByOneReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.F64Value + size += 8 + return size +} +func (m *GetF64IncrementByOneReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.F64Value + o.PutUint64(buf[pos:pos+8], math.Float64bits(float64(m.F64Value))) + pos += 8 + return buf, nil +} +func (m *GetF64IncrementByOneReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.F64Value + m.F64Value = float64(math.Float64frombits(o.Uint64(tmp[pos : pos+8]))) + pos += 8 + return nil +} + // GetNextIndex represents VPP binary API message 'get_next_index'. type GetNextIndex struct { - NodeName []byte `struc:"[64]byte"` - NextName []byte `struc:"[64]byte"` + NodeName []byte `binapi:"u8[64],name=node_name" json:"node_name,omitempty" struc:"[64]byte"` + NextName []byte `binapi:"u8[64],name=next_name" json:"next_name,omitempty" struc:"[64]byte"` } func (m *GetNextIndex) Reset() { *m = GetNextIndex{} } @@ -194,10 +778,72 @@ func (*GetNextIndex) GetMessageName() string { return "get_next_index" func (*GetNextIndex) GetCrcString() string { return "9ab92f7a" } func (*GetNextIndex) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *GetNextIndex) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.NodeName + size += 64 + // field[1] m.NextName + size += 64 + return size +} +func (m *GetNextIndex) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.NodeName + for i := 0; i < 64; i++ { + var x uint8 + if i < len(m.NodeName) { + x = uint8(m.NodeName[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[1] m.NextName + for i := 0; i < 64; i++ { + var x uint8 + if i < len(m.NextName) { + x = uint8(m.NextName[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + return buf, nil +} +func (m *GetNextIndex) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.NodeName + m.NodeName = make([]uint8, 64) + for i := 0; i < len(m.NodeName); i++ { + m.NodeName[i] = uint8(tmp[pos]) + pos += 1 + } + // field[1] m.NextName + m.NextName = make([]uint8, 64) + for i := 0; i < len(m.NextName); i++ { + m.NextName[i] = uint8(tmp[pos]) + pos += 1 + } + return nil +} + // GetNextIndexReply represents VPP binary API message 'get_next_index_reply'. type GetNextIndexReply struct { - Retval int32 - NextIndex uint32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + NextIndex uint32 `binapi:"u32,name=next_index" json:"next_index,omitempty"` } func (m *GetNextIndexReply) Reset() { *m = GetNextIndexReply{} } @@ -205,6 +851,50 @@ func (*GetNextIndexReply) GetMessageName() string { return "get_next_in func (*GetNextIndexReply) GetCrcString() string { return "2ed75f32" } func (*GetNextIndexReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *GetNextIndexReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.NextIndex + size += 4 + return size +} +func (m *GetNextIndexReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.NextIndex + o.PutUint32(buf[pos:pos+4], uint32(m.NextIndex)) + pos += 4 + return buf, nil +} +func (m *GetNextIndexReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.NextIndex + m.NextIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // GetNodeGraph represents VPP binary API message 'get_node_graph'. type GetNodeGraph struct{} @@ -213,10 +903,38 @@ func (*GetNodeGraph) GetMessageName() string { return "get_node_graph" func (*GetNodeGraph) GetCrcString() string { return "51077d14" } func (*GetNodeGraph) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *GetNodeGraph) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *GetNodeGraph) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *GetNodeGraph) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + // GetNodeGraphReply represents VPP binary API message 'get_node_graph_reply'. type GetNodeGraphReply struct { - Retval int32 - ReplyInShmem uint64 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + ReplyInShmem uint64 `binapi:"u64,name=reply_in_shmem" json:"reply_in_shmem,omitempty"` } func (m *GetNodeGraphReply) Reset() { *m = GetNodeGraphReply{} } @@ -224,9 +942,53 @@ func (*GetNodeGraphReply) GetMessageName() string { return "get_node_gr func (*GetNodeGraphReply) GetCrcString() string { return "06d68297" } func (*GetNodeGraphReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *GetNodeGraphReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.ReplyInShmem + size += 8 + return size +} +func (m *GetNodeGraphReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.ReplyInShmem + o.PutUint64(buf[pos:pos+8], uint64(m.ReplyInShmem)) + pos += 8 + return buf, nil +} +func (m *GetNodeGraphReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.ReplyInShmem + m.ReplyInShmem = uint64(o.Uint64(tmp[pos : pos+8])) + pos += 8 + return nil +} + // GetNodeIndex represents VPP binary API message 'get_node_index'. type GetNodeIndex struct { - NodeName []byte `struc:"[64]byte"` + NodeName []byte `binapi:"u8[64],name=node_name" json:"node_name,omitempty" struc:"[64]byte"` } func (m *GetNodeIndex) Reset() { *m = GetNodeIndex{} } @@ -234,10 +996,55 @@ func (*GetNodeIndex) GetMessageName() string { return "get_node_index" func (*GetNodeIndex) GetCrcString() string { return "6c9a495d" } func (*GetNodeIndex) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *GetNodeIndex) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.NodeName + size += 64 + return size +} +func (m *GetNodeIndex) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.NodeName + for i := 0; i < 64; i++ { + var x uint8 + if i < len(m.NodeName) { + x = uint8(m.NodeName[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + return buf, nil +} +func (m *GetNodeIndex) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.NodeName + m.NodeName = make([]uint8, 64) + for i := 0; i < len(m.NodeName); i++ { + m.NodeName[i] = uint8(tmp[pos]) + pos += 1 + } + return nil +} + // GetNodeIndexReply represents VPP binary API message 'get_node_index_reply'. type GetNodeIndexReply struct { - Retval int32 - NodeIndex uint32 + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + NodeIndex uint32 `binapi:"u32,name=node_index" json:"node_index,omitempty"` } func (m *GetNodeIndexReply) Reset() { *m = GetNodeIndexReply{} } @@ -245,12 +1052,56 @@ func (*GetNodeIndexReply) GetMessageName() string { return "get_node_in func (*GetNodeIndexReply) GetCrcString() string { return "a8600b89" } func (*GetNodeIndexReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *GetNodeIndexReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.NodeIndex + size += 4 + return size +} +func (m *GetNodeIndexReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.NodeIndex + o.PutUint32(buf[pos:pos+4], uint32(m.NodeIndex)) + pos += 4 + return buf, nil +} +func (m *GetNodeIndexReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.NodeIndex + m.NodeIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // 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"` + Timestamp Timestamp `binapi:"timestamp,name=timestamp" json:"timestamp,omitempty"` + Level LogLevel `binapi:"log_level,name=level" json:"level,omitempty"` + MsgClass string `binapi:"string[32],name=msg_class" json:"msg_class,omitempty" struc:"[32]byte"` + Message string `binapi:"string[256],name=message" json:"message,omitempty" struc:"[256]byte"` } func (m *LogDetails) Reset() { *m = LogDetails{} } @@ -258,9 +1109,75 @@ func (*LogDetails) GetMessageName() string { return "log_details" } func (*LogDetails) GetCrcString() string { return "255827a1" } func (*LogDetails) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *LogDetails) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Timestamp + size += 8 + // field[1] m.Level + size += 4 + // field[1] m.MsgClass + size += 32 + // field[1] m.Message + size += 256 + return size +} +func (m *LogDetails) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Timestamp + o.PutUint64(buf[pos:pos+8], math.Float64bits(float64(m.Timestamp))) + pos += 8 + // field[1] m.Level + o.PutUint32(buf[pos:pos+4], uint32(m.Level)) + pos += 4 + // field[1] m.MsgClass + copy(buf[pos:pos+32], m.MsgClass) + pos += 32 + // field[1] m.Message + copy(buf[pos:pos+256], m.Message) + pos += 256 + return buf, nil +} +func (m *LogDetails) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Timestamp + m.Timestamp = Timestamp(math.Float64frombits(o.Uint64(tmp[pos : pos+8]))) + pos += 8 + // field[1] m.Level + m.Level = LogLevel(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.MsgClass + { + nul := bytes.Index(tmp[pos:pos+32], []byte{0x00}) + m.MsgClass = codec.DecodeString(tmp[pos : pos+nul]) + pos += 32 + } + // field[1] m.Message + { + nul := bytes.Index(tmp[pos:pos+256], []byte{0x00}) + m.Message = codec.DecodeString(tmp[pos : pos+nul]) + pos += 256 + } + return nil +} + // LogDump represents VPP binary API message 'log_dump'. type LogDump struct { - StartTimestamp Timestamp + StartTimestamp Timestamp `binapi:"timestamp,name=start_timestamp" json:"start_timestamp,omitempty"` } func (m *LogDump) Reset() { *m = LogDump{} } @@ -268,6 +1185,42 @@ func (*LogDump) GetMessageName() string { return "log_dump" } func (*LogDump) GetCrcString() string { return "6ab31753" } func (*LogDump) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *LogDump) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.StartTimestamp + size += 8 + return size +} +func (m *LogDump) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.StartTimestamp + o.PutUint64(buf[pos:pos+8], math.Float64bits(float64(m.StartTimestamp))) + pos += 8 + return buf, nil +} +func (m *LogDump) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.StartTimestamp + m.StartTimestamp = Timestamp(math.Float64frombits(o.Uint64(tmp[pos : pos+8]))) + pos += 8 + return nil +} + // ShowThreads represents VPP binary API message 'show_threads'. type ShowThreads struct{} @@ -276,11 +1229,39 @@ func (*ShowThreads) GetMessageName() string { return "show_threads" } func (*ShowThreads) GetCrcString() string { return "51077d14" } func (*ShowThreads) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *ShowThreads) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *ShowThreads) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *ShowThreads) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + // ShowThreadsReply represents VPP binary API message 'show_threads_reply'. type ShowThreadsReply struct { - Retval int32 - Count uint32 `struc:"sizeof=ThreadData"` - ThreadData []ThreadData + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"count,omitempty" struc:"sizeof=ThreadData"` + ThreadData []ThreadData `binapi:"thread_data[count],name=thread_data" json:"thread_data,omitempty"` } func (m *ShowThreadsReply) Reset() { *m = ShowThreadsReply{} } @@ -288,6 +1269,143 @@ func (*ShowThreadsReply) GetMessageName() string { return "show_threads func (*ShowThreadsReply) GetCrcString() string { return "f5e0b66f" } func (*ShowThreadsReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *ShowThreadsReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.Count + size += 4 + // field[1] m.ThreadData + for j1 := 0; j1 < len(m.ThreadData); j1++ { + var s1 ThreadData + _ = s1 + if j1 < len(m.ThreadData) { + s1 = m.ThreadData[j1] + } + // field[2] s1.ID + size += 4 + // field[2] s1.Name + size += 64 + // field[2] s1.Type + size += 64 + // field[2] s1.PID + size += 4 + // field[2] s1.CPUID + size += 4 + // field[2] s1.Core + size += 4 + // field[2] s1.CPUSocket + size += 4 + } + return size +} +func (m *ShowThreadsReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.Count + o.PutUint32(buf[pos:pos+4], uint32(len(m.ThreadData))) + pos += 4 + // field[1] m.ThreadData + for j1 := 0; j1 < len(m.ThreadData); j1++ { + var v1 ThreadData + if j1 < len(m.ThreadData) { + v1 = m.ThreadData[j1] + } + // field[2] v1.ID + o.PutUint32(buf[pos:pos+4], uint32(v1.ID)) + pos += 4 + // field[2] v1.Name + for i := 0; i < 64; i++ { + var x uint8 + if i < len(v1.Name) { + x = uint8(v1.Name[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[2] v1.Type + for i := 0; i < 64; i++ { + var x uint8 + if i < len(v1.Type) { + x = uint8(v1.Type[i]) + } + buf[pos] = uint8(x) + pos += 1 + } + // field[2] v1.PID + o.PutUint32(buf[pos:pos+4], uint32(v1.PID)) + pos += 4 + // field[2] v1.CPUID + o.PutUint32(buf[pos:pos+4], uint32(v1.CPUID)) + pos += 4 + // field[2] v1.Core + o.PutUint32(buf[pos:pos+4], uint32(v1.Core)) + pos += 4 + // field[2] v1.CPUSocket + o.PutUint32(buf[pos:pos+4], uint32(v1.CPUSocket)) + pos += 4 + } + return buf, nil +} +func (m *ShowThreadsReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Count + m.Count = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.ThreadData + m.ThreadData = make([]ThreadData, int(m.Count)) + for j1 := 0; j1 < int(m.Count); j1++ { + // field[2] m.ThreadData[j1].ID + m.ThreadData[j1].ID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.ThreadData[j1].Name + m.ThreadData[j1].Name = make([]uint8, 64) + for i := 0; i < len(m.ThreadData[j1].Name); i++ { + m.ThreadData[j1].Name[i] = uint8(tmp[pos]) + pos += 1 + } + // field[2] m.ThreadData[j1].Type + m.ThreadData[j1].Type = make([]uint8, 64) + for i := 0; i < len(m.ThreadData[j1].Type); i++ { + m.ThreadData[j1].Type[i] = uint8(tmp[pos]) + pos += 1 + } + // field[2] m.ThreadData[j1].PID + m.ThreadData[j1].PID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.ThreadData[j1].CPUID + m.ThreadData[j1].CPUID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.ThreadData[j1].Core + m.ThreadData[j1].Core = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.ThreadData[j1].CPUSocket + m.ThreadData[j1].CPUSocket = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + } + return nil +} + // ShowVersion represents VPP binary API message 'show_version'. type ShowVersion struct{} @@ -296,13 +1414,41 @@ func (*ShowVersion) GetMessageName() string { return "show_version" } func (*ShowVersion) GetCrcString() string { return "51077d14" } func (*ShowVersion) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *ShowVersion) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *ShowVersion) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *ShowVersion) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + // 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"` + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Program string `binapi:"string[32],name=program" json:"program,omitempty" struc:"[32]byte"` + Version string `binapi:"string[32],name=version" json:"version,omitempty" struc:"[32]byte"` + BuildDate string `binapi:"string[32],name=build_date" json:"build_date,omitempty" struc:"[32]byte"` + BuildDirectory string `binapi:"string[256],name=build_directory" json:"build_directory,omitempty" struc:"[256]byte"` } func (m *ShowVersionReply) Reset() { *m = ShowVersionReply{} } @@ -310,6 +1456,86 @@ func (*ShowVersionReply) GetMessageName() string { return "show_version func (*ShowVersionReply) GetCrcString() string { return "c919bde1" } func (*ShowVersionReply) GetMessageType() api.MessageType { return api.ReplyMessage } +func (m *ShowVersionReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.Program + size += 32 + // field[1] m.Version + size += 32 + // field[1] m.BuildDate + size += 32 + // field[1] m.BuildDirectory + size += 256 + return size +} +func (m *ShowVersionReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.Program + copy(buf[pos:pos+32], m.Program) + pos += 32 + // field[1] m.Version + copy(buf[pos:pos+32], m.Version) + pos += 32 + // field[1] m.BuildDate + copy(buf[pos:pos+32], m.BuildDate) + pos += 32 + // field[1] m.BuildDirectory + copy(buf[pos:pos+256], m.BuildDirectory) + pos += 256 + return buf, nil +} +func (m *ShowVersionReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Program + { + nul := bytes.Index(tmp[pos:pos+32], []byte{0x00}) + m.Program = codec.DecodeString(tmp[pos : pos+nul]) + pos += 32 + } + // field[1] m.Version + { + nul := bytes.Index(tmp[pos:pos+32], []byte{0x00}) + m.Version = codec.DecodeString(tmp[pos : pos+nul]) + pos += 32 + } + // field[1] m.BuildDate + { + nul := bytes.Index(tmp[pos:pos+32], []byte{0x00}) + m.BuildDate = codec.DecodeString(tmp[pos : pos+nul]) + pos += 32 + } + // field[1] m.BuildDirectory + { + nul := bytes.Index(tmp[pos:pos+256], []byte{0x00}) + m.BuildDirectory = codec.DecodeString(tmp[pos : pos+nul]) + pos += 256 + } + return nil +} + // ShowVpeSystemTime represents VPP binary API message 'show_vpe_system_time'. type ShowVpeSystemTime struct{} @@ -318,10 +1544,38 @@ func (*ShowVpeSystemTime) GetMessageName() string { return "show_vpe_sy func (*ShowVpeSystemTime) GetCrcString() string { return "51077d14" } func (*ShowVpeSystemTime) GetMessageType() api.MessageType { return api.RequestMessage } +func (m *ShowVpeSystemTime) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *ShowVpeSystemTime) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *ShowVpeSystemTime) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + // ShowVpeSystemTimeReply represents VPP binary API message 'show_vpe_system_time_reply'. type ShowVpeSystemTimeReply struct { - Retval int32 - VpeSystemTime Timestamp + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + VpeSystemTime Timestamp `binapi:"timestamp,name=vpe_system_time" json:"vpe_system_time,omitempty"` } func (m *ShowVpeSystemTimeReply) Reset() { *m = ShowVpeSystemTimeReply{} } @@ -329,7 +1583,52 @@ func (*ShowVpeSystemTimeReply) GetMessageName() string { return "show_v func (*ShowVpeSystemTimeReply) GetCrcString() string { return "7ffd8193" } func (*ShowVpeSystemTimeReply) GetMessageType() api.MessageType { return api.ReplyMessage } -func init() { +func (m *ShowVpeSystemTimeReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.VpeSystemTime + size += 8 + return size +} +func (m *ShowVpeSystemTimeReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.VpeSystemTime + o.PutUint64(buf[pos:pos+8], math.Float64bits(float64(m.VpeSystemTime))) + pos += 8 + return buf, nil +} +func (m *ShowVpeSystemTimeReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.VpeSystemTime + m.VpeSystemTime = Timestamp(math.Float64frombits(o.Uint64(tmp[pos : pos+8]))) + pos += 8 + return nil +} + +func init() { file_vpe_binapi_init() } +func file_vpe_binapi_init() { api.RegisterMessage((*AddNodeNext)(nil), "vpe.AddNodeNext") api.RegisterMessage((*AddNodeNextReply)(nil), "vpe.AddNodeNextReply") api.RegisterMessage((*Cli)(nil), "vpe.Cli") @@ -390,175 +1689,13 @@ func AllMessages() []api.Message { } } -// 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 _ = codec.DecodeString var _ = bytes.NewBuffer var _ = context.Background var _ = io.Copy var _ = strconv.Itoa var _ = struc.Pack +var _ = binary.BigEndian +var _ = math.Float32bits diff --git a/examples/binapi/vpe/vpe_rpc.ba.go b/examples/binapi/vpe/vpe_rpc.ba.go new file mode 100644 index 0000000..e81fb91 --- /dev/null +++ b/examples/binapi/vpe/vpe_rpc.ba.go @@ -0,0 +1,174 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package vpe + +import ( + "context" + "io" + + api "git.fd.io/govpp.git/api" +) + +// 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 +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = context.Background +var _ = io.Copy 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 dbe81e0..0000000 --- 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 "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "vpe_types" - // VersionCrc is the CRC of this module. - VersionCrc = 0x3369988d -) - -// LogLevel represents VPP binary API enum 'log_level'. -type LogLevel uint32 - -const ( - VPE_API_LOG_LEVEL_EMERG LogLevel = 0 - VPE_API_LOG_LEVEL_ALERT LogLevel = 1 - VPE_API_LOG_LEVEL_CRIT LogLevel = 2 - VPE_API_LOG_LEVEL_ERR LogLevel = 3 - VPE_API_LOG_LEVEL_WARNING LogLevel = 4 - VPE_API_LOG_LEVEL_NOTICE LogLevel = 5 - VPE_API_LOG_LEVEL_INFO LogLevel = 6 - VPE_API_LOG_LEVEL_DEBUG LogLevel = 7 - VPE_API_LOG_LEVEL_DISABLED LogLevel = 8 -) - -var LogLevel_name = map[uint32]string{ - 0: "VPE_API_LOG_LEVEL_EMERG", - 1: "VPE_API_LOG_LEVEL_ALERT", - 2: "VPE_API_LOG_LEVEL_CRIT", - 3: "VPE_API_LOG_LEVEL_ERR", - 4: "VPE_API_LOG_LEVEL_WARNING", - 5: "VPE_API_LOG_LEVEL_NOTICE", - 6: "VPE_API_LOG_LEVEL_INFO", - 7: "VPE_API_LOG_LEVEL_DEBUG", - 8: "VPE_API_LOG_LEVEL_DISABLED", -} - -var LogLevel_value = map[string]uint32{ - "VPE_API_LOG_LEVEL_EMERG": 0, - "VPE_API_LOG_LEVEL_ALERT": 1, - "VPE_API_LOG_LEVEL_CRIT": 2, - "VPE_API_LOG_LEVEL_ERR": 3, - "VPE_API_LOG_LEVEL_WARNING": 4, - "VPE_API_LOG_LEVEL_NOTICE": 5, - "VPE_API_LOG_LEVEL_INFO": 6, - "VPE_API_LOG_LEVEL_DEBUG": 7, - "VPE_API_LOG_LEVEL_DISABLED": 8, -} - -func (x LogLevel) String() string { - s, ok := LogLevel_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// Timedelta represents VPP binary API alias 'timedelta'. -type Timedelta float64 - -// Timestamp represents VPP binary API alias 'timestamp'. -type Timestamp float64 - -// Version represents VPP binary API type 'version'. -type Version struct { - Major uint32 - Minor uint32 - Patch uint32 - PreRelease []byte `struc:"[17]byte"` - BuildMetadata []byte `struc:"[17]byte"` -} - -func (*Version) GetTypeName() string { return "version" } - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/examples/simple-client/simple_client.go b/examples/simple-client/simple_client.go index fe7c109..0017eac 100644 --- a/examples/simple-client/simple_client.go +++ b/examples/simple-client/simple_client.go @@ -27,10 +27,8 @@ import ( "git.fd.io/govpp.git/adapter/socketclient" "git.fd.io/govpp.git/api" "git.fd.io/govpp.git/core" - "git.fd.io/govpp.git/examples/binapi/interface_types" "git.fd.io/govpp.git/examples/binapi/interfaces" "git.fd.io/govpp.git/examples/binapi/ip" - "git.fd.io/govpp.git/examples/binapi/ip_types" "git.fd.io/govpp.git/examples/binapi/vpe" ) @@ -166,10 +164,10 @@ func addIPAddress(ch api.Channel, index interfaces.InterfaceIndex) { req := &interfaces.SwInterfaceAddDelAddress{ SwIfIndex: index, IsAdd: true, - Prefix: ip_types.AddressWithPrefix{ + Prefix: interfaces.AddressWithPrefix{ Address: interfaces.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(interfaces.IP4Address{10, 10, 0, uint8(index)}), + Af: interfaces.ADDRESS_IP4, + Un: interfaces.AddressUnionIP4(interfaces.IP4Address{10, 10, 0, uint8(index)}), }, Len: 32, }, @@ -190,7 +188,7 @@ func ipAddressDump(ch api.Channel, index interfaces.InterfaceIndex) { fmt.Printf("Dumping IP addresses for interface index %d\n", index) req := &ip.IPAddressDump{ - SwIfIndex: index, + SwIfIndex: ip.InterfaceIndex(index), } reqCtx := ch.SendMultiRequest(req) @@ -246,7 +244,7 @@ func interfaceNotifications(ch api.Channel, index interfaces.InterfaceIndex) { // generate some events in VPP err = ch.SendRequest(&interfaces.SwInterfaceSetFlags{ SwIfIndex: index, - Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, + Flags: interfaces.IF_STATUS_API_FLAG_ADMIN_UP, }).ReceiveReply(&interfaces.SwInterfaceSetFlagsReply{}) if err != nil { logError(err, "setting interface flags") |