diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-07-11 21:54:50 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-07-20 04:25:25 +0900 |
commit | f27afac154c955e1e2508d2443ef29ecfc62c6b8 (patch) | |
tree | 7fd57b56426706790a3fc6c746d2604e30b80493 /table | |
parent | e090609b146fdde93714e966aa8ec300b5842ba3 (diff) |
move gRPC-related code in path.go and destination.go to grpc_server.go
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r-- | table/destination.go | 28 | ||||
-rw-r--r-- | table/path.go | 29 |
2 files changed, 0 insertions, 57 deletions
diff --git a/table/destination.go b/table/destination.go index f6de40d1..b1fa3509 100644 --- a/table/destination.go +++ b/table/destination.go @@ -20,7 +20,6 @@ import ( "encoding/binary" "fmt" log "github.com/Sirupsen/logrus" - api "github.com/osrg/gobgp/api" "github.com/osrg/gobgp/config" "github.com/osrg/gobgp/packet/bgp" "net" @@ -139,33 +138,6 @@ func NewDestination(nlri bgp.AddrPrefixInterface) *Destination { return d } -func (dd *Destination) ToApiStruct(id string) *api.Destination { - prefix := dd.GetNlri().String() - paths := func(arg []*Path) []*api.Path { - ret := make([]*api.Path, 0, len(arg)) - first := true - for _, p := range arg { - if p.Filtered(id) == POLICY_DIRECTION_NONE { - pp := p.ToApiStruct(id) - if first { - pp.Best = true - first = false - } - ret = append(ret, pp) - } - } - return ret - }(dd.knownPathList) - - if len(paths) == 0 { - return nil - } - return &api.Destination{ - Prefix: prefix, - Paths: paths, - } -} - func (dd *Destination) Family() bgp.RouteFamily { return dd.routeFamily } diff --git a/table/path.go b/table/path.go index 1d0765d4..e10cd44b 100644 --- a/table/path.go +++ b/table/path.go @@ -19,7 +19,6 @@ import ( "bytes" "fmt" log "github.com/Sirupsen/logrus" - api "github.com/osrg/gobgp/api" "github.com/osrg/gobgp/config" "github.com/osrg/gobgp/packet/bgp" "math" @@ -271,34 +270,6 @@ func (path *Path) IsIBGP() bool { return path.GetSource().AS == path.GetSource().LocalAS } -func (path *Path) ToApiStruct(id string) *api.Path { - nlri := path.GetNlri() - n, _ := nlri.Serialize() - family := uint32(bgp.AfiSafiToRouteFamily(nlri.AFI(), nlri.SAFI())) - pattrs := func(arg []bgp.PathAttributeInterface) [][]byte { - ret := make([][]byte, 0, len(arg)) - for _, a := range arg { - aa, _ := a.Serialize() - ret = append(ret, aa) - } - return ret - }(path.GetPathAttrs()) - return &api.Path{ - Nlri: n, - Pattrs: pattrs, - Age: path.OriginInfo().timestamp.Unix(), - IsWithdraw: path.IsWithdraw, - Validation: int32(path.OriginInfo().validation.ToInt()), - Filtered: path.Filtered(id) == POLICY_DIRECTION_IN, - Family: family, - SourceAsn: path.OriginInfo().source.AS, - SourceId: path.OriginInfo().source.ID.String(), - NeighborIp: path.OriginInfo().source.Address.String(), - Stale: path.IsStale(), - IsFromExternal: path.OriginInfo().isFromExternal, - } -} - // create new PathAttributes func (path *Path) Clone(isWithdraw bool) *Path { return &Path{ |