From 2cb804fe352a955c69d738b170c74ac670ab9e3f Mon Sep 17 00:00:00 2001
From: Daniel Czerwonk <daniel@dan-nrw.de>
Date: Fri, 28 Dec 2018 19:04:02 +0100
Subject: [PATCH] added filter to make it more clear if a filter should be
 applied to the list

---
 protocols/bgp/api/bgp.pb.go | 94 +++++++++++++++++++++++++++----------
 protocols/bgp/api/bgp.proto |  4 ++
 2 files changed, 72 insertions(+), 26 deletions(-)

diff --git a/protocols/bgp/api/bgp.pb.go b/protocols/bgp/api/bgp.pb.go
index a77d280b..0a663c6a 100644
--- a/protocols/bgp/api/bgp.pb.go
+++ b/protocols/bgp/api/bgp.pb.go
@@ -24,11 +24,10 @@ var _ = math.Inf
 const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
 
 type ListSessionsRequest struct {
-	NeighborIp           *api.IP  `protobuf:"bytes,1,opt,name=neighbor_ip,json=neighborIp,proto3" json:"neighbor_ip,omitempty"`
-	VrfName              string   `protobuf:"bytes,2,opt,name=vrf_name,json=vrfName,proto3" json:"vrf_name,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	Filter               *SessionFilter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}       `json:"-"`
+	XXX_unrecognized     []byte         `json:"-"`
+	XXX_sizecache        int32          `json:"-"`
 }
 
 func (m *ListSessionsRequest) Reset()         { *m = ListSessionsRequest{} }
@@ -56,14 +55,54 @@ func (m *ListSessionsRequest) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_ListSessionsRequest proto.InternalMessageInfo
 
-func (m *ListSessionsRequest) GetNeighborIp() *api.IP {
+func (m *ListSessionsRequest) GetFilter() *SessionFilter {
+	if m != nil {
+		return m.Filter
+	}
+	return nil
+}
+
+type SessionFilter struct {
+	NeighborIp           *api.IP  `protobuf:"bytes,1,opt,name=neighbor_ip,json=neighborIp,proto3" json:"neighbor_ip,omitempty"`
+	VrfName              string   `protobuf:"bytes,2,opt,name=vrf_name,json=vrfName,proto3" json:"vrf_name,omitempty"`
+	XXX_NoUnkeyedLiteral struct{} `json:"-"`
+	XXX_unrecognized     []byte   `json:"-"`
+	XXX_sizecache        int32    `json:"-"`
+}
+
+func (m *SessionFilter) Reset()         { *m = SessionFilter{} }
+func (m *SessionFilter) String() string { return proto.CompactTextString(m) }
+func (*SessionFilter) ProtoMessage()    {}
+func (*SessionFilter) Descriptor() ([]byte, []int) {
+	return fileDescriptor_2d4ce551e16bb738, []int{1}
+}
+
+func (m *SessionFilter) XXX_Unmarshal(b []byte) error {
+	return xxx_messageInfo_SessionFilter.Unmarshal(m, b)
+}
+func (m *SessionFilter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+	return xxx_messageInfo_SessionFilter.Marshal(b, m, deterministic)
+}
+func (m *SessionFilter) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_SessionFilter.Merge(m, src)
+}
+func (m *SessionFilter) XXX_Size() int {
+	return xxx_messageInfo_SessionFilter.Size(m)
+}
+func (m *SessionFilter) XXX_DiscardUnknown() {
+	xxx_messageInfo_SessionFilter.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_SessionFilter proto.InternalMessageInfo
+
+func (m *SessionFilter) GetNeighborIp() *api.IP {
 	if m != nil {
 		return m.NeighborIp
 	}
 	return nil
 }
 
-func (m *ListSessionsRequest) GetVrfName() string {
+func (m *SessionFilter) GetVrfName() string {
 	if m != nil {
 		return m.VrfName
 	}
@@ -81,7 +120,7 @@ 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_2d4ce551e16bb738, []int{1}
+	return fileDescriptor_2d4ce551e16bb738, []int{2}
 }
 
 func (m *ListSessionsResponse) XXX_Unmarshal(b []byte) error {
@@ -111,6 +150,7 @@ func (m *ListSessionsResponse) GetSessions() []*Session {
 
 func init() {
 	proto.RegisterType((*ListSessionsRequest)(nil), "bio.bgp.ListSessionsRequest")
+	proto.RegisterType((*SessionFilter)(nil), "bio.bgp.SessionFilter")
 	proto.RegisterType((*ListSessionsResponse)(nil), "bio.bgp.ListSessionsResponse")
 }
 
@@ -119,24 +159,26 @@ func init() {
 }
 
 var fileDescriptor_2d4ce551e16bb738 = []byte{
-	// 271 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x90, 0xcf, 0x4b, 0xfc, 0x30,
-	0x10, 0xc5, 0xbf, 0xfd, 0x0a, 0xee, 0x9a, 0x7a, 0x90, 0xe8, 0xa1, 0x16, 0x85, 0xd2, 0x53, 0x0f,
-	0x6b, 0x82, 0xf5, 0xe4, 0xc1, 0xcb, 0xe2, 0x65, 0x41, 0x45, 0xba, 0x37, 0x05, 0x97, 0xa6, 0xce,
-	0x66, 0x03, 0x36, 0x89, 0x99, 0xb4, 0x7f, 0xbf, 0xf4, 0x87, 0x8b, 0x82, 0x0a, 0x7b, 0x4a, 0x78,
-	0x33, 0x9f, 0x37, 0x6f, 0x86, 0x5c, 0x4b, 0xe5, 0x37, 0x8d, 0x60, 0x95, 0xa9, 0xb9, 0x50, 0xe6,
-	0xc2, 0x99, 0xc6, 0x2b, 0x2d, 0x87, 0xff, 0x2b, 0xb7, 0xce, 0x78, 0x53, 0x99, 0x37, 0xe4, 0x42,
-	0x5a, 0x5e, 0x5a, 0xd5, 0xbd, 0xac, 0x57, 0xe9, 0x44, 0x28, 0xc3, 0x84, 0xb4, 0x31, 0xff, 0xdb,
-	0x43, 0x83, 0xef, 0x49, 0x0d, 0x7e, 0x20, 0xe3, 0x9b, 0x5d, 0x87, 0x22, 0x20, 0x2a, 0xa3, 0x07,
-	0x3c, 0x7d, 0x21, 0xc7, 0x77, 0x0a, 0xfd, 0x72, 0x10, 0xb1, 0x80, 0xf7, 0x06, 0xd0, 0xd3, 0x19,
-	0x09, 0x35, 0x28, 0xb9, 0x11, 0xc6, 0xad, 0x94, 0x8d, 0x82, 0x24, 0xc8, 0xc2, 0x3c, 0x64, 0x5d,
-	0xca, 0x6e, 0xf4, 0xe2, 0xb1, 0x20, 0x9f, 0xf5, 0x85, 0xa5, 0xa7, 0x64, 0xda, 0xba, 0xf5, 0x4a,
-	0x97, 0x35, 0x44, 0xff, 0x93, 0x20, 0x3b, 0x28, 0x26, 0xad, 0x5b, 0x3f, 0x94, 0x35, 0xa4, 0xb7,
-	0xe4, 0xe4, 0xbb, 0x3f, 0x5a, 0xa3, 0x11, 0xe8, 0x8c, 0x4c, 0xc7, 0x20, 0x18, 0x05, 0xc9, 0x5e,
-	0x16, 0xe6, 0x47, 0x6c, 0xbc, 0x01, 0x1b, 0x9b, 0x8b, 0x6d, 0x47, 0xfe, 0x4c, 0xc8, 0x5c, 0xda,
-	0x25, 0xb8, 0x56, 0x55, 0x40, 0xef, 0xc9, 0xe1, 0x57, 0x4f, 0x7a, 0xb6, 0x25, 0x7f, 0x58, 0x25,
-	0x3e, 0xff, 0xa5, 0x3a, 0x04, 0x49, 0xff, 0xcd, 0x2f, 0x9f, 0xf8, 0x8e, 0x37, 0x14, 0xfb, 0xbd,
-	0x74, 0xf5, 0x11, 0x00, 0x00, 0xff, 0xff, 0x70, 0x64, 0xa0, 0xba, 0xf2, 0x01, 0x00, 0x00,
+	// 293 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0xcf, 0x4b, 0xf3, 0x30,
+	0x18, 0xc7, 0xdf, 0xbe, 0xc2, 0x36, 0x9f, 0x2a, 0x48, 0x14, 0x99, 0x43, 0x61, 0xf4, 0xb4, 0xc3,
+	0x4c, 0xb0, 0x9e, 0x3c, 0x78, 0x19, 0x2a, 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x40, 0x67, 0xb4, 0x72, 0x48,
+	0xc6, 0xd0, 0x6b, 0x6f, 0xe2, 0xfa, 0xc1, 0x70, 0x67, 0x14, 0xc6, 0x07, 0xdf, 0x19, 0x93, 0xb5,
+	0x23, 0x7e, 0x05, 0x98, 0x08, 0x33, 0x43, 0x5b, 0xc9, 0x0c, 0xc9, 0x03, 0xec, 0x7d, 0xed, 0x24,
+	0xa7, 0xeb, 0xe4, 0x0f, 0x6f, 0x31, 0x38, 0xfb, 0x45, 0x6d, 0x40, 0xa2, 0x7f, 0x93, 0x8b, 0x17,
+	0xb6, 0xe5, 0x27, 0xf0, 0x4e, 0x3d, 0xba, 0xfc, 0x08, 0x00, 0x00, 0xff, 0xff, 0x93, 0x79, 0xb9,
+	0xa9, 0x33, 0x02, 0x00, 0x00,
 }
 
 // Reference imports to suppress errors if they are not otherwise used.
diff --git a/protocols/bgp/api/bgp.proto b/protocols/bgp/api/bgp.proto
index 76ae6f95..cbe7def9 100644
--- a/protocols/bgp/api/bgp.proto
+++ b/protocols/bgp/api/bgp.proto
@@ -7,6 +7,10 @@ import "github.com/bio-routing/bio-rd/protocols/bgp/api/session.proto";
 option go_package = "github.com/bio-routing/bio-rd/protocols/bgp/api";
 
 message ListSessionsRequest {
+    SessionFilter filter = 1;
+}
+
+message SessionFilter {
     bio.net.IP neighbor_ip = 1;
     string vrf_name = 2;
 }
-- 
GitLab