Navigation


Changeset 1423:67c263056d78 in freeDiameter for tests


Ignore:
Timestamp:
Feb 19, 2020, 8:20:20 AM (4 years ago)
Author:
Luke Mewburn <luke@mewburn.net>
Branch:
default
Phase:
public
Message:

fd_msg_search_avp: search msg_or_avp, not just msg

Change fd_msg_search_avp() to support searching
struct msg or struct avp, and not just struct msg.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/testmesg.c

    r1414 r1423  
    681681                        struct dict_object * avp_model;
    682682                        struct avp         * found;
     683                        struct avp         * grouped = NULL;
    683684                        struct avp_hdr     * avpdata = NULL;
    684685                       
     
    688689                        CPYBUF();
    689690                        CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
    690                        
     691                        CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
     692#if 0
     693                        LOG_D("msg: %s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
     694#endif
     695
    691696                        /* Search this AVP instance in the msg */
    692697                        CHECK( 0, fd_msg_search_avp( msg, avp_model, &found ) );
     
    695700                        CHECK( 0, fd_msg_avp_hdr ( found, &avpdata ) );
    696701                        CHECK( 3.1415F, avpdata->avp_value->f32 );
    697                        
     702
     703                        /* Search for the first grouped message */
     704                        {
     705                        struct dict_avp_request grouped_req = { 73565, 0, "AVP Test - grouped"};
     706                        CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &grouped_req, &avp_model, ENOENT ) );
     707                        }
     708                        CHECK( 0, fd_msg_search_avp( msg, avp_model, &grouped ) );
     709#if 0
     710                        LOG_D("grouped: %s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, grouped, fd_g_config->cnf_dict, 0, 1));
     711#endif
     712
     713                        /* Find the first item in the grouped */
     714                        {
     715                        struct dict_avp_request avp_req = { 73565, 0, "AVP Test - os"};
     716                        CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &avp_req, &avp_model, ENOENT ) );
     717                        }
     718
     719                        CHECK( 0, fd_msg_search_avp( grouped, avp_model, &found ) );
     720
     721                        /* Check the AVP value is "1" */
     722                        CHECK( 0, fd_msg_avp_hdr ( found, &avpdata ) );
     723                        CHECK( 8, avpdata->avp_value->os.len );
     724                        CHECK( 0, memcmp(avpdata->avp_value->os.data, "12345678", 8));
     725
    698726                        /* reinit the msg */
    699727                        CHECK( 0, fd_msg_free ( msg ) );
Note: See TracChangeset for help on using the changeset viewer.