Exemple #1
0
        /// <summary>
        /// Prepare ManagementAnswer to send via UDP/TCP
        /// To send via UDP, use Label(package).toBytes()
        /// </summary>
        /// <param name="answer">Prepared ManagementAnswer package</param>
        /// <returns>Package object</returns>
        public static Package RoutingTables(ManagementAnswer answer)
        {
            Package package = new Package();

            package.Key  = "ROUTINGTABLE";
            package.data = answer.toString();

            return(package);
        }
Exemple #2
0
        /// <summary>
        /// Prepare ManagementAnswer to send via UDP/TCP
        /// To send via UDP, use Label(package).toBytes()
        /// </summary>
        /// <param name="answer">Prepared ManagementAnswer package</param>
        /// <returns>Package</returns>
        public static Package Label(ManagementAnswer answer)
        {
            Package package = new Package();

            package.Key  = "MANAGEMENTTOHOST";
            package.data = answer.toString();

            return(package);
        }
        /*
         * //----------RESPOND TO HOST WITH TUNEL CLOSING-----
         * public static ManagementAnswer TunelCloseAccept(int label)
         * {
         *  ManagementAnswer answer = new ManagementAnswer();
         *  answer.Key = "TUNELCLOSED";
         *  answer.answer = label.ToString();
         *
         *  return answer;
         * }
         *
         * public bool isToHostTunelClosingAccept()
         * {
         *  if (Key == "TUNELCLOSED")
         *  {
         *      return true;
         *  }
         *  else
         *  {
         *      return false;
         *  }
         * }
         */

        //-----------RESPOND TO ROUTER--------------
        public static ManagementAnswer RouterAnswer(String routingTable)
        {
            ManagementAnswer answer = new ManagementAnswer();

            answer.Key    = "ROUTINGTABLE";
            answer.answer = routingTable;

            return(answer);
        }
        //--------------RESPOND TO HOST WITH OPEN TUNEL-------------
        public static ManagementAnswer HostAnswer(int label)
        {
            ManagementAnswer answer = new ManagementAnswer();

            answer.Key    = "LABELFORHOST";
            answer.answer = label.ToString();

            return(answer);
        }
        public static ManagementAnswer fromString(String stringMassage)
        {
            ManagementAnswer answer = new ManagementAnswer();

            try
            {
                answer.answer = stringMassage;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }


            return(answer);
        }
Exemple #6
0
 /// <summary>
 /// Creates Label ManagementAnsware from previously opened package.
 /// Management sends in respond available label or "null"
 /// </summary>
 /// <param name="package">Opened Package got from UDP/TCP</param>
 /// <returns>ManagementAnswer created from HostAnswer</returns>
 public static ManagementAnswer ReceiveLabel(Package package)
 {
     return(ManagementAnswer.HostAnswer(int.Parse(package.data)));
 }
Exemple #7
0
        /// <summary>
        /// Creates Label ManagementAnsware from bytes
        /// Management sends in respond available label or "null"
        /// </summary>
        /// <param name="respond">Bytes from which ManagementAnswer will be created</param>
        /// <returns>ManagementAnswer created from HostAnswer</returns>
        public static ManagementAnswer ReceiveLabel(byte[] respond)
        {
            Package package = Package.fromBytes(respond);

            return(ManagementAnswer.HostAnswer(int.Parse(package.data)));
        }
Exemple #8
0
 /// <summary>
 /// Creates RoutingTables ManagementAnsware from previously opened package.
 /// Management sends in respond routing tables to Router
 /// </summary>
 /// <param name="package">Opened Package got from UDP/TCP</param>
 /// <returns>ManagementAnswer created from RoutingAnswer</returns>
 public static ManagementAnswer ReceiveRoutingTables(Package package)
 {
     return(ManagementAnswer.RouterAnswer(package.data));
 }
Exemple #9
0
        /// <summary>
        /// Creates RoutingTables ManagementAnsware from bytes
        /// Management sends in respond routing tables to Router
        /// </summary>
        /// <param name="respond">Bytes from which ManagementAnswer will be created</param>
        /// <returns>ManagementAnswer created from RoutingAnswer</returns>
        public static ManagementAnswer ReceiveRoutingTables(byte[] respond)
        {
            Package package = Package.fromBytes(respond);

            return(ManagementAnswer.RouterAnswer(package.data));
        }