📄 nsmgp.h
字号:
#include <sys/types.h>
#define ID_SMGP_LOGIN 0x00000001 // SP or SMG login request
#define ID_SMGP_LOGIN_RESP 0x80000001 // SP or SMG login reply
#define ID_SMGP_SUBMIT 0x00000002 // SP send sms request
#define ID_SMGP_SUBMIT_RESP 0x80000002 // sp send sms send reply
#define ID_SMGP_DELIVER 0x00000003 // SMG send mo to SP
#define ID_SMGP_DELIVER_RESP 0x80000003 // SP send mo send reply
#define ID_SMGP_ACTIVE_TEST 0x00000004 // test data-packet
#define ID_SMGP_ACTIVE_TEST_RESP 0x80000004 // test data-packet reply
#define ID_SMGP_FORWARD 0x00000005 // sms forward
#define ID_SMGP_FORWARD_RESP 0x80000005 // sms forward reply packet
#define ID_SMGP_EXIT 0x00000006 // the request of exit
#define ID_SMGP_EXIT_RESP 0x80000006 // the reply of request of exit
#define ID_SMGP_QUERY 0x00000007 // query request
#define ID_SMGP_QUERY_RESP 0x80000007 // the reply of query request
#define LEN_SMGP_HEAD 12
/* Body Length */
#define LEN_SMGP_LOGIN 30
#define LEN_SMGP_LOGIN_RESP 21
#define LEN_SMGP_SUBMIT 135 //114//104+ (DestTermIDCount)1+21*DestTermCount+1+MsgTontent+8
//135 + Message_Length +TLV
#define LEN_SMGP_SUBMIT_RESP 14
#define LEN_SMGP_DELIVER 77 //69+8+ Msg_Length */
#define LEN_SMGP_DELIVER_RESP 14
#define LEN_SMGP_REPORT 66
#ifndef UCHAR
#define UCHAR unsigned char
#endif
#ifndef UINT
#define UINT unsigned int
#endif
typedef struct {
unsigned int Packetlength;
unsigned int RequestID;
unsigned int SequenceID;
} SMGP_HEAD;
typedef struct {
u_char ClintID[9];
u_char Auth[17];
uint32_t LogMod;
uint32_t TimeStamp;
uint32_t CliVer;
} LOGIN;
typedef struct {
uint32_t Status;
u_char Auth[17];
uint32_t SvrVer;
} LOGIN_REP;
//-----------------------------------
#pragma pack(1)
typedef struct {
unsigned short Paramater_Tag;
unsigned short Length;
unsigned char Value;
} TLV;
typedef struct {
unsigned short Tag;
unsigned short Length;
unsigned char Value[20];
} TLV_LinkID;
typedef struct
{
UCHAR MsgType; //短消息类型: 6
UCHAR NeedReport; //SP是否要求返回状态报告
UCHAR Priority; //短消息发送优先级
char ServiceID[10]; //业务代码
char FeeType[2]; //收费类型
char FeeCode[6]; //资费
char FixedFee[6]; //包月费/封顶费
UCHAR MsgFormat; //短消息格式: 15
char ValidTime[17]; //短消息有效时间: 0
char AtTime[17]; //短消息定时发送时间:0
char SrcTermID[21]; // 短信息发送方的电话号码
char ChargeTermID[21]; // 付费号码
UCHAR DestTermIDCount; // 接收短消息的手机数量
char DestTermID[21]; // 接收该短消息的手机号
UCHAR MsgLength;
// char MsgContent[140]; //长度可变,不包含在结构中
// char Reserve[8];
// LinkID
// ChargeUserType //计费用户类型:0=对短消息接收方计费;1=对短消息发送方计费;
//2=对SP计费;3=表示本字段无效
// SubmitMsgType //发送的消息类型:0=普通短消息; 5=包月扣费通知消息;
//13=订购(包括点播和定制)关系同步;15=订购关系同步回复,14=群发结果通知消息;
// SPDealResult
}SMGP3_SUBMIT;
#pragma pack(0)
//-----------------------------------
typedef struct {
u_char ChargeTerm[21+1]; // 付费号码
u_char SrcTermID[21+1]; // 短信息发送方的电话号码
uint32_t DestTermCount; // 接收短消息的手机数量
u_char DestTermID[21+1]; // 接收该短消息的手机号
u_char ServiceID[10+1]; // 业务代码
u_char FeeType[3]; // 计费类型
u_char FeeCode[6+1]; // 该条短消息的收费值
u_char FixFee[6+1]; // 包月费
uint32_t Priority; // 优先级
u_char ExpireTime[16+1]; // 短消息寿命的终止时间
u_char ScheduleTime[16+1]; // 短消息定时发送的时间
uint32_t ReportFlag; // 状态报告标记
uint32_t MsgCoding; // 短消息的编码格式
uint32_t MsgType; // 信息类型
uint32_t MsgLength; // 短消息的长度
u_char MsgContent[256]; // 短消息的内容
u_char Reserve[8+1]; // 保留,扩展用
//u_char LinkID[21];
u_char Paramater[256]; //yhw.用于存入TLV.
uint32_t ParamaterLen;
} SMGP_SUBMIT;
typedef struct {
u_char MsgID[11];
uint32_t Status;
}SMGP_REP;
typedef struct
{
u_char MsgID[11];
u_char SrcTermID[21+1]; //发送短消息的用户手机号
u_char DestTermID[21+1]; // SP的接入号码
uint32_t MsgCoding; //短消息的编码格式
uint32_t IsReport;
uint32_t MsgLength; //短消息的长度
u_char RecvTime[14+1];
u_char MsgContent[256]; //短消息的内容
u_char Reserve[8+1]; //保留
//u_char LinkID[21];
u_char Paramater[256];
uint32_t ParamaterLen;
} SMGP_DELIVER;
typedef struct {
uint32_t MsgID[21]; // 序列号,BCD to ASCII
u_char State[8]; // 短消息的当前执行状态
u_char Err[8+1]; // 保留,扩展用
} SMGP_REPORT;
//func define
void MakeHead(char *buffer, unsigned int PacketLength, unsigned int RequestID, unsigned int SequenceID);
int ConnectSMG(unsigned int *Socket_fd, char *IP, int Port);
int LoginSMG(int Socket_fd, char *ClientID, char *Secrect, int LoginMode, int Version, unsigned int SequenceID);
int GetMessageHead(char *socketbuffer, unsigned int *Body_Length, unsigned int *RequestID, unsigned int *SequenceID);
int RecvLoginResp(char *socketbuffer, unsigned int Body_Length, unsigned int *Status, unsigned int *Version);
int Submit(int Socket_fd, unsigned int SequenceNum, SMGP3_SUBMIT *submit,
unsigned char *content,
unsigned char *linkid,
unsigned char subMsgType,
unsigned char spDealRes );
int RecvSubmitResp(char *socketbuffer, unsigned int Body_Length, char *MsgID, unsigned int *result);
int DeliverGet(char *socketbuffer, SMGP_DELIVER *deliver,unsigned int Body_Length);
int SMGP_Recv_Length(int Socket_fd,unsigned int Body_Length);
int SMGP_Active_Test_Rep_Recv(int socket_fd,unsigned int Body_Length);
int DeliverResp(int Socket_fd, unsigned int Sequence, char *MsgID, int Result);
int ActiveTest(int Socket_fd, unsigned int Sequence);
int ActiveTestResp(int Socket_fd, unsigned int Sequence);
int Exit(int Socket_fd, unsigned int Sequence);
int SendExitResp(int Socket_fd, unsigned int Sequence);
int Query(int Socket_fd, unsigned int Sequence, char *Time, int QueryType, char *QueryCode);
int GetSmcNotice( unsigned char *smcBuf,
char *mobile ,
char *service ,
char *date1 ,
char *date2 ,
char *status ,
char *feecode );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -