-
Notifications
You must be signed in to change notification settings - Fork 0
/
childprotocol.h
113 lines (89 loc) · 4.17 KB
/
childprotocol.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef SMS_A6CC8CFE_F731_4b1d_9373_9F0A880D48B2
#define SMS_A6CC8CFE_F731_4b1d_9373_9F0A880D48B2
/* 与下游通讯协议定义 */
namespace SMS {
#define FEETYPE_1 1
//短信类型常量定义
#define testport "4000"
//消息类型常量定义
#define MSGTYPE_SM 0
#define MSGTYPE_SMR 1
#define MSGTYPE_SMS 2
#define MSGTYPE_RM 3
#define MSGTYPE_CD 4
#define MSGTYPE_CDR 5
#define MSGTYPE_PWD 10 //验证连接密码
#define CONNECTION_USER_LEN 20
#define CONNECTION_PASSWORD_LEN 50
typedef struct _SMSChildProtocolHead{
byte msgTypeID; //消息类型
byte SMSSerialNo[4]; //由消息主动产生方生成的信息序列号,高位在前
byte msgLength[4]; //不包括头信息的消息体长度(字节数)高位在前,低位在后
byte unused[4]; //保留,将来做checksum
} SMSChildProtocolHead, *PSMSChildProtocolHead;
typedef struct _SMSChildProtocolCommon { //用于处理消息头的结构
SMSChildProtocolHead head; //头信息
} SMSChildProtocolCommon, *PSMSChildProtocolCommon;
typedef struct _SMSChildProtocolSendMessage { //下游网关的发送短信消息
SMSChildProtocolHead head; //头信息
char senderNo[MOBILENUMBERLENGTH+1]; //短信的发送方号码
char targetNo[MOBILENUMBERLENGTH+1]; //短信的接收方号码
char feeTargetNo[MOBILENUMBERLENGTH+1]; //本次短信计费的对象号码
byte feeTypeID; // 收费类型代码
byte smsTypeID; // 短信类型
byte smsBodyLength[4]; //短信内容长度(字节) 高位在前,低位在后
char smsBody[0]; //短信内容
}SMSChildProtocolSendMessage, *PSMSChildProtocolSendMessage;
#define MSG_OK 0
#define MSGERR_SENDERNO 11
#define MSGERR_TARGETNO 12
#define MSGERR_FEETARGETNO 21
#define MSGERR_FEETYPE 22
#define MSGERR_SMSTYPE 31
#define MSGERR_SMSLEN 41
#define MSGERR_MSGTYPE 51
typedef struct _SMSChildProtocolSendMessgeReceived{ //本地网关接受到发送短信消息之后的返回
SMSChildProtocolHead head; //头信息
byte SerialNo[4]; //由本地网关生成的信息序列号,高位在前
byte ErrorNo; //对发送短信消息内容validate之后的结果
} SMSChildProtocolSendMessgeReceived, *PSMSChildProtocolSendMessgeReceived;
#define SEND_OK 0
typedef struct _SMSChildProtocolSendMessageSended{ //本地网关成功发送短信消息之后的返回
SMSChildProtocolHead head; //头信息
byte SerialNo[4]; //由本地网关生成的信息序列号,高位在前
byte ErrorNo; //发送结果
}SMSChildProtocolSendMessageSended, *PSMSChildProtocolSendMessageSended;
typedef struct _SMSChildProtocolReceivedMessage{ //本地网关转发给下游的短信
SMSChildProtocolHead head; //头信息
char senderNo[MOBILENUMBERLENGTH+1]; //短信的发送方号码
char targetNo[MOBILENUMBERLENGTH+1]; //短信的接收方号码
byte smsTypeID; // 短信类型
byte smsLength[4]; //短信内容长度(字节) 高位在前,低位在后
char smsBody[0]; //短信内容
}SMSChildProtocolReceivedMessage, *PSMSChildProtocolReceivedMessage;
typedef struct _SMSChildProtocolConnectionDetect{ //本地网关对下游进行状态检测
SMSChildProtocolHead head; //头信息
byte SerialNo[4]; //由本地网关生成的信息序列号,高位在前
} SMSChildProtocolConnectionDetect, *PSMSChildProtocolConnectionDetect;
typedef struct _SMSChildProtocolReply{ //下游对本地网关状态检测的回复
SMSChildProtocolHead head; //头信息
byte SerialNo[4]; //由本地网关生成的信息序列号,高位在前
} SMSChildProtocolReply, *PSMSChildProtocolReply;
typedef struct _SMSChildProtocolPassword{ //验证连接用户名和密码
SMSChildProtocolHead head; //头信息
char user[CONNECTION_USER_LEN];
char password[CONNECTION_PASSWORD_LEN];
} SMSChildProtocolPassword, *PSMSChildProtocolPassword;
inline unsigned long int sms_byteToLong(byte arg[4]) {
long tmp;
tmp=(arg[0]<<24)+(arg[1]<<16)+(arg[2]<<8)+arg[3];
return tmp;
}
inline void sms_longToByte(byte* arg, unsigned long int num) {
(arg)[0]=num>>24;
(arg)[1]=(num<<8)>>24;
(arg)[2]=(num<<16)>>24;
(arg)[3]=(num<<24)>>24;
}
}
#endif