From 9d7cac6faaa16dfd72fbbb8984208235d959f751 Mon Sep 17 00:00:00 2001
From: Daniel Czerwonk <daniel@dan-nrw.de>
Date: Thu, 27 Dec 2018 22:34:48 +0100
Subject: [PATCH] added simple bgp service to get session information

---
 protocols/bgp/api/bgp.pb.go                  | 121 +++++++++++++++++++
 protocols/bgp/api/bgp.proto                  |  18 +++
 protocols/bgp/{server => }/api/session.pb.go |   0
 protocols/bgp/{server => }/api/session.proto |   2 +-
 4 files changed, 140 insertions(+), 1 deletion(-)
 create mode 100644 protocols/bgp/api/bgp.pb.go
 create mode 100644 protocols/bgp/api/bgp.proto
 rename protocols/bgp/{server => }/api/session.pb.go (100%)
 rename protocols/bgp/{server => }/api/session.proto (93%)

diff --git a/protocols/bgp/api/bgp.pb.go b/protocols/bgp/api/bgp.pb.go
new file mode 100644
index 00000000..96547a24
--- /dev/null
+++ b/protocols/bgp/api/bgp.pb.go
@@ -0,0 +1,121 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: protocols/bgp/server/api/bgp.proto
+
+package api // import "protocols/bgp/server/api"
+
+import proto "github.com/golang/protobuf/proto"
+import fmt "fmt"
+import math "math"
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
+
+type ListSessionsRequest struct {
+	NameFilter           string   `protobuf:"bytes,1,opt,name=name_filter,json=nameFilter,proto3" json:"name_filter,omitempty"`
+	XXX_NoUnkeyedLiteral struct{} `json:"-"`
+	XXX_unrecognized     []byte   `json:"-"`
+	XXX_sizecache        int32    `json:"-"`
+}
+
+func (m *ListSessionsRequest) Reset()         { *m = ListSessionsRequest{} }
+func (m *ListSessionsRequest) String() string { return proto.CompactTextString(m) }
+func (*ListSessionsRequest) ProtoMessage()    {}
+func (*ListSessionsRequest) Descriptor() ([]byte, []int) {
+	return fileDescriptor_bgp_d327b15a3107b32f, []int{0}
+}
+func (m *ListSessionsRequest) XXX_Unmarshal(b []byte) error {
+	return xxx_messageInfo_ListSessionsRequest.Unmarshal(m, b)
+}
+func (m *ListSessionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+	return xxx_messageInfo_ListSessionsRequest.Marshal(b, m, deterministic)
+}
+func (dst *ListSessionsRequest) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_ListSessionsRequest.Merge(dst, src)
+}
+func (m *ListSessionsRequest) XXX_Size() int {
+	return xxx_messageInfo_ListSessionsRequest.Size(m)
+}
+func (m *ListSessionsRequest) XXX_DiscardUnknown() {
+	xxx_messageInfo_ListSessionsRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ListSessionsRequest proto.InternalMessageInfo
+
+func (m *ListSessionsRequest) GetNameFilter() string {
+	if m != nil {
+		return m.NameFilter
+	}
+	return ""
+}
+
+type ListSessionsResponse struct {
+	Sessions             []*Session `protobuf:"bytes,1,rep,name=sessions,proto3" json:"sessions,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}   `json:"-"`
+	XXX_unrecognized     []byte     `json:"-"`
+	XXX_sizecache        int32      `json:"-"`
+}
+
+func (m *ListSessionsResponse) Reset()         { *m = ListSessionsResponse{} }
+func (m *ListSessionsResponse) String() string { return proto.CompactTextString(m) }
+func (*ListSessionsResponse) ProtoMessage()    {}
+func (*ListSessionsResponse) Descriptor() ([]byte, []int) {
+	return fileDescriptor_bgp_d327b15a3107b32f, []int{1}
+}
+func (m *ListSessionsResponse) XXX_Unmarshal(b []byte) error {
+	return xxx_messageInfo_ListSessionsResponse.Unmarshal(m, b)
+}
+func (m *ListSessionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+	return xxx_messageInfo_ListSessionsResponse.Marshal(b, m, deterministic)
+}
+func (dst *ListSessionsResponse) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_ListSessionsResponse.Merge(dst, src)
+}
+func (m *ListSessionsResponse) XXX_Size() int {
+	return xxx_messageInfo_ListSessionsResponse.Size(m)
+}
+func (m *ListSessionsResponse) XXX_DiscardUnknown() {
+	xxx_messageInfo_ListSessionsResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ListSessionsResponse proto.InternalMessageInfo
+
+func (m *ListSessionsResponse) GetSessions() []*Session {
+	if m != nil {
+		return m.Sessions
+	}
+	return nil
+}
+
+func init() {
+	proto.RegisterType((*ListSessionsRequest)(nil), "bio.bgp.ListSessionsRequest")
+	proto.RegisterType((*ListSessionsResponse)(nil), "bio.bgp.ListSessionsResponse")
+}
+
+func init() {
+	proto.RegisterFile("protocols/bgp/server/api/bgp.proto", fileDescriptor_bgp_d327b15a3107b32f)
+}
+
+var fileDescriptor_bgp_d327b15a3107b32f = []byte{
+	// 207 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2a, 0x28, 0xca, 0x2f,
+	0xc9, 0x4f, 0xce, 0xcf, 0x29, 0xd6, 0x4f, 0x4a, 0x2f, 0xd0, 0x2f, 0x4e, 0x2d, 0x2a, 0x4b, 0x2d,
+	0xd2, 0x4f, 0x2c, 0xc8, 0x04, 0x71, 0xf5, 0xc0, 0x92, 0x42, 0xec, 0x49, 0x99, 0xf9, 0x7a, 0x49,
+	0xe9, 0x05, 0x52, 0x6a, 0x38, 0x15, 0x17, 0xa7, 0x16, 0x17, 0x67, 0xe6, 0xe7, 0x41, 0x34, 0x28,
+	0x99, 0x71, 0x09, 0xfb, 0x64, 0x16, 0x97, 0x04, 0x43, 0x04, 0x8b, 0x83, 0x52, 0x0b, 0x4b, 0x53,
+	0x8b, 0x4b, 0x84, 0xe4, 0xb9, 0xb8, 0xf3, 0x12, 0x73, 0x53, 0xe3, 0xd3, 0x32, 0x73, 0x4a, 0x52,
+	0x8b, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xb8, 0x40, 0x42, 0x6e, 0x60, 0x11, 0x25, 0x17,
+	0x2e, 0x11, 0x54, 0x7d, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x42, 0x3a, 0x5c, 0x1c, 0x50, 0x0b,
+	0x8a, 0x25, 0x18, 0x15, 0x98, 0x35, 0xb8, 0x8d, 0x04, 0xf4, 0xa0, 0x6e, 0xd2, 0x83, 0x2a, 0x0e,
+	0x82, 0xab, 0x30, 0x8a, 0xe6, 0xe2, 0x72, 0x4a, 0x2f, 0x08, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e,
+	0x15, 0xf2, 0xe5, 0xe2, 0x41, 0x36, 0x53, 0x48, 0x06, 0xae, 0x13, 0x8b, 0x13, 0xa5, 0x64, 0x71,
+	0xc8, 0x42, 0x1c, 0xa2, 0xc4, 0xe0, 0x24, 0x15, 0x25, 0x81, 0x2b, 0x10, 0x92, 0xd8, 0xc0, 0x32,
+	0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x66, 0x7d, 0xcb, 0xda, 0x54, 0x01, 0x00, 0x00,
+}
diff --git a/protocols/bgp/api/bgp.proto b/protocols/bgp/api/bgp.proto
new file mode 100644
index 00000000..bb439c63
--- /dev/null
+++ b/protocols/bgp/api/bgp.proto
@@ -0,0 +1,18 @@
+syntax = "proto3";
+
+package bio.bgp;
+
+import "protocols/bgp/api/session.proto";
+option go_package = "protocols/bgp/api";
+
+message ListSessionsRequest {
+    string name_filter = 1;
+}
+
+message ListSessionsResponse {
+    repeated Session sessions = 1;
+}
+
+service BgpService {
+    rpc ListSessions(ListSessionsRequest) returns (ListSessionsResponse) {}
+}
\ No newline at end of file
diff --git a/protocols/bgp/server/api/session.pb.go b/protocols/bgp/api/session.pb.go
similarity index 100%
rename from protocols/bgp/server/api/session.pb.go
rename to protocols/bgp/api/session.pb.go
diff --git a/protocols/bgp/server/api/session.proto b/protocols/bgp/api/session.proto
similarity index 93%
rename from protocols/bgp/server/api/session.proto
rename to protocols/bgp/api/session.proto
index 511f51e2..017b7c56 100644
--- a/protocols/bgp/server/api/session.proto
+++ b/protocols/bgp/api/session.proto
@@ -3,7 +3,7 @@ syntax = "proto3";
 package bio.bgp;
 
 import "net/api/net.proto";
-option go_package = "protocols/bgp/server/api";
+option go_package = "protocols/bgp/api";
 
 message Session {
     bio.net.IP local_address = 1;
-- 
GitLab