Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PPSi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
PPSi
Commits
abcfc9dd
Commit
abcfc9dd
authored
Mar 08, 2012
by
Alessandro Rubini
Committed by
Aurelio Colosimo
Mar 09, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ptpdump: discard duplicates in main loop
parent
15353c45
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
ptpdump.c
tools/ptpdump.c
+10
-10
No files found.
tools/ptpdump.c
View file @
abcfc9dd
...
...
@@ -246,8 +246,6 @@ static int dump_udppkt(void *buf, int len)
struct
udphdr
*
udp
=
(
void
*
)(
ip
+
1
);
void
*
payload
=
(
void
*
)(
udp
+
1
);
int
udpdest
=
ntohs
(
udp
->
dest
);
static
unsigned
char
prev
[
256
];
static
int
prevlen
;
if
(
len
<
ETH_HLEN
+
sizeof
(
*
ip
)
+
sizeof
(
*
udp
))
return
-
1
;
...
...
@@ -257,11 +255,6 @@ static int dump_udppkt(void *buf, int len)
if
(
udpdest
!=
319
&&
udpdest
!=
320
)
return
-
1
;
/* for some reasons, we receive it three times, check dups */
if
(
len
==
prevlen
&&
!
memcmp
(
buf
,
prev
,
len
))
return
-
1
;
memcpy
(
prev
,
buf
,
len
);
prevlen
=
len
;
dump_eth
(
eth
);
dump_ip
(
ip
);
dump_udp
(
udp
);
...
...
@@ -320,15 +313,22 @@ int main(int argc, char **argv)
while
(
1
)
{
struct
ethhdr
*
eth
;
struct
iphdr
*
ip
;
unsigned
char
buf
[
10000
];
static
unsigned
char
prev
[
1500
];
static
int
prevlen
;
unsigned
char
buf
[
1500
];
struct
sockaddr_in
from
;
socklen_t
fromlen
=
sizeof
(
from
);
int
len
;
len
=
recvfrom
(
sock
,
buf
,
10000
,
MSG_TRUNC
,
len
=
recvfrom
(
sock
,
buf
,
sizeof
(
buf
)
,
MSG_TRUNC
,
(
struct
sockaddr
*
)
&
from
,
&
fromlen
);
if
(
len
>
sizeof
(
buf
))
len
=
sizeof
(
buf
);
/* for some reasons, we receive it three times, check dups */
if
(
len
==
prevlen
&&
!
memcmp
(
buf
,
prev
,
len
))
continue
;
memcpy
(
prev
,
buf
,
len
);
prevlen
=
len
;
/* now only print ptp packets */
if
(
len
<
ETH_HLEN
)
...
...
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