From fe95d39c98d164d60d29de173fef0917d97e07b7 Mon Sep 17 00:00:00 2001
From: Daniel Czerwonk <daniel@dan-nrw.de>
Date: Thu, 27 Dec 2018 21:50:27 +0100
Subject: [PATCH] added proto file for bgp sessions

---
 protocols/bgp/server/api/session.pb.go | 268 +++++++++++++++++++++++++
 protocols/bgp/server/api/session.proto |  35 ++++
 2 files changed, 303 insertions(+)
 create mode 100644 protocols/bgp/server/api/session.pb.go
 create mode 100644 protocols/bgp/server/api/session.proto

diff --git a/protocols/bgp/server/api/session.pb.go b/protocols/bgp/server/api/session.pb.go
new file mode 100644
index 00000000..1860314a
--- /dev/null
+++ b/protocols/bgp/server/api/session.pb.go
@@ -0,0 +1,268 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: protocols/bgp/server/api/session.proto
+
+package api // import "protocols/bgp/server/api"
+
+import proto "github.com/golang/protobuf/proto"
+import fmt "fmt"
+import math "math"
+import api "net/api"
+
+// 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 Session_State int32
+
+const (
+	Session_Disabled      Session_State = 0
+	Session_Idle          Session_State = 1
+	Session_Connect       Session_State = 2
+	Session_Active        Session_State = 3
+	Session_OpenSent      Session_State = 4
+	Session_OpenConfirmed Session_State = 5
+	Session_Established   Session_State = 6
+	Session_Ceased        Session_State = 7
+)
+
+var Session_State_name = map[int32]string{
+	0: "Disabled",
+	1: "Idle",
+	2: "Connect",
+	3: "Active",
+	4: "OpenSent",
+	5: "OpenConfirmed",
+	6: "Established",
+	7: "Ceased",
+}
+var Session_State_value = map[string]int32{
+	"Disabled":      0,
+	"Idle":          1,
+	"Connect":       2,
+	"Active":        3,
+	"OpenSent":      4,
+	"OpenConfirmed": 5,
+	"Established":   6,
+	"Ceased":        7,
+}
+
+func (x Session_State) String() string {
+	return proto.EnumName(Session_State_name, int32(x))
+}
+func (Session_State) EnumDescriptor() ([]byte, []int) {
+	return fileDescriptor_session_ac0c55083006f27c, []int{0, 0}
+}
+
+type Session struct {
+	LocalAddress         *api.IP       `protobuf:"bytes,1,opt,name=local_address,json=localAddress,proto3" json:"local_address,omitempty"`
+	NeighborAddress      *api.IP       `protobuf:"bytes,2,opt,name=neighbor_address,json=neighborAddress,proto3" json:"neighbor_address,omitempty"`
+	LocalAsn             uint32        `protobuf:"varint,3,opt,name=local_asn,json=localAsn,proto3" json:"local_asn,omitempty"`
+	PeerAsn              uint32        `protobuf:"varint,4,opt,name=peer_asn,json=peerAsn,proto3" json:"peer_asn,omitempty"`
+	Status               Session_State `protobuf:"varint,5,opt,name=status,proto3,enum=bio.bgp.Session_State" json:"status,omitempty"`
+	Stats                *SessionStats `protobuf:"bytes,6,opt,name=stats,proto3" json:"stats,omitempty"`
+	EstablishedSince     uint64        `protobuf:"varint,7,opt,name=established_since,json=establishedSince,proto3" json:"established_since,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}      `json:"-"`
+	XXX_unrecognized     []byte        `json:"-"`
+	XXX_sizecache        int32         `json:"-"`
+}
+
+func (m *Session) Reset()         { *m = Session{} }
+func (m *Session) String() string { return proto.CompactTextString(m) }
+func (*Session) ProtoMessage()    {}
+func (*Session) Descriptor() ([]byte, []int) {
+	return fileDescriptor_session_ac0c55083006f27c, []int{0}
+}
+func (m *Session) XXX_Unmarshal(b []byte) error {
+	return xxx_messageInfo_Session.Unmarshal(m, b)
+}
+func (m *Session) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+	return xxx_messageInfo_Session.Marshal(b, m, deterministic)
+}
+func (dst *Session) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_Session.Merge(dst, src)
+}
+func (m *Session) XXX_Size() int {
+	return xxx_messageInfo_Session.Size(m)
+}
+func (m *Session) XXX_DiscardUnknown() {
+	xxx_messageInfo_Session.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Session proto.InternalMessageInfo
+
+func (m *Session) GetLocalAddress() *api.IP {
+	if m != nil {
+		return m.LocalAddress
+	}
+	return nil
+}
+
+func (m *Session) GetNeighborAddress() *api.IP {
+	if m != nil {
+		return m.NeighborAddress
+	}
+	return nil
+}
+
+func (m *Session) GetLocalAsn() uint32 {
+	if m != nil {
+		return m.LocalAsn
+	}
+	return 0
+}
+
+func (m *Session) GetPeerAsn() uint32 {
+	if m != nil {
+		return m.PeerAsn
+	}
+	return 0
+}
+
+func (m *Session) GetStatus() Session_State {
+	if m != nil {
+		return m.Status
+	}
+	return Session_Disabled
+}
+
+func (m *Session) GetStats() *SessionStats {
+	if m != nil {
+		return m.Stats
+	}
+	return nil
+}
+
+func (m *Session) GetEstablishedSince() uint64 {
+	if m != nil {
+		return m.EstablishedSince
+	}
+	return 0
+}
+
+type SessionStats struct {
+	PackagesIn           uint64   `protobuf:"varint,6,opt,name=packages_in,json=packagesIn,proto3" json:"packages_in,omitempty"`
+	PackagesOut          uint64   `protobuf:"varint,7,opt,name=packages_out,json=packagesOut,proto3" json:"packages_out,omitempty"`
+	Flaps                uint64   `protobuf:"varint,8,opt,name=flaps,proto3" json:"flaps,omitempty"`
+	RoutesReceived       uint64   `protobuf:"varint,9,opt,name=routes_received,json=routesReceived,proto3" json:"routes_received,omitempty"`
+	RoutesImported       uint64   `protobuf:"varint,10,opt,name=routes_imported,json=routesImported,proto3" json:"routes_imported,omitempty"`
+	RoutesExported       uint64   `protobuf:"varint,11,opt,name=routes_exported,json=routesExported,proto3" json:"routes_exported,omitempty"`
+	XXX_NoUnkeyedLiteral struct{} `json:"-"`
+	XXX_unrecognized     []byte   `json:"-"`
+	XXX_sizecache        int32    `json:"-"`
+}
+
+func (m *SessionStats) Reset()         { *m = SessionStats{} }
+func (m *SessionStats) String() string { return proto.CompactTextString(m) }
+func (*SessionStats) ProtoMessage()    {}
+func (*SessionStats) Descriptor() ([]byte, []int) {
+	return fileDescriptor_session_ac0c55083006f27c, []int{1}
+}
+func (m *SessionStats) XXX_Unmarshal(b []byte) error {
+	return xxx_messageInfo_SessionStats.Unmarshal(m, b)
+}
+func (m *SessionStats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+	return xxx_messageInfo_SessionStats.Marshal(b, m, deterministic)
+}
+func (dst *SessionStats) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_SessionStats.Merge(dst, src)
+}
+func (m *SessionStats) XXX_Size() int {
+	return xxx_messageInfo_SessionStats.Size(m)
+}
+func (m *SessionStats) XXX_DiscardUnknown() {
+	xxx_messageInfo_SessionStats.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_SessionStats proto.InternalMessageInfo
+
+func (m *SessionStats) GetPackagesIn() uint64 {
+	if m != nil {
+		return m.PackagesIn
+	}
+	return 0
+}
+
+func (m *SessionStats) GetPackagesOut() uint64 {
+	if m != nil {
+		return m.PackagesOut
+	}
+	return 0
+}
+
+func (m *SessionStats) GetFlaps() uint64 {
+	if m != nil {
+		return m.Flaps
+	}
+	return 0
+}
+
+func (m *SessionStats) GetRoutesReceived() uint64 {
+	if m != nil {
+		return m.RoutesReceived
+	}
+	return 0
+}
+
+func (m *SessionStats) GetRoutesImported() uint64 {
+	if m != nil {
+		return m.RoutesImported
+	}
+	return 0
+}
+
+func (m *SessionStats) GetRoutesExported() uint64 {
+	if m != nil {
+		return m.RoutesExported
+	}
+	return 0
+}
+
+func init() {
+	proto.RegisterType((*Session)(nil), "bio.bgp.Session")
+	proto.RegisterType((*SessionStats)(nil), "bio.bgp.SessionStats")
+	proto.RegisterEnum("bio.bgp.Session_State", Session_State_name, Session_State_value)
+}
+
+func init() {
+	proto.RegisterFile("protocols/bgp/server/api/session.proto", fileDescriptor_session_ac0c55083006f27c)
+}
+
+var fileDescriptor_session_ac0c55083006f27c = []byte{
+	// 450 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0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 0x45, 0xa7,
+	0xd2, 0xfd, 0xde, 0xf2, 0xe7, 0x30, 0x7c, 0xa8, 0x45, 0x43, 0x69, 0xec, 0x59, 0x3b, 0xf0, 0xf7,
+	0x30, 0x31, 0x7a, 0x6f, 0x91, 0xb6, 0x06, 0x4b, 0x94, 0x07, 0xac, 0xd2, 0x0b, 0xcf, 0x2f, 0xdb,
+	0x38, 0xef, 0xd2, 0x9e, 0x28, 0x9f, 0x1a, 0x6d, 0x2c, 0x56, 0x29, 0xf4, 0xc5, 0x75, 0x97, 0xf6,
+	0x44, 0xfc, 0xd1, 0x89, 0x49, 0x5f, 0xbc, 0xeb, 0xd2, 0xcf, 0x57, 0xdf, 0xd2, 0xff, 0x7d, 0xdb,
+	0x45, 0xe8, 0xc9, 0xc7, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x1e, 0x0e, 0xc1, 0xc1, 0xfe, 0x02,
+	0x00, 0x00,
+}
diff --git a/protocols/bgp/server/api/session.proto b/protocols/bgp/server/api/session.proto
new file mode 100644
index 00000000..511f51e2
--- /dev/null
+++ b/protocols/bgp/server/api/session.proto
@@ -0,0 +1,35 @@
+syntax = "proto3";
+
+package bio.bgp;
+
+import "net/api/net.proto";
+option go_package = "protocols/bgp/server/api";
+
+message Session {
+    bio.net.IP local_address = 1;
+    bio.net.IP neighbor_address = 2;
+    uint32 local_asn = 3;
+    uint32 peer_asn = 4;
+    enum State {
+        Disabled = 0;
+        Idle = 1;
+        Connect = 2;
+        Active = 3;
+        OpenSent = 4;
+        OpenConfirmed = 5;
+        Established = 6;
+        Ceased = 7;
+    }
+    State status = 5;
+    SessionStats stats = 6;
+    uint64 established_since = 7;
+}
+
+message SessionStats {
+    uint64 packages_in = 6;
+    uint64 packages_out = 7;
+    uint64 flaps = 8;
+    uint64 routes_received = 9;
+    uint64 routes_imported = 10;
+    uint64 routes_exported = 11;
+}
\ No newline at end of file
-- 
GitLab