1/*
2 * FSM pseudo code used in the design/implementation of the CC Q.SIG agent.
3 */
4FSM CC_QSIG_Agent
5{
6	State CC_STATE_IDLE {
7		Init {
8		}
9		Prolog {
10			Action Set_Selfdestruct;
11		}
12		Stimulus CC_EVENT_AVAILABLE {
13			Next_State CC_STATE_AVAILABLE;
14		}
15		Stimulus CC_EVENT_CANCEL {
16			Action Set_Selfdestruct;
17		}
18	}
19	State CC_STATE_AVAILABLE {
20		/*
21		 * For Q.SIG mode the T_RETENTION timer is not defined.  However,
22		 * we will use it anyway in this state to protect our resources
23		 * from leaks caused by user A not requesting CC.  This timer
24		 * should be set much longer than the PTMP network link to
25		 * allow for variations in user A's CC offer timer.
26		 */
27		Epilog {
28			Action Stop_T_RETENTION;
29		}
30		Stimulus CC_EVENT_MSG_RELEASE {
31			Action Stop_T_RETENTION;
32			Action Start_T_RETENTION;
33		}
34		Stimulus CC_EVENT_MSG_RELEASE_COMPLETE {
35			Action Stop_T_RETENTION;
36			Action Start_T_RETENTION;
37		}
38		Stimulus CC_EVENT_CC_REQUEST {
39			Action Pass_Up_CC_Request;
40			/* Send Q931_CALL_PROCEEDING message on signaling link. */
41			Action Send_Call_Proceeding;
42			Next_State CC_STATE_REQUESTED;
43		}
44		Stimulus CC_EVENT_INTERNAL_CLEARING {
45			Action Stop_T_RETENTION;
46			Action Start_T_RETENTION;
47		}
48		Stimulus CC_EVENT_TIMEOUT_T_RETENTION {
49			Action Pass_Up_CC_Cancel;
50			Next_State CC_STATE_IDLE;
51		}
52		Stimulus CC_EVENT_CANCEL {
53			Next_State CC_STATE_IDLE;
54		}
55	}
56	State CC_STATE_REQUESTED {
57		Stimulus CC_EVENT_CC_REQUEST_ACCEPT {
58			Next_State CC_STATE_ACTIVATED;
59		}
60		Stimulus CC_EVENT_SIGNALING_GONE {
61			/* Signaling link cleared. */
62			Action Pass_Up_CC_Cancel;
63			Next_State CC_STATE_IDLE;
64		}
65		Stimulus CC_EVENT_CANCEL {
66			Action Hangup_Signaling_Link;
67			Next_State CC_STATE_IDLE;
68		}
69	}
70	State CC_STATE_WAIT_DESTRUCTION {
71		/*
72		 * Delayed disconnect of the signaling link to allow subcmd events
73		 * from the signaling link to be passed up.
74		 */
75		Stimulus CC_EVENT_SIGNALING_GONE {
76			/* Signaling link cleared. */
77			Next_State CC_STATE_IDLE;
78		}
79		Stimulus CC_EVENT_HANGUP_SIGNALING {
80			Action Hangup_Signaling_Link;
81			Next_State CC_STATE_IDLE;
82		}
83	}
84	State CC_STATE_ACTIVATED {
85		Stimulus CC_EVENT_REMOTE_USER_FREE {
86			/* Send ccExecPossible in FACILITY or SETUP. */
87			Action Send_RemoteUserFree;
88			Next_State CC_STATE_WAIT_CALLBACK;
89		}
90	}
91	State CC_STATE_WAIT_CALLBACK {
92		Stimulus CC_EVENT_SUSPEND {
93			/* Received ccSuspend */
94			Action Set_A_Status_Busy;
95			Action Pass_Up_A_Status;
96			Next_State CC_STATE_SUSPENDED;
97		}
98		Stimulus CC_EVENT_RECALL {
99			/* Received ccRingout */
100			Action Pass_Up_CC_Call;
101			Action Set_Original_Call_Parameters;
102		}
103	}
104	State CC_STATE_SUSPENDED {
105		Stimulus CC_EVENT_RESUME {
106			/* Received ccResume */
107			Action Set_A_Status_Free;
108			Action Pass_Up_A_Status;
109			Next_State CC_STATE_ACTIVATED;
110		}
111	}
112	Superstate CC_ACTIVE(CC_STATE_ACTIVATED, CC_STATE_WAIT_CALLBACK, CC_STATE_SUSPENDED) {
113		Prolog {
114			/* Start QSIG_CCBS_T2/QSIG_CCNR_T2 depending upon CC mode. */
115			Action Start_T_SUPERVISION;
116		}
117		Epilog {
118			Action Stop_T_SUPERVISION;
119		}
120		Stimulus CC_EVENT_TIMEOUT_T_SUPERVISION {
121			Action Pass_Up_CC_Cancel;
122			Action Send_CC_Cancel;
123			Next_State CC_STATE_IDLE;
124		}
125		Stimulus CC_EVENT_SIGNALING_GONE {
126			/* Signaling link cleared. */
127			Action Disassociate_Signaling_Link;
128		}
129		Stimulus CC_EVENT_LINK_CANCEL {
130			/* Received ccCancel */
131			Action Pass_Up_CC_Cancel;
132			Action Post_HANGUP_SIGNALING;
133			Next_State CC_STATE_WAIT_DESTRUCTION;
134		}
135		Stimulus CC_EVENT_CANCEL {
136			Action Send_CC_Cancel;
137			Next_State CC_STATE_IDLE;
138		}
139	}
140}
141