diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-07-31 18:51:05 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-08 20:56:46 +0900 |
commit | bf9e135ba85cad641c3812abace9221cbf5a2615 (patch) | |
tree | 435728bd72e93ddfea7a3c02d78cfb1a9c65f16f /table/vrf.go | |
parent | ecd079e318e1c5d5aa2d2f1348a4ad1a37daec37 (diff) |
server: support vrf
to add/delete vrf
$ gobgp vrf [add|del] <vrf-name> rd <rd> rt [import|export|both] <rt>...
show vrf
$ gobgp vrf
to add/delete a path to a specific vrf
$ gobgp vrf <vrf-name> rib [add|del] <prefix> -a <address-family>
show paths contained in a specific vrf
$ gobgp vrf <vrf-name> rib -a <address-family>
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/vrf.go')
-rw-r--r-- | table/vrf.go | 46 |
1 files changed, 46 insertions, 0 deletions
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), + } +} |