[asterisk-dev] A method to retrieve sip custom headers, is this a good way?

Eric Dantie edantie at gmail.com
Wed Apr 23 08:23:50 CDT 2008


Like there's no way to retrieve custom parameters from SIP headers (AFAIK) I've written a little code wich reading for each SIP packet the header. If' there are some headers starting with X- then add a variable of the same name to the concern channel (if any).

Is it a good way?

Here is the code I added at the end of handle_request, just before the return.


        // Save customs headers (starting with X-) as variables

        // if there's a channel asociated with the request
        if (p->owner) {
                int x;
                for (x=0; x<req->headers; x++) {
                        if (!strncasecmp(req->header[x], "X-", 2)) {
                                char *name = ast_strdupa(req->header[x]);
                                char *nameptr = strstr(name, ":");

                                if (*nameptr) {
                                        *nameptr = 0;
                                        nameptr++;
                                        pbx_builtin_setvar_helper(p->owner,ast_skip_blanks(name),ast_skip_blanks(nameptr));
                                }
                        }
                }

        }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20080423/24fc71ed/attachment.htm 


More information about the asterisk-dev mailing list