]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
function parameter changes in fw_endpoint
authorMartin Molnar <molnar@sum.(none)>
Fri, 8 Feb 2008 17:01:56 +0000 (18:01 +0100)
committerMartin Molnar <molnar@sum.(none)>
Fri, 8 Feb 2008 17:01:56 +0000 (18:01 +0100)
fwp/libfwp/include/fwp_endpoint.h
fwp/libfwp/include/fwp_vres.h
fwp/libfwp/src/fwp_endpoint.c
fwp/libfwp/src/fwp_proto.c
fwp/libfwp/src/fwp_vres.c

index 6602311702d03ce9f8ed06eba97039cb2c3d9340..096ce2f96f638a091a8e42acaea4f3896d3ae76c 100644 (file)
@@ -29,13 +29,15 @@ struct fwp_endpoint{
 };
 
 void fwp_endpoint_table_init();
-int fwp_endpoint_destroy(struct fwp_endpoint *epoint);
+int fwp_endpoint_destroy(unsigned int id);
+inline int fwp_endpoint_is_valid(unsigned int id);
+inline int fwp_send_endpoint_is(unsigned int id);
 
-int fwp_send_endpoint_create(int node, int port, struct fwp_endpoint *epoint);
-int fwp_receive_endpoint_create(int port, struct fwp_endpoint *epoint);
+int fwp_send_endpoint_create(int node, int port, unsigned int id);
+int fwp_receive_endpoint_create(int port, unsigned int epoint_id);
 
-int fwp_send_endpoint_bind(unsigned int vres_id, struct fwp_endpoint *epoint);
-int fwp_send_endpoint_unbind(struct fwp_endpoint *epoint);
+int fwp_send_endpoint_bind(unsigned int vres_id, unsigned int epoint_id);
+int fwp_send_endpoint_unbind(unsigned int epoint_id);
 /*int fwp_endpoint_setqpolicy(struct fwp_endpoint *epoint, qpolicy);*/
 
 #endif /*_FWP_ENDPOINT_H */ 
index 60c6deddb9e3a389200ca4225bce3f0ad0acf6a7..5a965d98874ec7e918ae7064850f9cbde77b94af 100644 (file)
@@ -14,7 +14,7 @@ inline int fwp_vres_send(unsigned int id, struct fwp_msgb* msgb);
 
 inline int fwp_vres_is_valid(int id);
 
-inline void fwp_vres_endpoint_bind(unsigned int id, struct endpoint *epoint);
-inline void fwp_vres_endpoint_unbind(unsigned int id);
+inline int fwp_vres_endpoint_bind(unsigned int id, struct endpoint *epoint);
+inline int fwp_vres_endpoint_unbind(unsigned int id);
 
 #endif /* _FWP_VRES_H */
index 2c1a14270676ddde86bce867162ec70ecdfe895c..2a2646ce2a962541278ed617b49b008082ea986e 100644 (file)
@@ -24,6 +24,11 @@ inline int fwp_endpoint_is_valid(int id)
        return 0;
 }
 
