Changeset 409:c2fb5b26bfcb in freeDiameter for extensions/app_sip/multimediaauth.c
- Timestamp:
- Jul 8, 2010, 4:19:28 PM (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 ) );
Note: See TracChangeset
for help on using the changeset viewer.