Ejemplo n.º 1
0
 /// <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];
 }
Ejemplo n.º 2
0
 public OSPFAreaVertex(uint iID, int iDistanceFromRoot, LSAHeader lAssociatedLSA, int iAge, LSType lType)
 {
     this.iID = iID;
     this.iDistanceFromRoot = iDistanceFromRoot;
     this.lsAssociatedLSA   = lAssociatedLSA;
     this.iAge    = iAge;
     lNextHops    = new List <Link>();
     lIPAddresses = new List <IPAddress>();
     lAreas       = new List <OSPFArea>();
     this.lsType  = lType;
 }
Ejemplo n.º 3
0
        public static ILeastSquare Create(LSType type)
        {
            switch (type)
            {
            case LSType.GeneralReal:
                return(new GeneralReal());

            case LSType.GeneralComplex:
                return(new GeneralComplex());

            case LSType.FirComplex:
                return(new FirComplex());

            case LSType.FirPowerApprox:
                return(new FirPowerApprox());

            case LSType.IirComplexApprox:
                return(new IirComplexApprox());

            case LSType.IirPowerApprox:
                return(new IirPowerApprox());
            }
            return(null);
        }
Ejemplo n.º 4
0
        /// <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];
            }
        }
Ejemplo n.º 5
0
 public LSObject(string Name, object Value, LSType Type) : this()
 {
     this.Name  = Name;
     this.Value = Value;
     ValueType  = Type;
 }
 /// <summary>
 /// Creates a new instance of this class by parsing the given data starting at a given index
 /// </summary>
 /// <param name="bData">The data to parse</param>
 /// <param name="iStartIndex">The index from which parsing starts</param>
 public LSARequestItem(byte[] bData, int iStartIndex)
 {
     lsType               = (LSType)((int)bData[iStartIndex + 0] << 24) + ((int)bData[iStartIndex + 1] << 16) + ((int)bData[iStartIndex + 2] << 8) + bData[iStartIndex + 3];
     iLinkStateID         = ((int)bData[iStartIndex + 4] << 24) + ((int)bData[iStartIndex + 5] << 16) + ((int)bData[iStartIndex + 6] << 8) + bData[iStartIndex + 7];
     iAdvertisingRouterID = ((int)bData[iStartIndex + 8] << 24) + ((int)bData[iStartIndex + 9] << 16) + ((int)bData[iStartIndex + 10] << 8) + bData[iStartIndex + 11];
 }
 /// <summary>
 /// Creates a new instance of this class
 /// </summary>
 public LSARequestItem()
 {
     lsType               = LSType.Unknown;
     iLinkStateID         = 0;
     iAdvertisingRouterID = 0;
 }