From: <oja...@us...> - 2006-09-06 21:25:36
|
Revision: 33 http://svn.sourceforge.net/sipp/?rev=33&view=rev Author: ojacques Date: 2006-09-06 14:25:29 -0700 (Wed, 06 Sep 2006) Log Message: ----------- Added NOTIFY to -aa (automatic answer). SIP messages with unknown call-id will be processed through the automatic answer process Modified Paths: -------------- sipp/trunk/call.cpp sipp/trunk/sipp.cpp Modified: sipp/trunk/call.cpp =================================================================== --- sipp/trunk/call.cpp 2006-09-04 16:37:11 UTC (rev 32) +++ sipp/trunk/call.cpp 2006-09-06 21:25:29 UTC (rev 33) @@ -3049,7 +3049,8 @@ L_res = 2 ; } else if (strcmp(P_recv, "PING") == 0) { L_res = 3 ; - } else if ((strcmp(P_recv, "INFO") == 0) && (call_established == true) && (auto_answer == true)){ + } else if (((strcmp(P_recv, "INFO") == 0) || (strcmp(P_recv, "NOTIFY") == 0)) + && (auto_answer == true)){ L_res = 4 ; } @@ -3063,6 +3064,7 @@ int res ; char * old_last_recv_msg = NULL; + bool last_recv_msg_saved = false; switch (P_case) { case 1: // response for an unexpected BYE @@ -3171,19 +3173,21 @@ } break ; - case 4: // response for a random INFO - // store previous last msg if msg is INFO + case 4: // response for a random INFO or NOTIFY + // store previous last msg if msg is INFO or NOTIFY // restore last_recv_msg to previous one // after sending ok old_last_recv_msg = NULL; - old_last_recv_msg = (char *) malloc(strlen(last_recv_msg)+1); - strcpy(old_last_recv_msg,last_recv_msg); - + if (last_recv_msg != NULL) { + last_recv_msg_saved = true; + old_last_recv_msg = (char *) malloc(strlen(last_recv_msg)+1); + strcpy(old_last_recv_msg,last_recv_msg); + } // usage of last_ keywords last_recv_msg = (char *) realloc(last_recv_msg, strlen(P_recv) + 1); strcpy(last_recv_msg, P_recv); - WARNING_P1("Automatic response mode for an unexpected INFO for call: %s", (id==NULL)?"none":id); + WARNING_P1("Automatic response mode for an unexpected INFO or NOTIFY for call: %s", (id==NULL)?"none":id); res = sendBuffer(createSendingMessage( (char*)"SIP/2.0 200 OK\n" "[last_Via:]\n" @@ -3196,11 +3200,13 @@ , -1)) ; // restore previous last msg - last_recv_msg = (char *) realloc(last_recv_msg, strlen(old_last_recv_msg) + 1); - strcpy(last_recv_msg, old_last_recv_msg); - if (old_last_recv_msg != NULL) { - free(old_last_recv_msg); - old_last_recv_msg = NULL; + if (last_recv_msg_saved == true) { + last_recv_msg = (char *) realloc(last_recv_msg, strlen(old_last_recv_msg) + 1); + strcpy(last_recv_msg, old_last_recv_msg); + if (old_last_recv_msg != NULL) { + free(old_last_recv_msg); + old_last_recv_msg = NULL; + } } CStat::instance()->computeStat(CStat::E_AUTO_ANSWERED); return true; Modified: sipp/trunk/sipp.cpp =================================================================== --- sipp/trunk/sipp.cpp 2006-09-04 16:37:11 UTC (rev 32) +++ sipp/trunk/sipp.cpp 2006-09-06 21:25:29 UTC (rev 33) @@ -2320,11 +2320,23 @@ #endif else // mode != from SERVER and 3PCC Controller B { - nb_out_of_the_blue++; - CStat::instance()->computeStat - (CStat::E_OUT_OF_CALL_MSGS); - WARNING_P1("Discarding message which can't be mapped to a known SIPp call:\n%s", msg); // This is a message that is not relating to any known call + if (auto_answer == true) { + // If auto answer mode, try to answer the incoming message + // if the message is not handled by automatic answers, this new + // call will be discarded (aborted) +#ifdef _USE_OPENSSL + call_ptr = add_call(call_id , pollset_index, ipv6); + pollset_attached(call_ptr,pollset_index); +#else + call_ptr = add_call(call_id , ipv6); +#endif + } else { + nb_out_of_the_blue++; + CStat::instance()->computeStat + (CStat::E_OUT_OF_CALL_MSGS); + WARNING_P1("Discarding message which can't be mapped to a known SIPp call:\n%s", msg); + } } } @@ -2932,7 +2944,8 @@ "\n" " -max_reconnect : Set the the maximum number of reconnection.\n" "\n" - " -aa : Enable the automatic answer for the INFO message.\n" + " -aa : Enable automatic 200 OK answer for INFO and NOTIFY\n" + " messages.\n" "\n" " -tdmmap map : Generate and handle a table of TDM circuits.\n" " A circuit must be available for the call to be placed.\n" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |