From 88beb51aaf3e5bc865be369eeee2db064c817f6b Mon Sep 17 00:00:00 2001 From: free will <2647778488@qq.com> Date: Fri, 1 Apr 2022 23:47:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E9=83=A8=E5=88=86lsdb?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lsa/ILsa.go | 16 ++++++++++++++++ lsdb/Lsdb.go | 32 +++++++++++++++++++++++--------- 2 files changed, 39 insertions(+), 9 deletions(-) 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) {