Contiki 2.5
registration.h
Go to the documentation of this file.
1 /**
2  * \addtogroup bprocess
3  * @{
4  */
5 
6 /**
7  * \file
8  * \brief Handle Service Registrations
9  *
10  * \author Georg von Zengen <vonzeng@ibr.cs.tu-bs.de>
11  */
12 
13 #ifndef REGISTRATION_H
14 #define REGISTRATION_H
15 
16 #include <stdint.h>
17 
18 #include "contiki.h"
19 
20 #include "lib/list.h"
21 
22 list_t reg_list;
23 
24 /**
25  * \brief structure of registration
26  */
27 struct registration {
28  struct registration * next;
29  uint32_t node_id;
30  uint32_t app_id;
31  uint8_t status:1;
32  uint8_t busy:1;
33  struct process * application_process;
34 };
35 
36 /**
37  * \brief called by agent at startup
38  */
39 void registration_init(void);
40 
41 /**
42  * \brief registers a new service
43  *
44  * \param app_id id of service
45  * \param application_process pointer to service
46  * \param node_id Node ID
47  *
48  * \return 1 on success, 0 on error
49  */
50 int registration_new_application(uint32_t app_id, struct process * application_process, uint32_t node_id);
51 
52 /**
53  * \brief deletes registration of service
54  *
55  * \param app_id service id
56  * \param node_id Node ID
57  */
58 void registration_remove_application(uint32_t app_id, uint32_t node_id);
59 
60 /**
61  * \brief sets state of service active
62  *
63  * \param app_id id of service
64  * \param node_id Node ID
65  *
66  * \return New status when successful, -1 on error
67  */
68 int registration_set_active(uint32_t app_id, uint32_t node_id);
69 
70 /**
71  * \brief sets state of service passive
72  *
73  * \param app_id id of service
74  * \param node_id Node ID
75  *
76  * \return New status when successful, -1 on error
77  */
78 int registration_set_passive(uint32_t app_id, uint32_t node_id);
79 
80 /**
81  * \brief Returns the status of a registred service
82  *
83  * \param app_id id of service
84  * \param node_id Node ID
85  *
86  * \return state of service
87  */
88 int registration_return_status(uint32_t app_id, uint32_t node_id);
89 
90 /**
91  * \brief returns the process struct for a specific registration
92  *
93  * \param app_id Service identifier
94  * \param node_id Node ID
95  *
96  * \return pointer to process struct
97  */
98 struct process * registration_get_process(uint32_t app_id, uint32_t node_id);
99 
100 /**
101  * \brief provides the endpoint id of a registred process (if any)
102  *
103  * \param application_process Pointer to the process
104  *
105  * \return app_id, 0xFFFF on error
106  */
107 uint32_t registration_get_application_id(struct process * application_process);
108 
109 /**
110  * \brief Checks whether the bundle is for a local process
111  *
112  * \param app_id Service Identifier
113  * \param node_id Node Identifier
114  *
115  * \return 1 on local, 0 otherwise
116  *
117  */
118 uint8_t registration_is_local(uint32_t app_id, uint32_t node_id);
119 
120 #endif
121 /** @} */