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
b64e38cf
Commit
b64e38cf
authored
Aug 31, 2016
by
Davide Ciminaghi
Committed by
Alessandro Rubini
Sep 20, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pdelay: factorize code handling pdelay_resp_followup
remove duplication, remove code size
parent
18b2ed68
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
124 deletions
+46
-124
common-fun.c
proto-standard/common-fun.c
+39
-0
common-fun.h
proto-standard/common-fun.h
+3
-0
state-listening.c
proto-standard/state-listening.c
+1
-32
state-master.c
proto-standard/state-master.c
+1
-32
state-passive.c
proto-standard/state-passive.c
+1
-30
state-slave.c
proto-standard/state-slave.c
+1
-30
No files found.
proto-standard/common-fun.c
View file @
b64e38cf
...
...
@@ -228,6 +228,45 @@ int st_com_peer_handle_pres(struct pp_instance *ppi, unsigned char *buf,
return
0
;
}
int
st_com_peer_handle_pres_followup
(
struct
pp_instance
*
ppi
,
unsigned
char
*
buf
,
int
plen
)
{
MsgHeader
*
hdr
=
&
ppi
->
received_ptp_header
;
MsgPDelayRespFollowUp
respFllw
;
int
e
=
0
;
if
(
plen
<
PP_PDELAY_RESP_FOLLOW_UP_LENGTH
)
/* Ignore */
return
e
;
msg_unpack_pdelay_resp_follow_up
(
buf
,
&
respFllw
);
if
((
memcmp
(
&
DSPOR
(
ppi
)
->
portIdentity
.
clockIdentity
,
&
respFllw
.
requestingPortIdentity
.
clockIdentity
,
PP_CLOCK_IDENTITY_LENGTH
)
==
0
)
&&
((
ppi
->
sent_seq
[
PPM_PDELAY_REQ
])
==
hdr
->
sequenceId
)
&&
(
DSPOR
(
ppi
)
->
portIdentity
.
portNumber
==
respFllw
.
requestingPortIdentity
.
portNumber
)
&&
(
ppi
->
flags
&
PPI_FLAG_FROM_CURRENT_PARENT
))
{
to_TimeInternal
(
&
ppi
->
t5
,
&
respFllw
.
responseOriginTimestamp
);
ppi
->
flags
|=
PPI_FLAG_WAITING_FOR_RF_UP
;
if
(
pp_hooks
.
handle_presp
)
e
=
pp_hooks
.
handle_presp
(
ppi
);
else
pp_servo_got_presp
(
ppi
);
}
else
{
pp_diag
(
ppi
,
frames
,
2
,
"%s: "
"PDelay Resp F-up doesn't match PDelay Req
\n
"
,
__func__
);
}
return
e
;
}
int
st_com_peer_handle_preq
(
struct
pp_instance
*
ppi
,
unsigned
char
*
buf
,
int
len
)
{
...
...
proto-standard/common-fun.h
View file @
b64e38cf
...
...
@@ -41,6 +41,9 @@ int st_com_peer_handle_preq(struct pp_instance *ppi, unsigned char *buf,
int
st_com_peer_handle_pres
(
struct
pp_instance
*
ppi
,
unsigned
char
*
buf
,
int
len
);
int
st_com_peer_handle_pres_followup
(
struct
pp_instance
*
ppi
,
unsigned
char
*
buf
,
int
len
);
static
inline
int
__send_and_log
(
struct
pp_instance
*
ppi
,
int
msglen
,
int
msgtype
,
int
chtype
)
{
...
...
proto-standard/state-listening.c
View file @
b64e38cf
...
...
@@ -12,8 +12,6 @@
int
pp_listening
(
struct
pp_instance
*
ppi
,
unsigned
char
*
pkt
,
int
plen
)
{
int
e
=
0
;
/* error var, to check errors in msg handling */
MsgHeader
*
hdr
=
&
ppi
->
received_ptp_header
;
MsgPDelayRespFollowUp
respFllw
;
if
(
pp_hooks
.
listening
)
e
=
pp_hooks
.
listening
(
ppi
,
pkt
,
plen
);
...
...
@@ -46,36 +44,7 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
break
;
case
PPM_PDELAY_RESP_FOLLOW_UP
:
if
(
plen
<
PP_PDELAY_RESP_FOLLOW_UP_LENGTH
)
break
;
msg_unpack_pdelay_resp_follow_up
(
pkt
,
&
respFllw
);
if
((
memcmp
(
&
DSPOR
(
ppi
)
->
portIdentity
.
clockIdentity
,
&
respFllw
.
requestingPortIdentity
.
clockIdentity
,
PP_CLOCK_IDENTITY_LENGTH
)
==
0
)
&&
((
ppi
->
sent_seq
[
PPM_PDELAY_REQ
])
==
hdr
->
sequenceId
)
&&
(
DSPOR
(
ppi
)
->
portIdentity
.
portNumber
==
respFllw
.
requestingPortIdentity
.
portNumber
)
&&
(
ppi
->
flags
&
PPI_FLAG_FROM_CURRENT_PARENT
))
{
to_TimeInternal
(
&
ppi
->
t5
,
&
respFllw
.
responseOriginTimestamp
);
ppi
->
flags
|=
PPI_FLAG_WAITING_FOR_RF_UP
;
if
(
pp_hooks
.
handle_presp
)
e
=
pp_hooks
.
handle_presp
(
ppi
);
else
pp_servo_got_presp
(
ppi
);
if
(
e
)
goto
out
;
}
else
{
pp_diag
(
ppi
,
frames
,
2
,
"%s: "
"PDelay Resp F-up doesn't match PDelay Req
\n
"
,
__func__
);
}
e
=
st_com_peer_handle_pres_followup
(
ppi
,
pkt
,
plen
);
break
;
default:
...
...
proto-standard/state-master.c
View file @
b64e38cf
...
...
@@ -13,8 +13,6 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
int
msgtype
;
int
e
=
0
;
/* error var, to check errors in msg handling */
MsgHeader
*
hdr
=
&
ppi
->
received_ptp_header
;
MsgPDelayRespFollowUp
respFllw
;
/* ignore errors; we are not getting FAULTY if not transmitting */
pp_lib_may_issue_sync
(
ppi
);
...
...
@@ -68,36 +66,7 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
break
;
case
PPM_PDELAY_RESP_FOLLOW_UP
:
if
(
plen
<
PP_PDELAY_RESP_FOLLOW_UP_LENGTH
)
break
;
msg_unpack_pdelay_resp_follow_up
(
pkt
,
&
respFllw
);
if
((
memcmp
(
&
DSPOR
(
ppi
)
->
portIdentity
.
clockIdentity
,
&
respFllw
.
requestingPortIdentity
.
clockIdentity
,
PP_CLOCK_IDENTITY_LENGTH
)
==
0
)
&&
((
ppi
->
sent_seq
[
PPM_PDELAY_REQ
])
==
hdr
->
sequenceId
)
&&
(
DSPOR
(
ppi
)
->
portIdentity
.
portNumber
==
respFllw
.
requestingPortIdentity
.
portNumber
)
&&
(
ppi
->
flags
&
PPI_FLAG_FROM_CURRENT_PARENT
))
{
to_TimeInternal
(
&
ppi
->
t5
,
&
respFllw
.
responseOriginTimestamp
);
ppi
->
flags
|=
PPI_FLAG_WAITING_FOR_RF_UP
;
if
(
pp_hooks
.
handle_presp
)
e
=
pp_hooks
.
handle_presp
(
ppi
);
else
pp_servo_got_presp
(
ppi
);
if
(
e
)
goto
out
;
}
else
{
pp_diag
(
ppi
,
frames
,
2
,
"%s: "
"PDelay Resp F-up doesn't match PDelay Req
\n
"
,
__func__
);
}
e
=
st_com_peer_handle_pres_followup
(
ppi
,
pkt
,
plen
);
break
;
default:
...
...
proto-standard/state-passive.c
View file @
b64e38cf
...
...
@@ -12,8 +12,6 @@
int
pp_passive
(
struct
pp_instance
*
ppi
,
unsigned
char
*
pkt
,
int
plen
)
{
int
e
=
0
;
/* error var, to check errors in msg handling */
MsgHeader
*
hdr
=
&
ppi
->
received_ptp_header
;
MsgPDelayRespFollowUp
respFllw
;
/* when the clock is using peer-delay, listening must send it too */
if
(
ppi
->
glbs
->
delay_mech
==
PP_P2P_MECH
)
...
...
@@ -41,34 +39,7 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
break
;
case
PPM_PDELAY_RESP_FOLLOW_UP
:
if
(
plen
<
PP_PDELAY_RESP_FOLLOW_UP_LENGTH
)
break
;
msg_unpack_pdelay_resp_follow_up
(
pkt
,
&
respFllw
);
if
((
memcmp
(
&
DSPOR
(
ppi
)
->
portIdentity
.
clockIdentity
,
&
respFllw
.
requestingPortIdentity
.
clockIdentity
,
PP_CLOCK_IDENTITY_LENGTH
)
==
0
)
&&
((
ppi
->
sent_seq
[
PPM_PDELAY_REQ
])
==
hdr
->
sequenceId
)
&&
(
DSPOR
(
ppi
)
->
portIdentity
.
portNumber
==
respFllw
.
requestingPortIdentity
.
portNumber
)
&&
(
ppi
->
flags
&
PPI_FLAG_FROM_CURRENT_PARENT
))
{
to_TimeInternal
(
&
ppi
->
t5
,
&
respFllw
.
responseOriginTimestamp
);
ppi
->
flags
|=
PPI_FLAG_WAITING_FOR_RF_UP
;
if
(
pp_hooks
.
handle_presp
)
e
=
pp_hooks
.
handle_presp
(
ppi
);
else
pp_servo_got_presp
(
ppi
);
}
else
{
pp_diag
(
ppi
,
frames
,
2
,
"%s: "
"PDelay Resp F-up doesn't match PDelay Req
\n
"
,
__func__
);
}
e
=
st_com_peer_handle_pres_followup
(
ppi
,
pkt
,
plen
);
break
;
default:
...
...
proto-standard/state-slave.c
View file @
b64e38cf
...
...
@@ -16,7 +16,6 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
int
e
=
0
;
/* error var, to check errors in msg handling */
MsgHeader
*
hdr
=
&
ppi
->
received_ptp_header
;
MsgDelayResp
resp
;
MsgPDelayRespFollowUp
respFllw
;
if
(
ppi
->
is_new_state
)
{
memset
(
&
ppi
->
t1
,
0
,
sizeof
(
ppi
->
t1
));
...
...
@@ -101,35 +100,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
break
;
case
PPM_PDELAY_RESP_FOLLOW_UP
:
if
(
plen
<
PP_PDELAY_RESP_FOLLOW_UP_LENGTH
)
break
;
msg_unpack_pdelay_resp_follow_up
(
pkt
,
&
respFllw
);
if
((
memcmp
(
&
DSPOR
(
ppi
)
->
portIdentity
.
clockIdentity
,
&
respFllw
.
requestingPortIdentity
.
clockIdentity
,
PP_CLOCK_IDENTITY_LENGTH
)
==
0
)
&&
((
ppi
->
sent_seq
[
PPM_PDELAY_REQ
])
==
hdr
->
sequenceId
)
&&
(
DSPOR
(
ppi
)
->
portIdentity
.
portNumber
==
respFllw
.
requestingPortIdentity
.
portNumber
)
&&
(
ppi
->
flags
&
PPI_FLAG_FROM_CURRENT_PARENT
))
{
to_TimeInternal
(
&
ppi
->
t5
,
&
respFllw
.
responseOriginTimestamp
);
ppi
->
flags
|=
PPI_FLAG_WAITING_FOR_RF_UP
;
if
(
pp_hooks
.
handle_presp
)
e
=
pp_hooks
.
handle_presp
(
ppi
);
else
pp_servo_got_presp
(
ppi
);
if
(
e
)
goto
out
;
}
else
{
pp_diag
(
ppi
,
frames
,
2
,
"pp_pclock : "
"PDelay Resp F-up doesn't match PDelay Req
\n
"
);
}
e
=
st_com_peer_handle_pres_followup
(
ppi
,
pkt
,
plen
);
break
;
default:
...
...
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