Creates new connections ... on demand, when an address has data being sent to it, the method Active should be calld. An internal internal timer (FuzzyTimer) automatically removes inactive connections.
Inheritance: PolicyBasedConnectionOverlord
Ejemplo n.º 1
0
    public ConnectionHandler(PType ptype, StructuredNode node)
    {
      _node = node;
      _ondemand = new OnDemandConnectionOverlord(node);
      _node.AddConnectionOverlord(_ondemand);
      _ptype = ptype;
      _ptype_mb = ptype.ToMemBlock();
      _address_to_sender = new Dictionary<Address, ISender>();
      _sender_to_address = new Dictionary<ISender, Address>();

      node.GetTypeSource(_ptype).Subscribe(this, null);
      node.ConnectionTable.ConnectionEvent += HandleConnection;
      node.ConnectionTable.DisconnectionEvent += HandleDisconnection;
    }
Ejemplo n.º 2
0
    /// <summary>Creates an IpopNode given a NodeConfig and an IpopConfig.
    /// Also sets up the Information, Ethernet device, and subscribes
    /// to Brunet for IP Packets</summary>
    /// <param name="node_config">The path to a NodeConfig xml file</param>
    /// <param name="ipop_config">The path to a IpopConfig xml file</param>
    public IpopNode(NodeConfig node_config, IpopConfig ipop_config,
        DHCPConfig dhcp_config) : base(node_config)
    {
      PublicNode = CreateNode(node_config);
      PublicNode.Node.DisconnectOnOverload = false;
      if(PublicNode.PrivateNode == null) {
        AppNode = PublicNode;
      } else {
        AppNode = PublicNode.PrivateNode;
        AppNode.Node.DisconnectOnOverload = false;
      }

      _ondemand = new OnDemandConnectionOverlord(AppNode.Node);
      AppNode.Node.AddConnectionOverlord(_ondemand);
      _ipop_config = ipop_config;

      Ethernet = new Ethernet(_ipop_config.VirtualNetworkDevice);
      Ethernet.Subscribe(this, null);

      Info = new Information(AppNode.Node, "IpopNode", AppNode.SecurityOverlord);
      Info.UserData["IpopNamespace"] = _ipop_config.IpopNamespace;
      if(PublicNode == AppNode) {
        PublicInfo = Info;
      } else {
        PublicInfo = new Information(PublicNode.Node, "PrivateIpopNode",
            PublicNode.SecurityOverlord);
        PublicInfo.UserData["IpopNamespace"] = _ipop_config.IpopNamespace;
      }

      if(_ipop_config.EndToEndSecurity && AppNode.SymphonySecurityOverlord != null) {
        _secure_senders = true;
      } else {
        _secure_senders = false;
      }
      AppNode.Node.GetTypeSource(PType.Protocol.IP).Subscribe(this, null);

      _sync = new object();
      _lock = 0;

      _ether_to_ip = new Dictionary<MemBlock, MemBlock>();
      _ip_to_ether = new Dictionary<MemBlock, MemBlock>();

      _dhcp_server_port = _ipop_config.DHCPPort != 0 ? _ipop_config.DHCPPort : 67;
      _dhcp_client_port = _dhcp_server_port + 1;
      ProtocolLog.WriteIf(IpopLog.DhcpLog, String.Format(
          "Setting Dhcp Ports to: {0},{1}", _dhcp_server_port, _dhcp_client_port));
      _ether_to_dhcp_server = new Dictionary<MemBlock, DhcpServer>();
      _static_mapping = new Dictionary<MemBlock, SimpleTimer>();
      _dhcp_config = dhcp_config;
      if(_dhcp_config != null) {
        SetDns();
        SetTAAuth();
        _dhcp_server = GetDhcpServer();
      }
      _checked_out = new Hashtable();

      AppNode.Node.HeartBeatEvent += CheckNode;
      _last_check_node = Brunet.DateTime.UtcNow;

      AppNode.Node.Rpc.AddHandler("Ipop", this);
    }