]> rtime.felk.cvut.cz Git - frescor/forb.git/blobdiff - src/port.h
forb: Split forb_port_destroy() to stop and destroy phases
[frescor/forb.git] / src / port.h
index 8139f4e4b81681077aebcfb45230355dd54f0f82..4d0d010c8a6d2bdf9b10bcf34f0f33ad922668f7 100644 (file)
@@ -1,3 +1,59 @@
+/**************************************************************************/
+/* ---------------------------------------------------------------------- */
+/* Copyright (C) 2006 - 2008 FRESCOR consortium partners:                */
+/*                                                                       */
+/*   Universidad de Cantabria,              SPAIN                        */
+/*   University of York,                    UK                           */
+/*   Scuola Superiore Sant'Anna,            ITALY                        */
+/*   Kaiserslautern University,             GERMANY                      */
+/*   Univ. Politécnica  Valencia,           SPAIN                       */
+/*   Czech Technical University in Prague,  CZECH REPUBLIC               */
+/*   ENEA                                   SWEDEN                       */
+/*   Thales Communication S.A.              FRANCE                       */
+/*   Visual Tools S.A.                      SPAIN                        */
+/*   Rapita Systems Ltd                     UK                           */
+/*   Evidence                               ITALY                        */
+/*                                                                       */
+/*   See http://www.frescor.org for a link to partners' websites         */
+/*                                                                       */
+/*          FRESCOR project (FP6/2005/IST/5-034026) is funded            */
+/*       in part by the European Union Sixth Framework Programme         */
+/*       The European Union is not liable of any use that may be         */
+/*       made of this code.                                              */
+/*                                                                       */
+/*                                                                       */
+/*  This file is part of FORB (Frescor Object Request Broker)            */
+/*                                                                       */
+/* FORB is free software; you can redistribute it and/or modify it       */
+/* under terms of the GNU General Public License as published by the     */
+/* Free Software Foundation; either version 2, or (at your option) any   */
+/* later version.  FORB is distributed in the hope that it will be       */
+/* useful, but WITHOUT ANY WARRANTY; without even the implied warranty   */
+/* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   */
+/* General Public License for more details. You should have received a   */
+/* copy of the GNU General Public License along with FORB; see file      */
+/* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,  */
+/* Cambridge, MA 02139, USA.                                             */
+/*                                                                       */
+/* As a special exception, including FORB header files in a file,        */
+/* instantiating FORB generics or templates, or linking other files      */
+/* with FORB objects to produce an executable application, does not      */
+/* by itself cause the resulting executable application to be covered    */
+/* by the GNU General Public License. This exception does not            */
+/* however invalidate any other reasons why the executable file might be  */
+/* covered by the GNU Public License.                                    */
+/**************************************************************************/
+
+/**
+ * @file   port.h
+ * @author Michal Sojka <sojkam1@fel.cvut.cz>
+ * @date   Sun Oct 12 17:36:39 2008
+ * 
+ * @brief  Declarations of port types and functions.
+ * 
+ * 
+ */
+
 #ifndef FORB_PORT_H
 #define FORB_PORT_H
 
 #include <forb/syncobj.h>
 
 struct forb_proto;
+struct forb_peer;
 
 /**
- * Represents one (of possibly multiple) ports using a specific
- * FORB transport protocol (see ::forb_proto).
+ * Description of a port. Needs to be filled for forb_register_port().
  */
-struct forb_port {
+struct forb_port_desc {
        const struct forb_proto *proto;   /**< Protocol used on this port */
        void *proto_priv;                 /**< Protocol specific data */
+       void *addr;                       /**< Port's address in a protocol specific format. */
+};
+
+/**
+ * Represents one (of possibly multiple) ports using a specific
+ * FORB transport protocol (see ::forb_proto).
+ *
+ * Every port runs its own thread for receiving messages
+ * (forb_iop_receiver_thread()) and another thread
+ * (forb_iop_discovery_thread()) for periodic broadcasting of HELLO
+ * messages to discover peers connected to the same network.
+ */
+typedef struct forb_port {
+       struct forb_port_desc desc;       /**< Description of the port */
        forb_t *forb;                     /**< FORB, this port is registered in. */
        fosa_thread_id_t receiver_thread; /**< The thread running forb_port_receiver_thread() */
        fosa_thread_id_t discovery_thread;/**< The thread for periodic sending HELLO messages */
        forb_syncobj_t hello;             /**< Synchronization object for signaling the discovery thread to send the hello messages now. */
        forb_syncobj_t reply_processed;   /**< Synchronization object for signaling the receiver thread to continue processing after the reply is processed by a stub. */
-       CDR_Codec codec;                  /**< Receiving buffer for receiver thread */
-       void *addr;                       /**< Port's address in a protocol specific format. */
+       FORB_CDR_Codec codec;             /**< Receiving buffer for receiver thread */
        ul_list_node_t node;              /**< Node in forb's port list */
-       gavl_cust_root_field_t peers;     /**< Peers discovered on this port by discovery protocol */
+       ul_list_head_t peers;             /**< Peers discovered on this port by discovery protocol */
        bool finish;                      /**< True when the threads should finish their execution, false otherwise. */
-};
 
-typedef struct forb_port forb_port_t;
+       /** Peer discovered by another mean than discovery
+        * protocol. This field may be set by the protocol whenever it
+        * receives a message (e.g. request) from a new peer. This is
+        * to overcome limitations of discovery protocol on unreliable
+        * medium. */
+       struct forb_peer *new_peer;
+} forb_port_t;
 
 UL_LIST_CUST_DEC(forb_port,    /* cust_prefix */
                 forb_t,        /* cust_head_t */
@@ -33,7 +107,8 @@ UL_LIST_CUST_DEC(forb_port,  /* cust_prefix */
                 ports,         /* cust_head_field */
                 node)          /* cust_node_field */
 
-int forb_register_port(forb_t *forb, forb_port_t *port);
+int forb_register_port(forb_orb orb, forb_port_t *port);
+void forb_stop_port(forb_port_t *port);
 void forb_destroy_port(forb_port_t *port);