Exemplo n.º 1
0
 public Client(SharpNet NetworkInterface, ClientProfile Profile)
 {
     mNet     = NetworkInterface;
     mProfile = Profile;
     mNet.OnReceiveUDPPacket += ClientHandlerUDP;
     mNet.OnReceiveTCPPacket += ClientHandlerTCP;
 }
Exemplo n.º 2
0
        public static void Init(TestContext context)
        {
            Trace.Listeners.Add(new ConsoleTraceListener());
            //Helper.Driver.Profile.DriverPath = "E:\\Workbench\\ZeroHub\\ZeroHub\\SharpNetUnitTest\\bin\\Debug\\Drivers\\";
            //Helper.Driver.Uninstall();
            //Helper.Driver.Install();
            LocalIP       = "10.3.0.1";
            RemoteIPRange = "10.3.0.0"; // RemoteIPRange & Mask , and filter away local
            RemoteIP      = "10.3.0.5";
            Mask          = "255.255.255.0";

            net = new SharpNet();
            net.Tap.SetMediaStatus(true);
            net.Tap.ConfigTun(LocalIP, RemoteIPRange, Mask);
            net.Tap.SetIpAddress(LocalIP, Mask, "10.3.0.0");

            //net.Tap.ConfigDHCPMASQ("192.168.137.1", "255.255.255.255", "1.1.1.1", 2);
            Task.Delay(TimeSpan.FromSeconds(5)).Wait();

            ping       = new Ping();
            localPort  = 233;
            remotePort = 233;

            local  = new IPEndPoint(IPAddress.Parse(LocalIP), localPort);
            remote = new IPEndPoint(IPAddress.Parse(RemoteIP), remotePort);
            //remote = new IPEndPoint(IPAddress.Any, remotePort);
            client = new System.Net.Sockets.UdpClient(local);
        }
Exemplo n.º 3
0
 public UdpClient(SharpNet NetworkInterface, int LocalPort, string FakeRemoteIP, int FakeRemotePort)
 {
     net                     = NetworkInterface;
     LocalIP                 = NetworkInterface.Tap.Ip;
     this.LocalPort          = LocalPort;
     this.FakeRemoteIP       = FakeRemoteIP;
     this.FakeRemotePort     = FakeRemotePort;
     mRx                     = new BlockingCollection <UDPPacket>(new ConcurrentQueue <UDPPacket>());
     net.OnReceiveUDPPacket += Parse;
 }