mirror of
https://gitee.com/willfree/mlsr.git
synced 2026-10-04 19:42:02 +08:00
fix: 增强参数检查
This commit is contained in:
1 parent
32937ca587
commit
330f26a234
4 files changed
+31
-7
No files matched your search
+3
-3
@@ -153,7 +153,7 @@ func (l *Lsdb) Init(mc *common.MlsrConfig, ms *MlsrScheduler,
|
||||
|
||||
if args[2] != nil {
|
||||
originRouter, ok = args[2].(*component.Identifier)
|
||||
if !ok {
|
||||
if !ok || originRouter == nil {
|
||||
common2.LogError("originRouter conversion failed.")
|
||||
return
|
||||
}
|
||||
@@ -826,7 +826,7 @@ func (l *Lsdb) ExpressInterest(interestName *component.Identifier,
|
||||
var ok bool
|
||||
if args[0] != nil {
|
||||
data, ok = args[0].(*packet.Data)
|
||||
if !ok {
|
||||
if !ok || data == nil {
|
||||
common2.LogError("data conversion failed.")
|
||||
return
|
||||
}
|
||||
@@ -858,7 +858,7 @@ func (l *Lsdb) ExpressInterest(interestName *component.Identifier,
|
||||
var ok bool
|
||||
if args[0] != nil {
|
||||
buffer, ok = args[0].([]byte)
|
||||
if !ok {
|
||||
if !ok || buffer == nil {
|
||||
common2.LogError("buffer conversion failed.")
|
||||
return
|
||||
}
|
||||
|
||||
+5
-1
@@ -123,7 +123,11 @@ func (m *Mlsr) Init(face *logicface.DummyClientLogicFace, scheduler *lsdb.MlsrSc
|
||||
bindHelloFunc := func(args ...interface{}) {
|
||||
common2.LogInfo("Mlsr.bindHelloFunc")
|
||||
// Hello协议收到有效Data包,解析其参数为邻居
|
||||
neighbor := args[0].(*component.Identifier)
|
||||
neighbor, ok := args[0].(*component.Identifier)
|
||||
if !ok || neighbor == nil {
|
||||
common2.LogError("Invalid Identifier")
|
||||
return
|
||||
}
|
||||
// 查看本机是否已知道此路由器
|
||||
adjInfo := m.m_adjacencyList.FindAdjacencyByRouterIdentifier(neighbor)
|
||||
if adjInfo != nil {
|
||||
|
||||
@@ -86,7 +86,11 @@ func (t *NamePrefixTable) Init(ownRouterName *component.Identifier,
|
||||
// 监听路由表的修改,触发NPT表修改
|
||||
bindRoutingChangeFunc := func(args ...interface{}) {
|
||||
common2.LogInfo("NamePrefixTable bindRoutingChangeFunc.")
|
||||
entrys := args[0].([]*RoutingTableEntry)
|
||||
entrys, ok := args[0].([]*RoutingTableEntry)
|
||||
if !ok || entrys == nil {
|
||||
common2.LogError("NamePrefixTable Invalid Entry")
|
||||
return
|
||||
}
|
||||
t.UpdateWithNewRoute(entrys)
|
||||
}
|
||||
t.m_afterRoutingChangeConnection = afterRoutingChangeSignal.Connect(bindRoutingChangeFunc)
|
||||
@@ -96,14 +100,26 @@ func (t *NamePrefixTable) Init(ownRouterName *component.Identifier,
|
||||
common2.LogInfo("NamePrefixTable bindLsdbModifiedFunc.")
|
||||
// 获取四个参数
|
||||
ilsa := args[0].(lsa.ILsa)
|
||||
if ilsa == nil {
|
||||
common2.LogError("Invalid lsa")
|
||||
return
|
||||
}
|
||||
updateType := args[1].(lsdb.LsdbUpdate)
|
||||
common2.LogInfo("NamePrefixTable bindLsdbModifiedFunc lsa: ", ilsa.GetOriginRouter().ToUri())
|
||||
common2.LogInfo("NamePrefixTable bindLsdbModifiedFunc updateType: ", updateType)
|
||||
namesToAdd := []*component.Identifier{}
|
||||
namesToRemove := []*component.Identifier{}
|
||||
if updateType == lsdb.UPDATED {
|
||||
namesToAdd = args[2].([]*component.Identifier)
|
||||
namesToRemove = args[3].([]*component.Identifier)
|
||||
namesToAdd, ok := args[2].([]*component.Identifier)
|
||||
if !ok || namesToAdd == nil {
|
||||
common2.LogError("Invalid namesToAdd")
|
||||
return
|
||||
}
|
||||
namesToRemove, ok = args[3].([]*component.Identifier)
|
||||
if !ok || namesToRemove == nil {
|
||||
common2.LogError("Invalid namesToRemove")
|
||||
return
|
||||
}
|
||||
}
|
||||
// 执行更新操作
|
||||
t.UpdateFromLsdb(ilsa, updateType, namesToAdd, namesToRemove)
|
||||
|
||||
@@ -98,6 +98,10 @@ func (t *RoutingTable) Init(mc *common.MlsrConfig,
|
||||
bindFunc := func(args ...interface{}) {
|
||||
// 获取四个参数
|
||||
ilsa := args[0].(lsa.ILsa)
|
||||
if ilsa == nil {
|
||||
common2.LogError("Invalid lsa")
|
||||
return
|
||||
}
|
||||
updateType := args[1].(lsdb.LsdbUpdate)
|
||||
common2.LogInfo("RoutingTable.bindFunc: ",
|
||||
ilsa.GetOriginRouter().ToUri(), " ", updateType)
|
||||
|
||||
Reference in new issue
Block a user