-
Notifications
You must be signed in to change notification settings - Fork 2
/
fsm_example.h
85 lines (78 loc) · 3.31 KB
/
fsm_example.h
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
/* Copyright (C) January 2014, Leonid Chernin & Evgeny Yoshpe
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LAG_FSM_H
#define _LAG_FSM_H
/* only example - ConcreteTimer is real object that aggregates TimerMngr.
* InitFunc fills pointers to functions by values of real functions.
* Framework will work with these functions. */
/*#$*/
#include "fsm_tool_framework.h"
/*----------------------------------------------------------------
Generated enumerator for States of FSM
---------------------------------------------------------------*/
enum lag_fsm_states_t{
lag_fsm_idle = 0,
lag_fsm_admin_down = 1,
lag_fsm_admin_up = 2,
lag_fsm_lag_down = 3,
lag_fsm_wait_lag_up = 4,
lag_fsm_lag_up = 5,
lag_fsm_condit1 = 6,
lag_fsm_mismatch = 7,
};
struct lag_fsm;
/*----------------------------------------------------------------
Events of FSM
---------------------------------------------------------------*/
int lag_fsm_start_ev(struct lag_fsm * fsm);
int lag_fsm_port_up_ev(struct lag_fsm * fsm, int lacp_enable, int* port_id);
int lag_fsm_port_down_ev(struct lag_fsm * fsm);
int lag_fsm_lacp_up_ev(struct lag_fsm * fsm, int* port_id);
int lag_fsm_lacp_down_ev(struct lag_fsm * fsm, int* port_id);
int lag_fsm_mismatch_ev(struct lag_fsm * fsm, int* port_id);
int lag_fsm_admin_on_ev(struct lag_fsm * fsm);
int lag_fsm_admin_off_ev(struct lag_fsm * fsm);
/*----------------------------------------------------------------
Getters for each State
---------------------------------------------------------------*/
tbool lag_fsm_idle_in(struct lag_fsm *fsm);
tbool lag_fsm_admin_down_in(struct lag_fsm *fsm);
tbool lag_fsm_admin_up_in(struct lag_fsm *fsm);
tbool lag_fsm_lag_down_in(struct lag_fsm *fsm);
tbool lag_fsm_wait_lag_up_in(struct lag_fsm *fsm);
tbool lag_fsm_lag_up_in(struct lag_fsm *fsm);
tbool lag_fsm_condit1_in(struct lag_fsm *fsm);
tbool lag_fsm_mismatch_in(struct lag_fsm *fsm);
/*----------------------------------------------------------------
Constructor of FSM
---------------------------------------------------------------*/
int lag_fsm_init(struct lag_fsm *fsm, fsm_user_trace user_trace, void * sched_func, void * unsched_func);
/*###############################################################
###### declaration of FSM #########
//################################################################*/
typedef struct lag_fsm
{
struct fsm_base base;
struct fsm_tm_base tm;
int state_timer[8];
/*----------------------------------------------------------------
Private attributes :
---------------------------------------------------------------*/
/*#$*/
int lag;
/*#$*/
} lag_fsm;
/*#$*/
#endif // _LAG_FSM_H