diff options
Diffstat (limited to 'binapi/pppoe')
-rw-r--r-- | binapi/pppoe/pppoe.ba.go | 244 | ||||
-rw-r--r-- | binapi/pppoe/pppoe_rest.ba.go | 37 | ||||
-rw-r--r-- | binapi/pppoe/pppoe_rpc.ba.go | 73 |
3 files changed, 354 insertions, 0 deletions
diff --git a/binapi/pppoe/pppoe.ba.go b/binapi/pppoe/pppoe.ba.go new file mode 100644 index 0000000..0b7cafb --- /dev/null +++ b/binapi/pppoe/pppoe.ba.go @@ -0,0 +1,244 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.4.0-dev +// VPP: 20.05-release +// source: /usr/share/vpp/api/plugins/pppoe.api.json + +// Package pppoe contains generated bindings for API file pppoe.api. +// +// Contents: +// 4 messages +// +package pppoe + +import ( + api "git.fd.io/govpp.git/api" + ethernet_types "git.fd.io/govpp.git/binapi/ethernet_types" + interface_types "git.fd.io/govpp.git/binapi/interface_types" + ip_types "git.fd.io/govpp.git/binapi/ip_types" + codec "git.fd.io/govpp.git/codec" +) + +// 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 + +const ( + APIFile = "pppoe" + APIVersion = "2.0.0" + VersionCrc = 0x24ebf557 +) + +// PppoeAddDelSession defines message 'pppoe_add_del_session'. +type PppoeAddDelSession struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + SessionID uint16 `binapi:"u16,name=session_id" json:"session_id,omitempty"` + ClientIP ip_types.Address `binapi:"address,name=client_ip" json:"client_ip,omitempty"` + DecapVrfID uint32 `binapi:"u32,name=decap_vrf_id" json:"decap_vrf_id,omitempty"` + ClientMac ethernet_types.MacAddress `binapi:"mac_address,name=client_mac" json:"client_mac,omitempty"` +} + +func (m *PppoeAddDelSession) Reset() { *m = PppoeAddDelSession{} } +func (*PppoeAddDelSession) GetMessageName() string { return "pppoe_add_del_session" } +func (*PppoeAddDelSession) GetCrcString() string { return "46ace853" } +func (*PppoeAddDelSession) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PppoeAddDelSession) Size() int { + if m == nil { + return 0 + } + var size int + size += 1 // m.IsAdd + size += 2 // m.SessionID + size += 1 // m.ClientIP.Af + size += 1 * 16 // m.ClientIP.Un + size += 4 // m.DecapVrfID + size += 1 * 6 // m.ClientMac + return size +} +func (m *PppoeAddDelSession) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeBool(m.IsAdd) + buf.EncodeUint16(uint16(m.SessionID)) + buf.EncodeUint8(uint8(m.ClientIP.Af)) + buf.EncodeBytes(m.ClientIP.Un.XXX_UnionData[:], 0) + buf.EncodeUint32(uint32(m.DecapVrfID)) + buf.EncodeBytes(m.ClientMac[:], 6) + return buf.Bytes(), nil +} +func (m *PppoeAddDelSession) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.SessionID = buf.DecodeUint16() + m.ClientIP.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.ClientIP.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.DecapVrfID = buf.DecodeUint32() + copy(m.ClientMac[:], buf.DecodeBytes(6)) + return nil +} + +// PppoeAddDelSessionReply defines message 'pppoe_add_del_session_reply'. +type PppoeAddDelSessionReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *PppoeAddDelSessionReply) Reset() { *m = PppoeAddDelSessionReply{} } +func (*PppoeAddDelSessionReply) GetMessageName() string { return "pppoe_add_del_session_reply" } +func (*PppoeAddDelSessionReply) GetCrcString() string { return "5383d31f" } +func (*PppoeAddDelSessionReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PppoeAddDelSessionReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *PppoeAddDelSessionReply) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeUint32(uint32(m.Retval)) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *PppoeAddDelSessionReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// PppoeSessionDetails defines message 'pppoe_session_details'. +type PppoeSessionDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + SessionID uint16 `binapi:"u16,name=session_id" json:"session_id,omitempty"` + ClientIP ip_types.Address `binapi:"address,name=client_ip" json:"client_ip,omitempty"` + EncapIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=encap_if_index" json:"encap_if_index,omitempty"` + DecapVrfID uint32 `binapi:"u32,name=decap_vrf_id" json:"decap_vrf_id,omitempty"` + LocalMac ethernet_types.MacAddress `binapi:"mac_address,name=local_mac" json:"local_mac,omitempty"` + ClientMac ethernet_types.MacAddress `binapi:"mac_address,name=client_mac" json:"client_mac,omitempty"` +} + +func (m *PppoeSessionDetails) Reset() { *m = PppoeSessionDetails{} } +func (*PppoeSessionDetails) GetMessageName() string { return "pppoe_session_details" } +func (*PppoeSessionDetails) GetCrcString() string { return "332bc742" } +func (*PppoeSessionDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PppoeSessionDetails) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.SwIfIndex + size += 2 // m.SessionID + size += 1 // m.ClientIP.Af + size += 1 * 16 // m.ClientIP.Un + size += 4 // m.EncapIfIndex + size += 4 // m.DecapVrfID + size += 1 * 6 // m.LocalMac + size += 1 * 6 // m.ClientMac + return size +} +func (m *PppoeSessionDetails) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint16(uint16(m.SessionID)) + buf.EncodeUint8(uint8(m.ClientIP.Af)) + buf.EncodeBytes(m.ClientIP.Un.XXX_UnionData[:], 0) + buf.EncodeUint32(uint32(m.EncapIfIndex)) + buf.EncodeUint32(uint32(m.DecapVrfID)) + buf.EncodeBytes(m.LocalMac[:], 6) + buf.EncodeBytes(m.ClientMac[:], 6) + return buf.Bytes(), nil +} +func (m *PppoeSessionDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.SessionID = buf.DecodeUint16() + m.ClientIP.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.ClientIP.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.EncapIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.DecapVrfID = buf.DecodeUint32() + copy(m.LocalMac[:], buf.DecodeBytes(6)) + copy(m.ClientMac[:], buf.DecodeBytes(6)) + return nil +} + +// PppoeSessionDump defines message 'pppoe_session_dump'. +type PppoeSessionDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *PppoeSessionDump) Reset() { *m = PppoeSessionDump{} } +func (*PppoeSessionDump) GetMessageName() string { return "pppoe_session_dump" } +func (*PppoeSessionDump) GetCrcString() string { return "f9e6675e" } +func (*PppoeSessionDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PppoeSessionDump) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.SwIfIndex + return size +} +func (m *PppoeSessionDump) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *PppoeSessionDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +func init() { file_pppoe_binapi_init() } +func file_pppoe_binapi_init() { + api.RegisterMessage((*PppoeAddDelSession)(nil), "pppoe_add_del_session_46ace853") + api.RegisterMessage((*PppoeAddDelSessionReply)(nil), "pppoe_add_del_session_reply_5383d31f") + api.RegisterMessage((*PppoeSessionDetails)(nil), "pppoe_session_details_332bc742") + api.RegisterMessage((*PppoeSessionDump)(nil), "pppoe_session_dump_f9e6675e") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*PppoeAddDelSession)(nil), + (*PppoeAddDelSessionReply)(nil), + (*PppoeSessionDetails)(nil), + (*PppoeSessionDump)(nil), + } +} diff --git a/binapi/pppoe/pppoe_rest.ba.go b/binapi/pppoe/pppoe_rest.ba.go new file mode 100644 index 0000000..6b01227 --- /dev/null +++ b/binapi/pppoe/pppoe_rest.ba.go @@ -0,0 +1,37 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package pppoe + +import ( + "encoding/json" + "io/ioutil" + "net/http" +) + +func RESTHandler(rpc RPCService) http.Handler { + mux := http.NewServeMux() + mux.HandleFunc("/pppoe_add_del_session", func(w http.ResponseWriter, req *http.Request) { + var request = new(PppoeAddDelSession) + b, err := ioutil.ReadAll(req.Body) + if err != nil { + http.Error(w, "read body failed", http.StatusBadRequest) + return + } + if err := json.Unmarshal(b, request); err != nil { + http.Error(w, "unmarshal data failed", http.StatusBadRequest) + return + } + reply, err := rpc.PppoeAddDelSession(req.Context(), request) + if err != nil { + http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) + return + } + rep, err := json.MarshalIndent(reply, "", " ") + if err != nil { + http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) + return + } + w.Write(rep) + }) + return http.HandlerFunc(mux.ServeHTTP) +} diff --git a/binapi/pppoe/pppoe_rpc.ba.go b/binapi/pppoe/pppoe_rpc.ba.go new file mode 100644 index 0000000..384d5a8 --- /dev/null +++ b/binapi/pppoe/pppoe_rpc.ba.go @@ -0,0 +1,73 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package pppoe + +import ( + "context" + "fmt" + api "git.fd.io/govpp.git/api" + vpe "git.fd.io/govpp.git/binapi/vpe" + "io" +) + +// RPCService defines RPC service pppoe. +type RPCService interface { + PppoeAddDelSession(ctx context.Context, in *PppoeAddDelSession) (*PppoeAddDelSessionReply, error) + PppoeSessionDump(ctx context.Context, in *PppoeSessionDump) (RPCService_PppoeSessionDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) PppoeAddDelSession(ctx context.Context, in *PppoeAddDelSession) (*PppoeAddDelSessionReply, error) { + out := new(PppoeAddDelSessionReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) PppoeSessionDump(ctx context.Context, in *PppoeSessionDump) (RPCService_PppoeSessionDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_PppoeSessionDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&vpe.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_PppoeSessionDumpClient interface { + Recv() (*PppoeSessionDetails, error) + api.Stream +} + +type serviceClient_PppoeSessionDumpClient struct { + api.Stream +} + +func (c *serviceClient_PppoeSessionDumpClient) Recv() (*PppoeSessionDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *PppoeSessionDetails: + return m, nil + case *vpe.ControlPingReply: + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} |