summaryrefslogtreecommitdiffhomepage
path: root/table/table.go
diff options
context:
space:
mode:
authorYuji Oshima <yuji.oshima0x3fd@gmail.com>2015-03-21 08:08:43 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-03-21 08:08:43 +0900
commit28feabe1ef3961e05e0e109551021f0bc8902abe (patch)
tree5b055cd546c0561e4fd2ac1cdb70a07fc17d6f3e /table/table.go
parent84f6e0b04cc48289d342d0b904c43ab19ba2a427 (diff)
table: add EVPN route family support
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/table.go')
-rw-r--r--table/table.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/table/table.go b/table/table.go
index c5ce287a..47e42fbb 100644
--- a/table/table.go
+++ b/table/table.go
@@ -381,3 +381,43 @@ func (ipv4vpnt *IPv4VPNTable) MarshalJSON() ([]byte, error) {
})
}
+
+type EVPNTable struct {
+ *TableDefault
+ //need structure
+}
+
+func NewEVPNTable(scope_id int) *EVPNTable {
+ EVPNTable := &EVPNTable{}
+ EVPNTable.TableDefault = NewTableDefault(scope_id)
+ EVPNTable.TableDefault.ROUTE_FAMILY = bgp.RF_EVPN
+ //need Processing
+ return EVPNTable
+}
+
+//Creates destination
+//Implements interface
+func (ipv4vpnt *EVPNTable) createDest(nlri bgp.AddrPrefixInterface) Destination {
+ return Destination(NewEVPNDestination(nlri))
+}
+
+//make tablekey
+//Implements interface
+func (ipv4vpnt *EVPNTable) tableKey(nlri bgp.AddrPrefixInterface) string {
+
+ addrPrefix := nlri.(*bgp.EVPNNLRI)
+ return addrPrefix.String()
+}
+
+func ParseEVPNPrefix(key string) patricia.Prefix {
+ vpnaddrprefix := strings.Split(key, "/")
+ length, _ := strconv.ParseInt(vpnaddrprefix[1], 10, 0)
+ _, n, _ := net.ParseCIDR(vpnaddrprefix[0] + "/" + strconv.FormatInt((int64(length)-88), 10))
+
+ var buffer bytes.Buffer
+ for i := 0; i < len(n.IP); i++ {
+ buffer.WriteString(fmt.Sprintf("%08b", n.IP[i]))
+ }
+ ones, _ := n.Mask.Size()
+ return patricia.Prefix(buffer.String()[:ones])
+}