Pārlūkot izejas kodu

Merge pull request #698 from sjthomason/sipcapture-timestamp-fix

Sipcapture timestamp fix
Alexandr Dubovikov 9 gadi atpakaļ
vecāks
revīzija
adfce11299
3 mainītis faili ar 11 papildinājumiem un 4 dzēšanām
  1. 2 2
      modules/sipcapture/hep.c
  2. 7 0
      modules/sipcapture/hep.h
  3. 2 2
      modules/siptrace/siptrace.c

+ 2 - 2
modules/sipcapture/hep.c

@@ -176,8 +176,8 @@ int hepv2_received(char *buf, unsigned int len, struct receive_info *ri){
                 hep_offset+=sizeof(struct hep_timehdr);
                 heptime_tmp = (struct hep_timehdr*) hep_payload;
 
-                heptime->tv_sec = heptime_tmp->tv_sec;
-                heptime->tv_usec = heptime_tmp->tv_usec;
+                heptime->tv_sec = to_le(heptime_tmp->tv_sec);
+                heptime->tv_usec = to_le(heptime_tmp->tv_usec);
                 heptime->captid = heptime_tmp->captid;
         }
 

+ 7 - 0
modules/sipcapture/hep.h

@@ -24,6 +24,13 @@
 #ifndef _hep_h
 #define _hep_h
 
+#include "../../endianness.h"
+
+#ifdef __IS_BIG_ENDIAN
+#define to_le(x) bswap32(x)
+#else
+#define to_le(x) (x)
+#endif
 
 #ifdef __OS_solaris
 typedef uint8_t u_int8_t;

+ 2 - 2
modules/siptrace/siptrace.c

@@ -1799,8 +1799,8 @@ static int trace_send_hep_duplicate(str *body, str *from, str *to, struct dest_i
 
 	if(hep_version == 2) {
 
-		hep_time.tv_sec = tvb.tv_sec;
-		hep_time.tv_usec = tvb.tv_usec;
+		hep_time.tv_sec = to_le(tvb.tv_sec);
+		hep_time.tv_usec = to_le(tvb.tv_usec);
 		hep_time.captid = hep_capture_id;
 
 		memcpy((void*)buffer+buflen, &hep_time, sizeof(struct hep_timehdr));