diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-10-16 15:04:32 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-20 10:33:10 +0900 |
commit | 722975bfafdd723160dced623936c361475c9bff (patch) | |
tree | ade5ddb978c797de4864fff814adf2781dac2108 /api | |
parent | 434aa169f457d6bbc4d923641fc57e2c84fe6ef9 (diff) |
policy: another cleanup
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'api')
-rw-r--r-- | api/gobgp.pb.go | 148 | ||||
-rw-r--r-- | api/gobgp.proto | 25 |
2 files changed, 135 insertions, 38 deletions
diff --git a/api/gobgp.pb.go b/api/gobgp.pb.go index d4ec9c0a..577c29ed 100644 --- a/api/gobgp.pb.go +++ b/api/gobgp.pb.go @@ -21,9 +21,10 @@ It has these top-level messages: PeerInfo Peer Prefix + DefinedSet PrefixSet - AsPathLength MatchSet + AsPathLength Conditions CommunityAction MedAction @@ -396,42 +397,51 @@ func (m *Prefix) Reset() { *m = Prefix{} } func (m *Prefix) String() string { return proto.CompactTextString(m) } func (*Prefix) ProtoMessage() {} -type PrefixSet struct { - Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - List []*Prefix `protobuf:"bytes,2,rep,name=list" json:"list,omitempty"` - Option int32 `protobuf:"varint,3,opt,name=option" json:"option,omitempty"` +type DefinedSet struct { + Type int32 `protobuf:"varint,1,opt,name=type" json:"type,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` + List []string `protobuf:"bytes,3,rep,name=list" json:"list,omitempty"` + Prefixes []*Prefix `protobuf:"bytes,4,rep,name=prefixes" json:"prefixes,omitempty"` } -func (m *PrefixSet) Reset() { *m = PrefixSet{} } -func (m *PrefixSet) String() string { return proto.CompactTextString(m) } -func (*PrefixSet) ProtoMessage() {} +func (m *DefinedSet) Reset() { *m = DefinedSet{} } +func (m *DefinedSet) String() string { return proto.CompactTextString(m) } +func (*DefinedSet) ProtoMessage() {} -func (m *PrefixSet) GetList() []*Prefix { +func (m *DefinedSet) GetPrefixes() []*Prefix { if m != nil { - return m.List + return m.Prefixes } return nil } -type AsPathLength struct { - Length uint32 `protobuf:"varint,1,opt,name=length" json:"length,omitempty"` - Type int32 `protobuf:"varint,2,opt,name=type" json:"type,omitempty"` +type PrefixSet struct { + Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Option int32 `protobuf:"varint,2,opt,name=option" json:"option,omitempty"` } -func (m *AsPathLength) Reset() { *m = AsPathLength{} } -func (m *AsPathLength) String() string { return proto.CompactTextString(m) } -func (*AsPathLength) ProtoMessage() {} +func (m *PrefixSet) Reset() { *m = PrefixSet{} } +func (m *PrefixSet) String() string { return proto.CompactTextString(m) } +func (*PrefixSet) ProtoMessage() {} type MatchSet struct { - Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - List []string `protobuf:"bytes,2,rep,name=list" json:"list,omitempty"` - Option int32 `protobuf:"varint,3,opt,name=option" json:"option,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Option int32 `protobuf:"varint,2,opt,name=option" json:"option,omitempty"` } func (m *MatchSet) Reset() { *m = MatchSet{} } func (m *MatchSet) String() string { return proto.CompactTextString(m) } func (*MatchSet) ProtoMessage() {} +type AsPathLength struct { + Length uint32 `protobuf:"varint,1,opt,name=length" json:"length,omitempty"` + Type int32 `protobuf:"varint,2,opt,name=type" json:"type,omitempty"` +} + +func (m *AsPathLength) Reset() { *m = AsPathLength{} } +func (m *AsPathLength) String() string { return proto.CompactTextString(m) } +func (*AsPathLength) ProtoMessage() {} + type Conditions struct { PrefixSet *PrefixSet `protobuf:"bytes,1,opt,name=prefix_set" json:"prefix_set,omitempty"` NeighborSet *MatchSet `protobuf:"bytes,2,opt,name=neighbor_set" json:"neighbor_set,omitempty"` @@ -597,22 +607,15 @@ func (m *PolicyDefinition) GetStatements() []*Statement { } type ApplyPolicy struct { - Type PolicyType `protobuf:"varint,1,opt,name=type,enum=gobgpapi.PolicyType" json:"type,omitempty"` - Policies []*PolicyDefinition `protobuf:"bytes,2,rep,name=policies" json:"policies,omitempty"` - Default RouteAction `protobuf:"varint,3,opt,name=default,enum=gobgpapi.RouteAction" json:"default,omitempty"` + Type PolicyType `protobuf:"varint,1,opt,name=type,enum=gobgpapi.PolicyType" json:"type,omitempty"` + Policies []string `protobuf:"bytes,2,rep,name=policies" json:"policies,omitempty"` + Default RouteAction `protobuf:"varint,3,opt,name=default,enum=gobgpapi.RouteAction" json:"default,omitempty"` } func (m *ApplyPolicy) Reset() { *m = ApplyPolicy{} } func (m *ApplyPolicy) String() string { return proto.CompactTextString(m) } func (*ApplyPolicy) ProtoMessage() {} -func (m *ApplyPolicy) GetPolicies() []*PolicyDefinition { - if m != nil { - return m.Policies - } - return nil -} - type MrtMessage struct { Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` } @@ -723,6 +726,8 @@ type GobgpApiClient interface { GetROA(ctx context.Context, in *Arguments, opts ...grpc.CallOption) (GobgpApi_GetROAClient, error) GetVrfs(ctx context.Context, in *Arguments, opts ...grpc.CallOption) (GobgpApi_GetVrfsClient, error) ModVrf(ctx context.Context, in *ModVrfArguments, opts ...grpc.CallOption) (*Error, error) + GetDefinedSet(ctx context.Context, in *DefinedSet, opts ...grpc.CallOption) (*DefinedSet, error) + GetDefinedSets(ctx context.Context, in *DefinedSet, opts ...grpc.CallOption) (GobgpApi_GetDefinedSetsClient, error) } type gobgpApiClient struct { @@ -1216,6 +1221,47 @@ func (c *gobgpApiClient) ModVrf(ctx context.Context, in *ModVrfArguments, opts . return out, nil } +func (c *gobgpApiClient) GetDefinedSet(ctx context.Context, in *DefinedSet, opts ...grpc.CallOption) (*DefinedSet, error) { + out := new(DefinedSet) + err := grpc.Invoke(ctx, "/gobgpapi.GobgpApi/GetDefinedSet", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gobgpApiClient) GetDefinedSets(ctx context.Context, in *DefinedSet, opts ...grpc.CallOption) (GobgpApi_GetDefinedSetsClient, error) { + stream, err := grpc.NewClientStream(ctx, &_GobgpApi_serviceDesc.Streams[12], c.cc, "/gobgpapi.GobgpApi/GetDefinedSets", opts...) + if err != nil { + return nil, err + } + x := &gobgpApiGetDefinedSetsClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type GobgpApi_GetDefinedSetsClient interface { + Recv() (*DefinedSet, error) + grpc.ClientStream +} + +type gobgpApiGetDefinedSetsClient struct { + grpc.ClientStream +} + +func (x *gobgpApiGetDefinedSetsClient) Recv() (*DefinedSet, error) { + m := new(DefinedSet) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + // Server API for GobgpApi service type GobgpApiServer interface { @@ -1242,6 +1288,8 @@ type GobgpApiServer interface { GetROA(*Arguments, GobgpApi_GetROAServer) error GetVrfs(*Arguments, GobgpApi_GetVrfsServer) error ModVrf(context.Context, *ModVrfArguments) (*Error, error) + GetDefinedSet(context.Context, *DefinedSet) (*DefinedSet, error) + GetDefinedSets(*DefinedSet, GobgpApi_GetDefinedSetsServer) error } func RegisterGobgpApiServer(s *grpc.Server, srv GobgpApiServer) { @@ -1647,6 +1695,39 @@ func _GobgpApi_ModVrf_Handler(srv interface{}, ctx context.Context, dec func(int return out, nil } +func _GobgpApi_GetDefinedSet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error) (interface{}, error) { + in := new(DefinedSet) + if err := dec(in); err != nil { + return nil, err + } + out, err := srv.(GobgpApiServer).GetDefinedSet(ctx, in) + if err != nil { + return nil, err + } + return out, nil +} + +func _GobgpApi_GetDefinedSets_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(DefinedSet) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(GobgpApiServer).GetDefinedSets(m, &gobgpApiGetDefinedSetsServer{stream}) +} + +type GobgpApi_GetDefinedSetsServer interface { + Send(*DefinedSet) error + grpc.ServerStream +} + +type gobgpApiGetDefinedSetsServer struct { + grpc.ServerStream +} + +func (x *gobgpApiGetDefinedSetsServer) Send(m *DefinedSet) error { + return x.ServerStream.SendMsg(m) +} + var _GobgpApi_serviceDesc = grpc.ServiceDesc{ ServiceName: "gobgpapi.GobgpApi", HandlerType: (*GobgpApiServer)(nil), @@ -1695,6 +1776,10 @@ var _GobgpApi_serviceDesc = grpc.ServiceDesc{ MethodName: "ModVrf", Handler: _GobgpApi_ModVrf_Handler, }, + { + MethodName: "GetDefinedSet", + Handler: _GobgpApi_GetDefinedSet_Handler, + }, }, Streams: []grpc.StreamDesc{ { @@ -1759,5 +1844,10 @@ var _GobgpApi_serviceDesc = grpc.ServiceDesc{ Handler: _GobgpApi_GetVrfs_Handler, ServerStreams: true, }, + { + StreamName: "GetDefinedSets", + Handler: _GobgpApi_GetDefinedSets_Handler, + ServerStreams: true, + }, }, } diff --git a/api/gobgp.proto b/api/gobgp.proto index b91ef183..7ef404f4 100644 --- a/api/gobgp.proto +++ b/api/gobgp.proto @@ -43,6 +43,8 @@ service GobgpApi { rpc GetROA(Arguments) returns (stream ROA) {} rpc GetVrfs(Arguments) returns (stream Vrf) {} rpc ModVrf(ModVrfArguments) returns (Error) {} + rpc GetDefinedSet(DefinedSet) returns (DefinedSet) {} + rpc GetDefinedSets(DefinedSet) returns (stream DefinedSet) {} } message Error { @@ -177,10 +179,21 @@ message Prefix { uint32 mask_length_max = 3; } +message DefinedSet { + int32 type = 1; + string name = 2; + repeated string list = 3; + repeated Prefix prefixes = 4; +} + message PrefixSet { string name = 1; - repeated Prefix list = 2; - int32 option = 3; + int32 option = 2; +} + +message MatchSet { + string name = 1; + int32 option = 2; } message AsPathLength { @@ -188,12 +201,6 @@ message AsPathLength { int32 type = 2; } -message MatchSet { - string name = 1; - repeated string list = 2; - int32 option = 3; -} - message Conditions { PrefixSet prefix_set = 1; MatchSet neighbor_set = 2; @@ -253,7 +260,7 @@ enum PolicyType { message ApplyPolicy { PolicyType type = 1; - repeated PolicyDefinition policies = 2; + repeated string policies = 2; RouteAction default = 3; } |