public void InitLSBD() { //+ local-router LSA var header = new OspfLsaHeader { LSAge = 0, AdvertisingRouter = Module.RouterID, Options = (byte)GetOptions(supportOBit: true, removeLLSDataBlock: true), OspfLsaType = OspfLsaType.Route, LSID = Module.RouterID, SequenceNumber = Constant.InitialSequenceNumber }; var routerLsa = new OspfLsaRouterHeader { CommonHeader = header, RouterLSAOptions = Module.RouterLSAOptions, LinkCount = (ushort)InterfaceList.Count }; RouterLSAMap.Add(header.Key, routerLsa); var lsaLinkList = new List<OspfLsaRouterLinkHeader>(); foreach (var interfc in InterfaceList) { var link = new OspfLsaRouterLinkHeader { TypeOfService = 0, Metric = 1 }; if (_controller.DeviceConfigurationMap[interfc.DeviceID].IsLoopback) { link.OspfLsaLinkType = OspfLsaLinkType.Stub; } else { link.OspfLsaLinkType = OspfLsaLinkType.Transit; } lsaLinkList.Add(link); switch (link.OspfLsaLinkType) { case OspfLsaLinkType.PointToPoint: link.LinkID = interfc.RemoteRouterID; link.LinkData = interfc.IPAddress; //TODO: something about unnumbered here, p207 " break; case OspfLsaLinkType.Transit: link.LinkID = interfc.DR; link.LinkData = interfc.IPAddress; break; case OspfLsaLinkType.Stub: link.LinkID = interfc.IPAddress.GetNetwork(interfc.Mask); link.LinkData = interfc.Mask; break; case OspfLsaLinkType.VirtualLink: link.LinkID = interfc.RemoteRouterID; link.LinkData = interfc.IPAddress; break; default: throw new ArgumentOutOfRangeException(); } } routerLsa.LinkList = lsaLinkList; }
public bool IsSame(OspfLsaHeader header) { return header.LSType == LSType && header.LSID == LSID && header.AdvertisingRouter == AdvertisingRouter; }