rem: "internal error",
add: "internal error"
context: int session_state_machine( struct session *ses, enum AAA_EVENTS event,															AAAMessage *msg){	static char *err_msg[]= {		"no error"		"event - state mismatch",		"unknown type event",		"unknown peer_identity type",		"internal error",	};	int error_code=0;	DBG("DEBUG:session_state_machine: session %p, state = %d, event=%d\n",		ses,ses->state,event);	switch(ses->peer_identity) {		case AAA_CLIENT:			/* I am server, I am all the time statefull ;-) */			break;		case AAA_SERVER_STATELESS:			/* I am client to a stateless server */			switch( event ) {				case AAA_SEND_AR:					/* an auth request has to be sent */					lock_get( ses->mutex );					switch(ses->state) {						case AAA_IDLE_STATE:							/* send out the message */							if (send_request(msg)==-1) {								lock_release( ses->mutex );								error_code = 4;								goto error;							}							ses->state = AAA_PENDING_STATE;							lock_release( ses->mutex );							break;						default:							lock_release( ses->mutex );							error_code = 1;							goto error;					}					break;				case AAA_AA_RECEIVED:					/* an auth answer was received */					lock_get( ses->mutex );					switch(ses->state) {						case AAA_PENDING_STATE:							/* check the session state advertise by server */							if (msg->auth_ses_state && SESSION_STATE_MAINTAINED							==avp2int(msg->auth_ses_state) )								ses->peer_identity = AAA_SERVER_STATEFULL;							/* new state */							if ( avp2int(msg->res_code)== AAA_SUCCESS)								ses->state = AAA_OPEN_STATE;							else								ses->state = AAA_IDLE_STATE;							lock_release( ses->mutex );							break;						default:							lock_release( ses->mutex );							error_code = 1;							goto error;					}					break;				case AAA_SESSION_TIMEOUT:					/* session timeout was generated */					switch(ses->state) {						case AAA_OPEN_STATE:							/* Disconnect user/device */							/* Destroy session ???? */							// TO DO							ses->state = AAA_IDLE_STATE;							break;						default:							error_code = 1;							goto error;					}					break;				default:					error_code = 2;					goto error;			}			break;		case AAA_SERVER_STATEFULL:			/* I am client to a statefull server */			switch( event ) {				case AAA_SEND_AR:					/* an re-auth request was sent */					switch(ses->state) {						case AAA_OPEN_STATE:							/* update all the needed information from AR */							//TO DO							ses->state = AAA_OPEN_STATE;							break;						default:							error_code = 1;							goto error;					}					break;				case AAA_AA_RECEIVED:					/* a re-auth answer was received */					switch(ses->state) {						case AAA_OPEN_STATE:							/* provide service or , if failed, disconnnect */							//TO DO							break;						default:							error_code = 1;							goto error;					}					break;				case AAA_SESSION_TIMEOUT:					/* session timeout was generated */					switch(ses->state) {						case AAA_OPEN_STATE:							/* send STR */							//TO DO							ses->state = AAA_DISCON_STATE;							break;						default:							error_code = 1;							goto error;					}					break;				case AAA_ASR_RECEIVED:					/* abort session request received */					switch(ses->state) {						case AAA_OPEN_STATE:							/* send ASA and STR */							// if user wants ????							// TO DO 							ses->state = AAA_DISCON_STATE;							break;						case AAA_DISCON_STATE:							/* send ASA */							// TO DO 							ses->state = AAA_DISCON_STATE;							break;						default:							error_code = 1;							goto error;					}					break;				case AAA_STA_RECEIVED:					/* session terminate answer received  */					switch(ses->state) {						case AAA_DISCON_STATE:							/* disconnect user/device */							// destroy session ??							// TO DO							ses->state = AAA_IDLE_STATE;							break;						default:							error_code = 1;							goto error;					}					break;				default:					error_code = 2;					goto error;			}			break;		default:			error_code = 3;			goto error;	}	DBG("DEBUG:session_state_machine: session %p, new state = %d\n",		ses,ses->state);	return 1;error:	LOG(L_ERR,"ERROR:session_state_machine: %s : session=%p, peer_identity=%d,"		"state=%d, event=%d\n",err_msg[error_code],		ses,ses->peer_identity,ses->state,event);	return -1;}