| 1084 | } |
| 1085 | |
| 1086 | void process_message(SIPpSocket *socket, char *msg, ssize_t msg_size, struct sockaddr_storage *src) |
| 1087 | { |
| 1088 | // TRACE_MSG(" msg_size %d and pollset_index is %d \n", msg_size, pollset_index)); |
| 1089 | if (msg_size <= 0) { |
| 1090 | return; |
| 1091 | } |
| 1092 | if (sipMsgCheck(msg, socket) == false) { |
| 1093 | if (msg_size == 4 && |
| 1094 | (memcmp(msg, "\r\n\r\n", 4) == 0 || memcmp(msg, "\x00\x00\x00\x00", 4) == 0)) { |
| 1095 | /* Common keepalives */; |
| 1096 | } else { |
| 1097 | WARNING("non SIP message discarded: \"%.*s\" (%zu)", (int)msg_size, msg, msg_size); |
| 1098 | } |
| 1099 | return; |
| 1100 | } |
| 1101 | |
| 1102 | const char *call_id = get_trimmed_call_id(msg); |
| 1103 | if (call_id[0] == '\0') { |
| 1104 | WARNING("SIP message without Call-ID discarded"); |
| 1105 | return; |
| 1106 | } |
| 1107 | listener *listener_ptr = get_listener(call_id); |
| 1108 | struct timeval currentTime; |
| 1109 | GET_TIME (¤tTime); |
| 1110 | |
| 1111 | if (useShortMessagef == 1) { |
| 1112 | TRACE_SHORTMSG("%s\tR\t%s\tCSeq:%s\t%s\n", |
| 1113 | CStat::formatTime(¤tTime), call_id, get_header_content(msg, "CSeq:"), get_first_line(msg)); |
| 1114 | } |
| 1115 | |
| 1116 | if (useMessagef == 1) { |
| 1117 | TRACE_MSG("----------------------------------------------- %s\n" |
| 1118 | "%s %smessage received [%zu] bytes:\n\n%s\n", |
| 1119 | CStat::formatTime(¤tTime, true), |
| 1120 | TRANSPORT_TO_STRING(socket->ss_transport), |
| 1121 | socket->ss_control ? "control " : "", |
| 1122 | msg_size, msg); |
| 1123 | } |
| 1124 | |
| 1125 | // got as message not relating to a known call |
| 1126 | if (!listener_ptr) { |
| 1127 | if (thirdPartyMode == MODE_3PCC_CONTROLLER_B || thirdPartyMode == MODE_3PCC_A_PASSIVE || |
| 1128 | thirdPartyMode == MODE_MASTER_PASSIVE || thirdPartyMode == MODE_SLAVE) { |
| 1129 | // Adding a new OUTGOING call ! |
| 1130 | main_scenario->stats->computeStat(CStat::E_CREATE_OUTGOING_CALL); |
| 1131 | call *new_ptr = new call(main_scenario, call_id, local_ip_is_ipv6, 0, use_remote_sending_addr ? &remote_sending_sockaddr : &remote_sockaddr); |
| 1132 | |
| 1133 | outbound_congestion = false; |
| 1134 | if ((socket != main_socket) && |
| 1135 | (socket != tcp_multiplex) && |
| 1136 | (socket != localTwinSippSocket) && |
| 1137 | (socket != twinSippSocket) && |
| 1138 | (!is_a_local_socket(socket))) { |
| 1139 | new_ptr->associate_socket(socket); |
| 1140 | socket->ss_count++; |
| 1141 | } else { |
| 1142 | /* We need to hook this call up to a real *call* socket. */ |
| 1143 | if (!multisocket) { |
no test coverage detected