public SimulationEdge(IEdgeSendHandler s, int local_id, int remote_id, bool is_in, int delay) : base(s, is_in) { _sh = s; _l_id = local_id; _r_id = remote_id; Delay = delay; }
/// <summary>Constructor for a TunnelEdge, RemoteID == -1 for out bound.</summary> public TunnelEdge(IEdgeSendHandler send_handler, TunnelTransportAddress local_ta, TunnelTransportAddress remote_ta, IForwarderSelector ias, List <Connection> overlap, int remote_id) : base(send_handler, remote_id != -1) { _remote_id = remote_id; lock (_rand) { LocalID = _rand.Next(); } byte[] bid = new byte[8]; NumberSerializer.WriteInt(LocalID, bid, 0); NumberSerializer.WriteInt(_remote_id, bid, 4); _mid = MemBlock.Reference(bid); _local_ta = local_ta; _remote_ta = remote_ta; _tunnels = new List <Connection>(overlap); _ias = ias; _ias.Update(_tunnels); AHHeader ahh = new AHHeader(1, 20, local_ta.Target, remote_ta.Target, AHHeader.Options.Exact); ICopyable header = new CopyList(PType.Protocol.AH, ahh, PType.Protocol.Tunneling); Header = MemBlock.Copy(header); }
public SimulationEdge(IEdgeSendHandler s, int local_id, int remote_id, bool is_in, int delay) : base(s, is_in) { _sh = s; Delay = delay; ListenerId = local_id; RemoteID = remote_id; }
/// <summary>Create a XmppEdge.</summary> public XmppEdge(IEdgeSendHandler send_handler, XmppTransportAddress local_ta, XmppTransportAddress remote_ta, bool inbound) : base(send_handler, inbound) { _ip = new IdentifierPair(); _local_ta = local_ta; _remote_ta = remote_ta; To = remote_ta.JID; }
public SimulationEdge(IEdgeSendHandler s, int local_id, int remote_id, bool is_in, int delay, TransportAddress.TAType type) : base(s, is_in) { Delay = delay; LocalID = local_id; RemoteID = remote_id; _ta_type = type; _local_ta = GetTransportAddress(local_id); _remote_ta = GetTransportAddress(remote_id); SimEL = s as SimulationEdgeListener; }
/** * The send_cb is the method which actually does the * sending (which is in UdpEdgeListener). */ public TcpEdge(IEdgeSendHandler send_cb, bool is_in, Socket s) : base(send_cb, is_in) { //This will update both the end point and the remote TA Socket = s; _localta = TransportAddressFactory.CreateInstance(TAType, (IPEndPoint)s.LocalEndPoint); _remoteta = TransportAddressFactory.CreateInstance(TAType, (IPEndPoint)s.RemoteEndPoint); _buffer = new byte[MAX_PACKET + 2]; //+2 to include the size of the packet. _written = 0; _flush_ptr = 0; }
/** * The send_cb is the method which actually does the * sending (which is in UdpEdgeListener). */ public TcpEdge(IEdgeSendHandler send_cb, bool is_in, Socket s) : base(send_cb, is_in) { //This will update both the end point and the remote TA Socket = s; _localta = TransportAddressFactory.CreateInstance(TAType, (IPEndPoint) s.LocalEndPoint); _remoteta = TransportAddressFactory.CreateInstance(TAType, (IPEndPoint) s.RemoteEndPoint); _buffer = new byte[ MAX_PACKET + 2 ]; //+2 to include the size of the packet. _written = 0; _flush_ptr = 0; }
/** * The send_cb is the method which actually does the * sending (which is in UdpEdgeListener). */ public UdpEdge(IEdgeSendHandler send_cb, bool is_in, System.Net.IPEndPoint remote_end_point, System.Net.IPEndPoint local_end_point, int id, int remoteid) : base(send_cb, is_in) { //This will update both the end point and the remote TA this.End = remote_end_point; _localta = TransportAddressFactory.CreateInstance(TAType, (IPEndPoint) local_end_point); _id = id; _remoteid = remoteid; }
/** * The send_cb is the method which actually does the * sending (which is in UdpEdgeListener). */ public UdpEdge(IEdgeSendHandler send_cb, bool is_in, System.Net.IPEndPoint remote_end_point, System.Net.IPEndPoint local_end_point, int id, int remoteid) : base(send_cb, is_in) { //This will update both the end point and the remote TA this.End = remote_end_point; _localta = TransportAddressFactory.CreateInstance(TAType, (IPEndPoint)local_end_point); _id = id; _remoteid = remoteid; }
/** * @param port the local port to bind to * @param local_tas an IEnumerable object which gives the list of local * IPs. This is consulted every time LocalTAs is accessed, so it can * change as new interfaces are added * @param ta_auth the TAAuthorizer for packets incoming */ public UdpEdgeListener(int port, IEnumerable local_config_ips, TAAuthorizer ta_auth) { _s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); _s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, Int32.MaxValue); _s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, Int32.MaxValue); ipep = new IPEndPoint(IPAddress.Any, port); _s.Bind(ipep); _port = port = ((IPEndPoint)(_s.LocalEndPoint)).Port; /** * We get all the IPAddresses for this computer */ if (local_config_ips == null) { _tas = TransportAddressFactory.CreateForLocalHost(TransportAddress.TAType.Udp, _port); } else { _tas = TransportAddressFactory.Create(TransportAddress.TAType.Udp, _port, local_config_ips); } _nat_hist = null; _nat_tas = new NatTAs(_tas, _nat_hist); _ta_auth = ta_auth; if (_ta_auth == null) { //Always authorize in this case: _ta_auth = new ConstantAuthorizer(TAAuthorizer.Decision.Allow); } //We start out expecting around 30 edges with //a load factor of 0.15 (to make edge lookup fast) _id_ht = new Hashtable(30, 0.15f); _remote_id_ht = new Hashtable(); _sync = new object(); _running = 0; _isstarted = 0; ///@todo, we need a system for using the cryographic RNG _rand = new Random(); _send_handler = this; _listen_finished_event = new ManualResetEvent(false); _listen_thread = new Thread(ListenThread); _send_thread = new Thread(SendThread); _send_thread.IsBackground = true; _send_queue = new LFBlockingQueue <UdpMessage>(); }
protected Edge(IEdgeSendHandler esh, bool is_in) : this() { _send_cb = esh; IsInbound = is_in; }
public SimulationEdge(IEdgeSendHandler s, int local_id, int remote_id, bool is_in, int delay) : this(s, local_id, remote_id, is_in, delay, TransportAddress.TAType.S) { }
public FunctionEdge(IEdgeSendHandler s, int local_id, int remote_id, bool is_in) : base(s, is_in) { _l_id = local_id; _r_id = remote_id; }
public SimulationEdge(IEdgeSendHandler s, int local_id, int remote_id, bool is_in) : this(s, local_id, remote_id, is_in, 0) { }
/** * @param port the local port to bind to * @param local_tas an IEnumerable object which gives the list of local * IPs. This is consulted every time LocalTAs is accessed, so it can * change as new interfaces are added * @param ta_auth the TAAuthorizer for packets incoming */ public UdpEdgeListener(int port, IEnumerable local_config_ips, TAAuthorizer ta_auth) { _s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); ipep = new IPEndPoint(IPAddress.Any, port); _s.Bind(ipep); _port = port = ((IPEndPoint) (_s.LocalEndPoint)).Port; /** * We get all the IPAddresses for this computer */ if( local_config_ips == null ) { _tas = TransportAddressFactory.CreateForLocalHost(TransportAddress.TAType.Udp, _port); } else { _tas = TransportAddressFactory.Create(TransportAddress.TAType.Udp, _port, local_config_ips); } _nat_hist = null; _nat_tas = new NatTAs( _tas, _nat_hist ); _ta_auth = ta_auth; if( _ta_auth == null ) { //Always authorize in this case: _ta_auth = new ConstantAuthorizer(TAAuthorizer.Decision.Allow); } //We start out expecting around 30 edges with //a load factor of 0.15 (to make edge lookup fast) _id_ht = new Hashtable(30, 0.15f); _remote_id_ht = new Hashtable(); _sync = new object(); _running = 0; _isstarted = 0; ///@todo, we need a system for using the cryographic RNG _rand = new Random(); _send_handler = this; _listen_finished_event = new ManualResetEvent(false); _listen_thread = new Thread(ListenThread); _send_thread = new Thread(SendThread); _send_thread.IsBackground = true; _send_queue = new LFBlockingQueue<UdpMessage>(); }
/// <summary>Outgoing edge, since we don't know the RemoteID yet!</summary> public TunnelEdge(IEdgeSendHandler send_handler, TunnelTransportAddress local_ta, TunnelTransportAddress remote_ta, IForwarderSelector ias, List <Connection> overlap) : this(send_handler, local_ta, remote_ta, ias, overlap, -1) { }
/// <summary>Constructor for a RelayEdge, RemoteID == -1 for out bound.</summary> public RelayEdge(IEdgeSendHandler send_handler, RelayTransportAddress local_ta, RelayTransportAddress remote_ta, IForwarderSelector ias, List<Connection> overlap, int remote_id) : base(send_handler, remote_id != -1) { _remote_id = remote_id; lock(_rand) { LocalID = _rand.Next(); } byte[] bid = new byte[8]; NumberSerializer.WriteInt(LocalID, bid, 0); NumberSerializer.WriteInt(_remote_id, bid, 4); _mid = MemBlock.Reference(bid); _local_ta = local_ta; _remote_ta = remote_ta; _tunnels = new List<Connection>(overlap); _ias = ias; _ias.Update(_tunnels); AHHeader ahh = new AHHeader(1, 20, local_ta.Target, remote_ta.Target, AHHeader.Options.Exact); ICopyable header = new CopyList(PType.Protocol.AH, ahh, PType.Protocol.Relaying); Header = MemBlock.Copy(header); }
/// <summary>Outgoing edge, since we don't know the RemoteID yet!</summary> public RelayEdge(IEdgeSendHandler send_handler, RelayTransportAddress local_ta, RelayTransportAddress remote_ta, IForwarderSelector ias, List<Connection> overlap) : this(send_handler, local_ta, remote_ta, ias, overlap, -1) { }