diff options
author | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2018-12-23 23:12:49 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2018-12-23 23:40:37 +0900 |
commit | 8d0a8b0ffa696a3838740fec7accc54ccfb452ab (patch) | |
tree | cc9dd2da324045dba80bb6dc1d1149ed0114c639 /pkg/server/server.go | |
parent | ababf3068c48d665e2d9d7816cbb521c74fc47c5 (diff) |
make the usage of type name in protobuf consistent
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'pkg/server/server.go')
-rw-r--r-- | pkg/server/server.go | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/pkg/server/server.go b/pkg/server/server.go index 9269bbd4..728214f5 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -1584,14 +1584,14 @@ func (s *BgpServer) EnableZebra(ctx context.Context, r *api.EnableZebraRequest) func (s *BgpServer) AddBmp(ctx context.Context, r *api.AddBmpRequest) error { return s.mgmtOperation(func() error { - _, ok := api.AddBmpRequest_MonitoringPolicy_name[int32(r.Type)] + _, ok := api.AddBmpRequest_MonitoringPolicy_name[int32(r.Policy)] if !ok { - return fmt.Errorf("invalid bmp route monitoring policy: %v", r.Type) + return fmt.Errorf("invalid bmp route monitoring policy: %v", r.Policy) } return s.bmpManager.addServer(&config.BmpServerConfig{ Address: r.Address, Port: r.Port, - RouteMonitoringPolicy: config.IntToBmpRouteMonitoringPolicyTypeMap[int(r.Type)], + RouteMonitoringPolicy: config.IntToBmpRouteMonitoringPolicyTypeMap[int(r.Policy)], StatisticsTimeout: uint16(r.StatisticsTimeout), }) }, true) @@ -1845,7 +1845,7 @@ func (s *BgpServer) addPathList(vrfId string, pathList []*table.Path) error { func (s *BgpServer) AddPath(ctx context.Context, r *api.AddPathRequest) (*api.AddPathResponse, error) { var uuidBytes []byte err := s.mgmtOperation(func() error { - path, err := api2Path(r.Resource, r.Path, false) + path, err := api2Path(r.TableType, r.Path, false) if err != nil { return err } @@ -1867,7 +1867,7 @@ func (s *BgpServer) DeletePath(ctx context.Context, r *api.DeletePathRequest) er pathList, err := func() ([]*table.Path, error) { if r.Path != nil { - path, err := api2Path(r.Resource, r.Path, true) + path, err := api2Path(r.TableType, r.Path, true) return []*table.Path{path}, err } return []*table.Path{}, nil @@ -2330,18 +2330,18 @@ func (s *BgpServer) ListPath(ctx context.Context, r *api.ListPathRequest, fn fun family = bgp.AfiSafiToRouteFamily(uint16(r.Family.Afi), uint8(r.Family.Safi)) } var err error - switch r.Type { - case api.Resource_LOCAL, api.Resource_GLOBAL: + switch r.TableType { + case api.TableType_LOCAL, api.TableType_GLOBAL: tbl, v, err = s.getRib(r.Name, family, f()) - case api.Resource_ADJ_IN: + case api.TableType_ADJ_IN: in = true fallthrough - case api.Resource_ADJ_OUT: + case api.TableType_ADJ_OUT: tbl, v, err = s.getAdjRib(r.Name, family, in, f()) - case api.Resource_VRF: + case api.TableType_VRF: tbl, err = s.getVrfRib(r.Name, family, []*table.LookupPrefix{}) default: - return fmt.Errorf("unsupported resource type: %v", r.Type) + return fmt.Errorf("unsupported resource type: %v", r.TableType) } if err != nil { @@ -2359,8 +2359,8 @@ func (s *BgpServer) ListPath(ctx context.Context, r *api.ListPathRequest, fn fun p := toPathApi(path, getValidation(v, idx)) idx++ if i == 0 && !table.SelectionOptions.DisableBestPathSelection { - switch r.Type { - case api.Resource_LOCAL, api.Resource_GLOBAL: + switch r.TableType { + case api.TableType_LOCAL, api.TableType_GLOBAL: p.Best = true } } @@ -2433,16 +2433,16 @@ func (s *BgpServer) GetTable(ctx context.Context, r *api.GetTableRequest) (*api. var in bool var err error var info *table.TableInfo - switch r.Type { - case api.Resource_GLOBAL, api.Resource_LOCAL: + switch r.TableType { + case api.TableType_GLOBAL, api.TableType_LOCAL: info, err = s.getRibInfo(r.Name, family) - case api.Resource_ADJ_IN: + case api.TableType_ADJ_IN: in = true fallthrough - case api.Resource_ADJ_OUT: + case api.TableType_ADJ_OUT: info, err = s.getAdjRibInfo(r.Name, family, in) default: - return nil, fmt.Errorf("unsupported resource type: %s", r.Type) + return nil, fmt.Errorf("unsupported resource type: %s", r.TableType) } if err != nil { @@ -3014,7 +3014,7 @@ func (s *BgpServer) ListDefinedSet(ctx context.Context, r *api.ListDefinedSetReq var cd *config.DefinedSets var err error err = s.mgmtOperation(func() error { - cd, err = s.policy.GetDefinedSet(table.DefinedType(r.Type), r.Name) + cd, err = s.policy.GetDefinedSet(table.DefinedType(r.DefinedType), r.Name) return err }, false) @@ -3033,8 +3033,8 @@ func (s *BgpServer) ListDefinedSet(ctx context.Context, r *api.ListDefinedSetReq for _, cs := range cd.PrefixSets { ad := &api.DefinedSet{ - Type: api.DefinedType_PREFIX, - Name: cs.PrefixSetName, + DefinedType: api.DefinedType_PREFIX, + Name: cs.PrefixSetName, Prefixes: func() []*api.Prefix { l := make([]*api.Prefix, 0, len(cs.PrefixList)) for _, p := range cs.PrefixList { @@ -3053,9 +3053,9 @@ func (s *BgpServer) ListDefinedSet(ctx context.Context, r *api.ListDefinedSetReq } for _, cs := range cd.NeighborSets { ad := &api.DefinedSet{ - Type: api.DefinedType_NEIGHBOR, - Name: cs.NeighborSetName, - List: cs.NeighborInfoList, + DefinedType: api.DefinedType_NEIGHBOR, + Name: cs.NeighborSetName, + List: cs.NeighborInfoList, } if exec(ad) { return nil @@ -3063,9 +3063,9 @@ func (s *BgpServer) ListDefinedSet(ctx context.Context, r *api.ListDefinedSetReq } for _, cs := range cd.BgpDefinedSets.CommunitySets { ad := &api.DefinedSet{ - Type: api.DefinedType_COMMUNITY, - Name: cs.CommunitySetName, - List: cs.CommunityList, + DefinedType: api.DefinedType_COMMUNITY, + Name: cs.CommunitySetName, + List: cs.CommunityList, } if exec(ad) { return nil @@ -3073,9 +3073,9 @@ func (s *BgpServer) ListDefinedSet(ctx context.Context, r *api.ListDefinedSetReq } for _, cs := range cd.BgpDefinedSets.ExtCommunitySets { ad := &api.DefinedSet{ - Type: api.DefinedType_EXT_COMMUNITY, - Name: cs.ExtCommunitySetName, - List: cs.ExtCommunityList, + DefinedType: api.DefinedType_EXT_COMMUNITY, + Name: cs.ExtCommunitySetName, + List: cs.ExtCommunityList, } if exec(ad) { return nil @@ -3083,9 +3083,9 @@ func (s *BgpServer) ListDefinedSet(ctx context.Context, r *api.ListDefinedSetReq } for _, cs := range cd.BgpDefinedSets.LargeCommunitySets { ad := &api.DefinedSet{ - Type: api.DefinedType_LARGE_COMMUNITY, - Name: cs.LargeCommunitySetName, - List: cs.LargeCommunityList, + DefinedType: api.DefinedType_LARGE_COMMUNITY, + Name: cs.LargeCommunitySetName, + List: cs.LargeCommunityList, } if exec(ad) { return nil @@ -3093,9 +3093,9 @@ func (s *BgpServer) ListDefinedSet(ctx context.Context, r *api.ListDefinedSetReq } for _, cs := range cd.BgpDefinedSets.AsPathSets { ad := &api.DefinedSet{ - Type: api.DefinedType_AS_PATH, - Name: cs.AsPathSetName, - List: cs.AsPathList, + DefinedType: api.DefinedType_AS_PATH, + Name: cs.AsPathSetName, + List: cs.AsPathList, } if exec(ad) { return nil @@ -3486,16 +3486,16 @@ func (s *BgpServer) MonitorTable(ctx context.Context, r *api.MonitorTableRequest return fmt.Errorf("nil request") } w, err := func() (*watcher, error) { - switch r.Type { - case api.Resource_GLOBAL: + switch r.TableType { + case api.TableType_GLOBAL: return s.watch(watchBestPath(r.Current)), nil - case api.Resource_ADJ_IN: + case api.TableType_ADJ_IN: if r.PostPolicy { return s.watch(watchPostUpdate(r.Current)), nil } return s.watch(watchUpdate(r.Current)), nil default: - return nil, fmt.Errorf("unsupported resource type: %v", r.Type) + return nil, fmt.Errorf("unsupported resource type: %v", r.TableType) } }() if err != nil { |