Jonathan Hart | 44bdbfc | 2020-04-14 17:45:47 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 3 | * Copyright (c) 2011, 2012 Open Networking Foundation |
| 4 | * Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler. |
| 5 | * Copyright 2018, Red Hat, Inc. |
| 6 | */ |
| 7 | // Automatically generated by LOXI from template module.go |
| 8 | // Do not modify |
| 9 | |
| 10 | package of14 |
| 11 | |
| 12 | import ( |
| 13 | "bytes" |
| 14 | "encoding/binary" |
| 15 | "fmt" |
| 16 | |
| 17 | "github.com/opencord/goloxi" |
| 18 | ) |
| 19 | |
| 20 | type Instruction struct { |
| 21 | Type uint16 |
| 22 | Len uint16 |
| 23 | } |
| 24 | |
| 25 | type IInstruction interface { |
| 26 | goloxi.Serializable |
| 27 | GetType() uint16 |
| 28 | GetLen() uint16 |
| 29 | } |
| 30 | |
| 31 | func (self *Instruction) GetType() uint16 { |
| 32 | return self.Type |
| 33 | } |
| 34 | |
| 35 | func (self *Instruction) SetType(v uint16) { |
| 36 | self.Type = v |
| 37 | } |
| 38 | |
| 39 | func (self *Instruction) GetLen() uint16 { |
| 40 | return self.Len |
| 41 | } |
| 42 | |
| 43 | func (self *Instruction) SetLen(v uint16) { |
| 44 | self.Len = v |
| 45 | } |
| 46 | |
| 47 | func (self *Instruction) Serialize(encoder *goloxi.Encoder) error { |
| 48 | |
| 49 | encoder.PutUint16(uint16(self.Type)) |
| 50 | encoder.PutUint16(uint16(self.Len)) |
| 51 | |
| 52 | return nil |
| 53 | } |
| 54 | |
| 55 | func DecodeInstruction(decoder *goloxi.Decoder) (IInstruction, error) { |
| 56 | _instruction := &Instruction{} |
| 57 | if decoder.Length() < 4 { |
| 58 | return nil, fmt.Errorf("Instruction packet too short: %d < 4", decoder.Length()) |
| 59 | } |
| 60 | _instruction.Type = uint16(decoder.ReadUint16()) |
| 61 | _instruction.Len = uint16(decoder.ReadUint16()) |
| 62 | oldDecoder := decoder |
| 63 | defer func() { decoder = oldDecoder }() |
| 64 | decoder = decoder.SliceDecoder(int(_instruction.Len), 2+2) |
| 65 | |
| 66 | switch _instruction.Type { |
| 67 | case 1: |
| 68 | return DecodeInstructionGotoTable(_instruction, decoder) |
| 69 | case 2: |
| 70 | return DecodeInstructionWriteMetadata(_instruction, decoder) |
| 71 | case 3: |
| 72 | return DecodeInstructionWriteActions(_instruction, decoder) |
| 73 | case 4: |
| 74 | return DecodeInstructionApplyActions(_instruction, decoder) |
| 75 | case 5: |
| 76 | return DecodeInstructionClearActions(_instruction, decoder) |
| 77 | case 6: |
| 78 | return DecodeInstructionMeter(_instruction, decoder) |
| 79 | case 65535: |
| 80 | return DecodeInstructionExperimenter(_instruction, decoder) |
| 81 | default: |
| 82 | return nil, fmt.Errorf("Invalid type '%d' for 'Instruction'", _instruction.Type) |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | func NewInstruction(_type uint16) *Instruction { |
| 87 | obj := &Instruction{} |
| 88 | obj.Type = _type |
| 89 | return obj |
| 90 | } |
| 91 | |
| 92 | type InstructionApplyActions struct { |
| 93 | *Instruction |
| 94 | Actions []goloxi.IAction |
| 95 | } |
| 96 | |
| 97 | type IInstructionApplyActions interface { |
| 98 | IInstruction |
| 99 | GetActions() []goloxi.IAction |
| 100 | } |
| 101 | |
| 102 | func (self *InstructionApplyActions) GetActions() []goloxi.IAction { |
| 103 | return self.Actions |
| 104 | } |
| 105 | |
| 106 | func (self *InstructionApplyActions) SetActions(v []goloxi.IAction) { |
| 107 | self.Actions = v |
| 108 | } |
| 109 | |
| 110 | func (self *InstructionApplyActions) Serialize(encoder *goloxi.Encoder) error { |
| 111 | startIndex := len(encoder.Bytes()) |
| 112 | if err := self.Instruction.Serialize(encoder); err != nil { |
| 113 | return err |
| 114 | } |
| 115 | |
| 116 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 117 | for _, obj := range self.Actions { |
| 118 | if err := obj.Serialize(encoder); err != nil { |
| 119 | return err |
| 120 | } |
| 121 | } |
| 122 | length := len(encoder.Bytes()) - startIndex |
| 123 | |
| 124 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 125 | |
| 126 | return nil |
| 127 | } |
| 128 | |
| 129 | func DecodeInstructionApplyActions(parent *Instruction, decoder *goloxi.Decoder) (*InstructionApplyActions, error) { |
| 130 | _instructionapplyactions := &InstructionApplyActions{Instruction: parent} |
| 131 | if decoder.Length() < 4 { |
| 132 | return nil, fmt.Errorf("InstructionApplyActions packet too short: %d < 4", decoder.Length()) |
| 133 | } |
| 134 | decoder.Skip(4) |
| 135 | |
| 136 | for decoder.Length() >= 8 { |
| 137 | item, err := DecodeAction(decoder) |
| 138 | if err != nil { |
| 139 | return nil, err |
| 140 | } |
| 141 | if item != nil { |
| 142 | _instructionapplyactions.Actions = append(_instructionapplyactions.Actions, item) |
| 143 | } |
| 144 | } |
| 145 | return _instructionapplyactions, nil |
| 146 | } |
| 147 | |
| 148 | func NewInstructionApplyActions() *InstructionApplyActions { |
| 149 | obj := &InstructionApplyActions{ |
| 150 | Instruction: NewInstruction(4), |
| 151 | } |
| 152 | return obj |
| 153 | } |
| 154 | |
| 155 | type InstructionExperimenter struct { |
| 156 | *Instruction |
| 157 | Experimenter uint32 |
| 158 | } |
| 159 | |
| 160 | type IInstructionExperimenter interface { |
| 161 | IInstruction |
| 162 | GetExperimenter() uint32 |
| 163 | } |
| 164 | |
| 165 | func (self *InstructionExperimenter) GetExperimenter() uint32 { |
| 166 | return self.Experimenter |
| 167 | } |
| 168 | |
| 169 | func (self *InstructionExperimenter) SetExperimenter(v uint32) { |
| 170 | self.Experimenter = v |
| 171 | } |
| 172 | |
| 173 | func (self *InstructionExperimenter) Serialize(encoder *goloxi.Encoder) error { |
| 174 | if err := self.Instruction.Serialize(encoder); err != nil { |
| 175 | return err |
| 176 | } |
| 177 | |
| 178 | encoder.PutUint32(uint32(self.Experimenter)) |
| 179 | |
| 180 | return nil |
| 181 | } |
| 182 | |
| 183 | func DecodeInstructionExperimenter(parent *Instruction, decoder *goloxi.Decoder) (IInstructionExperimenter, error) { |
| 184 | _instructionexperimenter := &InstructionExperimenter{Instruction: parent} |
| 185 | if decoder.Length() < 4 { |
| 186 | return nil, fmt.Errorf("InstructionExperimenter packet too short: %d < 4", decoder.Length()) |
| 187 | } |
| 188 | _instructionexperimenter.Experimenter = uint32(decoder.ReadUint32()) |
| 189 | |
| 190 | switch _instructionexperimenter.Experimenter { |
| 191 | case 6035143: |
| 192 | return DecodeInstructionBsn(_instructionexperimenter, decoder) |
| 193 | default: |
| 194 | return nil, fmt.Errorf("Invalid type '%d' for 'InstructionExperimenter'", _instructionexperimenter.Experimenter) |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | func NewInstructionExperimenter(_experimenter uint32) *InstructionExperimenter { |
| 199 | obj := &InstructionExperimenter{ |
| 200 | Instruction: NewInstruction(65535), |
| 201 | } |
| 202 | obj.Experimenter = _experimenter |
| 203 | return obj |
| 204 | } |
| 205 | |
| 206 | type InstructionBsn struct { |
| 207 | *InstructionExperimenter |
| 208 | Subtype uint32 |
| 209 | } |
| 210 | |
| 211 | type IInstructionBsn interface { |
| 212 | IInstructionExperimenter |
| 213 | GetSubtype() uint32 |
| 214 | } |
| 215 | |
| 216 | func (self *InstructionBsn) GetSubtype() uint32 { |
| 217 | return self.Subtype |
| 218 | } |
| 219 | |
| 220 | func (self *InstructionBsn) SetSubtype(v uint32) { |
| 221 | self.Subtype = v |
| 222 | } |
| 223 | |
| 224 | func (self *InstructionBsn) Serialize(encoder *goloxi.Encoder) error { |
| 225 | if err := self.InstructionExperimenter.Serialize(encoder); err != nil { |
| 226 | return err |
| 227 | } |
| 228 | |
| 229 | encoder.PutUint32(uint32(self.Subtype)) |
| 230 | |
| 231 | return nil |
| 232 | } |
| 233 | |
| 234 | func DecodeInstructionBsn(parent *InstructionExperimenter, decoder *goloxi.Decoder) (IInstructionBsn, error) { |
| 235 | _instructionbsn := &InstructionBsn{InstructionExperimenter: parent} |
| 236 | if decoder.Length() < 4 { |
| 237 | return nil, fmt.Errorf("InstructionBsn packet too short: %d < 4", decoder.Length()) |
| 238 | } |
| 239 | _instructionbsn.Subtype = uint32(decoder.ReadUint32()) |
| 240 | |
| 241 | switch _instructionbsn.Subtype { |
| 242 | case 0: |
| 243 | return DecodeInstructionBsnDisableSrcMacCheck(_instructionbsn, decoder) |
| 244 | case 1: |
| 245 | return DecodeInstructionBsnArpOffload(_instructionbsn, decoder) |
| 246 | case 2: |
| 247 | return DecodeInstructionBsnDhcpOffload(_instructionbsn, decoder) |
| 248 | case 4: |
| 249 | return DecodeInstructionBsnPermit(_instructionbsn, decoder) |
| 250 | case 5: |
| 251 | return DecodeInstructionBsnDeny(_instructionbsn, decoder) |
| 252 | case 6: |
| 253 | return DecodeInstructionBsnPacketOfDeath(_instructionbsn, decoder) |
| 254 | case 7: |
| 255 | return DecodeInstructionBsnPrioritizePdus(_instructionbsn, decoder) |
| 256 | case 8: |
| 257 | return DecodeInstructionBsnRequireVlanXlate(_instructionbsn, decoder) |
| 258 | case 9: |
| 259 | return DecodeInstructionBsnDisableVlanCounters(_instructionbsn, decoder) |
| 260 | case 10: |
| 261 | return DecodeInstructionBsnSpanDestination(_instructionbsn, decoder) |
| 262 | case 11: |
| 263 | return DecodeInstructionBsnAutoNegotiation(_instructionbsn, decoder) |
| 264 | case 12: |
| 265 | return DecodeInstructionBsnInternalPriority(_instructionbsn, decoder) |
| 266 | case 13: |
| 267 | return DecodeInstructionBsnDisableL3(_instructionbsn, decoder) |
| 268 | case 14: |
| 269 | return DecodeInstructionBsnNdpOffload(_instructionbsn, decoder) |
| 270 | case 15: |
| 271 | return DecodeInstructionBsnHashSelect(_instructionbsn, decoder) |
| 272 | case 16: |
| 273 | return DecodeInstructionBsnDirectedBroadcast(_instructionbsn, decoder) |
| 274 | default: |
| 275 | return nil, fmt.Errorf("Invalid type '%d' for 'InstructionBsn'", _instructionbsn.Subtype) |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | func NewInstructionBsn(_subtype uint32) *InstructionBsn { |
| 280 | obj := &InstructionBsn{ |
| 281 | InstructionExperimenter: NewInstructionExperimenter(6035143), |
| 282 | } |
| 283 | obj.Subtype = _subtype |
| 284 | return obj |
| 285 | } |
| 286 | |
| 287 | type InstructionBsnArpOffload struct { |
| 288 | *InstructionBsn |
| 289 | } |
| 290 | |
| 291 | type IInstructionBsnArpOffload interface { |
| 292 | IInstructionBsn |
| 293 | } |
| 294 | |
| 295 | func (self *InstructionBsnArpOffload) Serialize(encoder *goloxi.Encoder) error { |
| 296 | startIndex := len(encoder.Bytes()) |
| 297 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 298 | return err |
| 299 | } |
| 300 | |
| 301 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 302 | length := len(encoder.Bytes()) - startIndex |
| 303 | |
| 304 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 305 | |
| 306 | return nil |
| 307 | } |
| 308 | |
| 309 | func DecodeInstructionBsnArpOffload(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnArpOffload, error) { |
| 310 | _instructionbsnarpoffload := &InstructionBsnArpOffload{InstructionBsn: parent} |
| 311 | if decoder.Length() < 4 { |
| 312 | return nil, fmt.Errorf("InstructionBsnArpOffload packet too short: %d < 4", decoder.Length()) |
| 313 | } |
| 314 | decoder.Skip(4) |
| 315 | return _instructionbsnarpoffload, nil |
| 316 | } |
| 317 | |
| 318 | func NewInstructionBsnArpOffload() *InstructionBsnArpOffload { |
| 319 | obj := &InstructionBsnArpOffload{ |
| 320 | InstructionBsn: NewInstructionBsn(1), |
| 321 | } |
| 322 | return obj |
| 323 | } |
| 324 | |
| 325 | type InstructionBsnAutoNegotiation struct { |
| 326 | *InstructionBsn |
| 327 | } |
| 328 | |
| 329 | type IInstructionBsnAutoNegotiation interface { |
| 330 | IInstructionBsn |
| 331 | } |
| 332 | |
| 333 | func (self *InstructionBsnAutoNegotiation) Serialize(encoder *goloxi.Encoder) error { |
| 334 | startIndex := len(encoder.Bytes()) |
| 335 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 336 | return err |
| 337 | } |
| 338 | |
| 339 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 340 | length := len(encoder.Bytes()) - startIndex |
| 341 | |
| 342 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 343 | |
| 344 | return nil |
| 345 | } |
| 346 | |
| 347 | func DecodeInstructionBsnAutoNegotiation(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnAutoNegotiation, error) { |
| 348 | _instructionbsnautonegotiation := &InstructionBsnAutoNegotiation{InstructionBsn: parent} |
| 349 | if decoder.Length() < 4 { |
| 350 | return nil, fmt.Errorf("InstructionBsnAutoNegotiation packet too short: %d < 4", decoder.Length()) |
| 351 | } |
| 352 | decoder.Skip(4) |
| 353 | return _instructionbsnautonegotiation, nil |
| 354 | } |
| 355 | |
| 356 | func NewInstructionBsnAutoNegotiation() *InstructionBsnAutoNegotiation { |
| 357 | obj := &InstructionBsnAutoNegotiation{ |
| 358 | InstructionBsn: NewInstructionBsn(11), |
| 359 | } |
| 360 | return obj |
| 361 | } |
| 362 | |
| 363 | type InstructionBsnDeny struct { |
| 364 | *InstructionBsn |
| 365 | } |
| 366 | |
| 367 | type IInstructionBsnDeny interface { |
| 368 | IInstructionBsn |
| 369 | } |
| 370 | |
| 371 | func (self *InstructionBsnDeny) Serialize(encoder *goloxi.Encoder) error { |
| 372 | startIndex := len(encoder.Bytes()) |
| 373 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 374 | return err |
| 375 | } |
| 376 | |
| 377 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 378 | length := len(encoder.Bytes()) - startIndex |
| 379 | |
| 380 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 381 | |
| 382 | return nil |
| 383 | } |
| 384 | |
| 385 | func DecodeInstructionBsnDeny(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnDeny, error) { |
| 386 | _instructionbsndeny := &InstructionBsnDeny{InstructionBsn: parent} |
| 387 | if decoder.Length() < 4 { |
| 388 | return nil, fmt.Errorf("InstructionBsnDeny packet too short: %d < 4", decoder.Length()) |
| 389 | } |
| 390 | decoder.Skip(4) |
| 391 | return _instructionbsndeny, nil |
| 392 | } |
| 393 | |
| 394 | func NewInstructionBsnDeny() *InstructionBsnDeny { |
| 395 | obj := &InstructionBsnDeny{ |
| 396 | InstructionBsn: NewInstructionBsn(5), |
| 397 | } |
| 398 | return obj |
| 399 | } |
| 400 | |
| 401 | type InstructionBsnDhcpOffload struct { |
| 402 | *InstructionBsn |
| 403 | } |
| 404 | |
| 405 | type IInstructionBsnDhcpOffload interface { |
| 406 | IInstructionBsn |
| 407 | } |
| 408 | |
| 409 | func (self *InstructionBsnDhcpOffload) Serialize(encoder *goloxi.Encoder) error { |
| 410 | startIndex := len(encoder.Bytes()) |
| 411 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 412 | return err |
| 413 | } |
| 414 | |
| 415 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 416 | length := len(encoder.Bytes()) - startIndex |
| 417 | |
| 418 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 419 | |
| 420 | return nil |
| 421 | } |
| 422 | |
| 423 | func DecodeInstructionBsnDhcpOffload(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnDhcpOffload, error) { |
| 424 | _instructionbsndhcpoffload := &InstructionBsnDhcpOffload{InstructionBsn: parent} |
| 425 | if decoder.Length() < 4 { |
| 426 | return nil, fmt.Errorf("InstructionBsnDhcpOffload packet too short: %d < 4", decoder.Length()) |
| 427 | } |
| 428 | decoder.Skip(4) |
| 429 | return _instructionbsndhcpoffload, nil |
| 430 | } |
| 431 | |
| 432 | func NewInstructionBsnDhcpOffload() *InstructionBsnDhcpOffload { |
| 433 | obj := &InstructionBsnDhcpOffload{ |
| 434 | InstructionBsn: NewInstructionBsn(2), |
| 435 | } |
| 436 | return obj |
| 437 | } |
| 438 | |
| 439 | type InstructionBsnDirectedBroadcast struct { |
| 440 | *InstructionBsn |
| 441 | } |
| 442 | |
| 443 | type IInstructionBsnDirectedBroadcast interface { |
| 444 | IInstructionBsn |
| 445 | } |
| 446 | |
| 447 | func (self *InstructionBsnDirectedBroadcast) Serialize(encoder *goloxi.Encoder) error { |
| 448 | startIndex := len(encoder.Bytes()) |
| 449 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 450 | return err |
| 451 | } |
| 452 | |
| 453 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 454 | length := len(encoder.Bytes()) - startIndex |
| 455 | |
| 456 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 457 | |
| 458 | return nil |
| 459 | } |
| 460 | |
| 461 | func DecodeInstructionBsnDirectedBroadcast(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnDirectedBroadcast, error) { |
| 462 | _instructionbsndirectedbroadcast := &InstructionBsnDirectedBroadcast{InstructionBsn: parent} |
| 463 | if decoder.Length() < 4 { |
| 464 | return nil, fmt.Errorf("InstructionBsnDirectedBroadcast packet too short: %d < 4", decoder.Length()) |
| 465 | } |
| 466 | decoder.Skip(4) |
| 467 | return _instructionbsndirectedbroadcast, nil |
| 468 | } |
| 469 | |
| 470 | func NewInstructionBsnDirectedBroadcast() *InstructionBsnDirectedBroadcast { |
| 471 | obj := &InstructionBsnDirectedBroadcast{ |
| 472 | InstructionBsn: NewInstructionBsn(16), |
| 473 | } |
| 474 | return obj |
| 475 | } |
| 476 | |
| 477 | type InstructionBsnDisableL3 struct { |
| 478 | *InstructionBsn |
| 479 | } |
| 480 | |
| 481 | type IInstructionBsnDisableL3 interface { |
| 482 | IInstructionBsn |
| 483 | } |
| 484 | |
| 485 | func (self *InstructionBsnDisableL3) Serialize(encoder *goloxi.Encoder) error { |
| 486 | startIndex := len(encoder.Bytes()) |
| 487 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 488 | return err |
| 489 | } |
| 490 | |
| 491 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 492 | length := len(encoder.Bytes()) - startIndex |
| 493 | |
| 494 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 495 | |
| 496 | return nil |
| 497 | } |
| 498 | |
| 499 | func DecodeInstructionBsnDisableL3(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnDisableL3, error) { |
| 500 | _instructionbsndisablel3 := &InstructionBsnDisableL3{InstructionBsn: parent} |
| 501 | if decoder.Length() < 4 { |
| 502 | return nil, fmt.Errorf("InstructionBsnDisableL3 packet too short: %d < 4", decoder.Length()) |
| 503 | } |
| 504 | decoder.Skip(4) |
| 505 | return _instructionbsndisablel3, nil |
| 506 | } |
| 507 | |
| 508 | func NewInstructionBsnDisableL3() *InstructionBsnDisableL3 { |
| 509 | obj := &InstructionBsnDisableL3{ |
| 510 | InstructionBsn: NewInstructionBsn(13), |
| 511 | } |
| 512 | return obj |
| 513 | } |
| 514 | |
| 515 | type InstructionBsnDisableSrcMacCheck struct { |
| 516 | *InstructionBsn |
| 517 | } |
| 518 | |
| 519 | type IInstructionBsnDisableSrcMacCheck interface { |
| 520 | IInstructionBsn |
| 521 | } |
| 522 | |
| 523 | func (self *InstructionBsnDisableSrcMacCheck) Serialize(encoder *goloxi.Encoder) error { |
| 524 | startIndex := len(encoder.Bytes()) |
| 525 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 526 | return err |
| 527 | } |
| 528 | |
| 529 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 530 | length := len(encoder.Bytes()) - startIndex |
| 531 | |
| 532 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 533 | |
| 534 | return nil |
| 535 | } |
| 536 | |
| 537 | func DecodeInstructionBsnDisableSrcMacCheck(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnDisableSrcMacCheck, error) { |
| 538 | _instructionbsndisablesrcmaccheck := &InstructionBsnDisableSrcMacCheck{InstructionBsn: parent} |
| 539 | if decoder.Length() < 4 { |
| 540 | return nil, fmt.Errorf("InstructionBsnDisableSrcMacCheck packet too short: %d < 4", decoder.Length()) |
| 541 | } |
| 542 | decoder.Skip(4) |
| 543 | return _instructionbsndisablesrcmaccheck, nil |
| 544 | } |
| 545 | |
| 546 | func NewInstructionBsnDisableSrcMacCheck() *InstructionBsnDisableSrcMacCheck { |
| 547 | obj := &InstructionBsnDisableSrcMacCheck{ |
| 548 | InstructionBsn: NewInstructionBsn(0), |
| 549 | } |
| 550 | return obj |
| 551 | } |
| 552 | |
| 553 | type InstructionBsnDisableVlanCounters struct { |
| 554 | *InstructionBsn |
| 555 | } |
| 556 | |
| 557 | type IInstructionBsnDisableVlanCounters interface { |
| 558 | IInstructionBsn |
| 559 | } |
| 560 | |
| 561 | func (self *InstructionBsnDisableVlanCounters) Serialize(encoder *goloxi.Encoder) error { |
| 562 | startIndex := len(encoder.Bytes()) |
| 563 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 564 | return err |
| 565 | } |
| 566 | |
| 567 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 568 | length := len(encoder.Bytes()) - startIndex |
| 569 | |
| 570 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 571 | |
| 572 | return nil |
| 573 | } |
| 574 | |
| 575 | func DecodeInstructionBsnDisableVlanCounters(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnDisableVlanCounters, error) { |
| 576 | _instructionbsndisablevlancounters := &InstructionBsnDisableVlanCounters{InstructionBsn: parent} |
| 577 | if decoder.Length() < 4 { |
| 578 | return nil, fmt.Errorf("InstructionBsnDisableVlanCounters packet too short: %d < 4", decoder.Length()) |
| 579 | } |
| 580 | decoder.Skip(4) |
| 581 | return _instructionbsndisablevlancounters, nil |
| 582 | } |
| 583 | |
| 584 | func NewInstructionBsnDisableVlanCounters() *InstructionBsnDisableVlanCounters { |
| 585 | obj := &InstructionBsnDisableVlanCounters{ |
| 586 | InstructionBsn: NewInstructionBsn(9), |
| 587 | } |
| 588 | return obj |
| 589 | } |
| 590 | |
| 591 | type InstructionBsnHashSelect struct { |
| 592 | *InstructionBsn |
| 593 | Flags BsnHashSelectFlags |
| 594 | } |
| 595 | |
| 596 | type IInstructionBsnHashSelect interface { |
| 597 | IInstructionBsn |
| 598 | GetFlags() BsnHashSelectFlags |
| 599 | } |
| 600 | |
| 601 | func (self *InstructionBsnHashSelect) GetFlags() BsnHashSelectFlags { |
| 602 | return self.Flags |
| 603 | } |
| 604 | |
| 605 | func (self *InstructionBsnHashSelect) SetFlags(v BsnHashSelectFlags) { |
| 606 | self.Flags = v |
| 607 | } |
| 608 | |
| 609 | func (self *InstructionBsnHashSelect) Serialize(encoder *goloxi.Encoder) error { |
| 610 | startIndex := len(encoder.Bytes()) |
| 611 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 612 | return err |
| 613 | } |
| 614 | |
| 615 | encoder.PutUint32(uint32(self.Flags)) |
| 616 | length := len(encoder.Bytes()) - startIndex |
| 617 | |
| 618 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 619 | |
| 620 | return nil |
| 621 | } |
| 622 | |
| 623 | func DecodeInstructionBsnHashSelect(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnHashSelect, error) { |
| 624 | _instructionbsnhashselect := &InstructionBsnHashSelect{InstructionBsn: parent} |
| 625 | if decoder.Length() < 4 { |
| 626 | return nil, fmt.Errorf("InstructionBsnHashSelect packet too short: %d < 4", decoder.Length()) |
| 627 | } |
| 628 | _instructionbsnhashselect.Flags = BsnHashSelectFlags(decoder.ReadUint32()) |
| 629 | return _instructionbsnhashselect, nil |
| 630 | } |
| 631 | |
| 632 | func NewInstructionBsnHashSelect() *InstructionBsnHashSelect { |
| 633 | obj := &InstructionBsnHashSelect{ |
| 634 | InstructionBsn: NewInstructionBsn(15), |
| 635 | } |
| 636 | return obj |
| 637 | } |
| 638 | |
| 639 | type InstructionBsnInternalPriority struct { |
| 640 | *InstructionBsn |
| 641 | Value uint32 |
| 642 | } |
| 643 | |
| 644 | type IInstructionBsnInternalPriority interface { |
| 645 | IInstructionBsn |
| 646 | GetValue() uint32 |
| 647 | } |
| 648 | |
| 649 | func (self *InstructionBsnInternalPriority) GetValue() uint32 { |
| 650 | return self.Value |
| 651 | } |
| 652 | |
| 653 | func (self *InstructionBsnInternalPriority) SetValue(v uint32) { |
| 654 | self.Value = v |
| 655 | } |
| 656 | |
| 657 | func (self *InstructionBsnInternalPriority) Serialize(encoder *goloxi.Encoder) error { |
| 658 | startIndex := len(encoder.Bytes()) |
| 659 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 660 | return err |
| 661 | } |
| 662 | |
| 663 | encoder.PutUint32(uint32(self.Value)) |
| 664 | length := len(encoder.Bytes()) - startIndex |
| 665 | |
| 666 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 667 | |
| 668 | return nil |
| 669 | } |
| 670 | |
| 671 | func DecodeInstructionBsnInternalPriority(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnInternalPriority, error) { |
| 672 | _instructionbsninternalpriority := &InstructionBsnInternalPriority{InstructionBsn: parent} |
| 673 | if decoder.Length() < 4 { |
| 674 | return nil, fmt.Errorf("InstructionBsnInternalPriority packet too short: %d < 4", decoder.Length()) |
| 675 | } |
| 676 | _instructionbsninternalpriority.Value = uint32(decoder.ReadUint32()) |
| 677 | return _instructionbsninternalpriority, nil |
| 678 | } |
| 679 | |
| 680 | func NewInstructionBsnInternalPriority() *InstructionBsnInternalPriority { |
| 681 | obj := &InstructionBsnInternalPriority{ |
| 682 | InstructionBsn: NewInstructionBsn(12), |
| 683 | } |
| 684 | return obj |
| 685 | } |
| 686 | |
| 687 | type InstructionBsnNdpOffload struct { |
| 688 | *InstructionBsn |
| 689 | } |
| 690 | |
| 691 | type IInstructionBsnNdpOffload interface { |
| 692 | IInstructionBsn |
| 693 | } |
| 694 | |
| 695 | func (self *InstructionBsnNdpOffload) Serialize(encoder *goloxi.Encoder) error { |
| 696 | startIndex := len(encoder.Bytes()) |
| 697 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 698 | return err |
| 699 | } |
| 700 | |
| 701 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 702 | length := len(encoder.Bytes()) - startIndex |
| 703 | |
| 704 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 705 | |
| 706 | return nil |
| 707 | } |
| 708 | |
| 709 | func DecodeInstructionBsnNdpOffload(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnNdpOffload, error) { |
| 710 | _instructionbsnndpoffload := &InstructionBsnNdpOffload{InstructionBsn: parent} |
| 711 | if decoder.Length() < 4 { |
| 712 | return nil, fmt.Errorf("InstructionBsnNdpOffload packet too short: %d < 4", decoder.Length()) |
| 713 | } |
| 714 | decoder.Skip(4) |
| 715 | return _instructionbsnndpoffload, nil |
| 716 | } |
| 717 | |
| 718 | func NewInstructionBsnNdpOffload() *InstructionBsnNdpOffload { |
| 719 | obj := &InstructionBsnNdpOffload{ |
| 720 | InstructionBsn: NewInstructionBsn(14), |
| 721 | } |
| 722 | return obj |
| 723 | } |
| 724 | |
| 725 | type InstructionBsnPacketOfDeath struct { |
| 726 | *InstructionBsn |
| 727 | } |
| 728 | |
| 729 | type IInstructionBsnPacketOfDeath interface { |
| 730 | IInstructionBsn |
| 731 | } |
| 732 | |
| 733 | func (self *InstructionBsnPacketOfDeath) Serialize(encoder *goloxi.Encoder) error { |
| 734 | startIndex := len(encoder.Bytes()) |
| 735 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 736 | return err |
| 737 | } |
| 738 | |
| 739 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 740 | length := len(encoder.Bytes()) - startIndex |
| 741 | |
| 742 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 743 | |
| 744 | return nil |
| 745 | } |
| 746 | |
| 747 | func DecodeInstructionBsnPacketOfDeath(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnPacketOfDeath, error) { |
| 748 | _instructionbsnpacketofdeath := &InstructionBsnPacketOfDeath{InstructionBsn: parent} |
| 749 | if decoder.Length() < 4 { |
| 750 | return nil, fmt.Errorf("InstructionBsnPacketOfDeath packet too short: %d < 4", decoder.Length()) |
| 751 | } |
| 752 | decoder.Skip(4) |
| 753 | return _instructionbsnpacketofdeath, nil |
| 754 | } |
| 755 | |
| 756 | func NewInstructionBsnPacketOfDeath() *InstructionBsnPacketOfDeath { |
| 757 | obj := &InstructionBsnPacketOfDeath{ |
| 758 | InstructionBsn: NewInstructionBsn(6), |
| 759 | } |
| 760 | return obj |
| 761 | } |
| 762 | |
| 763 | type InstructionBsnPermit struct { |
| 764 | *InstructionBsn |
| 765 | } |
| 766 | |
| 767 | type IInstructionBsnPermit interface { |
| 768 | IInstructionBsn |
| 769 | } |
| 770 | |
| 771 | func (self *InstructionBsnPermit) Serialize(encoder *goloxi.Encoder) error { |
| 772 | startIndex := len(encoder.Bytes()) |
| 773 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 774 | return err |
| 775 | } |
| 776 | |
| 777 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 778 | length := len(encoder.Bytes()) - startIndex |
| 779 | |
| 780 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 781 | |
| 782 | return nil |
| 783 | } |
| 784 | |
| 785 | func DecodeInstructionBsnPermit(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnPermit, error) { |
| 786 | _instructionbsnpermit := &InstructionBsnPermit{InstructionBsn: parent} |
| 787 | if decoder.Length() < 4 { |
| 788 | return nil, fmt.Errorf("InstructionBsnPermit packet too short: %d < 4", decoder.Length()) |
| 789 | } |
| 790 | decoder.Skip(4) |
| 791 | return _instructionbsnpermit, nil |
| 792 | } |
| 793 | |
| 794 | func NewInstructionBsnPermit() *InstructionBsnPermit { |
| 795 | obj := &InstructionBsnPermit{ |
| 796 | InstructionBsn: NewInstructionBsn(4), |
| 797 | } |
| 798 | return obj |
| 799 | } |
| 800 | |
| 801 | type InstructionBsnPrioritizePdus struct { |
| 802 | *InstructionBsn |
| 803 | } |
| 804 | |
| 805 | type IInstructionBsnPrioritizePdus interface { |
| 806 | IInstructionBsn |
| 807 | } |
| 808 | |
| 809 | func (self *InstructionBsnPrioritizePdus) Serialize(encoder *goloxi.Encoder) error { |
| 810 | startIndex := len(encoder.Bytes()) |
| 811 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 812 | return err |
| 813 | } |
| 814 | |
| 815 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 816 | length := len(encoder.Bytes()) - startIndex |
| 817 | |
| 818 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 819 | |
| 820 | return nil |
| 821 | } |
| 822 | |
| 823 | func DecodeInstructionBsnPrioritizePdus(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnPrioritizePdus, error) { |
| 824 | _instructionbsnprioritizepdus := &InstructionBsnPrioritizePdus{InstructionBsn: parent} |
| 825 | if decoder.Length() < 4 { |
| 826 | return nil, fmt.Errorf("InstructionBsnPrioritizePdus packet too short: %d < 4", decoder.Length()) |
| 827 | } |
| 828 | decoder.Skip(4) |
| 829 | return _instructionbsnprioritizepdus, nil |
| 830 | } |
| 831 | |
| 832 | func NewInstructionBsnPrioritizePdus() *InstructionBsnPrioritizePdus { |
| 833 | obj := &InstructionBsnPrioritizePdus{ |
| 834 | InstructionBsn: NewInstructionBsn(7), |
| 835 | } |
| 836 | return obj |
| 837 | } |
| 838 | |
| 839 | type InstructionBsnRequireVlanXlate struct { |
| 840 | *InstructionBsn |
| 841 | } |
| 842 | |
| 843 | type IInstructionBsnRequireVlanXlate interface { |
| 844 | IInstructionBsn |
| 845 | } |
| 846 | |
| 847 | func (self *InstructionBsnRequireVlanXlate) Serialize(encoder *goloxi.Encoder) error { |
| 848 | startIndex := len(encoder.Bytes()) |
| 849 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 850 | return err |
| 851 | } |
| 852 | |
| 853 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 854 | length := len(encoder.Bytes()) - startIndex |
| 855 | |
| 856 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 857 | |
| 858 | return nil |
| 859 | } |
| 860 | |
| 861 | func DecodeInstructionBsnRequireVlanXlate(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnRequireVlanXlate, error) { |
| 862 | _instructionbsnrequirevlanxlate := &InstructionBsnRequireVlanXlate{InstructionBsn: parent} |
| 863 | if decoder.Length() < 4 { |
| 864 | return nil, fmt.Errorf("InstructionBsnRequireVlanXlate packet too short: %d < 4", decoder.Length()) |
| 865 | } |
| 866 | decoder.Skip(4) |
| 867 | return _instructionbsnrequirevlanxlate, nil |
| 868 | } |
| 869 | |
| 870 | func NewInstructionBsnRequireVlanXlate() *InstructionBsnRequireVlanXlate { |
| 871 | obj := &InstructionBsnRequireVlanXlate{ |
| 872 | InstructionBsn: NewInstructionBsn(8), |
| 873 | } |
| 874 | return obj |
| 875 | } |
| 876 | |
| 877 | type InstructionBsnSpanDestination struct { |
| 878 | *InstructionBsn |
| 879 | } |
| 880 | |
| 881 | type IInstructionBsnSpanDestination interface { |
| 882 | IInstructionBsn |
| 883 | } |
| 884 | |
| 885 | func (self *InstructionBsnSpanDestination) Serialize(encoder *goloxi.Encoder) error { |
| 886 | startIndex := len(encoder.Bytes()) |
| 887 | if err := self.InstructionBsn.Serialize(encoder); err != nil { |
| 888 | return err |
| 889 | } |
| 890 | |
| 891 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 892 | length := len(encoder.Bytes()) - startIndex |
| 893 | |
| 894 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 895 | |
| 896 | return nil |
| 897 | } |
| 898 | |
| 899 | func DecodeInstructionBsnSpanDestination(parent *InstructionBsn, decoder *goloxi.Decoder) (*InstructionBsnSpanDestination, error) { |
| 900 | _instructionbsnspandestination := &InstructionBsnSpanDestination{InstructionBsn: parent} |
| 901 | if decoder.Length() < 4 { |
| 902 | return nil, fmt.Errorf("InstructionBsnSpanDestination packet too short: %d < 4", decoder.Length()) |
| 903 | } |
| 904 | decoder.Skip(4) |
| 905 | return _instructionbsnspandestination, nil |
| 906 | } |
| 907 | |
| 908 | func NewInstructionBsnSpanDestination() *InstructionBsnSpanDestination { |
| 909 | obj := &InstructionBsnSpanDestination{ |
| 910 | InstructionBsn: NewInstructionBsn(10), |
| 911 | } |
| 912 | return obj |
| 913 | } |
| 914 | |
| 915 | type InstructionClearActions struct { |
| 916 | *Instruction |
| 917 | } |
| 918 | |
| 919 | type IInstructionClearActions interface { |
| 920 | IInstruction |
| 921 | } |
| 922 | |
| 923 | func (self *InstructionClearActions) Serialize(encoder *goloxi.Encoder) error { |
| 924 | startIndex := len(encoder.Bytes()) |
| 925 | if err := self.Instruction.Serialize(encoder); err != nil { |
| 926 | return err |
| 927 | } |
| 928 | |
| 929 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 930 | length := len(encoder.Bytes()) - startIndex |
| 931 | |
| 932 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 933 | |
| 934 | return nil |
| 935 | } |
| 936 | |
| 937 | func DecodeInstructionClearActions(parent *Instruction, decoder *goloxi.Decoder) (*InstructionClearActions, error) { |
| 938 | _instructionclearactions := &InstructionClearActions{Instruction: parent} |
| 939 | if decoder.Length() < 4 { |
| 940 | return nil, fmt.Errorf("InstructionClearActions packet too short: %d < 4", decoder.Length()) |
| 941 | } |
| 942 | decoder.Skip(4) |
| 943 | return _instructionclearactions, nil |
| 944 | } |
| 945 | |
| 946 | func NewInstructionClearActions() *InstructionClearActions { |
| 947 | obj := &InstructionClearActions{ |
| 948 | Instruction: NewInstruction(5), |
| 949 | } |
| 950 | return obj |
| 951 | } |
| 952 | |
| 953 | type InstructionGotoTable struct { |
| 954 | *Instruction |
| 955 | TableId uint8 |
| 956 | } |
| 957 | |
| 958 | type IInstructionGotoTable interface { |
| 959 | IInstruction |
| 960 | GetTableId() uint8 |
| 961 | } |
| 962 | |
| 963 | func (self *InstructionGotoTable) GetTableId() uint8 { |
| 964 | return self.TableId |
| 965 | } |
| 966 | |
| 967 | func (self *InstructionGotoTable) SetTableId(v uint8) { |
| 968 | self.TableId = v |
| 969 | } |
| 970 | |
| 971 | func (self *InstructionGotoTable) Serialize(encoder *goloxi.Encoder) error { |
| 972 | startIndex := len(encoder.Bytes()) |
| 973 | if err := self.Instruction.Serialize(encoder); err != nil { |
| 974 | return err |
| 975 | } |
| 976 | |
| 977 | encoder.PutUint8(uint8(self.TableId)) |
| 978 | encoder.Write(bytes.Repeat([]byte{0}, 3)) |
| 979 | length := len(encoder.Bytes()) - startIndex |
| 980 | |
| 981 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 982 | |
| 983 | return nil |
| 984 | } |
| 985 | |
| 986 | func DecodeInstructionGotoTable(parent *Instruction, decoder *goloxi.Decoder) (*InstructionGotoTable, error) { |
| 987 | _instructiongototable := &InstructionGotoTable{Instruction: parent} |
| 988 | if decoder.Length() < 4 { |
| 989 | return nil, fmt.Errorf("InstructionGotoTable packet too short: %d < 4", decoder.Length()) |
| 990 | } |
| 991 | _instructiongototable.TableId = uint8(decoder.ReadByte()) |
| 992 | decoder.Skip(3) |
| 993 | return _instructiongototable, nil |
| 994 | } |
| 995 | |
| 996 | func NewInstructionGotoTable() *InstructionGotoTable { |
| 997 | obj := &InstructionGotoTable{ |
| 998 | Instruction: NewInstruction(1), |
| 999 | } |
| 1000 | return obj |
| 1001 | } |
| 1002 | |
| 1003 | type InstructionMeter struct { |
| 1004 | *Instruction |
| 1005 | MeterId uint32 |
| 1006 | } |
| 1007 | |
| 1008 | type IInstructionMeter interface { |
| 1009 | IInstruction |
| 1010 | GetMeterId() uint32 |
| 1011 | } |
| 1012 | |
| 1013 | func (self *InstructionMeter) GetMeterId() uint32 { |
| 1014 | return self.MeterId |
| 1015 | } |
| 1016 | |
| 1017 | func (self *InstructionMeter) SetMeterId(v uint32) { |
| 1018 | self.MeterId = v |
| 1019 | } |
| 1020 | |
| 1021 | func (self *InstructionMeter) Serialize(encoder *goloxi.Encoder) error { |
| 1022 | startIndex := len(encoder.Bytes()) |
| 1023 | if err := self.Instruction.Serialize(encoder); err != nil { |
| 1024 | return err |
| 1025 | } |
| 1026 | |
| 1027 | encoder.PutUint32(uint32(self.MeterId)) |
| 1028 | length := len(encoder.Bytes()) - startIndex |
| 1029 | |
| 1030 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 1031 | |
| 1032 | return nil |
| 1033 | } |
| 1034 | |
| 1035 | func DecodeInstructionMeter(parent *Instruction, decoder *goloxi.Decoder) (*InstructionMeter, error) { |
| 1036 | _instructionmeter := &InstructionMeter{Instruction: parent} |
| 1037 | if decoder.Length() < 4 { |
| 1038 | return nil, fmt.Errorf("InstructionMeter packet too short: %d < 4", decoder.Length()) |
| 1039 | } |
| 1040 | _instructionmeter.MeterId = uint32(decoder.ReadUint32()) |
| 1041 | return _instructionmeter, nil |
| 1042 | } |
| 1043 | |
| 1044 | func NewInstructionMeter() *InstructionMeter { |
| 1045 | obj := &InstructionMeter{ |
| 1046 | Instruction: NewInstruction(6), |
| 1047 | } |
| 1048 | return obj |
| 1049 | } |
| 1050 | |
| 1051 | type InstructionWriteActions struct { |
| 1052 | *Instruction |
| 1053 | Actions []goloxi.IAction |
| 1054 | } |
| 1055 | |
| 1056 | type IInstructionWriteActions interface { |
| 1057 | IInstruction |
| 1058 | GetActions() []goloxi.IAction |
| 1059 | } |
| 1060 | |
| 1061 | func (self *InstructionWriteActions) GetActions() []goloxi.IAction { |
| 1062 | return self.Actions |
| 1063 | } |
| 1064 | |
| 1065 | func (self *InstructionWriteActions) SetActions(v []goloxi.IAction) { |
| 1066 | self.Actions = v |
| 1067 | } |
| 1068 | |
| 1069 | func (self *InstructionWriteActions) Serialize(encoder *goloxi.Encoder) error { |
| 1070 | startIndex := len(encoder.Bytes()) |
| 1071 | if err := self.Instruction.Serialize(encoder); err != nil { |
| 1072 | return err |
| 1073 | } |
| 1074 | |
| 1075 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 1076 | for _, obj := range self.Actions { |
| 1077 | if err := obj.Serialize(encoder); err != nil { |
| 1078 | return err |
| 1079 | } |
| 1080 | } |
| 1081 | length := len(encoder.Bytes()) - startIndex |
| 1082 | |
| 1083 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 1084 | |
| 1085 | return nil |
| 1086 | } |
| 1087 | |
| 1088 | func DecodeInstructionWriteActions(parent *Instruction, decoder *goloxi.Decoder) (*InstructionWriteActions, error) { |
| 1089 | _instructionwriteactions := &InstructionWriteActions{Instruction: parent} |
| 1090 | if decoder.Length() < 4 { |
| 1091 | return nil, fmt.Errorf("InstructionWriteActions packet too short: %d < 4", decoder.Length()) |
| 1092 | } |
| 1093 | decoder.Skip(4) |
| 1094 | |
| 1095 | for decoder.Length() >= 8 { |
| 1096 | item, err := DecodeAction(decoder) |
| 1097 | if err != nil { |
| 1098 | return nil, err |
| 1099 | } |
| 1100 | if item != nil { |
| 1101 | _instructionwriteactions.Actions = append(_instructionwriteactions.Actions, item) |
| 1102 | } |
| 1103 | } |
| 1104 | return _instructionwriteactions, nil |
| 1105 | } |
| 1106 | |
| 1107 | func NewInstructionWriteActions() *InstructionWriteActions { |
| 1108 | obj := &InstructionWriteActions{ |
| 1109 | Instruction: NewInstruction(3), |
| 1110 | } |
| 1111 | return obj |
| 1112 | } |
| 1113 | |
| 1114 | type InstructionWriteMetadata struct { |
| 1115 | *Instruction |
| 1116 | Metadata uint64 |
| 1117 | MetadataMask uint64 |
| 1118 | } |
| 1119 | |
| 1120 | type IInstructionWriteMetadata interface { |
| 1121 | IInstruction |
| 1122 | GetMetadata() uint64 |
| 1123 | GetMetadataMask() uint64 |
| 1124 | } |
| 1125 | |
| 1126 | func (self *InstructionWriteMetadata) GetMetadata() uint64 { |
| 1127 | return self.Metadata |
| 1128 | } |
| 1129 | |
| 1130 | func (self *InstructionWriteMetadata) SetMetadata(v uint64) { |
| 1131 | self.Metadata = v |
| 1132 | } |
| 1133 | |
| 1134 | func (self *InstructionWriteMetadata) GetMetadataMask() uint64 { |
| 1135 | return self.MetadataMask |
| 1136 | } |
| 1137 | |
| 1138 | func (self *InstructionWriteMetadata) SetMetadataMask(v uint64) { |
| 1139 | self.MetadataMask = v |
| 1140 | } |
| 1141 | |
| 1142 | func (self *InstructionWriteMetadata) Serialize(encoder *goloxi.Encoder) error { |
| 1143 | startIndex := len(encoder.Bytes()) |
| 1144 | if err := self.Instruction.Serialize(encoder); err != nil { |
| 1145 | return err |
| 1146 | } |
| 1147 | |
| 1148 | encoder.Write(bytes.Repeat([]byte{0}, 4)) |
| 1149 | encoder.PutUint64(uint64(self.Metadata)) |
| 1150 | encoder.PutUint64(uint64(self.MetadataMask)) |
| 1151 | length := len(encoder.Bytes()) - startIndex |
| 1152 | |
| 1153 | binary.BigEndian.PutUint16(encoder.Bytes()[startIndex+2:startIndex+4], uint16(length)) |
| 1154 | |
| 1155 | return nil |
| 1156 | } |
| 1157 | |
| 1158 | func DecodeInstructionWriteMetadata(parent *Instruction, decoder *goloxi.Decoder) (*InstructionWriteMetadata, error) { |
| 1159 | _instructionwritemetadata := &InstructionWriteMetadata{Instruction: parent} |
| 1160 | if decoder.Length() < 20 { |
| 1161 | return nil, fmt.Errorf("InstructionWriteMetadata packet too short: %d < 20", decoder.Length()) |
| 1162 | } |
| 1163 | decoder.Skip(4) |
| 1164 | _instructionwritemetadata.Metadata = uint64(decoder.ReadUint64()) |
| 1165 | _instructionwritemetadata.MetadataMask = uint64(decoder.ReadUint64()) |
| 1166 | return _instructionwritemetadata, nil |
| 1167 | } |
| 1168 | |
| 1169 | func NewInstructionWriteMetadata() *InstructionWriteMetadata { |
| 1170 | obj := &InstructionWriteMetadata{ |
| 1171 | Instruction: NewInstruction(2), |
| 1172 | } |
| 1173 | return obj |
| 1174 | } |