From 229d11635e4f7798401b159f08a9599db72696b1 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Sun, 16 Jan 2022 23:45:44 +0000 Subject: [PATCH] clean up FQDNCapability message - we don't need hostlen and domainlen. - use camel case. Signed-off-by: FUJITA Tomonori --- api/capability.pb.go | 75 ++++++++++++++------------------------- api/capability.proto | 8 ++--- pkg/apiutil/capability.go | 12 +++---- 3 files changed, 35 insertions(+), 60 deletions(-) diff --git a/api/capability.pb.go b/api/capability.pb.go index dd0bc7a03..d7476f8a3 100644 --- a/api/capability.pb.go +++ b/api/capability.pb.go @@ -774,19 +774,17 @@ func (*RouteRefreshCiscoCapability) Descriptor() ([]byte, []int) { return file_capability_proto_rawDescGZIP(), []int{13} } -type FQDNCapability struct { +type FqdnCapability struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - HostNameLen uint32 `protobuf:"varint,1,opt,name=host_name_len,json=hostNameLen,proto3" json:"host_name_len,omitempty"` - HostName string `protobuf:"bytes,2,opt,name=host_name,json=hostName,proto3" json:"host_name,omitempty"` - DomainNameLen uint32 `protobuf:"varint,3,opt,name=domain_name_len,json=domainNameLen,proto3" json:"domain_name_len,omitempty"` - DomainName string `protobuf:"bytes,4,opt,name=domain_name,json=domainName,proto3" json:"domain_name,omitempty"` + HostName string `protobuf:"bytes,1,opt,name=host_name,json=hostName,proto3" json:"host_name,omitempty"` + DomainName string `protobuf:"bytes,2,opt,name=domain_name,json=domainName,proto3" json:"domain_name,omitempty"` } -func (x *FQDNCapability) Reset() { - *x = FQDNCapability{} +func (x *FqdnCapability) Reset() { + *x = FqdnCapability{} if protoimpl.UnsafeEnabled { mi := &file_capability_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -794,13 +792,13 @@ func (x *FQDNCapability) Reset() { } } -func (x *FQDNCapability) String() string { +func (x *FqdnCapability) String() string { return protoimpl.X.MessageStringOf(x) } -func (*FQDNCapability) ProtoMessage() {} +func (*FqdnCapability) ProtoMessage() {} -func (x *FQDNCapability) ProtoReflect() protoreflect.Message { +func (x *FqdnCapability) ProtoReflect() protoreflect.Message { mi := &file_capability_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -812,33 +810,19 @@ func (x *FQDNCapability) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use FQDNCapability.ProtoReflect.Descriptor instead. -func (*FQDNCapability) Descriptor() ([]byte, []int) { +// Deprecated: Use FqdnCapability.ProtoReflect.Descriptor instead. +func (*FqdnCapability) Descriptor() ([]byte, []int) { return file_capability_proto_rawDescGZIP(), []int{14} } -func (x *FQDNCapability) GetHostNameLen() uint32 { - if x != nil { - return x.HostNameLen - } - return 0 -} - -func (x *FQDNCapability) GetHostName() string { +func (x *FqdnCapability) GetHostName() string { if x != nil { return x.HostName } return "" } -func (x *FQDNCapability) GetDomainNameLen() uint32 { - if x != nil { - return x.DomainNameLen - } - return 0 -} - -func (x *FQDNCapability) GetDomainName() string { +func (x *FqdnCapability) GetDomainName() string { if x != nil { return x.DomainName } @@ -978,24 +962,19 @@ var file_capability_proto_rawDesc = []byte{ 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x52, 0x06, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x22, 0x1d, 0x0a, 0x1b, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x43, 0x69, 0x73, - 0x63, 0x6f, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x22, 0x9a, 0x01, 0x0a, - 0x0e, 0x46, 0x51, 0x44, 0x4e, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, - 0x22, 0x0a, 0x0d, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x6c, 0x65, 0x6e, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x68, 0x6f, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, - 0x4c, 0x65, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, - 0x12, 0x26, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, - 0x6c, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x64, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x4c, 0x65, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6f, 0x6d, 0x61, - 0x69, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x3d, 0x0a, 0x11, 0x55, 0x6e, 0x6b, - 0x6e, 0x6f, 0x77, 0x6e, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x12, - 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x63, 0x6f, - 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x24, 0x5a, 0x22, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x73, 0x72, 0x67, 0x2f, 0x67, 0x6f, 0x62, 0x67, - 0x70, 0x2f, 0x76, 0x33, 0x2f, 0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x6f, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x22, 0x4e, 0x0a, 0x0e, + 0x46, 0x71, 0x64, 0x6e, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x1b, + 0x0a, 0x09, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x64, + 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0a, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x3d, 0x0a, 0x11, + 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, + 0x79, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x24, 0x5a, 0x22, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x73, 0x72, 0x67, 0x2f, 0x67, + 0x6f, 0x62, 0x67, 0x70, 0x2f, 0x76, 0x33, 0x2f, 0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, 0x70, + 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1028,7 +1007,7 @@ var file_capability_proto_goTypes = []interface{}{ (*LongLivedGracefulRestartCapabilityTuple)(nil), // 12: apipb.LongLivedGracefulRestartCapabilityTuple (*LongLivedGracefulRestartCapability)(nil), // 13: apipb.LongLivedGracefulRestartCapability (*RouteRefreshCiscoCapability)(nil), // 14: apipb.RouteRefreshCiscoCapability - (*FQDNCapability)(nil), // 15: apipb.FQDNCapability + (*FqdnCapability)(nil), // 15: apipb.FqdnCapability (*UnknownCapability)(nil), // 16: apipb.UnknownCapability (*Family)(nil), // 17: apipb.Family } @@ -1227,7 +1206,7 @@ func file_capability_proto_init() { } } file_capability_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FQDNCapability); i { + switch v := v.(*FqdnCapability); i { case 0: return &v.state case 1: diff --git a/api/capability.proto b/api/capability.proto index 621ac2785..cb7f36691 100644 --- a/api/capability.proto +++ b/api/capability.proto @@ -94,11 +94,9 @@ message LongLivedGracefulRestartCapability { message RouteRefreshCiscoCapability { } -message FQDNCapability { - uint32 host_name_len = 1; - string host_name = 2; - uint32 domain_name_len = 3; - string domain_name = 4; +message FqdnCapability { + string host_name = 1; + string domain_name = 2; } message UnknownCapability { diff --git a/pkg/apiutil/capability.go b/pkg/apiutil/capability.go index b2585c916..1334f5c93 100644 --- a/pkg/apiutil/capability.go +++ b/pkg/apiutil/capability.go @@ -109,12 +109,10 @@ func NewRouteRefreshCiscoCapability(a *bgp.CapRouteRefreshCisco) *api.RouteRefre return &api.RouteRefreshCiscoCapability{} } -func NewFQDNCapability(a *bgp.CapFQDN) *api.FQDNCapability { - return &api.FQDNCapability{ - HostNameLen: uint32(a.HostNameLen), - HostName: a.HostName, - DomainNameLen: uint32(a.DomainNameLen), - DomainName: a.DomainName, +func NewFQDNCapability(a *bgp.CapFQDN) *api.FqdnCapability { + return &api.FqdnCapability{ + HostName: a.HostName, + DomainName: a.DomainName, } } @@ -237,7 +235,7 @@ func unmarshalCapability(a *apb.Any) (bgp.ParameterCapabilityInterface, error) { return bgp.NewCapLongLivedGracefulRestart(tuples), nil case *api.RouteRefreshCiscoCapability: return bgp.NewCapRouteRefreshCisco(), nil - case *api.FQDNCapability: + case *api.FqdnCapability: return bgp.NewCapFQDN(a.HostName, a.DomainName), nil case *api.UnknownCapability: return bgp.NewCapUnknown(bgp.BGPCapabilityCode(a.Code), a.Value), nil