]> rtime.felk.cvut.cz Git - frescor/forb.git/blobdiff - src/proto.h
Added register callback for protocols
[frescor/forb.git] / src / proto.h
index c68c423410740b972db91b342b1c75da929f0c13..140e0c7145377ae759187e6febf7dc61c3df75c3 100644 (file)
@@ -49,7 +49,7 @@
  * @author Michal Sojka <sojkam1@fel.cvut.cz>
  * @date   Thu Aug 28 10:36:23 2008
  * 
- * @brief  FORB transport protocol module
+ * @brief  FORB transport protocol declarations
  * 
  * 
  */
@@ -104,9 +104,10 @@ struct forb_proto {
         * 
         * @param peer Peer to destroy
         * 
-        * @return Zero on success, negatove error code on error.
+        * @note The memory allocated by @a deserialize_addr (if any)
+        * is deallocated by FORB and should not be deallocated here.
         */
-       int (*peer_destroy)(forb_peer_t *peer);
+       void (*peer_destroy)(forb_peer_t *peer);
        /** 
         * Receives data through a port
         * 
@@ -136,13 +137,23 @@ struct forb_proto {
        size_t (*broadcast)(forb_port_t *port, const void *buf, size_t len);
 
        /** Serializes the protocol specific address */
-       CORBA_boolean (*serialize_addr)(CDR_Codec *codec, const void *addr);
+       CORBA_boolean (*serialize_addr)(FORB_CDR_Codec *codec, const void *addr);
+
+       /** Deserializes the protocol specific address. The memory for
+        * storing the address should be allocated by forb_malloc(). */
+       CORBA_boolean (*deserialize_addr)(FORB_CDR_Codec *codec, void **addr);
 
-       /** Deserializes the protocol specific address */
-       CORBA_boolean (*deserialize_addr)(CDR_Codec *codec, void **addr);
+       /** Converts protocol specific address to string */
+       size_t (*addr2str)(char *dest, size_t maxlen, const void *addr);
+
+       /**
+        * Callback caled when the port is registered to FORB just
+        * before reception and discovery threads are started.
+        */
+       void (*register_cb)(forb_port_t *port);
 };
 
-size_t forb_proto_send(forb_peer_t *peer, CDR_Codec *codec);
+size_t forb_proto_send(forb_peer_t *peer, FORB_CDR_Codec *codec);
 
 forb_peer_t *
 forb_get_next_hop(forb_t *forb, forb_server_id *server, fosa_abs_time_t *timeout);