1 #ifndef _FWP_CONTRACT_H
2 #define _FWP_CONTRACT_H
7 *typedef struct mfrsh_contract_ops{
8 * fwp_contract_d_t (*create)(fwp_contract_t *contract);
9 * int (*destroy)(fwp_contract_t *contract);
10 * int (*reserve)(fwp_contract_d_t contractd);
11 * int (*commit)(fwp_contract_d_t contractd);
12 * int (*cancel)(fwp_contract_d_t contractd);
13 * int (*commute)(fwp_contract_d_t origin,
14 * fwp_contract_d_t contractd);
15 *} mfrsh_contract_ops_t;
17 * typedef struct mfrsh_contract_d {
18 * mfrsh_resource_id_t resource_id;
19 * mfrsh_contract_id_t contract_id;
25 * It is an external representation of contract intented for application
31 int budget; /**< bytes per period */
32 int period_usec; /**< all time units are in microseconds */
36 struct fwp_contract_data;
37 typedef struct fwp_contract_data* fwp_contract_d_t;
39 fwp_contract_d_t fwp_contract_create(fwp_contract_t *contract);
40 int fwp_contract_destroy(fwp_contract_d_t contractd);
41 int fwp_contract_negotiate(fwp_contract_d_t contract, fwp_vres_d_t *vresdp);
42 int fwp_contract_cancel(fwp_contract_d_t contractd);
43 int fwp_contract_is_negotiated(fwp_contract_d_t contract);
44 int fwp_contract_cancel(fwp_contract_d_t contractd);
46 #ifdef _FWP_INTERNALS_
48 #include "ul_gavlcust.h"
52 /**< Contract Status */
55 FWP_CONT_REQUESTED = 1,
56 FWP_CONT_REJECTED = 2,
57 FWP_CONT_NEGOTIATED = 3,
59 } fwp_contract_status_t;*/
62 FWP_CONT_NOTNEGOTIATED = 0,
63 FWP_CONT_RESERVED = 1,
64 FWP_CONT_NEGOTIATED = 2
65 } fwp_contract_status_t;
67 typedef struct fwp_contract_data fwp_contract_data_t;
68 typedef fwp_vres_id_t fwp_contract_id_t;
72 * This is an internal representation of contract in every FWP application.
74 struct fwp_contract_data {
76 /** contract specified by user */
77 fwp_contract_t contract;
78 /** parameters from contract negotiated for vres */
79 fwp_vres_params_t vres_params;
80 /* * the address of agent from that the contract comes */
81 /*fwp_transaction_id_t trans_id;*/
82 /* pointer to fwp_vres or fwp_participant */
85 fwp_contract_status_t status;
86 /** For future: exclude (replaced) contract
87 fwp_contract_d_t contex; */
89 ul_list_node_t list_node;
90 gavl_node_t tree_node;
95 static inline fwp_contract_data_t* fwp_contract_data_new()
97 fwp_contract_data_t *contdata = malloc(sizeof (fwp_contract_data_t));
100 return memset(contdata,'\0', sizeof(fwp_contract_data_t));
103 static inline void fwp_contract_data_delete(fwp_contract_data_t* contdata)
108 int fwp_contract_reserve(fwp_contract_d_t contractd);
109 int fwp_contract_commit(fwp_contract_d_t contractd, fwp_vres_d_t *vresdp);
111 /* TODO: Implement fwp_contract_set_state function
112 * int fwp_contract_set_state(fwp_contract_state_t state)
115 #endif /*_FWP_INTERNALS_ */
116 #endif /*_FWP_CONTRACT_H */