Remove sdp flag in messages

This commit is contained in:
Kaian 2015-07-02 13:29:17 +02:00
parent 5cfa24b017
commit df175cc5ba
4 changed files with 14 additions and 43 deletions

View File

@ -143,7 +143,7 @@ call_group_msg_number(sip_call_group_t *group, sip_msg_t *msg)
int number = 0;
sip_msg_t *cur = NULL;
while ((cur = call_group_get_next_msg(group, cur))) {
if (group->sdp_only && !msg->sdp)
if (group->sdp_only && !msg_has_sdp(msg))
continue;
if (cur == msg)

View File

@ -85,10 +85,6 @@ sip_init(int limit, int only_calls, int no_incomplete)
regcomp(&calls.reg_cseq, "^CSeq:[ ]*([0-9]+) .+\r$", match_flags);
regcomp(&calls.reg_from, "^(From|f):[ ]*[^:]*:(([^@]+)@?[^\r>;]+)", match_flags);
regcomp(&calls.reg_to, "^(To|t):[ ]*[^:]*:(([^@]+)@?[^\r>;]+)", match_flags);
regcomp(&calls.reg_sdp, "^Content-Type:[ ]* application/sdp\r$", match_flags);
regcomp(&calls.reg_sdp_addr, "^c=[^ ]+ [^ ]+ (.+)\r$", match_flags);
regcomp(&calls.reg_sdp_port, "^m=[^ ]+ ([0-9]+)", match_flags);
}
void
@ -108,9 +104,6 @@ sip_deinit()
regfree(&calls.reg_cseq);
regfree(&calls.reg_from);
regfree(&calls.reg_to);
regfree(&calls.reg_sdp);
regfree(&calls.reg_sdp_addr);
regfree(&calls.reg_sdp_port);
// Remove calls mutex
pthread_mutex_destroy(&calls.lock);
}
@ -366,7 +359,6 @@ sip_load_message(capture_packet_t *packet, const char *src, u_short sport, const
msg_add_packet(msg, packet);
// Add the message to the call
call_add_message(call, msg);
// Parse SIP payload
msg_parse_payload(msg, payload);
// Parse media data
@ -484,7 +476,7 @@ msg_has_sdp(void *item)
{
// TODO
sip_msg_t *msg = (sip_msg_t *)item;
return msg->sdp;
return vector_count(msg->medias) ? 1 : 0;
}
void
@ -645,32 +637,9 @@ msg_parse_media(sip_msg_t *msg, const u_char *payload)
int port = 0;
char *payload2, *tofree, *line;
// Check if this message has sdp
if (regexec(&calls.reg_sdp, (char*)payload, 0, 0, 0) != 0)
return;
// Initialize variables
memset(address, 0, sizeof(address));
// SDP Address
if (regexec(&calls.reg_sdp_addr, (char*)payload, 2, pmatch, 0) == 0) {
sprintf(address, "%.*s", pmatch[1].rm_eo - pmatch[1].rm_so, payload + pmatch[1].rm_so);
msg_set_attribute(msg, SIP_ATTR_SDP_ADDRESS, address);
}
// SDP Port
if (regexec(&calls.reg_sdp_port, (char*)payload, 2, pmatch, 0) == 0) {
msg_set_attribute(msg, SIP_ATTR_SDP_PORT, "%.*s", pmatch[1].rm_eo - pmatch[1].rm_so,
payload + pmatch[1].rm_so);
port = atoi(msg_get_attribute(msg, SIP_ATTR_SDP_PORT));
}
if (!strlen(address) || !port)
return;
// Message has SDP
msg->sdp = 1;
// Parse each line of payload looking for sdp information
tofree = payload2 = strdup((char*)payload);
while ((line = strsep(&payload2, "\r\n")) != NULL) {
@ -715,6 +684,13 @@ msg_parse_media(sip_msg_t *msg, const u_char *payload)
}
}
free(tofree);
// If message has media
if ((media = vector_first(msg->medias))) {
msg_set_attribute(msg, SIP_ATTR_SDP_ADDRESS, media_get_address(media));
msg_set_attribute(msg, SIP_ATTR_SDP_PORT, "%d", media_get_port(media));
}
}
int

View File

@ -91,8 +91,6 @@ struct sip_msg {
int color;
//! Request Method or Response Code @see sip_methods
int reqresp;
//! This message contains sdp data
int sdp;
//! Message Cseq
int cseq;
//! Message attribute list
@ -164,9 +162,6 @@ struct sip_call_list {
regex_t reg_cseq;
regex_t reg_from;
regex_t reg_to;
regex_t reg_sdp;
regex_t reg_sdp_addr;
regex_t reg_sdp_port;
// Warranty thread-safe access to the calls list
pthread_mutex_t lock;

View File

@ -369,18 +369,18 @@ call_flow_draw_message(PANEL *panel, call_flow_arrow_t *arrow, int cline)
sprintf(method, "%s", msg_method);
// If message has sdp information
if (msg->sdp && setting_has_value(SETTING_CF_SDP_INFO, "off")) {
if (msg_has_sdp(msg) && setting_has_value(SETTING_CF_SDP_INFO, "off")) {
// Show sdp tag in tittle
sprintf(method, "%s (SDP)", msg_method);
}
if (msg->sdp && setting_has_value(SETTING_CF_SDP_INFO, "first")) {
if (msg_has_sdp(msg) && setting_has_value(SETTING_CF_SDP_INFO, "first")) {
sprintf(method, "%.3s (%s:%s)",
msg_method,
msg_get_attribute(msg, SIP_ATTR_SDP_ADDRESS),
msg_get_attribute(msg, SIP_ATTR_SDP_PORT));
}
if (msg->sdp && setting_has_value(SETTING_CF_SDP_INFO, "full")) {
if (msg_has_sdp(msg) && setting_has_value(SETTING_CF_SDP_INFO, "full")) {
sprintf(method, "%.3s (%s)",
msg_method,
msg_get_attribute(msg, SIP_ATTR_SDP_ADDRESS));
@ -441,7 +441,7 @@ call_flow_draw_message(PANEL *panel, call_flow_arrow_t *arrow, int cline)
mvwprintw(win, cline, startpos + distance / 2 - msglen / 2 + 2, "%.26s", method);
cline ++;
// Draw media information
if (msg->sdp && setting_has_value(SETTING_CF_SDP_INFO, "full")) {
if (msg_has_sdp(msg) && setting_has_value(SETTING_CF_SDP_INFO, "full")) {
medias = vector_iterator(msg->medias);
while ((media = vector_iterator_next(&medias))) {
sprintf(mediastr, "%s %d (%s)",
@ -679,7 +679,7 @@ int
call_flow_arrow_height(PANEL *panel, const call_flow_arrow_t *arrow)
{
if (arrow->type == CF_ARROW_SIP) {
if (!arrow->msg->sdp)
if (!msg_has_sdp(arrow->msg))
return 2;
if (setting_has_value(SETTING_CF_SDP_INFO, "off"))
return 2;