File: unicast_fsm.c

package info (click to toggle)
linuxptp 4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,536 kB
  • sloc: ansic: 26,119; sh: 92; makefile: 87
file content (86 lines) | stat: -rw-r--r-- 2,007 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
 * @file unicast_fsm.c
 * @brief Unicast client state machine
 * @note Copyright (C) 2018 Richard Cochran <richardcochran@gmail.com>
 *
 * 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;
}