summaryrefslogtreecommitdiffhomepage
path: root/table/table.go
diff options
context:
space:
mode:
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])
+}