Răsfoiți Sursa

modules:siptrace added HEPv2 protocol.

Alexandr Dubovikov 13 ani în urmă
părinte
comite
dd7028a192

+ 35 - 2
modules_k/siptrace/README

@@ -46,6 +46,8 @@ Daniel-Constantin Mierla
               3.11. xheaders_write (integer)
               3.11. xheaders_write (integer)
               3.12. xheaders_read (integer)
               3.12. xheaders_read (integer)
               3.13. hep_mode_on (integer)
               3.13. hep_mode_on (integer)
+              3.14. hep_version (integer)
+              3.15. hep_capture_id (integer)
 
 
         4. Functions
         4. Functions
 
 
@@ -73,7 +75,9 @@ Daniel-Constantin Mierla
    1.11. Set xheaders_write parameter
    1.11. Set xheaders_write parameter
    1.12. Set xheaders_read parameter
    1.12. Set xheaders_read parameter
    1.13. Set hep_mode_on 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
 Chapter 1. Admin Guide
 
 
@@ -100,6 +104,8 @@ Chapter 1. Admin Guide
         3.11. xheaders_write (integer)
         3.11. xheaders_write (integer)
         3.12. xheaders_read (integer)
         3.12. xheaders_read (integer)
         3.13. hep_mode_on (integer)
         3.13. hep_mode_on (integer)
+        3.14. hep_version (integer)
+        3.15. hep_capture_id (integer)
 
 
    4. Functions
    4. Functions
 
 
@@ -166,6 +172,8 @@ Chapter 1. Admin Guide
    3.11. xheaders_write (integer)
    3.11. xheaders_write (integer)
    3.12. xheaders_read (integer)
    3.12. xheaders_read (integer)
    3.13. hep_mode_on (integer)
    3.13. hep_mode_on (integer)
+   3.14. hep_version (integer)
+   3.15. hep_capture_id (integer)
 
 
 3.1. db_url (str)
 3.1. db_url (str)
 
 
@@ -347,6 +355,31 @@ modparam("siptrace", "xheaders_read", 0)
 modparam("siptrace", "hep_mode_on", 1)
 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. Functions
 
 
    4.1. sip_trace()
    4.1. sip_trace()
@@ -359,7 +392,7 @@ modparam("siptrace", "hep_mode_on", 1)
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
    ONREPLY_ROUTE, BRANCH_ROUTE.
    ONREPLY_ROUTE, BRANCH_ROUTE.
 
 
-   Example 1.14. sip_trace() usage
+   Example 1.16. sip_trace() usage
 ...
 ...
 sip_trace();
 sip_trace();
 ...
 ...

+ 46 - 0
modules_k/siptrace/doc/siptrace_admin.xml

@@ -386,6 +386,52 @@ modparam("siptrace", "hep_mode_on", 1)
 </programlisting>
 </programlisting>
                 </example>
                 </example>
         </section>
         </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>
 	
 	
 	<section>
 	<section>

+ 31 - 2
modules_k/siptrace/siptrace.c

@@ -129,6 +129,9 @@ int trace_sl_acks = 1;
 
 
 int trace_to_database = 1;
 int trace_to_database = 1;
 
 
+int hep_version = 1;
+int hep_capture_id = 1;
+
 int xheaders_write = 0;
 int xheaders_write = 0;
 int xheaders_read = 0;
 int xheaders_read = 0;
 
 
@@ -193,6 +196,8 @@ static param_export_t params[] = {
 	{"xheaders_write",     INT_PARAM, &xheaders_write       },
 	{"xheaders_write",     INT_PARAM, &xheaders_write       },
 	{"xheaders_read",      INT_PARAM, &xheaders_read        },
 	{"xheaders_read",      INT_PARAM, &xheaders_read        },
 	{"hep_mode_on",        INT_PARAM, &hep_mode_on          },	 
 	{"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}
 	{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));
 	trace_on_flag = (int*)shm_malloc(sizeof(int));
 	if(trace_on_flag==NULL) {
 	if(trace_on_flag==NULL) {
 		LM_ERR("no more shm memory left\n");
 		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;
 	unsigned int len, buflen, proto;
 	struct hep_hdr hdr;
 	struct hep_hdr hdr;
 	struct hep_iphdr hep_ipheader;
 	struct hep_iphdr hep_ipheader;
+	struct hep_timehdr hep_time;
+	struct timeval tvb;
+	struct timezone tz;
+	                 
 #if USE_IPV6
 #if USE_IPV6
 	struct hep_ip6hdr hep_ip6header;
 	struct hep_ip6hdr hep_ip6header;
 #endif
 #endif
@@ -1469,6 +1485,9 @@ static int trace_send_hep_duplicate(str *body, str *from, str *to)
 		return 0;
 		return 0;
 
 
 
 
+        gettimeofday( &tvb, &tz );
+        
+
 	/* message length */
 	/* message length */
 	len = body->len 
 	len = body->len 
 #if USE_IPV6
 #if USE_IPV6
@@ -1476,7 +1495,7 @@ static int trace_send_hep_duplicate(str *body, str *from, str *to)
 #else
 #else
 		+ sizeof(struct hep_iphdr)          
 		+ sizeof(struct hep_iphdr)          
 #endif
 #endif
-		+ sizeof(struct hep_hdr);
+		+ sizeof(struct hep_hdr) + sizeof(struct hep_timehdr);;
 
 
 
 
 	/* The packet is too big for us */
 	/* 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 */
 	/* Version && proto && length */
 	hdr.hp_l = sizeof(struct hep_hdr);
 	hdr.hp_l = sizeof(struct hep_hdr);
-	hdr.hp_v = 1;
+	hdr.hp_v = hep_version;
 	hdr.hp_p = proto;
 	hdr.hp_p = proto;
 
 
 	/* AND the last */
 	/* AND the last */
@@ -1580,6 +1599,16 @@ static int trace_send_hep_duplicate(str *body, str *from, str *to)
 	}
 	}
 #endif /* USE_IPV6 */
 #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 */
 	/* PAYLOAD */
 	memcpy((void*)(buffer + buflen) , (void*)body->s, body->len);
 	memcpy((void*)(buffer + buflen) , (void*)body->s, body->len);
 	buflen +=body->len;
 	buflen +=body->len;