Improve binapi generator
[govpp.git] / binapi / urpf / urpf.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2 // versions:
3 //  binapi-generator: v0.4.0-dev
4 //  VPP:              20.05-release
5 // source: /usr/share/vpp/api/plugins/urpf.api.json
6
7 // Package urpf contains generated bindings for API file urpf.api.
8 //
9 // Contents:
10 //   1 enum
11 //   2 messages
12 //
13 package urpf
14
15 import (
16         api "git.fd.io/govpp.git/api"
17         _ "git.fd.io/govpp.git/binapi/fib_types"
18         interface_types "git.fd.io/govpp.git/binapi/interface_types"
19         ip_types "git.fd.io/govpp.git/binapi/ip_types"
20         codec "git.fd.io/govpp.git/codec"
21         "strconv"
22 )
23
24 // This is a compile-time assertion to ensure that this generated file
25 // is compatible with the GoVPP api package it is being compiled against.
26 // A compilation error at this line likely means your copy of the
27 // GoVPP api package needs to be updated.
28 const _ = api.GoVppAPIPackageIsVersion2
29
30 const (
31         APIFile    = "urpf"
32         APIVersion = "1.0.0"
33         VersionCrc = 0x3e2ebd8a
34 )
35
36 // UrpfMode defines enum 'urpf_mode'.
37 type UrpfMode uint8
38
39 const (
40         URPF_API_MODE_OFF    UrpfMode = 1
41         URPF_API_MODE_LOOSE  UrpfMode = 2
42         URPF_API_MODE_STRICT UrpfMode = 3
43 )
44
45 var (
46         UrpfMode_name = map[uint8]string{
47                 1: "URPF_API_MODE_OFF",
48                 2: "URPF_API_MODE_LOOSE",
49                 3: "URPF_API_MODE_STRICT",
50         }
51         UrpfMode_value = map[string]uint8{
52                 "URPF_API_MODE_OFF":    1,
53                 "URPF_API_MODE_LOOSE":  2,
54                 "URPF_API_MODE_STRICT": 3,
55         }
56 )
57
58 func (x UrpfMode) String() string {
59         s, ok := UrpfMode_name[uint8(x)]
60         if ok {
61                 return s
62         }
63         return "UrpfMode(" + strconv.Itoa(int(x)) + ")"
64 }
65
66 // UrpfUpdate defines message 'urpf_update'.
67 type UrpfUpdate struct {
68         IsInput   bool                           `binapi:"bool,name=is_input,default=true" json:"is_input,omitempty"`
69         Mode      UrpfMode                       `binapi:"urpf_mode,name=mode" json:"mode,omitempty"`
70         Af        ip_types.AddressFamily         `binapi:"address_family,name=af" json:"af,omitempty"`
71         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
72 }
73
74 func (m *UrpfUpdate) Reset()               { *m = UrpfUpdate{} }
75 func (*UrpfUpdate) GetMessageName() string { return "urpf_update" }
76 func (*UrpfUpdate) GetCrcString() string   { return "2bf8a77c" }
77 func (*UrpfUpdate) GetMessageType() api.MessageType {
78         return api.RequestMessage
79 }
80
81 func (m *UrpfUpdate) Size() int {
82         if m == nil {
83                 return 0
84         }
85         var size int
86         size += 1 // m.IsInput
87         size += 1 // m.Mode
88         size += 1 // m.Af
89         size += 4 // m.SwIfIndex
90         return size
91 }
92 func (m *UrpfUpdate) Marshal(b []byte) ([]byte, error) {
93         var buf *codec.Buffer
94         if b == nil {
95                 buf = codec.NewBuffer(make([]byte, m.Size()))
96         } else {
97                 buf = codec.NewBuffer(b)
98         }
99         buf.EncodeBool(m.IsInput)
100         buf.EncodeUint8(uint8(m.Mode))
101         buf.EncodeUint8(uint8(m.Af))
102         buf.EncodeUint32(uint32(m.SwIfIndex))
103         return buf.Bytes(), nil
104 }
105 func (m *UrpfUpdate) Unmarshal(b []byte) error {
106         buf := codec.NewBuffer(b)
107         m.IsInput = buf.DecodeBool()
108         m.Mode = UrpfMode(buf.DecodeUint8())
109         m.Af = ip_types.AddressFamily(buf.DecodeUint8())
110         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
111         return nil
112 }
113
114 // UrpfUpdateReply defines message 'urpf_update_reply'.
115 type UrpfUpdateReply struct {
116         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
117 }
118
119 func (m *UrpfUpdateReply) Reset()               { *m = UrpfUpdateReply{} }
120 func (*UrpfUpdateReply) GetMessageName() string { return "urpf_update_reply" }
121 func (*UrpfUpdateReply) GetCrcString() string   { return "e8d4e804" }
122 func (*UrpfUpdateReply) GetMessageType() api.MessageType {
123         return api.ReplyMessage
124 }
125
126 func (m *UrpfUpdateReply) Size() int {
127         if m == nil {
128                 return 0
129         }
130         var size int
131         size += 4 // m.Retval
132         return size
133 }
134 func (m *UrpfUpdateReply) Marshal(b []byte) ([]byte, error) {
135         var buf *codec.Buffer
136         if b == nil {
137                 buf = codec.NewBuffer(make([]byte, m.Size()))
138         } else {
139                 buf = codec.NewBuffer(b)
140         }
141         buf.EncodeUint32(uint32(m.Retval))
142         return buf.Bytes(), nil
143 }
144 func (m *UrpfUpdateReply) Unmarshal(b []byte) error {
145         buf := codec.NewBuffer(b)
146         m.Retval = int32(buf.DecodeUint32())
147         return nil
148 }
149
150 func init() { file_urpf_binapi_init() }
151 func file_urpf_binapi_init() {
152         api.RegisterMessage((*UrpfUpdate)(nil), "urpf_update_2bf8a77c")
153         api.RegisterMessage((*UrpfUpdateReply)(nil), "urpf_update_reply_e8d4e804")
154 }
155
156 // Messages returns list of all messages in this module.
157 func AllMessages() []api.Message {
158         return []api.Message{
159                 (*UrpfUpdate)(nil),
160                 (*UrpfUpdateReply)(nil),
161         }
162 }