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
81590d98
Commit
81590d98
authored
Nov 11, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time-{unix,wrs}: prepare for PROTO_VLAN addition
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
46c498d9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
217 additions
and
174 deletions
+217
-174
ppsi.h
include/ppsi/ppsi.h
+1
-0
unix-socket.c
time-unix/unix-socket.c
+171
-147
wrs-socket.c
time-wrs/wrs-socket.c
+45
-27
No files found.
include/ppsi/ppsi.h
View file @
81590d98
...
...
@@ -316,6 +316,7 @@ extern int pp_config_file(struct pp_globals *ppg, int force, char *fname);
#define PPSI_PROTO_RAW 0
#define PPSI_PROTO_UDP 1
#define PPSI_PROTO_VLAN 2
/* Actually: vlan over raw eth */
#define PPSI_ROLE_AUTO 0
#define PPSI_ROLE_MASTER 1
...
...
time-unix/unix-socket.c
View file @
81590d98
This diff is collapsed.
Click to expand it.
time-wrs/wrs-socket.c
View file @
81590d98
...
...
@@ -245,15 +245,18 @@ int wrs_net_recv(struct pp_instance *ppi, void *pkt, int len,
TimeInternal
*
t
)
{
struct
pp_channel
*
ch1
,
*
ch2
;
int
ret
=
-
1
;
int
fd
,
ret
=
-
1
;
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
{
int
fd
=
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
;
switch
(
ppi
->
proto
)
{
case
PPSI_PROTO_RAW
:
fd
=
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
;
ret
=
wrs_recv_msg
(
ppi
,
fd
,
pkt
,
len
,
t
);
if
(
ret
>
0
&&
pp_diag_allow
(
ppi
,
frames
,
2
))
dump_1588pkt
(
"recv: "
,
pkt
,
ret
,
t
);
}
else
{
break
;
case
PPSI_PROTO_UDP
:
/* UDP: always handle EVT msgs before GEN */
ch1
=
&
(
NP
(
ppi
)
->
ch
[
PP_NP_EVT
]);
ch2
=
&
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
]);
...
...
@@ -265,7 +268,14 @@ int wrs_net_recv(struct pp_instance *ppi, void *pkt, int len,
if
(
ret
>
0
&&
pp_diag_allow
(
ppi
,
frames
,
2
))
dump_payloadpkt
(
"recv: "
,
pkt
,
ret
,
t
);
break
;
case
PPSI_PROTO_VLAN
:
/* FIXME */
default:
return
-
1
;
}
if
(
ret
<
0
)
return
ret
;
pp_diag
(
ppi
,
time
,
1
,
"recv stamp: (correct %i) %9li.%09li
\n
"
,
...
...
@@ -337,10 +347,10 @@ static void poll_tx_timestamp(struct pp_instance *ppi, void *pkt, int len,
/*
* Raw frames return "sock_extended_err" too, telling this is
* a tx timestamp. U
dp doesn't
so don't check in udp mode
* a tx timestamp. U
DP does not;
so don't check in udp mode
* (the pointer is only checked for non-null)
*/
if
(
!
(
ppi
->
proto
==
PPSI_PROTO_RAW
))
if
(
!
(
ppi
->
proto
!=
PPSI_PROTO_UDP
))
serr
=
(
void
*
)
1
;
for
(
cmsg
=
CMSG_FIRSTHDR
(
&
msg
);
...
...
@@ -384,7 +394,8 @@ int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
*/
drop
=
ppsi_drop_tx
();
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
{
switch
(
ppi
->
proto
)
{
case
PPSI_PROTO_RAW
:
fd
=
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
;
hdr
->
h_proto
=
htons
(
ETH_P_1588
);
if
(
drop
)
...
...
@@ -401,7 +412,7 @@ int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
poll_tx_timestamp
(
ppi
,
pkt
,
len
,
s
,
fd
,
t
);
if
(
drop
)
/* avoid messaging about stamps that are not used */
goto
drop_msg
;
break
;
if
(
pp_diag_allow
(
ppi
,
frames
,
2
))
dump_1588pkt
(
"send: "
,
pkt
,
len
,
t
);
...
...
@@ -409,28 +420,35 @@ int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
t
->
correct
,
(
long
)
t
->
seconds
,
(
long
)
t
->
nanoseconds
);
return
ret
;
}
/* else: UDP */
fd
=
NP
(
ppi
)
->
ch
[
chtype
].
fd
;
addr
.
sin_family
=
AF_INET
;
addr
.
sin_port
=
htons
(
chtype
==
PP_NP_GEN
?
PP_GEN_PORT
:
PP_EVT_PORT
);
addr
.
sin_addr
.
s_addr
=
NP
(
ppi
)
->
mcast_addr
;
if
(
drop
)
addr
.
sin_port
=
3200
;
ret
=
sendto
(
fd
,
pkt
,
len
,
0
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
struct
sockaddr_in
));
poll_tx_timestamp
(
ppi
,
pkt
,
len
,
s
,
fd
,
t
);
case
PPSI_PROTO_UDP
:
fd
=
NP
(
ppi
)
->
ch
[
chtype
].
fd
;
addr
.
sin_family
=
AF_INET
;
addr
.
sin_port
=
htons
(
chtype
==
PP_NP_GEN
?
PP_GEN_PORT
:
PP_EVT_PORT
);
addr
.
sin_addr
.
s_addr
=
NP
(
ppi
)
->
mcast_addr
;
if
(
drop
)
addr
.
sin_port
=
3200
;
ret
=
sendto
(
fd
,
pkt
,
len
,
0
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
struct
sockaddr_in
));
poll_tx_timestamp
(
ppi
,
pkt
,
len
,
s
,
fd
,
t
);
if
(
drop
)
/* like above: skil messages about timestamps */
break
;
if
(
drop
)
/* like above: skil messages about timestamps */
goto
drop_msg
;
if
(
pp_diag_allow
(
ppi
,
frames
,
2
))
dump_payloadpkt
(
"send: "
,
pkt
,
len
,
t
);
pp_diag
(
ppi
,
time
,
1
,
"send stamp: (correct %i) %9li.%09li
\n
"
,
t
->
correct
,
(
long
)
t
->
seconds
,
(
long
)
t
->
nanoseconds
);
return
ret
;
case
PPSI_PROTO_VLAN
:
/* FIXME */
default:
return
-
1
;
}
if
(
pp_diag_allow
(
ppi
,
frames
,
2
))
dump_payloadpkt
(
"send: "
,
pkt
,
len
,
t
);
pp_diag
(
ppi
,
time
,
1
,
"send stamp: (correct %i) %9li.%09li
\n
"
,
t
->
correct
,
(
long
)
t
->
seconds
,
(
long
)
t
->
nanoseconds
);
drop_msg:
if
(
drop
)
pp_diag
(
ppi
,
frames
,
1
,
"Drop sent frame
\n
"
);
...
...
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