Example #1
0
        /**
         * When a ConnectionEvent occurs, this handler registers the
         * information with the node
         */
        public virtual void ConnectionHandler(object ct, EventArgs args)
        {
            ConnectionEventArgs ce_args = (ConnectionEventArgs)args;
            Edge edge = ce_args.Edge;

            edge.Subscribe(this, edge);
            //Our peer's remote is us
            TransportAddress reported_ta =
                ce_args.Connection.PeerLinkMessage.Remote.FirstTA;
            //Our peer's local is them
            TransportAddress remote_ta =
                ce_args.Connection.PeerLinkMessage.Local.FirstTA;

            /*
             * Make a copy so that _remote_ta never changes while
             * someone is using it
             */
            ArrayList new_remote_ta = new ArrayList();

            foreach (EdgeListener el in _edgelistener_list)
            {
                //Update our local list:
                el.UpdateLocalTAs(edge, reported_ta);
                el.UpdateRemoteTAs(new_remote_ta, edge, remote_ta);
            }
            UpdateRemoteTAs(new_remote_ta);
        }
 ///<summary>Makes the SecurityOverlord listen to the edge and instantiates
 ///a new SecurityAssociation for the insecure edge.  CreateSecurityAssociation
 ///is idempotent.</summary>
 protected override void WrapEdge(Edge edge) {
   edge.Subscribe(_so, null);
   SecurityAssociation sa = _so.CreateSecurityAssociation(edge, DefaultEdgeSPI, !edge.IsInbound);
   if(edge.IsClosed) {
     sa.Close("Edge closed too quickly.");
   }
 }
Example #3
0
 public override void Start()
 {
     //Make sure the Node is listening to this node
     try {
         //This will throw an exception if _e is already closed:
         _e.CloseEvent += this.CloseHandler;
         //_e must not be closed, let's start listening to it:
         _e.Subscribe(_node, _e);
         /* Make the call */
         Channel results = new Channel();
         results.CloseAfterEnqueue();
         results.CloseEvent += this.LinkCloseHandler;
         RpcManager rpc = _node.Rpc;
         if (ProtocolLog.LinkDebug.Enabled)
         {
             ProtocolLog.Write(ProtocolLog.LinkDebug,
                               String.Format("LPS target: {0} Invoking Start() over edge: {1}", _linker.Target, _e));
         }
         rpc.Invoke(_e, results, "sys:link.Start", MakeLM().ToDictionary());
     }
     catch (Exception e) {
         //The Edge must have closed, move on to the next TA
         if (ProtocolLog.LinkDebug.Enabled)
         {
             ProtocolLog.Write(ProtocolLog.LinkDebug,
                               String.Format("LPS target: {0} Start() over edge: {1}, hit exception: {2}",
                                             _linker.Target, _e, e));
         }
         Finish(Result.MoveToNextTA);
     }
 }
 ///<summary>Creates a new WrapperEdge.<summary>
 ///<param name="edge">The edge to wrap.</param>
 ///<param name="SubscribeToEdge">Should this subscribe to the edge.</param>
 public WrapperEdge(Edge edge, bool SubscribeToEdge) {
   _weclosed = 0;
   _edge = edge;
   if(SubscribeToEdge) {
     _edge.Subscribe(this, null);
   }
 }
Example #5
0
 public ETClient(Edge e)
 {
     _sync        = new object();
     _sent_blocks = new Hashtable();
     _e           = e;
     _e.Subscribe(this, null);
 }
Example #6
0
 public ETClient(Edge e)
 {
   _sync = new object();
   _sent_blocks = new Hashtable();
   _e = e;
   _e.Subscribe(this, null );
 }
Example #7
0
 ///<summary>Creates a new WrapperEdge.<summary>
 ///<param name="edge">The edge to wrap.</param>
 ///<param name="SubscribeToEdge">Should this subscribe to the edge.</param>
 public WrapperEdge(Edge edge, bool SubscribeToEdge)
 {
     _weclosed = 0;
     _edge     = edge;
     if (SubscribeToEdge)
     {
         _edge.Subscribe(this, null);
     }
 }
Example #8
0
        ///<summary>Makes the SecurityOverlord listen to the edge and instantiates
        ///a new SecurityAssociation for the insecure edge.  CreateSecurityAssociation
        ///is idempotent.</summary>
        protected override void WrapEdge(Edge edge)
        {
            edge.Subscribe(_so, null);
            SecurityAssociation sa = _so.CreateSecurityAssociation(edge, DefaultEdgeSPI, !edge.IsInbound);

            if (edge.IsClosed)
            {
                sa.Close("Edge closed too quickly.");
            }
        }
