Ejemplo n.º 1
0
        public MTUConfig GetMTU(IPEndPoint ep)
        {
            var result = new MTUConfig();

            if (ep == null)
            {
                result.MTU    = 1484 - 28; // IPV4 28 byte UDP header
                result.MTUMax = 1484 - 28;
                result.MTUMin = 620 - 28;
                return(result);
            }

            switch (ep.AddressFamily)
            {
            case System.Net.Sockets.AddressFamily.InterNetwork:
                result.MTU    = 1484 - 28;
                result.MTUMax = 1484 - 28;
                result.MTUMin = 620 - 28;
                break;

            case System.Net.Sockets.AddressFamily.InterNetworkV6:
                result.MTU    = 1280 - 48;   // IPV6 48 byte UDP header
                result.MTUMax = 1472 - 48;
                result.MTUMin = 1280 - 48;
                break;

            default:
                throw new NotImplementedException($"{ep.AddressFamily} not supported");
            }

            return(result);
        }
Ejemplo n.º 2
0
        // Session to introducer
        internal SSUSession(SSUHost owner, IPEndPoint remoteep, IntroducerInfo ii, IMTUProvider mtup, RouterContext rc)
        {
            Host            = owner;
            RemoteEP        = remoteep;
            MTUProvider     = mtup;
            MyRouterContext = rc;

            RemoteAddr = new I2PRouterAddress(ii.Host, ii.Port, 0, "SSU");

            // TODO: This is what PurpleI2P does. Seems strange... But there is no RouterInfo available for introducer sessions.
            RemoteRouter = MyRouterContext.MyRouterIdentity;

            TransportInstance = Interlocked.Increment(ref NTCPClient.TransportInstanceCounter);

#if LOG_ALL_TRANSPORT
            DebugUtils.LogDebug("SSUSession: " + DebugId + " Introducer instance created.");
#endif

            Fragmenter = new DataFragmenter();

            if (RemoteAddr == null)
            {
                throw new NullReferenceException("SSUSession needs an address");
            }

            IntroKey = ii.IntroKey;

            MTU = MTUProvider.GetMTU(remoteep);
        }
Ejemplo n.º 3
0
        // We are client
        public SSUSession(SSUHost owner, IPEndPoint remoteep, I2PRouterAddress remoteaddr, I2PKeysAndCert rri, IMTUProvider mtup, RouterContext rc)
        {
            Host              = owner;
            RemoteEP          = remoteep;
            RemoteAddr        = remoteaddr;
            RemoteRouter      = rri;
            MTUProvider       = mtup;
            MyRouterContext   = rc;
            TransportInstance = Interlocked.Increment(ref NTCPClient.TransportInstanceCounter);

#if LOG_ALL_TRANSPORT
            DebugUtils.LogDebug("SSUSession: " + DebugId + " Client instance created.");
#endif

            Fragmenter = new DataFragmenter();

            if (RemoteAddr == null)
            {
                throw new NullReferenceException("SSUSession needs an address");
            }

            IntroKey = new BufLen(FreenetBase64.Decode(RemoteAddr.Options["key"]));

            MTU = MTUProvider.GetMTU(remoteep);
        }
Ejemplo n.º 4
0
            public MTUConfig GetMTU(IPEndPoint ep)
            {
                var result = new MTUConfig();

                result.MTU    = 1484 - 28;
                result.MTUMax = 1484 - 28;
                result.MTUMin = 620 - 28;
                return(result);
            }
Ejemplo n.º 5
0
        // We are host
        public SSUSession(SSUHost owner, IPEndPoint remoteep, IMTUProvider mtup, RouterContext rc)
        {
            Host              = owner;
            RemoteEP          = remoteep;
            MTUProvider       = mtup;
            MyRouterContext   = rc;
            TransportInstance = Interlocked.Increment(ref NTCPClient.TransportInstanceCounter) + 10000;

#if LOG_ALL_TRANSPORT
            DebugUtils.LogDebug("SSUSession: " + DebugId + " Host instance created.");
#endif

            Fragmenter = new DataFragmenter();

            MTU = MTUProvider.GetMTU(remoteep);

            SendQueue.AddLast((new DeliveryStatusMessage((ulong)I2PConstants.I2P_NETWORK_ID)).Header5);
            SendQueue.AddLast((new DatabaseStoreMessage(MyRouterContext.MyRouterInfo)).Header5);

            CurrentState = new SessionCreatedState(this);
        }
Ejemplo n.º 6
0
 public void MTUUsed(IPEndPoint ep, MTUConfig mtu)
 {
 }