From 1e2780ea1bc81c8e93b6aa49724d2bbc4f1b68ce Mon Sep 17 00:00:00 2001 From: free will <2647778488@qq.com> Date: Fri, 3 Jun 2022 22:19:27 +0800 Subject: [PATCH] =?UTF-8?q?LSDB=EF=BC=9A=E5=AE=9E=E7=8E=B0=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E9=82=BB=E6=8E=A5lsa=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lsa/AdjLsaAdjacencyList.go | 12 ++++++++++++ lsdb/Lsdb.go | 34 ++++++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/lsa/AdjLsaAdjacencyList.go b/lsa/AdjLsaAdjacencyList.go index 490d5d2..8d9010e 100644 --- a/lsa/AdjLsaAdjacencyList.go +++ b/lsa/AdjLsaAdjacencyList.go @@ -37,6 +37,18 @@ func (l *AdjLsaAdjacenctList) Insert(info *AdjLsaAdjacencyInfo) { l.lsaAdjacencys = append(l.lsaAdjacencys, info) } +// +// InsertAdjacenctList +// @Description: 插入邻接列表 +// @receiver l +// @param list +// +func (l *AdjLsaAdjacenctList) InsertAdjacenctList(list []*AdjLsaAdjacencyInfo) { + for i := 0; i < len(list); i++ { + l.Insert(list[i]) + } +} + // // getAdjList // @Description: 获取包含所有邻接信息的邻接表 diff --git a/lsdb/Lsdb.go b/lsdb/Lsdb.go index a18b0a7..5bcd8c4 100644 --- a/lsdb/Lsdb.go +++ b/lsdb/Lsdb.go @@ -190,8 +190,8 @@ func (l *Lsdb) ScheduleAdjLsaBuild() { func (l *Lsdb) ProcessInterest(interest *packet.Interest) { } -func (l Lsdb) processInterestForLsa() bool { - return true +func (l *Lsdb) processInterestForLsa(interest *packet.Interest, + originRouterIdentifier *component.Identifier, lsaType lsa.LsaType, seqNo uint64) { } func (l *Lsdb) ProcessGPPkt(pkt *packet.GPPkt) { @@ -378,6 +378,20 @@ func (l *Lsdb) BuildAdjLsa() { // @receiver l // func (l *Lsdb) BuildAndInstallOwnAdjLsa() { + // 根据配置文件,构造本机的名称LSA + adjLsa := new(lsa.AdjLsa) + adjLsa.SetOriginRouter(l.thisRouterPrefix) + adjLsa.SetSeqNo(l.sequencingManager.GetAdjLsaSeq() + 1) // 序列号 + adjLsa.SetLsaExpirationTime(l.getLsaExpirationTimePoint()) // 超期时间 + adjLsa.AdjLsaAdjacenctList.InsertAdjacenctList(l.mlsrConfig.GetAdjacencyList()) // 名称前缀列表 + // 刷新序列号管理器中的名称LSA序列号 + l.sequencingManager.IncreaseAdjLsaSeq() + + // todo: 使用sync通知路由更新 + // m_sync.publishRoutingUpdate(Lsa::Type::ADJACENCY, m_sequencingManager.getAdjLsaSeq()); + + // 安装lsa到LSDB + l.InstallLsa(adjLsa) } // @@ -438,10 +452,14 @@ func (l *Lsdb) ExpireOrRefreshLsa(lsa lsa.ILsa) { } } -func (l *Lsdb) ProcessInterestForLsa(interest *packet.Interest, - originRouterIdentifier *component.Identifier, lsaType lsa.LsaType, seqNo uint64) { -} - +// +// ExpressInterest +// @Description: 发送请求其它路由器LSA的兴趣包 +// @receiver l +// @param interestName +// @param timeOut +// @param deadline +// func (l *Lsdb) ExpressInterest(interestName *component.Identifier, timeOut uint32, deadline *time.Time) { } @@ -458,7 +476,7 @@ func (l *Lsdb) ExpressInterest(interestName *component.Identifier, // @param lsaName // @param seqNo // -func (l *Lsdb) OnFetchLsaError(errorCode uint32, msg string, +func (l *Lsdb) onFetchLsaError(errorCode uint32, msg string, interestName *component.Identifier, retransmitNo uint32, deadline *time.Time, lsaName *component.Identifier, seqNo uint64) { } @@ -472,7 +490,7 @@ func (l *Lsdb) OnFetchLsaError(errorCode uint32, msg string, // @param buffer // @param interestName // -func (l *Lsdb) AfterFetchLsa(buffer bytes.Buffer, interestName *component.Identifier) { +func (l *Lsdb) afterFetchLsa(buffer bytes.Buffer, interestName *component.Identifier) { } func (l *Lsdb) getLsaExpirationTimePoint() uint64 {