diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-07-11 10:12:26 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-07-20 04:25:25 +0900 |
commit | e090609b146fdde93714e966aa8ec300b5842ba3 (patch) | |
tree | d198865abf0c5600b28a7648ca1aa233fa0953d2 /table/vrf.go | |
parent | c31164d90d1728e8c565cb8348adad0316cc60db (diff) |
move gRPC-related code in vrf.go to grpc_server.go
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/vrf.go')
-rw-r--r-- | table/vrf.go | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/table/vrf.go b/table/vrf.go index 16e02ed4..c8fc2a16 100644 --- a/table/vrf.go +++ b/table/vrf.go @@ -1,4 +1,4 @@ -// Copyright (C) 2014 Nippon Telegraph and Telephone Corporation. +// Copyright (C) 2014-2016 Nippon Telegraph and Telephone Corporation. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package table import ( - api "github.com/osrg/gobgp/api" "github.com/osrg/gobgp/packet/bgp" ) @@ -28,21 +27,26 @@ type Vrf struct { LabelMap map[string]uint32 } -func (v *Vrf) ToApiStruct() *api.Vrf { - f := func(rts []bgp.ExtendedCommunityInterface) [][]byte { - ret := make([][]byte, 0, len(rts)) - for _, rt := range rts { - b, _ := rt.Serialize() - ret = append(ret, b) +func (v *Vrf) Clone() *Vrf { + f := func(rt []bgp.ExtendedCommunityInterface) []bgp.ExtendedCommunityInterface { + l := make([]bgp.ExtendedCommunityInterface, 0, len(rt)) + for _, v := range rt { + l = append(l, v) } - return ret + return l } - rd, _ := v.Rd.Serialize() - return &api.Vrf{ + return &Vrf{ Name: v.Name, - Rd: rd, + Rd: v.Rd, ImportRt: f(v.ImportRt), ExportRt: f(v.ExportRt), + LabelMap: func() map[string]uint32 { + m := make(map[string]uint32) + for k, v := range v.LabelMap { + m[k] = v + } + return m + }(), } } |