Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arne Øslebø
mapi
Commits
cbcef1e2
Commit
cbcef1e2
authored
Aug 16, 2006
by
Arne Øslebø
Browse files
improved timestamp conversion
git-svn-id:
file:///home/svn/mapi/trunk@797
8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent
2b637217
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/drivers/mapinicdrv.c
View file @
cbcef1e2
...
...
@@ -166,8 +166,8 @@ process_pkts(void *buf,unsigned len, nic_instance_t *i,MAPI_UNUSED int devid, in
mhdr
.
caplen
=
rec
->
caplen
;
mhdr
.
ifindex
=
0
;
mhdr
.
wlen
=
rec
->
len
;
mhdr
.
ts
=
(((
unsigned
long
long
)
rec
->
ts
.
tv_sec
)
<<
32
)
+
((
rec
->
ts
.
tv_usec
*
4295
)
&
0xffffffff
);
//TODO: Need to check accuracy of timestamp. Rounding errors?
mhdr
.
ts
=
(((
unsigned
long
long
)
rec
->
ts
.
tv_sec
)
<<
32
)
+
(((
rec
->
ts
.
tv_usec
<<
12
)
+
(
rec
->
ts
.
tv_usec
<<
8
)
-
((
rec
->
ts
.
tv_usec
*
1825
)
>>
5
))
&
0xffffffff
);
// increase counter for packets seen so far
i
->
hwinfo
.
pkts
++
;
...
...
@@ -312,8 +312,8 @@ mapidrv_proc_loop (int devid)
// This is only for backward compatibility
mhdr
.
caplen
=
phdr
.
caplen
;
mhdr
.
wlen
=
phdr
.
len
;
mhdr
.
ts
=
(((
unsigned
long
long
)
phdr
.
ts
.
tv_sec
)
<<
32
)
+
((
phdr
.
ts
.
tv_usec
*
4295
)
&
0xffffffff
);
//
mhdr.ts = (((unsigned long long)phdr.ts.tv_sec)<<32)+((phdr.ts.tv_usec*4295) & 0xffffffff);
mhdr
.
ts
=
(((
unsigned
long
long
)
phdr
.
ts
.
tv_sec
)
<<
32
)
+
((((
phdr
.
ts
.
tv_usec
<<
12
)
+
(
phdr
.
ts
.
tv_usec
<<
8
)
-
((
phdr
.
ts
.
tv_usec
*
1825
)
>>
5
)))
&
0xffffffff
);
// increase counter for packets seen so far
i
->
hwinfo
.
pkts
++
;
...
...
src/stdflib/to_tcpdump.c
View file @
cbcef1e2
...
...
@@ -95,6 +95,7 @@ static int to_tcpdump_process(mapidflib_function_instance_t *instance,MAPI_UNUSE
struct
pcap_pkthdr
phdr
;
struct
to_tcpdump_data
*
i
=
instance
->
internal_data
;
int
*
res
=
instance
->
result
.
data
;
unsigned
long
long
ts
;
if
(
i
->
pkts
>=
i
->
maxpkts
&&
i
->
maxpkts
!=
0
)
{
*
res
=
0
;
...
...
@@ -103,8 +104,16 @@ static int to_tcpdump_process(mapidflib_function_instance_t *instance,MAPI_UNUSE
phdr
.
caplen
=
pkthdr
->
caplen
;
phdr
.
len
=
pkthdr
->
wlen
;
phdr
.
ts
.
tv_sec
=
pkthdr
->
ts
>>
32
;
phdr
.
ts
.
tv_usec
=
(
pkthdr
->
ts
&
0xffffffff
)
/
4295
;
ts
=
pkthdr
->
ts
;
phdr
.
ts
.
tv_sec
=
(
long
)(
ts
>>
32
);
ts
=
((
ts
&
0xffffffffULL
)
*
1000
*
1000
);
ts
+=
(
ts
&
0x80000000ULL
)
<<
1
;
/* rounding */
phdr
.
ts
.
tv_usec
=
(
long
)(
ts
>>
32
);
if
(
phdr
.
ts
.
tv_usec
>=
1000000
)
{
phdr
.
ts
.
tv_usec
-=
1000000
;
phdr
.
ts
.
tv_sec
+=
1
;
}
write
(
i
->
file
,
&
phdr
,
sizeof
(
struct
pcap_pkthdr
));
write
(
i
->
file
,
link_pkt
,
pkthdr
->
caplen
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment