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
ada67af9
Commit
ada67af9
authored
Mar 07, 2013
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
foreign-master: simplify add_foreign()
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
75517b0e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
21 deletions
+11
-21
common-fun.c
proto-standard/common-fun.c
+11
-21
No files found.
proto-standard/common-fun.c
View file @
ada67af9
...
...
@@ -76,48 +76,38 @@ int st_com_check_record_update(struct pp_instance *ppi)
/* Called by this file, basically when an announce is got, all states */
static
void
st_com_add_foreign
(
struct
pp_instance
*
ppi
,
unsigned
char
*
buf
)
{
int
i
,
j
;
int
found
=
0
;
int
i
;
MsgHeader
*
hdr
=
&
ppi
->
received_ptp_header
;
j
=
ppi
->
foreign_record_best
;
/* Check if foreign master is already known */
for
(
i
=
0
;
i
<
ppi
->
number_foreign_records
;
i
++
)
{
if
(
!
memcmp
(
&
hdr
->
sourcePortIdentity
,
&
ppi
->
frgn_master
[
j
].
port_id
,
&
ppi
->
frgn_master
[
i
].
port_id
,
sizeof
(
hdr
->
sourcePortIdentity
)))
{
/* already in Foreign master data set */
found
=
1
;
msg_copy_header
(
&
ppi
->
frgn_master
[
j
].
hdr
,
hdr
);
msg_unpack_announce
(
buf
,
&
ppi
->
frgn_master
[
j
].
ann
);
break
;
/* already in Foreign master data set, update info */
msg_copy_header
(
&
ppi
->
frgn_master
[
i
].
hdr
,
hdr
);
msg_unpack_announce
(
buf
,
&
ppi
->
frgn_master
[
i
].
ann
);
return
;
}
j
=
(
j
+
1
)
%
ppi
->
number_foreign_records
;
}
/* Old foreign master */
if
(
found
)
return
;
/* New foreign master */
if
(
ppi
->
number_foreign_records
<
PP_NR_FOREIGN_RECORDS
)
ppi
->
number_foreign_records
++
;
j
=
ppi
->
foreign_record_i
;
/* FIXME: replace the worst */
i
=
ppi
->
foreign_record_i
;
/* Copy new foreign master data set from announce message */
memcpy
(
&
ppi
->
frgn_master
[
j
].
port_id
,
memcpy
(
&
ppi
->
frgn_master
[
i
].
port_id
,
&
hdr
->
sourcePortIdentity
,
sizeof
(
hdr
->
sourcePortIdentity
));
/*
* header and announce field of each Foreign Master are
* usefull to run Best Master Clock Algorithm
*/
msg_copy_header
(
&
ppi
->
frgn_master
[
j
].
hdr
,
hdr
);
msg_unpack_announce
(
buf
,
&
ppi
->
frgn_master
[
j
].
ann
);
msg_copy_header
(
&
ppi
->
frgn_master
[
i
].
hdr
,
hdr
);
msg_unpack_announce
(
buf
,
&
ppi
->
frgn_master
[
i
].
ann
);
PP_VPRINTF
(
"New foreign Master added
\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