Changeset 409:c2fb5b26bfcb in freeDiameter
- Timestamp:
- Jul 8, 2010, 4:19:28 PM (14 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- extensions
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/app_sip/diamsip.c
r392 r409 37 37 38 38 struct disp_hdl * diamsip_MAR_hdl=NULL; 39 struct disp_hdl * diamsip_LIR_hdl=NULL; 40 struct disp_hdl * diamsip_UAR_hdl=NULL; 41 struct disp_hdl * diamsip_SAR_hdl=NULL; 42 struct disp_hdl * diamsip_PPA_hdl=NULL; 43 struct disp_hdl * diamsip_RTA_hdl=NULL; 44 45 39 46 struct disp_hdl * diamsip_default_hdl=NULL; 40 47 struct session_handler * ds_sess_hdl; … … 137 144 memset(&data, 0, sizeof(data)); 138 145 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Diameter Session Initiation Protocol (SIP) Application", &data.app, ENOENT) ); 139 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Multimedia-Auth-Request", &data.command, ENOENT) );140 146 141 //Callback for unexpected messages142 CHECK_FCT( fd_disp_register( diamsip_MAR_cb, DISP_HOW_APPID, &data, &diamsip_default_hdl ) );143 147 144 148 //**Command Codes 145 149 //MAR 150 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Multimedia-Auth-Request", &data.command, ENOENT) ); 146 151 CHECK_FCT( fd_disp_register( diamsip_MAR_cb, DISP_HOW_CC, &data, &diamsip_MAR_hdl ) ); 152 //RTA 153 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Registration-Termination-Answer", &data.command, ENOENT) ); 154 CHECK_FCT( fd_disp_register( diamsip_RTA_cb, DISP_HOW_CC, &data, &diamsip_RTA_hdl ) ); 147 155 148 //TRACE_DEBUG(INFO,"*%s*%s*%s*%s*",DB_SERVER,DB_USERNAME, DB_PASSWORD, DB_DATABASE); 156 //Callback for unexpected messages 157 CHECK_FCT( fd_disp_register( diamsip_default_cb, DISP_HOW_APPID, &data, &diamsip_default_hdl ) ); 158 159 149 160 //We start database connection 150 161 if(start_mysql_connection()) … … 160 171 { 161 172 162 if (diamsip_MAR_cb) {163 164 165 }173 174 (void) fd_disp_unregister(&diamsip_MAR_hdl); 175 CHECK_FCT_DO( fd_sess_handler_destroy(&ds_sess_hdl),return); 176 166 177 167 178 //We close database connection -
extensions/app_sip/diamsip.h
r392 r409 76 76 77 77 void calc_md5(char *buffer, char * data); 78 void clear_digest( char* digest, char * readable_digest, int digestlength);78 void clear_digest(uint8_t * digest, char * readable_digest, int digestlength); 79 79 struct avp_hdr * walk_digest(struct avp *avp, int avp_code); 80 80 int start_mysql_connection(); … … 82 82 void close_mysql_connection(); 83 83 84 void DigestCalcHA1(char * pszAlg,char * pszUserName,char * pszRealm,char * pszPassword,char * pszNonce,char * pszCNonce,HASHHEX SessionKey); 85 void DigestCalcResponse(HASHHEX HA1,char * pszNonce,char * pszNonceCount,char * pszCNonce,char * pszQop,char * pszMethod,char * pszDigestUri,HASHHEX HEntity,HASHHEX Response); 86 void DigestCalcResponseAuth(HASHHEX HA1,char * pszNonce,char * pszNonceCount,char * pszCNonce,char * pszQop,char * pszMethod,char * pszDigestUri,HASHHEX HEntity,HASHHEX Response); 84 87 88 int fd_avp_search_avp ( struct avp * groupedavp, struct dict_object * what, struct avp ** avp ); 85 89 86 90 int ds_entry(); … … 88 92 int diamsip_default_cb( struct msg ** msg, struct avp * avp, struct session * sess, enum disp_action * act); 89 93 int diamsip_MAR_cb( struct msg ** msg, struct avp * avp, struct session * sess, enum disp_action * act); 94 int diamsip_RTA_cb( struct msg ** msg, struct avp * avp, struct session * sess, enum disp_action * act); 90 95 #define SQL_GETPASSWORD "SELECT `password` FROM ds_users WHERE `username` ='%s'" 91 96 #define SQL_GETPASSWORD_LEN 52 -
extensions/app_sip/libdiamsip.c
r392 r409 38 38 39 39 MYSQL *conn; 40 /* 41 void calculate_nonce(u8 * nonce) 42 { 43 44 nonce="lkgbsljhsdjdsgj"; 45 return; 46 }*/ 47 48 void clear_digest(char * digest, char * readable_digest, int digestlength) 40 41 void clear_digest(uint8_t * digest, char * readable_digest, int digestlength) 49 42 { 50 43 int i=0; … … 81 74 struct avp_hdr * nextavphdr; 82 75 struct dict_avp_data dictdata; 83 enum dict_object_type dicttype;76 84 77 85 78 TRACE_ENTRY("%p %p %p", groupedavp, what, avp); … … 125 118 { 126 119 struct avp_hdr *temphdr=NULL; 127 CHECK_FCT_DO(fd_msg_browse ( avp, MSG_BRW_WALK, &avp, NULL), 0);120 CHECK_FCT_DO(fd_msg_browse ( avp, MSG_BRW_WALK, &avp, NULL),return NULL); 128 121 129 122 while(avp!=NULL) 130 123 { 131 124 132 CHECK_FCT_DO( fd_msg_avp_hdr( avp,&temphdr ), 0);125 CHECK_FCT_DO( fd_msg_avp_hdr( avp,&temphdr ),return NULL); 133 126 134 127 if(temphdr->avp_code==avp_code) … … 149 142 else 150 143 { 151 CHECK_FCT_DO(fd_msg_browse ( avp, MSG_BRW_WALK, &avp, NULL), 0);144 CHECK_FCT_DO(fd_msg_browse ( avp, MSG_BRW_WALK, &avp, NULL),return NULL); 152 145 temphdr=NULL; 153 146 -
extensions/app_sip/md5.c
r360 r409 53 53 54 54 MD5Init(&Md5Ctx); 55 MD5Update(&Md5Ctx, pszUserName, strlen(pszUserName));56 MD5Update(&Md5Ctx, ":", 1);57 MD5Update(&Md5Ctx, pszRealm, strlen(pszRealm));58 MD5Update(&Md5Ctx, ":", 1);59 MD5Update(&Md5Ctx, pszPassword, strlen(pszPassword));60 MD5Final( HA1, &Md5Ctx);55 MD5Update(&Md5Ctx, (const unsigned char *)pszUserName, strlen(pszUserName)); 56 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 57 MD5Update(&Md5Ctx, (const unsigned char *)pszRealm, strlen(pszRealm)); 58 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 59 MD5Update(&Md5Ctx, (const unsigned char *)pszPassword, strlen(pszPassword)); 60 MD5Final((unsigned char *)HA1, &Md5Ctx); 61 61 if (strcmp(pszAlg, "md5-sess") == 0) { 62 62 MD5Init(&Md5Ctx); 63 MD5Update(&Md5Ctx, HA1, HASHLEN);64 MD5Update(&Md5Ctx, ":", 1);65 MD5Update(&Md5Ctx, pszNonce, strlen(pszNonce));66 MD5Update(&Md5Ctx, ":", 1);67 MD5Update(&Md5Ctx, pszCNonce, strlen(pszCNonce));68 MD5Final( HA1, &Md5Ctx);63 MD5Update(&Md5Ctx, (const unsigned char *)HA1, HASHLEN); 64 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 65 MD5Update(&Md5Ctx, (const unsigned char *)pszNonce, strlen(pszNonce)); 66 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 67 MD5Update(&Md5Ctx, (const unsigned char *)pszCNonce, strlen(pszCNonce)); 68 MD5Final((unsigned char *)HA1, &Md5Ctx); 69 69 } 70 70 CvtHex(HA1, SessionKey); … … 81 81 // calculate H(A2) 82 82 MD5Init(&Md5Ctx); 83 MD5Update(&Md5Ctx, pszMethod, strlen(pszMethod));84 MD5Update(&Md5Ctx, ":", 1);85 MD5Update(&Md5Ctx, pszDigestUri, strlen(pszDigestUri));83 MD5Update(&Md5Ctx, (const unsigned char *)pszMethod, strlen(pszMethod)); 84 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 85 MD5Update(&Md5Ctx, (const unsigned char *)pszDigestUri, strlen(pszDigestUri)); 86 86 if (strcmp(pszQop, "auth-int") == 0) { 87 MD5Update(&Md5Ctx, ":", 1);88 MD5Update(&Md5Ctx, HEntity, HASHHEXLEN);87 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 88 MD5Update(&Md5Ctx, (const unsigned char *)HEntity, HASHHEXLEN); 89 89 } 90 MD5Final( HA2, &Md5Ctx);90 MD5Final((unsigned char *)HA2, &Md5Ctx); 91 91 CvtHex(HA2, HA2Hex); 92 92 93 93 // calculate response 94 94 MD5Init(&Md5Ctx); 95 MD5Update(&Md5Ctx, HA1, HASHHEXLEN);96 MD5Update(&Md5Ctx, ":", 1);97 MD5Update(&Md5Ctx, pszNonce, strlen(pszNonce));98 MD5Update(&Md5Ctx, ":", 1);95 MD5Update(&Md5Ctx, (const unsigned char *)HA1, HASHHEXLEN); 96 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 97 MD5Update(&Md5Ctx,(const unsigned char *) pszNonce, strlen(pszNonce)); 98 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 99 99 if (*pszQop) { 100 MD5Update(&Md5Ctx, pszNonceCount, strlen(pszNonceCount));101 MD5Update(&Md5Ctx, ":", 1);102 MD5Update(&Md5Ctx, pszCNonce, strlen(pszCNonce));103 MD5Update(&Md5Ctx, ":", 1);104 MD5Update(&Md5Ctx, pszQop, strlen(pszQop));105 MD5Update(&Md5Ctx, ":", 1);100 MD5Update(&Md5Ctx, (const unsigned char *)pszNonceCount, strlen(pszNonceCount)); 101 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 102 MD5Update(&Md5Ctx, (const unsigned char *)pszCNonce, strlen(pszCNonce)); 103 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 104 MD5Update(&Md5Ctx, (const unsigned char *)pszQop, strlen(pszQop)); 105 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 106 106 } 107 MD5Update(&Md5Ctx, HA2Hex, HASHHEXLEN);108 MD5Final( RespHash, &Md5Ctx);107 MD5Update(&Md5Ctx, (const unsigned char *)HA2Hex, HASHHEXLEN); 108 MD5Final((unsigned char *)RespHash, &Md5Ctx); 109 109 CvtHex(RespHash, Response); 110 110 } … … 119 119 // calculate H(A2) 120 120 MD5Init(&Md5Ctx); 121 MD5Update(&Md5Ctx, ":", 1);122 MD5Update(&Md5Ctx, pszDigestUri, strlen(pszDigestUri));121 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 122 MD5Update(&Md5Ctx, (const unsigned char *)pszDigestUri, strlen(pszDigestUri)); 123 123 if (strcmp(pszQop, "auth-int") == 0) { 124 MD5Update(&Md5Ctx, ":", 1);125 MD5Update(&Md5Ctx, HEntity, HASHHEXLEN);124 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 125 MD5Update(&Md5Ctx, (const unsigned char *)HEntity, HASHHEXLEN); 126 126 } 127 MD5Final( HA2, &Md5Ctx);127 MD5Final((unsigned char *)HA2, &Md5Ctx); 128 128 CvtHex(HA2, HA2Hex); 129 129 130 130 // calculate response 131 131 MD5Init(&Md5Ctx); 132 MD5Update(&Md5Ctx, HA1, HASHHEXLEN);133 MD5Update(&Md5Ctx, ":", 1);134 MD5Update(&Md5Ctx, pszNonce, strlen(pszNonce));135 MD5Update(&Md5Ctx, ":", 1);132 MD5Update(&Md5Ctx, (const unsigned char *)HA1, HASHHEXLEN); 133 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 134 MD5Update(&Md5Ctx, (const unsigned char *)pszNonce, strlen(pszNonce)); 135 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 136 136 if (*pszQop) { 137 MD5Update(&Md5Ctx, pszNonceCount, strlen(pszNonceCount));138 MD5Update(&Md5Ctx, ":", 1);139 MD5Update(&Md5Ctx, pszCNonce, strlen(pszCNonce));140 MD5Update(&Md5Ctx, ":", 1);141 MD5Update(&Md5Ctx, pszQop, strlen(pszQop));142 MD5Update(&Md5Ctx, ":", 1);137 MD5Update(&Md5Ctx, (const unsigned char *)pszNonceCount, strlen(pszNonceCount)); 138 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 139 MD5Update(&Md5Ctx, (const unsigned char *)pszCNonce, strlen(pszCNonce)); 140 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 141 MD5Update(&Md5Ctx, (const unsigned char *)pszQop, strlen(pszQop)); 142 MD5Update(&Md5Ctx, (const unsigned char *)":", 1); 143 143 } 144 MD5Update(&Md5Ctx, HA2Hex, HASHHEXLEN);145 MD5Final( RespHash, &Md5Ctx);144 MD5Update(&Md5Ctx, (const unsigned char *)HA2Hex, HASHHEXLEN); 145 MD5Final((unsigned char *)RespHash, &Md5Ctx); 146 146 CvtHex(RespHash, Response); 147 147 } -
extensions/app_sip/multimediaauth.c
r368 r409 41 41 struct msg *ans, *qry; 42 42 struct avp *avp, *a2, *authdataitem; 43 struct msg_hdr * header = NULL;43 //struct msg_hdr * header = NULL; 44 44 struct avp_hdr * avphdr=NULL, *avpheader=NULL, *avpheader_auth=NULL,*digestheader=NULL; 45 45 union avp_value val; … … 48 48 char * result; 49 49 char password[51]; 50 int idx=0, idx2=0,number_of_auth_items=0,i=0;50 int idx=0, number_of_auth_items=0,i=0; 51 51 //Flags and variables for Database 52 52 int sipurinotstored=0, authenticationpending=0, querylen=0, usernamelen=0; … … 70 70 71 71 72 /* Add the appropriate command code & Auth-Application-Id */72 /* Add the appropriate command code & Auth-Application-Id 73 73 { 74 74 … … 79 79 80 80 81 / * Add the Auth-Application-Id */81 // Add the Auth-Application-Id 82 82 { 83 83 CHECK_FCT( fd_msg_avp_new ( sip_dict.Auth_Application_Id, 0, &avp ) ); … … 87 87 CHECK_FCT( fd_msg_avp_add ( ans, MSG_BRW_LAST_CHILD, avp) ); 88 88 } 89 } 89 }*/ 90 90 91 91 … … 125 125 username=malloc(avphdr->avp_value->os.len*2+1); 126 126 //We purify username not to have forbidden characters 127 usernamelen=mysql_real_escape_string(conn, username, avphdr->avp_value->os.data, avphdr->avp_value->os.len);128 129 130 if((strncmp( avpheader->avp_value->os.data,"REGISTER",avpheader->avp_value->os.len)==0))127 usernamelen=mysql_real_escape_string(conn, username, (const char *)avphdr->avp_value->os.data, avphdr->avp_value->os.len); 128 129 130 if((strncmp((const char *)avpheader->avp_value->os.data,"REGISTER",avpheader->avp_value->os.len)==0)) 131 131 { 132 132 not_found=1; … … 153 153 while ((row = mysql_fetch_row(res)) != NULL) 154 154 { 155 if( row[0]!="")155 if(strlen(row[0])>0) 156 156 { 157 157 strcpy(password,row[0]); … … 195 195 while ((row = mysql_fetch_row(res)) != NULL) 196 196 { 197 if(strncmp( avphdr->avp_value->os.data,row[0],avphdr->avp_value->os.len)==0)197 if(strncmp((const char *)avphdr->avp_value->os.data,row[0],avphdr->avp_value->os.len)==0) 198 198 { 199 199 not_found=0; … … 225 225 sipuri=malloc(avphdr->avp_value->os.len*2+1); 226 226 //We purify SIP-URI not to have forbidden characters 227 sipurilen=mysql_real_escape_string(conn, sipuri, avphdr->avp_value->os.data, avphdr->avp_value->os.len);227 sipurilen=mysql_real_escape_string(conn, sipuri, (const char *)avphdr->avp_value->os.data, avphdr->avp_value->os.len); 228 228 229 229 … … 245 245 while ((row = mysql_fetch_row(res)) != NULL) 246 246 { 247 if(strncmp( avphdr->avp_value->os.data,row[0],avphdr->avp_value->os.len)==0)247 if(strncmp((const char *)avphdr->avp_value->os.data,row[0],avphdr->avp_value->os.len)==0) 248 248 { 249 249 not_found=0; … … 361 361 { 362 362 CHECK_FCT( fd_msg_avp_new ( sip_dict.Digest_QOP, 0, &a2 ) ); 363 val.os.data= "auth";364 val.os.len=strlen( val.os.data);363 val.os.data=(unsigned char *)"auth"; 364 val.os.len=strlen((const char *)val.os.data); 365 365 CHECK_FCT( fd_msg_avp_setvalue( a2, &val ) ); 366 366 CHECK_FCT( fd_msg_avp_add( sipAuthenticate, MSG_BRW_LAST_CHILD, a2 ) ); … … 387 387 CHECK_FCT( fd_sess_state_store ( ds_sess_hdl, sess, &storednonce )); 388 388 389 val.os.data= nonce;389 val.os.data=(unsigned char *)nonce; 390 390 val.os.len=NONCE_SIZE * 2; 391 391 … … 396 396 { 397 397 CHECK_FCT( fd_msg_avp_new ( sip_dict.Digest_Algorithm, 0, &a2 ) ); 398 val.os.data= "MD5";399 val.os.len=strlen( val.os.data);398 val.os.data=(unsigned char *)"MD5"; 399 val.os.len=strlen((const char *)val.os.data); 400 400 CHECK_FCT( fd_msg_avp_setvalue( a2, &val ) ); 401 401 CHECK_FCT( fd_msg_avp_add( sipAuthenticate, MSG_BRW_LAST_CHILD, a2 ) ); … … 464 464 //uint8_t bufferresp[DIGEST_LEN]; 465 465 //char response[DIGEST_LEN*2+1]; 466 int i=0;466 467 467 468 468 //We extract all the data we need … … 640 640 641 641 DigestCalcHA1(digest_algorithm, digest_username, digest_realm, password, digest_nonce,digest_cnonce, HA1); 642 643 DigestCalcResponse(HA1, digest_nonce, digest_noncecount, digest_cnonce, digest_qop,digest_method, digest_uri, HA2, response); 642 DigestCalcResponse(HA1, digest_nonce, digest_noncecount, digest_cnonce, digest_qop,digest_method, digest_uri, HA2, response); 644 643 645 644 … … 677 676 //Digest-HA1 MUST be used instead of Digest-Response-Auth if Digest-Qop is 'auth-int'. 678 677 CHECK_FCT( fd_msg_avp_new ( sip_dict.Digest_HA1, 0, &a2 ) ); 679 val.os.data= HA1;678 val.os.data=(unsigned char *)HA1; 680 679 val.os.len=HASHHEXLEN+1; 681 680 CHECK_FCT( fd_msg_avp_setvalue( a2, &val ) ); … … 686 685 //Digest-Response-Auth MUST be used instead of Digest-HA1 if Digest-Qop is 'auth'. 687 686 CHECK_FCT( fd_msg_avp_new ( sip_dict.Digest_Response_Auth, 0, &a2 ) ); 688 val.os.data= responseauth;687 val.os.data=(unsigned char *)responseauth; 689 688 val.os.len=DIGEST_LEN*2; 690 689 CHECK_FCT( fd_msg_avp_setvalue( a2, &val ) ); -
extensions/test_sip/test_sip.c
r392 r409 40 40 41 41 42 struct disp_hdl * test_sip_MAA_hdl=NULL; 43 struct disp_hdl * test_sip_LIA_hdl=NULL; 44 struct disp_hdl * test_sip_UAA_hdl=NULL; 45 struct disp_hdl * test_sip_SAA_hdl=NULL; 46 struct disp_hdl * test_sip_PPR_hdl=NULL; 47 struct disp_hdl * test_sip_RTR_hdl=NULL; 42 48 49 50 struct disp_hdl * test_sip_default_hdl=NULL; 51 struct session_handler * ts_sess_hdl; 52 53 //configuration stucture 54 struct ts_conf * ts_conf=NULL; 55 static struct ts_conf app_sip_conf; 56 57 //dictionary of SIP 58 struct test_sip_dict sip_dict; 59 60 int test_sip_default_cb( struct msg ** msg, struct avp * avp, struct session * sess, enum disp_action * act) 61 { 62 TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act); 63 64 return 0; 65 } 66 67 username = "awestfahl" 68 password = "test" 69 sip_aor = "sip:awestfahl@tera.ics.keio.ac.jp" 70 71 #Destination information 72 destination_realm = "freediameter.net" 73 destination_sip = "sip:awestfahl@freediameter.net" 74 75 void dump_config() 76 { 77 TRACE_DEBUG(FULL,"***Configuration of TEST Diameter-SIP extension***"); 78 TRACE_DEBUG(FULL,"# username: *%s*",ts_conf->username); 79 TRACE_DEBUG(FULL,"# password: *%s*",ts_conf->password); 80 TRACE_DEBUG(FULL,"# sip_aor: *%s*",ts_conf->sip_aor); 81 TRACE_DEBUG(FULL,"# destination_realm: *%s*",ts_conf->destination_realm); 82 TRACE_DEBUG(FULL,"# destination_sip: *%s*",ts_conf->destination_sip); 83 TRACE_DEBUG(FULL,"***End of TEST Diameter-SIP configuration extension***"); 84 } 85 86 static int ts_conf_init(void) 87 { 88 ts_conf=&test_sip_conf; 89 //memset(app_sip_conf, 0, sizeof(struct ts_conf)); 90 91 92 return 0; 93 } 94 95 /* entry point */ 96 int as_entry(char * conffile) 97 { 98 TRACE_ENTRY("%p", conffile); 99 100 struct dict_object * app=NULL; 101 struct disp_when data; 102 103 /* Initialize configuration */ 104 CHECK_FCT( ts_conf_init() ); 105 106 107 //We parse the configuration file 108 if (conffile != NULL) { 109 CHECK_FCT( ts_conf_handle(conffile) ); 110 } 111 else 112 { 113 TRACE_DEBUG(INFO, "We need a configuration file for Diameter-SIP extension. See doc/ for an example."); 114 } 115 116 //We can dump the configuration extracted from app_sip.conf 117 dump_config(); 118 119 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Diameter Session Initiation Protocol (SIP) Application", &app, ENOENT) ); 120 CHECK_FCT( fd_disp_app_support ( app, NULL, 1, 0 ) ); 121 122 123 124 //We set usefull AVPs 125 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Auth-Session-State", &sip_dict.Auth_Session_State, ENOENT) ); 126 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &sip_dict.Auth_Application_Id, ENOENT) ); 127 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "SIP-Auth-Data-Item", &sip_dict.SIP_Auth_Data_Item, ENOENT) ); 128 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "SIP-Authorization", &sip_dict.SIP_Authorization, ENOENT) ); 129 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "SIP-Authenticate", &sip_dict.SIP_Authenticate, ENOENT) ); 130 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "SIP-Number-Auth-Items", &sip_dict.SIP_Number_Auth_Items, ENOENT) ); 131 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "SIP-Authentication-Scheme", &sip_dict.SIP_Authentication_Scheme, ENOENT) ); 132 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "SIP-Authentication-Info", &sip_dict.SIP_Authentication_Info, ENOENT) ); 133 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "SIP-Server-URI", &sip_dict.SIP_Server_URI, ENOENT) ); 134 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "SIP-Method", &sip_dict.SIP_Method, ENOENT) ); 135 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "SIP-AOR", &sip_dict.SIP_AOR, ENOENT) ); 136 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Digest-Realm", &sip_dict.Digest_Realm, ENOENT) ); 137 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Digest-URI", &sip_dict.Digest_URI, ENOENT) ); 138 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Digest-Nonce", &sip_dict.Digest_Nonce, ENOENT) ); 139 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Digest-CNonce", &sip_dict.Digest_CNonce, ENOENT) ); 140 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Digest-Method", &sip_dict.Digest_Method, ENOENT) ); 141 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Digest-Nonce-Count", &sip_dict.Digest_Nonce_Count, ENOENT) ); 142 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Digest-Realm", &sip_dict.Digest_Realm, ENOENT) ); 143 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Digest-Response", &sip_dict.Digest_Response, ENOENT) ); 144 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Digest-Response-Auth", &sip_dict.Digest_Response_Auth, ENOENT) ); 145 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Digest-Username", &sip_dict.Digest_Username, ENOENT) ); 146 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Digest-Algorithm", &sip_dict.Digest_Algorithm, ENOENT) ); 147 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Digest-QoP", &sip_dict.Digest_QOP, ENOENT) ); 148 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "User-Name", &sip_dict.User_Name, ENOENT) ); 149 150 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Digest-HA1", &sip_dict.Digest_HA1, ENOENT) ); 151 152 153 //Register Application 154 memset(&data, 0, sizeof(data)); 155 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Diameter Session Initiation Protocol (SIP) Application", &data.app, ENOENT) ); 156 157 158 //**Command Codes 159 //MAR 160 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Multimedia-Auth-Request", &data.command, ENOENT) ); 161 CHECK_FCT( fd_disp_register( test_sip_MAR_cb, DISP_HOW_CC, &data, &test_sip_MAR_hdl ) ); 162 //RTR 163 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Registration-Termination-Request", &data.command, ENOENT) ); 164 CHECK_FCT( fd_disp_register( test_sip_RTR_cb, DISP_HOW_CC, &data, &test_sip_RTA_hdl ) ); 165 166 167 //Callback for unexpected messages 168 CHECK_FCT( fd_disp_register( test_sip_default_cb, DISP_HOW_APPID, &data, &test_sip_default_hdl ) ); 169 170 171 //We start database connection 172 if(start_mysql_connection()) 173 return 1; 174 175 CHECK_FCT(fd_sess_handler_create(&ds_sess_hdl, free)); 176 177 return 0; 178 } 179 180 //Cleanup callback 181 void fd_ext_fini(void) 182 { 183 184 if (test_sip_MAR_cb) { 185 (void) fd_disp_unregister(&test_sip_MAR_hdl); 186 CHECK_FCT_DO( fd_sess_handler_destroy(&ds_sess_hdl),return); 187 } 188 189 //We close database connection 190 close_mysql_connection(); 191 192 193 194 TRACE_ENTRY(); 195 return ; 196 } 197 198 EXTENSION_ENTRY("test_sip", ts_entry); 199 -
extensions/test_sip/test_sip.h
r392 r409 38 38 /* The module configuration */ 39 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 40 char * destination_sip; 41 char * destination_realm; 42 char * username; 43 char * password; 44 char * sip_aor; 48 45 }; 49 46 extern struct test_sip_conf * test_sip_conf; 50 47 51 48 49 //Storage for some usefull AVPs 50 struct sip_dict{ 51 struct dict_object * Auth_Session_State; 52 struct dict_object * Auth_Application_Id; 53 struct dict_object * User_Name; 54 struct dict_object * SIP_Auth_Data_Item; 55 struct dict_object * SIP_Authorization; 56 struct dict_object * SIP_Authenticate; 57 struct dict_object * SIP_Number_Auth_Items; 58 struct dict_object * SIP_Authentication_Scheme; 59 struct dict_object * SIP_Authentication_Info; 60 struct dict_object * SIP_Server_URI; 61 struct dict_object * SIP_Method; 62 struct dict_object * SIP_AOR; 63 struct dict_object * Digest_URI; 64 struct dict_object * Digest_Nonce; 65 struct dict_object * Digest_Nonce_Count; 66 struct dict_object * Digest_CNonce; 67 struct dict_object * Digest_Realm; 68 struct dict_object * Digest_Response; 69 struct dict_object * Digest_Response_Auth; 70 struct dict_object * Digest_Username; 71 struct dict_object * Digest_Method; 72 struct dict_object * Digest_QOP; 73 struct dict_object * Digest_Algorithm; 74 struct dict_object * Digest_HA1; 75 }; 76 77 extern struct sip_dict sip_dict; 52 78 53 79 54 80 55 81 82 int test_sip_default_cb( struct msg ** msg, struct avp * avp, struct session * sess, enum disp_action * act); 83 int test_sip_MAA_cb( struct msg ** msg, struct avp * avp, struct session * sess, enum disp_action * act); 84 int test_sip_RTR_cb( struct msg ** msg, struct avp * avp, struct session * sess, enum disp_action * act); 56 85 57 86 58 59 60 61 62
Note: See TracChangeset
for help on using the changeset viewer.