Navigation


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

    r1093 r1103  
    491491        if (!avp_oh_model) {
    492492                avp_code_t code = AC_ORIGIN_HOST;
    493                 int ret;
    494                 CHECK_FCT_DO( ret = fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_CODE, &code, &avp_oh_model, ENOENT),
    495                         { CHECK_POSIX( pthread_mutex_unlock(&cache_avp_lock) ); return ret; } );
     493                CHECK_FCT_DO( fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_CODE, &code, &avp_oh_model, ENOENT),
     494                        { LOG_E("Cannot find Origin-Host AVP definition in the dictionary!"); (void) pthread_mutex_unlock(&cache_avp_lock); return __ret__; } );
    496495        }
    497496        CHECK_POSIX( pthread_mutex_unlock(&cache_avp_lock) );
     
    504503        /* First, check if the Origin-Host value is valid */
    505504        if (!fd_os_is_valid_DiameterIdentity(avp_hdr->avp_value->os.data, avp_hdr->avp_value->os.len)) {
    506                 TRACE_DEBUG(INFO, "Received new CER with invalid Origin-Host");
    507505                CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, cer, MSGFL_ANSW_ERROR ) );
    508506                CHECK_FCT( fd_msg_rescode_set(*cer, "DIAMETER_INVALID_AVP_VALUE",
    509507                                                        "Your Origin-Host contains invalid characters.", avp_oh, 1 ) );
     508               
     509                fd_hook_call(HOOK_PEER_CONNECT_FAILED, *cer, NULL, "Received CER with invalid Origin-Host AVP", NULL);
     510               
    510511                CHECK_FCT( fd_out_send(cer, *cnx, NULL, FD_CNX_ORDERED) );
    511512                return EINVAL;
     
    545546                peer->p_flags.pf_responder = 1;
    546547                peer->p_flags.pf_delete = 1;
     548               
     549                LOG_D("Created new peer object for incoming CER: %s", peer->p_hdr.info.pi_diamid);
    547550               
    548551#ifndef DISABLE_PEER_EXPIRY
     
    591594                *cer = NULL;
    592595                *cnx = NULL;
     596        } else {
     597                char buf[1024];
     598                snprintf(buf, sizeof(buf), "An error occurred while processing new incoming CER: %s", strerror(ret));
     599                fd_hook_call(HOOK_PEER_CONNECT_FAILED, *cer, NULL, buf, NULL);
    593600        }
    594601       
Note: See TracChangeset for help on using the changeset viewer.