Navigation


Changeset 1300:3f1e79e1273e in freeDiameter for tests/testmesg.c


Ignore:
Timestamp:
Aug 30, 2015, 2:11:55 AM (9 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/testmesg.c

    r1281 r1300  
    309309                        #endif
    310310                }
     311
     312                {
     313                        struct dict_object  * type = NULL;
     314                        struct dict_type_data type_data = { AVP_TYPE_OCTETSTRING, "OS test2", NULL, NULL, NULL, fd_dictfct_CharInOS_check, "@." };
     315                        struct dict_avp_data  avp_data = { 73575, 73565, "AVP Test - os2", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_OCTETSTRING };
     316                        CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_TYPE, &type_data , NULL, &type ) );
     317                        CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , type, NULL ) );
     318                }
     319               
    311320                #if 0
    312321                {
     
    753762                                /* reset */
    754763                                CHECK( 0, fd_msg_free ( msg ) );
     764                        }
     765                       
     766                        /* Test with a type verifier */
     767                        {
     768                                struct fd_pei error_info;
     769                                CPYBUF();
     770                                buf_cpy[103] = 0x67;    /* Replaced AVP code = 0x00011F67, OS test2 type in the dictionary */
     771                               
     772                                /* Check that we cannot support this message now */
     773                                CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
     774                                CHECK( EBADMSG, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
     775                               
     776                                /* reset */
     777                                CHECK( 0, fd_msg_free ( msg ) );
     778
     779                                CPYBUF();
     780                                buf_cpy[103] = 0x67;    /* Replaced AVP code = 0x00011F67, OS test2 type in the dictionary */
     781                               
     782                                /* Check error reporting works */
     783                                CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
     784                                CHECK( EBADMSG, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, &error_info ) );
     785                               
     786                                #if 1
     787                                fd_log_debug("Error reported: %s\n in AVP: %s", error_info.pei_message, fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, error_info.pei_avp, fd_g_config->cnf_dict, 0, 1));
     788                                #endif
     789                               
     790                                /* reset */
     791                                CHECK( 0, fd_msg_free ( msg ) );
     792                               
     793                                CPYBUF();
     794                                buf_cpy[103] = 0x67;    /* Replaced AVP code = 0x00011F67, OS test2 type in the dictionary */
     795                                buf_cpy[130] = '@';
     796                                buf_cpy[140] = '.';     /* now we comply to the constraints */
     797                               
     798                                /* Check that we cannot support this message now */
     799                                CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
     800                                CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
     801                               
     802                                /* reset */
     803                                CHECK( 0, fd_msg_free ( msg ) );
     804                               
     805                               
    755806                        }
    756807                       
     
    13991450        }
    14001451       
    1401 
    14021452        /* That's all for the tests yet */
    14031453        PASSTEST();
Note: See TracChangeset for help on using the changeset viewer.