};
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 */
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 */
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;
* 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;
}
/**
* 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;
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)
*
*/
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];
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;
}