I tried to get an answer in Userâs forum but no answer, so I delted the post there and try it here
I want to send SIP error codes like â500â to the calling phone.
This seems proxy functionality (because SER can do that with sl_send_reply) but I do not want to install another server with SER.
So does anyone know how to send such codes?
I looked the code of chan_sip.c and (IIRC) pbx.c and found a structure of type sip_pvt but unfortunately this structure is not available in any header file
Btw:
SendText is not what I want
Do I really have to write my own application and get information aobut the phoneâs ip address via channel structures?
I am not sure this is directly possible in the latest version of Asterisk (v1.2) or even in the CVS HEAD. The closest you may get is SIPAddHeader() and SIPGetHeader(), but that is for adding custom headers.
Thanks for the answer.
I added SipAddHeader to my dialplan and built up a SER. So now my network looks like this:
KPhone --> SER --> Asterisk --> ...
SER uses âforwardâ to route calls to Asterisk. Works pretty fine (though it wasnât fine to understand ser.cfg g).
Then I added a kind of extension to SER, means a special number that should reply an error code (letâs use 500). Works fine but the reply is sent to Asterisk
So now I know who called and callerâs IP address on SER (and of course on Asterisk).
Any idea how to do such a routing:
My phone --> SER --> Asterisk (uses DIAL(SIP/F500@myser.mydomain.com)) --> SER --(error 500 with sl_send_reply or such a thing)--> My phone
As we know, Asterisk uses legsâŚhow can I bridge or transfer or whatever?
Hope, someone has an idea
Thanks and kind regards,
Sancho
P.S.: I found openSER 0.10.0âŚseems it works with variablesâŚ
My next tries:
With Asterisk I call a ânumberâ at SER and SER returns with error 606 per sl_send_reply (thatâs currently hardcoded in ser.cfg).
The caller gets a 403 on his phoneâs display
So I thought: "Open source means do some changes in chan_sip.c and everythingâs okay!"
Result: nothingâs okay. I found function handle_response in that file and wrote following (with some lines of code before; I changed code in default section):
case 480: /* Temporarily Unavailable */
case 404: /* Not Found */
case 410: /* Gone */
case 400: /* Bad Request */
case 500: /* Server error */
case 503: /* Service Unavailable */
if (owner)
ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
break;
default:
/* Send hangup */
if (p->owner) {
ast_log(LOG_WARNING, "Peer %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port));
if (sipmethod == SIP_INVITE) {
ast_log(LOG_NOTICE, "We are on invitation\n");
transmit_request(p, SIP_ACK, seqno, 0, 0);
}
ast_log(LOG_NOTICE, "Detected Code %d. Weare from: %s, %s \n", resp, p->fromname, p->fromuser);
ast_queue_control(p->owner, resp);
ast_queue_hangup(p->owner);
}
break;
}
So why isnât it possible that codes are sent to the caller as they are?