Changeset 35:6486e97f56ae in freeDiameter for freeDiameter/tests/testmesg.c
- Timestamp:
- Nov 2, 2009, 2:54:42 PM (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
freeDiameter/tests/testmesg.c
r10 r35 283 283 ADD_RULE(gavp, 73565, "AVP Test - enumos", RULE_OPTIONAL, 0, 1, 0); 284 284 ADD_RULE(gavp, 73565, "AVP Test - grouped", RULE_FIXED_TAIL, -1, 1, 1); 285 285 /* ABNF : 286 < no vendor - f32 > 287 < i64 > 288 < enumi32 > 289 2*3 { os } 290 *1 [ enumos ] 291 < grouped > 292 */ 286 293 #if 0 287 294 fd_dict_dump_object ( gavp ); … … 728 735 /* Now test the msg_parse_rule function */ 729 736 { 730 struct dict_object * rule;731 732 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, & rule) );737 struct fd_pei pei; 738 739 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, &pei ) ); 733 740 734 741 /* Use the "AVP Test - rules" AVP to test the rules */ … … 749 756 750 757 /* Check the message is still conform */ 751 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, & rule) );758 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, &pei ) ); 752 759 753 760 /* The first avp is optional in fixed position, so remove it and check the message is still OK */ 754 761 CHECK( 0, fd_msg_browse ( tavp, MSG_BRW_FIRST_CHILD, &childavp, NULL) ); 755 762 CHECK( 0, fd_msg_free ( childavp ) ); 756 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, & rule) );763 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, &pei ) ); 757 764 ADD_AVP( tavp, MSG_BRW_FIRST_CHILD, childavp, 0, "AVP Test - no vendor - f32" ); 758 765 759 766 760 767 /* Now break some rules and check it is detected */ 761 #define CHECK_CONFLICT( _msg, _ruleavp, _avpvendor ) { \ 762 struct dict_object * _rule; \ 763 CHECK( EBADMSG, fd_msg_parse_rules( _msg, fd_g_config->cnf_dict, &_rule ) ); \ 764 if ((_ruleavp) == NULL) { \ 765 CHECK( NULL, _rule); \ 768 #define CHECK_CONFLICT( _msg, _error, _conflictavp_name, _conflictavp_vnd ) { \ 769 struct fd_pei _pei; \ 770 CHECK( EBADMSG, fd_msg_parse_rules( _msg, fd_g_config->cnf_dict, &_pei ) ); \ 771 if (_error) { \ 772 CHECK( 0, strcmp( _error, _pei.pei_errcode ) ); \ 773 } \ 774 if ((_conflictavp_name) == NULL) { \ 775 CHECK( NULL, _pei.pei_avp); \ 766 776 } else { \ 767 struct dict_ rule_data _ruledata;\777 struct dict_avp_request _req = { (_conflictavp_vnd), 0, (_conflictavp_name) }; \ 768 778 struct dict_object * _avp; \ 769 struct dict_avp_request _req = { (_avpvendor), 0, (_ruleavp) }; \ 779 struct dict_object * _conflict; \ 780 CHECK( 1, (_pei.pei_avp) ? 1 : 0 ); \ 781 CHECK( 0, fd_msg_model( _pei.pei_avp, &_conflict ) ); \ 770 782 CHECK( 0, fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT)); \ 771 CHECK( 0, fd_dict_getval( _rule, &_ruledata ) ); \ 772 CHECK( _avp, _ruledata.rule_avp ); \ 783 CHECK( _avp, _conflict ); \ 773 784 } \ 774 785 } 775 786 787 /* ABNF : 788 < no vendor - f32 > 789 < i64 > 790 < enumi32 > 791 2*3 { os } 792 *1 [ enumos ] 793 < grouped > 794 */ 776 795 { 777 796 /* Test the FIXED_HEAD rules positions: add another AVP before the third */ … … 780 799 ADD_AVP( tempavp, MSG_BRW_NEXT, childavp, 73565, "AVP Test - os" ); 781 800 782 CHECK_CONFLICT( msg, " AVP Test - enumi32", 73565 );801 CHECK_CONFLICT( msg, "DIAMETER_MISSING_AVP", "AVP Test - enumi32", 73565 ); 783 802 784 803 /* Now remove this AVP */ … … 790 809 CHECK( 0, fd_msg_free ( childavp ) ); 791 810 792 CHECK_CONFLICT( msg, " AVP Test - enumi32", 73565 );811 CHECK_CONFLICT( msg, "DIAMETER_MISSING_AVP", "AVP Test - enumi32", 73565 ); 793 812 794 813 /* Add the AVP back */ … … 801 820 CHECK( 0, fd_msg_free ( tempavp ) ); 802 821 803 CHECK_CONFLICT( msg, " AVP Test - os", 73565 );/* The rule requires at least 2 AVP, we have only 1 */822 CHECK_CONFLICT( msg, "DIAMETER_MISSING_AVP", "AVP Test - os", 73565 ); /* The rule requires at least 2 AVP, we have only 1 */ 804 823 805 824 /* Now add this AVP */ … … 811 830 ADD_AVP( childavp, MSG_BRW_NEXT, tempavp, 73565, "AVP Test - os" ); 812 831 813 CHECK_CONFLICT( msg, " AVP Test - os", 73565 );/* The rule requires at most 3 AVP, we have 4 */832 CHECK_CONFLICT( msg, "DIAMETER_AVP_OCCURS_TOO_MANY_TIMES", "AVP Test - os", 73565 ); /* The rule requires at most 3 AVP, we have 4 */ 814 833 815 834 /* Now delete these AVP */ … … 824 843 825 844 /* The message is still conform */ 826 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, & rule) );845 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, &pei ) ); 827 846 828 847 /* Now break the rule */ 829 848 ADD_AVP( childavp, MSG_BRW_NEXT, tempavp, 73565, "AVP Test - enumos" ); 830 849 831 CHECK_CONFLICT( msg, " AVP Test - enumos", 73565 ); /* The rule requires at most 3 AVP, we have 4 */850 CHECK_CONFLICT( msg, "DIAMETER_AVP_OCCURS_TOO_MANY_TIMES", "AVP Test - enumos", 73565 ); 832 851 833 852 /* Now delete this AVP */ … … 839 858 ADD_AVP( tavp, MSG_BRW_LAST_CHILD, childavp, 73565, "AVP Test - os" ); 840 859 841 CHECK_CONFLICT( msg, " AVP Test - grouped", 73565 );860 CHECK_CONFLICT( msg, "DIAMETER_MISSING_AVP", "AVP Test - grouped", 73565 ); 842 861 843 862 /* Now remove this AVP */
Note: See TracChangeset
for help on using the changeset viewer.