Changeset 1423:67c263056d78 in freeDiameter
- Timestamp:
- Feb 19, 2020, 8:20:20 AM (4 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
include/freeDiameter/libfdproto.h
r1422 r1423 2367 2367 * 2368 2368 * PARAMETERS: 2369 * msg : The message structurein which to search the AVP.2369 * reference : Pointer to a valid msg or avp in which to search the AVP. 2370 2370 * what : The dictionary model of the AVP to search. 2371 2371 * avp : location where the AVP reference is stored if found. 2372 2372 * 2373 2373 * DESCRIPTION: 2374 * Search the first top-level AVP of a given model inside a message.2374 * Search for the first top-level AVP of a given model inside a message or AVP. 2375 2375 * Note: only the first instance of the AVP is returned by this function. 2376 2376 * Note: only top-level AVPs are searched, not inside grouped AVPs. … … 2382 2382 * ENOENT : No AVP has been found, and "avp" was NULL (otherwise, *avp is set to NULL and 0 returned). 2383 2383 */ 2384 int fd_msg_search_avp ( struct msg * msg, struct dict_object * what, struct avp ** avp );2384 int fd_msg_search_avp ( msg_or_avp * reference, struct dict_object * what, struct avp ** avp ); 2385 2385 2386 2386 /* -
libfdproto/messages.c
r1405 r1423 597 597 } 598 598 599 /* Search a given AVP model in a message */600 int fd_msg_search_avp ( struct msg * msg, struct dict_object * what, struct avp ** avp )599 /* Search a given AVP model in a message or AVP */ 600 int fd_msg_search_avp ( msg_or_avp * reference, struct dict_object * what, struct avp ** avp ) 601 601 { 602 602 struct avp * nextavp; … … 604 604 enum dict_object_type dicttype; 605 605 606 TRACE_ENTRY("%p %p %p", msg, what, avp);607 608 CHECK_PARAMS( CHECK_MSG(msg) && what );606 TRACE_ENTRY("%p %p %p", reference, what, avp); 607 608 CHECK_PARAMS( VALIDATE_OBJ(reference) && what ); 609 609 610 610 CHECK_PARAMS( (fd_dict_gettype(what, &dicttype) == 0) && (dicttype == DICT_AVP) ); 611 611 CHECK_FCT( fd_dict_getval(what, &dictdata) ); 612 612 613 /* Loop on all top AVPs */614 CHECK_FCT( fd_msg_browse( msg, MSG_BRW_FIRST_CHILD, (void *)&nextavp, NULL) );613 /* Loop on all top AVPs in message or AVP */ 614 CHECK_FCT( fd_msg_browse(reference, MSG_BRW_FIRST_CHILD, (void *)&nextavp, NULL) ); 615 615 while (nextavp) { 616 616 … … 619 619 break; 620 620 621 /* Otherwise move to next AVP in the message */621 /* Otherwise move to next AVP in the message or AVP */ 622 622 CHECK_FCT( fd_msg_browse(nextavp, MSG_BRW_NEXT, (void *)&nextavp, NULL) ); 623 623 } -
tests/testmesg.c
r1414 r1423 681 681 struct dict_object * avp_model; 682 682 struct avp * found; 683 struct avp * grouped = NULL; 683 684 struct avp_hdr * avpdata = NULL; 684 685 … … 688 689 CPYBUF(); 689 690 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 691 696 /* Search this AVP instance in the msg */ 692 697 CHECK( 0, fd_msg_search_avp( msg, avp_model, &found ) ); … … 695 700 CHECK( 0, fd_msg_avp_hdr ( found, &avpdata ) ); 696 701 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 698 726 /* reinit the msg */ 699 727 CHECK( 0, fd_msg_free ( msg ) );
Note: See TracChangeset
for help on using the changeset viewer.