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
a43f3182
Commit
a43f3182
authored
Feb 26, 2013
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
state-initializing: simplify assignments
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
a8733f10
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
29 deletions
+32
-29
hooks.c
proto-ext-whiterabbit/hooks.c
+8
-6
state-initializing.c
proto-standard/state-initializing.c
+24
-23
No files found.
proto-ext-whiterabbit/hooks.c
View file @
a43f3182
...
...
@@ -5,12 +5,14 @@
static
int
wr_init
(
struct
pp_instance
*
ppi
,
unsigned
char
*
pkt
,
int
plen
)
{
WR_DSPOR
(
ppi
)
->
wrStateTimeout
=
WR_DEFAULT_STATE_TIMEOUT_MS
;
WR_DSPOR
(
ppi
)
->
wrStateRetry
=
WR_DEFAULT_STATE_REPEAT
;
WR_DSPOR
(
ppi
)
->
calPeriod
=
WR_DEFAULT_CAL_PERIOD
;
WR_DSPOR
(
ppi
)
->
wrModeOn
=
0
;
WR_DSPOR
(
ppi
)
->
parentWrConfig
=
0
;
WR_DSPOR
(
ppi
)
->
calibrated
=
!
WR_DEFAULT_PHY_CALIBRATION_REQUIRED
;
struct
wr_dsport
*
wp
=
WR_DSPOR
(
ppi
);
wp
->
wrStateTimeout
=
WR_DEFAULT_STATE_TIMEOUT_MS
;
wp
->
wrStateRetry
=
WR_DEFAULT_STATE_REPEAT
;
wp
->
calPeriod
=
WR_DEFAULT_CAL_PERIOD
;
wp
->
wrModeOn
=
0
;
wp
->
parentWrConfig
=
0
;
wp
->
calibrated
=
!
WR_DEFAULT_PHY_CALIBRATION_REQUIRED
;
return
0
;
}
...
...
proto-standard/state-initializing.c
View file @
a43f3182
...
...
@@ -10,10 +10,12 @@
* Initializes network and other stuff
*/
int
pp_initializing
(
struct
pp_instance
*
ppi
,
unsigned
char
*
pkt
,
int
plen
)
{
unsigned
char
*
id
,
*
mac
;
struct
DSDefault
*
def
=
DSDEF
(
ppi
);
struct
DSPort
*
port
=
DSPOR
(
ppi
);
struct
pp_runtime_opts
*
opt
=
OPTS
(
ppi
);
int
ret
=
0
;
if
(
NP
(
ppi
)
->
inited
)
...
...
@@ -24,12 +26,12 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
NP
(
ppi
)
->
inited
=
1
;
DSPOR
(
ppi
)
->
portState
=
PPS_INITIALIZING
;
port
->
portState
=
PPS_INITIALIZING
;
/* Initialize default data set */
DSDEF
(
ppi
)
->
twoStepFlag
=
PP_TWO_STEP_FLAG
;
def
->
twoStepFlag
=
PP_TWO_STEP_FLAG
;
/* Clock identity comes from mac address with 0xff:0xfe intermixed */
id
=
DSDEF
(
ppi
)
->
clockIdentity
;
id
=
def
->
clockIdentity
;
mac
=
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
addr
;
id
[
0
]
=
mac
[
0
];
id
[
1
]
=
mac
[
1
];
...
...
@@ -40,30 +42,29 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
id
[
6
]
=
mac
[
4
];
id
[
7
]
=
mac
[
5
];
DSDEF
(
ppi
)
->
numberPorts
=
1
;
memcpy
(
&
DSDEF
(
ppi
)
->
clockQuality
,
&
OPTS
(
ppi
)
->
clock_quality
,
def
->
numberPorts
=
1
;
memcpy
(
&
def
->
clockQuality
,
&
opt
->
clock_quality
,
sizeof
(
ClockQuality
));
DSDEF
(
ppi
)
->
priority1
=
OPTS
(
ppi
)
->
prio1
;
DSDEF
(
ppi
)
->
priority2
=
OPTS
(
ppi
)
->
prio2
;
DSDEF
(
ppi
)
->
domainNumber
=
OPTS
(
ppi
)
->
domain_number
;
DSDEF
(
ppi
)
->
slaveOnly
=
OPTS
(
ppi
)
->
slave_only
;
if
(
OPTS
(
ppi
)
->
slave_only
)
def
->
priority1
=
opt
->
prio1
;
def
->
priority2
=
opt
->
prio2
;
def
->
domainNumber
=
opt
->
domain_number
;
def
->
slaveOnly
=
opt
->
slave_only
;
if
(
opt
->
slave_only
)
ppi
->
defaultDS
->
clockQuality
.
clockClass
=
255
;
/* Initialize port data set */
memcpy
(
ppi
->
portDS
->
portIdentity
.
clockIdentity
,
ppi
->
defaultDS
->
clockIdentity
,
PP_CLOCK_IDENTITY_LENGTH
);
DSPOR
(
ppi
)
->
portIdentity
.
portNumber
=
1
;
DSPOR
(
ppi
)
->
logMinDelayReqInterval
=
PP_DEFAULT_DELAYREQ_INTERVAL
;
DSPOR
(
ppi
)
->
peerMeanPathDelay
.
seconds
=
0
;
DSPOR
(
ppi
)
->
peerMeanPathDelay
.
nanoseconds
=
0
;
DSPOR
(
ppi
)
->
logAnnounceInterval
=
OPTS
(
ppi
)
->
announce_intvl
;
DSPOR
(
ppi
)
->
announceReceiptTimeout
=
PP_DEFAULT_ANNOUNCE_RECEIPT_TIMEOUT
;
DSPOR
(
ppi
)
->
logSyncInterval
=
OPTS
(
ppi
)
->
sync_intvl
;
DSPOR
(
ppi
)
->
delayMechanism
=
PP_DEFAULT_DELAY_MECHANISM
;
DSPOR
(
ppi
)
->
logMinPdelayReqInterval
=
PP_DEFAULT_PDELAYREQ_INTERVAL
;
DSPOR
(
ppi
)
->
versionNumber
=
PP_VERSION_PTP
;
port
->
portIdentity
.
portNumber
=
1
;
port
->
logMinDelayReqInterval
=
PP_DEFAULT_DELAYREQ_INTERVAL
;
port
->
peerMeanPathDelay
.
seconds
=
0
;
port
->
peerMeanPathDelay
.
nanoseconds
=
0
;
port
->
logAnnounceInterval
=
opt
->
announce_intvl
;
port
->
announceReceiptTimeout
=
PP_DEFAULT_ANNOUNCE_RECEIPT_TIMEOUT
;
port
->
logSyncInterval
=
opt
->
sync_intvl
;
port
->
delayMechanism
=
PP_DEFAULT_DELAY_MECHANISM
;
port
->
logMinPdelayReqInterval
=
PP_DEFAULT_PDELAYREQ_INTERVAL
;
port
->
versionNumber
=
PP_VERSION_PTP
;
if
(
pp_hooks
.
init
)
ret
=
pp_hooks
.
init
(
ppi
,
pkt
,
plen
);
...
...
@@ -83,7 +84,7 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
msg_pack_header
(
ppi
,
ppi
->
buf_out
);
if
(
!
OPTS
(
ppi
)
->
master_only
)
if
(
!
opt
->
master_only
)
ppi
->
next_state
=
PPS_LISTENING
;
else
ppi
->
next_state
=
PPS_MASTER
;
...
...
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