diff options
author | 2020-06-18 08:22:13 +0200 | |
---|---|---|
committer | 2020-06-22 14:37:14 +0200 | |
commit | 94620e85f0bdbb054af07ce3670fadc1f76cfdf0 (patch) | |
tree | 7784ddf381c4e08a6a1ece5b55911b47ea8395f3 /examples/binapi/vpe | |
parent | 280b1c6c83b676ef4e592f4ecf60cb5b54b6a753 (diff) |
Refactored binapi generator with message encoding
Change-Id: I5a6abb68b9d058866f94818169300e5c2fc43895
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'examples/binapi/vpe')
-rw-r--r-- | examples/binapi/vpe/vpe.ba.go | 1589 | ||||
-rw-r--r-- | examples/binapi/vpe/vpe_rpc.ba.go | 174 |
2 files changed, 1537 insertions, 226 deletions
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 |