Skip to content

Commit

Permalink
Merge pull request #1006 from giavac/master
Browse files Browse the repository at this point in the history
Add HEPv3 support to siptrace
  • Loading branch information
giavac committed Feb 23, 2017
2 parents 9e6f94e + d00f198 commit 103e503
Show file tree
Hide file tree
Showing 4 changed files with 385 additions and 48 deletions.
47 changes: 47 additions & 0 deletions src/modules/sipcapture/hep.h
Expand Up @@ -177,5 +177,52 @@ struct hep_generic_recv {

typedef struct hep_generic_recv hep_generic_recv_t;

#define HEP3_PACK_INIT(buf) \
union { \
hep_chunk_uint8_t chunk8; \
hep_chunk_uint16_t chunk16; \
hep_chunk_uint32_t chunk32; \
hep_chunk_t chunkpl; \
uint16_t len; \
} _tmpu; \
char *_tmp_p = (buf); \
memcpy(_tmp_p, "HEP3", 4); \
_tmp_p += 4 + 2/* skip length */;

#define HEP3_PACK_FINALIZE(buf, lenp) \
do { \
_tmpu.len = htons(_tmp_p - (char *)(buf)); \
memcpy((void *)(&(((hep_ctrl_t *)(buf))->length)), (void*)&_tmpu.len, 2); \
*lenp = _tmp_p - (char *)(buf); \
} while (0)

#define _HEP3_PACK_CHUNK_GENERIC(type, tmpvar, vid, tid, val) \
do { \
(tmpvar).chunk.vendor_id = htons(vid); \
(tmpvar).chunk.type_id = htons(tid); \
(tmpvar).chunk.length = htons(sizeof(type)); \
(tmpvar).data = (val); \
memcpy(_tmp_p, (void *) &(tmpvar), sizeof(type)); \
_tmp_p += sizeof(type); \
} while (0)

#define HEP3_PACK_CHUNK_UINT8(vid, tid, val) _HEP3_PACK_CHUNK_GENERIC(hep_chunk_uint8_t, _tmpu.chunk8, vid, tid, val)
#define HEP3_PACK_CHUNK_UINT16(vid, tid, val) _HEP3_PACK_CHUNK_GENERIC(hep_chunk_uint16_t, _tmpu.chunk16, vid, tid, htons(val))
#define HEP3_PACK_CHUNK_UINT16_NBO(vid, tid, val) _HEP3_PACK_CHUNK_GENERIC(hep_chunk_uint16_t, _tmpu.chunk16, vid, tid, (val))
#define HEP3_PACK_CHUNK_UINT32(vid, tid, val) _HEP3_PACK_CHUNK_GENERIC(hep_chunk_uint32_t, _tmpu.chunk32, vid, tid, htonl(val))
#define HEP3_PACK_CHUNK_UINT32_NBO(vid, tid, val) _HEP3_PACK_CHUNK_GENERIC(hep_chunk_uint32_t, _tmpu.chunk32, vid, tid, (val))

#define HEP3_PACK_CHUNK_DATA(vid, tid, val, len) \
do { \
_tmpu.chunkpl.vendor_id = htons(vid); \
_tmpu.chunkpl.type_id = htons(tid); \
_tmpu.chunkpl.length = htons(sizeof(hep_chunk_t) + (len)); \
memcpy(_tmp_p, (void *) &_tmpu.chunkpl, sizeof(hep_chunk_t)); \
_tmp_p += sizeof(hep_chunk_t); \
memcpy(_tmp_p, (void *) (val), len); \
_tmp_p += len; \
} while (0)

#define HEP3_PACK_CHUNK_IP6(vid, tid, paddr) HEP3_PACK_CHUNK_DATA(vid, tid, paddr, sizeof(struct in6_addr))

#endif
5 changes: 5 additions & 0 deletions src/modules/siptrace/doc/siptrace.xml
Expand Up @@ -28,6 +28,11 @@
<surname>Mierla</surname>
<email>miconda@gmail.com</email>
</editor>
<editor>
<firstname>Giacomo</firstname>
<surname>Vacca</surname>
<email>giacomo.vacca@gmail.com</email>
</editor>
</authorgroup>
<copyright>
<year>2010</year>
Expand Down
60 changes: 42 additions & 18 deletions src/modules/siptrace/doc/siptrace_admin.xml
Expand Up @@ -17,8 +17,8 @@
<title>Overview</title>
<para>
The SIPtrace module offer a possibility to store incoming and outgoing SIP
messages in a database and/or duplicate to the capturing server (using <acronym>HEP</acronym>
the Homer encapsulation protocol or plain SIP mode)
messages in a database and/or duplicate to the capturing server (using <acronym>HEP</acronym>,
the Homer encapsulation protocol, or plain SIP mode)
</para>
<para>
There are two ways of storing information:
Expand All @@ -42,8 +42,7 @@
</para>

<para>
The tracing can be turned on/off using Kamailio <acronym>mi</acronym> or <acronym>RPC</acronym>
commands.
The tracing can be turned on/off using Kamailio <acronym>RPC</acronym> commands.
</para>
<para>
&ctltool; fifo sip_trace on
Expand All @@ -57,12 +56,12 @@
<section>
<title>&kamailio; Modules</title>
<para>
The following modules must be loaded before this module:
The following modules must be conditionally loaded before this module:
<itemizedlist>
<listitem>
<para>
<emphasis>A database module</emphasis> - Mysql, Postgres,
dbtext, unixODBC...
dbtext, unixODBC... Optional, if tracing to DB is enabled.
</para>
</listitem>
<listitem>
Expand Down Expand Up @@ -199,7 +198,7 @@ modparam("siptrace", "traced_user_avp", "$avp(s:user)")
store the SIP messages. If it is not set, the value of
<quote>table</quote> parameter is used. In this way one can select
dynamically where to store the traced messages. The table
must exists, and must have the same structure as the <quote>sip_trace</quote>
must exist, and must have the same structure as the <quote>sip_trace</quote>
table.
</para>
<para>
Expand Down Expand Up @@ -395,8 +394,9 @@ modparam("siptrace", "hep_mode_on", 1)
<title><varname>hep_version</varname> (integer)</title>
<para>
The parameter indicate the version of the HEP protocol.
Can be <quote>1</quote> or <quote>2</quote>. In HEPv2 the timestamp and capture agent ID
will be included to HEP header.
Can be <quote>1</quote>, <quote>2</quote> or <quote>3</quote>.
In HEPv2 and HEPv3 the timestamp and capture agent ID will be
included in the HEP header.
</para>
<para>
<emphasis>
Expand All @@ -407,7 +407,7 @@ modparam("siptrace", "hep_mode_on", 1)
<title>Set <varname>hep_version</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("siptrace", "hep_version", 2)
modparam("siptrace", "hep_version", 3)
...
</programlisting>
</example>
Expand All @@ -416,17 +416,16 @@ modparam("siptrace", "hep_version", 2)
<title><varname>hep_capture_id</varname> (integer)</title>
<para>
The parameter indicate the capture agent ID for the <acronym>HEPv2</acronym>
protocol.
Limitation: 16-bit integer.
or <acronym>HEPv3</acronym> protocol.
Limitation: 16-bit integer for HEPv2, 32-bit for HEPv3.
</para>
<para>
<emphasis>
Default value is "1".
</emphasis>
</para>
<example>
<title>Set <varname>hep_capture_id</varname>
parameter</title>
<title>Set <varname>hep_capture_id</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("siptrace", "hep_capture_id", 234)
Expand Down Expand Up @@ -456,7 +455,7 @@ modparam("siptrace", "trace_delayed", 1)
<section id="siptrace.p.force_send_sock">
<title><varname>force_send_sock</varname> (str)</title>
<para>
The local interface in the form of SIP uri from where to send
The local interface in the form of SIP URI from where to send
the duplicated traffic. In the absence of this parameter
&kamailio; automatically picks an interface.
</para>
Expand Down Expand Up @@ -490,6 +489,25 @@ modparam("siptrace", "force_send_sock", "sip:10.1.1.2:5000")
...
modparam("siptrace", "trace_mode", 1)
...
</programlisting>
</example>
</section>
<section id="siptrace.p.auth_key">
<title><varname>auth_key</varname> (integer)</title>
<para>
A string with an authorization key.
Supported on HEPv3 only.
</para>
<para>
Default value is empty.
</para>
<example>
<title>Set <varname>auth_key</varname>
parameter</title>
<programlisting format="linespecific">
...
modparam("siptrace", "auth_key", "spoihepuirthpeuia")
...
</programlisting>
</example>
</section>
Expand All @@ -499,7 +517,7 @@ modparam("siptrace", "trace_mode", 1)
<title>Functions</title>
<section id="siptrace.f.sip_trace">
<title>
<function moreinfo="none">sip_trace([address])</function>
<function moreinfo="none">sip_trace([address][, correlation_id])</function>
</title>
<para>
Store or forward the current processed SIP message in database. It is stored in the
Expand All @@ -508,10 +526,14 @@ modparam("siptrace", "trace_mode", 1)
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>address</emphasis> - The address in form of SIP uri
<para><emphasis>address</emphasis> - The address in form of SIP URI
where to send a duplicate of traced message. This parameter trumps
duplicate_uri and allows tracing to more than one server.
</para>
<para><emphasis>correlation_id</emphasis> - A string with a correlation ID
to be added to the HEP header when using HEPv3.
It's possible to use PVs.
</para>
</listitem>
</itemizedlist>
<para>
Expand All @@ -529,6 +551,8 @@ sip_trace();
...
sip_trace("sip:10.1.1.2:5085");
...
sip_trace("sip:10.1.1.2:5085", "$ci-abc");
...
</programlisting>
</example>
</section>
Expand All @@ -549,7 +573,7 @@ sip_trace("sip:10.1.1.2:5085");
</para>
<para>Parameters: </para>
<itemizedlist>
<listitem><para>on or off: turns on/off SIP message tracing..
<listitem><para>on or off: turns on/off SIP message tracing.
Possible values are:</para>
<itemizedlist>
<listitem><para>on</para></listitem>
Expand Down

0 comments on commit 103e503

Please sign in to comment.