po_hi_storage.h 20.9 KB
Newer Older
jdelange's avatar
jdelange committed
1
2
3
4
5
6
7
8
9
10
11
12
13
/*
 * This is a part of PolyORB-HI-C distribution, a minimal
 * middleware written for generated code from AADL models.
 * You should use it with the Ocarina toolsuite.
 *
 * For more informations, please visit http://assert-project.net/taste
 *
 * Copyright (C) 2011, European Space Agency.
 */

#ifndef __PO_HI_STORAGE_H__
#define __PO_HI_STORAGE_H__

jdelange's avatar
jdelange committed
14
15
16
17
#include <po_hi_types.h>
#include <deployment.h>
#include <request.h>

jdelange's avatar
jdelange committed
18
19
20
21
22
23
#include <deployment.h>
/* included files from the generated code */

#include <po_hi_config.h>
#include <po_hi_returns.h>
#include <po_hi_monitor.h>
24
#include <po_hi_time.h>
jdelange's avatar
jdelange committed
25
26
27
28
29
30
#include <po_hi_task.h>
#include <po_hi_debug.h>
#include <po_hi_protected.h>
#include <po_hi_utils.h>


jdelange's avatar
jdelange committed
31
32
#ifndef __PO_HI_STORAGE_FILENAME_MAXLENGTH
#define __PO_HI_STORAGE_FILENAME_MAXLENGTH 100
jdelange's avatar
jdelange committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#endif

#ifndef __PO_HI_STORAGE_DIRECTORY_MAXFILES
#define __PO_HI_STORAGE_DIRECTORY_MAXFILES 100
#endif

#ifndef __PO_HI_STORAGE_PACKET_SIZE
#define __PO_HI_STORAGE_PACKET_SIZE sizeof(__po_hi_request_t)
#endif


#ifndef __PO_HI_STORAGE_MAX_PACKETS
#define __PO_HI_STORAGE_MAX_PACKETS 100
#endif

#ifndef __PO_HI_STORAGE_MAX_PACKET_STORES
#define __PO_HI_STORAGE_MAX_PACKET_STORES 100
#endif

52
53
54
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
#include <sys/types.h>
#include <sys/stat.h>
55
#include <dirent.h>
56
57
58
#include <fcntl.h>
#include <unistd.h>
#endif
jdelange's avatar
jdelange committed
59
60
61
62
63

typedef struct
{
   int         file_id;
   char        filename[__PO_HI_STORAGE_FILENAME_MAXLENGTH];
64
65
66
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
   int         fd;
#endif
jdelange's avatar
jdelange committed
67
68
69
70
71
} __po_hi_storage_file_t;

typedef struct
{
   int         dir_id;
72
   int         nb_files;
73
   char        dirname[__PO_HI_STORAGE_FILENAME_MAXLENGTH];
jdelange's avatar
jdelange committed
74
   char        filename[__PO_HI_STORAGE_DIRECTORY_MAXFILES][__PO_HI_STORAGE_FILENAME_MAXLENGTH];
jdelange's avatar
jdelange committed
75
76
} __po_hi_storage_dir_t;

jdelange's avatar
jdelange committed
77
78
79
80
81
#ifndef __PO_HI_STORAGE_PACKET_SIZE
#define __PO_HI_STORAGE_PACKET_SIZE sizeof(__po_hi_request_t __po_hi_storage_packet_t)
#endif

typedef __po_hi_uint8_t __po_hi_storage_packet_t;
jdelange's avatar
jdelange committed
82
83
84

typedef struct
{
jdelange's avatar
jdelange committed
85
86
87
88
89
90
   __po_hi_uint8_t            packets[__PO_HI_STORAGE_PACKET_SIZE * __PO_HI_STORAGE_MAX_PACKETS];    /*< packets contained int he store (structured bytes)  >*/
   int                        n_packets;                               /*< amount of packets stored in the store                                            >*/
   int                        capacity;                                /*< actual size of the store, meaning the number of packets it can store             >*/
   int                        read_off;                                /*< read offset in the buffer in terms of number of packets                          >*/
   int                        write_off;                               /*< write offset in the buffer in terns of number of packets                         >*/
   __po_hi_mutex_t            mutex;                                   /*< ensure buffer protection from concurrent accesses                                >*/
jdelange's avatar
jdelange committed
91
92
93
} __po_hi_storage_packet_store_t;


jdelange's avatar
jdelange committed
94
95
96
97
98
99
100
typedef struct
{
   __po_hi_uint32_t    n_packets;   /*< number of packets in the store >   */
   __po_hi_uint32_t    n_avail;     /*< available packets size >           */
   __po_hi_uint8_t     full;        /*< is the store full ?>               */
}__po_hi_storage_packet_store_status_t;

