summaryrefslogtreecommitdiffhomepage
path: root/pkg/server/grpc_server.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@gmail.com>2020-10-20 21:09:34 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2020-10-21 21:09:12 +0900
commit3d3d6f34381f811c4e42c148c7666b47f45a7654 (patch)
tree6ac6cd1a32b0af142bb39ba8f83b45e5ccf9be6b /pkg/server/grpc_server.go
parente6eb1da279769bd3d56364ab685b4fb2e0b029a7 (diff)
api: add ListPathRequest's option to get binary of nlri and attributes
put the binary of nlri and path attribute to the response. Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'pkg/server/grpc_server.go')
-rw-r--r--pkg/server/grpc_server.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/pkg/server/grpc_server.go b/pkg/server/grpc_server.go
index 69af445c..a9f621fb 100644
--- a/pkg/server/grpc_server.go
+++ b/pkg/server/grpc_server.go
@@ -153,11 +153,26 @@ func toPathAPI(binNlri []byte, binPattrs [][]byte, anyNlri *any.Any, anyPattrs [
return p
}
-func toPathApi(path *table.Path, v *table.Validation) *api.Path {
+func toPathApi(path *table.Path, v *table.Validation, nlri_binary, attribute_binary bool) *api.Path {
nlri := path.GetNlri()
anyNlri := apiutil.MarshalNLRI(nlri)
anyPattrs := apiutil.MarshalPathAttributes(path.GetPathAttrs())
- return toPathAPI(nil, nil, anyNlri, anyPattrs, path, v)
+ var binNlri []byte
+ if nlri_binary {
+ binNlri, _ = nlri.Serialize()
+ }
+ var binPattrs [][]byte
+ if attribute_binary {
+ pa := path.GetPathAttrs()
+ binPattrs = make([][]byte, 0, len(pa))
+ for _, a := range pa {
+ b, e := a.Serialize()
+ if e == nil {
+ binPattrs = append(binPattrs, b)
+ }
+ }
+ }
+ return toPathAPI(binNlri, binPattrs, anyNlri, anyPattrs, path, v)
}
func getValidation(v map[*table.Path]*table.Validation, p *table.Path) *table.Validation {