+inline int fwp_send_endpoint_is(int id)
+{      
+       return (fwp_endpoint_table[id].type == FWP_SEND_EPOINT);
+}
+
 void fwp_endpoint_table_init(){
        int id;
 
@@ -136,20 +141,23 @@ int fwp_endpoint_destroy(unsigned int epoint_id)
  * Binds send endpoint to vres
  *
  * \param[in] vres_id identifier of vres
- * \param[in] epoint send endpoint to bind to vres
+ * \param[in] epoint_id send endpoint identifier
  *
  * \return On success returns 0. On error, negative error code is returned 
  */
-int fwp_send_endpoint_bind(unsigned int vres_id, unsigned int epoint_id)
+int fwp_send_endpoint_bind(unsigned int epoint_id, unsigned int vres_id)
 {
+       struct fwp_endpoint *epoint = &fwp_endpoint_table[epoint_id];
+       
        if ((epoint->status != FWP_EPOINT_UNBOUND) || 
            (epoint->type != FWP_SEND_EPOINT)){
                return (-EPERM);
        }
        
-       fwp_vres_endpoint_bind(vres_id, &fwp_endpoint_table[epoint_id]);
-       epoint->vres = vres_id;
-       epoint->status = FWP_EPOINT_BOUND;
+       if (!fwp_vres_endpoint_bind(vres_id, epoint)) {
+               epoint->vres = vres_id;  
+               epoint->status = FWP_EPOINT_BOUND;
+       }
        
        return 0;
 }
@@ -157,19 +165,20 @@ int fwp_send_endpoint_bind(unsigned int vres_id, unsigned int epoint_id)
 /**
  * Unbinds send endpoint from vres
  *
- * \param[in] epoint send endpoint to unbind 
+ * \param[in] id send endpoint identifier 
  * \return On success returns 0. On error, negative error code is returned 
  *
  */
-int fwp_send_endpoint_unbind(unsigned int epoint_id)
+int fwp_send_endpoint_unbind(unsigned int id)
 {
+       struct fwp_endpoint *epoint = &fwp_endpoint_table[id];
+
        if ((epoint->status != FWP_EPOINT_BOUND) || 
            (epoint->type != FWP_SEND_EPOINT)){
                return (-EPERM);
        }
        
-       fwp_vres_endpoint_unbind(vres_id);
-       epoint->vres = -1;
+       fwp_vres_endpoint_unbind(epoint->vres_id);
        epoint->status = FWP_EPOINT_UNBOUND;
 
        return 0;
index a1462957b38712c1ffa9bf3cfbebb6c503422ed7..84dcbd7ac30344ed9ee3a621c72ee2dae56e4ba0 100644 (file)
@@ -92,7 +92,7 @@ int fwp_send(unsigned int epoint_id, void *msg, size_t size, int flags)
        struct fwp_msgb *msgb;
        int rc;
 
-       if ((rc = fwp_vres_is_valid(vres_id) != 0))
+       if ((rc = fwp_endpoint_is_valid(vres_id) != 0))
                return rc;
 
        /*if (flags && MSG_DONTWAIT) 
index 109ef359da52bf0a13937bfca29a886762c9858c..9088ca533ae09d8d7205ca7899e6d7cacec8c6ca 100644 (file)
@@ -24,13 +24,13 @@ typedef unsigned int  fwp_vresid_t;
  * 
  */
 struct fwp_vres{
-       struct fwp_contract contract;
+       struct fwp_contract     contract;
        /* consideration: move tx_queue to endpoint */
-       struct fwp_msgq tx_queue;       /**< queue for messages to send */ 
-       struct fwp_endpoint  *epoint;   /**< endpoint bounded to this vres */ 
-       pthread_t tx_thread;
-       pthread_attr_t tx_thread_attr;
-       fwp_vres_status_t status;
+       struct fwp_msgq         tx_queue;  /**< queue for messages to send */ 
+       struct fwp_endpoint     *epoint;   /**< endpoint bounded to this vres */ 
+       pthread_t               tx_thread;
+       pthread_attr_t          tx_thread_attr;
+       fwp_vres_status_t       status;
 };
 
 static struct fwp_vres fwp_vres_table[FWP_VRES_MAX];
@@ -201,17 +201,17 @@ static void* fwp_vres_tx_thread(void *_vres)
        return NULL;
 }
 
-inline void fwp_vres_endpoint_bind(unsigned int vres_id, 
+inline int fwp_vres_endpoint_bind(unsigned int vres_id, 
                                   struct fwp_endpoint *epoint)
 {
        fwp_vres_table[vres_id].epoint = epoint;
+       return 0;
 }
 
-inline void fwp_vres_endpoint_unbind(unsigned int vres_id)
+inline int fwp_vres_endpoint_unbind(unsigned int vres_id)
 {
-       struct fwp_vres *vres = &fwp_vres_table[vres_id];
-       
-       vres->epoint = NULL;
+       fwp_vres_table[vres_id].epoint = NULL;
        /* TODO: consider what to do with pending messages */
-       fwp_vres_free_msgb(vres->tx_queue);
+       /* fwp_vres_free_msgb(vres->tx_queue); */
+       return 0;
 }