public static StunMessageAttribute Parse(BitSequence bits)
    {
      var type = (StunMessageAttributeType)(BitConverter.ToUInt16(bits.PopLittleEndianBytes(2), 0));
      var length = BitConverter.ToUInt16(bits.PopLittleEndianBytes(2), 0);

      switch (type)
      {
        case StunMessageAttributeType.XorMappedAddress:
          {
            return ParseXorMappedAddress(bits);
          }
      }

      throw new InvalidOperationException("Invalid attribute.");
    }