⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmppe_proto.h

📁 本人为友邦软件公司做的短信发送程序
💻 H
字号:
#ifndef _CMPP_EXT_PROTO_H
#define _CMPP_EXT_PROTO_H

#ifdef __cplusplus
extern "C"{
#endif

#define		CMPPE_MAX_ISMG_ID_LEN		6
#define		CMPPE_MAX_ICP_ID_LEN		6
#define		CMPPE_MAX_LOCALE_LEN		4
#define		CMPPE_AUTH_LEN			16	
#define		CMPPE_MAX_SVC_LEN		10
#define		CMPPE_MAX_SVC_ID_LEN		6
#define		CMPPE_DATETIME_LEN		16
#define		CMPPE_MAX_DSTS_NUM		100
#define		CMPPE_MAX_MSGID_LEN		64
#define		CMPPE_MAX_MSISDN_LEN		20
#define		CMPPE_MAX_SM_LEN		160
#define		CMPPE_MBS_MAX_BYTES		140
#define		CMPPE_MAX_MSISDN_LEN		20
#define 	CMPPE_DATE_TIME_LEN		14
#define		CMPPE_LOGIN_BODY_LEN		29

#define		CMPPE_MAX_PRIORITY		9
#define		CMPPE_MIN_PRIORITY		0

#define		CMPPE_MAX_FEE_TYPE		99
#define		CMPPE_MAX_INFO_FEE		999999

#define		CMPPE_PK_HEAD_SIZE		16
#define		CMPPE_PK_LEN_SIZE		4
#define		CMPPE_MIN_PK_SIZE		CMPPE_PK_HEAD_SIZE		
#define		CMPPE_MAX_PK_SIZE		2477	/*forward-submit*/
#define		CMPPE_MAX_ICPMO_ID_LEN		20
#define		CMPPE_MAX_ICPMO_PASSWD_LEN	20
#define		CMPPE_MAX_SERVICES		10

#define		CMPPE_V11			0x11
#define 	CMPPE_V12			0x12
#define		CMPPE_OV			0x00
#define		CMPPE_MAX_VERSION		CMPPE_V12

#define		CMPPE_MAX_FUTYPE		0x03
#define		CMPPE_MAX_FEETYPE		0x05

#define		CMPPE_FRG			0x01
#define		CMPPE_FMC			0x02
#define		CMPPE_FSTK			0x04
#define		CMPPE_FUDHI			0x08

enum{
	CMPPE_FUT_DU	= 0,
	CMPPE_FUT_SU	= 1,
	CMPPE_FUT_SP	= 2,
	CMPPE_FUT_NU	= 3
};
enum{
	CMPPE_BIND_SEND		= 0,
	CMPPE_BIND_RECV		= 1,
	CMPPE_BIND_SENDRECV	= 2
};

enum{
	CMPPE_DC_ASCII	= 0,
	CMPPE_DC_STK	= 3,
	CMPPE_DC_BIN	= 4,
	CMPPE_DC_UCS2	= 8,
	CMPPE_DC_GB2312	= 15
};


/*
计费用户类型字段,0:对目的终端MSISDN计费;1:对源终端MSISDN计费;
2:对SP计费;3:表示本字段无效,对谁计费参见Fee_terminal_id字段。
*/
enum{
	FEE_DST_MSISDN		= 0,
	FEE_SRC_MSISDN		= 1,
	FEE_SP_MSISDN		= 2,
	FEE_USR_MSISDN		= 3
};

enum{
	CMPPE_NACK_RESP		= 0x80000000L,
	CMPPE_LOGIN		= 0x00000001L,
	CMPPE_LOGIN_RESP	= 0x80000001L,
	CMPPE_LOGOUT		= 0x00000002L,
	CMPPE_LOGOUT_RESP	= 0x80000002L,
	CMPPE_ROUTE		= 0x00000003L,
	CMPPE_ROUTE_RESP	= 0x80000003L,
	CMPPE_SUBMIT		= 0x00000004L,
	CMPPE_SUBMIT_RESP	= 0x80000004L,
	CMPPE_DELIVER		= 0x00000005L,
	CMPPE_DELIVER_RESP	= 0x80000005L,
	CMPPE_QUERY		= 0x00000006L,
	CMPPE_QUERY_RESP	= 0x80000006L,
	CMPPE_CANCEL		= 0x00000007L,
	CMPPE_CANCEL_RESP	= 0x80000007L,
	CMPPE_ACTIVE		= 0x00000008L,
	CMPPE_ACTIVE_RESP	= 0x80000008L,
	CMPPE_FWD_SUBMIT 	= 0x00000009L,
	CMPPE_FWD_SUBMIT_RESP	= 0x80000009L,
	CMPPE_FWD_DELIVER	= 0x0000000AL,
	CMPPE_FWD_DELIVER_RESP	= 0x8000000AL,
	CMPPE_ICPMO_LOGIN       = 0x0000000BL,
        CMPPE_ICPMO_LOGIN_RESP  = 0x8000000BL,
        CMPPE_ICPMO_REQ         = 0x0000000CL,
        CMPPE_ICPMO_REQ_RESP    = 0x8000000CL,
        CMPPE_ICPMO_LOGOUT      = 0x0000000DL,
        CMPPE_ICPMO_LOGOUT_RESP = 0x8000000DL
};


enum{
	CMPPE_ROUTE_REGIST		= 1,
	CMPPE_ROUTE_MODIFY_SERVICE	= 2,
	CMPPE_ROUTE_SUBMIT_SERVICE	= 3
};


/***
 * @define the CMPPE packet type
 */
typedef struct cmppe_head		cmppe_head;
//typedef struct cmppe_packet		cmppe_packet;

typedef struct cmppe_login		cmppe_login;
typedef struct cmppe_submit		cmppe_submit;
typedef struct cmppe_submit_m		cmppe_submit_m;
typedef struct cmppe_deliver		cmppe_deliver;
typedef struct cmppe_err_rpt		cmppe_err_rpt;
typedef struct cmppe_cancel		cmppe_cancel;
typedef struct cmppe_deliver_rpt	cmppe_deliver_rpt;
typedef	struct cmppe_login_resp		cmppe_login_resp;
typedef	struct cmppe_submit_resp	cmppe_submit_resp;
/***
 * @define the CMPPE packet struct
 */

struct cmppe_head{
	dpl_uint32_t	pk_len;
	dpl_uint32_t	pk_cmd;
	dpl_uint32_t	pk_stat;
	dpl_uint32_t	pk_seq;
};

/*
struct cmppe_packet{
	cmppe_head		pk_head;
	char			pk_body	[CMPPE_MAX_PK_SIZE+1];
};
*/

struct cmppe_login{
	char			icp_id[CMPPE_MAX_ICP_ID_LEN+1];		/* ICP ID */
	char			icp_auth[CMPPE_AUTH_LEN+1];		/* MD5加密授权码 */
	dpl_uint8_t		icp_bind_type;				/* 连接类型 */
	dpl_uint8_t		if_version;				/* 版本号 0x12*/
	dpl_uint32_t		icp_timestamp;				/* 时间戳 */
};

struct cmppe_login_resp{
	dpl_uint8_t		if_version;				/* 最高版本*/
	char			ismg_auth[CMPPE_AUTH_LEN+1];		/* ISMG MD5 加密授权 */
};

struct cmppe_submit{
	char			icp_id  [CMPPE_MAX_ICP_ID_LEN+1];	/* 服务商代码   */
	char			svc_type[CMPPE_MAX_SVC_LEN+1];		/* 服务类型     */
	dpl_uint8_t		fee_type;				/* 计费类型     */
	dpl_uint32_t		info_fee;				/* 信息费       */
	dpl_uint8_t		proto_id;				/* 协议ID GSM3.4*/
	dpl_uint8_t		msg_mode;				/* 消息模式	*/
	dpl_uint8_t		priority;				/* 优先级别     */
	char			validate[CMPPE_DATETIME_LEN+1];		/* 过期时间     */
	char			schedule[CMPPE_DATETIME_LEN+1];		/* 调度时间     */
	dpl_uint8_t		fee_utype;				/* 计费用户类型 */
	char			fee_user [CMPPE_MAX_MSISDN_LEN+1];	/* 被计费的用户 */
	char			src_addr [CMPPE_MAX_MSISDN_LEN+1];	/* 源用户	*/
	dpl_uint8_t		du_count;				/* 目的数量	*/
	char			dst_addr[CMPPE_MAX_DSTS_NUM][CMPPE_MAX_MSISDN_LEN+1];	/* 目的用户	*/
	dpl_uint8_t		data_coding;				/* 数据编码     */
	dpl_uint8_t		sm_len;					/* 消息长度     */
	char			short_msg[CMPPE_MAX_SM_LEN+1];		/* 短消息内容   */
};

typedef struct cmppe_us_user cmppe_us_user;
struct	cmppe_us_user{
	dpl_uint8_t	index;						/* 用户索引     */
	dpl_uint8_t	stat;						/* 错误状态     */
};
struct cmppe_submit_resp{
	char			msg_id	[CMPPE_MAX_MSGID_LEN+1];	/* 消息标识	*/
	dpl_uint8_t		us_count;				/* 不成功数量	*/
	cmppe_us_user		us_user[CMPPE_MAX_DSTS_NUM];				/* 不成功列表	*/
};
struct cmppe_deliver_rpt{
	char			msg_id      [CMPPE_MAX_MSGID_LEN+1];	/* 消息标识 */
	dpl_uint8_t		final_status;				/* 最终状态 */
	char			submit_date [CMPPE_DATE_TIME_LEN+1];	/* 提交时间 */
	char			final_date  [CMPPE_DATE_TIME_LEN+1];	/* 完成时间 */
};
struct cmppe_deliver{
	char			src_addr [CMPPE_MAX_MSISDN_LEN+1];	/* 发起用户 */
	char			dst_addr [CMPPE_MAX_MSISDN_LEN+1];	/* 目的用户 */
	char			svc_type [CMPPE_MAX_SVC_LEN+1];		/* 服务类型 */
	dpl_uint8_t		proto_id;				/* 协议标识 */
	dpl_uint8_t		status_rpt;				/* 消息模式 */
	dpl_uint8_t		priority;				/* 优先级别 */
	dpl_uint8_t		data_coding;				/* 数据编码 */
	dpl_uint8_t		sm_len;					/* 消息长度 */
        union{
                char			short_msg[CMPPE_MAX_SM_LEN+1];
                cmppe_deliver_rpt	sm_rpt;
        }pk_sm;
};
struct cmppe_cancel{
	char			msg_id	[CMPPE_MAX_MSGID_LEN+1];
};





#define CMPPE_IS_NACK_ERR(errcode)	( ((errcode) > CMPPE_RSP_OTHER_ERR)&&((errcode) < 0X10 ))

#define	CMPPE_RSP_SUCCESS		0x00000000L

#define	CMPPE_RSP_OTHER_ERR		0x00000001L

#define CMPPE_RSP_INVAL_MSG_LEN		0x00000002L	/*不合法的消息长度*/
#define CMPPE_RSP_UNKNOWN_CMD		0x00000003L	/*不能识别的命令*/
#define CMPPE_RSP_SYNC_ERR		0x00000004L	/*同步错误*/
#define CMPPE_RSP_INVAL_STRUCT		0x00000005L	/*不合法的消息结构*/

#define CMPPE_RSP_INVAL_ICP		0x00000010L	/* 不合法的ICP_ID */
#define CMPPE_RSP_INVAL_AUTH		0x00000011L	/* 不合法的ICP授权 */
#define CMPPE_RSP_INVAL_BIND_TYPE	0x00000012L	/* 不合法的绑定类型 */
#define	CMPPE_RSP_BINDED		0x00000013L	/* 已经正确BIND */
#define CMPPE_RSP_BIND_EXCEED		0x00000014L	/* 超过最大允许连接数*/
#define CMPPE_RSP_NOT_BIND		0x00000015L	/* 尚未正确Bind */
#define CMPPE_RSP_INVAL_VERSION		0x00000016L	/* 不正确的版本 */

#define	CMPPE_RSP_INVAL_MSG_MODE	0x00000020L	/*不合法的消息模式*/
#define CMPPE_RSP_INVAL_DATA_CODING	0x00000021L	/*不合法的数据编码*/
#define	CMPPE_RSP_INVAL_SVC_TYPE	0x00000022L	/*不合法的服务类型*/
#define CMPPE_RSP_INVAL_FEE_TYPE	0x00000023L	/*不合法的计费类型*/
#define CMPPE_RSP_INVAL_DATETIME	0x00000024L	/*不合法的日期格式*/
#define CMPPE_RSP_DSTS_EXCEED		0x00000025L	/*目标地址数量过多*/
#define CMPPE_RSP_SMLEN_EXCEED		0x00000026L	/*短消息过长*/
#define CMPPE_RSP_INVAL_MSISDN		0x00000027L	/*不合法的msisdn*/
#define CMPPE_RSP_INVAL_PARA		0x00000028L	/*不合法的参数*/
#define CMPPE_RSP_DST_ADDR_UNKNOWN	0x00000029L	/*没有目的地址*/
#define CMPPE_RSP_NO_RIGHT		0x0000002AL	/*没有权限*/
#define CMPPE_RSP_NO_ROUTE		0x0000002BL	/*找不到路由*/
#define CMPPE_RSP_SYS_ERR		0x0000002CL	/*系统错误*/
#define CMPPE_RSP_INFO_FEE_EXCEED	0x0000002DL	/*信息费过大*/
#define CMPPE_RSP_SCHEDULE_EXCEED	0x0000002EL	/*定时发送时间太大*/
#define CMPPE_RSP_MQ_FULL		0x0000002FL	/*发送队列满*/

#define CMPPE_RSP_SRC_ADDR_UNKNOWN	0x00000030L	/*不合法的源地址 */
#define CMPPE_RSP_INVAL_FUTYPE		0x00000031L	/*不合法的计费用户类型*/
#define CMPPE_RSP_INVAL_FEEUSR		0x00000032L	/*不合法的计费用户*/

#define CMPPE_RSP_INVAL_MSGID		0x00000040L	/*不合法的消息标识*/
#define CMPPE_RSP_PK_SEQ_REPEAT		0x00000041L	/*包序号重复*/
#define CMPPE_RSP_PK_SEQ_EXCEED		0x00000042L	/*包序号越界*/
#define CMPPE_RSP_MSG_NOT_FOUND		0x00000043L	/*找不到对应msgid的短消息*/

#define CMPPE_RSP_INVAL_ISMG		0x00000050L	/*不合法的ISMG标识*/
#define CMPPE_RSP_INVAL_DEST_GATEWAY    0x00000051L     /*不合法的目的网关*/
#define CMPPE_RSP_INVAL_STATUS_RPT	0x00000052L	/*不合法的状态报告*/
#define CMPPE_RSP_INVAL_SVC_ID		0x00000053L	/*不合法的服务ID*/
#define CMPPE_RSP_SRC_GATEWAY_UNKNOWN	0x00000054L	/*不合法的源网关*/
#define CMPPE_RSP_SMSC_UNKNOWN		0x00000055L	/*未知SMSC */
#define CMPPE_RSP_INVAL_LOCALE		0x00000056L	/*未知LOCALE */

#define	CMPPE_RPACKET_ERR		0x00000060L	/*收到的消息是错误的消息*/
/***********************************************************/
/***********************************************************/
/***********************************************************/
enum{
	TRANS_CS_CLOSED	= 0,
	TRANS_CS_OPEN	= 1,
	TRANS_CS_BIND	= 2
};
typedef cmppe_login		icp_login;
typedef cmppe_submit		icp_submit;
typedef cmppe_submit_m		icp_submit_m;
typedef cmppe_cancel		icp_cancel;


typedef struct icp_trans	icp_trans;
typedef struct icp_packet	icp_packet;

enum{
	ICP_STAT_WAIT_LOGIN 		,
	ICP_STAT_WAIT_PK    		,
	ICP_STAT_WAIT_ACTIVE_RSP	,
	ICP_STAT_WAIT_DELIV_RSP		
};

struct icp_trans{
	dpl_socket_t	socket;
	dpl_uint32_t	sequence;
	dpl_uint32_t	icp_seq;
	dpl_uint8_t	mode;
	dpl_uint8_t	status;
	dpl_uint8_t	stat;
	dpl_uint8_t	version;
	char		icp_id[CMPPE_MAX_ICP_ID_LEN+1];
};

struct icp_packet{
	dpl_uint32_t	pk_cmd;
	dpl_uint32_t	pk_seq;
	dpl_uint32_t	pk_stat;
	union{
		icp_login		login_body;	
		icp_submit		submit_body;
		icp_cancel		cancel_body;
	}pk_data;
};


typedef struct cmppe_packet		cmppe_packet;
struct cmppe_packet{
	cmppe_head	pk_head;	/*接收到的包头信息*/
	dpl_int32_t	result;		/*表明解析该包的结果*/ 
	union{
		cmppe_deliver		pk_deliver;
		cmppe_login_resp	pk_login_resp;
		cmppe_submit_resp	pk_submit_resp;
	}pk_data;
};



typedef struct conn_desc	conn_desc;
struct	conn_desc{
	dpl_socket_t	sock;
	unsigned long	seq;
	int		status;
	char		act_flag;
};


#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -