mirror of
https://gitee.com/willfree/mlsr.git
synced 2026-06-07 19:49:28 +08:00
声明LsaContainer_BuntDB中的基本函数接口;增加各种LSA的GetType方法
This commit is contained in:
@@ -19,6 +19,10 @@ type AdjLsa struct {
|
||||
AdjLsaAdjacenctList
|
||||
}
|
||||
|
||||
func (a *AdjLsa) GetType() LsaType {
|
||||
return LsaADJACENCYType
|
||||
}
|
||||
|
||||
//
|
||||
// GetAdjList
|
||||
// @Description: 获取邻接信息表
|
||||
|
||||
+12
-4
@@ -23,18 +23,26 @@ type CoordinateLsa struct {
|
||||
HyperbolicAngles
|
||||
}
|
||||
|
||||
func (l *CoordinateLsa) GetType() LsaType {
|
||||
return LsaCOORDINATEType
|
||||
}
|
||||
|
||||
func (c *CoordinateLsa) IsEqualContent(lsa *CoordinateLsa) bool {
|
||||
panic("")
|
||||
// todo
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *CoordinateLsa) ToString() string {
|
||||
panic("")
|
||||
// todo
|
||||
return ""
|
||||
}
|
||||
|
||||
func (c *CoordinateLsa) WireEncode(encoder *encoding.Encoder) (int,error) {
|
||||
panic("")
|
||||
// todo
|
||||
return 0,nil
|
||||
}
|
||||
|
||||
func (c *CoordinateLsa) WireDecode(block *encoding.Block) error {
|
||||
panic("")
|
||||
// todo
|
||||
return nil
|
||||
}
|
||||
@@ -23,6 +23,8 @@ type ILsa interface {
|
||||
GetExpirationTime() uint64
|
||||
SetExpirationTime(time uint64)
|
||||
|
||||
GetType() LsaType
|
||||
|
||||
WireEncode(encoder *encoding.Encoder) (int,error)
|
||||
WireDecode(block *encoding.Block) error
|
||||
}
|
||||
|
||||
+7
-1
@@ -17,6 +17,7 @@ import (
|
||||
type LsaType int
|
||||
|
||||
const (
|
||||
LsaBaseType LsaType = 0
|
||||
LsaADJACENCYType LsaType = 1
|
||||
LsaNAMEType LsaType = 2
|
||||
LsaCOORDINATEType LsaType = 3
|
||||
@@ -30,6 +31,10 @@ type LsaBase struct {
|
||||
LsaOriginRouterIdentifier *component.Identifier // 源路由
|
||||
}
|
||||
|
||||
func (l *LsaBase) GetType() LsaType {
|
||||
return LsaBaseType
|
||||
}
|
||||
|
||||
//
|
||||
// GetSeqNo
|
||||
// @Description: 获取序列号
|
||||
@@ -91,7 +96,8 @@ func (l LsaBase) SetExpirationTime(time uint64) {
|
||||
}
|
||||
|
||||
func (l *LsaBase) ToString() string {
|
||||
panic("")
|
||||
// todo
|
||||
return ""
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
+8
-2
@@ -19,6 +19,10 @@ type NameLsa struct {
|
||||
NameLsaNamePrefixList
|
||||
}
|
||||
|
||||
func (n *NameLsa) GetType() LsaType {
|
||||
return LsaNAMEType
|
||||
}
|
||||
|
||||
//
|
||||
// GetNamePrefixList
|
||||
// @Description: 获取名称前缀信息表
|
||||
@@ -40,11 +44,13 @@ func (n *NameLsa) AddNamePrefixInfo(info *NameLsaNamePrefixInfo) {
|
||||
}
|
||||
|
||||
func (n *NameLsa) IsEqualContent(aLsa *AdjLsa) bool {
|
||||
panic("")
|
||||
// todo
|
||||
return false
|
||||
}
|
||||
|
||||
func (n *NameLsa) ToString() string {
|
||||
panic("")
|
||||
// todo
|
||||
return ""
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -6,8 +6,14 @@
|
||||
// @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
//
|
||||
|
||||
package lsdb
|
||||
package LsaContainer
|
||||
|
||||
//
|
||||
// LsaContainer
|
||||
// @Description:
|
||||
// 1. Unique索引键:GetOriginRouter()+Type()
|
||||
// 2. 其它索引键:Type()
|
||||
//
|
||||
type LsaContainer struct {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
// Package buntdb
|
||||
// @Author: Wang Feng
|
||||
// @Description:
|
||||
// @Version: 0.1.0
|
||||
// @Date: 2022/4/6 17:49
|
||||
// @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
//
|
||||
|
||||
package buntdb
|
||||
|
||||
import (
|
||||
"github.com/tidwall/buntdb"
|
||||
"minlib/component"
|
||||
"mlsr/lsa"
|
||||
)
|
||||
|
||||
//
|
||||
// LsaContainer_BuntDB
|
||||
// @Description: 使用BuntDB存储各种类型的LSA
|
||||
// 实现接口:
|
||||
// emplace() 安装
|
||||
// erase() 删除
|
||||
// GetByName() 根据LSA名称进行索引,返回一个lsa
|
||||
// GetByType() 根据LSA类型进行索引,返回一组lsa,或其在db中的一组键
|
||||
//
|
||||
type LsaContainer_BuntDB struct {
|
||||
db *buntdb.DB
|
||||
}
|
||||
|
||||
//
|
||||
// Init
|
||||
// @Description: 初始化buntdb数据库
|
||||
// @receiver bdb
|
||||
// @return error 如果成功初始化,则返回nil
|
||||
//
|
||||
func (bdb *LsaContainer_BuntDB) Init() error {
|
||||
db, err := buntdb.Open(":memory:")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bdb.db = db
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// Clear
|
||||
// @Description: 关闭数据库
|
||||
// @receiver bdb
|
||||
// @return error
|
||||
//
|
||||
func (bdb *LsaContainer_BuntDB) Clear() error {
|
||||
return bdb.db.Close()
|
||||
}
|
||||
|
||||
func (bdb *LsaContainer_BuntDB) Emplace(lsa *lsa.ILsa) {
|
||||
|
||||
}
|
||||
|
||||
func (bdb *LsaContainer_BuntDB) Erase(lsa *lsa.ILsa) {
|
||||
}
|
||||
|
||||
func (bdb *LsaContainer_BuntDB) EraseByIndex(index int) {
|
||||
}
|
||||
|
||||
func (bdb *LsaContainer_BuntDB) GetLSAByNameAndType(routerIdentifier *component.Identifier,
|
||||
lsaType lsa.LsaType) *lsa.ILsa {
|
||||
}
|
||||
|
||||
func (bdb *LsaContainer_BuntDB) GetLSAsByType(routerIdentifier *component.Identifier) []*lsa.ILsa {
|
||||
}
|
||||
|
||||
func (bdb *LsaContainer_BuntDB) GetLSAKeysByType(routerIdentifier *component.Identifier) []string {
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@ import (
|
||||
"mlsr/common"
|
||||
"mlsr/communication"
|
||||
"mlsr/lsa"
|
||||
"mlsr/lsdb/LsaContainer"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -33,7 +34,7 @@ type Lsdb struct {
|
||||
sync *communication.SyncLogicHandler
|
||||
|
||||
// LSA容器
|
||||
lsaContainer *LsaContainer
|
||||
lsaContainer *LsaContainer.LsaContainer
|
||||
|
||||
lsaRefreshTime *time.Duration // lsa刷新时间
|
||||
adjLsaBuildInterval *time.Duration // 邻接LSA构建间隔
|
||||
|
||||
Reference in New Issue
Block a user