/// <summary> /// Creates a new instance of this class /// </summary> public OSPFDatabaseDescriptionMessage() { sInterfaceMTU = 0; ospfOptions = new OSPFOptionsField(); iDDSequenceNumber = 0; lLSAHeaders = new List <LSAHeader>(); }
/// <summary> /// Creates a new instance of this class /// </summary> public LSAHeader() { iLSAge = 0; ospfOptions = new OSPFOptionsField(); lsType = LSType.Unknown; iLinkStateID = 0; iAdvertisingRouter = 0; iLSSequenceNumber = 0; iOrigalLength = -1; bOriginalChecksum = new byte[0]; }
/// <summary> /// Creates a new instance of this class /// </summary> public OSPFHelloMessage() { nNetmask = new Subnetmask(); iHelloInterval = 0; bPriority = 0; iDeadInterval = 30; ipaDesignatedRouter = IPAddress.Any; ipaBackupDesignatedRouter = IPAddress.Any; lipaNeighbours = new List <IPAddress>(); ospfOptions = new OSPFOptionsField(); }
/// <summary> /// Creates a new instance of this class by parsing the given data /// </summary> /// <param name="bData">The data to pase</param> public OSPFHelloMessage(byte[] bData) { byte[] bTmpBytes = new byte[4]; for (int iC1 = 0; iC1 < 4; iC1++) { bTmpBytes[iC1] = bData[iC1]; } nNetmask = new Subnetmask(bTmpBytes); iHelloInterval = (bData[5] << 8) + bData[6]; ospfOptions = new OSPFOptionsField(bData[6]); bPriority = bData[7]; iDeadInterval = ((int)bData[8] << 24) + ((int)bData[9] << 16) + ((int)bData[10] << 8) + bData[11]; for (int iC1 = 12; iC1 < 16; iC1++) { bTmpBytes[iC1 - 12] = bData[iC1]; } ipaDesignatedRouter = new IPAddress(bTmpBytes); for (int iC1 = 16; iC1 < 20; iC1++) { bTmpBytes[iC1 - 16] = bData[iC1]; } ipaBackupDesignatedRouter = new IPAddress(bTmpBytes); lipaNeighbours = new List <IPAddress>(); for (int iC2 = 20; iC2 < bData.Length; iC2 += 4) { for (int iC1 = iC2; iC1 < iC2 + 4; iC1++) { bTmpBytes[iC1 - iC2] = bData[iC1]; } lipaNeighbours.Add(new IPAddress(bTmpBytes)); } }
/// <summary> /// Creates a new instance of this class by parsing the given data /// </summary> /// <param name="bData">The data to parse</param> public OSPFDatabaseDescriptionMessage(byte[] bData) { sInterfaceMTU = (short)(((int)bData[0] << 8) + bData[1]); ospfOptions = new OSPFOptionsField(bData[2]); bMSBit = (bData[3] & 0x1) != 0; bMBit = (bData[3] & 0x2) != 0; bIBit = (bData[3] & 0x4) != 0; bOOBResyncBit = (bData[3] & 0x8) != 0; iDDSequenceNumber = ((uint)bData[4] << 24) + ((uint)bData[5] << 16) + ((uint)bData[6] << 8) + bData[7]; lLSAHeaders = new List <LSAHeader>(); byte[] bLSAHeader = new byte[20]; for (int iC1 = 8; iC1 < bData.Length; iC1 += 20) { for (int iC2 = 0; iC2 < 20; iC2++) { bLSAHeader[iC2] = bData[iC2 + iC1]; } lLSAHeaders.Add(new LSAHeader(bLSAHeader, false)); } }
/// <summary> /// Creates a new instance of this class by parsing the given data. /// </summary> /// <param name="bData">The data to parse</param> /// <param name="bCreateBody">A bool indicating whether a LSA body should be created. Set this property to false for database descriptions and LS acknowledgements messages</param> public LSAHeader(byte[] bData, bool bCreateBody) { iLSAge = (short)((bData[0] << 8) + bData[1]); ospfOptions = new OSPFOptionsField(bData[2]); lsType = (LSType)bData[3]; iLinkStateID = ((uint)bData[4] << 24) + ((uint)bData[5] << 16) + ((uint)bData[6] << 8) + bData[7]; iAdvertisingRouter = ((uint)bData[8] << 24) + ((uint)bData[9] << 16) + ((uint)bData[10] << 8) + bData[11]; iLSSequenceNumber = ((uint)bData[12] << 24) + ((uint)bData[13] << 16) + ((uint)bData[14] << 8) + bData[15]; // 2 byte checksum int iLen = ((bData[18] << 8) + bData[19]) - 20; if (bCreateBody) { iOrigalLength = -1; bOriginalChecksum = new byte[0]; byte[] bBodyBytes = new byte[iLen]; for (int iC1 = 0; iC1 < iLen; iC1++) { bBodyBytes[iC1] = bData[iC1 + 20]; } if (bBodyBytes.Length > 0) { if (lsType == LSType.Router) { fEncapsulatedFrame = new RouterLSA(bBodyBytes); } else if (lsType == LSType.External) { fEncapsulatedFrame = new ASExternalLSA(bBodyBytes); } else if (lsType == LSType.Network) { fEncapsulatedFrame = new NetworkLSA(bBodyBytes); } else if (lsType == LSType.Summary_IP) { fEncapsulatedFrame = new SummaryLSA(bBodyBytes); } else if (lsType == LSType.Summary_ASBR) { fEncapsulatedFrame = new SummaryLSA(bBodyBytes); } else if (lsType == LSType.NSSA) { fEncapsulatedFrame = new ASExternalLSA(bBodyBytes); } else { fEncapsulatedFrame = new RawDataFrame(bBodyBytes); } } } else { iOrigalLength = iLen + 20; bOriginalChecksum = new byte[2]; bOriginalChecksum[0] = bData[16]; bOriginalChecksum[1] = bData[17]; } }