forked from osmocom/wireshark
Put various epoch time deltas into wsutil/epochs.h.
There are some deltas between the UN*X epoch and other epochs that are used in a number of places; put them into a header. Change-Id: Ia2d9d69b9d91352d730d97d9e4897518635b4861 Reviewed-on: https://code.wireshark.org/review/35895 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
d44c5e45cb
commit
a152e041fa
|
@ -1044,7 +1044,7 @@ SystemInformationBlockType16-r11/timeInfo-r11/localTimeOffset-r11 DISPLAY=BASE_C
|
|||
|
||||
#.FN_FTR SystemInformationBlockType16-r11/timeInfo-r11/timeInfoUTC-r11
|
||||
subtree = proto_item_add_subtree(actx->created_item, ett_lte_rrc_timeInfo);
|
||||
ts.secs = (time_t)(timeInfo/100)-2208988800U; /* epoch is 00:00:00 (midnight) UTC on 1900-01-01 */
|
||||
ts.secs = (time_t)(timeInfo/100)-EPOCH_DELTA_1900_01_01_00_00_00_UTC; /* epoch is 00:00:00 (midnight) UTC on 1900-01-01 */
|
||||
ts.nsecs = (int)(timeInfo%100)*10000000;
|
||||
proto_tree_add_time(subtree, hf_lte_rrc_utc_time, tvb, old_offset>>3, (old_offset&0x07) ? 6 : 5, &ts);
|
||||
proto_tree_add_time(subtree, hf_lte_rrc_local_time, tvb, old_offset>>3, (old_offset&0x07) ? 6 : 5, &ts);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <epan/proto_data.h>
|
||||
|
||||
#include <wsutil/str_util.h>
|
||||
#include <wsutil/epochs.h>
|
||||
|
||||
#include "packet-per.h"
|
||||
#include "packet-rrc.h"
|
||||
|
|
|
@ -702,7 +702,7 @@ SIB8/messageIdentifier TYPE=FT_UINT16 DISPLAY=BASE_DEC|BASE_EXT_STRING STRINGS=&
|
|||
|
||||
#.FN_FTR SIB9/timeInfo/timeInfoUTC
|
||||
subtree = proto_item_add_subtree(actx->created_item, ett_nr_rrc_timeInfo);
|
||||
ts.secs = (time_t)(timeInfo/100)-2208988800U; /* epoch is 00:00:00 (midnight) UTC on 1900-01-01 */
|
||||
ts.secs = (time_t)(timeInfo/100)-EPOCH_DELTA_1900_01_01_00_00_00_UTC; /* epoch is 00:00:00 (midnight) UTC on 1900-01-01 */
|
||||
ts.nsecs = (int)(timeInfo%100)*10000000;
|
||||
proto_tree_add_time(subtree, hf_nr_rrc_utc_time, tvb, old_offset>>3, (old_offset&0x07) ? 6 : 5, &ts);
|
||||
proto_tree_add_time(subtree, hf_nr_rrc_local_time, tvb, old_offset>>3, (old_offset&0x07) ? 6 : 5, &ts);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <epan/proto_data.h>
|
||||
|
||||
#include <wsutil/str_util.h>
|
||||
#include <wsutil/epochs.h>
|
||||
|
||||
#include "packet-per.h"
|
||||
#include "packet-gsm_map.h"
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <epan/proto_data.h>
|
||||
|
||||
#include <wsutil/str_util.h>
|
||||
#include <wsutil/epochs.h>
|
||||
|
||||
#include "packet-per.h"
|
||||
#include "packet-rrc.h"
|
||||
|
@ -293,7 +294,7 @@ typedef enum _SI_OrPSI_GERAN_enum {
|
|||
} SI_OrPSI_GERAN_enum;
|
||||
|
||||
/*--- End of included file: packet-lte-rrc-val.h ---*/
|
||||
#line 73 "./asn1/lte-rrc/packet-lte-rrc-template.c"
|
||||
#line 74 "./asn1/lte-rrc/packet-lte-rrc-template.c"
|
||||
|
||||
/* Initialize the protocol and registered fields */
|
||||
static int proto_lte_rrc = -1;
|
||||
|
@ -7646,7 +7647,7 @@ static int hf_lte_rrc_carrierFreq_r14 = -1; /* CarrierFreq_NB_r13 */
|
|||
static int dummy_hf_lte_rrc_eag_field = -1; /* never registered */
|
||||
|
||||
/*--- End of included file: packet-lte-rrc-hf.c ---*/
|
||||
#line 78 "./asn1/lte-rrc/packet-lte-rrc-template.c"
|
||||
#line 79 "./asn1/lte-rrc/packet-lte-rrc-template.c"
|
||||
|
||||
static int hf_lte_rrc_eutra_cap_feat_group_ind_1 = -1;
|
||||
static int hf_lte_rrc_eutra_cap_feat_group_ind_2 = -1;
|
||||
|
@ -11138,7 +11139,7 @@ static gint ett_lte_rrc_SCPTM_NeighbourCellList_NB_r14 = -1;
|
|||
static gint ett_lte_rrc_PCI_ARFCN_NB_r14 = -1;
|
||||
|
||||
/*--- End of included file: packet-lte-rrc-ett.c ---*/
|
||||
#line 272 "./asn1/lte-rrc/packet-lte-rrc-template.c"
|
||||
#line 273 "./asn1/lte-rrc/packet-lte-rrc-template.c"
|
||||
|
||||
static gint ett_lte_rrc_featureGroupIndicators = -1;
|
||||
static gint ett_lte_rrc_featureGroupIndRel9Add = -1;
|
||||
|
@ -59835,7 +59836,7 @@ dissect_lte_rrc_T_timeInfoUTC_r11(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t
|
|||
|
||||
|
||||
subtree = proto_item_add_subtree(actx->created_item, ett_lte_rrc_timeInfo);
|
||||
ts.secs = (time_t)(timeInfo/100)-2208988800U; /* epoch is 00:00:00 (midnight) UTC on 1900-01-01 */
|
||||
ts.secs = (time_t)(timeInfo/100)-EPOCH_DELTA_1900_01_01_00_00_00_UTC; /* epoch is 00:00:00 (midnight) UTC on 1900-01-01 */
|
||||
ts.nsecs = (int)(timeInfo%100)*10000000;
|
||||
proto_tree_add_time(subtree, hf_lte_rrc_utc_time, tvb, old_offset>>3, (old_offset&0x07) ? 6 : 5, &ts);
|
||||
proto_tree_add_time(subtree, hf_lte_rrc_local_time, tvb, old_offset>>3, (old_offset&0x07) ? 6 : 5, &ts);
|
||||
|
@ -111653,7 +111654,7 @@ static int dissect_UE_RadioPagingInfo_NB_r13_PDU(tvbuff_t *tvb _U_, packet_info
|
|||
|
||||
|
||||
/*--- End of included file: packet-lte-rrc-fn.c ---*/
|
||||
#line 3182 "./asn1/lte-rrc/packet-lte-rrc-template.c"
|
||||
#line 3183 "./asn1/lte-rrc/packet-lte-rrc-template.c"
|
||||
|
||||
static int
|
||||
dissect_lte_rrc_DL_CCCH(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
||||
|
@ -141401,7 +141402,7 @@ void proto_register_lte_rrc(void) {
|
|||
"CarrierFreq_NB_r13", HFILL }},
|
||||
|
||||
/*--- End of included file: packet-lte-rrc-hfarr.c ---*/
|
||||
#line 3557 "./asn1/lte-rrc/packet-lte-rrc-template.c"
|
||||
#line 3558 "./asn1/lte-rrc/packet-lte-rrc-template.c"
|
||||
|
||||
{ &hf_lte_rrc_eutra_cap_feat_group_ind_1,
|
||||
{ "Indicator 1", "lte-rrc.eutra_cap_feat_group_ind_1",
|
||||
|
@ -145458,7 +145459,7 @@ void proto_register_lte_rrc(void) {
|
|||
&ett_lte_rrc_PCI_ARFCN_NB_r14,
|
||||
|
||||
/*--- End of included file: packet-lte-rrc-ettarr.c ---*/
|
||||
#line 4316 "./asn1/lte-rrc/packet-lte-rrc-template.c"
|
||||
#line 4317 "./asn1/lte-rrc/packet-lte-rrc-template.c"
|
||||
|
||||
&ett_lte_rrc_featureGroupIndicators,
|
||||
&ett_lte_rrc_featureGroupIndRel9Add,
|
||||
|
@ -145592,7 +145593,7 @@ void proto_register_lte_rrc(void) {
|
|||
|
||||
|
||||
/*--- End of included file: packet-lte-rrc-dis-reg.c ---*/
|
||||
#line 4411 "./asn1/lte-rrc/packet-lte-rrc-template.c"
|
||||
#line 4412 "./asn1/lte-rrc/packet-lte-rrc-template.c"
|
||||
|
||||
lte_rrc_etws_cmas_dcs_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal);
|
||||
lte_rrc_system_info_value_changed_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal);
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <epan/proto_data.h>
|
||||
|
||||
#include <wsutil/str_util.h>
|
||||
#include <wsutil/epochs.h>
|
||||
|
||||
#include "packet-per.h"
|
||||
#include "packet-gsm_map.h"
|
||||
|
@ -245,7 +246,7 @@ typedef enum _T_targetRAT_Type_enum {
|
|||
} T_targetRAT_Type_enum;
|
||||
|
||||
/*--- End of included file: packet-nr-rrc-val.h ---*/
|
||||
#line 58 "./asn1/nr-rrc/packet-nr-rrc-template.c"
|
||||
#line 59 "./asn1/nr-rrc/packet-nr-rrc-template.c"
|
||||
|
||||
/* Initialize the protocol and registered fields */
|
||||
static int proto_nr_rrc = -1;
|
||||
|
@ -3254,7 +3255,7 @@ static int hf_nr_rrc_overheatingIndicationProhibitTimer = -1; /* T_overheatingI
|
|||
static int dummy_hf_nr_rrc_eag_field = -1; /* never registered */
|
||||
|
||||
/*--- End of included file: packet-nr-rrc-hf.c ---*/
|
||||
#line 62 "./asn1/nr-rrc/packet-nr-rrc-template.c"
|
||||
#line 63 "./asn1/nr-rrc/packet-nr-rrc-template.c"
|
||||
static int hf_nr_rrc_serialNumber_gs = -1;
|
||||
static int hf_nr_rrc_serialNumber_msg_code = -1;
|
||||
static int hf_nr_rrc_serialNumber_upd_nb = -1;
|
||||
|
@ -4530,7 +4531,7 @@ static gint ett_nr_rrc_T_overheatingAssistanceConfig = -1;
|
|||
static gint ett_nr_rrc_OverheatingAssistanceConfig = -1;
|
||||
|
||||
/*--- End of included file: packet-nr-rrc-ett.c ---*/
|
||||
#line 98 "./asn1/nr-rrc/packet-nr-rrc-template.c"
|
||||
#line 99 "./asn1/nr-rrc/packet-nr-rrc-template.c"
|
||||
static gint ett_nr_rrc_DedicatedNAS_Message = -1;
|
||||
static gint ett_rr_rrc_targetRAT_MessageContainer = -1;
|
||||
static gint ett_nr_rrc_nas_Container = -1;
|
||||
|
@ -11254,7 +11255,7 @@ dissect_nr_rrc_T_timeInfoUTC(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx
|
|||
|
||||
|
||||
subtree = proto_item_add_subtree(actx->created_item, ett_nr_rrc_timeInfo);
|
||||
ts.secs = (time_t)(timeInfo/100)-2208988800U; /* epoch is 00:00:00 (midnight) UTC on 1900-01-01 */
|
||||
ts.secs = (time_t)(timeInfo/100)-EPOCH_DELTA_1900_01_01_00_00_00_UTC; /* epoch is 00:00:00 (midnight) UTC on 1900-01-01 */
|
||||
ts.nsecs = (int)(timeInfo%100)*10000000;
|
||||
proto_tree_add_time(subtree, hf_nr_rrc_utc_time, tvb, old_offset>>3, (old_offset&0x07) ? 6 : 5, &ts);
|
||||
proto_tree_add_time(subtree, hf_nr_rrc_local_time, tvb, old_offset>>3, (old_offset&0x07) ? 6 : 5, &ts);
|
||||
|
@ -44429,7 +44430,7 @@ static int dissect_UECapabilityEnquiry_v1560_IEs_PDU(tvbuff_t *tvb _U_, packet_i
|
|||
|
||||
|
||||
/*--- End of included file: packet-nr-rrc-fn.c ---*/
|
||||
#line 380 "./asn1/nr-rrc/packet-nr-rrc-template.c"
|
||||
#line 381 "./asn1/nr-rrc/packet-nr-rrc-template.c"
|
||||
|
||||
void
|
||||
proto_register_nr_rrc(void) {
|
||||
|
@ -56438,7 +56439,7 @@ proto_register_nr_rrc(void) {
|
|||
NULL, HFILL }},
|
||||
|
||||
/*--- End of included file: packet-nr-rrc-hfarr.c ---*/
|
||||
#line 388 "./asn1/nr-rrc/packet-nr-rrc-template.c"
|
||||
#line 389 "./asn1/nr-rrc/packet-nr-rrc-template.c"
|
||||
|
||||
{ &hf_nr_rrc_serialNumber_gs,
|
||||
{ "Geographical Scope", "nr-rrc.serialNumber.gs",
|
||||
|
@ -57812,7 +57813,7 @@ proto_register_nr_rrc(void) {
|
|||
&ett_nr_rrc_OverheatingAssistanceConfig,
|
||||
|
||||
/*--- End of included file: packet-nr-rrc-ettarr.c ---*/
|
||||
#line 522 "./asn1/nr-rrc/packet-nr-rrc-template.c"
|
||||
#line 523 "./asn1/nr-rrc/packet-nr-rrc-template.c"
|
||||
&ett_nr_rrc_DedicatedNAS_Message,
|
||||
&ett_rr_rrc_targetRAT_MessageContainer,
|
||||
&ett_nr_rrc_nas_Container,
|
||||
|
@ -57874,7 +57875,7 @@ proto_register_nr_rrc(void) {
|
|||
|
||||
|
||||
/*--- End of included file: packet-nr-rrc-dis-reg.c ---*/
|
||||
#line 565 "./asn1/nr-rrc/packet-nr-rrc-template.c"
|
||||
#line 566 "./asn1/nr-rrc/packet-nr-rrc-template.c"
|
||||
|
||||
nr_rrc_etws_cmas_dcs_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(),
|
||||
g_direct_hash, g_direct_equal);
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include <epan/tvbparse.h>
|
||||
#include <epan/conversation.h>
|
||||
|
||||
#include <wsutil/epochs.h>
|
||||
|
||||
#include "packet-ntp.h"
|
||||
|
||||
void proto_register_ntp(void);
|
||||
|
@ -1011,8 +1013,11 @@ static const int *ntppriv_reset_stats_flags[] = {
|
|||
static tvbparse_wanted_t *want;
|
||||
static tvbparse_wanted_t *want_ignore;
|
||||
|
||||
/* NTP_BASETIME is in fact epoch - ntp_start_time */
|
||||
#define NTP_BASETIME 2208988800u
|
||||
/*
|
||||
* NTP_BASETIME is in fact epoch - ntp_start_time; ntp_start_time
|
||||
* is January 1, 2036, 00:00:00 UTC.
|
||||
*/
|
||||
#define NTP_BASETIME EPOCH_DELTA_1900_01_01_00_00_00_UTC
|
||||
#define NTP_FLOAT_DENOM 4294967296.0
|
||||
#define NTP_TS_SIZE 100
|
||||
|
||||
|
|
|
@ -143,6 +143,8 @@
|
|||
#include <epan/expert.h>
|
||||
#include <epan/proto_data.h>
|
||||
|
||||
#include <wsutil/epochs.h>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "packet-tcp.h"
|
||||
|
@ -2030,7 +2032,7 @@ handle_tds_sql_datetime(tvbuff_t *tvb, guint offset, proto_tree *sub_tree, tds_c
|
|||
days = threehndths = 0;
|
||||
}
|
||||
|
||||
tv.secs = (time_t)((days * G_GUINT64_CONSTANT(86400)) + (threehndths/300) - G_GUINT64_CONSTANT(2208988800)); /* 2208988800 - seconds between Jan 1, 1900 and Jan 1, 1970 */
|
||||
tv.secs = (time_t)((days * G_GUINT64_CONSTANT(86400)) + (threehndths/300) - EPOCH_DELTA_1900_01_01_00_00_00_UTC); /* seconds between Jan 1, 1900 and Jan 1, 1970 */
|
||||
tv.nsecs = (int)((threehndths%300) * 10000000 / 3);
|
||||
proto_tree_add_time(sub_tree, hf_tds_type_varbyte_data_absdatetime, tvb, offset, 8, &tv);
|
||||
}
|
||||
|
@ -2058,7 +2060,7 @@ handle_tds_sql_smalldatetime(tvbuff_t *tvb, guint offset, proto_tree *sub_tree,
|
|||
}
|
||||
|
||||
|
||||
tv.secs = (time_t)((days * G_GUINT64_CONSTANT(86400)) + (minutes * 60) - G_GUINT64_CONSTANT(2208988800)); /* 2208988800 - seconds between Jan 1, 1900 and Jan 1, 1970 */
|
||||
tv.secs = (time_t)((days * G_GUINT64_CONSTANT(86400)) + (minutes * 60) - EPOCH_DELTA_1900_01_01_00_00_00_UTC); /* seconds between Jan 1, 1900 and Jan 1, 1970 */
|
||||
tv.nsecs = 0;
|
||||
proto_tree_add_time(sub_tree, hf_tds_type_varbyte_data_absdatetime, tvb, offset, 8, &tv);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include <epan/prefs.h>
|
||||
#include <epan/to_str.h>
|
||||
|
||||
#include <wsutil/epochs.h>
|
||||
|
||||
void proto_reg_handoff_time(void);
|
||||
void proto_register_time(void);
|
||||
|
||||
|
@ -63,7 +65,7 @@ dissect_time(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
|
|||
guint32 delta_seconds = tvb_get_ntohl(tvb, 0);
|
||||
proto_tree_add_uint_format(time_tree, hf_time_time, tvb, 0, 4,
|
||||
delta_seconds, "%s",
|
||||
abs_time_secs_to_str(wmem_packet_scope(), delta_seconds-2208988800U,
|
||||
abs_time_secs_to_str(wmem_packet_scope(), delta_seconds-EPOCH_DELTA_1900_01_01_00_00_00_UTC,
|
||||
(absolute_time_display_e)time_display_type, TRUE));
|
||||
}
|
||||
return tvb_captured_length(tvb);
|
||||
|
|
30
epan/proto.c
30
epan/proto.c
|
@ -47,6 +47,7 @@
|
|||
|
||||
#include <wsutil/ws_printf.h> /* ws_debug_printf */
|
||||
#include <wsutil/crash_info.h>
|
||||
#include <wsutil/epochs.h>
|
||||
|
||||
/* Ptvcursor limits */
|
||||
#define SUBTREE_ONCE_ALLOCATION_NUMBER 8
|
||||
|
@ -1782,6 +1783,8 @@ get_stringzpad_value(wmem_allocator_t *scope, tvbuff_t *tvb, gint start,
|
|||
|
||||
/*
|
||||
* NTP Era 0: the epoch is January 1, 1900, 00:00:00 (proleptic?) UTC.
|
||||
* XXX - if it's OK if this is unsigned, can we just use
|
||||
* EPOCH_DELTA_1900_01_01_00_00_00_UTC?
|
||||
*/
|
||||
#define NTP_TIMEDIFF1900TO1970SEC G_GINT64_CONSTANT(2208988800)
|
||||
|
||||
|
@ -1790,17 +1793,6 @@ get_stringzpad_value(wmem_allocator_t *scope, tvbuff_t *tvb, gint start,
|
|||
*/
|
||||
#define NTP_TIMEDIFF1970TO2036SEC G_GINT64_CONSTANT(2085978496)
|
||||
|
||||
/*
|
||||
* System/370, System/390, and z/Architecture TOD clock: the epoch
|
||||
* is January 1, 1900, 00:00:00 (proleptic?) UTC.
|
||||
*/
|
||||
#define TOD_BASETIME G_GUINT64_CONSTANT(2208988800)
|
||||
|
||||
/*
|
||||
* Classic Mac OS: the epoch is January 1, 1904, 00:00:00 (proleptic?) UTC.
|
||||
*/
|
||||
#define CLASSIC_MAC_OS_BASETIME G_GUINT64_CONSTANT(2082844800)
|
||||
|
||||
/* this can be called when there is no tree, so tree may be null */
|
||||
static void
|
||||
get_time_value(proto_tree *tree, tvbuff_t *tvb, const gint start,
|
||||
|
@ -1996,7 +1988,9 @@ get_time_value(proto_tree *tree, tvbuff_t *tvb, const gint start,
|
|||
case ENC_TIME_TOD|ENC_BIG_ENDIAN:
|
||||
/*
|
||||
* S/3x0 and z/Architecture TOD clock time stamp,
|
||||
* big-endian.
|
||||
* big-endian. The epoch is January 1, 1900,
|
||||
* 00:00:00 (proleptic?) UTC.
|
||||
*
|
||||
* Only supported for absolute times.
|
||||
*/
|
||||
DISSECTOR_ASSERT(!is_relative);
|
||||
|
@ -2004,7 +1998,7 @@ get_time_value(proto_tree *tree, tvbuff_t *tvb, const gint start,
|
|||
|
||||
if (length == 8) {
|
||||
todusecs = tvb_get_ntoh64(tvb, start) >> 12;
|
||||
time_stamp->secs = (time_t)((todusecs / 1000000) - TOD_BASETIME);
|
||||
time_stamp->secs = (time_t)((todusecs / 1000000) - EPOCH_DELTA_1900_01_01_00_00_00_UTC);
|
||||
time_stamp->nsecs = (int)((todusecs % 1000000) * 1000);
|
||||
} else {
|
||||
time_stamp->secs = 0;
|
||||
|
@ -2016,14 +2010,16 @@ get_time_value(proto_tree *tree, tvbuff_t *tvb, const gint start,
|
|||
case ENC_TIME_TOD|ENC_LITTLE_ENDIAN:
|
||||
/*
|
||||
* S/3x0 and z/Architecture TOD clock time stamp,
|
||||
* little-endian.
|
||||
* little-endian. The epoch is January 1, 1900,
|
||||
* 00:00:00 (proleptic?) UTC.
|
||||
*
|
||||
* Only supported for absolute times.
|
||||
*/
|
||||
DISSECTOR_ASSERT(!is_relative);
|
||||
|
||||
if (length == 8) {
|
||||
todusecs = tvb_get_letoh64(tvb, start) >> 12 ;
|
||||
time_stamp->secs = (time_t)((todusecs / 1000000) - TOD_BASETIME);
|
||||
time_stamp->secs = (time_t)((todusecs / 1000000) - EPOCH_DELTA_1900_01_01_00_00_00_UTC);
|
||||
time_stamp->nsecs = (int)((todusecs % 1000000) * 1000);
|
||||
} else {
|
||||
time_stamp->secs = 0;
|
||||
|
@ -2358,11 +2354,11 @@ get_time_value(proto_tree *tree, tvbuff_t *tvb, const gint start,
|
|||
|
||||
if (length == 8) {
|
||||
tmp64secs = tvb_get_ntoh64(tvb, start);
|
||||
time_stamp->secs = (time_t)(tmp64secs - CLASSIC_MAC_OS_BASETIME);
|
||||
time_stamp->secs = (time_t)(tmp64secs - EPOCH_DELTA_1904_01_01_00_00_00_UTC);
|
||||
time_stamp->nsecs = 0;
|
||||
} else if (length == 4) {
|
||||
tmpsecs = tvb_get_ntohl(tvb, start);
|
||||
time_stamp->secs = (time_t)(tmpsecs - CLASSIC_MAC_OS_BASETIME);
|
||||
time_stamp->secs = (time_t)(tmpsecs - EPOCH_DELTA_1904_01_01_00_00_00_UTC);
|
||||
time_stamp->nsecs = 0;
|
||||
} else {
|
||||
time_stamp->secs = 0;
|
||||
|
|
|
@ -24,9 +24,13 @@
|
|||
#include "config.h"
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <wsutil/epochs.h>
|
||||
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "peekclassic.h"
|
||||
|
||||
/* CREDITS
|
||||
*
|
||||
* This file decoder could not have been writen without examining how
|
||||
|
@ -130,8 +134,6 @@ typedef struct peekclassic_utime {
|
|||
#define STATUS_SLICED 0x20 /* Sliced (cut short by snaplen?) */
|
||||
#define STATUS_HIDDEN 0x80 /* Hidden (in the *Peek GUI?) */
|
||||
|
||||
static const unsigned int mac2unix = 2082844800u;
|
||||
|
||||
typedef struct {
|
||||
time_t reference_time;
|
||||
} peekclassic_t;
|
||||
|
@ -298,7 +300,7 @@ wtap_open_return_val peekclassic_open(wtap *wth, int *err, gchar **err_info)
|
|||
g_ntohl(ep_hdr.secondary.v567.linkSpeed);
|
||||
|
||||
/* Get the reference time as a time_t */
|
||||
reference_time = ep_hdr.secondary.v567.timeDate - mac2unix;
|
||||
reference_time = ep_hdr.secondary.v567.timeDate - EPOCH_DELTA_1904_01_01_00_00_00_UTC;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -436,7 +438,7 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
|
|||
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_PACK_FLAGS;
|
||||
tsecs = (time_t) (timestamp/1000000);
|
||||
tusecs = (guint32) (timestamp - tsecs*1000000);
|
||||
rec->ts.secs = tsecs - mac2unix;
|
||||
rec->ts.secs = tsecs - EPOCH_DELTA_1904_01_01_00_00_00_UTC;
|
||||
rec->ts.nsecs = tusecs * 1000;
|
||||
rec->rec_header.packet_header.len = length;
|
||||
rec->rec_header.packet_header.caplen = sliceLength;
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include <wsutil/epochs.h>
|
||||
|
||||
#include "pcapio.h"
|
||||
|
||||
/* Magic numbers in "libpcap" files.
|
||||
|
@ -655,7 +657,7 @@ pcapng_write_interface_statistics_block(FILE* pfile,
|
|||
* Subtract difference, in microseconds, between January 1, 1601
|
||||
* 00:00:00 UTC and January 1, 1970, 00:00:00 UTC.
|
||||
*/
|
||||
timestamp -= G_GUINT64_CONSTANT(11644473600000000);
|
||||
timestamp -= EPOCH_DELTA_1601_01_01_00_00_00_UTC*1000000;
|
||||
#else
|
||||
/*
|
||||
* Current time, represented as seconds and microseconds since
|
||||
|
|
|
@ -34,6 +34,7 @@ set(WSUTIL_PUBLIC_HEADERS
|
|||
crc32.h
|
||||
curve25519.h
|
||||
eax.h
|
||||
epochs.h
|
||||
filesystem.h
|
||||
frequency-utils.h
|
||||
g711.h
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/* epochs.h
|
||||
* Definitions of epoch values for various absolute time types.
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 2006 Gerald Combs
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef __EPOCHS_H__
|
||||
#define __EPOCHS_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
/*
|
||||
* Deltas between the epochs for various non-UN*X time stamp formats and
|
||||
* the January 1, 1970, 00:00:00 (proleptic?) UTC epoch for the UN*X time
|
||||
* stamp format.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 1900-01-01 00:00:00 (proleptic?) UTC.
|
||||
* Used by a number of time formats.
|
||||
*/
|
||||
#define EPOCH_DELTA_1900_01_01_00_00_00_UTC 2208988800U
|
||||
|
||||
/*
|
||||
* 1904-01-01 00:00:00 (proleptic?) UTC.
|
||||
* Used in the classic Mac OS, and by formats, such as MPEG-4 Part 14 (MP4),
|
||||
* which is based on Apple's QuickTime format.
|
||||
*/
|
||||
#define EPOCH_DELTA_1904_01_01_00_00_00_UTC 2082844800U
|
||||
|
||||
/*
|
||||
* 1601-01-01 (proleptic Gregorian) 00:00:00 (proleptic?) UTC.
|
||||
* The Windows NT epoch, used in a number of places.
|
||||
*
|
||||
* This is
|
||||
*
|
||||
* 369*365.25*24*60*60-(3*24*60*60+6*60*60)
|
||||
*
|
||||
* 1970-1601 is 369; 365.25 is the average length of a year in days,
|
||||
* including leap years.
|
||||
*
|
||||
* 3 days are subtracted because 1700, 1800, and 1900 were not leap
|
||||
* years, as, while they're all evenly divisible by 4, they're also
|
||||
* evently divisible by 100, but not evently divisible by 400, so
|
||||
* we need to compensate for using the average length of a year in
|
||||
* days, which assumes a leap year every 4 years, *including* every
|
||||
* 100 years.
|
||||
*
|
||||
* I'm not sure what the extra 6 hours are that are being subtracted.
|
||||
*/
|
||||
#define EPOCH_DELTA_1601_01_01_00_00_00_UTC G_GUINT64_CONSTANT(11644473600)
|
||||
|
||||
#endif /* __EPOCHS_H__ */
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include "nstime.h"
|
||||
#include "epochs.h"
|
||||
|
||||
/* this is #defined so that we can clearly see that we have the right number of
|
||||
zeros, rather than as a guard against the number of nanoseconds in a second
|
||||
|
@ -182,29 +183,6 @@ double nstime_to_sec(const nstime_t *nstime)
|
|||
* Copyright (C) Andrew Tridgell 1992-1998
|
||||
*/
|
||||
|
||||
/*
|
||||
* Number of seconds between the UN*X epoch (January 1, 1970, 00:00:00 GMT)
|
||||
* and the Windows NT epoch (January 1, 1601 in the proleptic Gregorian
|
||||
* calendar, 00:00:00 "GMT")
|
||||
*
|
||||
* This is
|
||||
*
|
||||
* 369*365.25*24*60*60-(3*24*60*60+6*60*60)
|
||||
*
|
||||
* 1970-1601 is 369; 365.25 is the average length of a year in days,
|
||||
* including leap years.
|
||||
*
|
||||
* 3 days are subtracted because 1700, 1800, and 1900 were not leap
|
||||
* years, as, while they're all evenly divisible by 4, they're also
|
||||
* evently divisible by 100, but not evently divisible by 400, so
|
||||
* we need to compensate for using the average length of a year in
|
||||
* days, which assumes a leap year every 4 years, *including* every
|
||||
* 100 years.
|
||||
*
|
||||
* I'm not sure what the extra 6 hours are that are being subtracted.
|
||||
*/
|
||||
#define TIME_FIXUP_CONSTANT G_GUINT64_CONSTANT(11644473600)
|
||||
|
||||
#ifndef TIME_T_MIN
|
||||
#define TIME_T_MIN ((time_t) ((time_t)0 < (time_t) -1 ? (time_t) 0 \
|
||||
: (time_t) (~0ULL << (sizeof (time_t) * CHAR_BIT - 1))))
|
||||
|
@ -223,11 +201,11 @@ common_filetime_to_nstime(nstime_t *nstime, guint64 ftsecs, int nsecs)
|
|||
* ftsecs's value should fit in a 64-bit signed variable, as
|
||||
* ftsecs is derived from a 64-bit fractions-of-a-second value,
|
||||
* and is far from the maximum 64-bit signed value, and
|
||||
* TIME_FIXUP_CONSTANT is also far from the maximum 64-bit
|
||||
* signed value, so the difference between them should also
|
||||
* fit in a 64-bit signed value.
|
||||
* EPOCH_DELTA_1601_01_01_00_00_00_UTC is also far from the
|
||||
* maximum 64-bit signed value, so the difference between them
|
||||
* should also fit in a 64-bit signed value.
|
||||
*/
|
||||
secs = (gint64)ftsecs - TIME_FIXUP_CONSTANT;
|
||||
secs = (gint64)ftsecs - EPOCH_DELTA_1601_01_01_00_00_00_UTC;
|
||||
|
||||
if (!(TIME_T_MIN <= secs && secs <= TIME_T_MAX)) {
|
||||
/* The result won't fit in a time_t */
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include <wsutil/epochs.h>
|
||||
|
||||
#include "time_util.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
|
@ -147,7 +149,7 @@ create_timestamp(void) {
|
|||
* Subtract difference, in microseconds, between January 1, 1601
|
||||
* 00:00:00 UTC and January 1, 1970, 00:00:00 UTC.
|
||||
*/
|
||||
timestamp -= G_GUINT64_CONSTANT(11644473600000000);
|
||||
timestamp -= EPOCH_DELTA_1601_01_01_00_00_00_UTC*1000000;
|
||||
#else
|
||||
/*
|
||||
* Current time, represented as seconds and microseconds since
|
||||
|
|
Loading…
Reference in New Issue