/// <summary> /// Creates a new instance of this class /// </summary> public IPOption() { bCopyFlag = false; iOptionClass = IPOptionClass.Control; iOptionNumber = IPOptionNumber.NoOperation; bOptionData = new byte[0]; }
/// <summary> /// Creates a new instance of this class by parsing the given data /// </summary> /// <param name="bOptionBytes">The data to parse</param> public IPOption(byte[] bOptionBytes) { this.bCopyFlag = ((int)((bOptionBytes[0] & 0x80) >> 7)) == 1; this.iOptionClass = (IPOptionClass)((bOptionBytes[0] & 0x60) >> 5); this.iOptionNumber = (IPOptionNumber)(bOptionBytes[0] & 0x1F); if (!((iOptionNumber == IPOptionNumber.EndOfList || iOptionNumber == IPOptionNumber.NoOperation) && iOptionClass == IPOptionClass.Control)) { int iOptionLength = (int)(bOptionBytes[1]); if (iOptionLength > 2) { this.bOptionData = new byte[iOptionLength - 2]; for (int iC1 = 2; iC1 < iOptionLength; iC1++) { bOptionData[iC1 - 2] = bOptionBytes[iC1]; } } else { this.bOptionData = new byte[0]; } } else { this.bOptionData = new byte[0]; } }