Example #9
0
        /**
         * This Handler should be connected to incoming EdgeEvent
         * events.  If it is not, it cannot hear the new edges.
         *
         * When a new edge is created, we make sure we can hear
         * the packets from it.  Also, we make sure we can hear
         * the CloseEvent.
         *
         * @param edge the new Edge
         */
        protected void EdgeHandler(object edge, EventArgs args)
        {
            Edge e = (Edge)edge;

            try {
                _connection_table.AddUnconnected(e);
                e.Subscribe(this, e);
            }
            catch (TableClosedException) {
                /*
                 * Close this edge immediately, before any packets
                 * have a chance to be received.  We are shutting down,
                 * and it is best that we stop getting new packets
                 */
                e.Close();
            }
        }
Example #10
0
        /** Watch this incoming Edge
         */
        protected void HandleEdge(object newedge, System.EventArgs args)
        {
            Edge e = (Edge)newedge;

            try {
                e.CloseEvent += this.HandleEdgeClose;
                e.Subscribe(this, null);
                lock ( _sync ) {
                    _edges.Add(e);
                }
            }
            catch (Exception x) {
                //Didn't work out, make sure the edges is closed
                Console.WriteLine("Closing ({0}) due to: {1}", e, x);
                e.Close();
            }
        }
Example #11
0
    ///<summary>Makes the SecurityOverlord listen to the edge and instantiates
    ///a new SecurityAssociation for the insecure edge.  CreateSecurityAssociation
    ///is idempotent.</summary>
    protected override void WrapEdge(Edge edge) {
      edge.Subscribe(_so, null);

      if(edge.IsInbound) {
        lock(_sync) {
          _edge_to_inbound.Add(edge, true);
        }
      } else {
        SecurityAssociation sa = _so.CreateSecurityAssociation(edge);
        lock(_sync) {
          _edge_to_sa.Add(edge, sa);
        }
      }

      try {
        edge.CloseEvent += HandleEdgeClose;
      } catch {
        HandleEdgeClose(edge, EventArgs.Empty);
      }
    }
Example #12
0
 public void HandleEC(bool succ, Edge e, Exception x)
 {
     if (succ)
     {
         /*
          * Got the underlying Edge, now do the path protocol
          */
         Channel results = new Channel(1);
         results.CloseEvent += delegate(object q, EventArgs args) {
             try {
                 RpcResult res = (RpcResult)results.Dequeue();
                 object    o   = res.Result;
                 if (o is Exception)
                 {
                     Console.WriteLine(o);
                     throw (o as Exception);
                 }
                 //If we get here, everything looks good:
                 PathEdge pe = new PathEdge(e, LocalPath, RemotePath);
                 //Start sending e's packets into pe
                 pe.Subscribe();
                 ECB(true, pe, null);
             }
             catch (Exception cx) {
                 ECB(false, null, cx);
             }
         };
         //Make sure we hear the packets on this edge:
         e.Subscribe(_pel._pem, null);
         //Now make the rpc call:
         _pel._pem.Rpc.Invoke(e, results, "sys:pathing.create", LocalPath, RemotePath);
     }
     else
     {
         ECB(false, null, x);
     }
 }
        ///<summary>Makes the SecurityOverlord listen to the edge and instantiates
        ///a new SecurityAssociation for the insecure edge.  CreateSecurityAssociation
        ///is idempotent.</summary>
        protected override void WrapEdge(Edge edge)
        {
            edge.Subscribe(_so, null);

            if (edge.IsInbound)
            {
                lock (_sync) {
                    _edge_to_inbound.Add(edge, true);
                }
            }
            else
            {
                SecurityAssociation sa = _so.CreateSecurityAssociation(edge);
                lock (_sync) {
                    _edge_to_sa.Add(edge, sa);
                }
            }

            try {
                edge.CloseEvent += HandleEdgeClose;
            } catch {
                HandleEdgeClose(edge, EventArgs.Empty);
            }
        }
Example #14
0
 public ETServer(Edge e)
 {
     e.Subscribe(this, null);
     _e = e;
 }
Example #15
0
 public ETServer(Edge e) {
   e.Subscribe(this, null);
   _e = e;
 }
Example #16
0
 public void Subscribe()
 {
     _e.Subscribe(this, null);
 }
Example #17
0
 public void HandleEC(bool succ, Edge e, Exception x) {
   if( succ ) {
     /*
      * Got the underlying Edge, now do the path protocol
      */ 
     Channel results = new Channel(1);
     results.CloseEvent += delegate(object q, EventArgs args) {
       try {
         RpcResult res = (RpcResult)results.Dequeue();
         object o = res.Result;
         if(o is Exception) {
           Console.WriteLine(o);
           throw (o as Exception);
         }
         //If we get here, everything looks good:
         PathEdge pe = new PathEdge(e, LocalPath, RemotePath);
         //Start sending e's packets into pe
         pe.Subscribe();
         ECB(true, pe, null);
       }
       catch(Exception cx) {
         ECB(false, null, cx);
       }
     };
     //Make sure we hear the packets on this edge:
     e.Subscribe(_pel._pem, null);
     //Now make the rpc call:
     _pel._pem.Rpc.Invoke(e, results, "sys:pathing.create", LocalPath, RemotePath ); 
   }
   else {
     ECB(false, null, x);
   }
 }