Navigation


Changeset 1103:d8591b1c56cd in freeDiameter for libfdcore/messages.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/messages.c

    r1078 r1103  
    346346
    347347/* Parse a message against our dictionary, and in case of error log and eventually build the error reply -- returns the parsing status */
    348 int fd_msg_parse_or_error( struct msg ** msg )
     348int fd_msg_parse_or_error( struct msg ** msg, struct msg **error)
    349349{
    350350        int ret = 0;
     
    355355        TRACE_ENTRY("%p", msg);
    356356       
    357         CHECK_PARAMS(msg && *msg);
     357        CHECK_PARAMS(msg && *msg && error);
    358358        m = *msg;
     359        *error = NULL;
    359360       
    360361        /* Parse the message against our dictionary */
     
    364365                return ret; /* 0 or another error */
    365366       
    366         TRACE_DEBUG(INFO, "A message does not comply to the dictionary and/or rules (%s)", pei.pei_errcode);
    367         fd_msg_dump_walk(FULL, m);
     367        /* Log */
     368        fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, m, NULL, pei.pei_message ?: pei.pei_errcode, fd_msg_pmdl_get(m));
    368369       
    369370        CHECK_FCT( fd_msg_hdr(m, &hdr) );
     
    373374               
    374375                /* Create the error message */
    375                 CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, msg, pei.pei_protoerr ? MSGFL_ANSW_ERROR : 0 ) );
     376                CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, &m, pei.pei_protoerr ? MSGFL_ANSW_ERROR : 0 ) );
    376377               
    377378                /* Set the error code */
    378                 CHECK_FCT( fd_msg_rescode_set(*msg, pei.pei_errcode, pei.pei_message, pei.pei_avp, 1 ) );
     379                CHECK_FCT( fd_msg_rescode_set(m, pei.pei_errcode, pei.pei_message, pei.pei_avp, 1 ) );
     380               
     381                *msg = NULL;
     382                *error = m;
    379383               
    380384        } else {
     
    409413                                        default: /* Other errors */
    410414                                                /* We let the application decide what to do with the message, we rescue it */
    411                                                 return 0;
     415                                                *error = m;
    412416                                }
    413417                        }
    414418                } while (0);
    415                
    416                 /* Just discard */
    417                 //fd_msg_log( FD_MSG_LOG_DROPPED, m, "Answer not compliant to dictionary's ABNF (%s)", pei.pei_errcode  );
    418                 CHECK_FCT( fd_msg_free( m ) );
    419                 *msg = NULL;
    420419        }
    421420       
Note: See TracChangeset for help on using the changeset viewer.