Navigation


Changeset 1301:50fb308e84f7 in freeDiameter


Ignore:
Timestamp:
Aug 30, 2015, 2:58:21 AM (9 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Added a new hook to allow extensions act on the error messages being returned in case of parsing error (e.g. if some mandatory AVP are expected in error messages)

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/dbg_msg_dumps/dbg_msg_dumps.c

    r1299 r1301  
    105105                }
    106106                break;
     107        case HOOK_MESSAGE_PARSING_ERROR2:
     108                LOG_E("PARSING ERROR, returning:");
     109                LOG_SPLIT(FD_LOG_ERROR, "     ", buf, NULL);
     110                break;
    107111        case HOOK_MESSAGE_ROUTING_ERROR:
    108112                LOG_E("ROUTING ERROR '%s' for: ", (char *)other);
     
    198202                }
    199203                break;
     204        case HOOK_MESSAGE_PARSING_ERROR2:
     205                LOG_E("PARSING ERROR, returning: %s", buf);
     206                break;
    200207        case HOOK_MESSAGE_ROUTING_ERROR:
    201208                LOG_E("ROUTING ERROR '%s' for: %s", (char *)other, buf);
     
    280287                }
    281288                break;
     289        case HOOK_MESSAGE_PARSING_ERROR2:
     290                LOG_E("PARSING ERROR, returning: %s", buf);
     291                break;
    282292        case HOOK_MESSAGE_ROUTING_ERROR:
    283293                LOG_E("ROUTING ERROR '%s' for: %s", (char *)other, buf);
     
    351361        }
    352362       
    353         mask_errors = HOOK_MASK( HOOK_MESSAGE_FAILOVER, HOOK_MESSAGE_PARSING_ERROR, HOOK_MESSAGE_ROUTING_ERROR, HOOK_MESSAGE_DROPPED  );
     363        mask_errors = HOOK_MASK( HOOK_MESSAGE_FAILOVER, HOOK_MESSAGE_PARSING_ERROR, HOOK_MESSAGE_PARSING_ERROR2, HOOK_MESSAGE_ROUTING_ERROR, HOOK_MESSAGE_DROPPED  );
    354364        mask_sndrcv = HOOK_MASK( HOOK_MESSAGE_RECEIVED, HOOK_MESSAGE_SENT ); /* We don t access SENDING hook here */
    355365        mask_routing= HOOK_MASK( HOOK_MESSAGE_LOCAL, HOOK_MESSAGE_ROUTING_FORWARD, HOOK_MESSAGE_ROUTING_LOCAL );
  • include/freeDiameter/libfdcore.h

    r1299 r1301  
    10031003                 - {permsgdata} points to existing structure associated with this message (or new structure if no previous hook was registered).
    10041004                 */
    1005        
     1005                 
    10061006        HOOK_MESSAGE_ROUTING_ERROR,
    10071007                /* Hook called when a message being processed by the routing thread meets an error such as no remaining available peer for sending, based on routing callbacks decisions (maybe after retries).
     
    10591059                 */
    10601060       
    1061 #define HOOK_LAST       HOOK_PEER_CONNECT_SUCCESS
     1061        HOOK_MESSAGE_PARSING_ERROR2,
     1062                /* Hook called after an error message has been generated due to a dictionary parsing error.
     1063                 - {msg} points to the error message that has been generated.
     1064                 - {peer} is NULL. You can still retrieve the source from the message itself.
     1065                 - {other} is NULL
     1066                 - {permsgdata} points to existing structure associated with this message (or new structure if no previous hook was registered).
     1067                 Use this hook if you need to populate more data in the error being returned, from the error message.
     1068                 (e.g. some AVP need to be added to replies even if error case.
     1069                 */
     1070#define HOOK_LAST       HOOK_MESSAGE_PARSING_ERROR2
    10621071};
    10631072
  • libfdcore/hooks.c

    r1299 r1301  
    383383                        }
    384384                       
     385                        case HOOK_MESSAGE_PARSING_ERROR2: {
     386                                CHECK_MALLOC_DO(fd_msg_dump_treeview(&hook_default_buf, &hook_default_len, NULL, msg, NULL, 0, 1), break);
     387
     388                                LOG_E("Returning following message after parsing error:");
     389                                LOG_SPLIT(FD_LOG_ERROR, "   ", hook_default_buf, NULL);
     390                                break;
     391                        }
     392                       
    385393                        case HOOK_MESSAGE_ROUTING_ERROR: {
    386394                                CHECK_MALLOC_DO(fd_msg_dump_treeview(&hook_default_buf, &hook_default_len, NULL, msg, NULL, 0, 1), break);
  • libfdcore/routing_dispatch.c

    r1283 r1301  
    454454                        } else {
    455455                                if (!msgptr) {
     456                                        fd_hook_call(HOOK_MESSAGE_PARSING_ERROR2, error, NULL, NULL, fd_msg_pmdl_get(error));
    456457                                        /* error now contains the answer message to send back */
    457458                                        CHECK_FCT( fd_fifo_post(fd_g_outgoing, &error) );
Note: See TracChangeset for help on using the changeset viewer.