From bf9e135ba85cad641c3812abace9221cbf5a2615 Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Fri, 31 Jul 2015 18:51:05 +0900 Subject: server: support vrf to add/delete vrf $ gobgp vrf [add|del] rd rt [import|export|both] ... show vrf $ gobgp vrf to add/delete a path to a specific vrf $ gobgp vrf rib [add|del] -a show paths contained in a specific vrf $ gobgp vrf rib -a Signed-off-by: ISHIDA Wataru --- table/vrf.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 table/vrf.go (limited to 'table/vrf.go') diff --git a/table/vrf.go b/table/vrf.go new file mode 100644 index 00000000..3833ecac --- /dev/null +++ b/table/vrf.go @@ -0,0 +1,46 @@ +// Copyright (C) 2014 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. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +// implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package table + +import ( + "github.com/osrg/gobgp/api" + "github.com/osrg/gobgp/packet" +) + +type Vrf struct { + Name string + Rd bgp.RouteDistinguisherInterface + ImportRt []bgp.ExtendedCommunityInterface + ExportRt []bgp.ExtendedCommunityInterface +} + +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) + } + return ret + } + rd, _ := v.Rd.Serialize() + return &api.Vrf{ + Name: v.Name, + Rd: rd, + ImportRt: f(v.ImportRt), + ExportRt: f(v.ExportRt), + } +} -- cgit v1.2.3