}
/**
- * Creates contract
+ * Allocates a contract and VRES and inserts the contract to
+ * contract_table.
*
- * FIXME: Not very helpful description :)
- *
* \param[in] contract User-level contract
*
* \return On success, returns contract descriptor, on error NULL is returned.
return 0;
}
-int fwp_mngt_service_vres_create(fwp_vres_d_t* vresdp)
+int fwp_mngt_service_vres_create(fwp_contract_d_t* contd, fwp_vres_d_t* vresdp)
{
fwp_contract_d_t contractd;
fwp_contract_data_t* contdata;
*vresdp = contdata->vresd;
FWP_DEBUG("Service vres negotiated\n");
+ *contd = contractd;
return 0;
}
/* Create discovery endpoint */
FWP_DEBUG("Service vres created\n");
- fwp_mngt_service_vres_create(&fwp_participant_mngr->vresd);
+ fwp_mngt_service_vres_create(&fwp_participant_mngr->service_contract,
+ &fwp_participant_mngr->vresd);
FWP_DEBUG("Discovery send endpoint created\n");
ret = fwp_send_endpoint_create(fwp_participant_mngr->id.node_id,
int fwp_mngt_recv(fwp_msg_type_t *type, fwp_participant_id_t *participant_id,
fwp_msgb_t *msgb);
-int fwp_mngt_service_vres_create(fwp_vres_d_t* fwp_service_vresd);
+int fwp_mngt_service_vres_create(fwp_contract_d_t* contd, fwp_vres_d_t* vresdp);
#endif /* _FWP_INTERNALS_ */
fwp_participant_id_t id;
unsigned int stream_id;
fwp_endpoint_d_t epointd; /**< endpoint descriptor for communication*/
+ fwp_contract_d_t service_contract; /**< Service contract descriptor */
fwp_vres_d_t vresd; /**< service vres descriptor */
gavl_node_t participant_tree_node;
fwp_contract_table_t contract_table; /**< participant`s contract table */
#define CONFIGURE_FWP_MY_STREAM_ID 3000
#define CONFIGURE_FWP_MNGR_ADDR "127.0.0.1"
+#include <error.h>
+#include <errno.h>
#include "fwp_confdefs.h"
#include "fwp.h"
participant = fwp_participant_new(&participant_info);
if (!participant)
return -1;
- ret = fwp_mngt_service_vres_create(&participant->vresd);
+ ret = fwp_mngt_service_vres_create(&participant->service_contract,
+ &participant->vresd);
if (ret < 0)
goto err_vres;
ret = fwp_send_endpoint_create(participant->id.node_id, participant->stream_id,
participant_id.node_id, participant_id.app_id);
return 0;
err_send:
+ fwp_send_endpoint_unbind(participant->epointd);
err_bind:
fwp_endpoint_destroy(participant->epointd);
err_endpoint:
* fwp_mngt_service_vres_create(), beacuse it doesn't delete
* the service contract. */
fwp_vres_destroy(participant->vresd);
+ fwp_contract_destroy(participant->service_contract);
err_vres:
fwp_participant_delete(participant);
return -1;
if (!(participant = fwp_participant_table_find(&participant_id))){
return -EPERM;
}
-
+
+ /* TODO: Check for errors */
fwp_participant_table_delete(participant);
fwp_send_endpoint_unbind(participant->epointd);
fwp_endpoint_destroy(participant->epointd);
participant_id.app_id);
ret = fwp_mngr_hello(msgb, participant_id);
if (ret < 0) {
- fwp_mngr_bye(msgb, participant_id);
+ ret = fwp_mngr_bye(msgb, participant_id);
+ if (ret < 0) {
+ error(0, errno, "Cannot send bye");
+ }
}
break;