@@ -323,6 +323,8 @@ void callback_proto(unsigned char *arg, struct pcap_pkthdr *pkthdr, unsigned cha
323323 uint8_t ip_proto = 0 , erspan_offset = 0 ;
324324 uint8_t tmp_ip_proto = 0 , tmp_ip_len = 0 , is_only_gre = 0 ;
325325
326+ time_t now = use_current_timestamp ? time (NULL ) : 0 ;
327+
326328 unsigned char * ethaddr = NULL ;
327329 unsigned char * mplsaddr = NULL ;
328330
@@ -449,8 +451,8 @@ void callback_proto(unsigned char *arg, struct pcap_pkthdr *pkthdr, unsigned cha
449451 _msg .rcinfo .ip_family = DLT_MTP2 ;
450452 _msg .rcinfo .ip_proto = DLT_MTP2 ;
451453
452- _msg .rcinfo .time_sec = pkthdr -> ts .tv_sec ;
453- _msg .rcinfo .time_usec = pkthdr -> ts .tv_usec ;
454+ _msg .rcinfo .time_sec = use_current_timestamp ? now : pkthdr -> ts .tv_sec ;
455+ _msg .rcinfo .time_usec = use_current_timestamp ? 0 : pkthdr -> ts .tv_usec ;
454456 _msg .tcpflag = 0 ;
455457 _msg .parse_it = 1 ;
456458
@@ -734,8 +736,8 @@ void callback_proto(unsigned char *arg, struct pcap_pkthdr *pkthdr, unsigned cha
734736 _msg .rcinfo .dst_port = ntohs (tcp_pkt -> th_dport );
735737 _msg .rcinfo .ip_family = ip_ver == 4 ? AF_INET : AF_INET6 ;
736738 _msg .rcinfo .ip_proto = ip_proto ;
737- _msg .rcinfo .time_sec = pkthdr -> ts .tv_sec ;
738- _msg .rcinfo .time_usec = pkthdr -> ts .tv_usec ;
739+ _msg .rcinfo .time_sec = use_current_timestamp ? now : pkthdr -> ts .tv_sec ;
740+ _msg .rcinfo .time_usec = use_current_timestamp ? 0 : pkthdr -> ts .tv_usec ;
739741 _msg .tcpflag = tcp_pkt -> th_flags ;
740742 _msg .parse_it = 1 ;
741743
@@ -800,8 +802,8 @@ void callback_proto(unsigned char *arg, struct pcap_pkthdr *pkthdr, unsigned cha
800802 _msg .rcinfo .dst_port = ntohs (tcp_pkt -> th_dport );
801803 _msg .rcinfo .ip_family = ip_ver == 4 ? AF_INET : AF_INET6 ;
802804 _msg .rcinfo .ip_proto = ip_proto ;
803- _msg .rcinfo .time_sec = pkthdr -> ts .tv_sec ;
804- _msg .rcinfo .time_usec = pkthdr -> ts .tv_usec ;
805+ _msg .rcinfo .time_sec = use_current_timestamp ? now : pkthdr -> ts .tv_sec ;
806+ _msg .rcinfo .time_usec = use_current_timestamp ? 0 : pkthdr -> ts .tv_usec ;
805807 _msg .tcpflag = tcp_pkt -> th_flags ;
806808 _msg .parse_it = 1 ;
807809
@@ -853,8 +855,8 @@ void callback_proto(unsigned char *arg, struct pcap_pkthdr *pkthdr, unsigned cha
853855 _msg .rcinfo .dst_mac = mac_dst ;
854856 _msg .rcinfo .ip_family = ip_ver == 4 ? AF_INET : AF_INET6 ;
855857 _msg .rcinfo .ip_proto = ip_proto ;
856- _msg .rcinfo .time_sec = pkthdr -> ts .tv_sec ;
857- _msg .rcinfo .time_usec = pkthdr -> ts .tv_usec ;
858+ _msg .rcinfo .time_sec = use_current_timestamp ? now : pkthdr -> ts .tv_sec ;
859+ _msg .rcinfo .time_usec = use_current_timestamp ? 0 : pkthdr -> ts .tv_usec ;
858860 _msg .tcpflag = 0 ;
859861 _msg .parse_it = 1 ;
860862
@@ -916,8 +918,8 @@ void callback_proto(unsigned char *arg, struct pcap_pkthdr *pkthdr, unsigned cha
916918 _msg .rcinfo .dst_mac = mac_dst ;
917919 _msg .rcinfo .ip_family = ip_ver == 4 ? AF_INET : AF_INET6 ;
918920 _msg .rcinfo .ip_proto = ip_proto ;
919- _msg .rcinfo .time_sec = pkthdr -> ts .tv_sec ;
920- _msg .rcinfo .time_usec = pkthdr -> ts .tv_usec ;
921+ _msg .rcinfo .time_sec = use_current_timestamp ? now : pkthdr -> ts .tv_sec ;
922+ _msg .rcinfo .time_usec = use_current_timestamp ? 0 : pkthdr -> ts .tv_usec ;
921923 _msg .tcpflag = 0 ;
922924 _msg .parse_it = 1 ;
923925
0 commit comments