Navigation


Changes in / [1269:c748e2439a3a:1280:3eeb564e7bea] in freeDiameter


Ignore:
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • contrib/test_Gx/main_gx.c

    r1257 r1271  
    1414/* The content of this file follows the same structure as dict_base_proto.c */
    1515
     16#if 0
    1617#define CHECK_dict_new( _type, _data, _parent, _ref )  \
    1718       CHECK_FCT(  fd_dict_new( fd_g_config->cnf_dict, (_type), (_data), (_parent), (_ref))  );
    18 
    19 #define CHECK_dict_search( _type, _criteria, _what, _result )  \
    20        CHECK_FCT(  fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) );
     19#endif
    2120
    2221void dump_sess_eyec(struct session *sess, const char *);
    23 struct local_rules_definition {
    24        char                    *avp_name;
    25        enum rule_position      position;
    26        int                     min;
    27        int                     max;
    28 };
    29 
    30 #define RULE_ORDER( _position ) ((((_position) == RULE_FIXED_HEAD) || ((_position) == RULE_FIXED_TAIL)) ? 1 : 0 )
    31 
    32 #define PARSE_loc_rules( _rulearray, _parent) {                                                                \
    33        int __ar;                                                                                       \
    34        for (__ar=0; __ar < sizeof(_rulearray) / sizeof((_rulearray)[0]); __ar++) {                     \
    35                struct dict_rule_data __data = { NULL,                                                  \
    36                        (_rulearray)[__ar].position,                                                    \
    37                        0,                                                                              \
    38                        (_rulearray)[__ar].min,                                                         \
    39                        (_rulearray)[__ar].max};                                                        \
    40                __data.rule_order = RULE_ORDER(__data.rule_position);                                   \
    41                CHECK_FCT(  fd_dict_search(                                                             \
    42                        fd_g_config->cnf_dict,                                                          \
    43                        DICT_AVP,                                                                       \
    44                        AVP_BY_NAME,                                                                    \
    45                        (_rulearray)[__ar].avp_name,                                                    \
    46                        &__data.rule_avp, 0 ) );                                                        \
    47                if ( !__data.rule_avp ) {                                                               \
    48                        TRACE_DEBUG(INFO, "AVP Not found: '%s'", (_rulearray)[__ar].avp_name );         \
    49                        return ENOENT;                                                                  \
    50                }                                                                                       \
    51                CHECK_FCT_DO( fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &__data, _parent, NULL),   \
    52                        {                                                                               \
    53                                TRACE_DEBUG(INFO, "Error on rule with AVP '%s'",                        \
    54                                         (_rulearray)[__ar].avp_name );                                 \
    55                                return EINVAL;                                                          \
    56                        } );                                                                            \
    57        }                                                                                               \
    58 }
    59 
    60 #define enumval_def_u32( _val_, _str_ ) \
    61                { _str_,                { .u32 = _val_ }}
    62 
    63 #define enumval_def_os( _len_, _val_, _str_ ) \
    64                { _str_,                { .os = { .data = (unsigned char *)_val_, .len = _len_ }}}
    65 
    66 
    67  
     22
    6823static int ccr_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act);
    6924static int reauth_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act);
     
    288243
    289244
    290        TRACE_DEBUG(INFO, "Extension 'Dictionary definitions for DCCA (rfc4006)' initialized");
     245       TRACE_DEBUG(INFO, "Extension 'Gx' initialized");
    291246       return 0;
    292247}
     
    861816 return 0;
    862817}
    863 EXTENSION_ENTRY( "app_gx", app_gx_entry, "dict_dcca");
     818EXTENSION_ENTRY( "app_gx", app_gx_entry, "dict_dcca_3gpp");
    864819//EXTENSION_ENTRY( "app_gx", gx_entry);
  • extensions/CMakeLists.txt

    r1126 r1278  
    6868# Routing extensions
    6969
     70FD_EXTENSION_SUBDIR(rt_busypeers "Handling of Diameter TOO_BUSY messages and relay timeouts"    ON)
    7071FD_EXTENSION_SUBDIR(rt_default   "Configurable routing rules for freeDiameter"                  ON)
    71 FD_EXTENSION_SUBDIR(rt_redirect  "Handling of Diameter Redirect messages"                       ON)
    72 FD_EXTENSION_SUBDIR(rt_busypeers "Handling of Diameter TOO_BUSY messages and relay timeouts"    ON)
    7372FD_EXTENSION_SUBDIR(rt_ereg      "Configurable routing based on regexp matching of AVP values" OFF)
    7473FD_EXTENSION_SUBDIR(rt_ignore_dh "Stow Destination-Host in Proxy-Info, restore to Origin-Host for answers"      ON)
    7574FD_EXTENSION_SUBDIR(rt_load_balance "Balance load over multiple equal hosts, based on outstanding requests"     ON)
     75FD_EXTENSION_SUBDIR(rt_randomize "Randomly choose one of the highest scored hosts and increase its score by one"        ON)
     76FD_EXTENSION_SUBDIR(rt_redirect  "Handling of Diameter Redirect messages"                       ON)
    7677
    7778
  • extensions/dict_dcca_starent/dict_dcca_starent.c

    r1227 r1276  
    8888        /* Changes will be lost during the next update. Modify the source org file instead. */
    8989
    90         /* Cisco ASR 5000 Series AAA Interface  */
    91         /* Administration and Reference         */
    92         /* Release 8.x and 9.0                  */
    93         /* Last Updated June 30, 2010           */
     90        /* Cisco ASR 5000 Series AAA Interface                                              */
     91        /* Administration and Reference                                                     */
     92        /* Release 8.x and 9.0                                                              */
     93        /* Last Updated June 30, 2010                                                       */
     94        /* updated using v15 docs from Jan 2014                                             */
     95        /* www.cisco.com/c/dam/en/us/td/docs/wireless/asr_5000/15-0/15-0-AAA-Reference.pdf  */
    9496        /* SN-Volume-Quota-Threshold */
    9597        {
     
    283285        };
    284286
     287        /* SN-Session-Start-Indicator */
     288        {
     289                struct dict_avp_data data = {
     290                        522,    /* Code */
     291                        8164,   /* Vendor */
     292                        "SN-Session-Start-Indicator",   /* Name */
     293                        AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY,    /* Fixed flags */
     294                        AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY,    /* Fixed flag values */
     295                        AVP_TYPE_OCTETSTRING    /* base type of data */
     296                };
     297                CHECK_dict_new(DICT_AVP, &data, NULL, NULL);
     298        };
     299
     300        /* SN-Phase0-PSAPName */
     301        {
     302                struct dict_avp_data data = {
     303                        523,    /* Code */
     304                        8164,   /* Vendor */
     305                        "SN-Phase0-PSAPName",   /* Name */
     306                        AVP_FLAG_VENDOR,        /* Fixed flags */
     307                        AVP_FLAG_VENDOR,        /* Fixed flag values */
     308                        AVP_TYPE_OCTETSTRING    /* base type of data */
     309                };
     310                CHECK_dict_new(DICT_AVP, &data, UTF8String_type, NULL);
     311        };
     312
     313        /* SN-Charging-Id */
     314        {
     315                struct dict_avp_data data = {
     316                        525,    /* Code */
     317                        8164,   /* Vendor */
     318                        "SN-Charging-Id",       /* Name */
     319                        AVP_FLAG_VENDOR,        /* Fixed flags */
     320                        AVP_FLAG_VENDOR,        /* Fixed flag values */
     321                        AVP_TYPE_OCTETSTRING    /* base type of data */
     322                };
     323                CHECK_dict_new(DICT_AVP, &data, NULL, NULL);
     324        };
     325
     326        /* SN-Remaining-Service-Unit */
     327        {
     328                struct dict_avp_data data = {
     329                        526,    /* Code */
     330                        8164,   /* Vendor */
     331                        "SN-Remaining-Service-Unit",    /* Name */
     332                        AVP_FLAG_VENDOR,        /* Fixed flags */
     333                        AVP_FLAG_VENDOR,        /* Fixed flag values */
     334                        AVP_TYPE_GROUPED        /* base type of data */
     335                };
     336                CHECK_dict_new(DICT_AVP, &data, NULL, NULL);
     337        };
     338
     339        /* SN-Service-Start-Timestamp */
     340        {
     341                struct dict_avp_data data = {
     342                        527,    /* Code */
     343                        8164,   /* Vendor */
     344                        "SN-Service-Start-Timestamp",   /* Name */
     345                        AVP_FLAG_VENDOR,        /* Fixed flags */
     346                        AVP_FLAG_VENDOR,        /* Fixed flag values */
     347                        AVP_TYPE_OCTETSTRING    /* base type of data */
     348                };
     349                CHECK_dict_new(DICT_AVP, &data, Time_type, NULL);
     350        };
     351
     352        /* SN-Rulebase-Id */
     353        {
     354                struct dict_avp_data data = {
     355                        528,    /* Code */
     356                        8164,   /* Vendor */
     357                        "SN-Rulebase-Id",       /* Name */
     358                        AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY,    /* Fixed flags */
     359                        AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY,    /* Fixed flag values */
     360                        AVP_TYPE_OCTETSTRING    /* base type of data */
     361                };
     362                CHECK_dict_new(DICT_AVP, &data, UTF8String_type, NULL);
     363        };
     364
     365        /* SN-CF-Policy-ID */
     366        {
     367                struct dict_avp_data data = {
     368                        529,    /* Code */
     369                        8164,   /* Vendor */
     370                        "SN-CF-Policy-ID",      /* Name */
     371                        AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY,    /* Fixed flags */
     372                        AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY,    /* Fixed flag values */
     373                        AVP_TYPE_UNSIGNED32     /* base type of data */
     374                };
     375                CHECK_dict_new(DICT_AVP, &data, NULL, NULL);
     376        };
     377
     378        /* SN-Charging-Collection-Function-Name */
     379        {
     380                struct dict_avp_data data = {
     381                        530,    /* Code */
     382                        8164,   /* Vendor */
     383                        "SN-Charging-Collection-Function-Name", /* Name */
     384                        AVP_FLAG_VENDOR,        /* Fixed flags */
     385                        AVP_FLAG_VENDOR,        /* Fixed flag values */
     386                        AVP_TYPE_OCTETSTRING    /* base type of data */
     387                };
     388                CHECK_dict_new(DICT_AVP, &data, UTF8String_type, NULL);
     389        };
     390
     391        /* SN-Fast-Reauth-Username */
     392        {
     393                struct dict_avp_data data = {
     394                        11010,  /* Code */
     395                        8164,   /* Vendor */
     396                        "SN-Fast-Reauth-Username",      /* Name */
     397                        AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY,    /* Fixed flags */
     398                        AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY,    /* Fixed flag values */
     399                        AVP_TYPE_OCTETSTRING    /* base type of data */
     400                };
     401                CHECK_dict_new(DICT_AVP, &data, NULL, NULL);
     402        };
     403
     404        /* SN-Pseudonym-Username */
     405        {
     406                struct dict_avp_data data = {
     407                        11011,  /* Code */
     408                        8164,   /* Vendor */
     409                        "SN-Pseudonym-Username",        /* Name */
     410                        AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY,    /* Fixed flags */
     411                        AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY,    /* Fixed flag values */
     412                        AVP_TYPE_OCTETSTRING    /* base type of data */
     413                };
     414                CHECK_dict_new(DICT_AVP, &data, NULL, NULL);
     415        };
     416
     417
    285418
    286419        /* Rules section */
     420
     421        /* SN-Remaining-Service-Unit */
     422        {
     423                struct dict_object *rule_avp;
     424                struct dict_avp_request vpa;
     425                vpa.avp_vendor = 8164;
     426                vpa.avp_name = "SN-Remaining-Service-Unit";
     427                CHECK_dict_search(DICT_AVP, AVP_BY_NAME_AND_VENDOR, &vpa, &rule_avp);
     428                struct local_rules_definition rules[] = {
     429                        {  "Tariff-Change-Usage",       RULE_OPTIONAL,  -1, 1 },
     430                        {  "CC-Time",                   RULE_OPTIONAL,  -1, 1 },
     431                        {  "CC-Total-Octets",           RULE_OPTIONAL,  -1, 1 },
     432                        {  "CC-Input-Octets",           RULE_OPTIONAL,  -1, 1 },
     433                        {  "CC-Output-Octets",          RULE_OPTIONAL,  -1, 1 },
     434                        {  "CC-Service-Specific-Units", RULE_OPTIONAL,  -1, 1 },
     435                        {  "Reporting-Reason",          RULE_OPTIONAL,  -1, 1 }
     436                };
     437                PARSE_loc_rules( rules, rule_avp );
     438        }
    287439
    288440        /* SN-Total-Used-Service-Unit */
  • extensions/dict_dcca_starent/dict_dcca_starent.org

    r962 r1276  
    1 | Attribute Name                        | Code | Section defined | Value Type  | MUST | MAY | SHLD NOT | MUST NOT | Encr |
    2 | # Cisco ASR 5000 Series AAA Interface |      |                 |             |      |     |          |          |      |
    3 | # Administration and Reference        |      |                 |             |      |     |          |          |      |
    4 | # Release 8.x and 9.0                 |      |                 |             |      |     |          |          |      |
    5 | # Last Updated June 30, 2010          |      |                 |             |      |     |          |          |      |
    6 | SN-Volume-Quota-Threshold             |  501 |                 | Unsigned32  | M,V  |     |          |          |      |
    7 | SN-Unit-Quota-Threshold               |  502 |                 | Unsigned32  | M,V  |     |          |          |      |
    8 | SN-Time-Quota-Threshold               |  503 |                 | Unsigned32  | M,V  |     |          |          |      |
    9 | SN-Total-Used-Service-Unit            |  504 |                 | Grouped     | V    |     |          |          |      |
    10 | SN-Absolute-Validity-Time             |  505 |                 | Time        | V    |     |          |          |      |
    11 | SN-Bandwidth-Control                  |  512 |                 | Enumerated  | M,V  |     |          |          |      |
    12 | SN-Transparent-Data                   |  513 |                 | OctetString | V    |     |          |          |      |
    13 | SN-Traffic-Policy                     |  514 |                 | UTF8String  | V    |     |          |          |      |
    14 | SN-Firewall-Policy                    |  515 |                 | UTF8String  | V    |     |          |          |      |
    15 | SN-Usage-Monitoring-Control           |  517 |                 | Grouped     | V    |     |          |          |      |
    16 | SN-Monitoring-Key                     |  518 |                 | Unsigned32  | V    |     |          |          |      |
    17 | SN-Usage-Volume                       |  519 |                 | Unsigned64  | V    |     |          |          |      |
    18 | SN-Service-Flow-Detection             |  520 |                 | Enumerated  | V    |     |          |          |      |
    19 | SN-Usage-Monitoring                   |  521 |                 | Enumerated  | V    |     |          |          |      |
     1| Attribute Name                                                                    |  Code | Section defined | Value Type  | MUST | MAY | SHLD NOT | MUST NOT | Encr |
     2| # Cisco ASR 5000 Series AAA Interface                                             |       |                 |             |      |     |          |          |      |
     3| # Administration and Reference                                                    |       |                 |             |      |     |          |          |      |
     4| # Release 8.x and 9.0                                                             |       |                 |             |      |     |          |          |      |
     5| # Last Updated June 30, 2010                                                      |       |                 |             |      |     |          |          |      |
     6| # updated using v15 docs from Jan 2014                                            |       |                 |             |      |     |          |          |      |
     7| # www.cisco.com/c/dam/en/us/td/docs/wireless/asr_5000/15-0/15-0-AAA-Reference.pdf |       |                 |             |      |     |          |          |      |
     8| SN-Volume-Quota-Threshold                                                         |   501 |                 | Unsigned32  | M,V  |     |          |          |      |
     9| SN-Unit-Quota-Threshold                                                           |   502 |                 | Unsigned32  | M,V  |     |          |          |      |
     10| SN-Time-Quota-Threshold                                                           |   503 |                 | Unsigned32  | M,V  |     |          |          |      |
     11| SN-Total-Used-Service-Unit                                                        |   504 |                 | Grouped     | V    |     |          |          |      |
     12| SN-Absolute-Validity-Time                                                         |   505 |                 | Time        | V    |     |          |          |      |
     13| SN-Bandwidth-Control                                                              |   512 |                 | Enumerated  | M,V  |     |          |          |      |
     14| SN-Transparent-Data                                                               |   513 |                 | OctetString | V    |     |          |          |      |
     15| SN-Traffic-Policy                                                                 |   514 |                 | UTF8String  | V    |     |          |          |      |
     16| SN-Firewall-Policy                                                                |   515 |                 | UTF8String  | V    |     |          |          |      |
     17| SN-Usage-Monitoring-Control                                                       |   517 |                 | Grouped     | V    |     |          |          |      |
     18| SN-Monitoring-Key                                                                 |   518 |                 | Unsigned32  | V    |     |          |          |      |
     19| SN-Usage-Volume                                                                   |   519 |                 | Unsigned64  | V    |     |          |          |      |
     20| SN-Service-Flow-Detection                                                         |   520 |                 | Enumerated  | V    |     |          |          |      |
     21| SN-Usage-Monitoring                                                               |   521 |                 | Enumerated  | V    |     |          |          |      |
     22| SN-Session-Start-Indicator                                                        |   522 |                 | OctetString | M,V  |     |          |          |      |
     23| SN-Phase0-PSAPName                                                                |   523 |                 | UTF8String  | V    |     |          |          |      |
     24| SN-Charging-Id                                                                    |   525 |                 | OctetString | V    |     |          |          |      |
     25| SN-Remaining-Service-Unit                                                         |   526 |                 | Grouped     | V    |     |          |          |      |
     26| SN-Service-Start-Timestamp                                                        |   527 |                 | Time        | V    |     |          |          |      |
     27| SN-Rulebase-Id                                                                    |   528 |                 | UTF8String  | M,V  |     |          |          |      |
     28| SN-CF-Policy-ID                                                                   |   529 |                 | Unsigned32  | M,V  |     |          |          |      |
     29| SN-Charging-Collection-Function-Name                                              |   530 |                 | UTF8String  | V    |     |          |          |      |
     30| SN-Fast-Reauth-Username                                                           | 11010 |                 | OctetString | M,V  |     |          |          |      |
     31| SN-Pseudonym-Username                                                             | 11011 |                 | OctetString | M,V  |     |          |          |      |
  • extensions/rt_busypeers/rtbusy.c

    r1127 r1279  
    5050        struct rt_data * rtd = NULL;
    5151        struct fd_list * candidates = NULL;
    52         int sendingattemtps;
     52        int sendingattempts;
    5353        int resend = 1;
    5454       
     
    7373                                    ER_DIAMETER_TOO_BUSY,
    7474                                    &candidates,
    75                                     &sendingattemtps) );
     75                                    &sendingattempts) );
    7676       
    7777        /* Now we need to decide if we re-send this query to a different peer or return an error to upstream */
     
    7979        /* First, are we exceeding the allowed attempts? */
    8080        if (rtbusy_conf.RetryMaxPeers != 0) {
    81                 if (sendingattemtps >= rtbusy_conf.RetryMaxPeers) {
     81                if (sendingattempts >= rtbusy_conf.RetryMaxPeers) {
    8282                        TRACE_DEBUG(FULL, "Maximum number of sending attempts reached for message %p, returning an error upstream", qry);
    8383                        resend = 0;
     
    107107                /* Send the query again. We  need to re-associate the expirecb which was cleaned, if it is used */
    108108                if (rtbusy_conf.RelayTimeout) {
     109                        char *buf = NULL;
     110                        size_t len;
    109111                        struct timespec expire;
    110112                        CHECK_SYS(  clock_gettime(CLOCK_REALTIME, &expire)  );
    111113                        expire.tv_sec += rtbusy_conf.RelayTimeout/1000 + ((expire.tv_nsec + (1000000LL * (rtbusy_conf.RelayTimeout % 1000))) / 1000000000LL);
    112114                        expire.tv_nsec = (expire.tv_nsec + (1000000LL * (rtbusy_conf.RelayTimeout % 1000))) % 1000000000LL;
     115                        CHECK_MALLOC_DO( fd_msg_dump_full(&buf, &len, NULL, *pmsg, fd_g_config->cnf_dict, 0, 1), /* nothing */);
     116                        TRACE_ERROR( "No answer received for message from peer '%.*s' before timeout (%dms), re-sending: %s", senttolen, sentto,
     117                                     rtbusy_conf.RelayTimeout, buf);
     118                        free(buf);
    113119                        CHECK_FCT( fd_msg_send_timeout( pmsg, NULL, NULL, rtbusy_expirecb, &expire ) );
    114120                } else {
     
    118124        } else {
    119125                if (is_req) {
     126                        char *buf = NULL;
     127                        size_t len;
     128
     129                        CHECK_MALLOC_DO( fd_msg_dump_full(&buf, &len, NULL, *pmsg, fd_g_config->cnf_dict, 0, 1), /* nothing */);
     130                        TRACE_ERROR( "No answer received for message from peer '%.*s' before timeout (%dms), giving up and sending error reply: %s", senttolen, sentto,
     131                                     rtbusy_conf.RelayTimeout, buf);
     132                        free(buf);
    120133                        /* We must create an answer */
    121134                        CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, pmsg, MSGFL_ANSW_ERROR ) );
  • extensions/rt_ignore_dh/rt_ignore_dh.c

    r1052 r1272  
    4242struct dict_object * pi_avp_do; /* cache the Proxy-Info dictionary object */
    4343struct dict_object * ps_avp_do; /* cache the Proxy-State dictionary object */
    44 
    45 static void *memdup(void *data, size_t len)
    46 {
    47         void *mem;
    48         if ((mem=malloc(len)) == NULL)
    49                 return NULL;
    50         memcpy(mem, data, len);
    51         return mem;
    52 }
    5344
    5445static int restore_origin_host(struct msg **msg) {
     
    9283                                                        break;
    9384                                                case AC_PROXY_STATE:
     85                                                        ps = chdr->avp_value->os.data;
    9486                                                        ps_len = chdr->avp_value->os.len;
    95                                                         ps = memdup(chdr->avp_value->os.data, ps_len);
    96                                                         if (!ps) {
    97                                                                 TRACE_ERROR("malloc failure");
    98                                                                 return 0;
    99                                                         }
    10087                                                        break;
    10188                                                default:
     
    10996                                        new_oh_len = ps_len;
    11097                                        pi_avp = avp;
    111                                 } else
    112                                         free(ps);
     98                                }
    11399                                break;
    114100                        default:
     
    152138                        CHECK_FCT(fd_msg_avp_new(ph_avp_do, 0, &ph_avp));
    153139                        memset(&val, 0, sizeof(val));
    154                         val.os.data = memdup(fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len);
     140                        val.os.data = fd_g_config->cnf_diamid;
    155141                        val.os.len = fd_g_config->cnf_diamid_len;
    156142                        CHECK_FCT(fd_msg_avp_setvalue(ph_avp, &val));
     
    158144                        CHECK_FCT(fd_msg_avp_new(ps_avp_do, 0, &ps_avp));
    159145                        memset(&val, 0, sizeof(val));
    160                         val.os.data = memdup(ahdr->avp_value->os.data, ahdr->avp_value->os.len);
     146                        val.os.data = ahdr->avp_value->os.data;
    161147                        val.os.len = ahdr->avp_value->os.len;
    162148                        CHECK_FCT(fd_msg_avp_setvalue(ps_avp, &val));
  • extensions/rt_load_balance/CMakeLists.txt

    r1042 r1277  
    33
    44# List of source files
    5 SET(RT_IGNORE_DH_SRC
     5SET(RT_LOAD_BALANCE_SRC
    66        rt_load_balance.c
    77)
     
    1010
    1111# Compile these files as a freeDiameter extension
    12 FD_ADD_EXTENSION(rt_load_balance ${RT_IGNORE_DH_SRC})
     12FD_ADD_EXTENSION(rt_load_balance ${RT_LOAD_BALANCE_SRC})
    1313
    1414####
  • extensions/rt_load_balance/rt_load_balance.c

    r1221 r1273  
    33* Author: Thomas Klausner <tk@giga.or.at>                                                                *
    44*                                                                                                        *
    5 * Copyright (c) 2013, Thomas Klausner                                                                    *
     5* Copyright (c) 2013, 2014 Thomas Klausner                                                               *
    66* All rights reserved.                                                                                   *
    77*                                                                                                        *
     
    5959                CHECK_FCT(fd_peer_get_load_pending(peer, &to_receive, &to_send));
    6060                load = to_receive + to_send;
    61                 score = cand->score;
    62                 if ((cand->score > 0) && (load >= cand->score))
    63                         cand->score = 1;
    64                 else
    65                         cand->score -= load;
    66                 TRACE_DEBUG(INFO, "evaluated peer `%.*s', score was %d, now %d", (int)cand->diamidlen, cand->diamid, score, cand->score);
     61                /* other routing mechanisms need to add to the
     62                 * appropriate entries so their base value is high
     63                 * enough that they are considered */
     64
     65                /* logarithmic scaling */
     66                int load_log = 0;
     67                while (load > 0) {
     68                    load_log++;
     69                    load /= 2;
     70                }
     71                cand->score -= load_log;
     72                TRACE_DEBUG(FULL, "evaluated peer `%.*s', score was %d, now %d", (int)cand->diamidlen, cand->diamid, score, cand->score);
    6773        }
    6874
  • libfdcore/routing_dispatch.c

    r1238 r1274  
    879879                /* Find the peer corresponding to this name */
    880880                CHECK_FCT( fd_peer_getbyid( qry_src, qry_src_len, 0, (void *) &peer ) );
    881                 if (fd_peer_getstate(peer) != STATE_OPEN) {
     881                if (fd_peer_getstate(peer) != STATE_OPEN && fd_peer_getstate(peer) != STATE_CLOSING_GRACE) {
    882882                        char buf[128];
    883883                        snprintf(buf, sizeof(buf), "Unable to forward answer to deleted / closed peer '%s'.", qry_src);
Note: See TracChangeset for help on using the changeset viewer.