jdelange's avatar
jdelange committed
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 * Files operations
 */

/**
 * \fn __po_hi_storage_file_open
 *
 * \brief Open a file designated as filename and complete the content of the
 * second parameter.
 *
 * Please note that this function just fills the structure passed as the
 * second parameter. It does not create the file, this is supposed to be
 * done by a separate function.
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS: successful operation
 *  - __PO_HI_TOOMANY: too may files are open at this time, cannot open more.
119
 *  - __PO_HI_INVALID: supplied filename is invalid (invalid characters or too long)
jdelange's avatar
jdelange committed
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
 */
int __po_hi_storage_file_open (const char* filename, __po_hi_storage_file_t*);

/**
 * \fn __po_hi_storage_file_create
 *
 * \brief Create the file on the filesystem.
 *
 * This function creates the file with the properties stored in the
 * second argument. The argument is the file to create.
 * The function can return the following values:
 * - __PO_HI_SUCCESS          : Successful operation
 * - __PO_HI_ERROR_UNKNOWN    : Unknown error
 * - __PO_HI_ERROR_EXISTS     : File already exists
 * - __PO_HI_INVALID          : Invalid file
 */
136
int __po_hi_storage_file_create (__po_hi_storage_file_t* file);
jdelange's avatar
jdelange committed
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203

/**
 * \fn __po_hi_storage_file_read
 *
 * \brief Read part of a file.
 *
 * This function read a fixed length (part of) a file and
 * stores the content in a buffer. First argument is a file 
 * (previously opened with __po_hi_storage_file_open() ), the
 * second argument is the buffer to store the file content
 * while the last argument is the size to be read.
 * - __PO_HI_SUCCESS          : Successful operation
 * - __PO_HI_ERROR_UNKNOWN    : Unknown error
 * - __PO_HI_INVALID          : Invalid file
 */
int __po_hi_storage_file_read (const __po_hi_storage_file_t* file, char* buf, int bufsize);

/**
 * \fn __po_hi_storage_file_write
 *
 * \brief Write part of a file.
 *
 * This function write a buffer in a file, at offset 0. 
 * First argument is a file 
 * (previously opened with __po_hi_storage_file_open() ), the
 * second argument is the buffer to write
 * while the last argument is the size to be written.
 * - __PO_HI_SUCCESS          : Successful operation
 * - __PO_HI_ERROR_UNKNOWN    : Unknown error
 * - __PO_HI_INVALID          : Invalid file
 */
int __po_hi_storage_file_write (const __po_hi_storage_file_t* file, char* buf, int bufsize);

/**
 * \fn __po_hi_storage_file_delete
 *
 * \brief Delete a file.
 *
 * This function delete a file. The first argument is the file to be deleted
 * (previously opened with __po_hi_storage_file_open() ).
 * Result code are the following:
 * - __PO_HI_SUCCESS          : Successful operation
 * - __PO_HI_ERROR_UNKNOWN    : Unknown error
 * - __PO_HI_INVALID          : Invalid file
 * - __PO_HI_ERROR_NOEXISTS   : The file does not exists
 */
int __po_hi_storage_file_delete (const __po_hi_storage_file_t* file);

/**
 * \fn __po_hi_storage_file_rename
 *
 * \brief Rename a file.
 *
 * This function renames a file. The first argument is the original file
 * and the second argument the destination file.
 * (both were reviously opened with __po_hi_storage_file_open() ).
 * This function assumes there is no file that has already the name of the
 * second argument.
 *
 * Result code are the following:
 * - __PO_HI_SUCCESS          : Successful operation
 * - __PO_HI_ERROR_UNKNOWN    : Unknown error
 * - __PO_HI_INVALID          : Invalid file (either source or destination)
 * - __PO_HI_ERROR_NOEXISTS   : The source file (first argument) does not exists
 * - __PO_HI_ERROR_EXISTS     : The destination file (second argument) already
 *                              exists.
 */
204
int __po_hi_storage_file_rename (const __po_hi_storage_file_t* oldfile, const __po_hi_storage_file_t* newfile);
jdelange's avatar
jdelange committed
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239

/**
 * \fn __po_hi_storage_file_append
 *
 * \brief Append content to a file.
 *
 * This function appends some data to an existing file.
 * This is as writting data at the last offset of the file.
 * First argument is a file (previously opened with 
 * __po_hi_storage_file_open() ), the
 * second argument is the buffer to write
 * while the last argument is the size to be written.
 * - __PO_HI_SUCCESS          : Successful operation
 * - __PO_HI_ERROR_UNKNOWN    : Unknown error
 * - __PO_HI_INVALID          : Invalid file
 */
