diff --git a/lsa/ILsa.go b/lsa/ILsa.go index 0565c0d..ac1e709 100644 --- a/lsa/ILsa.go +++ b/lsa/ILsa.go @@ -8,5 +8,21 @@ package lsa +import ( + "minlib/component" + "minlib/encoding" +) + type ILsa interface { + GetSeqNo() uint64 + SetSeqNo(seq uint64) + + GetOriginRouter() *component.Identifier + SetOriginRouter(routerIdentifier *component.Identifier) + + GetExpirationTime() uint64 + SetExpirationTime(time uint64) + + WireEncode(encoder *encoding.Encoder) (int,error) + WireDecode(block *encoding.Block) error } diff --git a/lsdb/Lsdb.go b/lsdb/Lsdb.go index fd96afc..67668da 100644 --- a/lsdb/Lsdb.go +++ b/lsdb/Lsdb.go @@ -114,17 +114,17 @@ func (l *Lsdb) ProcessGPPkt(pkt *packet.GPPkt) { // @return bool // func (l *Lsdb) GetIsBuildAdjLsaScheduled() bool { - panic("") + return l.isBuildAdjLsaScheduled } // // GetSync -// @Description: 获取Sync协议类型 +// @Description: 获取Sync协议逻辑处理器 // @receiver l // @return communication.SyncLogicHandler // -func (l *Lsdb) GetSync() communication.SyncLogicHandler { - panic("") +func (l *Lsdb) GetSync() *communication.SyncLogicHandler { + return l.sync } // @@ -133,15 +133,29 @@ func (l *Lsdb) GetSync() communication.SyncLogicHandler { // @receiver l* // @param routerIdentifier // @param lsaType -// @return []*lsa.ILsa +// @return *lsa.ILsa // -func (l* Lsdb) FindLsa(routerIdentifier *component.Identifier, - lsaType lsa.LsaType) []*lsa.ILsa { +func (l *Lsdb) FindLsa(routerIdentifier *component.Identifier, + lsaType lsa.LsaType) lsa.ILsa { panic("") } -func (l *Lsdb) IsLsaNew() bool { - return false +// +// IsLsaNew +// @Description: 返回来自某个路由器的seq是否表示新的LSA。 +// @receiver l +// @param routerIdentifier +// @param lsaType +// @param seqNo +// @return bool +// +func (l *Lsdb) IsLsaNew(routerIdentifier *component.Identifier, + lsaType lsa.LsaType,seqNo uint64) bool { + lsa := l.FindLsa(routerIdentifier,lsaType) + if lsa.GetSeqNo() >= seqNo{ + return false + } + return true } func (l *Lsdb) InstallLsa(lsa *lsa.ILsa) {