summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2018-05-09 15:36:06 +0900
committerIWASE Yusuke <iwase.yusuke0@gmail.com>2018-06-13 08:55:27 +0900
commit34acacddea8047843dbcaf8e0aa46dc895d40afa (patch)
tree665fa8d86ba109cd90bb06d741799da6a5ffbf3b
parenta7f58e3aa4c30ef1eef1db0197ee43c077ac26d9 (diff)
gobgp/lib: Remove usage of utils of "gobgpapi"
"gobgp/lib" can be independent from "gobgpapi" package, this patch removes the usage of utility function "ToPathApi()" in this package. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
-rw-r--r--gobgp/lib/path.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/gobgp/lib/path.go b/gobgp/lib/path.go
index c74a7bc0..da06bb93 100644
--- a/gobgp/lib/path.go
+++ b/gobgp/lib/path.go
@@ -36,7 +36,6 @@ import (
"encoding/json"
"strings"
- api "github.com/osrg/gobgp/api"
"github.com/osrg/gobgp/gobgp/cmd"
"github.com/osrg/gobgp/packet/bgp"
)
@@ -53,18 +52,19 @@ func get_route_family(input *C.char) C.int {
//export serialize_path
func serialize_path(rf C.int, input *C.char) *C.path {
args := strings.Split(C.GoString(input), " ")
- pp, err := cmd.ParsePath(bgp.RouteFamily(rf), args)
+ p, err := cmd.ParsePath(bgp.RouteFamily(rf), args)
if err != nil {
return nil
}
path := C.new_path()
- p := api.ToPathApi(pp, nil)
- if len(p.Nlri) > 0 {
- path.nlri.len = C.int(len(p.Nlri))
- path.nlri.value = C.CString(string(p.Nlri))
+ if nlri := p.GetNlri(); nlri != nil {
+ buf, _ := nlri.Serialize()
+ path.nlri.len = C.int(len(buf))
+ path.nlri.value = C.CString(string(buf))
}
- for _, attr := range p.Pattrs {
- C.append_path_attribute(path, C.int(len(attr)), C.CString(string(attr)))
+ for _, attr := range p.GetPathAttrs() {
+ buf, _ := attr.Serialize()
+ C.append_path_attribute(path, C.int(len(buf)), C.CString(string(buf)))
}
return path
}