1 |
/* |
2 |
* Cisco router simulation platform. |
3 |
* Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) |
4 |
* |
5 |
* Periodic tasks centralization. |
6 |
*/ |
7 |
|
8 |
#ifndef __PTASK_H__ |
9 |
#define __PTASK_H__ |
10 |
|
11 |
#include <sys/types.h> |
12 |
#include <sys/socket.h> |
13 |
#include <sys/un.h> |
14 |
#include "utils.h" |
15 |
|
16 |
/* ptask identifier */ |
17 |
typedef m_int64_t ptask_id_t; |
18 |
|
19 |
/* periodic task callback prototype */ |
20 |
typedef int (*ptask_callback)(void *object,void *arg); |
21 |
|
22 |
/* periodic task definition */ |
23 |
typedef struct ptask ptask_t; |
24 |
struct ptask { |
25 |
ptask_id_t id; |
26 |
ptask_t *next; |
27 |
ptask_callback cbk; |
28 |
void *object,*arg; |
29 |
}; |
30 |
|
31 |
/* Add a new task */ |
32 |
ptask_id_t ptask_add(ptask_callback cbk,void *object,void *arg); |
33 |
|
34 |
/* Remove a task */ |
35 |
int ptask_remove(ptask_id_t id); |
36 |
|
37 |
/* Initialize ptask module */ |
38 |
int ptask_init(u_int sleep_time); |
39 |
|
40 |
#endif |