Changeset 392:8e260030f32c in freeDiameter
- Timestamp:
- Jul 6, 2010, 7:50:52 PM (14 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 6 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/CMakeLists.txt
r380 r392 59 59 ENDIF (BUILD_APP_ACCT) 60 60 61 OPTION(BUILD_APP_SIP "Build app_sip? (Authentication and authorization for Diameter SIP RFC4740)" OFF)61 OPTION(BUILD_APP_SIP "Build app_sip? (Authentication and Authorization for Diameter SIP RFC4740)" OFF) 62 62 IF (BUILD_APP_SIP) 63 63 SUBDIRS(app_sip) … … 103 103 ENDIF (BUILD_TEST_APP) 104 104 105 OPTION(BUILD_TEST_ APP "Build test_sip.fdx? (Testing application to simulate Diameter-SIP client (RFC4740), for testing purpose only)" OFF)105 OPTION(BUILD_TEST_SIP "Build test_sip.fdx? (Testing application to simulate Diameter-SIP client (RFC4740), for testing purpose only)" OFF) 106 106 IF (BUILD_TEST_SIP) 107 107 SUBDIRS(test_sip) -
extensions/app_sip/CMakeLists.txt
r362 r392 5 5 INCLUDE_DIRECTORIES(${MySQL_INCLUDE_DIR}) 6 6 7 # Parser files 8 BISON_FILE(diamsip.y) 9 FLEX_FILE(diamsip.l) 10 SET_SOURCE_FILES_PROPERTIES(lex.diamsip.c diamsip.tab.c PROPERTIES COMPILE_FLAGS "-I ${CMAKE_CURRENT_SOURCE_DIR}") 11 7 12 # List of source files 8 13 SET( DIAM_SIP_SRC 14 lex.diamsip.c 15 diamsip.tab.c 16 diamsip.tab.h 9 17 diamsip.c 10 18 diamsip.h -
extensions/app_sip/diamsip.c
r368 r392 40 40 struct session_handler * ds_sess_hdl; 41 41 42 //configuration stucture 43 struct as_conf * as_conf=NULL; 44 static struct as_conf app_sip_conf; 45 46 //dictionary of SIP 42 47 struct diamsip_dict sip_dict; 43 48 44 49 int diamsip_default_cb( struct msg ** msg, struct avp * avp, struct session * sess, enum disp_action * act) 45 50 { 46 47 51 TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act); 48 49 52 50 53 return 0; 51 54 } 52 55 56 void 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 69 static 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 53 78 /* entry point */ 54 int ds_entry()79 int as_entry(char * conffile) 55 80 { 81 TRACE_ENTRY("%p", conffile); 82 56 83 struct dict_object * app=NULL; 57 84 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(); 58 101 59 102 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Diameter Session Initiation Protocol (SIP) Application", &app, ENOENT) ); … … 105 148 //TRACE_DEBUG(INFO,"*%s*%s*%s*%s*",DB_SERVER,DB_USERNAME, DB_PASSWORD, DB_DATABASE); 106 149 //We start database connection 107 if(start_mysql_connection( DB_SERVER,DB_USERNAME, DB_PASSWORD, DB_DATABASE))150 if(start_mysql_connection()) 108 151 return 1; 109 152 … … 131 174 } 132 175 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 */ 176 EXTENSION_ENTRY("app_sip", as_entry); -
extensions/app_sip/diamsip.h
r368 r392 48 48 #define DIGEST_LEN 16 49 49 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 */ 57 struct 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 }; 67 extern struct as_conf * as_conf; 68 69 /* Parse the configuration file */ 70 int as_conf_handle(char * conffile); 71 55 72 56 73 extern MYSQL *conn; … … 61 78 void clear_digest(char * digest, char * readable_digest, int digestlength); 62 79 struct avp_hdr * walk_digest(struct avp *avp, int avp_code); 63 int start_mysql_connection( char *server,char *user, char *password, char *database);80 int start_mysql_connection(); 64 81 void request_mysql(char *query); 65 82 void close_mysql_connection(); 66 /*67 typedef struct noncechain noncechain;68 struct noncechain69 {70 int timestamp;71 char * nonce;72 noncechain *next;73 };74 75 76 //Global variable which points to chained list of nonce77 noncechain* listnonce;78 79 void nonce_add_element(char * nonce);80 int nonce_check_element(char * nonce);81 void nonce_deletelistnonce();82 */83 83 84 84 -
extensions/app_sip/libdiamsip.c
r367 r392 158 158 } 159 159 160 int start_mysql_connection( char *server,char *user, char *password, char *database)160 int start_mysql_connection() 161 161 { 162 162 conn = mysql_init(NULL); … … 164 164 mysql_options(conn, MYSQL_OPT_RECONNECT, "true"); 165 165 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); 169 169 return 1; 170 170 } -
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 */ 39 struct 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 }; 49 extern 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.