return 0;
}
-static fwp_vres_t* fwp_vres_alloc()
+fwp_vres_id_t fwp_vres_get_id(fwp_vres_d_t vresd)
+{
+ fwp_vres_t *vres = vresd;
+
+ return (fwp_vres_table.entry - vres);
+}
+
+fwp_vres_d_t fwp_vres_alloc()
{
int i;
unsigned int nr_vres;
vres->status = FWP_VRES_FREE;
}
+int fwp_vres_set_params(fwp_vres_params_t *params, fwp_vres_d_t vresd)
+{
+ fwp_vres_t *vres = vresd;
+ int rv;
+
+ /* copy vres paramters into vres structure */
+ memcpy(&vres->params, params, sizeof(struct fwp_vres_params));
+ if (vres->status != FWP_VRES_INACTIVE) {
+ /* Consider: hwo to change parameters when vres is in running
+ * state - restart thread, set vres_resched flag
+ */
+ pthread_cancel(vres->tx_thread);
+ close(vres->ac_sockd);
+ /* or set vres_resched flag and return */
+ } else{
+ /* initialize msg queue */
+ fwp_msgq_init(&vres->tx_queue);
+ }
+ /* open ac socket */
+ if ((rv = fwp_vres_ac_open(vres->params.ac_id)) < 0) {
+ goto err;
+ }
+ vres->ac_sockd = rv;
+
+ pthread_attr_init(&vres->tx_thread_attr);
+ if ((rv = pthread_create(&vres->tx_thread, &vres->tx_thread_attr,
+ fwp_vres_tx_thread, (void*) vres)) != 0){
+ goto err;
+
+ }
+ vres->status = FWP_VRES_UNBOUND;
+
+/* return vres->params.id; */
+ return 0;
+err:
+ fwp_vres_free(vres);
+ return rv;
+}
+
int fwp_vres_create(fwp_vres_params_t *params, fwp_vres_d_t *vresdp)
{
int rv;