Mercurial > hg > freeDiameter
comparison include/freeDiameter/freeDiameter.h @ 25:67ca08d5bc48
Completed connection context files
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Mon, 26 Oct 2009 16:00:49 +0900 |
parents | bd83ce9328ed |
children | e6fcdf12b9a0 |
comparison
equal
deleted
inserted
replaced
24:bd83ce9328ed | 25:67ca08d5bc48 |
---|---|
149 | 149 |
150 | 150 |
151 /* Events */ | 151 /* Events */ |
152 struct fd_event { | 152 struct fd_event { |
153 int code; /* codespace depends on the queue */ | 153 int code; /* codespace depends on the queue */ |
154 size_t size; | |
154 void *data; | 155 void *data; |
155 }; | 156 }; |
156 | 157 |
157 static __inline__ int fd_event_send(struct fifo *queue, int code, void * data) | 158 /* Daemon's codespace: 1000->1999 */ |
158 { | |
159 struct fd_event * ev; | |
160 CHECK_MALLOC( ev = malloc(sizeof(struct fd_event)) ); | |
161 ev->code = code; | |
162 ev->data = data; | |
163 CHECK_FCT( fd_fifo_post(queue, &ev) ); | |
164 return 0; | |
165 } | |
166 static __inline__ int fd_event_get(struct fifo *queue, int *code, void ** data) | |
167 { | |
168 struct fd_event * ev; | |
169 CHECK_FCT( fd_fifo_get(queue, &ev) ); | |
170 if (code) | |
171 *code = ev->code; | |
172 if (data) | |
173 *data = ev->data; | |
174 free(ev); | |
175 return 0; | |
176 } | |
177 | |
178 /* Events codespace for fd_g_config->cnf_main_ev */ | |
179 enum { | 159 enum { |
180 FDEV_TERMINATE = 1000 /* request to terminate */ | 160 FDEV_TERMINATE = 1000 /* request to terminate */ |
181 ,FDEV_DUMP_DICT /* Dump the content of the dictionary */ | 161 ,FDEV_DUMP_DICT /* Dump the content of the dictionary */ |
182 ,FDEV_DUMP_EXT /* Dump state of extensions */ | 162 ,FDEV_DUMP_EXT /* Dump state of extensions */ |
183 ,FDEV_DUMP_SERV /* Dump the server socket status */ | 163 ,FDEV_DUMP_SERV /* Dump the server socket status */ |
184 ,FDEV_DUMP_QUEUES /* Dump the message queues */ | 164 ,FDEV_DUMP_QUEUES /* Dump the message queues */ |
185 ,FDEV_DUMP_CONFIG /* Dump the configuration */ | 165 ,FDEV_DUMP_CONFIG /* Dump the configuration */ |
186 ,FDEV_DUMP_PEERS /* Dump the list of peers */ | 166 ,FDEV_DUMP_PEERS /* Dump the list of peers */ |
187 }; | 167 }; |
168 | |
169 static __inline__ int fd_event_send(struct fifo *queue, int code, size_t datasz, void * data) | |
170 { | |
171 struct fd_event * ev; | |
172 CHECK_MALLOC( ev = malloc(sizeof(struct fd_event)) ); | |
173 ev->code = code; | |
174 ev->size = datasz; | |
175 ev->data = data; | |
176 CHECK_FCT( fd_fifo_post(queue, &ev) ); | |
177 return 0; | |
178 } | |
179 static __inline__ int fd_event_get(struct fifo *queue, int *code, size_t *datasz, void ** data) | |
180 { | |
181 struct fd_event * ev; | |
182 CHECK_FCT( fd_fifo_get(queue, &ev) ); | |
183 if (code) | |
184 *code = ev->code; | |
185 if (datasz) | |
186 *datasz = ev->size; | |
187 if (data) | |
188 *data = ev->data; | |
189 free(ev); | |
190 return 0; | |
191 } | |
192 static __inline__ int fd_event_timedget(struct fifo *queue, struct timespec * timeout, int timeoutcode, int *code, size_t *datasz, void ** data) | |
193 { | |
194 struct fd_event * ev; | |
195 int ret = 0; | |
196 ret = fd_fifo_timedget(queue, &ev, timeout); | |
197 if (ret == ETIMEDOUT) { | |
198 if (code) | |
199 *code = timeoutcode; | |
200 if (datasz) | |
201 *datasz = 0; | |
202 if (data) | |
203 *data = NULL; | |
204 } else { | |
205 CHECK_FCT( ret ); | |
206 if (code) | |
207 *code = ev->code; | |
208 if (datasz) | |
209 *datasz = ev->size; | |
210 if (data) | |
211 *data = ev->data; | |
212 free(ev); | |
213 } | |
214 return 0; | |
215 } | |
216 static __inline__ void fd_event_destroy(struct fifo **queue, void (*free_cb)(void * data)) | |
217 { | |
218 struct fd_event * ev; | |
219 /* Purge all events, and free the associated data if any */ | |
220 while (fd_fifo_tryget( *queue, &ev ) == 0) { | |
221 (*free_cb)(ev->data); | |
222 free(ev); | |
223 } | |
224 CHECK_FCT_DO( fd_fifo_del(queue), /* continue */ ); | |
225 return ; | |
226 } | |
188 const char * fd_ev_str(int event); /* defined in freeDiameter/main.c */ | 227 const char * fd_ev_str(int event); /* defined in freeDiameter/main.c */ |
189 | 228 |
190 | 229 |
191 /***************************************/ | 230 /***************************************/ |
192 /* Peers information */ | 231 /* Peers information */ |