]> rtime.felk.cvut.cz Git - frescor/fna.git/blob - src_frescan/frescan_bwres_requests.h
002dd913a1b16f5f54e033486b2da38b25863ff5
[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  * @license
16  *
17  * -----------------------------------------------------------------------
18  *  Copyright (C) 2006 - 2008 FRESCOR consortium partners:
19  *
20  *    Universidad de Cantabria,              SPAIN
21  *    University of York,                    UK
22  *    Scuola Superiore Sant'Anna,            ITALY
23  *    Kaiserslautern University,             GERMANY
24  *    Univ. Politécnica  Valencia,           SPAIN
25  *    Czech Technical University in Prague,  CZECH REPUBLIC
26  *    ENEA                                   SWEDEN
27  *    Thales Communication S.A.              FRANCE
28  *    Visual Tools S.A.                      SPAIN
29  *    Rapita Systems Ltd                     UK
30  *    Evidence                               ITALY
31  *
32  *    See http://www.frescor.org for a link to partners' websites
33  *
34  *           FRESCOR project (FP6/2005/IST/5-034026) is funded
35  *        in part by the European Union Sixth Framework Programme
36  *        The European Union is not liable of any use that may be
37  *        made of this code.
38  *
39  *  This file is part of FRESCAN
40  *
41  *  FRESCAN is free software; you can  redistribute it and/or  modify
42  *  it under the terms of  the GNU General Public License as published by
43  *  the Free Software Foundation;  either  version 2, or (at  your option)
44  *  any later version.
45  *
46  *  FRESCAN  is distributed  in  the hope  that  it  will  be useful,  but
47  *  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
48  *  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
49  *  General Public License for more details.
50  *
51  *  You should have  received a  copy of  the  GNU  General Public License
52  *  distributed  with  FRESCAN;  see file COPYING.   If not,  write to the
53  *  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
54  *  02111-1307, USA.
55  *
56  * As a special exception, including FRESCAN header files in a file,
57  * instantiating FRESCAN generics or templates, or linking other files
58  * with FRESCAN objects to produce an executable application, does not
59  * by itself cause the resulting executable application to be covered
60  * by the GNU General Public License. This exception does not
61  * however invalidate any other reasons why the executable file might be
62  * covered by the GNU Public License.
63  * -----------------------------------------------------------------------
64  *
65  */
66
67 #ifndef _FRESCAN_BWRES_REQUESTS_H_
68 #define _FRESCAN_BWRES_REQUESTS_H_
69
70 #include <stdint.h>
71 #include "frescan_bwres_robjs.h" // frescan_robj_id_t
72 #include "frescan_data.h" // frescan_ss_t
73
74 /**
75  * frescan_request_data_t
76  *
77  * This are the data contained in a request to perform the negotiation of
78  * contracts.
79  *
80  * @type: indicates the type of the request
81  * @contract: a pointer to the contract to (re)negotiate
82  * @ss: the local sporadic server ID
83  * @request_node: the node that performed the request
84  * @req: the request id of the SLAVE to identify the request in the reply
85  * @return_value: the value returned in a Reply (accepted or not)
86  * @final_values: the values for the ss after the negotiation
87  * @net: the network instance where this request belongs to
88  * @robj: a reply object to wait until a negotiation is completed
89  *
90  */
91
92 typedef uint16_t frescan_request_id_t; /* 0 .. MX_REQUESTS */
93
94 typedef enum {
95         FRESCAN_REQ_NEG    =  0,  // Negotiate a contract
96         FRESCAN_REQ_RENEG  =  1,  // Renegotiate a contract
97         FRESCAN_REQ_CANCEL =  2,  // Cancel a contract
98         FRESCAN_REP_DEC_BUDGET =  3,  // Mode Change B-
99         FRESCAN_REP_INC_BUDGET =  4,  // Mode Change B+
100         FRESCAN_REP_NEG    =  5,  // Reply to (Re)Negotiate a contract
101 } frescan_request_type_t;
102
103 typedef enum {
104         FRESCAN_REQ_ACCEPTED      =  0,  // the (re)negotiation is accepted
105         FRESCAN_REQ_NOT_ACCEPTED  =  1,  // the (re)negotiation is not accepted
106 } frescan_request_retval_t;
107
108 typedef struct {
109         frescan_request_type_t    type;
110         frsh_contract_t           *contract;
111         frescan_ss_t              ss;
112         frescan_node_t            request_node;
113         frescan_request_id_t      req;
114         frescan_request_retval_t  return_value;
115         frescan_server_params_t   final_values;
116         frescan_network_t         net;
117         frescan_robj_id_t         robj;
118 } frescan_request_data_t;
119
120 /**
121  * frescan_requests_init() - initializes the requests
122  *
123  * This function must be called at initialization time, before the rest of
124  * functions of this module.
125  *
126  * @max_ceiling: the max priority of the threads using this module
127  */
128
129 extern int frescan_requests_init(int max_ceiling);
130
131 /**
132  * frescan_requests_alloc() - allocates a request
133  */
134
135 extern int frescan_requests_alloc(frescan_request_id_t *req);
136
137 /**
138  * frescan_requests_free() - frees a request
139  */
140
141 extern int frescan_requests_free(frescan_request_id_t req);
142
143 /**
144  * frescan_requests_get_data() - gets the data of the request
145  *
146  * @data: the data is obtained as a pointer an manipulated directly
147  *        accesing to the members of the structure. Note that this is
148  *        just an internal API so instead of using get/set functions we
149  *        will just access to the members of the struc directly
150  */
151
152 extern int frescan_requests_get_data(frescan_request_id_t   req,
153                                      frescan_request_data_t **data);
154
155 /**
156  * frescan_requests_enqueue() - enqueue a request
157  */
158
159 extern int frescan_requests_enqueue(frescan_request_id_t req);
160
161 /**
162  * frescan_requests_dequeue() - dequeue a request
163  */
164
165 extern int frescan_requests_dequeue(frescan_request_id_t *req);
166
167 #endif // _FRESCAN_BWRES_REQUESTS_H_