int __po_hi_storage_file_append (const __po_hi_storage_file_t* file, char* buf, int bufsize);

/**
 * \fn __po_hi_storage_file_replace
 *
 * \brief Replace a file.
 *
 * This function replace a file with another one. The first argument is the original file
 * and the second argument the file to be replaced.
 * (both were reviously opened with __po_hi_storage_file_open() ).
 * This function assumes there is already one file labelled under the
 * destination file.
 *
 * Result code are the following:
 * - __PO_HI_SUCCESS          : Successful operation
 * - __PO_HI_ERROR_UNKNOWN    : Unknown error
 * - __PO_HI_INVALID          : Invalid file (either source or destination)
 * - __PO_HI_ERROR_NOEXISTS   : The source or destination file does not exists
 */
jdelange's avatar
jdelange committed
240
int __po_hi_storage_file_replace (const __po_hi_storage_file_t* oldfile, const __po_hi_storage_file_t* newfile);
jdelange's avatar
jdelange committed
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282


/**
 * \fn __po_hi_storage_file_lock
 *
 * \brief Lock a file
 *
 * This function locks a file, it acquires a lock on the file so that it
 * ensures that only one task is operating on it. If a call is issued while
 * the lock was already acquired, the second call will be put in the waiting
 * queue, waiting for the file to be unlocked. The behavior is basically like
 * a mutex.
 *
 * Result code are the following:
 * - __PO_HI_SUCCESS          : Successful operation
 * - __PO_HI_INVALID          : Invalid file
 */
int __po_hi_storage_file_lock (const __po_hi_storage_file_t* file);

/**
 * \fn __po_hi_storage_file_unlock
 *
 * \brief Unlock a file
 *
 * This function unlocks a file, it releases a lock on the specified file.
 * The lock hqs to be acquired before using __po_hi_storage_file_lock().
 * Please note that calling this function when the file was not locked
 * results in an error.
 *
 * Result code are the following:
 * - __PO_HI_SUCCESS          : Successful operation
 * - __PO_HI_INVALID          : Invalid file
 * - __PO_HI_UNAVAILABLE      : The file was not locked.
 */

int __po_hi_storage_file_unlock (const __po_hi_storage_file_t* file);


/*
 * Directory operations
 */

jdelange's avatar
jdelange committed
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
/**
 * \fn __po_hi_storage_directory_open
 *
 * \brief Open a directory designated under the name associated in the first
 * parameter. The second parameter is the directory structure to be
 * initialized.
 *
 * Please note that this function just fills the structure passed as the
 * second parameter. It does not create the directory itself
 * on the real filesystem, this is supposed to be done by a separate 
 * function (__po_hi_storage_directory_create).
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS: successful operation
 *  - __PO_HI_TOOMANY: too may directories are open at this time, cannot open more.
 *  - __PO_HI_INVALID: supplied directory name is invalid
 */
jdelange's avatar
jdelange committed
301
302
int __po_hi_storage_directory_open (const char*, __po_hi_storage_dir_t*);

jdelange's avatar
jdelange committed
303
304
305
306
307
308
309
310
311
312
313
314
315
316
/**
 * \fn __po_hi_storage_directory_create
 *
 * \brief Create a directory.
 *
 * Create a directory designated in the first parameter (previously
 * created using the __po_hi_storage_directory_open() function).
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
 *  - __PO_HI_INVALID            : invalid directory structure
 *  - __PO_HI_ERROR_EXISTS       : directory already exists
 */
jdelange's avatar
jdelange committed
317
318
int __po_hi_storage_directory_create (const __po_hi_storage_dir_t*);

jdelange's avatar
jdelange committed
319
320
321
322
323
324
325
326
327
328
329
330
331
332
/**
 * \fn __po_hi_storage_directory_delete
 *
 * \brief Delete a directory.
 *
 * Delete a directory designated in the first parameter (previously
 * created using the __po_hi_storage_directory_open() function).
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
 *  - __PO_HI_INVALID            : invalid directory structure
 *  - __PO_HI_ERROR_NOEXISTS     : directory does not exist
 */
jdelange's avatar
jdelange committed
333
334
int __po_hi_storage_directory_delete (const __po_hi_storage_dir_t*);

