-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFsm.java
More file actions
47 lines (41 loc) · 985 Bytes
/
Fsm.java
File metadata and controls
47 lines (41 loc) · 985 Bytes
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
package bfd.fsm;
/**
* This class keeps track of the current state of the BFD session by
* implementing the FSM described in the BFD rfc document
*
* @author angelos
*/
public class Fsm {
int state=1;
void Fsm(){
state=1;
}
void RecievedUp(){
if (state==1) state=1;
if (state==2) state=3;
if (state==3) state=3;
}
void RecievedDown(){
if (state==1) state=2;
if (state==2) state=2;
if (state==3) state=1;
}
void RecievedInit(){
if (state==1) state=3;
if (state==2) state=3;
if (state==3) state=3;
}
void RecievedTimer(){
if (state==1) state=1;
if (state==2) state=1;
if (state==3) state=1;
}
void RecievedAdminDown(){
if (state==1) state=0;
if (state==2) state=0;
if (state==3) state=0;
}
int getCurrentState(){
return state;
}
}