Mercurial > hg > freeDiameter
comparison libfreeDiameter/messages.c @ 90:2c9444152e4b
Added the dispatch thread code
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Mon, 07 Dec 2009 18:32:30 +0900 |
parents | e5fcd672caff |
children | 05ea77b86f53 |
comparison
equal
deleted
inserted
replaced
89:3f8b437bcb66 | 90:2c9444152e4b |
---|---|
2230 #define TEST_ACTION_STOP() \ | 2230 #define TEST_ACTION_STOP() \ |
2231 if ((*msg == NULL) || (*action != DISP_ACT_CONT)) \ | 2231 if ((*msg == NULL) || (*action != DISP_ACT_CONT)) \ |
2232 goto no_error; | 2232 goto no_error; |
2233 | 2233 |
2234 /* Call all dispatch callbacks for a given message */ | 2234 /* Call all dispatch callbacks for a given message */ |
2235 int fd_msg_dispatch ( struct msg ** msg, struct session * session, enum disp_action *action) | 2235 int fd_msg_dispatch ( struct msg ** msg, struct session * session, enum disp_action *action, const char ** error_code) |
2236 { | 2236 { |
2237 struct dictionary * dict; | 2237 struct dictionary * dict; |
2238 struct dict_object * app; | 2238 struct dict_object * app; |
2239 struct dict_object * cmd; | 2239 struct dict_object * cmd; |
2240 struct avp * avp; | 2240 struct avp * avp; |
2241 struct fd_list * cb_list; | 2241 struct fd_list * cb_list; |
2242 int ret = 0; | 2242 int ret = 0; |
2243 | 2243 |
2244 TRACE_ENTRY("%p %p %p", msg, session, action); | 2244 TRACE_ENTRY("%p %p %p %p", msg, session, action, error_code); |
2245 CHECK_PARAMS( msg && CHECK_MSG(*msg) && action); | 2245 CHECK_PARAMS( msg && CHECK_MSG(*msg) && action); |
2246 | |
2247 if (error_code) | |
2248 *error_code = NULL; | |
2246 | 2249 |
2247 /* Take the dispatch lock */ | 2250 /* Take the dispatch lock */ |
2248 CHECK_FCT( pthread_rwlock_rdlock(&fd_disp_lock) ); | 2251 CHECK_FCT( pthread_rwlock_rdlock(&fd_disp_lock) ); |
2249 pthread_cleanup_push( fd_cleanup_rwlock, &fd_disp_lock ); | 2252 pthread_cleanup_push( fd_cleanup_rwlock, &fd_disp_lock ); |
2250 | 2253 |
2259 /* Now resolve message application */ | 2262 /* Now resolve message application */ |
2260 CHECK_FCT_DO( ret = fd_dict_getdict( cmd, &dict ), goto error ); | 2263 CHECK_FCT_DO( ret = fd_dict_getdict( cmd, &dict ), goto error ); |
2261 CHECK_FCT_DO( ret = fd_dict_search( dict, DICT_APPLICATION, APPLICATION_BY_ID, &(*msg)->msg_public.msg_appl, &app, 0 ), goto error ); | 2264 CHECK_FCT_DO( ret = fd_dict_search( dict, DICT_APPLICATION, APPLICATION_BY_ID, &(*msg)->msg_public.msg_appl, &app, 0 ), goto error ); |
2262 | 2265 |
2263 if (app == NULL) { | 2266 if (app == NULL) { |
2264 /* In that case, maybe we should answer a DIAMETER_APPLICATION_UNSUPPORTED error ? Do we do this here ? */ | 2267 if ((*msg)->msg_public.msg_flags & CMD_FLAG_REQUEST) { |
2265 TODO("Reply DIAMETER_APPLICATION_UNSUPPORTED if it's a request ?"); | 2268 if (error_code) |
2269 *error_code = "DIAMETER_APPLICATION_UNSUPPORTED"; | |
2270 *action = DISP_ACT_ERROR; | |
2271 } else { | |
2272 TRACE_DEBUG(INFO, "Received an answer to a local query with an unsupported application %d, discarding...", (*msg)->msg_public.msg_appl); | |
2273 fd_msg_dump_walk(INFO, *msg); | |
2274 fd_msg_free(*msg); | |
2275 *msg = NULL; | |
2276 } | |
2277 goto no_error; | |
2266 } | 2278 } |
2267 | 2279 |
2268 /* So start browsing the message */ | 2280 /* So start browsing the message */ |
2269 CHECK_FCT_DO( ret = fd_msg_browse( *msg, MSG_BRW_FIRST_CHILD, &avp, NULL ), goto error ); | 2281 CHECK_FCT_DO( ret = fd_msg_browse( *msg, MSG_BRW_FIRST_CHILD, &avp, NULL ), goto error ); |
2270 while (avp != NULL) { | 2282 while (avp != NULL) { |