Navigation


Changes in / [964:992ef1167344:963:8702913eb443] in freeDiameter


Ignore:
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/CMakeLists.txt

    r935 r933  
    2929OPTION(DISABLE_PEER_EXPIRY "Disable RFC3539 Peers Connections Expiration after inactivity?" OFF)
    3030
    31 # The following workaround increases compatibility with some implementations without breaking anything in freeDiameter,
    32 # so it can be enabled without risk. We keep it disabled by default anyway for those people who use freeDiameter to check the
    33 # compliancy of their implementation with the Diameter RFC...
    34 OPTION(WORKAROUND_ACCEPT_INVALID_VSAI "Do not reject a CER/CEA with a Vendor-Specific-Application-Id AVP containing both Auth- and Acct- application AVPs?" OFF)
    35 
    36 MARK_AS_ADVANCED(DISABLE_SCTP DEBUG_SCTP SCTP_USE_MAPPED_ADDRESSES ERRORS_ON_TODO DIAMID_IDNA_IGNORE DIAMID_IDNA_REJECT DISABLE_PEER_EXPIRY WORKAROUND_ACCEPT_INVALID_VSAI)
     31
     32MARK_AS_ADVANCED(DISABLE_SCTP DEBUG_SCTP SCTP_USE_MAPPED_ADDRESSES ERRORS_ON_TODO DIAMID_IDNA_IGNORE DIAMID_IDNA_REJECT DISABLE_PEER_EXPIRY)
    3733
    3834########################
  • include/freeDiameter/freeDiameter-host.h.in

    r935 r933  
    6060#cmakedefine DIAMID_IDNA_REJECT
    6161#cmakedefine DISABLE_PEER_EXPIRY
    62 #cmakedefine WORKAROUND_ACCEPT_INVALID_VSAI
    6362#cmakedefine GNUTLS_VERSION_210
    6463#cmakedefine GNUTLS_VERSION_300
  • libfdcore/fdd.y

    r964 r961  
    328328                                if (fd == NULL) {
    329329                                        int ret = errno;
    330                                         TRACE_DEBUG_ERROR("WARNING: Unable to open extension file %s for reading: %s\nLD_LIBRARY_PATH will be used.\n", fname, strerror(ret));
    331                                 } else {
    332                                         fclose(fd);
    333                                 }
     330                                        TRACE_DEBUG_ERROR("Unable to open extension file %s for reading: %s\n", fname, strerror(ret));
     331                                        yyerror (&yylloc, conf, "Error adding extension");
     332                                        YYERROR;
     333                                }
     334                                fclose(fd);
    334335                               
    335336                                /* Try and open the configuration file (optional) */
  • libfdcore/p_ce.c

    r935 r837  
    455455                                {
    456456                                        struct avp * inavp = NULL;
     457                                        application_id_t aid = 0;
    457458                                        vendor_id_t vid = 0;
    458                                         application_id_t auth_aid = 0;
    459                                         application_id_t acct_aid = 0;
    460                                         int invalid=0;
     459                                        int auth = 0;
     460                                        int acct = 0;
    461461
    462462                                        /* get the first child AVP */
     
    482482                                                switch (inhdr->avp_code) {
    483483                                                        case AC_VENDOR_ID: /* Vendor-Id */
    484                                                                 if (vid != 0)
    485                                                                         invalid++; /* We already had one such AVP */
    486484                                                                vid = inhdr->avp_value->u32;
    487485                                                                break;
    488486                                                        case AC_AUTH_APPLICATION_ID: /* Auth-Application-Id */
    489                                                                 if (auth_aid != 0)
    490                                                                         invalid++; /* We already had one such AVP */
    491 #ifndef WORKAROUND_ACCEPT_INVALID_VSAI
    492                                                                 if (acct_aid != 0)
    493                                                                         invalid++; /* Only 1 *-Application-Id AVP is allowed */
    494 #endif /* WORKAROUND_ACCEPT_INVALID_VSAI */
    495                                                                 auth_aid = inhdr->avp_value->u32;
     487                                                                aid = inhdr->avp_value->u32;
     488                                                                auth += 1;
    496489                                                                break;
    497490                                                        case AC_ACCT_APPLICATION_ID: /* Acct-Application-Id */
    498                                                                 if (acct_aid != 0)
    499                                                                         invalid++; /* We already had one such AVP */
    500 #ifndef WORKAROUND_ACCEPT_INVALID_VSAI
    501                                                                 if (auth_aid != 0)
    502                                                                         invalid++; /* Only 1 *-Application-Id AVP is allowed */
    503 #endif /* WORKAROUND_ACCEPT_INVALID_VSAI */
    504                                                                 acct_aid = inhdr->avp_value->u32;
     491                                                                aid = inhdr->avp_value->u32;
     492                                                                acct += 1;
    505493                                                                break;
    506494                                                        /* ignore other AVPs */
    507                                                 }
    508                                                
    509                                                 if (invalid) {
    510                                                         TRACE_DEBUG(FULL, "Invalid Vendor-Specific-Application-Id AVP received, ignored");
    511                                                         fd_msg_dump_one(FULL, avp);
    512                                                         error->pei_errcode = "DIAMETER_INVALID_AVP_VALUE";
    513                                                         error->pei_avp = avp;
    514                                                         return EINVAL;
    515495                                                }
    516496
     
    520500                                        }
    521501                                       
    522                                         /* Add entry in the list */
    523                                         if (auth_aid) {
    524                                                 CHECK_FCT( fd_app_merge(&peer->p_hdr.info.runtime.pir_apps, auth_aid, vid, 1, 0) );
    525                                         }
    526                                         if (acct_aid) {
    527                                                 CHECK_FCT( fd_app_merge(&peer->p_hdr.info.runtime.pir_apps, acct_aid, vid, 0, 1) );
     502                                        if (auth + acct != 1) {
     503                                                TRACE_DEBUG(FULL, "Invalid Vendor-Specific-Application-Id AVP received, ignored");
     504                                                fd_msg_dump_one(FULL, avp);
     505                                                error->pei_errcode = "DIAMETER_INVALID_AVP_VALUE";
     506                                                error->pei_avp = avp;
     507                                                return EINVAL;
     508                                        } else {
     509                                                /* Add an entry in the list */
     510                                                CHECK_FCT( fd_app_merge(&peer->p_hdr.info.runtime.pir_apps, aid, vid, auth, acct) );
    528511                                        }
    529512                                }
  • libfdcore/routing_dispatch.c

    r934 r754  
    424424
    425425/* The DISPATCH message processing */
    426 static int msg_dispatch(struct msg * msg)
     426static int msg_dispatch(struct msg ** pmsg)
    427427{
    428428        struct msg_hdr * hdr;
     
    432432        char * ec = NULL;
    433433        char * em = NULL;
    434         struct msg *msgptr = msg;
    435434
    436435        /* Read the message header */
    437         CHECK_FCT( fd_msg_hdr(msg, &hdr) );
     436        CHECK_FCT( fd_msg_hdr(*pmsg, &hdr) );
    438437        is_req = hdr->msg_flags & CMD_FLAG_REQUEST;
    439438       
     
    442441
    443442        /* At this point, we need to understand the message content, so parse it */
    444         CHECK_FCT_DO( ret = fd_msg_parse_or_error( &msgptr ),
     443        CHECK_FCT_DO( ret = fd_msg_parse_or_error( pmsg ),
    445444                {
    446445                        /* 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 */);
     446                        if ((ret == EBADMSG) && (*pmsg != NULL)) {
     447                                /* msg now contains the answer message to send back */
     448                                CHECK_FCT( fd_fifo_post(fd_g_outgoing, pmsg) );
     449                        }
     450                        if (*pmsg) {    /* another error happen'd */
     451                                fd_msg_log( FD_MSG_LOG_DROPPED, *pmsg,  "An unexpected error occurred while parsing the message (%s)", strerror(ret));
     452                                CHECK_FCT_DO( fd_msg_free(*pmsg), /* continue */);
     453                                *pmsg = NULL;
    454454                        }
    455455                        /* We're done with this one */
     
    464464
    465465                /* Retrieve the corresponding query */
    466                 CHECK_FCT( fd_msg_answ_getq( msgptr, &qry ) );
     466                CHECK_FCT( fd_msg_answ_getq( *pmsg, &qry ) );
    467467
    468468                /* Retrieve any registered handler */
     
    473473
    474474                        TRACE_DEBUG(FULL, "Calling callback registered when query was sent (%p, %p)", anscb, data);
    475                         (*anscb)(data, &msgptr);
     475                        (*anscb)(data, pmsg);
    476476                       
    477477                        /* If the message is processed, we're done */
    478                         if (msgptr == NULL) {
     478                        if (*pmsg == NULL) {
    479479                                return 0;
    480480                        }
    481                        
    482                         /* otherwise continue the dispatching --hoping that the anscb callback did not mess with our message :) */
    483481                }
    484482        }
    485483       
    486484        /* Retrieve the session of the message */
    487         CHECK_FCT( fd_msg_sess_get(fd_g_config->cnf_dict, msgptr, &sess, NULL) );
     485        CHECK_FCT( fd_msg_sess_get(fd_g_config->cnf_dict, *pmsg, &sess, NULL) );
    488486
    489487        /* Now, call any callback registered for the message */
    490         CHECK_FCT( fd_msg_dispatch ( &msgptr, sess, &action, &ec) );
     488        CHECK_FCT( fd_msg_dispatch ( pmsg, sess, &action, &ec) );
    491489
    492490        /* Now, act depending on msg and action and ec */
    493         if (msgptr) {
     491        if (*pmsg)
    494492                switch ( action ) {
    495493                        case DISP_ACT_CONT:
     
    497495                                if (!fd_g_config->cnf_flags.no_fwd) {
    498496                                        /* requeue to fd_g_outgoing */
    499                                         CHECK_FCT( fd_fifo_post(fd_g_outgoing, &msgptr) );
     497                                        CHECK_FCT( fd_fifo_post(fd_g_outgoing, pmsg) );
    500498                                        break;
    501499                                }
     
    511509                               
    512510                                if (!is_req) {
    513                                         fd_msg_log( FD_MSG_LOG_DROPPED, msgptr,  "Internal error: Answer received to locally issued request, but not handled by any handler.");
    514                                         fd_msg_free(msgptr);
     511                                        fd_msg_log( FD_MSG_LOG_DROPPED, *pmsg,  "Internal error: Answer received to locally issued request, but not handled by any handler.");
     512                                        fd_msg_free(*pmsg);
     513                                        *pmsg = NULL;
    515514                                        break;
    516515                                }
    517516                               
    518517                                /* Create an answer with the error code and message */
    519                                 CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, &msgptr, 0 ) );
    520                                 CHECK_FCT( fd_msg_rescode_set(msgptr, ec, em, NULL, 1 ) );
     518                                CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, pmsg, 0 ) );
     519                                CHECK_FCT( fd_msg_rescode_set(*pmsg, ec, em, NULL, 1 ) );
    521520                               
    522521                        case DISP_ACT_SEND:
    523522                                /* Now, send the message */
    524                                 CHECK_FCT( fd_fifo_post(fd_g_outgoing, &msgptr) );
    525                 }
    526         }
     523                                CHECK_FCT( fd_fifo_post(fd_g_outgoing, pmsg) );
     524                }
    527525       
    528526        /* We're done with dispatching this message */
     
    531529
    532530/* The ROUTING-IN message processing */
    533 static int msg_rt_in(struct msg * msg)
     531static int msg_rt_in(struct msg ** pmsg)
    534532{
    535533        struct msg_hdr * hdr;
     
    538536        DiamId_t qry_src = NULL;
    539537        size_t   qry_src_len = 0;
    540         struct msg *msgptr = msg;
    541538
    542539        /* Read the message header */
    543         CHECK_FCT( fd_msg_hdr(msg, &hdr) );
     540        CHECK_FCT( fd_msg_hdr(*pmsg, &hdr) );
    544541        is_req = hdr->msg_flags & CMD_FLAG_REQUEST;
    545542        is_err = hdr->msg_flags & CMD_FLAG_ERROR;
     
    547544        /* Handle incorrect bits */
    548545        if (is_req && is_err) {
    549                 CHECK_FCT( return_error( &msgptr, "DIAMETER_INVALID_HDR_BITS", "R & E bits were set", NULL) );
     546                CHECK_FCT( return_error( pmsg, "DIAMETER_INVALID_HDR_BITS", "R & E bits were set", NULL) );
    550547                return 0;
    551548        }
     
    567564                        TRACE_DEBUG(INFO, "Received a routable message with application id 0 or " _stringize(AI_RELAY) " (relay),\n"
    568565                                          " returning DIAMETER_APPLICATION_UNSUPPORTED");
    569                         CHECK_FCT( return_error( &msgptr, "DIAMETER_APPLICATION_UNSUPPORTED", "Routable message with application id 0 or relay", NULL) );
     566                        CHECK_FCT( return_error( pmsg, "DIAMETER_APPLICATION_UNSUPPORTED", "Routable message with application id 0 or relay", NULL) );
    570567                        return 0;
    571568                } else {
     
    576573
    577574                /* Parse the message for Dest-Host and Dest-Realm */
    578                 CHECK_FCT(  fd_msg_browse(msgptr, MSG_BRW_FIRST_CHILD, &avp, NULL)  );
     575                CHECK_FCT(  fd_msg_browse(*pmsg, MSG_BRW_FIRST_CHILD, &avp, NULL)  );
    579576                while (avp) {
    580577                        struct avp_hdr * ahdr;
     
    593590                                                        {
    594591                                                                if (error_info.pei_errcode) {
    595                                                                         CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
     592                                                                        CHECK_FCT( return_error( pmsg, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
    596593                                                                        return 0;
    597594                                                                } else {
     
    613610                                                        {
    614611                                                                if (error_info.pei_errcode) {
    615                                                                         CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
     612                                                                        CHECK_FCT( return_error( pmsg, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
    616613                                                                        return 0;
    617614                                                                } else {
     
    635632                                                        {
    636633                                                                if (error_info.pei_errcode) {
    637                                                                         CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
     634                                                                        CHECK_FCT( return_error( pmsg, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
    638635                                                                        return 0;
    639636                                                                } else {
     
    660657                /* Handle the missing routing AVPs first */
    661658                if ( is_dest_realm == UNKNOWN ) {
    662                         CHECK_FCT( return_error( &msgptr, "DIAMETER_COMMAND_UNSUPPORTED", "Non-routable message not supported (invalid bit ? missing Destination-Realm ?)", NULL) );
     659                        CHECK_FCT( return_error( pmsg, "DIAMETER_COMMAND_UNSUPPORTED", "Non-routable message not supported (invalid bit ? missing Destination-Realm ?)", NULL) );
    663660                        return 0;
    664661                }
     
    668665                        if (is_local_app == YES) {
    669666                                /* Ok, give the message to the dispatch thread */
    670                                 CHECK_FCT( fd_fifo_post(fd_g_local, &msgptr) );
     667                                CHECK_FCT( fd_fifo_post(fd_g_local, pmsg) );
    671668                        } else {
    672669                                /* We don't support the application, reply an error */
    673                                 CHECK_FCT( return_error( &msgptr, "DIAMETER_APPLICATION_UNSUPPORTED", NULL, NULL) );
     670                                CHECK_FCT( return_error( pmsg, "DIAMETER_APPLICATION_UNSUPPORTED", NULL, NULL) );
    674671                        }
    675672                        return 0;
     
    679676                if ((is_dest_host == NO) || (is_dest_realm == NO)) {
    680677                        if (fd_g_config->cnf_flags.no_fwd) {
    681                                 CHECK_FCT( return_error( &msgptr, "DIAMETER_UNABLE_TO_DELIVER", "I am not a Diameter agent", NULL) );
     678                                CHECK_FCT( return_error( pmsg, "DIAMETER_UNABLE_TO_DELIVER", "I am not a Diameter agent", NULL) );
    682679                                return 0;
    683680                        }
     
    692689                                        {
    693690                                                /* If the process failed, we assume it is because of the AVP format */
    694                                                 CHECK_FCT( return_error( &msgptr, "DIAMETER_INVALID_AVP_VALUE", "Failed to process decorated NAI", un) );
     691                                                CHECK_FCT( return_error( pmsg, "DIAMETER_INVALID_AVP_VALUE", "Failed to process decorated NAI", un) );
    695692                                                return 0;
    696693                                        } );
     
    699696                        if (is_nai) {
    700697                                /* We have transformed the AVP, now submit it again in the queue */
    701                                 CHECK_FCT(fd_fifo_post(fd_g_incoming, &msgptr) );
     698                                CHECK_FCT(fd_fifo_post(fd_g_incoming, pmsg) );
    702699                                return 0;
    703700                        }
     
    705702                        if (is_local_app == YES) {
    706703                                /* Handle localy since we are able to */
    707                                 CHECK_FCT(fd_fifo_post(fd_g_local, &msgptr) );
     704                                CHECK_FCT(fd_fifo_post(fd_g_local, pmsg) );
    708705                                return 0;
    709706                        }
     
    711708                        if (fd_g_config->cnf_flags.no_fwd) {
    712709                                /* We return an error */
    713                                 CHECK_FCT( return_error( &msgptr, "DIAMETER_APPLICATION_UNSUPPORTED", NULL, NULL) );
     710                                CHECK_FCT( return_error( pmsg, "DIAMETER_APPLICATION_UNSUPPORTED", NULL, NULL) );
    714711                                return 0;
    715712                        }
     
    723720
    724721                /* Retrieve the corresponding query and its origin */
    725                 CHECK_FCT( fd_msg_answ_getq( msgptr, &qry ) );
     722                CHECK_FCT( fd_msg_answ_getq( *pmsg, &qry ) );
    726723                CHECK_FCT( fd_msg_source_get( qry, &qry_src, &qry_src_len ) );
    727724
    728725                if ((!qry_src) && (!is_err)) {
    729726                        /* The message is a normal answer to a request issued localy, we do not call the callbacks chain on it. */
    730                         CHECK_FCT(fd_fifo_post(fd_g_local, &msgptr) );
     727                        CHECK_FCT(fd_fifo_post(fd_g_local, pmsg) );
    731728                        return 0;
    732729                }
     
    743740
    744741                /* requests: dir = 1 & 2 => in order; answers = 3 & 2 => in reverse order */
    745                 for (   li = (is_req ? rt_fwd_list.next : rt_fwd_list.prev) ; msgptr && (li != &rt_fwd_list) ; li = (is_req ? li->next : li->prev) ) {
     742                for (   li = (is_req ? rt_fwd_list.next : rt_fwd_list.prev) ; *pmsg && (li != &rt_fwd_list) ; li = (is_req ? li->next : li->prev) ) {
    746743                        struct rt_hdl * rh = (struct rt_hdl *)li;
    747744                        int ret;
     
    753750
    754751                        /* Ok, call this cb */
    755                         TRACE_DEBUG(ANNOYING, "Calling next FWD callback on %p : %p", msgptr, rh->rt_fwd_cb);
    756                         CHECK_FCT_DO( ret = (*rh->rt_fwd_cb)(rh->cbdata, &msgptr),
     752                        TRACE_DEBUG(ANNOYING, "Calling next FWD callback on %p : %p", *pmsg, rh->rt_fwd_cb);
     753                        CHECK_FCT_DO( ret = (*rh->rt_fwd_cb)(rh->cbdata, pmsg),
    757754                                {
    758                                         fd_msg_log( FD_MSG_LOG_DROPPED, msgptr, "Internal error: a FWD routing callback returned an error (%s)", strerror(ret));
    759                                         fd_msg_free(msgptr);
    760                                         msgptr = NULL;
     755                                        fd_msg_log( FD_MSG_LOG_DROPPED, *pmsg, "Internal error: a FWD routing callback returned an error (%s)", strerror(ret));
     756                                        fd_msg_free(*pmsg);
     757                                        *pmsg = NULL;
    761758                                } );
    762759                }
     
    766763
    767764                /* If a callback has handled the message, we stop now */
    768                 if (!msgptr)
     765                if (!*pmsg)
    769766                        return 0;
    770767        }
     
    772769        /* Now pass the message to the next step: either forward to another peer, or dispatch to local extensions */
    773770        if (is_req || qry_src) {
    774                 CHECK_FCT(fd_fifo_post(fd_g_outgoing, &msgptr) );
     771                CHECK_FCT(fd_fifo_post(fd_g_outgoing, pmsg) );
    775772        } else {
    776                 CHECK_FCT(fd_fifo_post(fd_g_local, &msgptr) );
     773                CHECK_FCT(fd_fifo_post(fd_g_local, pmsg) );
    777774        }
    778775
     
    783780
    784781/* The ROUTING-OUT message processing */
    785 static int msg_rt_out(struct msg * msg)
     782static int msg_rt_out(struct msg ** pmsg)
    786783{
    787784        struct rt_data * rtd = NULL;
     
    792789        struct avp * avp;
    793790        struct rtd_candidate * c;
    794         struct msg *msgptr = msg;
    795791       
    796792        /* Read the message header */
    797         CHECK_FCT( fd_msg_hdr(msgptr, &hdr) );
     793        CHECK_FCT( fd_msg_hdr(*pmsg, &hdr) );
    798794        is_req = hdr->msg_flags & CMD_FLAG_REQUEST;
    799795       
     
    807803
    808804                /* Retrieve the corresponding query and its origin */
    809                 CHECK_FCT( fd_msg_answ_getq( msgptr, &qry ) );
     805                CHECK_FCT( fd_msg_answ_getq( *pmsg, &qry ) );
    810806                CHECK_FCT( fd_msg_source_get( qry, &qry_src, &qry_src_len ) );
    811807
     
    815811                CHECK_FCT( fd_peer_getbyid( qry_src, qry_src_len, 0, (void *) &peer ) );
    816812                if (fd_peer_getstate(peer) != STATE_OPEN) {
    817                         fd_msg_log( FD_MSG_LOG_DROPPED, msgptr, "Unable to forward answer to deleted / closed peer '%s'.", qry_src);
    818                         fd_msg_free(msgptr);
     813                        fd_msg_log( FD_MSG_LOG_DROPPED, *pmsg, "Unable to forward answer to deleted / closed peer '%s'.", qry_src);
     814                        fd_msg_free(*pmsg);
     815                        *pmsg = NULL;
    819816                        return 0;
    820817                }
     
    825822
    826823                /* Push the message into this peer */
    827                 CHECK_FCT( fd_out_send(&msgptr, NULL, peer, 0) );
     824                CHECK_FCT( fd_out_send(pmsg, NULL, peer, 0) );
    828825
    829826                /* We're done with this answer */
     
    834831
    835832        /* Get the routing data out of the message if any (in case of re-transmit) */
    836         CHECK_FCT( fd_msg_rt_get ( msgptr, &rtd ) );
     833        CHECK_FCT( fd_msg_rt_get ( *pmsg, &rtd ) );
    837834
    838835        /* If there is no routing data already, let's create it */
     
    854851
    855852                /* Now let's remove all peers from the Route-Records */
    856                 CHECK_FCT(  fd_msg_browse(msgptr, MSG_BRW_FIRST_CHILD, &avp, NULL)  );
     853                CHECK_FCT(  fd_msg_browse(*pmsg, MSG_BRW_FIRST_CHILD, &avp, NULL)  );
    857854                while (avp) {
    858855                        struct avp_hdr * ahdr;
     
    865862                                        {
    866863                                                if (error_info.pei_errcode) {
    867                                                         CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
     864                                                        CHECK_FCT( return_error( pmsg, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
    868865                                                        return 0;
    869866                                                } else {
     
    886883        fd_rtd_candidate_extract(rtd, &candidates, FD_SCORE_INI);
    887884
    888         /* Pass the list to registered callbacks (even if it is empty list) */
     885        /* Pass the list to registered callbacks (even if it is empty) */
    889886        {
    890887                CHECK_FCT( pthread_rwlock_rdlock( &rt_out_lock ) );
     
    895892                        struct rt_hdl * rh = (struct rt_hdl *)li;
    896893
    897                         TRACE_DEBUG(ANNOYING, "Calling next OUT callback on %p : %p (prio %d)", msgptr, rh->rt_out_cb, rh->prio);
    898                         CHECK_FCT_DO( ret = (*rh->rt_out_cb)(rh->cbdata, msgptr, candidates),
     894                        TRACE_DEBUG(ANNOYING, "Calling next OUT callback on %p : %p (prio %d)", *pmsg, rh->rt_out_cb, rh->prio);
     895                        CHECK_FCT_DO( ret = (*rh->rt_out_cb)(rh->cbdata, *pmsg, candidates),
    899896                                {
    900                                         fd_msg_log( FD_MSG_LOG_DROPPED, msgptr, "Internal error: an OUT routing callback returned an error (%s)", strerror(ret));
    901                                         fd_msg_free(msgptr);
    902                                         msgptr = NULL;
     897                                        fd_msg_log( FD_MSG_LOG_DROPPED, *pmsg, "Internal error: an OUT routing callback returned an error (%s)", strerror(ret));
     898                                        fd_msg_free(*pmsg);
     899                                        *pmsg = NULL;
    903900                                        break;
    904901                                } );
     
    909906
    910907                /* If an error occurred, skip to the next message */
    911                 if (! msgptr) {
     908                if (! *pmsg) {
    912909                        if (rtd)
    913910                                fd_rtd_free(&rtd);
     
    920917
    921918        /* Save the routing information in the message */
    922         CHECK_FCT( fd_msg_rt_associate ( msgptr, &rtd ) );
     919        CHECK_FCT( fd_msg_rt_associate ( *pmsg, &rtd ) );
    923920
    924921        /* Now try sending the message */
     
    937934                if (fd_peer_getstate(peer) == STATE_OPEN) {
    938935                        /* Send to this one */
    939                         CHECK_FCT_DO( fd_out_send(&msgptr, NULL, peer, 0), continue );
     936                        CHECK_FCT_DO( fd_out_send(pmsg, NULL, peer, 0), continue );
    940937                       
    941938                        /* If the sending was successful */
     
    945942
    946943        /* If the message has not been sent, return an error */
    947         if (msgptr) {
    948                 fd_msg_log( FD_MSG_LOG_NODELIVER, msgptr, "No suitable candidate to route the message to." );
    949                 return_error( &msgptr, "DIAMETER_UNABLE_TO_DELIVER", "No suitable candidate to route the message to", NULL);
     944        if (*pmsg) {
     945                fd_msg_log( FD_MSG_LOG_NODELIVER, *pmsg, "No suitable candidate to route the message to." );
     946                return_error( pmsg, "DIAMETER_UNABLE_TO_DELIVER", "No suitable candidate to route the message to", NULL);
    950947        }
    951948
     
    980977
    981978/* This is the common thread code (same for routing and dispatching) */
    982 static void * process_thr(void * arg, int (*action_cb)(struct msg * msg), struct fifo * queue, char * action_name)
     979static void * process_thr(void * arg, int (*action_cb)(struct msg ** pmsg), struct fifo * queue, char * action_name)
    983980{
    984981        TRACE_ENTRY("%p %p %p %p", arg, action_cb, queue, action_name);
     
    10431040               
    10441041                /* Now process the message */
    1045                 CHECK_FCT_DO( (*action_cb)(msg), goto fatal_error);
     1042                CHECK_FCT_DO( (*action_cb)(&msg), goto fatal_error);
    10461043
    10471044                /* We're done with this message */
Note: See TracChangeset for help on using the changeset viewer.