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
6ab0c121
Commit
6ab0c121
authored
Feb 27, 2013
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
state-listening: merge extension into std, using hooks
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
5b23d9ed
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
60 deletions
+15
-60
ppsi.h
include/ppsi/ppsi.h
+1
-0
Makefile
proto-ext-whiterabbit/Makefile
+0
-1
hooks.c
proto-ext-whiterabbit/hooks.c
+9
-1
state-listening.c
proto-ext-whiterabbit/state-listening.c
+0
-58
state-listening.c
proto-standard/state-listening.c
+5
-0
No files found.
include/ppsi/ppsi.h
View file @
6ab0c121
...
...
@@ -310,6 +310,7 @@ struct pp_ext_hooks {
int
(
*
init
)(
struct
pp_instance
*
ppi
,
unsigned
char
*
pkt
,
int
plen
);
int
(
*
open
)(
struct
pp_instance
*
ppi
,
struct
pp_runtime_opts
*
rt_opts
);
int
(
*
close
)(
struct
pp_instance
*
ppi
);
int
(
*
listening
)(
struct
pp_instance
*
ppi
,
unsigned
char
*
pkt
,
int
plen
);
};
extern
struct
pp_ext_hooks
pp_hooks
;
/* The one for the extension we build */
...
...
proto-ext-whiterabbit/Makefile
View file @
6ab0c121
...
...
@@ -7,7 +7,6 @@ LIBWRO := $D/libwr.o
LIBS
+=
$(LIBWRO)
OBJ-libwr
:=
$D
/fsm-table.o
\
$D
/state-listening.o
\
$D
/state-master.o
\
$D
/state-slave.o
\
$D
/common-fun.o
\
...
...
proto-ext-whiterabbit/hooks.c
View file @
6ab0c121
...
...
@@ -26,9 +26,17 @@ static int wr_open(struct pp_instance *ppi, struct pp_runtime_opts *rt_opts)
return
0
;
}
static
int
wr_listening
(
struct
pp_instance
*
ppi
,
unsigned
char
*
pkt
,
int
plen
)
{
struct
wr_dsport
*
wp
=
WR_DSPOR
(
ppi
);
wp
->
wrMode
=
NON_WR
;
wp
->
wrPortState
=
WRS_IDLE
;
return
0
;
}
struct
pp_ext_hooks
pp_hooks
=
{
.
init
=
wr_init
,
.
open
=
wr_open
,
.
listening
=
wr_listening
,
};
proto-ext-whiterabbit/state-listening.c
deleted
100644 → 0
View file @
5b23d9ed
/*
* Aurelio Colosimo for CERN, 2011 -- GNU LGPL v2.1 or later
* Based on PTPd project v. 2.1.0 (see AUTHORS for details)
*/
#include <ppsi/ppsi.h>
#include <ppsi/diag.h>
#include "common-fun.h"
#include "wr-api.h"
int
pp_listening
(
struct
pp_instance
*
ppi
,
unsigned
char
*
pkt
,
int
plen
)
{
int
e
=
0
;
/* error var, to check errors in msg handling */
if
(
ppi
->
is_new_state
)
{
DSPOR
(
ppi
)
->
portState
=
PPS_LISTENING
;
WR_DSPOR
(
ppi
)
->
wrMode
=
NON_WR
;
WR_DSPOR
(
ppi
)
->
wrPortState
=
WRS_IDLE
;
st_com_restart_annrec_timer
(
ppi
);
}
if
(
st_com_check_record_update
(
ppi
))
goto
state_updated
;
if
(
plen
==
0
)
goto
no_incoming_msg
;
switch
(
ppi
->
msg_tmp_header
.
messageType
)
{
case
PPM_ANNOUNCE
:
e
=
st_com_master_handle_announce
(
ppi
,
pkt
,
plen
);
break
;
case
PPM_SYNC
:
e
=
st_com_master_handle_sync
(
ppi
,
pkt
,
plen
);
break
;
default:
/* disreguard, nothing to do */
break
;
}
no_incoming_msg:
if
(
e
==
0
)
e
=
st_com_execute_slave
(
ppi
,
0
);
if
(
e
!=
0
)
ppi
->
next_state
=
PPS_FAULTY
;
state_updated:
/* Leaving this state */
if
(
ppi
->
next_state
!=
ppi
->
state
)
pp_timer_stop
(
ppi
->
timers
[
PP_TIMER_ANN_RECEIPT
]);
ppi
->
next_delay
=
PP_DEFAULT_NEXT_DELAY_MS
;
return
0
;
}
proto-standard/state-listening.c
View file @
6ab0c121
...
...
@@ -11,6 +11,11 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
int
e
=
0
;
/* error var, to check errors in msg handling */
if
(
pp_hooks
.
listening
)
e
=
pp_hooks
.
listening
(
ppi
,
pkt
,
plen
);
if
(
e
)
goto
no_incoming_msg
;
if
(
ppi
->
is_new_state
)
{
DSPOR
(
ppi
)
->
portState
=
PPS_LISTENING
;
st_com_restart_annrec_timer
(
ppi
);
...
...
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