]> rtime.felk.cvut.cz Git - frescor/fwp.git/blob - fwp/lib/mngt/fwp_contract.h
Futher include file cleaning
[frescor/fwp.git] / fwp / lib / mngt / fwp_contract.h
1 #ifndef _FWP_CONTRACT_H
2 #define _FWP_CONTRACT_H
3
4 #include "fwp_vres.h"
5
6 /*
7  *typedef struct mfrsh_contract_ops{
8  *      fwp_contract_d_t (*create)(fwp_contract_t *contract);
9  *      int              (*reserve)(fwp_contract_d_t contractd);
10  *      int              (*commit)(fwp_contract_d_t contractd);
11  *} mfrsh_contract_ops_t;
12  *
13  * typedef struct mfrsh_contract_d {
14  *      mfrsh_resource_id_t     resource_id;
15  *      mfrsh_contract_id_t     contract_id;
16  *}
17  */
18
19 /**
20  * FWP contract.
21  * It is an external representation of contract intented for application 
22  * programmer.
23  * 
24  */
25 typedef 
26 struct fwp_contract {
27         int budget;             /**< bytes per period */
28         int period_usec;        /**< all time units are in microseconds */
29 } fwp_contract_t;
30
31 struct fwp_contract_data;
32 typedef struct fwp_contract_data* fwp_contract_d_t;
33
34 fwp_contract_d_t fwp_contract_create(fwp_contract_t *contract);
35 int  fwp_contract_negotiate(fwp_contract_d_t contract, fwp_vres_d_t *vresdp);
36 int fwp_contract_is_negotiated(fwp_contract_d_t contract);
37
38
39 #ifdef _FWP_INTERNALS_
40
41 #include "ul_gavlcust.h"
42 #include "ul_list.h"
43 #include <stdlib.h>
44
45 /**< Contract Status */ 
46 /*typedef enum {
47         FWP_CONT_INVALID =      0,
48         FWP_CONT_REQUESTED =    1,
49         FWP_CONT_REJECTED =     2,
50         FWP_CONT_NEGOTIATED =   3,
51         FWP_CONT_ACCEPTED =     4
52 } fwp_contract_status_t;*/
53
54 typedef enum {
55         FWP_CONT_NOTNEGOTIATED  = 0,
56         FWP_CONT_RESERVED       = 1,    
57         FWP_CONT_NEGOTIATED     = 2
58 } fwp_contract_status_t;
59
60 typedef struct fwp_contract_data fwp_contract_data_t;
61 typedef fwp_vres_id_t fwp_contract_id_t;
62
63 /**
64  * FWP contract.
65  * It is an internal representation of contract.
66  * 
67  */
68 typedef 
69 struct fwp_contract_data {
70         fwp_contract_id_t               id;     
71         /**< contract specified by user */
72         fwp_contract_t                  contract;
73         /**< parameters from contract negotiated for vres */
74         fwp_vres_params_t               vres_params;
75         /**< the address of agent from that the contract comes */
76         /*fwp_transaction_id_t          trans_id;*/     
77         /* pointer to fwp_vres or fwp_participant */
78         /*void                          *priv; */
79         fwp_vres_d_t                    vresd;
80         fwp_contract_status_t           status;
81
82         ul_list_node_t                  list_node;
83         gavl_node_t                     tree_node;      
84 };
85
86 static inline fwp_contract_data_t* fwp_contract_data_new()
87 {
88         return memset(malloc(sizeof (fwp_contract_data_t)),'\0', 
89                         sizeof(fwp_contract_data_t));
90 }
91
92 int fwp_contract_reserve(fwp_contract_d_t contractd);
93 int fwp_contract_commit(fwp_contract_d_t contractd, fwp_vres_d_t *vresdp);
94
95 #endif /*_FWP_INTERNALS_ */
96 #endif /*_FWP_CONTRACT_H */