blob: eaf11dce212f968c0bdaea16faf13e8130561228 [file] [log] [blame]
Jonathan Hart44bdbfc2020-04-14 17:45:47 -07001/*
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 */
7package of14
8
9import (
10 "encoding/json"
11 "fmt"
12 "net"
13
14 "github.com/opencord/goloxi"
15)
16
17// TODO: set real types
18type OXM = Oxm
19type uint128 = goloxi.Uint128
20type Checksum128 [16]byte
21type Bitmap128 uint128
22type Bitmap512 struct {
23 a, b, c, d uint128
24}
25type Unimplemented struct{}
26type BSNVport uint16
27type ControllerURI uint16
28
29func (h *Header) MessageType() uint8 {
30 return h.Type
31}
32
33func (h *Header) MessageName() string {
34 return Type(h.Type).String()
35}
36
37func (self *Checksum128) Decode(decoder *goloxi.Decoder) error {
38 return nil
39}
40
41func (self *Checksum128) Serialize(encoder *goloxi.Encoder) error {
42 return nil
43}
44func (self *Bitmap128) Decode(decoder *goloxi.Decoder) error {
45 return nil
46}
47
48func (self *Bitmap128) Serialize(encoder *goloxi.Encoder) error {
49 return nil
50}
51func (self *Bitmap512) Decode(decoder *goloxi.Decoder) error {
52 return nil
53}
54
55func (self *Bitmap512) Serialize(encoder *goloxi.Encoder) error {
56 return nil
57}
58func (self *BSNVport) Decode(decoder *goloxi.Decoder) error {
59 return nil
60}
61
62func (self *BSNVport) Serialize(encoder *goloxi.Encoder) error {
63 return nil
64}
65func (self *ControllerURI) Decode(decoder *goloxi.Decoder) error {
66 return nil
67}
68
69func (self *ControllerURI) Serialize(encoder *goloxi.Encoder) error {
70 return nil
71}
72
73type FmCmd uint8
74
75func (self *FmCmd) Serialize(encoder *goloxi.Encoder) error {
76 encoder.PutUint8(uint8(*self))
77 return nil
78}
79
80func (self *FmCmd) Decode(decoder *goloxi.Decoder) error {
81 *self = FmCmd(decoder.ReadUint8())
82 return nil
83}
84
85type MatchBmap uint64
86
87func (self *MatchBmap) Serialize(encoder *goloxi.Encoder) error {
88 encoder.PutUint64(uint64(*self))
89 return nil
90}
91
92func (self *MatchBmap) Decode(decoder *goloxi.Decoder) error {
93 *self = MatchBmap(decoder.ReadUint64())
94 return nil
95}
96
97type WcBmap uint64
98
99func (self *WcBmap) Serialize(encoder *goloxi.Encoder) error {
100 encoder.PutUint64(uint64(*self))
101 return nil
102}
103
104func (self *WcBmap) Decode(decoder *goloxi.Decoder) error {
105 *self = WcBmap(decoder.ReadUint64())
106 return nil
107}
108
109type Match = MatchV3
110type PortNo uint32
111
112func (self *PortNo) Serialize(encoder *goloxi.Encoder) error {
113 encoder.PutUint32(uint32(*self))
114 return nil
115}
116
117func (self *PortNo) Decode(decoder *goloxi.Decoder) error {
118 *self = PortNo(decoder.ReadUint32())
119 return nil
120}
121
122func DecodeMessage(data []byte) (goloxi.Message, error) {
123 header, err := DecodeHeader(goloxi.NewDecoder(data))
124 if err != nil {
125 return nil, err
126 }
127
128 return header.(goloxi.Message), nil
129}
130
131func (self *Port) Serialize(encoder *goloxi.Encoder) error {
132 portNo := PortNo(*self)
133 return portNo.Serialize(encoder)
134}
135
136func (self *Port) Decode(decoder *goloxi.Decoder) error {
137 portNo := PortNo(*self)
138 if err := portNo.Decode(decoder); err != nil {
139 return err
140 }
141 *self = Port(portNo)
142 return nil
143}
144
145func jsonValue(value interface{}) ([]byte, error) {
146 switch t := value.(type) {
147 case net.HardwareAddr:
148 value = t.String()
149 case net.IP:
150 value = t.String()
151 default:
152 if s, ok := t.(fmt.Stringer); ok {
153 value = s.String()
154 } else {
155 value = t
156 }
157 }
158
159 return json.Marshal(value)
160}