Exemplo n.º 1
0
        public static void SetupConnection(ModelConnectionId connectionId, ModelDialectRevision clientMaxDialect)
        {
            // Restrict model contains 2 connections at most
            Condition.IsTrue(!ConnectionList.ContainsKey(connectionId));

            // Reduce states
            Combination.NWise(1, connectionId, clientMaxDialect);

            DialectRevision dialect = ModelHelper.DetermineNegotiateDialect(clientMaxDialect, config.MaxSmbVersionSupported);

            // Establish new connection
            ConnectionList.Add(
                connectionId,
                new ModelConnection(dialect));

            ConnectionList[connectionId].ConnectionState = ModelState.Connected;

            ModelHelper.Log(LogType.Requirement, "3.3.5.1: Connection.ConstrainedConnection is set to TRUE.");
            ConnectionList[connectionId].ConstrainedConnection = true;
        }
Exemplo n.º 2
0
        private static void AuthNewSession(ModelSmb2Status status, ModelSessionSetupRequest sessionSetupRequest)
        {
            ModelHelper.Log(LogType.Requirement, "3.3.5.5.1: A session object MUST be allocated for this request. ");

            ModelSession   session   = new ModelSession();
            ModelSessionId?sessionId = null;

            if (!GlobalSessionTable.ContainsKey(ModelSessionId.MainSessionId))
            {
                sessionId = ModelSessionId.MainSessionId;
            }
            else
            {
                sessionId = ModelSessionId.AlternativeSessionId;
            }

            // Update sessionId to new created one from zero
            sessionSetupRequest.sessionId = sessionId.Value;

            ModelHelper.Log(LogType.Requirement, "The other values MUST be initialized as follows:");
            session.Dialect = ConnectionList[sessionSetupRequest.connectionId].NegotiateDialect;

            ModelHelper.Log(LogType.Requirement, "Session.State is set to InProgress.");
            session.State     = ModelSessionState.InProgress;
            session.SessionId = sessionId.Value;

            ModelHelper.Log(LogType.Requirement,
                            "The session MUST be inserted into the GlobalSessionTable and a unique Session.SessionId is assigned to serve as a lookup key in the table. ");
            GlobalSessionTable.Add(sessionSetupRequest.sessionId, session);

            ModelHelper.Log(LogType.Requirement, "The session MUST be inserted into Connection.SessionTable. ");
            ConnectionList[sessionSetupRequest.connectionId].Session = session;

            ModelHelper.Log(LogType.Requirement, "Using this session, authentication is continued as specified in section 3.3.5.5.3.");
            HandleGssApiAuth(status, sessionSetupRequest);
        }
Exemplo n.º 3
0
        public int[,] SudokuMapBuilder()
        {
Start:

            int[,] Map = new int[9, 9];
            int mapCounter = 1;

            List <int[, ]> mapHolder = new List <int[, ]>();

            RandomNumberCorector            randomNumberCorector = new RandomNumberCorector();
            List <NumberCorectorValueTypes> NumberCorectorsList  = new List <NumberCorectorValueTypes>();
            RandomNumber randomNumber = new RandomNumber();
            MapContainer mapContainer = new MapContainer();

            int i              = 0;
            int indexi         = 0;
            int j              = 0;
            int indexj         = 0;
            int indexjComparer = 3;
            int countSquares   = 0;

            int FailFailCount = 0;

            int mapCounter_A = 0;
            int mapCounter_B = 0;

            int  countRow          = 0;
            int  countColumn       = 0;
            bool ifStartsNewSquare = false;

            int failCount   = 0;
            int numberCheck = 0;

            int countMapCounterAtempts = 0;

            RandomHolder = new List <int> {
                1, 2, 3, 4, 5, 6, 7, 8, 9
            };

            for (i = indexi; i < Map.GetLength(0); i++)
            {
                countRow++;

                for (j = indexj; j < indexjComparer; j++)
                {
                    countColumn++;

                    if (countColumn > 3)
                    {
                        countColumn = 1;
                    }

                    do
                    {
                        numberCheck = randomNumber.Get(countRow, countColumn, randomNumberCorector, NumberCorectorsList, RandomHolder);


                        if (numberCheck == 666 || randomNumberCorector.TotalImposibleFromHolderList(numberCheck, NumberCorectorsList))
                        {
                            ifStartsNewSquare = true;

                            if (mapCounter > mapHolder.Count)
                            {
                                mapCounter = 1;
                            }

                            failCount++;

                            mapCounter_A = mapCounter;


                            if (mapHolder.Count == 8 && failCount == 1)
                            {
                                FailFailCount++;
                            }

                            if (failCount > 1)
                            {
                                mapCounter++;
                                failCount = 0;
                            }

                            if (FailFailCount == 5)
                            {
                                mapCounter = 5;
                                mapHolder.RemoveRange(mapHolder.Count - 5, 5);
                                FailFailCount = 0;
                            }

                            mapCounter_B = mapCounter;

                            mapContainer.Get(mapHolder, ref Map, mapCounter);

                            RandomHolder = new List <int> {
                                1, 2, 3, 4, 5, 6, 7, 8, 9
                            };

                            if (mapCounter_A != mapCounter_B)
                            {
                                NumberCorectorsList = new List <NumberCorectorValueTypes>();
                            }

                            MapStepBack.SetIndexersToProperPpositions(Map, ref i, ref j, ref indexi, ref indexj, ref indexjComparer, ref countRow, ref countSquares);
                            randomNumberCorector.RemoveSquareNumbers(ref NumberCorectorsList);

                            countColumn = 0;

                            break;
                        }
                        else
                        {
                            Map[i, j] = numberCheck;
                        }
                    } while (NumberChecking.NumberDuplicate(Map, Map[i, j], ref randomNumberCorector, ref NumberCorectorsList, countRow, countColumn, j));


                    if (ifStartsNewSquare == false)
                    {
                        RandomHolder.Remove(Map[i, j]);
                    }

                    ifStartsNewSquare = false;
                }

                if (countRow == 3)
                {
                    countMapCounterAtempts++;
                    NumberCorectorsList = new List <NumberCorectorValueTypes>();

                    CountTry++;
                    if (CountTry > 30)
                    {
                        CountTry = 0;
                        goto Start;
                    }

                    mapContainer.Add(Map, ref mapHolder);
                    mapCounter = 1;

                    countSquares++;
                    if (countSquares == 3 && indexi + 3 < Map.GetLength(0))
                    {
                        countSquares   = 0;
                        indexi        += 3;
                        indexj         = 0;
                        indexjComparer = 3;
                        countRow       = 0;

                        RandomHolder = new List <int> {
                            1, 2, 3, 4, 5, 6, 7, 8, 9
                        };
                    }
                    else
                    {
                        RandomHolder = new List <int> {
                            1, 2, 3, 4, 5, 6, 7, 8, 9
                        };

                        if (i == 5)
                        {
                            i = 2;
                        }
                        else if (i == 8)
                        {
                            i = 5;
                        }
                        else
                        {
                            i = -1;
                        }

                        if (i != 8 && j != 9)
                        {
                            indexjComparer += 3;
                        }
                        else
                        {
                            i = Map.GetLength(0);
                        }

                        indexj += 3;

                        countRow = 0;
                    }
                }
            }
            return(Map);
        }