sgip

package
v0.0.0-...-a86be45 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 9 Imported by: 3

Documentation

Index

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 NewReport

func NewReport(phone string, mtSequence []uint32, status Status, code byte) 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】

func NewBind

func NewBind(ac *codec.AuthConf, loginType byte) *Bind

func (*Bind) Check

func (b *Bind) Check(ac *codec.AuthConf) Status

func (*Bind) Decode

func (b *Bind) Decode(cid uint32, frame []byte) error

func (*Bind) Encode

func (b *Bind) Encode() []byte

func (*Bind) Log

func (b *Bind) Log() []log.Field

func (*Bind) ToResponse

func (b *Bind) ToResponse(code uint32) codec.Pdu

type BindRsp

type BindRsp struct {
	MessageHeader
	Status Status
}

func (*BindRsp) Decode

func (r *BindRsp) Decode(cid uint32, frame []byte) error

func (*BindRsp) Encode

func (r *BindRsp) Encode() []byte

func (*BindRsp) Log

func (r *BindRsp) Log() []log.Field

type CommandId

type CommandId uint32

CommandId 命令定义

const (
	SGIP_REQUEST_MIN, SGIP_RESPONSE_MIN CommandId = iota, 0x80000000 + iota
	SGIP_BIND, SGIP_BIND_RESP
	SGIP_UNBIND, SGIP_UNBIND_RESP
	SGIP_SUBMIT, SGIP_SUBMIT_RESP
	SGIP_DELIVER, SGIP_DELIVER_RESP
	SGIP_REPORT, SGIP_REPORT_RESP
	SGIP_REQUEST_MAX, SGIP_RESPONSE_MAX
)

func (CommandId) OpLog

func (id CommandId) OpLog() log.Field

func (CommandId) String

func (id CommandId) String() string

func (CommandId) ToInt

func (id CommandId) ToInt() uint32

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 】
}

func (*Deliver) Decode

func (d *Deliver) Decode(cid uint32, frame []byte) error

func (*Deliver) Encode

func (d *Deliver) Encode() []byte

func (*Deliver) Log

func (d *Deliver) Log() []log.Field

func (*Deliver) ToResponse

func (d *Deliver) ToResponse(code uint32) codec.Pdu

type DeliverRsp

type DeliverRsp struct {
	MessageHeader
	Status  Status
	Reserve string
}

func (*DeliverRsp) Decode

func (r *DeliverRsp) Decode(cid uint32, frame []byte) error

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 】
}

func (*Report) Decode

func (r *Report) Decode(cid uint32, frame []byte) error

func (*Report) Encode

func (r *Report) Encode() []byte

func (*Report) Log

func (r *Report) Log() []log.Field

func (*Report) ToResponse

func (r *Report) ToResponse(code uint32) codec.Pdu

type ReportRsp

type ReportRsp struct {
	MessageHeader
	Status  Status
	Reserve string
}

func (*ReportRsp) Decode

func (r *ReportRsp) Decode(cid uint32, frame []byte) error

func (*ReportRsp) Encode

func (r *ReportRsp) Encode() []byte

func (*ReportRsp) Log

func (r *ReportRsp) Log() []log.Field

type Status

type Status byte

func (Status) String

func (r Status) String() 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 】

}

func (*Submit) Decode

func (s *Submit) Decode(cid uint32, frame []byte) error

func (*Submit) Encode

func (s *Submit) Encode() []byte

func (*Submit) Log

func (s *Submit) Log() []log.Field

func (*Submit) SetOptions

func (s *Submit) SetOptions(ac *codec.AuthConf, ops *codec.MtOptions)

func (*Submit) ToResponse

func (s *Submit) ToResponse(code uint32) codec.Pdu

type SubmitRsp

type SubmitRsp struct {
	MessageHeader
	Status  Status
	Reserve string
}

func (*SubmitRsp) Decode

func (r *SubmitRsp) Decode(cid uint32, frame []byte) error

func (*SubmitRsp) Encode

func (r *SubmitRsp) Encode() []byte

func (*SubmitRsp) Log

func (r *SubmitRsp) Log() []log.Field

type Unbind

type Unbind MessageHeader

func NewUnbind

func NewUnbind() *Unbind

func (*Unbind) Decode

func (u *Unbind) Decode(cid uint32, frame []byte) error

func (*Unbind) Encode

func (u *Unbind) Encode() []byte

func (*Unbind) Log

func (u *Unbind) Log() []log.Field

func (*Unbind) String

func (u *Unbind) String() string

func (*Unbind) ToResponse

func (u *Unbind) ToResponse(_ uint32) codec.Pdu

type UnbindRsp

type UnbindRsp MessageHeader

func (*UnbindRsp) Decode

func (r *UnbindRsp) Decode(cid uint32, frame []byte) error

func (*UnbindRsp) Encode

func (r *UnbindRsp) Encode() []byte

func (*UnbindRsp) Log

func (r *UnbindRsp) Log() []log.Field

type Version

type Version uint8
const V12 Version = 0x12

func (Version) MajorMatch

func (t Version) MajorMatch(v uint8) bool

MajorMatch 主版本相匹配

func (Version) MajorMatchV

func (t Version) MajorMatchV(v Version) bool

MajorMatchV 主版本相匹配

func (Version) String

func (t Version) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL