[sr-dev] git:master: modules:siptrace added HEPv2 protocol.

Alexandr Dubovikov alexandr.dubovikov at gmail.com
Fri Feb 3 15:37:34 CET 2012


Module: sip-router
Branch: master
Commit: dd7028a192333f313e7a4c4f84376c15ee65955a
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=dd7028a192333f313e7a4c4f84376c15ee65955a

Author: Alexandr Dubovikov <alexandr.dubovikov at gmail.com>
Committer: Alexandr Dubovikov <alexandr.dubovikov at gmail.com>
Date:   Fri Feb  3 15:37:07 2012 +0100

modules:siptrace  added HEPv2 protocol.

---

 modules_k/siptrace/README                 |   37 ++++++++++++++++++++++-
 modules_k/siptrace/doc/siptrace_admin.xml |   46 +++++++++++++++++++++++++++++
 modules_k/siptrace/siptrace.c             |   33 +++++++++++++++++++-
 3 files changed, 112 insertions(+), 4 deletions(-)

diff --git a/modules_k/siptrace/README b/modules_k/siptrace/README
index 3baa6ae..7934f24 100644
--- a/modules_k/siptrace/README
+++ b/modules_k/siptrace/README
@@ -46,6 +46,8 @@ Daniel-Constantin Mierla
               3.11. xheaders_write (integer)
               3.12. xheaders_read (integer)
               3.13. hep_mode_on (integer)
+              3.14. hep_version (integer)
+              3.15. hep_capture_id (integer)
 
         4. Functions
 
@@ -73,7 +75,9 @@ Daniel-Constantin Mierla
    1.11. Set xheaders_write parameter
    1.12. Set xheaders_read parameter
    1.13. Set hep_mode_on parameter
-   1.14. sip_trace() usage
+   1.14. Set hep_version parameter
+   1.15. Set hep_capture_id parameter
+   1.16. sip_trace() usage
 
 Chapter 1. Admin Guide
 
@@ -100,6 +104,8 @@ Chapter 1. Admin Guide
         3.11. xheaders_write (integer)
         3.12. xheaders_read (integer)
         3.13. hep_mode_on (integer)
+        3.14. hep_version (integer)
+        3.15. hep_capture_id (integer)
 
    4. Functions
 
@@ -166,6 +172,8 @@ Chapter 1. Admin Guide
    3.11. xheaders_write (integer)
    3.12. xheaders_read (integer)
    3.13. hep_mode_on (integer)
+   3.14. hep_version (integer)
+   3.15. hep_capture_id (integer)
 
 3.1. db_url (str)
 
@@ -347,6 +355,31 @@ modparam("siptrace", "xheaders_read", 0)
 modparam("siptrace", "hep_mode_on", 1)
 ...
 
+3.14. hep_version (integer)
+
+   The parameter indicate the version of HEP protocol. Can be 1 or 2. In
+   HEPv2 the timestamp and capture agent ID will be included to HEP
+   header.
+
+   Default value is "1".
+
+   Example 1.14. Set hep_version parameter
+...
+modparam("siptrace", "hep_version", 2)
+...
+
+3.15. hep_capture_id (integer)
+
+   The parameter indicate the capture agent ID for HEPv2 protocol.
+   Limitation: 16-bit integer.
+
+   Default value is "1".
+
+   Example 1.15. Set hep_capture_id parameter
+...
+modparam("siptrace", "hep_capture_id", 234)
+...
+
 4. Functions
 
    4.1. sip_trace()
@@ -359,7 +392,7 @@ modparam("siptrace", "hep_mode_on", 1)
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
    ONREPLY_ROUTE, BRANCH_ROUTE.
 
-   Example 1.14. sip_trace() usage
+   Example 1.16. sip_trace() usage
 ...
 sip_trace();
 ...
diff --git a/modules_k/siptrace/doc/siptrace_admin.xml b/modules_k/siptrace/doc/siptrace_admin.xml
index 6f452d6..e6492e0 100644
--- a/modules_k/siptrace/doc/siptrace_admin.xml
+++ b/modules_k/siptrace/doc/siptrace_admin.xml
@@ -386,6 +386,52 @@ modparam("siptrace", "hep_mode_on", 1)
 </programlisting>
                 </example>
         </section>
+        
+        <section>
+                <title><varname>hep_version</varname> (integer)</title>
+                <para>
+                The parameter indicate the version of HEP protocol.
+                Can be 1 or 2. In HEPv2 the timestamp and capture agent ID
+                will
+                be included to HEP header.
+                </para>
+                <para>
+                <emphasis>
+                        Default value is "1".
+                </emphasis>
+                </para>
+                <example>
+                <title>Set <varname>hep_version</varname> parameter</title>
+                <programlisting format="linespecific">
+...
+modparam("siptrace", "hep_version", 2)
+...
+</programlisting>
+                </example>
+        </section>
+        <section>
+                <title><varname>hep_capture_id</varname> (integer)</title>
+                <para>
+                The parameter indicate the capture agent ID for HEPv2
+                protocol.
+                Limitation: 16-bit integer.
+                </para>
+                <para>
+                <emphasis>
+                        Default value is "1".
+                </emphasis>
+                </para>
+                <example>
+                <title>Set <varname>hep_capture_id</varname>
+                parameter</title>
+                <programlisting format="linespecific">
+...
+modparam("siptrace", "hep_capture_id", 234)
+...
+</programlisting>
+                </example>
+        </section>
+
 	</section>
 	
 	<section>
diff --git a/modules_k/siptrace/siptrace.c b/modules_k/siptrace/siptrace.c
index d845ae8..d85b4aa 100644
--- a/modules_k/siptrace/siptrace.c
+++ b/modules_k/siptrace/siptrace.c
@@ -129,6 +129,9 @@ int trace_sl_acks = 1;
 
 int trace_to_database = 1;
 
+int hep_version = 1;
+int hep_capture_id = 1;
+
 int xheaders_write = 0;
 int xheaders_read = 0;
 
@@ -193,6 +196,8 @@ static param_export_t params[] = {
 	{"xheaders_write",     INT_PARAM, &xheaders_write       },
 	{"xheaders_read",      INT_PARAM, &xheaders_read        },
 	{"hep_mode_on",        INT_PARAM, &hep_mode_on          },	 
+	{"hep_version",        INT_PARAM, &hep_version          },
+        {"hep_capture_id",     INT_PARAM, &hep_capture_id       },	        
 	{0, 0, 0}
 };
 
@@ -309,6 +314,13 @@ static int mod_init(void)
 		}
 	}
 
+        if(hep_version != 1 && hep_version != 2) {
+  
+                  LM_ERR("unsupported version of HEP");
+                  return -1;
+        }                                          
+
+
 	trace_on_flag = (int*)shm_malloc(sizeof(int));
 	if(trace_on_flag==NULL) {
 		LM_ERR("no more shm memory left\n");
@@ -1458,6 +1470,10 @@ static int trace_send_hep_duplicate(str *body, str *from, str *to)
 	unsigned int len, buflen, proto;
 	struct hep_hdr hdr;
 	struct hep_iphdr hep_ipheader;
+	struct hep_timehdr hep_time;
+	struct timeval tvb;
+	struct timezone tz;
+	                 
 #if USE_IPV6
 	struct hep_ip6hdr hep_ip6header;
 #endif
@@ -1469,6 +1485,9 @@ static int trace_send_hep_duplicate(str *body, str *from, str *to)
 		return 0;
 
 
+        gettimeofday( &tvb, &tz );
+        
+
 	/* message length */
 	len = body->len 
 #if USE_IPV6
@@ -1476,7 +1495,7 @@ static int trace_send_hep_duplicate(str *body, str *from, str *to)
 #else
 		+ sizeof(struct hep_iphdr)          
 #endif
-		+ sizeof(struct hep_hdr);
+		+ sizeof(struct hep_hdr) + sizeof(struct hep_timehdr);;
 
 
 	/* The packet is too big for us */
@@ -1517,7 +1536,7 @@ static int trace_send_hep_duplicate(str *body, str *from, str *to)
 
 	/* Version && proto && length */
 	hdr.hp_l = sizeof(struct hep_hdr);
-	hdr.hp_v = 1;
+	hdr.hp_v = hep_version;
 	hdr.hp_p = proto;
 
 	/* AND the last */
@@ -1580,6 +1599,16 @@ static int trace_send_hep_duplicate(str *body, str *from, str *to)
 	}
 #endif /* USE_IPV6 */
 
+	if(hep_version == 2) {
+
+                hep_time.tv_sec = tvb.tv_sec;
+                hep_time.tv_usec = tvb.tv_usec;
+                hep_time.captid = hep_capture_id;
+
+                memcpy((void*)buffer+buflen, &hep_time, sizeof(struct hep_timehdr));
+                buflen += sizeof(struct hep_timehdr);
+        }
+
 	/* PAYLOAD */
 	memcpy((void*)(buffer + buflen) , (void*)body->s, body->len);
 	buflen +=body->len;




More information about the sr-dev mailing list