Navigation


Changeset 392:8e260030f32c in freeDiameter for extensions/app_sip/diamsip.c


Ignore:
Timestamp:
Jul 6, 2010, 7:50:52 PM (14 years ago)
Author:
Alexandre Westfahl <awestfahl@freediameter.net>
Branch:
default
Phase:
public
Message:

Added configuration file for app_sip and test_sip

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/app_sip/diamsip.c

    r368 r392  
    4040struct session_handler * ds_sess_hdl;
    4141
     42//configuration stucture
     43struct as_conf * as_conf=NULL;
     44static struct as_conf app_sip_conf;
     45
     46//dictionary of SIP
    4247struct diamsip_dict sip_dict;
    4348
    4449int diamsip_default_cb( struct msg ** msg, struct avp * avp, struct session * sess, enum disp_action * act)
    4550{
    46 
    4751        TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act);
    48 
    4952       
    5053        return 0;
    5154}
    5255
     56void dump_config()
     57{
     58        TRACE_DEBUG(FULL,"***Configuration of Diameter-SIP extension***");
     59        TRACE_DEBUG(FULL,"# mode: *%d*",as_conf->mode);
     60        TRACE_DEBUG(FULL,"# datasource: *%d*",as_conf->datasource);
     61        TRACE_DEBUG(FULL,"# mysql_login: *%s*",as_conf->mysql_login);
     62        TRACE_DEBUG(FULL,"# mysql_password: *%s*",as_conf->mysql_password);
     63        TRACE_DEBUG(FULL,"# mysql_database: *%s*",as_conf->mysql_database);
     64        TRACE_DEBUG(FULL,"# mysql_server: *%s*",as_conf->mysql_server);
     65        TRACE_DEBUG(FULL,"# mysql_port: *%d*",as_conf->mysql_port);
     66        TRACE_DEBUG(FULL,"***End of Diameter-SIP configuration extension***");
     67}
     68
     69static int as_conf_init(void)
     70{
     71        as_conf=&app_sip_conf;
     72        //memset(app_sip_conf, 0, sizeof(struct as_conf));
     73       
     74
     75        return 0;
     76}
     77
    5378/* entry point */
    54 int ds_entry()
     79int as_entry(char * conffile)
    5580{
     81        TRACE_ENTRY("%p", conffile);
     82       
    5683        struct dict_object * app=NULL;
    5784        struct disp_when data;
     85       
     86        /* Initialize configuration */
     87        CHECK_FCT( as_conf_init() );
     88       
     89       
     90        //We parse the configuration file
     91        if (conffile != NULL) {
     92                CHECK_FCT( as_conf_handle(conffile) );
     93        }
     94        else
     95        {
     96                TRACE_DEBUG(INFO, "We need a configuration file for Diameter-SIP extension. See doc/ for an example.");
     97        }
     98       
     99        //We can dump the configuration extracted from app_sip.conf
     100        //dump_config();
    58101       
    59102        CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Diameter Session Initiation Protocol (SIP) Application", &app, ENOENT) );
     
    105148        //TRACE_DEBUG(INFO,"*%s*%s*%s*%s*",DB_SERVER,DB_USERNAME, DB_PASSWORD, DB_DATABASE);
    106149        //We start database connection
    107         if(start_mysql_connection(DB_SERVER,DB_USERNAME, DB_PASSWORD, DB_DATABASE))
     150        if(start_mysql_connection())
    108151                return 1;
    109152       
     
    131174}
    132175
    133 EXTENSION_ENTRY("diam_sip", ds_entry);
    134 
    135 
    136 /*
    137 
    138 
    139 
    140 
    141 
    142 
    143 test set for digest calculate
    144 
    145 TRACE_DEBUG(FULL,"TEST");
    146                                                                         DigestCalcHA1("MD5", "12345678", "example.com", "secret", "3bada1a0","56593a80", HA1);
    147                                                                         TRACE_DEBUG(FULL,"TEST->HA1 done: *%s*",HA1);
    148                                                                         DigestCalcResponse(HA1, "3bada1a0", "00000001", "56593a80", "auth","INVITE", "sip:97226491335@example.com", HA2, response);
    149                                                                         DigestCalcResponseAuth(HA1, "3bada1a0", "00000001", "56593a80", "auth","INVITE", "sip:97226491335@example.com", HA2, responseauth);
    150        
    151        
    152        
    153        
    154        
    155        
    156 old digest reponse check
    157 
    158                                                 struct avp_hdr * tempavphdr=NULL;
    159                                                
    160                                                
    161                                                 CHECK_FCT(fd_msg_browse ( avp, MSG_BRW_WALK, &tempavp, NULL) );
    162                                                
    163                                                 while(tempavp)
    164                                                 {
    165                                                         CHECK_FCT( fd_msg_avp_hdr( tempavp, &tempavphdr )  );
    166                                                        
    167                                                         if(tempavphdr->avp_code==380)
    168                                                         {
    169                                                                 found_response=0;
    170                                                                 //We have not found it but we finished looking in this Auth-Data-Item
    171                                                                 tempavp=NULL;
    172                                                         }
    173                                                         else if(tempavphdr->avp_code==103)
    174                                                         {
    175                                                                 found_response=1;
    176                                                                 //We found it, we can leave the loop
    177                                                                 tempavp=NULL;
    178                                                         }
    179                                                         else
    180                                                         {
    181                                                                 CHECK_FCT(fd_msg_browse ( tempavp, MSG_BRW_WALK, &tempavp, NULL) );
    182                                                         }
    183                                                 }
    184 */
     176EXTENSION_ENTRY("app_sip", as_entry);
Note: See TracChangeset for help on using the changeset viewer.