Navigation


Changeset 392:8e260030f32c in freeDiameter


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

Files:
6 added
7 edited

Legend:

Unmodified
Added
Removed
  • extensions/CMakeLists.txt

    r380 r392  
    5959        ENDIF (BUILD_APP_ACCT)
    6060
    61 OPTION(BUILD_APP_SIP "Build app_sip? (Authentication and authorization for Diameter SIP RFC4740)" OFF)
     61OPTION(BUILD_APP_SIP "Build app_sip? (Authentication and Authorization for Diameter SIP RFC4740)" OFF)
    6262        IF (BUILD_APP_SIP)
    6363           SUBDIRS(app_sip)
     
    103103        ENDIF (BUILD_TEST_APP)
    104104
    105 OPTION(BUILD_TEST_APP "Build test_sip.fdx? (Testing application to simulate Diameter-SIP client (RFC4740), for testing purpose only)" OFF)
     105OPTION(BUILD_TEST_SIP "Build test_sip.fdx? (Testing application to simulate Diameter-SIP client (RFC4740), for testing purpose only)" OFF)
    106106        IF (BUILD_TEST_SIP)
    107107           SUBDIRS(test_sip)
  • extensions/app_sip/CMakeLists.txt

    r362 r392  
    55INCLUDE_DIRECTORIES(${MySQL_INCLUDE_DIR})
    66
     7# Parser files
     8BISON_FILE(diamsip.y)
     9FLEX_FILE(diamsip.l)
     10SET_SOURCE_FILES_PROPERTIES(lex.diamsip.c diamsip.tab.c PROPERTIES COMPILE_FLAGS "-I ${CMAKE_CURRENT_SOURCE_DIR}")
     11
    712# List of source files
    813SET( DIAM_SIP_SRC
     14        lex.diamsip.c
     15        diamsip.tab.c
     16        diamsip.tab.h
    917        diamsip.c
    1018        diamsip.h
  • 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);
  • extensions/app_sip/diamsip.h

    r368 r392  
    4848#define DIGEST_LEN 16
    4949
    50 //SQL configuration
    51 #define DB_USERNAME "diamsip"
    52 #define DB_PASSWORD "BAVpzCUhULVHayFr"
    53 #define DB_SERVER "pineapple.tera.ics.keio.ac.jp"
    54 #define DB_DATABASE "diamsip"
     50
     51/* Mode for the extension */
     52#define MODE_DSSERVER   0x1
     53#define MODE_SL 0x2
     54
     55
     56/* The module configuration */
     57struct as_conf {
     58        int             mode;           /* default MODE_DSSERVER | MODE_SL */
     59        enum {ASMYSQL} datasource;
     60        char * mysql_login;
     61        char * mysql_password;
     62        char * mysql_database;
     63        char * mysql_server;
     64        uint16_t  mysql_port;
     65       
     66};
     67extern struct as_conf * as_conf;
     68
     69/* Parse the configuration file */
     70int as_conf_handle(char * conffile);
     71
    5572
    5673extern MYSQL *conn;
     
    6178void clear_digest(char * digest, char * readable_digest, int digestlength);
    6279struct avp_hdr * walk_digest(struct avp *avp, int avp_code);
    63 int start_mysql_connection(char *server,char *user, char *password, char *database);
     80int start_mysql_connection();
    6481void request_mysql(char *query);
    6582void close_mysql_connection();
    66 /*
    67 typedef struct noncechain noncechain;
    68 struct noncechain
    69 {
    70     int timestamp;
    71     char * nonce;
    72     noncechain *next;
    73 };
    74 
    75 
    76 //Global variable which points to chained list of nonce
    77 noncechain* listnonce;
    78 
    79 void nonce_add_element(char * nonce);
    80 int nonce_check_element(char * nonce);
    81 void nonce_deletelistnonce();
    82 */
    8383
    8484
  • extensions/app_sip/libdiamsip.c

    r367 r392  
    158158}
    159159
    160 int start_mysql_connection(char *server,char *user, char *password, char *database)
     160int start_mysql_connection()
    161161{
    162162        conn = mysql_init(NULL);
     
    164164        mysql_options(conn, MYSQL_OPT_RECONNECT, "true");
    165165       
    166         if (!mysql_real_connect(conn, server,user, password, database, 0, NULL, 0))
    167         {
    168                 TRACE_DEBUG(INFO,"Unable to connect to database (%s) with login:%s",database,user);
     166        if (!mysql_real_connect(conn, as_conf->mysql_server,as_conf->mysql_login, as_conf->mysql_password, as_conf->mysql_database, as_conf->mysql_port, NULL, 0))
     167        {//TODO: display error from mysql
     168                TRACE_DEBUG(INFO,"Unable to connect to database (%s) with login:%s",as_conf->mysql_database,as_conf->mysql_login);
    169169                return 1;
    170170        }
  • extensions/test_sip/test_sip.c

    r381 r392  
     1/*********************************************************************************************************
     2* Software License Agreement (BSD License)                                                               *
     3* Author: Alexandre Westfahl <awestfahl@freediameter.net>                                                *
     4*                                                                                                        *
     5* Copyright (c) 2010, Alexandre Westfahl, Teraoka Laboratory (Keio University), and the WIDE Project.    *             
     6*                                                                                                        *
     7* All rights reserved.                                                                                   *
     8*                                                                                                        *
     9* Redistribution and use of this software in source and binary forms, with or without modification, are  *
     10* permitted provided that the following conditions are met:                                              *
     11*                                                                                                        *
     12* * Redistributions of source code must retain the above                                                 *
     13*   copyright notice, this list of conditions and the                                                    *
     14*   following disclaimer.                                                                                *
     15*                                                                                                        *
     16* * Redistributions in binary form must reproduce the above                                              *
     17*   copyright notice, this list of conditions and the                                                    *
     18*   following disclaimer in the documentation and/or other                                               *
     19*   materials provided with the distribution.                                                            *
     20*                                                                                                        *
     21* * Neither the name of the Teraoka Laboratory nor the                                                   *
     22*   names of its contributors may be used to endorse or                                                  *
     23*   promote products derived from this software without                                                  *
     24*   specific prior written permission of Teraoka Laboratory                                              *
     25*                                                                                                        *
     26*                                                                                                        *
     27* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
     28* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
     29* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
     30* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT     *
     31* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS    *
     32* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
     33* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF   *
     34* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                                                             *
     35*********************************************************************************************************/
     36
     37
     38#include"test_sip.h"
     39
     40
     41
     42
  • extensions/test_sip/test_sip.h

    r381 r392  
     1/*********************************************************************************************************
     2* Software License Agreement (BSD License)                                                               *
     3* Author: Alexandre Westfahl <awestfahl@freediameter.net>                                                *
     4*                                                                                                        *
     5* Copyright (c) 2010, Alexandre Westfahl, Teraoka Laboratory (Keio University), and the WIDE Project.    *             
     6*                                                                                                        *
     7* All rights reserved.                                                                                   *
     8*                                                                                                        *
     9* Redistribution and use of this software in source and binary forms, with or without modification, are  *
     10* permitted provided that the following conditions are met:                                              *
     11*                                                                                                        *
     12* * Redistributions of source code must retain the above                                                 *
     13*   copyright notice, this list of conditions and the                                                    *
     14*   following disclaimer.                                                                                *
     15*                                                                                                        *
     16* * Redistributions in binary form must reproduce the above                                              *
     17*   copyright notice, this list of conditions and the                                                    *
     18*   following disclaimer in the documentation and/or other                                               *
     19*   materials provided with the distribution.                                                            *
     20*                                                                                                        *
     21* * Neither the name of the Teraoka Laboratory nor the                                                   *
     22*   names of its contributors may be used to endorse or                                                  *
     23*   promote products derived from this software without                                                  *
     24*   specific prior written permission of Teraoka Laboratory                                              *
     25*                                                                                                        *
     26*                                                                                                        *
     27* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
     28* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
     29* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
     30* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT     *
     31* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS    *
     32* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
     33* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF   *
     34* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                                                             *
     35*********************************************************************************************************/
     36
     37
     38/* The module configuration */
     39struct test_sip_conf {
     40        int             mode;           /* default MODE_DSSERVER | MODE_SL */
     41        enum {ASMYSQL} datasource;
     42        char * mysql_login;
     43        char * mysql_password;
     44        char * mysql_database;
     45        char * mysql_server;
     46        uint16_t  mysql_port;
     47       
     48};
     49extern struct test_sip_conf * test_sip_conf;
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
Note: See TracChangeset for help on using the changeset viewer.