/********************************************************************
Copyright ?2007 LGC Wireless, Inc. All rights reserved
File Name: 		aifg.h
Description:	API Definition of AIFG module 
Version:		v9.0.0
Author:			Roy Jiang
Create Date:	2007-3-6

History:
2007-3-6		v9.0.0	Create
2007-7-7		v9.0.1	Remove Block/Unblock/Reset/Reset CC/Overload/HO Can. Enq. API, 
						replace with aifg_send
*********************************************************************/
#ifndef _WXC2_AIFG_H
#define _WXC2_AIFG_H
#include "aifg_msg.h"

/*******************************SAP Management**********************************/
/*
Name: 		aifg_bind
Purpose:	Request to create a SAP in AIFG module.
Input:		aifg_sap_type type:	type of upper layer entity 
			int opc:OPC of upper layer entity.
			aifg_ni ni:	NI of upper layer entity.
Output:		SAP id
*/
int aifg_bind(aifg_sap_type type, int (*callback)(aifg_indication, aifg_msg_pre_decoded *));

/*
Name: 		aifg_modify
Purpose:	Request to modify the SAP parameter in AIFG module.
Input:		aifg_sap_type type:	type of upper layer entity 
			int opc:	new OPC, -1 if no need to modify
			aifg_ni ni:new NI, -1 if no need to modify
			aifg_callback_func *callback:	new callback functions, null if no need to modify
Output:		none
*/
void aifg_modify(aifg_sap_type type, int (*callback)(aifg_indication, aifg_msg_pre_decoded *));

/*
Name: 		aifg_set_running_mode
Purpose:	Set the running mode of AIFG module.
Input:		enum aifg_run_mode mode:	running mode, 0 - single, 1 - dual
			int alter_ip:IP address of the alternative server, hex format
Output:		None
*/
void aifg_set_running_mode(aifg_run_mode mode);

/*
Name: 		aifg_createCircuitGroup
Purpose:	Request to create a circuit group in AIFG module.
Input:		int sapid: SAP ID of upper layer entity
			int dpc:	DPC of the circuit group.
			aifg_ni ni: NI of the circuit group.
Output:		Circuit Group ID - Upper layer entity should record this ID and pass it to AIFG module 
			whenever it request to send a message through this circuit group
			-1: Create failed
*/
int aifg_createCircuitGroup(int sapid, int dpc, aifg_ni ni, int tgid);

/*
Name: 		aifg_modCircuitGroup
Purpose:	Request to modify the parameter of a circuit group in AIFG module.
Input:		int sapid: SAP ID of upper layer entity
			int cgid:	Circuit Group ID
			int dpc:	new DPC of the circuit group, -1 if no need to change.
			enum aifg_ni:	new NI of the circuit group, -1 if no need to change.
Output:		Circuit Group ID - Upper layer entity should record this ID and pass it to AIFG module 
			whenever it request to send a message through this circuit group
*/
int aifg_modCircuitGroup(int sapid, int cgid, int dpc, int ni);

/*
Name: 		aifg_delCircuitGroup
Purpose:	Request to delete a circuit group in AIFG module.
Input:		int sapid: SAP ID of upper layer entity
			int cgid: Circuit Group ID
Output:		None
*/
void aifg_delCircuitGroup(int sapid, int cgid);

/*
Name: 		aifg_send
Purpose:	Request to send a message through A-interface.
Input:		int sapid: SAP ID of upper layer entity.
			int cgid: Circuit Group ID
			int u_port: process port of upper layer entity
			aifg_msg *msg: content of assign request message
Output:		0 - succeed
			-1 - failed
			-2 - failed, circuit group not ready
*/
int aifg_send(int sapid, int cgid, int u_port, aifg_msg_t *msg);

/*
Name: 		aifg_paging
Purpose:	Request to paging. 
Input:		int sapid: SAP ID of upper layer entity
			int cgid: Circuit Group ID
			int u_port: process port of upper layer entity
			aifg_msg_bm_paging *msg: paging message
Output:		0 - succeed
			-1 - failed
			-2 - failed, circuit group not ready
*/
int aifg_paging(int sapid, int cgid, int u_port, aifg_msg_t *msg);

/*
Name: 		aifg_ie_decode
Purpose:	Information element decode function
Input:		aifg_msg_protocol protocol: BSSMAP or DTAP
			aifg_pre_decoded_ie *pre_decoded: pre-decoded IE structure
			aifg_ie *dst: pointer to a aifg_ie structure object in which the decoded message will be stored.
Output:		Total length of decoded IE
*/
int aifg_ie_decode(aifg_ie_ptr *pre_decoded, aifg_ie *dst);

#endif
