forked from richardcochran/linuxptp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce the unicast client finite state machine.
In order to implement client side unicast negotiation, state is needed per port and master. This patch adds the needed state machines. Signed-off-by: Richard Cochran <[email protected]>
- Loading branch information
1 parent
e22dc6b
commit 0fffa6c
Showing
4 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* @file unicast_fsm.c | ||
* @brief Unicast client state machine | ||
* @note Copyright (C) 2018 Richard Cochran <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. | ||
*/ | ||
#include "unicast_fsm.h" | ||
|
||
enum unicast_state unicast_fsm(enum unicast_state state, enum unicast_event ev) | ||
{ | ||
enum unicast_state next = state; | ||
|
||
switch (state) { | ||
case UC_WAIT: | ||
switch (ev) { | ||
case UC_EV_GRANT_ANN: | ||
next = UC_HAVE_ANN; | ||
break; | ||
case UC_EV_SELECTED: | ||
case UC_EV_GRANT_SYDY: | ||
case UC_EV_UNSELECTED: | ||
case UC_EV_CANCEL: | ||
break; | ||
} | ||
break; | ||
case UC_HAVE_ANN: | ||
switch (ev) { | ||
case UC_EV_GRANT_ANN: | ||
break; | ||
case UC_EV_SELECTED: | ||
next = UC_NEED_SYDY; | ||
break; | ||
case UC_EV_GRANT_SYDY: | ||
case UC_EV_UNSELECTED: | ||
break; | ||
case UC_EV_CANCEL: | ||
next = UC_WAIT; | ||
break; | ||
} | ||
break; | ||
case UC_NEED_SYDY: | ||
switch (ev) { | ||
case UC_EV_GRANT_ANN: | ||
case UC_EV_SELECTED: | ||
break; | ||
case UC_EV_GRANT_SYDY: | ||
next = UC_HAVE_SYDY; | ||
break; | ||
case UC_EV_UNSELECTED: | ||
next = UC_HAVE_ANN; | ||
break; | ||
case UC_EV_CANCEL: | ||
next = UC_WAIT; | ||
break; | ||
} | ||
break; | ||
case UC_HAVE_SYDY: | ||
switch (ev) { | ||
case UC_EV_GRANT_ANN: | ||
case UC_EV_SELECTED: | ||
case UC_EV_GRANT_SYDY: | ||
break; | ||
case UC_EV_UNSELECTED: | ||
next = UC_HAVE_ANN; | ||
break; | ||
case UC_EV_CANCEL: | ||
next = UC_WAIT; | ||
break; | ||
} | ||
break; | ||
} | ||
return next; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* @file unicast_fsm.h | ||
* @brief Unicast client state machine | ||
* @note Copyright (C) 2018 Richard Cochran <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. | ||
*/ | ||
#ifndef HAVE_UNICAST_FSM_H | ||
#define HAVE_UNICAST_FSM_H | ||
|
||
enum unicast_state { | ||
UC_WAIT, | ||
UC_HAVE_ANN, | ||
UC_NEED_SYDY, | ||
UC_HAVE_SYDY, | ||
}; | ||
|
||
enum unicast_event { | ||
UC_EV_GRANT_ANN, | ||
UC_EV_SELECTED, | ||
UC_EV_GRANT_SYDY, | ||
UC_EV_UNSELECTED, | ||
UC_EV_CANCEL, | ||
}; | ||
|
||
enum unicast_state unicast_fsm(enum unicast_state state, enum unicast_event ev); | ||
|
||
#endif |