jdelange's avatar
jdelange committed
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
/**
 * \fn __po_hi_storage_directory_rename
 *
 * \brief Rename a directory.
 *
 * Rename a directory designated in the first parameter (previously
 * created using the __po_hi_storage_directory_open() function) with
 * the name of the directory supplied in the second argument
 * (also created using the __po_hi_storage_directory_open() function).
 * After successful call, the directory will not be available under the name
 * of the first argument.
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
 *  - __PO_HI_INVALID            : invalid directory structure
 *  - __PO_HI_ERROR_NOEXISTS     : directory of the first parameter does not
 *                                 exist
 *  - __PO_HI_ERROR_EXISTS       : directory of the second parameter already
 *                                 exist
 */
356
int __po_hi_storage_directory_rename (const __po_hi_storage_dir_t* olddir, const __po_hi_storage_dir_t* newdir);
jdelange's avatar
jdelange committed
357

jdelange's avatar
jdelange committed
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
/**
 * \fn __po_hi_storage_directory_list
 *
 * \brief List the content of the directory.
 *
 * This function fills the __po_hi_storage_dir_t structure
 * passed as argument with all the necessary content (files
 * contained in the directory, etc.).
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
 *  - __PO_HI_INVALID            : invalid directory structure
 *  - __PO_HI_ERROR_NOEXISTS     : the directory does not exist.
 */
373
int __po_hi_storage_directory_list (__po_hi_storage_dir_t* dir);
jdelange's avatar
jdelange committed
374

jdelange's avatar
jdelange committed
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
/**
 * \fn __po_hi_storage_directory_lock
 *
 * \brief Lock a directory.
 *
 * Lock a directory so that it ensures an exclusive access for
 * a task. It acts as a mutex: if the lock was already acquired,
 * a second call will make the second caller waiting for the lock to be
 * released.
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
 *  - __PO_HI_INVALID            : invalid directory structure
 */
jdelange's avatar
jdelange committed
390
391
int __po_hi_storage_directory_lock (const __po_hi_storage_dir_t* dir);

392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
/*
 * \fn __po_hi_storage_file_close
 *
 * \brief Close a file
 *
 * Close a file that was previously opened using __po_hi_storage_file_open().
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
 *  - __PO_HI_INVALID            : invalid directory structure
 */

int __po_hi_storage_file_close (__po_hi_storage_file_t* file);

jdelange's avatar
jdelange committed
407
408
409
410
411
412
413
414
415
416
417
418
419
420
/**
 * \fn __po_hi_storage_directory_unlock
 *
 * \brief Unlock a directory.
 *
 * Unlock a previously locked directory. It releases the mutex associated
 * to the mutex so that other task can locks the resource again.
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
 *  - __PO_HI_INVALID            : invalid directory structure
 *  - __PO_HI_UNAVAILABLE        : the directory was not locked.
 */
jdelange's avatar
jdelange committed
421
422
int __po_hi_storage_directory_unlock (const __po_hi_storage_dir_t* dir);

jdelange's avatar
jdelange committed
423
424
425
426
427
428
429
430
431
432
433
434
435
436
/**
 * \fn __po_hi_storage_change_cdir
 *
 * \brief Change the current directory of a task
 *
 * Change the directory associated with the current execution
 * context of the task.
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
 *  - __PO_HI_INVALID            : invalid directory structure
 *  - __PO_HI_NOEXISTS           : the directory does not exists
 */
jdelange's avatar
jdelange committed
437
438
int __po_hi_storage_change_cdir (__po_hi_storage_dir_t* new_current_directory);

jdelange's avatar
jdelange committed
439
440
441
442
443
444
445
446
447
448
449
450
/**
 * \fn __po_hi_storage_get_cdir
 *
 * \brief Get the current directory of the operating task
 *
 * Change the directory associated with the current execution
 * context of the task.
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
 */
jdelange's avatar
jdelange committed
451
452
453
454
455
456
457
int __po_hi_storage_get_cdir (__po_hi_storage_dir_t* current_directory);


/*
 * Packets service
 */

jdelange's avatar
jdelange committed
458
459
460
461
462
463
464
465
/**
 * \fn __po_hi_storage_packet_store_new
 *
 * \brief Create a new packet store
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
jdelange's avatar
jdelange committed
466
 *  - __PO_HI_ERROR_MUTEX_INIT   : error when trying to instantiate locking-related resources
jdelange's avatar
jdelange committed
467
468
 *  - __PO_HI_TOOMANY            : too many store already created
 */
jdelange's avatar
jdelange committed
469
470
int __po_hi_storage_packet_store_new (__po_hi_storage_packet_store_t* store);

