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
47
Issues
47
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
15c56131
Commit
15c56131
authored
Nov 13, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
general: remove use of needless NP function
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
225b2f27
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
100 additions
and
100 deletions
+100
-100
main-loop.c
arch-sim/main-loop.c
+1
-1
sim-startup.c
arch-sim/sim-startup.c
+2
-2
main-loop.c
arch-unix/main-loop.c
+4
-4
unix-startup.c
arch-unix/unix-startup.c
+2
-2
main-loop.c
arch-wrs/main-loop.c
+4
-4
wrs-startup.c
arch-wrs/wrs-startup.c
+2
-2
ppsi.h
include/ppsi/ppsi.h
+2
-2
main-loop.c
lib-bare/main-loop.c
+7
-7
common-fun.h
proto-standard/common-fun.h
+1
-1
state-initializing.c
proto-standard/state-initializing.c
+1
-1
bare-socket.c
time-bare/bare-socket.c
+9
-9
sim-socket.c
time-sim/sim-socket.c
+11
-11
unix-socket.c
time-unix/unix-socket.c
+28
-28
wrpc-socket.c
time-wrpc/wrpc-socket.c
+8
-8
wrs-socket.c
time-wrs/wrs-socket.c
+18
-18
No files found.
arch-sim/main-loop.c
View file @
15c56131
...
@@ -92,7 +92,7 @@ void sim_main_loop(struct pp_globals *ppg)
...
@@ -92,7 +92,7 @@ void sim_main_loop(struct pp_globals *ppg)
sim_set_global_DS
(
ppi
);
sim_set_global_DS
(
ppi
);
tmp_ns
=
1000LL
*
1000LL
*
pp_state_machine
(
ppi
,
tmp_ns
=
1000LL
*
1000LL
*
pp_state_machine
(
ppi
,
ppi
->
rx_ptp
,
i
-
NP
(
ppi
)
->
ptp_offset
);
ppi
->
rx_ptp
,
i
-
ppi
->
ptp_offset
);
if
(
tmp_ns
<
delay_ns
)
if
(
tmp_ns
<
delay_ns
)
delay_ns
=
tmp_ns
;
delay_ns
=
tmp_ns
;
...
...
arch-sim/sim-startup.c
View file @
15c56131
...
@@ -146,8 +146,8 @@ int main(int argc, char **argv)
...
@@ -146,8 +146,8 @@ int main(int argc, char **argv)
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
pp_printf
(
"Warning: simulator doesn't support raw "
pp_printf
(
"Warning: simulator doesn't support raw "
"ethernet. Using UDP
\n
"
);
"ethernet. Using UDP
\n
"
);
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
=
-
1
;
ppi
->
ch
[
PP_NP_GEN
].
fd
=
-
1
;
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
fd
=
-
1
;
ppi
->
ch
[
PP_NP_EVT
].
fd
=
-
1
;
ppi
->
t_ops
=
&
DEFAULT_TIME_OPS
;
ppi
->
t_ops
=
&
DEFAULT_TIME_OPS
;
ppi
->
n_ops
=
&
DEFAULT_NET_OPS
;
ppi
->
n_ops
=
&
DEFAULT_NET_OPS
;
if
(
pp_sim_is_master
(
ppi
))
if
(
pp_sim_is_master
(
ppi
))
...
...
arch-unix/main-loop.c
View file @
15c56131
...
@@ -54,7 +54,7 @@ void unix_main_loop(struct pp_globals *ppg)
...
@@ -54,7 +54,7 @@ void unix_main_loop(struct pp_globals *ppg)
* the ptp payload is one-eth-header bytes into the frame
* the ptp payload is one-eth-header bytes into the frame
*/
*/
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
NP
(
ppi
)
->
ptp_offset
=
ETH_HLEN
;
ppi
->
ptp_offset
=
ETH_HLEN
;
/*
/*
* The main loop here is based on select. While we are not
* The main loop here is based on select. While we are not
...
@@ -107,8 +107,8 @@ void unix_main_loop(struct pp_globals *ppg)
...
@@ -107,8 +107,8 @@ void unix_main_loop(struct pp_globals *ppg)
int
tmp_d
;
int
tmp_d
;
ppi
=
INST
(
ppg
,
j
);
ppi
=
INST
(
ppg
,
j
);
if
((
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
pkt_present
)
||
if
((
ppi
->
ch
[
PP_NP_GEN
].
pkt_present
)
||
(
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
pkt_present
))
{
(
ppi
->
ch
[
PP_NP_EVT
].
pkt_present
))
{
i
=
__recv_and_count
(
ppi
,
ppi
->
rx_frame
,
i
=
__recv_and_count
(
ppi
,
ppi
->
rx_frame
,
PP_MAX_FRAME_LENGTH
-
4
,
PP_MAX_FRAME_LENGTH
-
4
,
...
@@ -131,7 +131,7 @@ void unix_main_loop(struct pp_globals *ppg)
...
@@ -131,7 +131,7 @@ void unix_main_loop(struct pp_globals *ppg)
}
}
tmp_d
=
pp_state_machine
(
ppi
,
ppi
->
rx_ptp
,
tmp_d
=
pp_state_machine
(
ppi
,
ppi
->
rx_ptp
,
i
-
NP
(
ppi
)
->
ptp_offset
);
i
-
ppi
->
ptp_offset
);
if
((
delay_ms
==
-
1
)
||
(
tmp_d
<
delay_ms
))
if
((
delay_ms
==
-
1
)
||
(
tmp_d
<
delay_ms
))
delay_ms
=
tmp_d
;
delay_ms
=
tmp_d
;
...
...
arch-unix/unix-startup.c
View file @
15c56131
...
@@ -84,8 +84,8 @@ int main(int argc, char **argv)
...
@@ -84,8 +84,8 @@ int main(int argc, char **argv)
for
(
i
=
0
;
i
<
ppg
->
nlinks
;
i
++
)
{
for
(
i
=
0
;
i
<
ppg
->
nlinks
;
i
++
)
{
ppi
=
INST
(
ppg
,
i
);
ppi
=
INST
(
ppg
,
i
);
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
fd
=
-
1
;
ppi
->
ch
[
PP_NP_EVT
].
fd
=
-
1
;
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
=
-
1
;
ppi
->
ch
[
PP_NP_GEN
].
fd
=
-
1
;
ppi
->
glbs
=
ppg
;
ppi
->
glbs
=
ppg
;
ppi
->
vlans_array_len
=
CONFIG_VLAN_ARRAY_SIZE
,
ppi
->
vlans_array_len
=
CONFIG_VLAN_ARRAY_SIZE
,
...
...
arch-wrs/main-loop.c
View file @
15c56131
...
@@ -93,7 +93,7 @@ void wrs_main_loop(struct pp_globals *ppg)
...
@@ -93,7 +93,7 @@ void wrs_main_loop(struct pp_globals *ppg)
* the ptp payload is one-eth-header bytes into the frame
* the ptp payload is one-eth-header bytes into the frame
*/
*/
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
NP
(
ppi
)
->
ptp_offset
=
ETH_HLEN
;
ppi
->
ptp_offset
=
ETH_HLEN
;
/*
/*
* The main loop here is based on select. While we are not
* The main loop here is based on select. While we are not
...
@@ -148,8 +148,8 @@ void wrs_main_loop(struct pp_globals *ppg)
...
@@ -148,8 +148,8 @@ void wrs_main_loop(struct pp_globals *ppg)
int
tmp_d
;
int
tmp_d
;
ppi
=
INST
(
ppg
,
j
);
ppi
=
INST
(
ppg
,
j
);
if
((
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
pkt_present
)
||
if
((
ppi
->
ch
[
PP_NP_GEN
].
pkt_present
)
||
(
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
pkt_present
))
{
(
ppi
->
ch
[
PP_NP_EVT
].
pkt_present
))
{
i
=
__recv_and_count
(
ppi
,
ppi
->
rx_frame
,
i
=
__recv_and_count
(
ppi
,
ppi
->
rx_frame
,
PP_MAX_FRAME_LENGTH
-
4
,
PP_MAX_FRAME_LENGTH
-
4
,
...
@@ -172,7 +172,7 @@ void wrs_main_loop(struct pp_globals *ppg)
...
@@ -172,7 +172,7 @@ void wrs_main_loop(struct pp_globals *ppg)
}
}
tmp_d
=
pp_state_machine
(
ppi
,
ppi
->
rx_ptp
,
tmp_d
=
pp_state_machine
(
ppi
,
ppi
->
rx_ptp
,
i
-
NP
(
ppi
)
->
ptp_offset
);
i
-
ppi
->
ptp_offset
);
if
((
delay_ms
==
-
1
)
||
(
tmp_d
<
delay_ms
))
if
((
delay_ms
==
-
1
)
||
(
tmp_d
<
delay_ms
))
delay_ms
=
tmp_d
;
delay_ms
=
tmp_d
;
...
...
arch-wrs/wrs-startup.c
View file @
15c56131
...
@@ -199,8 +199,8 @@ int main(int argc, char **argv)
...
@@ -199,8 +199,8 @@ int main(int argc, char **argv)
}
}
for
(
i
=
0
;
i
<
ppg
->
nlinks
;
i
++
)
{
for
(
i
=
0
;
i
<
ppg
->
nlinks
;
i
++
)
{
ppi
=
INST
(
ppg
,
i
);
ppi
=
INST
(
ppg
,
i
);
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
fd
=
-
1
;
ppi
->
ch
[
PP_NP_EVT
].
fd
=
-
1
;
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
=
-
1
;
ppi
->
ch
[
PP_NP_GEN
].
fd
=
-
1
;
ppi
->
glbs
=
ppg
;
ppi
->
glbs
=
ppg
;
ppi
->
vlans_array_len
=
CONFIG_VLAN_ARRAY_SIZE
;
ppi
->
vlans_array_len
=
CONFIG_VLAN_ARRAY_SIZE
;
...
...
include/ppsi/ppsi.h
View file @
15c56131
...
@@ -103,12 +103,12 @@ static inline struct pp_servo *SRV(struct pp_instance *ppi)
...
@@ -103,12 +103,12 @@ static inline struct pp_servo *SRV(struct pp_instance *ppi)
/* Sometimes (e.g., raw ethernet frames), we need to consider an offset */
/* Sometimes (e.g., raw ethernet frames), we need to consider an offset */
static
inline
void
*
pp_get_header
(
struct
pp_instance
*
ppi
,
void
*
ptp_payload
)
static
inline
void
*
pp_get_header
(
struct
pp_instance
*
ppi
,
void
*
ptp_payload
)
{
{
return
ptp_payload
-
NP
(
ppi
)
->
ptp_offset
;
return
ptp_payload
-
ppi
->
ptp_offset
;
}
}
static
inline
void
*
pp_get_payload
(
struct
pp_instance
*
ppi
,
void
*
frame_ptr
)
static
inline
void
*
pp_get_payload
(
struct
pp_instance
*
ppi
,
void
*
frame_ptr
)
{
{
return
frame_ptr
+
NP
(
ppi
)
->
ptp_offset
;
return
frame_ptr
+
ppi
->
ptp_offset
;
}
}
extern
void
pp_prepare_pointers
(
struct
pp_instance
*
ppi
);
extern
void
pp_prepare_pointers
(
struct
pp_instance
*
ppi
);
...
...
lib-bare/main-loop.c
View file @
15c56131
...
@@ -24,7 +24,7 @@ void bare_main_loop(struct pp_instance *ppi)
...
@@ -24,7 +24,7 @@ void bare_main_loop(struct pp_instance *ppi)
{
{
int
delay_ms
;
int
delay_ms
;
NP
(
ppi
)
->
ptp_offset
=
14
;
ppi
->
ptp_offset
=
14
;
/*
/*
* The main loop here is based on select. While we are not
* The main loop here is based on select. While we are not
...
@@ -44,11 +44,11 @@ void bare_main_loop(struct pp_instance *ppi)
...
@@ -44,11 +44,11 @@ void bare_main_loop(struct pp_instance *ppi)
again:
again:
FD_ZERO
(
&
set
);
FD_ZERO
(
&
set
);
FD_SET
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
,
&
set
);
FD_SET
(
ppi
->
ch
[
PP_NP_GEN
].
fd
,
&
set
);
FD_SET
(
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
fd
,
&
set
);
FD_SET
(
ppi
->
ch
[
PP_NP_EVT
].
fd
,
&
set
);
maxfd
=
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
;
maxfd
=
ppi
->
ch
[
PP_NP_GEN
].
fd
;
if
(
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
fd
>
maxfd
)
if
(
ppi
->
ch
[
PP_NP_EVT
].
fd
>
maxfd
)
maxfd
=
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
fd
;
maxfd
=
ppi
->
ch
[
PP_NP_EVT
].
fd
;
i
=
sys_select
(
maxfd
+
1
,
&
set
,
NULL
,
NULL
,
&
tv
);
i
=
sys_select
(
maxfd
+
1
,
&
set
,
NULL
,
NULL
,
&
tv
);
if
(
i
<
0
&&
bare_errno
!=
4
/* EINTR */
)
if
(
i
<
0
&&
bare_errno
!=
4
/* EINTR */
)
...
@@ -77,6 +77,6 @@ void bare_main_loop(struct pp_instance *ppi)
...
@@ -77,6 +77,6 @@ void bare_main_loop(struct pp_instance *ppi)
goto
again
;
goto
again
;
delay_ms
=
pp_state_machine
(
ppi
,
ppi
->
rx_ptp
,
delay_ms
=
pp_state_machine
(
ppi
,
ppi
->
rx_ptp
,
i
-
NP
(
ppi
)
->
ptp_offset
);
i
-
ppi
->
ptp_offset
);
}
}
}
}
proto-standard/common-fun.h
View file @
15c56131
...
@@ -38,7 +38,7 @@ int st_com_slave_handle_followup(struct pp_instance *ppi, unsigned char *buf,
...
@@ -38,7 +38,7 @@ int st_com_slave_handle_followup(struct pp_instance *ppi, unsigned char *buf,
static
inline
int
__send_and_log
(
struct
pp_instance
*
ppi
,
int
msglen
,
static
inline
int
__send_and_log
(
struct
pp_instance
*
ppi
,
int
msglen
,
int
msgtype
,
int
chtype
)
int
msgtype
,
int
chtype
)
{
{
if
(
ppi
->
n_ops
->
send
(
ppi
,
ppi
->
tx_frame
,
msglen
+
NP
(
ppi
)
->
ptp_offset
,
if
(
ppi
->
n_ops
->
send
(
ppi
,
ppi
->
tx_frame
,
msglen
+
ppi
->
ptp_offset
,
&
ppi
->
last_snt_time
,
chtype
,
0
)
<
msglen
)
{
&
ppi
->
last_snt_time
,
chtype
,
0
)
<
msglen
)
{
pp_diag
(
ppi
,
frames
,
1
,
"%s(%d) Message can't be sent
\n
"
,
pp_diag
(
ppi
,
frames
,
1
,
"%s(%d) Message can't be sent
\n
"
,
pp_msg_names
[
msgtype
],
msgtype
);
pp_msg_names
[
msgtype
],
msgtype
);
...
...
proto-standard/state-initializing.c
View file @
15c56131
...
@@ -24,7 +24,7 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
...
@@ -24,7 +24,7 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
/* Clock identity comes from mac address with 0xff:0xfe intermixed */
/* Clock identity comes from mac address with 0xff:0xfe intermixed */
id
=
(
unsigned
char
*
)
&
DSDEF
(
ppi
)
->
clockIdentity
;
id
=
(
unsigned
char
*
)
&
DSDEF
(
ppi
)
->
clockIdentity
;
mac
=
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
addr
;
mac
=
ppi
->
ch
[
PP_NP_GEN
].
addr
;
id
[
0
]
=
mac
[
0
];
id
[
0
]
=
mac
[
0
];
id
[
1
]
=
mac
[
1
];
id
[
1
]
=
mac
[
1
];
id
[
2
]
=
mac
[
2
];
id
[
2
]
=
mac
[
2
];
...
...
time-bare/bare-socket.c
View file @
15c56131
...
@@ -18,7 +18,7 @@ static int bare_net_recv(struct pp_instance *ppi, void *pkt, int len,
...
@@ -18,7 +18,7 @@ static int bare_net_recv(struct pp_instance *ppi, void *pkt, int len,
if
(
t
)
if
(
t
)
ppi
->
t_ops
->
get
(
ppi
,
t
);
ppi
->
t_ops
->
get
(
ppi
,
t
);
ret
=
sys_recv
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
,
pkt
,
len
,
0
);
ret
=
sys_recv
(
ppi
->
ch
[
PP_NP_GEN
].
fd
,
pkt
,
len
,
0
);
if
(
ret
>
0
&&
pp_diag_allow
(
ppi
,
frames
,
2
))
if
(
ret
>
0
&&
pp_diag_allow
(
ppi
,
frames
,
2
))
dump_1588pkt
(
"recv: "
,
pkt
,
ret
,
t
);
dump_1588pkt
(
"recv: "
,
pkt
,
ret
,
t
);
return
ret
;
return
ret
;
...
@@ -35,12 +35,12 @@ static int bare_net_send(struct pp_instance *ppi, void *pkt, int len,
...
@@ -35,12 +35,12 @@ static int bare_net_send(struct pp_instance *ppi, void *pkt, int len,
memcpy
(
hdr
->
h_dest
,
PP_MCAST_MACADDRESS
,
6
);
memcpy
(
hdr
->
h_dest
,
PP_MCAST_MACADDRESS
,
6
);
/* raw socket implementation always uses gen socket */
/* raw socket implementation always uses gen socket */
memcpy
(
hdr
->
h_source
,
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
addr
,
6
);
memcpy
(
hdr
->
h_source
,
ppi
->
ch
[
PP_NP_GEN
].
addr
,
6
);
if
(
t
)
if
(
t
)
ppi
->
t_ops
->
get
(
ppi
,
t
);
ppi
->
t_ops
->
get
(
ppi
,
t
);
ret
=
sys_send
(
NP
(
ppi
)
->
ch
[
chtype
].
fd
,
pkt
,
len
,
0
);
ret
=
sys_send
(
ppi
->
ch
[
chtype
].
fd
,
pkt
,
len
,
0
);
if
(
ret
>
0
&&
pp_diag_allow
(
ppi
,
frames
,
2
))
if
(
ret
>
0
&&
pp_diag_allow
(
ppi
,
frames
,
2
))
dump_1588pkt
(
"send: "
,
pkt
,
len
,
t
);
dump_1588pkt
(
"send: "
,
pkt
,
len
,
t
);
return
ret
;
return
ret
;
...
@@ -82,9 +82,9 @@ static int bare_open_ch(struct pp_instance *ppi, char *ifname)
...
@@ -82,9 +82,9 @@ static int bare_open_ch(struct pp_instance *ppi, char *ifname)
if
(
sys_ioctl
(
sock
,
SIOCGIFHWADDR
,
&
ifr
)
<
0
)
if
(
sys_ioctl
(
sock
,
SIOCGIFHWADDR
,
&
ifr
)
<
0
)
goto
err_out
;
goto
err_out
;
memcpy
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
addr
,
memcpy
(
ppi
->
ch
[
PP_NP_GEN
].
addr
,
ifr
.
ifr_ifru
.
ifru_hwaddr
.
sa_data
,
6
);
ifr
.
ifr_ifru
.
ifru_hwaddr
.
sa_data
,
6
);
memcpy
(
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
addr
,
memcpy
(
ppi
->
ch
[
PP_NP_EVT
].
addr
,
ifr
.
ifr_ifru
.
ifru_hwaddr
.
sa_data
,
6
);
ifr
.
ifr_ifru
.
ifru_hwaddr
.
sa_data
,
6
);
/* bind */
/* bind */
...
@@ -106,8 +106,8 @@ static int bare_open_ch(struct pp_instance *ppi, char *ifname)
...
@@ -106,8 +106,8 @@ static int bare_open_ch(struct pp_instance *ppi, char *ifname)
sys_setsockopt
(
sock
,
SOL_PACKET
,
PACKET_ADD_MEMBERSHIP
,
sys_setsockopt
(
sock
,
SOL_PACKET
,
PACKET_ADD_MEMBERSHIP
,
&
pmr
,
sizeof
(
pmr
));
/* lazily ignore errors */
&
pmr
,
sizeof
(
pmr
));
/* lazily ignore errors */
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
=
sock
;
ppi
->
ch
[
PP_NP_GEN
].
fd
=
sock
;
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
fd
=
sock
;
ppi
->
ch
[
PP_NP_EVT
].
fd
=
sock
;
/* make timestamps available through recvmsg() -- FIXME: hw? */
/* make timestamps available through recvmsg() -- FIXME: hw? */
sys_setsockopt
(
sock
,
SOL_SOCKET
,
SO_TIMESTAMP
,
sys_setsockopt
(
sock
,
SOL_SOCKET
,
SO_TIMESTAMP
,
...
@@ -128,14 +128,14 @@ err_out:
...
@@ -128,14 +128,14 @@ err_out:
static
int
bare_net_exit
(
struct
pp_instance
*
ppi
)
static
int
bare_net_exit
(
struct
pp_instance
*
ppi
)
{
{
return
sys_shutdown
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
,
SHUT_RDWR
);
return
sys_shutdown
(
ppi
->
ch
[
PP_NP_GEN
].
fd
,
SHUT_RDWR
);
}
}
/* This function must be able to be called twice, and clean-up internally */
/* This function must be able to be called twice, and clean-up internally */
static
int
bare_net_init
(
struct
pp_instance
*
ppi
)
static
int
bare_net_init
(
struct
pp_instance
*
ppi
)
{
{
/* Here, socket may not be 0 (do we have stdin even if bare) */
/* Here, socket may not be 0 (do we have stdin even if bare) */
if
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
)
if
(
ppi
->
ch
[
PP_NP_GEN
].
fd
)
bare_net_exit
(
ppi
);
bare_net_exit
(
ppi
);
/* The buffer is inside ppi, but we need to set pointers and align */
/* The buffer is inside ppi, but we need to set pointers and align */
...
...
time-sim/sim-socket.c
View file @
15c56131
...
@@ -145,7 +145,7 @@ static int sim_net_recv(struct pp_instance *ppi, void *pkt, int len,
...
@@ -145,7 +145,7 @@ static int sim_net_recv(struct pp_instance *ppi, void *pkt, int len,
if
(
data
->
n_pending
<=
0
)
if
(
data
->
n_pending
<=
0
)
return
0
;
return
0
;
ch
=
&
(
NP
(
ppi
)
->
ch
[
data
->
pending
->
chtype
]);
ch
=
&
(
ppi
->
ch
[
data
->
pending
->
chtype
]);
ret
=
-
1
;
ret
=
-
1
;
if
(
ch
->
pkt_present
>
0
)
{
if
(
ch
->
pkt_present
>
0
)
{
...
@@ -181,12 +181,12 @@ static int sim_net_send(struct pp_instance *ppi, void *pkt, int len,
...
@@ -181,12 +181,12 @@ static int sim_net_send(struct pp_instance *ppi, void *pkt, int len,
PP_SLAVE_GEN_PORT
:
PP_SLAVE_GEN_PORT
:
PP_SLAVE_EVT_PORT
);
PP_SLAVE_EVT_PORT
);
addr
.
sin_addr
.
s_addr
=
NP
(
ppi
)
->
mcast_addr
;
addr
.
sin_addr
.
s_addr
=
ppi
->
mcast_addr
;
if
(
t
)
if
(
t
)
ppi
->
t_ops
->
get
(
ppi
,
t
);
ppi
->
t_ops
->
get
(
ppi
,
t
);
ret
=
sendto
(
NP
(
ppi
)
->
ch
[
chtype
].
fd
,
pkt
,
len
,
0
,
ret
=
sendto
(
ppi
->
ch
[
chtype
].
fd
,
pkt
,
len
,
0
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
struct
sockaddr_in
));
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
struct
sockaddr_in
));
if
(
pp_diag_allow
(
ppi
,
frames
,
2
))
if
(
pp_diag_allow
(
ppi
,
frames
,
2
))
dump_payloadpkt
(
"send: "
,
pkt
,
len
,
t
);
dump_payloadpkt
(
"send: "
,
pkt
,
len
,
t
);
...
@@ -219,7 +219,7 @@ static int sim_net_send(struct pp_instance *ppi, void *pkt, int len,
...
@@ -219,7 +219,7 @@ static int sim_net_send(struct pp_instance *ppi, void *pkt, int len,
pending
.
delay_ns
=
data
->
n_delay
.
t_prop_ns
+
jit_ns
;
pending
.
delay_ns
=
data
->
n_delay
.
t_prop_ns
+
jit_ns
;
insert_pending
(
SIM_PPG_ARCH
(
ppi
->
glbs
),
&
pending
);
insert_pending
(
SIM_PPG_ARCH
(
ppi
->
glbs
),
&
pending
);
NP
(
data
->
other_ppi
)
->
ch
[
chtype
].
pkt_present
++
;
data
->
other_ppi
->
ch
[
chtype
].
pkt_present
++
;
return
ret
;
return
ret
;
}
}
...
@@ -230,11 +230,11 @@ static int sim_net_exit(struct pp_instance *ppi)
...
@@ -230,11 +230,11 @@ static int sim_net_exit(struct pp_instance *ppi)
/* only UDP */
/* only UDP */
for
(
i
=
PP_NP_GEN
;
i
<=
PP_NP_EVT
;
i
++
)
{
for
(
i
=
PP_NP_GEN
;
i
<=
PP_NP_EVT
;
i
++
)
{
fd
=
NP
(
ppi
)
->
ch
[
i
].
fd
;
fd
=
ppi
->
ch
[
i
].
fd
;
if
(
fd
<
0
)
if
(
fd
<
0
)
continue
;
continue
;
close
(
fd
);
close
(
fd
);
NP
(
ppi
)
->
ch
[
i
].
fd
=
-
1
;
ppi
->
ch
[
i
].
fd
=
-
1
;
}
}
return
0
;
return
0
;
}
}
...
@@ -253,7 +253,7 @@ static int sim_open_ch(struct pp_instance *ppi, char *ifname, int chtype)
...
@@ -253,7 +253,7 @@ static int sim_open_ch(struct pp_instance *ppi, char *ifname, int chtype)
if
(
sock
<
0
)
if
(
sock
<
0
)
goto
err_out
;
goto
err_out
;
NP
(
ppi
)
->
ch
[
chtype
].
fd
=
sock
;
ppi
->
ch
[
chtype
].
fd
=
sock
;
temp
=
1
;
/* allow address reuse */
temp
=
1
;
/* allow address reuse */
if
(
setsockopt
(
sock
,
SOL_SOCKET
,
SO_REUSEADDR
,
&
temp
,
sizeof
(
int
))
<
0
)
if
(
setsockopt
(
sock
,
SOL_SOCKET
,
SO_REUSEADDR
,
&
temp
,
sizeof
(
int
))
<
0
)
...
@@ -278,21 +278,21 @@ static int sim_open_ch(struct pp_instance *ppi, char *ifname, int chtype)
...
@@ -278,21 +278,21 @@ static int sim_open_ch(struct pp_instance *ppi, char *ifname, int chtype)
sizeof
(
struct
sockaddr_in
))
<
0
)
sizeof
(
struct
sockaddr_in
))
<
0
)
goto
err_out
;
goto
err_out
;
NP
(
ppi
)
->
ch
[
chtype
].
fd
=
sock
;
ppi
->
ch
[
chtype
].
fd
=
sock
;
/*
/*
* Standard ppsi state machine is designed to drop packets coming from
* Standard ppsi state machine is designed to drop packets coming from
* itself, based on the clockIdentity. This hack avoids this behaviour,
* itself, based on the clockIdentity. This hack avoids this behaviour,
* changing the clockIdentity of the master.
* changing the clockIdentity of the master.
*/
*/
if
(
pp_sim_is_master
(
ppi
))
if
(
pp_sim_is_master
(
ppi
))
memset
(
NP
(
ppi
)
->
ch
[
chtype
].
addr
,
111
,
1
);
memset
(
ppi
->
ch
[
chtype
].
addr
,
111
,
1
);
return
0
;
return
0
;
err_out:
err_out:
pp_printf
(
"%s: %s: %s
\n
"
,
__func__
,
context
,
strerror
(
errno
));
pp_printf
(
"%s: %s: %s
\n
"
,
__func__
,
context
,
strerror
(
errno
));
if
(
sock
>=
0
)
if
(
sock
>=
0
)
close
(
sock
);
close
(
sock
);
NP
(
ppi
)
->
ch
[
chtype
].
fd
=
-
1
;
ppi
->
ch
[
chtype
].
fd
=
-
1
;
return
-
1
;
return
-
1
;
}
}
...
@@ -300,7 +300,7 @@ static int sim_net_init(struct pp_instance *ppi)
...
@@ -300,7 +300,7 @@ static int sim_net_init(struct pp_instance *ppi)
{
{
int
i
;
int
i
;
if
(
NP
(
ppi
)
->
ch
[
0
].
fd
>
0
)
if
(
ppi
->
ch
[
0
].
fd
>
0
)
sim_net_exit
(
ppi
);
sim_net_exit
(
ppi
);
/* The buffer is inside ppi, but we need to set pointers and align */
/* The buffer is inside ppi, but we need to set pointers and align */
...
...
time-unix/unix-socket.c
View file @
15c56131
...
@@ -108,7 +108,7 @@ static int unix_net_recv(struct pp_instance *ppi, void *pkt, int len,
...
@@ -108,7 +108,7 @@ static int unix_net_recv(struct pp_instance *ppi, void *pkt, int len,
switch
(
ppi
->
proto
)
{
switch
(
ppi
->
proto
)
{
case
PPSI_PROTO_RAW
:
case
PPSI_PROTO_RAW
:
fd
=
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
;
fd
=
ppi
->
ch
[
PP_NP_GEN
].
fd
;
ret
=
unix_recv_msg
(
ppi
,
fd
,
pkt
,
len
,
t
);
ret
=
unix_recv_msg
(
ppi
,
fd
,
pkt
,
len
,
t
);
if
(
ret
>
0
&&
pp_diag_allow
(
ppi
,
frames
,
2
))
if
(
ret
>
0
&&
pp_diag_allow
(
ppi
,
frames
,
2
))
...
@@ -118,8 +118,8 @@ static int unix_net_recv(struct pp_instance *ppi, void *pkt, int len,
...
@@ -118,8 +118,8 @@ static int unix_net_recv(struct pp_instance *ppi, void *pkt, int len,
case
PPSI_PROTO_UDP
:
case
PPSI_PROTO_UDP
:
/* we can return one frame only, always handle EVT msgs
/* we can return one frame only, always handle EVT msgs
* before GEN */
* before GEN */
ch1
=
&
(
NP
(
ppi
)
->
ch
[
PP_NP_EVT
]);
ch1
=
&
(
ppi
->
ch
[
PP_NP_EVT
]);
ch2
=
&
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
]);
ch2
=
&
(
ppi
->
ch
[
PP_NP_GEN
]);
ret
=
-
1
;
ret
=
-
1
;
if
(
ch1
->
pkt_present
)
if
(
ch1
->
pkt_present
)
...
@@ -159,12 +159,12 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,
...
@@ -159,12 +159,12 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,
memcpy
(
hdr
->
h_dest
,
PP_MCAST_MACADDRESS
,
ETH_ALEN
);
memcpy
(
hdr
->
h_dest
,
PP_MCAST_MACADDRESS
,
ETH_ALEN
);
/* raw socket implementation always uses gen socket */
/* raw socket implementation always uses gen socket */
memcpy
(
hdr
->
h_source
,
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
addr
,
ETH_ALEN
);
memcpy
(
hdr
->
h_source
,
ppi
->
ch
[
PP_NP_GEN
].
addr
,
ETH_ALEN
);
if
(
t
)
if
(
t
)
ppi
->
t_ops
->
get
(
ppi
,
t
);
ppi
->
t_ops
->
get
(
ppi
,
t
);
ret
=
send
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
,
hdr
,
len
,
0
);
ret
=
send
(
ppi
->
ch
[
PP_NP_GEN
].
fd
,
hdr
,
len
,
0
);
if
(
pp_diag_allow
(
ppi
,
frames
,
2
))
if
(
pp_diag_allow
(
ppi
,
frames
,
2
))
dump_1588pkt
(
"send: "
,
pkt
,
len
,
t
);
dump_1588pkt
(
"send: "
,
pkt
,
len
,
t
);
return
ret
;
return
ret
;
...
@@ -173,12 +173,12 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,
...
@@ -173,12 +173,12 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,
addr
.
sin_family
=
AF_INET
;
addr
.
sin_family
=
AF_INET
;
addr
.
sin_port
=
htons
(
chtype
==
PP_NP_GEN
addr
.
sin_port
=
htons
(
chtype
==
PP_NP_GEN
?
PP_GEN_PORT
:
PP_EVT_PORT
);
?
PP_GEN_PORT
:
PP_EVT_PORT
);
addr
.
sin_addr
.
s_addr
=
NP
(
ppi
)
->
mcast_addr
;
addr
.
sin_addr
.
s_addr
=
ppi
->
mcast_addr
;
if
(
t
)
if
(
t
)
ppi
->
t_ops
->
get
(
ppi
,
t
);
ppi
->
t_ops
->
get
(
ppi
,
t
);
ret
=
sendto
(
NP
(
ppi
)
->
ch
[
chtype
].
fd
,
pkt
,
len
,
0
,
ret
=
sendto
(
ppi
->
ch
[
chtype
].
fd
,
pkt
,
len
,
0
,
(
struct
sockaddr
*
)
&
addr
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
struct
sockaddr_in
));
sizeof
(
struct
sockaddr_in
));
if
(
pp_diag_allow
(
ppi
,
frames
,
2
))
if
(
pp_diag_allow
(
ppi
,
frames
,
2
))
...
@@ -221,7 +221,7 @@ static int unix_open_ch_raw(struct pp_instance *ppi, char *ifname, int chtype)
...
@@ -221,7 +221,7 @@ static int unix_open_ch_raw(struct pp_instance *ppi, char *ifname, int chtype)
if
(
ioctl
(
sock
,
SIOCGIFHWADDR
,
&
ifr
)
<
0
)
if
(
ioctl
(
sock
,
SIOCGIFHWADDR
,
&
ifr
)
<
0
)
goto
err_out
;
goto
err_out
;
memcpy
(
NP
(
ppi
)
->
ch
[
chtype
].
addr
,
ifr
.
ifr_hwaddr
.
sa_data
,
6
);
memcpy
(
ppi
->
ch
[
chtype
].
addr
,
ifr
.
ifr_hwaddr
.
sa_data
,
6
);
/* bind */
/* bind */
memset
(
&
addr_ll
,
0
,
sizeof
(
addr
));
memset
(
&
addr_ll
,
0
,
sizeof
(
addr
));
...
@@ -242,7 +242,7 @@ static int unix_open_ch_raw(struct pp_instance *ppi, char *ifname, int chtype)
...
@@ -242,7 +242,7 @@ static int unix_open_ch_raw(struct pp_instance *ppi, char *ifname, int chtype)
setsockopt
(
sock
,
SOL_PACKET
,
PACKET_ADD_MEMBERSHIP
,
setsockopt
(
sock
,
SOL_PACKET
,
PACKET_ADD_MEMBERSHIP
,
&
pmr
,
sizeof
(
pmr
));
/* lazily ignore errors */
&
pmr
,
sizeof
(
pmr
));
/* lazily ignore errors */
NP
(
ppi
)
->
ch
[
chtype
].
fd
=
sock
;
ppi
->
ch
[
chtype
].
fd
=
sock
;
/* make timestamps available through recvmsg() -- FIXME: hw? */
/* make timestamps available through recvmsg() -- FIXME: hw? */
setsockopt
(
sock
,
SOL_SOCKET
,
SO_TIMESTAMP
,
setsockopt
(
sock
,
SOL_SOCKET
,
SO_TIMESTAMP
,
...
@@ -254,7 +254,7 @@ err_out:
...
@@ -254,7 +254,7 @@ err_out:
pp_printf
(
"%s: %s: %s
\n
"
,
__func__
,
context
,
strerror
(
errno
));
pp_printf
(
"%s: %s: %s
\n
"
,
__func__
,
context
,
strerror
(
errno
));
if
(
sock
>=
0
)
if
(
sock
>=
0
)
close
(
sock
);
close
(
sock
);
NP
(
ppi
)
->
ch
[
chtype
].
fd
=
-
1
;
ppi
->
ch
[
chtype
].
fd
=
-
1
;
return
-
1
;
return
-
1
;
}
}
...
@@ -274,7 +274,7 @@ static int unix_open_ch_udp(struct pp_instance *ppi, char *ifname, int chtype)
...
@@ -274,7 +274,7 @@ static int unix_open_ch_udp(struct pp_instance *ppi, char *ifname, int chtype)
if
(
sock
<
0
)
if
(
sock
<
0
)
goto
err_out
;
goto
err_out
;
NP
(
ppi
)
->
ch
[
chtype
].
fd
=
sock
;
ppi
->
ch
[
chtype
].
fd
=
sock
;
/* hw interface information */
/* hw interface information */
memset
(
&
ifr
,
0
,
sizeof
(
ifr
));
memset
(
&
ifr
,
0
,
sizeof
(
ifr
));
...
@@ -287,7 +287,7 @@ static int unix_open_ch_udp(struct pp_instance *ppi, char *ifname, int chtype)
...
@@ -287,7 +287,7 @@ static int unix_open_ch_udp(struct pp_instance *ppi, char *ifname, int chtype)
if
(
ioctl
(
sock
,
SIOCGIFHWADDR
,
&
ifr
)
<
0
)
if
(
ioctl
(
sock
,
SIOCGIFHWADDR
,
&
ifr
)
<
0
)
goto
err_out
;
goto
err_out
;
memcpy
(
NP
(
ppi
)
->
ch
[
chtype
].
addr
,
ifr
.
ifr_hwaddr
.
sa_data
,
6
);
memcpy
(
ppi
->
ch
[
chtype
].
addr
,
ifr
.
ifr_hwaddr
.
sa_data
,
6
);
context
=
"ioctl(SIOCGIFADDR)"
;
context
=
"ioctl(SIOCGIFADDR)"
;
if
(
ioctl
(
sock
,
SIOCGIFADDR
,
&
ifr
)
<
0
)
if
(
ioctl
(
sock
,
SIOCGIFADDR
,
&
ifr
)
<
0
)
goto
err_out
;
goto
err_out
;
...
@@ -322,7 +322,7 @@ static int unix_open_ch_udp(struct pp_instance *ppi, char *ifname, int chtype)
...
@@ -322,7 +322,7 @@ static int unix_open_ch_udp(struct pp_instance *ppi, char *ifname, int chtype)
context
=
addr_str
;
errno
=
EINVAL
;
context
=
addr_str
;
errno
=
EINVAL
;
if
(
!
inet_aton
(
addr_str
,
&
net_addr
))
if
(
!
inet_aton
(
addr_str
,
&
net_addr
))
goto
err_out
;
goto
err_out
;
NP
(
ppi
)
->
mcast_addr
=
net_addr
.
s_addr
;
ppi
->
mcast_addr
=
net_addr
.
s_addr
;
/* multicast sends only on specified interface */
/* multicast sends only on specified interface */
imr
.
imr_multiaddr
.
s_addr
=
net_addr
.
s_addr
;
imr
.
imr_multiaddr
.
s_addr
=
net_addr
.
s_addr
;
...
@@ -359,14 +359,14 @@ static int unix_open_ch_udp(struct pp_instance *ppi, char *ifname, int chtype)
...
@@ -359,14 +359,14 @@ static int unix_open_ch_udp(struct pp_instance *ppi, char *ifname, int chtype)
&
temp
,
sizeof
(
int
))
<
0
)
&
temp
,
sizeof
(
int
))
<
0
)
goto
err_out
;
goto
err_out
;
NP
(
ppi
)
->
ch
[
chtype
].
fd
=
sock
;
ppi
->
ch
[
chtype
].
fd
=
sock
;
return
0
;
return
0
;
err_out:
err_out:
pp_printf
(
"%s: %s: %s
\n
"
,
__func__
,
context
,
strerror
(
errno
));
pp_printf
(
"%s: %s: %s
\n
"
,
__func__
,
context
,
strerror
(
errno
));
if
(
sock
>=
0
)
if
(
sock
>=
0
)
close
(
sock
);
close
(
sock
);
NP
(
ppi
)
->
ch
[
chtype
].
fd
=
-
1
;
ppi
->
ch
[
chtype
].
fd
=
-
1
;
return
-
1
;
return
-
1
;
}
}
...
@@ -381,7 +381,7 @@ static int unix_net_init(struct pp_instance *ppi)
...
@@ -381,7 +381,7 @@ static int unix_net_init(struct pp_instance *ppi)
{
{
int
i
;
int
i
;
if
(
NP
(
ppi
)
->
ch
[
0
].
fd
>
0
)
if
(
ppi
->
ch
[
0
].
fd
>
0
)
unix_net_exit
(
ppi
);
unix_net_exit
(
ppi
);
/* The buffer is inside ppi, but we need to set pointers and align */
/* The buffer is inside ppi, but we need to set pointers and align */
...
@@ -425,30 +425,30 @@ static int unix_net_exit(struct pp_instance *ppi)
...
@@ -425,30 +425,30 @@ static int unix_net_exit(struct pp_instance *ppi)
switch
(
ppi
->
proto
)
{
switch
(
ppi
->
proto
)
{
case
PPSI_PROTO_RAW
:
case
PPSI_PROTO_RAW
:
fd
=
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
;
fd
=
ppi
->
ch
[
PP_NP_GEN
].
fd
;
if
(
fd
>
0
)
{
if
(
fd
>
0
)
{
close
(
fd
);
close
(
fd
);
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
=
-
1
;
ppi
->
ch
[
PP_NP_GEN
].
fd
=
-
1
;
}
}
return
0
;
return
0
;
case
PPSI_PROTO_UDP
:
case
PPSI_PROTO_UDP
:
for
(
i
=
PP_NP_GEN
;
i
<=
PP_NP_EVT
;
i
++
)
{
for
(
i
=
PP_NP_GEN
;
i
<=
PP_NP_EVT
;
i
++
)
{
fd
=
NP
(
ppi
)
->
ch
[
i
].
fd
;
fd
=
ppi
->
ch
[
i
].
fd
;
if
(
fd
<
0
)
if
(
fd
<
0
)
continue
;
continue
;
/* Close General Multicast */
/* Close General Multicast */
imr
.
imr_multiaddr
.
s_addr
=
NP
(
ppi
)
->
mcast_addr
;
imr
.
imr_multiaddr
.
s_addr
=
ppi
->
mcast_addr
;
imr
.
imr_interface
.
s_addr
=
htonl
(
INADDR_ANY
);
imr
.
imr_interface
.
s_addr
=
htonl
(
INADDR_ANY
);
setsockopt
(
fd
,
IPPROTO_IP
,
IP_DROP_MEMBERSHIP
,
setsockopt
(
fd
,
IPPROTO_IP
,
IP_DROP_MEMBERSHIP
,
&
imr
,
sizeof
(
struct
ip_mreq
));
&
imr
,
sizeof
(
struct
ip_mreq
));
close
(
fd
);
close
(
fd
);
NP
(
ppi
)
->
ch
[
i
].
fd
=
-
1
;
ppi
->
ch
[
i
].
fd
=
-
1
;
}
}
NP
(
ppi
)
->
mcast_addr
=
0
;
ppi
->
mcast_addr
=
0
;
return
0
;
return
0
;
case
PPSI_PROTO_VLAN
:
case
PPSI_PROTO_VLAN
:
/* FIXME */
/* FIXME */
...
@@ -488,8 +488,8 @@ static int unix_net_check_packet(struct pp_globals *ppg, int delay_ms)
...
@@ -488,8 +488,8 @@ static int unix_net_check_packet(struct pp_globals *ppg, int delay_ms)
/* Use either fd that is valid, irrespective of ether/udp */
/* Use either fd that is valid, irrespective of ether/udp */
for
(
k
=
0
;
k
<
2
;
k
++
)
{
for
(
k
=
0
;
k
<
2
;
k
++
)
{
NP
(
ppi
)
->
ch
[
k
].
pkt_present
=
0
;
ppi
->
ch
[
k
].
pkt_present
=
0
;
fd_to_set
=
NP
(
ppi
)
->
ch
[
k
].
fd
;
fd_to_set
=
ppi
->
ch
[
k
].
fd
;
if
(
fd_to_set
<
0
)
if
(
fd_to_set
<
0
)
continue
;
continue
;
...
@@ -510,18 +510,18 @@ static int unix_net_check_packet(struct pp_globals *ppg, int delay_ms)
...
@@ -510,18 +510,18 @@ static int unix_net_check_packet(struct pp_globals *ppg, int delay_ms)
for
(
j
=
0
;
j
<
ppg
->
nlinks
;
j
++
)
{
for
(
j
=
0
;
j
<
ppg
->
nlinks
;
j
++
)
{
struct
pp_instance
*
ppi
=
INST
(
ppg
,
j
);
struct
pp_instance
*
ppi
=
INST
(
ppg
,
j
);
int
fd
=
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
;
int
fd
=
ppi
->
ch
[
PP_NP_GEN
].
fd
;
if
(
fd
>=
0
&&
FD_ISSET
(
fd
,
&
set
))
{
if
(
fd
>=
0
&&
FD_ISSET
(
fd
,
&
set
))
{
ret
++
;
ret
++
;
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
pkt_present
=
1
;
ppi
->
ch
[
PP_NP_GEN
].
pkt_present
=
1
;
}
}
fd
=
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
fd
;
fd
=
ppi
->
ch
[
PP_NP_EVT
].
fd
;
if
(
fd
>=
0
&&
FD_ISSET
(
fd
,
&
set
))
{
if
(
fd
>=
0
&&
FD_ISSET
(
fd
,
&
set
))
{
ret
++
;
ret
++
;
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
pkt_present
=
1
;
ppi
->
ch
[
PP_NP_EVT
].
pkt_present
=
1
;
}
}
}
}
return
ret
;
return
ret
;
...
...
time-wrpc/wrpc-socket.c
View file @
15c56131
...
@@ -26,10 +26,10 @@ static int wrpc_open_ch(struct pp_instance *ppi)
...
@@ -26,10 +26,10 @@ static int wrpc_open_ch(struct pp_instance *ppi)
return
-
1
;
return
-
1
;
ptpd_netif_get_hw_addr
(
sock
,
&
mac
);
ptpd_netif_get_hw_addr
(
sock
,
&
mac
);
memcpy
(
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
addr
,
&
mac
,
sizeof
(
mac_addr_t
));
memcpy
(
ppi
->
ch
[
PP_NP_EVT
].
addr
,
&
mac
,
sizeof
(
mac_addr_t
));
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
custom
=
sock
;
ppi
->
ch
[
PP_NP_EVT
].
custom
=
sock
;
memcpy
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
addr
,
&
mac
,
sizeof
(
mac_addr_t
));
memcpy
(
ppi
->
ch
[
PP_NP_GEN
].
addr
,
&
mac
,
sizeof
(
mac_addr_t
));
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
custom
=
sock
;
ppi
->
ch
[
PP_NP_GEN
].
custom
=
sock
;
return
0
;
return
0
;
}
}
...
@@ -42,7 +42,7 @@ static int wrpc_net_recv(struct pp_instance *ppi, void *pkt, int len,
...
@@ -42,7 +42,7 @@ static int wrpc_net_recv(struct pp_instance *ppi, void *pkt, int len,
wr_socket_t
*
sock
;
wr_socket_t
*
sock
;
wr_timestamp_t
wr_ts
;
wr_timestamp_t
wr_ts
;
wr_sockaddr_t
addr
;
wr_sockaddr_t
addr
;
sock
=
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
custom
;
sock
=
ppi
->
ch
[
PP_NP_EVT
].
custom
;
got
=
ptpd_netif_recvfrom
(
sock
,
&
addr
,
pkt
,
len
,
&
wr_ts
);
got
=
ptpd_netif_recvfrom
(
sock
,
&
addr
,
pkt
,
len
,
&
wr_ts
);
if
(
t
)
{
if
(
t
)
{
...
@@ -74,7 +74,7 @@ static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len,
...
@@ -74,7 +74,7 @@ static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len,
wr_socket_t
*
sock
;
wr_socket_t
*
sock
;
wr_timestamp_t
wr_ts
;
wr_timestamp_t
wr_ts
;
wr_sockaddr_t
addr
;
wr_sockaddr_t
addr
;
sock
=
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
custom
;
sock
=
ppi
->
ch
[
PP_NP_EVT
].
custom
;
addr
.
ethertype
=
ETH_P_1588
;
addr
.
ethertype
=
ETH_P_1588
;
memcpy
(
&
addr
.
mac
,
PP_MCAST_MACADDRESS
,
sizeof
(
mac_addr_t
));
memcpy
(
&
addr
.
mac
,
PP_MCAST_MACADDRESS
,
sizeof
(
mac_addr_t
));
...
@@ -102,14 +102,14 @@ static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len,
...
@@ -102,14 +102,14 @@ static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len,
static
int
wrpc_net_exit
(
struct
pp_instance
*
ppi
)
static
int
wrpc_net_exit
(
struct
pp_instance
*
ppi
)
{
{
ptpd_netif_close_socket
(
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
custom
);
ptpd_netif_close_socket
(
ppi
->
ch
[
PP_NP_EVT
].
custom
);
return
0
;
return
0
;
}
}
/* This function must be able to be called twice, and clean-up internally */
/* This function must be able to be called twice, and clean-up internally */
static
int
wrpc_net_init
(
struct
pp_instance
*
ppi
)
static
int
wrpc_net_init
(
struct
pp_instance
*
ppi
)
{
{
if
(
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
custom
)
if
(
ppi
->
ch
[
PP_NP_EVT
].
custom
)
wrpc_net_exit
(
ppi
);
wrpc_net_exit
(
ppi
);
pp_prepare_pointers
(
ppi
);
pp_prepare_pointers
(
ppi
);
wrpc_open_ch
(
ppi
);
wrpc_open_ch
(
ppi
);
...
...
time-wrs/wrs-socket.c
View file @
15c56131
...
@@ -171,7 +171,7 @@ static int wrs_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
...
@@ -171,7 +171,7 @@ static int wrs_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
struct
cmsghdr
*
cmsg
;
struct
cmsghdr
*
cmsg
;
struct
scm_timestamping
*
sts
=
NULL
;
struct
scm_timestamping
*
sts
=
NULL
;
s
=
(
struct
wrs_socket
*
)
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
arch_data
;
s
=
(
struct
wrs_socket
*
)
ppi
->
ch
[
PP_NP_GEN
].
arch_data
;
memset
(
&
msg
,
0
,
sizeof
(
msg
));
memset
(
&
msg
,
0
,
sizeof
(
msg
));
msg
.
msg_iov
=
&
entry
;
msg
.
msg_iov
=
&
entry
;
...
@@ -249,7 +249,7 @@ int wrs_net_recv(struct pp_instance *ppi, void *pkt, int len,
...
@@ -249,7 +249,7 @@ int wrs_net_recv(struct pp_instance *ppi, void *pkt, int len,
switch
(
ppi
->
proto
)
{
switch
(
ppi
->
proto
)
{
case
PPSI_PROTO_RAW
:
case
PPSI_PROTO_RAW
:
fd
=
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
;
fd
=
ppi
->
ch
[
PP_NP_GEN
].
fd
;
ret
=
wrs_recv_msg
(
ppi
,
fd
,
pkt
,
len
,
t
);
ret
=
wrs_recv_msg
(
ppi
,
fd
,
pkt
,
len
,
t
);
if
(
ret
>
0
&&
pp_diag_allow
(
ppi
,
frames
,
2
))
if
(
ret
>
0
&&
pp_diag_allow
(
ppi
,
frames
,
2
))
...
@@ -258,8 +258,8 @@ int wrs_net_recv(struct pp_instance *ppi, void *pkt, int len,
...
@@ -258,8 +258,8 @@ int wrs_net_recv(struct pp_instance *ppi, void *pkt, int len,
case
PPSI_PROTO_UDP
:
case
PPSI_PROTO_UDP
:
/* UDP: always handle EVT msgs before GEN */
/* UDP: always handle EVT msgs before GEN */
ch1
=
&
(
NP
(
ppi
)
->
ch
[
PP_NP_EVT
]);
ch1
=
&
(
ppi
->
ch
[
PP_NP_EVT
]);
ch2
=
&
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
]);
ch2
=
&
(
ppi
->
ch
[
PP_NP_GEN
]);
if
(
ch1
->
pkt_present
)
if
(
ch1
->
pkt_present
)
ret
=
wrs_recv_msg
(
ppi
,
ch1
->
fd
,
pkt
,
len
,
t
);
ret
=
wrs_recv_msg
(
ppi
,
ch1
->
fd
,
pkt
,
len
,
t
);
...
@@ -385,7 +385,7 @@ int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
...
@@ -385,7 +385,7 @@ int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
struct
wrs_socket
*
s
;
struct
wrs_socket
*
s
;
int
ret
,
fd
,
drop
;
int
ret
,
fd
,
drop
;
s
=
(
struct
wrs_socket
*
)
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
arch_data
;
s
=
(
struct
wrs_socket
*
)
ppi
->
ch
[
PP_NP_GEN
].
arch_data
;
/*
/*
* To fake a packet loss, we must corrupt the frame; we need
* To fake a packet loss, we must corrupt the frame; we need
...
@@ -396,14 +396,14 @@ int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
...
@@ -396,14 +396,14 @@ int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
switch
(
ppi
->
proto
)
{
switch
(
ppi
->
proto
)
{
case
PPSI_PROTO_RAW
:
case
PPSI_PROTO_RAW
:
fd
=
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
;
fd
=
ppi
->
ch
[
PP_NP_GEN
].
fd
;
hdr
->
h_proto
=
htons
(
ETH_P_1588
);
hdr
->
h_proto
=
htons
(
ETH_P_1588
);
if
(
drop
)
if
(
drop
)
hdr
->
h_proto
++
;
hdr
->
h_proto
++
;
memcpy
(
hdr
->
h_dest
,
PP_MCAST_MACADDRESS
,
ETH_ALEN
);
memcpy
(
hdr
->
h_dest
,
PP_MCAST_MACADDRESS
,
ETH_ALEN
);
/* raw socket implementation always uses gen socket */
/* raw socket implementation always uses gen socket */
memcpy
(
hdr
->
h_source
,
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
addr
,
ETH_ALEN
);
memcpy
(
hdr
->
h_source
,
ppi
->
ch
[
PP_NP_GEN
].
addr
,
ETH_ALEN
);
if
(
t
)
if
(
t
)
ppi
->
t_ops
->
get
(
ppi
,
t
);
ppi
->
t_ops
->
get
(
ppi
,
t
);
...
@@ -422,11 +422,11 @@ int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
...
@@ -422,11 +422,11 @@ int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
return
ret
;
return
ret
;
case
PPSI_PROTO_UDP
:
case
PPSI_PROTO_UDP
:
fd
=
NP
(
ppi
)
->
ch
[
chtype
].
fd
;
fd
=
ppi
->
ch
[
chtype
].
fd
;
addr
.
sin_family
=
AF_INET
;
addr
.
sin_family
=
AF_INET
;
addr
.
sin_port
=
htons
(
chtype
==
PP_NP_GEN
addr
.
sin_port
=
htons
(
chtype
==
PP_NP_GEN
?
PP_GEN_PORT
:
PP_EVT_PORT
);
?
PP_GEN_PORT
:
PP_EVT_PORT
);
addr
.
sin_addr
.
s_addr
=
NP
(
ppi
)
->
mcast_addr
;
addr
.
sin_addr
.
s_addr
=
ppi
->
mcast_addr
;
if
(
drop
)
if
(
drop
)
addr
.
sin_port
=
3200
;
addr
.
sin_port
=
3200
;
ret
=
sendto
(
fd
,
pkt
,
len
,
0
,
(
struct
sockaddr
*
)
&
addr
,
ret
=
sendto
(
fd
,
pkt
,
len
,
0
,
(
struct
sockaddr
*
)
&
addr
,
...
@@ -496,7 +496,7 @@ static int wrs_net_init(struct pp_instance *ppi)
...
@@ -496,7 +496,7 @@ static int wrs_net_init(struct pp_instance *ppi)
int
r
,
i
;
int
r
,
i
;
struct
hal_port_state
*
p
;
struct
hal_port_state
*
p
;
if
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
arch_data
)
if
(
ppi
->
ch
[
PP_NP_GEN
].
arch_data
)
wrs_net_exit
(
ppi
);
wrs_net_exit
(
ppi
);
/* Generic OS work is done by standard Unix stuff */
/* Generic OS work is done by standard Unix stuff */
...
@@ -530,15 +530,15 @@ static int wrs_net_init(struct pp_instance *ppi)
...
@@ -530,15 +530,15 @@ static int wrs_net_init(struct pp_instance *ppi)
s
->
dmtd_phase_valid
=
0
;
s
->
dmtd_phase_valid
=
0
;
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
arch_data
=
s
;
ppi
->
ch
[
PP_NP_GEN
].
arch_data
=
s
;
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
arch_data
=
s
;
ppi
->
ch
[
PP_NP_EVT
].
arch_data
=
s
;
tmo_init
(
&
s
->
dmtd_update_tmo
,
DMTD_UPDATE_INTERVAL
);
tmo_init
(
&
s
->
dmtd_update_tmo
,
DMTD_UPDATE_INTERVAL
);
for
(
i
=
PP_NP_GEN
,
r
=
0
;
i
<=
PP_NP_EVT
&&
r
==
0
;
i
++
)
for
(
i
=
PP_NP_GEN
,
r
=
0
;
i
<=
PP_NP_EVT
&&
r
==
0
;
i
++
)
r
=
wrs_enable_timestamps
(
ppi
,
NP
(
ppi
)
->
ch
[
i
].
fd
);
r
=
wrs_enable_timestamps
(
ppi
,
ppi
->
ch
[
i
].
fd
);
if
(
r
)
{
if
(
r
)
{
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
arch_data
=
NULL
;
ppi
->
ch
[
PP_NP_GEN
].
arch_data
=
NULL
;
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
arch_data
=
NULL
;
ppi
->
ch
[
PP_NP_EVT
].
arch_data
=
NULL
;
free
(
s
);
free
(
s
);
}
}
return
r
;
return
r
;
...
@@ -547,9 +547,9 @@ static int wrs_net_init(struct pp_instance *ppi)
...
@@ -547,9 +547,9 @@ static int wrs_net_init(struct pp_instance *ppi)
static
int
wrs_net_exit
(
struct
pp_instance
*
ppi
)
static
int
wrs_net_exit
(
struct
pp_instance
*
ppi
)
{
{
unix_net_ops
.
exit
(
ppi
);
unix_net_ops
.
exit
(
ppi
);
free
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
arch_data
);
free
(
ppi
->
ch
[
PP_NP_GEN
].
arch_data
);
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
arch_data
=
NULL
;
ppi
->
ch
[
PP_NP_GEN
].
arch_data
=
NULL
;
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
arch_data
=
NULL
;
ppi
->
ch
[
PP_NP_EVT
].
arch_data
=
NULL
;
return
0
;
return
0
;
}
}
...
...
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