Navigation


Changeset 1103:d8591b1c56cd in freeDiameter for libfdcore/routing_dispatch.c


Ignore:
Timestamp:
May 10, 2013, 7:48:57 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Implemented a few hooks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdcore/routing_dispatch.c

    r1078 r1103  
    432432        char * ec = NULL;
    433433        char * em = NULL;
    434         struct msg *msgptr = msg;
     434        struct msg *msgptr = msg, *error = NULL;
    435435
    436436        /* Read the message header */
     
    442442
    443443        /* 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 ),
    445445                {
    446                         /* in case of error */
    447                         if ((ret == EBADMSG) && (msgptr != NULL)) {
    448                                 /* msgptr now contains the answer message to send back */
    449                                 CHECK_FCT( fd_fifo_post(fd_g_outgoing, &msgptr) );
    450                         }
    451                         if (msgptr) {   /* another error happen'd */
    452                                 //fd_msg_log( FD_MSG_LOG_DROPPED, msgptr,  "An unexpected error occurred while parsing the message (%s)", strerror(ret));
    453                                 CHECK_FCT_DO( fd_msg_free(msgptr), /* continue */);
    454                         }
    455                         /* We're done with this one */
    456                         return 0;
     446                        int rescue = 0;
     447                        if (__ret__ != EBADMSG) {
     448                                fd_hook_call(HOOK_MESSAGE_DROPPED, msgptr, NULL, "Error while parsing received answer", fd_msg_pmdl_get(msgptr));
     449                                fd_msg_free(msgptr);
     450                        } else {
     451                                if (!msgptr) {
     452                                        /* error now contains the answer message to send back */
     453                                        CHECK_FCT( fd_fifo_post(fd_g_outgoing, &error) );
     454                                } else if (!error) {
     455                                        /* We have received an invalid answer to our query */
     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 */
    457465                } );
    458466
Note: See TracChangeset for help on using the changeset viewer.