summaryrefslogtreecommitdiffhomepage
path: root/server/grpc_server.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-07-26 12:04:04 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-07-26 12:04:04 +0900
commite0e421bbca8f620fc40c98de7d8ae386a8f8a6ad (patch)
tree6aca5e2e5cea4c7c60bc5ed451f90544f83e2ec8 /server/grpc_server.go
parentf623f8d538cd0ce9b31a97248ac862bb1c8b8b7c (diff)
move gRPC-related code for REQ_START_SERVER to grpc_server.go
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/grpc_server.go')
-rw-r--r--server/grpc_server.go37
1 files changed, 34 insertions, 3 deletions
diff --git a/server/grpc_server.go b/server/grpc_server.go
index 8ad5c3c8..c6486eac 100644
--- a/server/grpc_server.go
+++ b/server/grpc_server.go
@@ -1732,11 +1732,42 @@ func (s *Server) GetServer(ctx context.Context, arg *api.GetServerRequest) (*api
}
func (s *Server) StartServer(ctx context.Context, arg *api.StartServerRequest) (*api.StartServerResponse, error) {
- d, err := s.get(REQ_START_SERVER, arg)
- if err != nil {
+ g := arg.Global
+ if net.ParseIP(g.RouterId) == nil {
+ return nil, fmt.Errorf("invalid router-id format: %s", g.RouterId)
+ }
+ families := make([]config.AfiSafi, 0, len(g.Families))
+ for _, f := range g.Families {
+ name := config.AfiSafiType(bgp.RouteFamily(f).String())
+ families = append(families, config.AfiSafi{
+ Config: config.AfiSafiConfig{
+ AfiSafiName: name,
+ Enabled: true,
+ },
+ State: config.AfiSafiState{
+ AfiSafiName: name,
+ },
+ })
+ }
+ b := &config.BgpConfigSet{
+ Global: config.Global{
+ Config: config.GlobalConfig{
+ As: g.As,
+ RouterId: g.RouterId,
+ Port: g.ListenPort,
+ LocalAddressList: g.ListenAddresses,
+ },
+ MplsLabelRange: config.MplsLabelRange{
+ MinLabel: g.MplsLabelMin,
+ MaxLabel: g.MplsLabelMax,
+ },
+ AfiSafis: families,
+ },
+ }
+ if err := config.SetDefaultConfigValues(nil, b); err != nil {
return nil, err
}
- return d.(*api.StartServerResponse), err
+ return &api.StartServerResponse{}, s.bgpServer.Start(&b.Global)
}
func (s *Server) StopServer(ctx context.Context, arg *api.StopServerRequest) (*api.StopServerResponse, error) {