Navigation


Changeset 1113:eb4ce68b6e5c in freeDiameter for libfdcore


Ignore:
Timestamp:
May 13, 2013, 8:17:13 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Added calls to remaining hooks

Location:
libfdcore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • libfdcore/config.c

    r1107 r1113  
    8585        FD_DUMP_HANDLE_OFFSET();
    8686       
    87         CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{freeDiameter configuration}(@%p): \n", fd_g_config), return NULL);       
     87        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "freeDiameter configuration:\n", fd_g_config), return NULL);       
    8888        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "  Default trace level .... : %+d\n", fd_g_debug_lvl), return NULL);
    8989        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "  Configuration file ..... : %s\n", fd_g_config->cnf_file), return NULL);
     
    9999                CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "  Local endpoints ........ : Default (use all available)\n"), return NULL);
    100100        } else {
    101                 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "  Local endpoints ........ : \n"), return NULL);
    102                 CHECK_MALLOC_DO( fd_ep_dump( FD_DUMP_STD_PARAMS, 29, &fd_g_config->cnf_endpoints ), return NULL);
     101                CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "  Local endpoints ........ : "), return NULL);
     102                CHECK_MALLOC_DO( fd_ep_dump( FD_DUMP_STD_PARAMS, 0, 0, &fd_g_config->cnf_endpoints ), return NULL);
    103103        }
    104104        if (FD_IS_LIST_EMPTY(&fd_g_config->cnf_apps)) {
    105                 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "  Local applications ..... : (none)\n"), return NULL);
     105                CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "  Local applications ..... : (none)"), return NULL);
    106106        } else {
    107107                struct fd_list * li = fd_g_config->cnf_apps.next;
    108                 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "  Local applications ..... : \n"), return NULL);
     108                CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "  Local applications ..... : "), return NULL);
    109109                while (li != &fd_g_config->cnf_apps) {
    110110                        struct fd_app * app = (struct fd_app *)li;
    111                         CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "                             App: %u\t%s%s\tVnd: %u\n",
     111                        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "App: %u,%s%s,Vnd:%u\t",
    112112                                        app->appid,
    113113                                        app->flags.auth ? "Au" : "--",
     
    118118        }
    119119       
    120         CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "  Flags : - IP ........... : %s\n", fd_g_config->cnf_flags.no_ip4 ? "DISABLED" : "Enabled"), return NULL);
     120        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n  Flags : - IP ........... : %s\n", fd_g_config->cnf_flags.no_ip4 ? "DISABLED" : "Enabled"), return NULL);
    121121        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "          - IPv6 ......... : %s\n", fd_g_config->cnf_flags.no_ip6 ? "DISABLED" : "Enabled"), return NULL);
    122122        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "          - Relay app .... : %s\n", fd_g_config->cnf_flags.no_fwd ? "DISABLED" : "Enabled"), return NULL);
     
    588588               
    589589        } else {
    590                 TRACE_DEBUG(INFO, "Generating fresh Diffie-Hellman parameters of size %d (this takes some time)... ", fd_g_config->cnf_sec_data.dh_bits ?: GNUTLS_DEFAULT_DHBITS);
     590                LOG_D( "Generating fresh Diffie-Hellman parameters of size %d (this takes some time)... ", fd_g_config->cnf_sec_data.dh_bits ?: GNUTLS_DEFAULT_DHBITS);
    591591                CHECK_GNUTLS_DO( gnutls_dh_params_generate2(
    592592                                        fd_g_config->cnf_sec_data.dh_cache,
  • libfdcore/endpoints.c

    r1093 r1113  
    285285}
    286286
    287 DECLARE_FD_DUMP_PROTOTYPE(fd_ep_dump_one, struct fd_endpoint * ep )
     287DECLARE_FD_DUMP_PROTOTYPE(fd_ep_dump_one, int preamble, struct fd_endpoint * ep )
    288288{
    289289        FD_DUMP_HANDLE_OFFSET();
    290290       
    291         CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{ep}(@%p): ", ep), return NULL);
     291        if (preamble) {
     292                CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{ep}(@%p): ", ep), return NULL);
     293        }
    292294       
    293295        if (!ep) {
     
    297299       
    298300        CHECK_MALLOC_DO( fd_sa_dump_node_serv( FD_DUMP_STD_PARAMS, &ep->sa, NI_NUMERICHOST | NI_NUMERICSERV ), return NULL);
    299         CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " {%s%s%s%s%s}",
    300                         (ep->flags & EP_FL_CONF)        ? "C" : "-",
    301                         (ep->flags & EP_FL_DISC)        ? "D" : "-",
    302                         (ep->flags & EP_FL_ADV)         ? "A" : "-",
    303                         (ep->flags & EP_FL_LL)          ? "L" : "-",
    304                         (ep->flags & EP_FL_PRIMARY)     ? "P" : "-"), return NULL);
     301        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{%s%s%s%s%s}",
     302                                (ep->flags & EP_FL_CONF)        ? "C" : "-",
     303                                (ep->flags & EP_FL_DISC)        ? "D" : "-",
     304                                (ep->flags & EP_FL_ADV)         ? "A" : "-",
     305                                (ep->flags & EP_FL_LL)          ? "L" : "-",
     306                                (ep->flags & EP_FL_PRIMARY)     ? "P" : "-"), return NULL);
    305307        return *buf;
    306308}
    307309
    308 DECLARE_FD_DUMP_PROTOTYPE(fd_ep_dump, int indent, struct fd_list * eps  )
     310DECLARE_FD_DUMP_PROTOTYPE(fd_ep_dump, int preamble, int indent, struct fd_list * eps  )
    309311{
    310312        struct fd_list * li;
     
    312314        FD_DUMP_HANDLE_OFFSET();
    313315       
    314         CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%*s{eps}(@%p):", indent, "", eps), return NULL);
     316        if (preamble) {
     317                CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%*s{eps}(@%p):", indent, "", eps), return NULL);
     318        }
    315319        if (eps) {
    316320                for (li = eps->next; li != eps; li = li->next) {
    317321                        struct fd_endpoint * ep = (struct fd_endpoint *)li;
    318                         CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n%*s", indent+1, ""), return NULL);
    319                         CHECK_MALLOC_DO( fd_ep_dump_one( FD_DUMP_STD_PARAMS, ep ), return NULL);
    320                 }
    321         }
    322 }
    323        
     322                        if (preamble) {
     323                                CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n%*s", indent+1, ""), return NULL);
     324                        } else if (li->prev != eps) {
     325                                CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\t"), return NULL);
     326                        }
     327                        CHECK_MALLOC_DO( fd_ep_dump_one( FD_DUMP_STD_PARAMS, preamble, ep ), return NULL);
     328                }
     329        }
     330}
     331       
  • libfdcore/extensions.c

    r1094 r1113  
    151151        {
    152152                struct fd_ext_info * ext = (struct fd_ext_info *)li;
    153                 TRACE_DEBUG (INFO, "Loading : %s", ext->filename);
     153                LOG_D( "Loading : %s", ext->filename);
    154154               
    155155                /* Load the extension */
     
    162162                if (ext->handler == NULL) {
    163163                        /* An error occured */
    164                         TRACE_ERROR("Loading of extension %s failed: %s", ext->filename, dlerror());
     164                        LOG_F("Loading of extension %s failed: %s", ext->filename, dlerror());
    165165                        #ifdef DEBUG
    166166                        ext->handler = dlopen(ext->filename, RTLD_LAZY | RTLD_GLOBAL);
     
    208208        }
    209209
    210         TRACE_DEBUG (INFO, "All extensions loaded.");
     210        LOG_N("All extensions loaded.");
    211211       
    212212        /* We have finished. */
  • libfdcore/messages.c

    r1103 r1113  
    314314}
    315315
     316static int fd_msg_send_int( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data, void (*expirecb)(void *, DiamId_t, size_t, struct msg **), const struct timespec *timeout )
     317{
     318        struct msg_hdr *hdr;
     319        DiamId_t diamid;
     320        size_t diamidlen;
     321       
     322        /* Save the callback in the message, with the timeout */
     323        CHECK_FCT(  fd_msg_anscb_associate( *pmsg, anscb, data, expirecb, timeout )  );
     324       
     325        /* If this is a new request, call the HOOK_MESSAGE_LOCAL hook */
     326        if ( (fd_msg_hdr(*pmsg, &hdr) == 0)
     327         &&  (hdr->msg_flags & CMD_FLAG_REQUEST)
     328         &&  (fd_msg_source_get(*pmsg, &diamid, &diamidlen) == 0)
     329         &&  (diamid == NULL)) {
     330                fd_hook_call(HOOK_MESSAGE_LOCAL, *pmsg, NULL, NULL, fd_msg_pmdl_get(*pmsg));
     331        }
     332               
     333        /* Post the message in the outgoing queue */
     334        CHECK_FCT( fd_fifo_post(fd_g_outgoing, pmsg) );
     335       
     336        return 0;
     337}
     338
    316339/* Send a message and optionaly register a callback for an answer */
    317340int fd_msg_send ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data )
     
    320343        CHECK_PARAMS( pmsg );
    321344       
    322         /* Save the callback in the message */
    323         CHECK_FCT(  fd_msg_anscb_associate( *pmsg, anscb, data, NULL, NULL /* we should maybe use a safeguard here like 1 hour or so? */ )  );
    324        
    325         /* Post the message in the outgoing queue */
    326         CHECK_FCT( fd_fifo_post(fd_g_outgoing, pmsg) );
    327        
    328         return 0;
     345        return fd_msg_send_int(pmsg, anscb, data, NULL, NULL);
    329346}
    330347
     
    335352        CHECK_PARAMS( pmsg && expirecb && timeout );
    336353       
    337         /* Save the callback in the message, with the timeout */
    338         CHECK_FCT(  fd_msg_anscb_associate( *pmsg, anscb, data, expirecb, timeout )  );
    339        
    340         /* Post the message in the outgoing queue */
    341         CHECK_FCT( fd_fifo_post(fd_g_outgoing, pmsg) );
    342        
    343         return 0;
     354        return fd_msg_send_int(pmsg, anscb, data, expirecb, timeout);
    344355}
    345356
  • libfdcore/p_ce.c

    r1103 r1113  
    650650        *recv_cnx = NULL;
    651651        if (*cer) {
    652                 //fd_msg_log(FD_MSG_LOG_DROPPED, *cer, "An error occurred while rejecting a CER.");
     652                fd_hook_call(HOOK_MESSAGE_DROPPED, *cer, NULL, "An error occurred while rejecting this CER.", fd_msg_pmdl_get(*cer));
    653653                fd_msg_free(*cer);
    654654                *cer = NULL;
  • libfdcore/p_out.c

    r1103 r1113  
    9898        CHECK_FCT_DO(fd_fifo_post(fd_g_outgoing, &msg),
    9999                {
    100                         //fd_msg_log( FD_MSG_LOG_DROPPED, msg, "An error occurred while attempting to requeue this message during cancellation of the sending function");
     100                        fd_hook_call(HOOK_MESSAGE_DROPPED, msg, NULL, "An error occurred while attempting to requeue this message during cancellation of the sending function", fd_msg_pmdl_get(msg));
    101101                        CHECK_FCT_DO(fd_msg_free(msg), /* What can we do more? */);
    102102                } );
     
    131131                        {
    132132                                if (msg) {
    133                                         //fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Internal error: Problem while sending (%s)", strerror(ret) );
     133                                        char buf[256];
     134                                        snprintf(buf, sizeof(buf), "Error while sending this message: s", strerror(ret));
     135                                        fd_hook_call(HOOK_MESSAGE_DROPPED, msg, NULL, buf, fd_msg_pmdl_get(msg));
    134136                                        fd_msg_free(msg);
    135137                                }
     
    183185                        {
    184186                                if (msg) {
    185                                         //fd_msg_log( FD_MSG_LOG_DROPPED, *msg, "Internal error: Problem while sending (%s)", strerror(ret) );
     187                                        char buf[256];
     188                                        snprintf(buf, sizeof(buf), "Error while sending this message: s", strerror(ret));
     189                                        fd_hook_call(HOOK_MESSAGE_DROPPED, *msg, NULL, buf, fd_msg_pmdl_get(*msg));
    186190                                        fd_msg_free(*msg);
    187191                                        *msg = NULL;
  • libfdcore/p_psm.c

    r1104 r1113  
    241241                        case FDEVP_CNX_INCOMING: {
    242242                                struct cnx_incoming * evd = ev->data;
    243                                 //fd_msg_log( FD_MSG_LOG_DROPPED, evd->cer, "Message discarded while cleaning peer state machine queue." );
     243                                fd_hook_call(HOOK_MESSAGE_DROPPED, evd->cer, NULL, "Message discarded while cleaning peer state machine queue.", fd_msg_pmdl_get(evd->cer));
    244244                                CHECK_FCT_DO( fd_msg_free(evd->cer), /* continue */);
    245245                                fd_cnx_destroy(evd->cnx);
     
    577577                                        char buf[128];
    578578                                        snprintf(buf, sizeof(buf), "Received while peer state machine was in state %s.", STATE_STR(cur_state));
     579                                        LOG_E("%s",buf);
    579580                                        fd_hook_call(HOOK_MESSAGE_DROPPED, msg, peer, buf, fd_msg_pmdl_get(msg));
    580581                                        fd_msg_free(msg);
     
    590591                        if (ret != EBADMSG) {
    591592                                CHECK_FCT_DO( ret,
    592                                         {
    593                                                 LOG_E("%s: An unexpected error occurred while parsing a link-local message", peer->p_hdr.info.pi_diamid);
     593                                        {
     594                                                char buf[256];
     595                                                snprintf(buf, sizeof(buf), "%s: An unexpected error occurred while parsing a link-local message", peer->p_hdr.info.pi_diamid);
     596                                                LOG_E("%s",buf);
     597                                                fd_hook_call(HOOK_MESSAGE_DROPPED, msg, peer, buf, fd_msg_pmdl_get(msg));
    594598                                                fd_msg_free(msg);
    595599                                                goto psm_end;
     
    600604                                        CHECK_FCT_DO( ret = fd_out_send(&error, NULL, peer, FD_CNX_ORDERED),  );
    601605                                        if (error) {
     606                                                char buf[256];
    602607                                                /* Only if an error occurred & the message was not saved / dumped */
    603                                                 LOG_E("%s: error sending a message", peer->p_hdr.info.pi_diamid);
     608                                                snprintf(buf, sizeof(buf), "%s: error sending a message", peer->p_hdr.info.pi_diamid);
     609                                                LOG_E("%s",buf);
     610                                                fd_hook_call(HOOK_MESSAGE_DROPPED, error, peer, buf, fd_msg_pmdl_get(error));
    604611                                                CHECK_FCT_DO( fd_msg_free(error), goto psm_end);
    605612                                        }
    606613                                } else {
     614                                        char buf[256];
    607615                                        /* We received an invalid answer, let's disconnect */
    608                                         LOG_E("%s: Received invalid answer to Base protocol message, disconnecting...", peer->p_hdr.info.pi_diamid);
     616                                        snprintf(buf, sizeof(buf), "%s: Received invalid answer to Base protocol message, disconnecting...", peer->p_hdr.info.pi_diamid);
     617                                        LOG_E("%s",buf);
    609618                                        CHECK_FCT_DO( fd_msg_free(msg), goto psm_end);
    610619                                        CHECK_FCT_DO( fd_event_send(peer->p_events, FDEVP_CNX_ERROR, 0, NULL), goto psm_reset );
     
    657666                                /* Cleanup the message if not done */
    658667                                if (msg) {
    659                                         //fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Received un-handled non-routable command from peer '%s'.", peer->p_hdr.info.pi_diamid );
     668                                        char buf[256];
     669                                        snprintf(buf, sizeof(buf), "Received un-handled non-routable command from peer '%s'.", peer->p_hdr.info.pi_diamid);
     670                                        LOG_E("%s",buf);
     671                                        fd_hook_call(HOOK_MESSAGE_DROPPED, msg, NULL, buf, fd_msg_pmdl_get(msg));
    660672                                        CHECK_FCT_DO( fd_msg_free(msg), /* continue */);
    661673                                        msg = NULL;
     
    665677                /* At this point the message must have been fully handled already */
    666678                if (msg) {
    667                         //fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Internal error ('%s'): unhandled message.", peer->p_hdr.info.pi_diamid );
     679                        char buf[256];
     680                        snprintf(buf, sizeof(buf), "Internal error ('%s'): unhandled message.", peer->p_hdr.info.pi_diamid);
     681                        LOG_E("%s",buf);
     682                        fd_hook_call(HOOK_MESSAGE_DROPPED, msg, NULL, buf, fd_msg_pmdl_get(msg));
    668683                        fd_msg_free(msg);
    669684                }
     
    732747                        char * buf = NULL;
    733748                        size_t len = 0;
    734                         LOG_D("New remote endpoint(s): %s",  fd_ep_dump(&buf, &len, NULL, 6, &peer->p_hdr.info.pi_endpoints) ?: "error");
     749                        LOG_D("New remote endpoint(s): %s",  fd_ep_dump(&buf, &len, NULL, 0, 0, &peer->p_hdr.info.pi_endpoints) ?: "error");
    735750                        free(buf);
    736751                }
  • libfdcore/p_sr.c

    r1110 r1113  
    119119        /* If the callback did not dispose of the message, do it now */
    120120        if (ed->request) {
    121                 //fd_msg_log(FD_MSG_LOG_DROPPED, ed->request, "Expiration period completed without an answer, and the expiry callback did not dispose of the message.");
     121                fd_hook_call(HOOK_MESSAGE_DROPPED, ed->request, NULL, "Expiration period completed without an answer, and the expiry callback did not dispose of the message.", fd_msg_pmdl_get(ed->request));
    122122                CHECK_FCT_DO( fd_msg_free(ed->request), /* ignore */ );
    123123        }
     
    323323                                hdr->msg_flags |= CMD_FLAG_RETRANSMIT;
    324324                       
     325                        fd_hook_call(HOOK_MESSAGE_FAILOVER, sr->req, (struct fd_peer *)srlist->srs.o, NULL, fd_msg_pmdl_get(sr->req));
     326                       
    325327                        /* Requeue for sending to another peer */
    326328                        CHECK_FCT_DO( ret = fd_fifo_post(fd_g_outgoing, &sr->req),
    327329                                {
    328                                         //fd_msg_log( FD_MSG_LOG_DROPPED, sr->req, "Internal error: error while requeuing during failover: %s", strerror(ret) );
     330                                        char buf[256];
     331                                        snprintf(buf, sizeof(buf), "Internal error: error while requeuing during failover: %s", strerror(ret));
     332                                        fd_hook_call(HOOK_MESSAGE_DROPPED, sr->req, NULL, buf, fd_msg_pmdl_get(sr->req));
    329333                                        CHECK_FCT_DO(fd_msg_free(sr->req), /* What can we do more? */)
    330334                                });
    331335                } else {
    332336                        /* Just free the request. */
    333                         //fd_msg_log( FD_MSG_LOG_DROPPED, sr->req, "Sent & unanswered local message discarded during failover." );
     337                        /* fd_hook_call(HOOK_MESSAGE_DROPPED, sr->req, NULL, "Sent & unanswered local message discarded during failover.", fd_msg_pmdl_get(sr->req)); */
    334338                        CHECK_FCT_DO(fd_msg_free(sr->req), /* Ignore */);
    335339                }
  • libfdcore/peers.c

    r1103 r1113  
    242242        /* Requeue all messages in the "out" queue */
    243243        while ( fd_fifo_tryget(peer->p_tosend, &m) == 0 ) {
     244                fd_hook_call(HOOK_MESSAGE_FAILOVER, m, peer, NULL, fd_msg_pmdl_get(m));
    244245                CHECK_FCT_DO(fd_fifo_post(fd_g_outgoing, &m),
    245246                        {
    246247                                /* fallback: destroy the message */
    247                                 //fd_msg_log(FD_MSG_LOG_DROPPED, m, "Internal error: unable to requeue this message during failover process");
     248                                fd_hook_call(HOOK_MESSAGE_DROPPED, m, NULL, "Internal error: unable to requeue this message during failover process", fd_msg_pmdl_get(m));
    248249                                CHECK_FCT_DO(fd_msg_free(m), /* What can we do more? */)
    249250                        } );
  • libfdcore/queues.c

    r1078 r1113  
    7474               
    7575                /* We got one! */
    76                 //fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Message lost because framework is terminating." );
     76                fd_hook_call(HOOK_MESSAGE_DROPPED, msg, NULL, "Message lost because framework is terminating.", fd_msg_pmdl_get(msg));
    7777                fd_msg_free(msg);
    7878        }
  • libfdcore/routing_dispatch.c

    r1103 r1113  
    393393
    394394                        if (!peer) {
    395                                 //fd_msg_log(FD_MSG_LOG_DROPPED, *pmsg, "Unable to send error '%s' to deleted peer '%s' in reply to this message.", error_code, id);
     395                                char buf[256];
     396                                snprintf(buf, sizeof(buf), "Unable to send error '%s' to deleted peer '%s' in reply to this message.", error_code, id);
     397                                fd_hook_call(HOOK_MESSAGE_DROPPED, *pmsg, NULL, buf, fd_msg_pmdl_get(*pmsg));
    396398                                fd_msg_free(*pmsg);
    397399                                *pmsg = NULL;
     
    496498
    497499        /* Now, call any callback registered for the message */
    498         CHECK_FCT( fd_msg_dispatch ( &msgptr, sess, &action, &ec) );
     500        CHECK_FCT( fd_msg_dispatch ( &msgptr, sess, &action, &ec, &em, &error) );
    499501
    500502        /* Now, act depending on msg and action and ec */
     
    505507                                if (!fd_g_config->cnf_flags.no_fwd) {
    506508                                        /* requeue to fd_g_outgoing */
     509                                        fd_hook_call(HOOK_MESSAGE_ROUTING_FORWARD, msgptr, NULL, NULL, fd_msg_pmdl_get(msgptr));
    507510                                        CHECK_FCT( fd_fifo_post(fd_g_outgoing, &msgptr) );
    508511                                        break;
     
    519522                               
    520523                                if (!is_req) {
    521                                         //fd_msg_log( FD_MSG_LOG_DROPPED, msgptr,  "Internal error: Answer received to locally issued request, but not handled by any handler.");
     524                                        fd_hook_call(HOOK_MESSAGE_DROPPED, msgptr, NULL, "Internal error: Answer received to locally issued request, but not handled by any handler.", fd_msg_pmdl_get(msgptr));
    522525                                        fd_msg_free(msgptr);
    523526                                        break;
     
    532535                                CHECK_FCT( fd_fifo_post(fd_g_outgoing, &msgptr) );
    533536                }
     537        } else if (em) {
     538                fd_hook_call(HOOK_MESSAGE_DROPPED, error, NULL, em, fd_msg_pmdl_get(error));
     539                fd_msg_free(error);
    534540        }
    535541       
     
    555561        /* Handle incorrect bits */
    556562        if (is_req && is_err) {
     563                fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "R & E bits were set", fd_msg_pmdl_get(msgptr));
    557564                CHECK_FCT( return_error( &msgptr, "DIAMETER_INVALID_HDR_BITS", "R & E bits were set", NULL) );
    558565                return 0;
     
    573580                /* Check if we have local support for the message application */
    574581                if ( (hdr->msg_appl == 0) || (hdr->msg_appl == AI_RELAY) ) {
    575                         TRACE_DEBUG(INFO, "Received a routable message with application id 0 or " _stringize(AI_RELAY) " (relay),"
    576                                           " returning DIAMETER_APPLICATION_UNSUPPORTED");
     582                        fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Received a routable message with application id 0 or " _stringize(AI_RELAY) " (relay)", fd_msg_pmdl_get(msgptr));
    577583                        CHECK_FCT( return_error( &msgptr, "DIAMETER_APPLICATION_UNSUPPORTED", "Routable message with application id 0 or relay", NULL) );
    578584                        return 0;
     
    601607                                                        {
    602608                                                                if (error_info.pei_errcode) {
     609                                                                        fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, error_info.pei_message ?: error_info.pei_errcode, fd_msg_pmdl_get(msgptr));
    603610                                                                        CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
    604611                                                                        return 0;
    605612                                                                } else {
     613                                                                        fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Unspecified error while parsing Destination-Host AVP", fd_msg_pmdl_get(msgptr));
    606614                                                                        return ret;
    607615                                                                }
     
    621629                                                        {
    622630                                                                if (error_info.pei_errcode) {
     631                                                                        fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, error_info.pei_message ?: error_info.pei_errcode, fd_msg_pmdl_get(msgptr));
    623632                                                                        CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
    624633                                                                        return 0;
    625634                                                                } else {
     635                                                                        fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Unspecified error while parsing Destination-Realm AVP", fd_msg_pmdl_get(msgptr));
    626636                                                                        return ret;
    627637                                                                }
     
    643653                                                        {
    644654                                                                if (error_info.pei_errcode) {
     655                                                                        fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, error_info.pei_message ?: error_info.pei_errcode, fd_msg_pmdl_get(msgptr));
    645656                                                                        CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
    646657                                                                        return 0;
    647658                                                                } else {
     659                                                                        fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Unspecified error while parsing User-Name AVP", fd_msg_pmdl_get(msgptr));
    648660                                                                        return ret;
    649661                                                                }
     
    668680                /* Handle the missing routing AVPs first */
    669681                if ( is_dest_realm == UNKNOWN ) {
     682                        fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Non-routable message not supported (invalid bit ? missing Destination-Realm ?)", fd_msg_pmdl_get(msgptr));
    670683                        CHECK_FCT( return_error( &msgptr, "DIAMETER_COMMAND_UNSUPPORTED", "Non-routable message not supported (invalid bit ? missing Destination-Realm ?)", NULL) );
    671684                        return 0;
     
    676689                        if (is_local_app == YES) {
    677690                                /* Ok, give the message to the dispatch thread */
     691                                fd_hook_call(HOOK_MESSAGE_ROUTING_LOCAL, msgptr, NULL, NULL, fd_msg_pmdl_get(msgptr));
    678692                                CHECK_FCT( fd_fifo_post(fd_g_local, &msgptr) );
    679693                        } else {
    680694                                /* We don't support the application, reply an error */
     695                                fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Application unsupported", fd_msg_pmdl_get(msgptr));
    681696                                CHECK_FCT( return_error( &msgptr, "DIAMETER_APPLICATION_UNSUPPORTED", NULL, NULL) );
    682697                        }
     
    687702                if ((is_dest_host == NO) || (is_dest_realm == NO)) {
    688703                        if (fd_g_config->cnf_flags.no_fwd) {
     704                                fd_hook_call(HOOK_MESSAGE_ROUTING_ERROR, msgptr, NULL, "Message for another realm/host", fd_msg_pmdl_get(msgptr));
    689705                                CHECK_FCT( return_error( &msgptr, "DIAMETER_UNABLE_TO_DELIVER", "I am not a Diameter agent", NULL) );
    690706                                return 0;
     
    700716                                        {
    701717                                                /* If the process failed, we assume it is because of the AVP format */
     718                                                fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Failed to process decorated NAI", fd_msg_pmdl_get(msgptr));
    702719                                                CHECK_FCT( return_error( &msgptr, "DIAMETER_INVALID_AVP_VALUE", "Failed to process decorated NAI", un) );
    703720                                                return 0;
     
    713730                        if (is_local_app == YES) {
    714731                                /* Handle localy since we are able to */
     732                                fd_hook_call(HOOK_MESSAGE_ROUTING_LOCAL, msgptr, NULL, NULL, fd_msg_pmdl_get(msgptr));
    715733                                CHECK_FCT(fd_fifo_post(fd_g_local, &msgptr) );
    716734                                return 0;
     
    719737                        if (fd_g_config->cnf_flags.no_fwd) {
    720738                                /* We return an error */
     739                                fd_hook_call(HOOK_MESSAGE_ROUTING_ERROR, msgptr, NULL, "Application unsupported", fd_msg_pmdl_get(msgptr));
    721740                                CHECK_FCT( return_error( &msgptr, "DIAMETER_APPLICATION_UNSUPPORTED", NULL, NULL) );
    722741                                return 0;
     
    736755                if ((!qry_src) && (!is_err)) {
    737756                        /* The message is a normal answer to a request issued localy, we do not call the callbacks chain on it. */
     757                        fd_hook_call(HOOK_MESSAGE_ROUTING_LOCAL, msgptr, NULL, NULL, fd_msg_pmdl_get(msgptr));
    738758                        CHECK_FCT(fd_fifo_post(fd_g_local, &msgptr) );
    739759                        return 0;
     
    764784                        CHECK_FCT_DO( ret = (*rh->rt_fwd_cb)(rh->cbdata, &msgptr),
    765785                                {
    766                                         //fd_msg_log( FD_MSG_LOG_DROPPED, msgptr, "Internal error: a FWD routing callback returned an error (%s)", strerror(ret));
     786                                        char buf[256];
     787                                        snprintf(buf, sizeof(buf), "A FWD routing callback returned an error: %s", strerror(ret));
     788                                        fd_hook_call(HOOK_MESSAGE_ROUTING_ERROR, msgptr, NULL, buf, fd_msg_pmdl_get(msgptr));
     789                                        fd_hook_call(HOOK_MESSAGE_DROPPED, msgptr, NULL, buf, fd_msg_pmdl_get(msgptr));
    767790                                        fd_msg_free(msgptr);
    768791                                        msgptr = NULL;
     792                                        break;
    769793                                } );
    770794                }
     
    780804        /* Now pass the message to the next step: either forward to another peer, or dispatch to local extensions */
    781805        if (is_req || qry_src) {
     806                fd_hook_call(HOOK_MESSAGE_ROUTING_FORWARD, msgptr, NULL, NULL, fd_msg_pmdl_get(msgptr));
    782807                CHECK_FCT(fd_fifo_post(fd_g_outgoing, &msgptr) );
    783808        } else {
     809                fd_hook_call(HOOK_MESSAGE_ROUTING_LOCAL, msgptr, NULL, NULL, fd_msg_pmdl_get(msgptr));
    784810                CHECK_FCT(fd_fifo_post(fd_g_local, &msgptr) );
    785811        }
     
    823849                CHECK_FCT( fd_peer_getbyid( qry_src, qry_src_len, 0, (void *) &peer ) );
    824850                if (fd_peer_getstate(peer) != STATE_OPEN) {
    825                         //fd_msg_log( FD_MSG_LOG_DROPPED, msgptr, "Unable to forward answer to deleted / closed peer '%s'.", qry_src);
     851                        char buf[128];
     852                        snprintf(buf, sizeof(buf), "Unable to forward answer to deleted / closed peer '%s'.", qry_src);
     853                        fd_hook_call(HOOK_MESSAGE_ROUTING_ERROR, msgptr, NULL, buf, fd_msg_pmdl_get(msgptr));
     854                        fd_hook_call(HOOK_MESSAGE_DROPPED, msgptr, NULL, buf, fd_msg_pmdl_get(msgptr));
    826855                        fd_msg_free(msgptr);
    827856                        return 0;
     
    908937                        CHECK_FCT_DO( ret = (*rh->rt_out_cb)(rh->cbdata, msgptr, candidates),
    909938                                {
    910                                         //fd_msg_log( FD_MSG_LOG_DROPPED, msgptr, "Internal error: an OUT routing callback returned an error (%s)", strerror(ret));
     939                                        char buf[256];
     940                                        snprintf(buf, sizeof(buf), "An OUT routing callback returned an error: %s", strerror(ret));
     941                                        fd_hook_call(HOOK_MESSAGE_ROUTING_ERROR, msgptr, NULL, buf, fd_msg_pmdl_get(msgptr));
     942                                        fd_hook_call(HOOK_MESSAGE_DROPPED, msgptr, NULL, buf, fd_msg_pmdl_get(msgptr));
    911943                                        fd_msg_free(msgptr);
    912944                                        msgptr = NULL;
     
    956988        /* If the message has not been sent, return an error */
    957989        if (msgptr) {
    958                 //fd_msg_log( FD_MSG_LOG_NODELIVER, msgptr, "No suitable candidate to route the message to." );
     990                fd_hook_call(HOOK_MESSAGE_ROUTING_ERROR, msgptr, NULL, "No remaining suitable candidate to route the message to", fd_msg_pmdl_get(msgptr));
    959991                return_error( &msgptr, "DIAMETER_UNABLE_TO_DELIVER", "No suitable candidate to route the message to", NULL);
    960992        }
  • libfdcore/server.c

    r1103 r1113  
    9494
    9595/* Dump all servers information */
    96 DECLARE_FD_DUMP_PROTOTYPE(fd_servers_dump)
     96DECLARE_FD_DUMP_PROTOTYPE(fd_servers_dump, int details)
    9797{
    9898        struct fd_list * li, *cli;
     
    104104                enum s_state st = get_status(s);
    105105               
    106                 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{server}(@%p)'%s': %s, %s, %s", s, fd_cnx_getid(s->conn),
    107                                 IPPROTO_NAME( s->proto ),
    108                                 s->secur ? "Secur" : "NotSecur",
    109                                 (st == NOT_CREATED) ? "Thread not created" :
    110                                 ((st == RUNNING) ? "Thread running" :
    111                                 ((st == TERMINATED) ? "Thread terminated" :
    112                                                           "Thread status unknown"))), return NULL);
    113                 /* Dump the client list of this server */
    114                 CHECK_POSIX_DO( pthread_mutex_lock(&s->clients_mtx), );
    115                 for (cli = s->clients.next; cli != &s->clients; cli = cli->next) {
    116                         struct client * c = (struct client *)cli;
    117                         char bufts[128];
    118                         CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n  {client}(@%p)'%s': to:%s", c, fd_cnx_getid(c->conn), fd_log_time(&c->ts, bufts, sizeof(bufts))), break);
    119                 }
    120                 CHECK_POSIX_DO( pthread_mutex_unlock(&s->clients_mtx), );
    121                
    122                 if (li->next != &FD_SERVERS) {
    123                         CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL);
     106                if (details) {
     107                        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{server}(@%p)'%s': %s, %s, %s", s, fd_cnx_getid(s->conn),
     108                                        IPPROTO_NAME( s->proto ),
     109                                        s->secur ? "Secur" : "NotSecur",
     110                                        (st == NOT_CREATED) ? "Thread not created" :
     111                                        ((st == RUNNING) ? "Thread running" :
     112                                        ((st == TERMINATED) ? "Thread terminated" :
     113                                                                  "Thread status unknown"))), return NULL);
     114                        /* Dump the client list of this server */
     115                        CHECK_POSIX_DO( pthread_mutex_lock(&s->clients_mtx), );
     116                        for (cli = s->clients.next; cli != &s->clients; cli = cli->next) {
     117                                struct client * c = (struct client *)cli;
     118                                char bufts[128];
     119                                CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n  {client}(@%p)'%s': to:%s", c, fd_cnx_getid(c->conn), fd_log_time(&c->ts, bufts, sizeof(bufts))), break);
     120                        }
     121                        CHECK_POSIX_DO( pthread_mutex_unlock(&s->clients_mtx), );
     122
     123                        if (li->next != &FD_SERVERS) {
     124                                CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL);
     125                        }
     126                } else {
     127                        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "'%s'(%s,%s)  ", fd_cnx_getid(s->conn),
     128                                        IPPROTO_NAME( s->proto ), s->secur ? "Secur" : "NotSecur"), return NULL);
    124129                }
    125130        }
     
    446451                size_t len = 0, offset = 0;
    447452                CHECK_MALLOC_DO( fd_dump_extend( &buf, &len, &offset , "Local server address(es): "), );
    448                 CHECK_MALLOC_DO( fd_ep_dump(  &buf, &len, &offset, 5, &fd_g_config->cnf_endpoints ), );
     453                CHECK_MALLOC_DO( fd_ep_dump(  &buf, &len, &offset, 0, 0, &fd_g_config->cnf_endpoints ), );
    449454                LOG_N("%s", buf ?: "Error dumping addresses");
    450455                free(buf);
Note: See TracChangeset for help on using the changeset viewer.