Documentation ¶
Index ¶
- Constants
- Variables
- func NewDeliver(ac *codec.AuthConf, phone, content, destNo string) codec.RequestPdu
- func NewReport(phone string, mtSequence []uint32, status Status, code byte) codec.RequestPdu
- func NewSequencer(node, worker uint32) *sequence
- func NewSubmit(ac *codec.AuthConf, phones []string, content string, ...) (messages []codec.RequestPdu)
- type Bind
- type BindRsp
- type CommandId
- type Deliver
- type DeliverRsp
- type MessageHeader
- type Report
- type ReportRsp
- type Status
- type Submit
- type SubmitRsp
- type Unbind
- type UnbindRsp
- type Version
Constants ¶
View Source
const BindPkgLen = 61
View Source
const BindRspPkgLen = 21
View Source
const DlvPackLen = 64
View Source
const MoBaseLen = 77
View Source
const MtBaseLen = 143
Variables ¶
View Source
var ResultMap = map[Status]string{
0: "成功",
1: "非法登录, 如登录名、口令出错、登录名与口令不符等。",
2: "重复登录, 如在同一TCP/IP连接中连续两次以上请求登录。",
3: "连接过多, 指单个节点要求同时建立的连接数过多。",
4: "登录类型错, 指bind命令中的logintype字段出错。",
5: "参数格式错, 指命令中参数值与参数类型不符或与协议规定的范围不符。",
6: "非法手机号码, 协议中所有手机号码字段出现非86130号码或手机号码前未加“86”时都应报错。",
7: "消息ID错",
8: "信息长度错",
9: "非法序列号, 包括序列号重复、序列号格式错误等",
10: "非法操作GNS",
11: "节点忙, 指本节点存储队列满或其他原因, 暂时不能提供服务的情况",
21: "目的地址不可达, 指路由表存在路由且消息路由正确但被路由的节点暂时不能提供服务的情况",
22: "路由错, 指路由表存在路由但消息路由出错的情况, 如转错SMG等",
23: "路由不存在, 指消息路由的节点在路由表中不存在",
24: "计费号码无效, 鉴权不成功时反馈的错误信息",
25: "用户不能通信(如不在服务区、未开机等情况)",
26: "手机内存不足",
27: "手机不支持短消息",
28: "手机接收短消息出现错误",
29: "不知道的用户",
30: "不提供此功能",
31: "非法设备",
32: "系统失败",
33: "短信中心队列满",
}
View Source
var Sequencer *sequence
Functions ¶
func NewDeliver ¶
func NewDeliver(ac *codec.AuthConf, phone, content, destNo string) codec.RequestPdu
func NewSequencer ¶
func NewSequencer(node, worker uint32) *sequence
func NewSubmit ¶
func NewSubmit(ac *codec.AuthConf, phones []string, content string, options ...codec.OptionFunc) (messages []codec.RequestPdu)
Types ¶
type Bind ¶
type Bind struct { MessageHeader // 【20 bytes】报文头,不含序号 LoginType byte // 【1 bytes 】登录类型。 1:SP 向 SMG 建立的连接,用于发送命令 2:SMG 向 SP 建立的连接,用于发送命令 LoginName string // 【16 bytes】服务器端给客户端分配的登录名 LoginPassword string // 【16 bytes】服务器端和 Login Name 对应的密码 Reserve string // 【8 bytes 】保留字段 }
Bind 登录报文结构体【61 bytes】
type BindRsp ¶
type BindRsp struct { MessageHeader Status Status }
type Deliver ¶
type Deliver struct { MessageHeader UserNumber string // 接收该短消息的手机号,该字段重复UserCount指定的次数,手机号码前加“86”国别标志【 21 bytes 】 SPNumber string // SP的接入号码【 21 bytes 】 TpPid byte // GSM协议类型。详细解释请参考GSM03.40中的9.2.3.9 【 1 bytes 】 TpUdhi byte // GSM协议类型。详细解释请参考GSM03.40中的9.2.3.9 【 1 bytes 】 MessageCoding byte // 短消息的编码格式。 【 1 bytes 】 MessageLength uint32 // 短消息的长度【 4 bytes 】 MessageContent []byte // 编码后消息内容 Reserve string // 保留,扩展用【 8 bytes 】 }
type DeliverRsp ¶
type DeliverRsp struct { MessageHeader Status Status Reserve string }
func (*DeliverRsp) Encode ¶
func (r *DeliverRsp) Encode() []byte
func (*DeliverRsp) Log ¶
func (r *DeliverRsp) Log() []log.Field
type MessageHeader ¶
type MessageHeader struct { PacketLength uint32 // 【4 bytes】数据包总长度 CommandId CommandId // 【4 bytes】命令类型 SequenceNumber []uint32 // 【12 bytes】序号 }
MessageHeader 报文头【20 bytes】
func (*MessageHeader) Decode ¶
func (h *MessageHeader) Decode(frame []byte) error
func (*MessageHeader) Encode ¶
func (h *MessageHeader) Encode() []byte
func (*MessageHeader) Log ¶
func (h *MessageHeader) Log() []log.Field
func (*MessageHeader) Sequence2String ¶
func (h *MessageHeader) Sequence2String() string
func (*MessageHeader) Sequence2Uint64 ¶
func (h *MessageHeader) Sequence2Uint64() uint64
func (*MessageHeader) String ¶
func (h *MessageHeader) String() string
type Report ¶
type Report struct { MessageHeader MtSequence []uint32 // 该命令所涉及的 Submit 或 deliver 命令的序列号 ReportType byte // Report 命令类型 0:对先前一条 Submit 命令的状态报告 1:对先前一条前转 Deliver 命令的状态报告 UserNumber string // 接收短消息的手机号,手机号码前加“86”国别标 志 State Status // 该命令所涉及的短消息的当前执行状态 0:发送成功 1:等待发送 2:发送失败 ErrorCode byte // 当 State=2 时为错误码值,否则为 0 Reserve string // 保留,扩展用【 8 bytes 】 }
type ReportRsp ¶
type ReportRsp struct { MessageHeader Status Status Reserve string }
type Submit ¶
type Submit struct { MessageHeader SPNumber string // SP的接入号码【 21 bytes 】 ChargeNumber string // 付费号码,手机号码前加“86”国别标志;当且仅当群发且对用户收费时为空;如果为空,则该条短消息产生的费用由UserNumber代表的用户支付;如果为全零字符串“000000000000000000000”,表示该条短消息产生的费用由SP支付。【 21 bytes 】 UserCount byte // 接收短消息的手机数量,取值范围1至100【 1 bytes 】 UserNumber []string // 接收该短消息的手机号,该字段重复UserCount指定的次数,手机号码前加“86”国别标志【 21 bytes 】 CorpId string // 企业代码,取值范围0-99999 【 5 bytes 】 ServiceType string // 业务代码,由SP定义 【 10 bytes 】 FeeType byte // 计费类型【 1 bytes 】 FeeValue string // 取值范围0-99999,该条短消息的收费值,单位为分,由SP定义,对于包月制收费的用户,该值为月租费的值 【 6 bytes 】 GivenValue string // 取值范围0-99999,赠送用户的话费,单位为分,由SP定义,特指由SP向用户发送广告时的赠送话费【 6 bytes 】 AgentFlag byte // 代收费标志,0:应收;1:实收 【 1 bytes 】 MorelatetoMTFlag byte // 引起MT消息的原因 【 1 bytes 】 Priority byte // 优先级0-9从低到高,默认为0 【 1 bytes 】 ExpireTime string // 短消息寿命的终止时间,如果为空,表示使用短消息中心的缺省值。时间内容为16个字符,格式为”yymmddhhmmsstnnp” ,其中“tnnp”取固定值“032+”,即默认系统为北京时间 【 16 bytes 】 ScheduleTime string // 短消息定时发送的时间,如果为空,表示立刻发送该短消息。时间内容为16个字符,格式为“yymmddhhmmsstnnp” ,其中“tnnp”取固定值“032+”,即默认系统为北京时间 【 16 bytes 】 ReportFlag byte // 状态报告标记【 1 bytes 】 TpPid byte // GSM协议类型。详细解释请参考GSM03.40中的9.2.3.9 【 1 bytes 】 TpUdhi byte // GSM协议类型。详细解释请参考GSM03.40中的9.2.3.9 【 1 bytes 】 MessageCoding byte // 短消息的编码格式。 【 1 bytes 】 MessageType byte // 信息类型: 0-短消息信息 其它:待定 【 1 bytes 】 MessageLength uint32 // 短消息的长度【 4 bytes 】 MessageContent []byte // 编码后消息内容 Reserve string // 保留,扩展用【 8 bytes 】 }
type SubmitRsp ¶
type SubmitRsp struct { MessageHeader Status Status Reserve string }
type Unbind ¶
type Unbind MessageHeader
type UnbindRsp ¶
type UnbindRsp MessageHeader
Click to show internal directories.
Click to hide internal directories.