?? cmpp.h
字號:
/******************************************************************************FileName : cmpp.hDescription : cmpp協議相關的常量的定義Version : 1.0Date : 2004年4月6日Author : 潘昱宇Other : 這里只定義了部分的Command_Id(與SP相關的那一部分)******************************************************************************/
#ifndef _CMPP_H_#define _CMPP_H_const int nCMPP_VERSION =0x30; // CMPP3.0
const int nCMPP_WINDOW_SIZE =16; // CMPP滑動窗口的大小
const int nCMPP_PKG_SIZE =400; // CMPP數據包的最大長度
const int nCMPP_CONNECT =0x00000001; // 請求連接const int nCMPP_CONNECT_RESP =0x80000001; // 請求連接應答const int nCMPP_TERMINATE =0x00000002; // 終止連接const int nCMPP_TERMINATE_RESP =0x80000002; // 終止連接應答const int nCMPP_SUBMIT =0x00000004; // 提交短信const int nCMPP_SUBMIT_RESP =0x80000004; // 提交短信應答const int nCMPP_DELIVER =0x00000005; // 短信下發const int nCMPP_DELIVER_RESP =0x80000005; // 下發短信應答const int nCMPP_QUERY =0x00000006; // 短信狀態查詢const int nCMPP_QUERY_RESP =0x80000006; // 短信狀態查詢應答const int nCMPP_CANCEL =0x00000007; // 刪除短信const int nCMPP_CANCEL_RESP =0x80000007; // 刪除短信應答const int nCMPP_ACTIVE_TEST =0x00000008; // 激活測試const int nCMPP_ACTIVE_TEST_RESP =0x80000008; // 激活測試應答
const int eCMPP_INIT_OK =0; // 接口初始化成功
const int eCMPP_INIT_CONNECT =-1; // 不能連接服務器
const int eCMPP_INIT_INVAL_ADDR =2; // 非法源地址
const int eCMPP_INIT_AUTH =3; // 認證錯
const int eCMPP_INIT_VERSION =4; // 版本太高
const int eCMPP_INIT_UNKNOWN =5; // 其他錯誤
const int eCMPP_NEED_INIT =6; // 接口尚未初始化
typedef struct _CMPP_HEAD{ int size; // 數據報的長度
int cmdid; // 命令碼
int seqid; // 流水號} CMPP_HEAD;
typedef struct _CMPP_PACKAGE
{
CMPP_HEAD head; // 數據報的包頭
char data[nCMPP_PKG_SIZE]; // 要發送的數據
int n; // 重發次數,初始值3
time_t t; // 下次發送的時間
} CMPP_PACKAGE;
typedef struct _CMPP_CONNECT{ unsigned char spid[6]; // 9開頭的6位企業碼
unsigned char digest[16]; // MD5數字簽名
unsigned char ver; // 版本 int timestamp;
} CMPP_CONNECT;typedef struct _CMPP_CONNECT_RESP{ __int32 status; // 狀態標識
unsigned char digest[16]; // 服務器的MD5數字簽名
unsigned char ver; // 服務器的版本} CMPP_CONNECT_RESP;/******************************************************************************
* 注意:這里的目的地手機號碼只能填寫一個,所以desttotal恒等于1
* 這里的短消息內容為固定長度,發送的時候需要轉換成變長******************************************************************************/typedef struct _CMPP_SUBMIT{ __int64 msgid; // 信息標識 unsigned char pkgtotal; // 相同Msg_Id的信息總條數
unsigned char pkgnumber; // 相同Msg_Id的信息序號
unsigned char delivery; // 是否要求返回狀態確認報告
unsigned char msglevel; // 信息級別
unsigned char serviceid[10]; // 業務類型 unsigned char feeusertype; // 計費用戶類型字段
unsigned char feenumber[32]; // 被計費用戶的號碼
unsigned char srcttype; // 被計費用戶的號碼類型,0:真實號碼;1:偽碼。
unsigned char tppid; // TP-Protocol-Identifier
unsigned char tpudhi; // TP-User-Data-Header-Indicator unsigned char msgfmt; // 信息格式,8:UCS2編碼
unsigned char msgsrc[6]; // 信息內容來源(SP_Id)
unsigned char feetype[2]; // 資費類別
unsigned char feecode[6]; // 資費代碼(以分為單位) unsigned char validtime[17]; // 存活有效期,參見SMPP3.3
unsigned char attime[17]; // 定時發送時間,參見SMPP3.3
unsigned char srcnumber[21]; // 源號碼
unsigned char desttotal; // 接收信息的用戶數量(===1)
unsigned char destnumbers[32]; // 接收短信的MSISDN號碼
unsigned char desttype; // 接收短信的用戶的號碼類型,0:真實號碼;1:偽碼。
unsigned char msglen; // 信息長度(<=140)
unsigned char msgcontent[160]; // 信息內容
unsigned char reserve[20]; // 保留} CMPP_SUBMIT;typedef struct _CMPP_SUBMIT_RESP{ __int64 msgid; // 信息標識 __int32 result; // 結果} CMPP_SUBMIT_RESP;typedef struct _CMPP_QUERY{ unsigned char date[8]; // 日期YYYYMMDD(精確至日)
unsigned char type; // 查詢類別0/1
unsigned char serviceid[10]; // 查詢碼(Service_Id)
unsigned char reserve[8]; // 保留} CMPP_QUERY;typedef struct _CMPP_QUERY_RESP{ unsigned char date[8]; // 日期YYYYMMDD(精確至日)
unsigned char type; // 查詢類別0/1
unsigned char serviceid[10]; // 查詢碼(Service_Id) int mtmsgtotal; // 從SP接收信息總數
int mtusertotal; // 從SP接收用戶總數
int mtsuccess; // 成功轉發數量
int mtwait; // 待轉發數量
int mtfail; // 轉發失敗數量 int mosuccess; // 向SP成功送達數量
int mowait; // 向SP待送達數量
int mofail; // 向SP送達失敗數量} CMPP_QUERY_RESP;typedef struct _CMPP_DELIVER{ __int64 msgid; // 信息標識 unsigned char destnumber[21]; // 目的號碼
unsigned char serviceid[10]; // 業務類型
unsigned char tppid; // TP-Protocol-Identifier
unsigned char tpudhi; // TP-User-Data-Header-Indicator unsigned char msgfmt; // 信息格式,8:UCS2編碼
unsigned char srcnumber[32]; // 源終端MSISDN號碼
unsigned char srctype; // 源終端類型
unsigned char delivery; // 是否為狀態報告
unsigned char msglen; // 消息長度
unsigned char msgcontent[200]; // 消息內容
unsigned char LinkID[20] ; // LinkID} CMPP_DELIVER;typedef struct _CMPP_DELIVER_RESP{ __int64 msgid; // 信息標識 unsigned char result; // 結果} CMPP_DELIVER_RESP;typedef struct _CMPP_CANCEL{ __int64 msgid; // 信息標識} CMPP_CANCEL;typedef struct _CMPP_CANCEL_RESP{ unsigned char result; // 成功標識(0/1)} CMPP_CANCEL_RESP;typedef struct _CMPP_ACTIVE_TEST_RESP{ unsigned char reserve; // 保留} CMPP_ACTIVE_TEST_RESP;
typedef struct _CMPP_FUNC_MAP
{
int cmdid; // 命令字
void (*func)( CMPP_PACKAGE &pkg); // 函數入口
} CMPP_FUNC_MAP;
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -