Navigation


Changeset 1214:c2fbaf2985f4 in freeDiameter for extensions


Ignore:
Timestamp:
Jun 18, 2013, 5:27:45 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

New options to test_app extension to generate long Diameter messages

Location:
extensions/test_app
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • extensions/test_app/ta_cli.c

    r1088 r1214  
    182182        TRACE_DEBUG(FULL, "Creating a new message for sending.");
    183183       
    184         /* Create the request from template */
     184        /* Create the request */
    185185        CHECK_FCT_DO( fd_msg_new( ta_cmd_r, MSGFL_ALLOC_ETEID, &req ), goto out );
    186186       
     
    239239        }
    240240       
     241        /* Set the Test-Payload-AVP AVP */
     242        if (ta_conf->long_avp_id) {
     243                int l;
     244                CHECK_FCT_DO( fd_msg_avp_new ( ta_avp_long, 0, &avp ), goto out  );
     245                CHECK_MALLOC_DO( val.os.data = malloc(ta_conf->long_avp_len), goto out);
     246                val.os.len = ta_conf->long_avp_len;
     247                for (l=0; l < ta_conf->long_avp_len; l++)
     248                        val.os.data[l]=l;
     249                CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out  );
     250                free(val.os.data);
     251                CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out  );
     252        }
     253       
    241254        CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &mi->ts), goto out );
    242255       
  • extensions/test_app/ta_conf.l

    r1127 r1214  
    118118                        }
    119119
     120(?i:"long-avp-id")      {
     121                                return LONG_AVP_ID;
     122                        }
     123
     124(?i:"long-avp-len")     {
     125                                return LONG_AVP_LEN;
     126                        }
     127
    120128(?i:"mode")             {
    121129                                return MODE;
  • extensions/test_app/ta_conf.y

    r1127 r1214  
    121121%token          CMD_ID
    122122%token          AVP_ID
     123%token          LONG_AVP_ID
     124%token          LONG_AVP_LEN
    123125%token          MODE
    124126%token          DEST_REALM
     
    146148                        | conffile cmd
    147149                        | conffile avp
     150                        | conffile long_avp_id
     151                        | conffile long_avp_len
    148152                        | conffile mode
    149153                        | conffile dstrealm
     
    178182                        ;
    179183
     184long_avp_id:            LONG_AVP_ID '=' INTEGER ';'
     185                        {
     186                                ta_conf->long_avp_id = $3;
     187                        }
     188                        ;
     189
     190long_avp_len:           LONG_AVP_LEN '=' INTEGER ';'
     191                        {
     192                                ta_conf->long_avp_len = $3;
     193                        }
     194                        ;
     195
    180196mode:                   MODE '=' INTEGER ';'
    181197                        {
  • extensions/test_app/ta_dict.c

    r741 r1214  
    4343struct dict_object * ta_cmd_a = NULL;
    4444struct dict_object * ta_avp = NULL;
     45struct dict_object * ta_avp_long = NULL;
    4546
    4647struct dict_object * ta_sess_id = NULL;
     
    9596                data.avp_basetype = AVP_TYPE_INTEGER32;
    9697                CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_AVP, &data, NULL, &ta_avp));
     98        }
     99       
     100        /* Create the Test Payload AVP */
     101        if (ta_conf->long_avp_id) {
     102                struct dict_avp_data data;
     103                data.avp_code = ta_conf->long_avp_id;
     104                data.avp_vendor = ta_conf->vendor_id;
     105                data.avp_name = "Test-Payload-AVP";
     106                data.avp_flag_mask = AVP_FLAG_VENDOR;
     107                data.avp_flag_val = AVP_FLAG_VENDOR;
     108                data.avp_basetype = AVP_TYPE_OCTETSTRING;
     109                CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_AVP, &data, NULL, &ta_avp_long));
    97110        }
    98111       
  • extensions/test_app/ta_serv.c

    r1127 r1214  
    9595        }
    9696       
     97        /* Set the Test-Payload-AVP AVP */
     98        if (ta_conf->long_avp_id) {
     99                struct avp * src = NULL;
     100                struct avp_hdr * hdr = NULL;
     101               
     102                CHECK_FCT( fd_msg_search_avp ( qry, ta_avp_long, &src) );
     103                CHECK_FCT( fd_msg_avp_hdr( src, &hdr )  );
     104               
     105                CHECK_FCT( fd_msg_avp_new ( ta_avp_long, 0, &avp ) );
     106                CHECK_FCT( fd_msg_avp_setvalue( avp, hdr->avp_value ) );
     107                CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, avp ) );
     108        }
     109       
     110       
    97111        /* Set the Origin-Host, Origin-Realm, Result-Code AVPs */
    98112        CHECK_FCT( fd_msg_rescode_set( ans, "DIAMETER_SUCCESS", NULL, NULL, 1 ) );
  • extensions/test_app/test_app.c

    r1199 r1214  
    5555        ta_conf->cmd_id     = 0xfffffe; /* Experimental */
    5656        ta_conf->avp_id     = 0xffffff; /* dummy value */
     57        ta_conf->long_avp_len = 5000;
    5758        ta_conf->mode       = MODE_SERV | MODE_CLI;
    5859        ta_conf->dest_realm = strdup(fd_g_config->cnf_diamrlm);
     
    7778        fd_log_debug( " Command Id ......... : %u", ta_conf->cmd_id);
    7879        fd_log_debug( " AVP Id ............. : %u", ta_conf->avp_id);
     80        fd_log_debug( " Long AVP Id ........ : %u", ta_conf->long_avp_id);
     81        fd_log_debug( " Long AVP len ....... : %zu", ta_conf->long_avp_len);
    7982        fd_log_debug( " Mode ............... : %s%s%s", ta_conf->mode & MODE_SERV ? "Serv" : "", ta_conf->mode & MODE_CLI ? "Cli" : "",  ta_conf->mode & MODE_BENCH ? " (Benchmark)" : "");
    8083        fd_log_debug( " Destination Realm .. : %s", ta_conf->dest_realm ?: "- none -");
  • extensions/test_app/test_app.h

    r741 r1214  
    6060        uint32_t        cmd_id;         /* default 234567 */
    6161        uint32_t        avp_id;         /* default 345678 */
     62        uint32_t        long_avp_id;    /* default 0 */
     63        size_t          long_avp_len;   /* default 5000 */
    6264        int             mode;           /* default MODE_SERV | MODE_CLI */
    6365        char    *       dest_realm;     /* default local realm */
     
    105107extern struct dict_object * ta_cmd_a;
    106108extern struct dict_object * ta_avp;
     109extern struct dict_object * ta_avp_long;
    107110
    108111extern struct dict_object * ta_sess_id;
Note: See TracChangeset for help on using the changeset viewer.