Mercurial > hg > freeDiameter
comparison libfdcore/routing_dispatch.c @ 1103:d8591b1c56cd
Implemented a few hooks
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Fri, 10 May 2013 18:48:57 +0800 |
parents | 74bba7975864 |
children | eb4ce68b6e5c |
comparison
equal
deleted
inserted
replaced
1102:1d7b3ebda27f | 1103:d8591b1c56cd |
---|---|
429 int is_req = 0, ret; | 429 int is_req = 0, ret; |
430 struct session * sess; | 430 struct session * sess; |
431 enum disp_action action; | 431 enum disp_action action; |
432 char * ec = NULL; | 432 char * ec = NULL; |
433 char * em = NULL; | 433 char * em = NULL; |
434 struct msg *msgptr = msg; | 434 struct msg *msgptr = msg, *error = NULL; |
435 | 435 |
436 /* Read the message header */ | 436 /* Read the message header */ |
437 CHECK_FCT( fd_msg_hdr(msg, &hdr) ); | 437 CHECK_FCT( fd_msg_hdr(msg, &hdr) ); |
438 is_req = hdr->msg_flags & CMD_FLAG_REQUEST; | 438 is_req = hdr->msg_flags & CMD_FLAG_REQUEST; |
439 | 439 |
440 /* Note: if the message is for local delivery, we should test for duplicate | 440 /* Note: if the message is for local delivery, we should test for duplicate |
441 (draft-asveren-dime-dupcons-00). This may conflict with path validation decisions, no clear answer yet */ | 441 (draft-asveren-dime-dupcons-00). This may conflict with path validation decisions, no clear answer yet */ |
442 | 442 |
443 /* At this point, we need to understand the message content, so parse it */ | 443 /* At this point, we need to understand the message content, so parse it */ |
444 CHECK_FCT_DO( ret = fd_msg_parse_or_error( &msgptr ), | 444 CHECK_FCT_DO( fd_msg_parse_or_error( &msgptr, &error ), |
445 { | 445 { |
446 /* in case of error */ | 446 int rescue = 0; |
447 if ((ret == EBADMSG) && (msgptr != NULL)) { | 447 if (__ret__ != EBADMSG) { |
448 /* msgptr now contains the answer message to send back */ | 448 fd_hook_call(HOOK_MESSAGE_DROPPED, msgptr, NULL, "Error while parsing received answer", fd_msg_pmdl_get(msgptr)); |
449 CHECK_FCT( fd_fifo_post(fd_g_outgoing, &msgptr) ); | 449 fd_msg_free(msgptr); |
450 } | 450 } else { |
451 if (msgptr) { /* another error happen'd */ | 451 if (!msgptr) { |
452 //fd_msg_log( FD_MSG_LOG_DROPPED, msgptr, "An unexpected error occurred while parsing the message (%s)", strerror(ret)); | 452 /* error now contains the answer message to send back */ |
453 CHECK_FCT_DO( fd_msg_free(msgptr), /* continue */); | 453 CHECK_FCT( fd_fifo_post(fd_g_outgoing, &error) ); |
454 } | 454 } else if (!error) { |
455 /* We're done with this one */ | 455 /* We have received an invalid answer to our query */ |
456 return 0; | 456 fd_hook_call(HOOK_MESSAGE_DROPPED, msgptr, NULL, "Received answer failed the dictionary / rules parsing", fd_msg_pmdl_get(msgptr)); |
457 fd_msg_free(msgptr); | |
458 } else { | |
459 /* We will pass the invalid received error to the application */ | |
460 rescue = 1; | |
461 } | |
462 } | |
463 if (!rescue) | |
464 return 0; /* We are done with this message, go to the next */ | |
457 } ); | 465 } ); |
458 | 466 |
459 /* First, if the original request was registered with a callback and we receive the answer, call it. */ | 467 /* First, if the original request was registered with a callback and we receive the answer, call it. */ |
460 if ( ! is_req ) { | 468 if ( ! is_req ) { |
461 struct msg * qry; | 469 struct msg * qry; |