How to send error codes to connected phones?

Hi :smile:

I tried to get an answer in User’s forum but no answer, so I delted the post there and try it here :smile:

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 :frowning:

SendText is not what I want :wink:

Do I really have to write my own application and get information aobut the phone’s ip address via channel structures?

Thanks and kind regards,

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. … PGetHeader

Hi :smile:

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 :frowning:

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/ --> 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 :smile:

Thanks and kind regards,

P.S.: I found openSER 0.10.0…seems it works with variables…

Hi :smile:

Well, I better stay in this thread.

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 :frowning:

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);

                                         /* 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);

So why isn’t it possible that codes are sent to the caller as they are?

Kind regards,