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

Johan Wilfer johan at wilfer.se
Wed Apr 23 09:11:22 CDT 2008


Can't you use the function SIP_HEADER?
Like this: Noop(${SIP_HEADER(TO)})
/Johan

ons 2008-04-23 klockan 14:23 +0100 skrev Eric Dantie:
> 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));
>                                 }
>                         }
>                 }
>  
>         }
>  
>  
> _______________________________________________
> --Bandwidth and Colocation Provided by http://www.api-digital.com--
> 
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-dev




More information about the asterisk-dev mailing list