2 * @file frescan_bwres_requests.h
4 * @brief FRESCAN bandwith reservation layer: requests
6 * This module contains the request type definition and queues. They are used
7 * to ask negotiation, renegotiation or cancel contracts.
13 * @author Daniel Sangorrin <daniel.sangorrin@unican.es>
17 #ifndef _FRESCAN_BWRES_REQUESTS_H_
18 #define _FRESCAN_BWRES_REQUESTS_H_
21 #include "frescan_data.h" // frescan_contract_t
22 #include "frescan_bwres_robjs.h" // frescan_robj_id_t
25 * frescan_request_data_t
27 * This are the data contained in a request to perform the negotiation of
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 (accepted or not)
36 * @final_values: the values for the ss after the negotiation
37 * @net: the network instance where this request belongs to
38 * @robj: a reply object to wait until a negotiation is completed
42 typedef uint16_t frescan_request_id_t; /* 0 .. MX_REQUESTS */
45 FRESCAN_REQ_NEG = 0, // Negotiate a contract
46 FRESCAN_REQ_RENEG = 1, // Renegotiate a contract
47 FRESCAN_REQ_CANCEL = 2, // Cancel a contract
48 FRESCAN_REP_NEG = 3, // Reply to (Re)Negotiate a contract
49 } frescan_request_type_t;
52 FRESCAN_REQ_ACCEPTED = 0, // the (re)negotiation is accepted
53 FRESCAN_REQ_NOT_ACCEPTED = 1, // the (re)negotiation is not accepted
54 } frescan_request_retval_t;
57 frescan_request_type_t type;
58 frescan_contract_t *contract;
60 frescan_node_t request_node;
61 frescan_request_id_t req;
62 frescan_request_retval_t return_value;
63 frescan_sa_final_values_t final_values;
64 frescan_network_t net;
65 frescan_robj_id_t robj;
66 } frescan_request_data_t;
69 * frescan_requests_init() - initializes the requests
71 * This function must be called at initialization time, before the rest of
72 * functions of this module.
74 * @max_ceiling: the max priority of the threads using this module
77 extern int frescan_requests_init(int max_ceiling);
80 * frescan_requests_alloc() - allocates a request
83 extern int frescan_requests_alloc(frescan_request_id_t *req);
86 * frescan_requests_free() - frees a request
89 extern int frescan_requests_free(frescan_request_id_t req);
92 * frescan_requests_get_data() - gets the data of the request
94 * @data: the data is obtained as a pointer an manipulated directly
95 * accesing to the members of the structure. Note that this is
96 * just an internal API so instead of using get/set functions we
97 * will just access to the members of the struc directly
100 extern int frescan_requests_get_data(frescan_request_id_t req,
101 frescan_request_data_t **data);
104 * frescan_requests_enqueue() - enqueue a request
107 extern int frescan_requests_enqueue(frescan_request_id_t req);
110 * frescan_requests_dequeue() - dequeue a request
113 extern int frescan_requests_dequeue(frescan_request_id_t *req);
115 #endif // _FRESCAN_BWRES_REQUESTS_H_