jdelange's avatar
jdelange committed
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
/**
 * \fn __po_hi_storage_packet_store_new_from_file
 *
 * \brief Create a new packet store with the data stored in a file.
 *
 * The first argument is the store that would contain the packets
 * while the second argument is the file that contain the packet
 * store data (created during a previous execution with
 * __po_hi_storage_packet_store_zrite_to_file ())
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
 *  - __PO_HI_TOOMANY            : too many store already created
 *  - __PO_HI_NOEXISTS           : file does not exists (second argument)
 */
jdelange's avatar
jdelange committed
487
488
int __po_hi_storage_packet_store_new_from_file (__po_hi_storage_packet_store_t* store, __po_hi_storage_file_t* file);

jdelange's avatar
jdelange committed
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
/**
 * \fn __po_hi_storage_packet_store_write_to_file
 *
 * \brief Write the content of a packet store to a file.
 *
 * The first argument is the store that would contain the packets
 * while the second argument is the file that would be created.
 * This functions assumes the destination file does not exists.
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
 *  - __PO_HI_TOOMANY            : too many store already created
 *  - __PO_HI_EXISTS             : file already exists (second argument)
 */
jdelange's avatar
jdelange committed
504
505
int __po_hi_storage_packet_store_write_to_file (__po_hi_storage_packet_store_t* store, __po_hi_storage_file_t* file);

jdelange's avatar
jdelange committed
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
/**
 * \fn __po_hi_storage_packet_store_read
 *
 * \brief Read a packet from a packet store.
 *
 * The first argument is the store while the second argument
 * is the packet to be read (contain the information/data of 
 * the packet). If the store does not contain any packet, the function
 * returns an error.
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
 *  - __PO_HI_UNAVAILABLE        : no packet to be read.
 *  - __PO_HI_INVALID            : invalid packet store or packet to write
 *                                 (invalid address)
 */
jdelange's avatar
jdelange committed
523
524
int __po_hi_storage_packet_store_read (__po_hi_storage_packet_store_t* store, __po_hi_storage_packet_t*);

jdelange's avatar
jdelange committed
525
526
527
528
529
530
531
532
533
534
535
536
537
538
/**
 * \fn __po_hi_storage_packet_store_write
 *
 * \brief Write a packet to a packet store.
 *
 * The first argument is the store while the second argument
 * is the packet to be written (contain the information/data of 
 * the packet). 
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
 *  - __PO_HI_TOOMANY            : the store contains already too many
 *                                 packets, cannot write more packets.
jdelange's avatar
jdelange committed
539
540
541
542
 *  - __PO_HI_ERROR_MUTEX_LOCK   : error when trying to acquire the mutex
 *                                 associated with the packet store.
 *  - __PO_HI_ERROR_MUTEX_UNLOCK : error when trying to release the mutex
 *                                 associated with the packet store.
jdelange's avatar
jdelange committed
543
544
545
 *  - __PO_HI_INVALID            : invalid packet store or packet to write
 *                                 (invalid address)
 */
jdelange's avatar
jdelange committed
546
547
int __po_hi_storage_packet_store_write (__po_hi_storage_packet_store_t* store, __po_hi_storage_packet_t*);

jdelange's avatar
jdelange committed
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
/**
 * \fn __po_hi_storage_packet_store_free
 *
 * \brief Free old packets from a store.
 *
 * The first argument is the store while the second argument
 * is the number of packets to free. 
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
 *  - __PO_HI_NOEXISTS           : the user ask to free more packets
 *                                 than the quantity of available in the
 *                                 store. So, all packets are free'ed and the
 *                                 function returns __PO_HI_NOEXISTS.
 *  - __PO_HI_INVALID            : invalid packet store or packet to write
 *                                 (invalid address)
 */
jdelange's avatar
jdelange committed
566
567
int __po_hi_storage_packet_store_free (__po_hi_storage_packet_store_t* store, int n_free);

jdelange's avatar
jdelange committed
568
569
570
571
572
573
574
575
576
577
578
579
580
581
/**
 * \fn __po_hi_storage_packet_store_status
 *
 * \brief Indicate the status of a packet store.
 *
 * The first argument is the store while the second argument
 * is the status structure that would be filled by the function.
 *
 * Upon success, the function returns __PO_HI_SUCCESS.
 * It returns the following potential values:
 *  - __PO_HI_SUCCESS            : successful operation
 *  - __PO_HI_INVALID            : invalid packet store or invalid structure
 *                                 (invalid address)
 */
jdelange's avatar
jdelange committed
582
583
584
585
int __po_hi_storage_packet_store_status (__po_hi_storage_packet_store_t* store, __po_hi_storage_packet_store_status_t* status);

#endif /* __PO_HI_STORAGE_H__ */