<div dir="ltr">Look at mod_sofia.c:
<p class=""><span class="">case</span> SWITCH_EVENT_SEND_MESSAGE:</p></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 30, 2014 at 7:41 AM, Ronnie Beck <span dir="ltr"><<a href="mailto:rony@botl.au.com" target="_blank">rony@botl.au.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hello Freeswitch Gurus!<br>
<br>
I have a simple problem I am hoping someone might be able to help me
with. I want to configure a SNOM phone automagically using SIP
messages. The process is described here:
<a href="http://wiki.snom.com/Category:HowTo:XML_SIP_Settings" target="_blank">http://wiki.snom.com/Category:HowTo:XML_SIP_Settings</a><br>
I have created a Freeswitch module which sends the appropriate SIP
message to the phone but I have hit a small snag. In order for this
to work, two headers must be set in the SIP message else the SNOM
will ignore the request. Those are:<br>
<br>
Event: snom-settings<br>
Content-Type: application/xml<br>
<br>
I have code which should do that but when I do a packet capture, I
can see that the "Event" header is not in the SIP message that is
sent. The code I am using is listed below. Is there something
obvious that I am doing wrong?<br>
<br>
According to the output I get in the Freeswitch console from my
module, the "Event" header is successfully added to the event,
however it isn't present in the SIP message.<br>
<br>
Many thanks in advance,<br>
<br>
Ronnie<br>
<br>
<br>
Code:<br>
<br>
<code><font color="#3f7f5f"><font style="font-size:10pt">//Send
the
configuration </font></font></code><code><br>
</code><code>
</code><code><font color="#7f0055"><font style="font-size:10pt"><b>if</b></font></font></code><code><font color="#000000"><font style="font-size:10pt">
(switch_event_create(&event, </font></font></code><code><font color="#0000c0"><font style="font-size:10pt"><i>SWITCH_EVENT_SEND_MESSAGE</i></font></font></code><code><font color="#000000"><font style="font-size:10pt">)
== </font></font></code><code><font color="#0000c0"><font style="font-size:10pt"><i>SWITCH_STATUS_SUCCESS</i></font></font></code><code><font color="#000000"><font style="font-size:10pt">)</font></font></code><code></code><code></code><code><br>
</code><code><font color="#000000"><font style="font-size:10pt"> {</font></font></code><code></code><code></code><code></code><code><br>
</code><code><font color="#000000"><font style="font-size:10pt"> </font></font></code><code><font color="#642880"><font style="font-size:10pt"><b>
switch_event_add_header_string</b></font></font></code><code><font color="#000000"><font style="font-size:10pt">(event,
</font></font></code><code><font color="#0000c0"><font style="font-size:10pt"><i>SWITCH_STACK_BOTTOM</i></font></font></code><code><font color="#000000"><font style="font-size:10pt">,
</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">"user"</font></font></code><code><font color="#000000"><font style="font-size:10pt">,user);</font></font></code><code></code><code></code><code><br>
</code><code><font color="#000000"><font style="font-size:10pt"> </font></font></code><code><font color="#642880"><font style="font-size:10pt"><b>
switch_event_add_header_string</b></font></font></code><code><font color="#000000"><font style="font-size:10pt">(event,
</font></font></code><code><font color="#0000c0"><font style="font-size:10pt"><i>SWITCH_STACK_BOTTOM</i></font></font></code><code><font color="#000000"><font style="font-size:10pt">,
</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">"host"</font></font></code><code><font color="#000000"><font style="font-size:10pt">,</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">"10.0.0.23"</font></font></code><code><font color="#000000"><font style="font-size:10pt">);</font></font></code><code></code><code></code><code><br>
</code><code><font color="#000000"><font style="font-size:10pt"> </font></font></code><code><font color="#642880"><font style="font-size:10pt"><b>
switch_event_add_header_string</b></font></font></code><code><font color="#000000"><font style="font-size:10pt">(event,
</font></font></code><code><font color="#0000c0"><font style="font-size:10pt"><i>SWITCH_STACK_BOTTOM</i></font></font></code><code><font color="#000000"><font style="font-size:10pt">,
</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">"profile"</font></font></code><code><font color="#000000"><font style="font-size:10pt">,</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">"internal"</font></font></code><code><font color="#000000"><font style="font-size:10pt">);</font></font></code><code></code><code></code><code><br>
</code><code><font color="#000000"><font style="font-size:10pt"> </font></font></code><code><font color="#642880"><font style="font-size:10pt"><b>
switch_event_add_header_string</b></font></font></code><code><font color="#000000"><font style="font-size:10pt">(event,
</font></font></code><code><font color="#0000c0"><font style="font-size:10pt"><i>SWITCH_STACK_BOTTOM</i></font></font></code><code><font color="#000000"><font style="font-size:10pt">,
</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">"Subject"</font></font></code><code><font color="#000000"><font style="font-size:10pt">,</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">"buttons"</font></font></code><code><font color="#000000"><font style="font-size:10pt">);</font></font></code><code></code><code></code><code><br>
</code><code><font color="#000000"><font style="font-size:10pt"> returnValue
= </font></font></code><code><font color="#642880"><font style="font-size:10pt"><b>switch_event_add_header_string</b></font></font></code><code><font color="#000000"><font style="font-size:10pt">(event,
</font></font></code><code><font color="#0000c0"><font style="font-size:10pt"><i>SWITCH_STACK_BOTTOM</i></font></font></code><code><font color="#000000"><font style="font-size:10pt">,
</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">"Event"</font></font></code><code><font color="#000000"><font style="font-size:10pt">,</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">"</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt"><u>snom</u></font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">-settings"</font></font></code><code><font color="#000000"><font style="font-size:10pt">);</font></font></code><code></code><code></code><code><br>
</code><code><font color="#000000"><font style="font-size:10pt"> </font></font></code><code><font color="#642880"><font style="font-size:10pt"><b>
switch_event_add_header_string</b></font></font></code><code><font color="#000000"><font style="font-size:10pt">(event,
</font></font></code><code><font color="#0000c0"><font style="font-size:10pt"><i>SWITCH_STACK_BOTTOM</i></font></font></code><code><font color="#000000"><font style="font-size:10pt">,
</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">"Content-Type"</font></font></code><code><font color="#000000"><font style="font-size:10pt">,
</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">"application/</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt"><u>xml</u></font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">"</font></font></code><code><font color="#000000"><font style="font-size:10pt">);</font></font></code><code></code><code></code><code><br>
</code><code><font color="#000000"><font style="font-size:10pt"> </font></font></code><code><font color="#642880"><font style="font-size:10pt"><b> switch_event_add_body</b></font></font></code><code><font color="#000000"><font style="font-size:10pt">(event,
</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">"<settings>"</font></font></code><code></code><code></code><code><br>
</code><code><font color="#000000"><font style="font-size:10pt"> </font></font></code><code><font color="#2a00ff"><font style="font-size:10pt"> "<phone-settings>"</font></font></code><code><br>
</code><code>
</code><code></code><code><font color="#2a00ff"><font> .<br>
.<br>
<snip><br>
.<br>
.<br>
</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt"> "</settings>"</font></font></code><code><font color="#000000"><font style="font-size:10pt">);</font></font></code><code><br>
</code><code>
</code><code><font color="#000000"><font style="font-size:10pt"> switch_event_fire(&event);</font></font></code><code><br>
</code><code>
</code><code><br>
</code><code>
</code><code><br>
</code><code><font color="#000000"><font style="font-size:10pt"> </font></font></code><code><font color="#7f0055"><font style="font-size:10pt"><b> if</b></font></font></code><code><font color="#000000"><font style="font-size:10pt">(
returnValue != </font></font></code><code><font color="#0000c0"><font style="font-size:10pt"><i>SWITCH_STATUS_SUCCESS</i></font></font></code><code><font color="#000000"><font style="font-size:10pt">
)</font></font></code><code></code><code></code><code><br>
</code><code><font color="#000000"><font style="font-size:10pt"> </font></font></code><code><font color="#642880"><font style="font-size:10pt"><b> switch_log_printf</b></font></font></code><code><font color="#000000"><font style="font-size:10pt">(
SWITCH_CHANNEL_LOG, </font></font></code><code><font color="#0000c0"><font style="font-size:10pt"><i>SWITCH_LOG_INFO</i></font></font></code><code><font color="#000000"><font style="font-size:10pt">,
</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">"(%s)
Failed to set Event header for user %s.\n"</font></font></code><code><font color="#000000"><font style="font-size:10pt">,
__FUNCTION__, user );</font></font></code><code></code><code></code><code><br>
</code><code><font color="#000000"><font style="font-size:10pt"> </font></font></code><code><font color="#7f0055"><font style="font-size:10pt"><b> else</b></font></font></code><code></code><code></code><code><br>
</code><code><font color="#000000"><font style="font-size:10pt"> </font></font></code><code><font color="#642880"><font style="font-size:10pt"><b> switch_log_printf</b></font></font></code><code><font color="#000000"><font style="font-size:10pt">(
SWITCH_CHANNEL_LOG, </font></font></code><code><font color="#0000c0"><font style="font-size:10pt"><i>SWITCH_LOG_INFO</i></font></font></code><code><font color="#000000"><font style="font-size:10pt">,
</font></font></code><code><font color="#2a00ff"><font style="font-size:10pt">"(%s)
Succeeded to set Event header for user %s.\n"</font></font></code><code><font color="#000000"><font style="font-size:10pt">,
__FUNCTION__, user );</font></font></code><br>
}<br>
<p style="margin-bottom:0in;line-height:100%"><br>
</p>
<br>
</div>
<br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-dev mailing list<br>
<a href="mailto:FreeSWITCH-dev@lists.freeswitch.org">FreeSWITCH-dev@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">
<p><font face="courier new, monospace"><b><i><font size="4">Brian West</font></i></b><br><span style="font-size:x-small"><a href="mailto:brian@freeswitch.org" target="_blank">brian@freeswitch.org</a></span></font></p>
<p><font size="1" face="courier new, monospace"><img src="http://bkw.org/whmcslogo.png"><br></font></p><p><font face="courier new, monospace"><b><i>Twitter: @FreeSWITCH , @briankwest</i></b><br><a href="http://www.freeswitchbook.com" target="_blank">http://www.freeswitchbook.com</a><br><a href="http://www.freeswitchcookbook.com" target="_blank">http://www.freeswitchcookbook.com</a></font></p>
<p><font face="courier new, monospace"><b>T:</b>+19184209001 | <b>F:</b>+19184209002 | <b>M:</b>+1918424WEST (9378)<br><b>iNUM:</b>+883 5100 1420 9001 | <b>ISN:</b>410*543 | <b>Skype:</b>briankwest</font></p></div>
</div>