]> rtime.felk.cvut.cz Git - frescor/fna.git/blob - src_frescan/frescan_bwres_requests.h
b25e2031345b31ad00f833e3fd4ae513aec14b25
[frescor/fna.git] / src_frescan / frescan_bwres_requests.h
1 /*!
2  * @file frescan_bwres_requests.h
3  *
4  * @brief FRESCAN bandwith reservation layer: requests
5  *
6  * This module contains the request type definition and queues. They are used
7  * to ask negotiation, renegotiation or cancel contracts.
8  *
9  * @version 0.01
10  *
11  * @date 1-Apr-2008
12  *
13  * @author Daniel Sangorrin <daniel.sangorrin@unican.es>
14  *
15  */
16
17 #ifndef _FRESCAN_BWRES_REQUESTS_H_
18 #define _FRESCAN_BWRES_REQUESTS_H_
19
20 #include <stdint.h>
21 #include "frescan_data.h"        // frescan_contract_t
22 #include "frescan_bwres_robjs.h" // frescan_robj_id_t
23
24 /**
25  * frescan_request_data_t
26  *
27  * This are the data contained in a request to perform the negotiation of
28  * contracts.
29  *
30  * @type: indicates the type of the request
31  * @contract: a pointer to the contract to (re)negotiate
32  * @ss: the local sporadic server ID
33  * @request_node: the node that performed the request
34  * @req: the request id of the SLAVE to identify the request in the reply
35  * @return_value: the value returned in a Reply
36  * @net: the network instance where this request belongs to
37  * @robj: a reply object to wait until a negotiation is completed
38  *
39  */
40
41 typedef uint16_t frescan_request_id_t; /* 0 .. MX_REQUESTS */
42
43 typedef enum {
44         FRESCAN_REQ_NEG    =  0,  // Negotiate a contract
45         FRESCAN_REQ_RENEG  =  1,  // Renegotiate a contract
46         FRESCAN_REQ_CANCEL =  2,  // Cancel a contract
47         FRESCAN_REP_NEG    =  3,  // Reply to (Re)Negotiate a contract
48 } frescan_request_type_t;
49
50 typedef enum {
51         FRESCAN_REQ_ACCEPTED      =  0,  // the (re)negotiation is accepted
52         FRESCAN_REQ_NOT_ACCEPTED  =  1,  // the (re)negotiation is not accepted
53         FRESCAN_REQ_ERROR         =  2,  // error during the (re)negotiation
54 } frescan_request_retval_t;
55
56 typedef struct {
57         frescan_request_type_t   type;
58         frescan_contract_t       *contract;
59         frescan_ss_t             ss;
60         frescan_node_t           request_node;
61         frescan_request_id_t     req;
62         frescan_request_retval_t return_value;
63         frescan_network_t        net;
64         frescan_robj_id_t        robj;
65 } frescan_request_data_t;
66
67 /**
68  * frescan_requests_init() - initializes the requests
69  *
70  * This function must be called at initialization time, before the rest of
71  * functions of this module.
72  *
73  * @max_ceiling: the max priority of the threads using this module
74  */
75
76 extern int frescan_requests_init(int max_ceiling);
77
78 /**
79  * frescan_requests_alloc() - allocates a request
80  */
81
82 extern int frescan_requests_alloc(frescan_request_id_t *req);
83
84 /**
85  * frescan_requests_free() - frees a request
86  */
87
88 extern int frescan_requests_free(frescan_request_id_t req);
89
90 /**
91  * frescan_requests_get_data() - gets the data of the request
92  *
93  * @data: the data is obtained as a pointer an manipulated directly
94  *        accesing to the members of the structure. Note that this is
95  *        just an internal API so instead of using get/set functions we
96  *        will just access to the members of the struc directly
97  */
98
99 extern int frescan_requests_get_data(frescan_request_id_t   req,
100                                      frescan_request_data_t **data);
101
102 /**
103  * frescan_requests_enqueue() - enqueue a request
104  */
105
106 extern int frescan_requests_enqueue(frescan_request_id_t req);
107
108 /**
109  * frescan_requests_dequeue() - dequeue a request
110  */
111
112 extern int frescan_requests_dequeue(frescan_request_id_t *req);
113
114 #endif // _FRESCAN_BWRES_REQUESTS_H_