diff --git a/hello/HelloProtocol.go b/hello/HelloProtocol.go index fedb956..6427889 100644 --- a/hello/HelloProtocol.go +++ b/hello/HelloProtocol.go @@ -15,6 +15,7 @@ import ( "minlib/packet" "minlib/security" "mlsr/common" + "mlsr/extensions" "mlsr/lsa" "mlsr/lsdb" "time" @@ -220,9 +221,50 @@ func (h *HelloProtocol) onContent(interest *packet.Interest, data *packet.Data) logrus.Debug("Received data for name:v%", data.GetName()) Sig, _ := data.GetSignature(0) //获取指定位置的签名 kl := Sig.SigInfo.GetKeyLocator() - //签名的格式如何验证???????????? + //签名的格式如何验证????????????extensions选的是TlvMlsrLsaNamePrefix吗? if kl != nil { - logrus.Debug("Data signed with:v%", kl.GetIdentifier()) + if encoding.ExpectType(kl.Raw().GetType(), extensions.TlvMlsrLsaNamePrefix) != nil { + logrus.Debug("Data signed with:v%", kl.GetIdentifier()) + } } //数据如何校验????????????? } + +// +// onContentValidated +// @Description: 改变一个邻居的状态 +// @receiver h +// @param data +// +func (h *HelloProtocol) onContentValidated(data *packet.Data) { + // data name: //NLSR/INFO// + dataName := data.GetName() + logrus.Debug("Data validation successful for name:v%", dataName) + info, _ := dataName.Get(-3) + if info.ToUri() == INFO_COMPONENT { + neighborPrefix, _ := dataName.Get(-4) + var neighbor *component.Identifier + neighbor.WireDecode(neighborPrefix.Raw()) + oldStatus, _ := adjacentList.GetStatusOfNeighbor(neighbor) + adjacentList.SetStatusOfNeighbor(neighbor, 1) //邻居路由器的状态:未知-1、未激活0、激活1 + adjacentList.SetTimedOutInterestCount(neighbor, 0) + newStatus, _ := adjacentList.GetStatusOfNeighbor(neighbor) + + logrus.Debug("Neighbor:v%", neighbor) + logrus.Debug("Old status:v%,New status:V%", oldStatus, newStatus) + // change in Adjacency list + if oldStatus != newStatus { + h.ScheduleAdjLsaBuild() + } + + } + +} + +// +// onContentValidationFailed +// @Description: +// @param data +// @return {} +// +func onContentValidationFailed(data *packet.Data) {}