summaryrefslogtreecommitdiffhomepage
path: root/client/client.go
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2018-06-19 10:25:50 +0900
committerIWASE Yusuke <iwase.yusuke0@gmail.com>2018-06-19 12:01:48 +0900
commitb992c538652580cb4150524328dc2c3b13425863 (patch)
tree9911930f2771d7cfb815c9f3624fa13c46766626 /client/client.go
parentb73933c4b20e15f468944edd7012a7cc90adf0e7 (diff)
api: Use attribute.proto struct in message Vrf
The current formats of the RD and import/export RTs in message Vrf are the binary type representation, this patch fixes to use the structures defined in attribute.proto file. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'client/client.go')
-rw-r--r--client/client.go44
1 files changed, 11 insertions, 33 deletions
diff --git a/client/client.go b/client/client.go
index 37d68b49..3bdef91d 100644
--- a/client/client.go
+++ b/client/client.go
@@ -468,31 +468,23 @@ func (cli *Client) GetVRF() ([]*table.Vrf, error) {
}
var vrfs []*table.Vrf
- f := func(bufs [][]byte) ([]bgp.ExtendedCommunityInterface, error) {
- ret := make([]bgp.ExtendedCommunityInterface, 0, len(bufs))
- for _, rt := range bufs {
- r, err := bgp.ParseExtended(rt)
- if err != nil {
- return nil, err
- }
- ret = append(ret, r)
- }
- return ret, nil
- }
-
for _, vrf := range ret.Vrfs {
- importRT, err := f(vrf.ImportRt)
+ rd, err := api.UnmarshalRD(vrf.Rd)
+ if err != nil {
+ return nil, err
+ }
+ importRT, err := api.UnmarshalRTs(vrf.ImportRt)
if err != nil {
return nil, err
}
- exportRT, err := f(vrf.ExportRt)
+ exportRT, err := api.UnmarshalRTs(vrf.ExportRt)
if err != nil {
return nil, err
}
vrfs = append(vrfs, &table.Vrf{
Name: vrf.Name,
Id: vrf.Id,
- Rd: bgp.GetRouteDistinguisher(vrf.Rd),
+ Rd: rd,
ImportRt: importRT,
ExportRt: exportRT,
})
@@ -502,30 +494,16 @@ func (cli *Client) GetVRF() ([]*table.Vrf, error) {
}
func (cli *Client) AddVRF(name string, id int, rd bgp.RouteDistinguisherInterface, im, ex []bgp.ExtendedCommunityInterface) error {
- buf, err := rd.Serialize()
- if err != nil {
- return err
- }
-
- importRT, err := bgp.SerializeExtendedCommunities(im)
- if err != nil {
- return err
- }
- exportRT, err := bgp.SerializeExtendedCommunities(ex)
- if err != nil {
- return err
- }
-
arg := &api.AddVrfRequest{
Vrf: &api.Vrf{
Name: name,
- Rd: buf,
+ Rd: api.MarshalRD(rd),
Id: uint32(id),
- ImportRt: importRT,
- ExportRt: exportRT,
+ ImportRt: api.MarshalRTs(im),
+ ExportRt: api.MarshalRTs(ex),
},
}
- _, err = cli.cli.AddVrf(context.Background(), arg)
+ _, err := cli.cli.AddVrf(context.Background(), arg)
return err
}