| 94 | } |
| 95 | |
| 96 | static int notification_handler(str *command) |
| 97 | { |
| 98 | char cmd, *p; |
| 99 | str param, token; |
| 100 | unsigned int h_entry, h_id, is_callid = 0; |
| 101 | struct rtpp_dtmf_event dtmf; |
| 102 | str terminate_reason = str_init("RTPProxy Timeout"); |
| 103 | |
| 104 | if (command->len < 1) { |
| 105 | LM_ERR("no command received from RTPProxy!\n"); |
| 106 | return -1; |
| 107 | } |
| 108 | cmd = command->s[0]; |
| 109 | param.s = command->s + 1; |
| 110 | param.len = command->len - 1; |
| 111 | LM_DBG("Handling RTPProxy command %c %.*s\n", cmd, param.len, param.s); |
| 112 | switch (cmd) { |
| 113 | case 'I': |
| 114 | /* we are not listening for timeout notifications */ |
| 115 | return 0; |
| 116 | case 'T': |
| 117 | LM_INFO("Timeout notification for %.*s\n", param.len, param.s); |
| 118 | if (parse_dlg_did(¶m, &h_entry, &h_id) < 0) |
| 119 | return -1; |
| 120 | if(run_dlg_api(&dlg_api, terminate_dlg, NULL, h_entry, h_id, &terminate_reason)< 0) |
| 121 | LM_ERR("Failed to terminate dialog h_entry=[%u], h_id=[%u]\n", h_entry, h_id); |
| 122 | return 0; |
| 123 | case 'D': |
| 124 | p = q_memchr(param.s, ' ' ,param.len); |
| 125 | if (!p) { |
| 126 | LM_ERR("could not determine the notification id in %.*s!\n", |
| 127 | param.len, param.s); |
| 128 | return -1; |
| 129 | } |
| 130 | token.s = param.s + 1; |
| 131 | token.len = p - token.s; |
| 132 | if (*param.s == 'c') |
| 133 | is_callid = 1; |
| 134 | |
| 135 | param.s = p + 1; |
| 136 | param.len -= token.len + 2; |
| 137 | |
| 138 | if (param.len < 0) { |
| 139 | LM_ERR("could not get digit in param %.*s!\n", param.len, param.s); |
| 140 | return -1; |
| 141 | } |
| 142 | |
| 143 | memset(&dtmf, 0, sizeof dtmf); |
| 144 | dtmf.is_callid = is_callid; |
| 145 | dtmf.id = token; |
| 146 | |
| 147 | dtmf.digit = *param.s; |
| 148 | |
| 149 | param.s += 2; |
| 150 | param.len -= 2; |
| 151 | |
| 152 | if (param.len > 0) { |
| 153 | p = q_memchr(param.s, ' ', param.len); |
no test coverage detected