smgp

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TP_pid           = uint16(0x0001)
	TP_udhi          = uint16(0x0002)
	PkTotal          = uint16(0x0009)
	PkNumber         = uint16(0x000A)
	LinkID           = uint16(0x0003)
	ChargeUserType   = uint16(0x0004)
	ChargeTermType   = uint16(0x0005)
	ChargeTermPseudo = uint16(0x0006)
	DestTermType     = uint16(0x0007)
	DestTermPseudo   = uint16(0x0008)
	SubmitMsgType    = uint16(0x000B)
	SPDealReslt      = uint16(0x000C)
	SrcTermType      = uint16(0x000D)
	SrcTermPseudo    = uint16(0x000E)
	NodesCount       = uint16(0x000F)
	MsgSrc           = uint16(0x0010)
	SrcType          = uint16(0x0011)
	MServiceID       = uint16(0x0012)
)
View Source
const (
	HeadLength        = 12                 // 报文头长度
	CmdLogin          = uint32(0x00000001) // 客户端登录
	CmdLoginResp      = uint32(0x80000001) // 客户端登录应答
	CmdSubmit         = uint32(0x00000002) // 提交短消息
	CmdSubmitResp     = uint32(0x80000002) // 提交短消息应答
	CmdDeliver        = uint32(0x00000003) // 下发短消息
	CmdDeliverResp    = uint32(0x80000003) // 下发短消息应答
	CmdActiveTest     = uint32(0x00000004) // 链路检测
	CmdActiveTestResp = uint32(0x80000004) // 链路检测应答
	CmdExit           = uint32(0x00000006) // 退出请求
	CmdExitResp       = uint32(0x80000006) // 退出应答

)
View Source
const (
	LoginLen     = 42
	LoginRespLen = 33
)
View Source
const MtBaseLen = 126
View Source
const RptLen = 10 + 3 + 3 + 10 + 10 + 7 + 3 + 20 + len("id: sub: dlvrd: submit date: done date: stat: err: text:")

Variables

View Source
var CommandMap = make(map[uint32]string)
View Source
var ConnectStatusMap = map[uint32]string{
	0:  "成功",
	1:  "系统忙",
	2:  "超过最大连接数",
	10: "消息结构错",
	11: "命令字错",
	12: "序列号重复",
	20: "IP地址错",
	21: "认证错",
	22: "版本太高",
	30: "非法消息类型(MsgType)",
	31: "非法优先级(Priority)",
	32: "非法资费类型(FeeType)",
	33: "非法资费代码(FeeCode)",
}
View Source
var ErrorPacket = errors.New("error packet")
View Source
var GbDecoder = simplifiedchinese.GB18030.NewDecoder()
View Source
var GbEncoder = simplifiedchinese.GB18030.NewEncoder()
View Source
var StatMap = map[uint32]string{
	0:  "成功",
	1:  "系统忙",
	2:  "超过最大连接数",
	10: "消息结构错",
	11: "命令字错",
	12: "序列号重复",
	20: "IP地址错",
	21: "认证错",
	22: "版本太高",
	30: "非法消息类型(MsgType)",
	31: "非法优先级(Priority)",
	32: "非法资费类型(FeeType)",
	33: "非法资费代码(FeeCode)",
	34: "非法短消息格式(MsgFormat)",
	35: "非法时间格式",
	36: "非法短消息长度(MsgLength)",
	37: "有效期已过",
	38: "非法查询类别(QueryType)",
	39: "路由错误",
	40: "非法包月费/封顶费(FixedFee)",
	41: "非法更新类型(UpdateType)",
	42: "非法路由编号(RouteId)",
	43: "非法服务代码(ServiceId)",
	44: "非法有效期(ValidTime)",
	45: "非法定时发送时间(AtTime)",
	46: "非法发送用户号码(SrcTermId)",
	47: "非法接收用户号码(DestTermId)",
	48: "非法计费用户号码(ChargeTermId)",
	49: "非法SP服务代码(SPCode)",
	56: "非法源网关代码(SrcGatewayID)",
	57: "非法查询号码(QueryTermID)",
	58: "没有匹配路由",
	59: "非法SP类型(SPType)",
	60: "非法上一条路由编号(LastRouteID)",
	61: "非法路由类型(RouteType)",
	62: "非法目标网关代码(DestGatewayID)",
	63: "非法目标网关IP(DestGatewayIP)",
	64: "非法目标网关端口(DestGatewayPort)",
	65: "非法路由号码段(TermRangeID)",
	66: "非法终端所属省代码(ProvinceCode)",
	67: "非法用户类型(UserType)",
	68: "本节点不支持路由更新",
	69: "非法SP企业代码(SPID)",
	70: "非法SP接入类型(SPAccessType)",
	71: "路由信息更新失败",
	72: "非法时间戳(Time)",
	73: "非法业务代码(MServiceID)",
	74: "SP禁止下发时段",
	75: "SP发送超过日流量",
	76: "SP帐号过有效期",
}

Functions

func NewDeliver

func NewDeliver(srcNo string, destNo string, txt string) codec.RequestPdu

func NewSubmit

func NewSubmit(phones []string, content string, options MtOptions) (messages []codec.RequestPdu)

Types

type ActiveTest

type ActiveTest MessageHeader

func NewActiveTest

func NewActiveTest() *ActiveTest

func (*ActiveTest) Decode

func (at *ActiveTest) Decode(header codec.IHead, _ []byte) error

func (*ActiveTest) Encode

func (at *ActiveTest) Encode() []byte

func (*ActiveTest) String

func (at *ActiveTest) String() string

func (*ActiveTest) ToResponse

func (at *ActiveTest) ToResponse(_ uint32) interface{}

type ActiveTestResp

type ActiveTestResp MessageHeader

func NewActiveTestResp

func NewActiveTestResp(seq uint32) *ActiveTestResp

func (*ActiveTestResp) Decode

func (resp *ActiveTestResp) Decode(header codec.IHead, _ []byte) error

func (*ActiveTestResp) Encode

func (resp *ActiveTestResp) Encode() []byte

func (*ActiveTestResp) String

func (resp *ActiveTestResp) String() string

type Deliver

type Deliver struct {
	*MessageHeader
	// contains filtered or unexported fields
}

func NewDeliveryReport

func NewDeliveryReport(mt *Submit, msgId []byte) *Deliver

func (*Deliver) Decode

func (dlv *Deliver) Decode(header codec.IHead, frame []byte) error

func (*Deliver) Encode

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

func (*Deliver) IsReport

func (dlv *Deliver) IsReport() bool

func (*Deliver) String

func (dlv *Deliver) String() string

func (*Deliver) ToResponse

func (dlv *Deliver) ToResponse(code uint32) interface{}

type DeliverResp

type DeliverResp struct {
	*MessageHeader
	// contains filtered or unexported fields
}

func (*DeliverResp) Decode

func (r *DeliverResp) Decode(header codec.IHead, frame []byte) error

func (*DeliverResp) Encode

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

func (*DeliverResp) MsgId

func (r *DeliverResp) MsgId() string

func (*DeliverResp) String

func (r *DeliverResp) String() string

type Exit

type Exit MessageHeader

func NewExit

func NewExit() *Exit

func (*Exit) Decode

func (at *Exit) Decode(header codec.IHead, _ []byte) error

func (*Exit) Encode

func (at *Exit) Encode() []byte

func (*Exit) String

func (at *Exit) String() string

func (*Exit) ToResponse

func (at *Exit) ToResponse(_ uint32) interface{}

type ExitResp

type ExitResp MessageHeader

func NewExitResp

func NewExitResp(seq uint32) *ExitResp

func (*ExitResp) Decode

func (resp *ExitResp) Decode(header codec.IHead, _ []byte) error

func (*ExitResp) Encode

func (resp *ExitResp) Encode() []byte

func (*ExitResp) String

func (resp *ExitResp) String() string

type Login

type Login struct {
	*MessageHeader //  【12字节】消息头
	// contains filtered or unexported fields
}

func NewLogin

func NewLogin() *Login

func (*Login) Check

func (lo *Login) Check() uint32

func (*Login) Decode

func (lo *Login) Decode(header codec.IHead, frame []byte) error

func (*Login) Encode

func (lo *Login) Encode() []byte

func (*Login) String

func (lo *Login) String() string

func (*Login) ToResponse

func (lo *Login) ToResponse(code uint32) interface{}

type LoginResp

type LoginResp struct {
	*MessageHeader // 协议头, 12字节
	// contains filtered or unexported fields
}

func (*LoginResp) Decode

func (resp *LoginResp) Decode(header codec.IHead, frame []byte) error

func (*LoginResp) Encode

func (resp *LoginResp) Encode() []byte

func (*LoginResp) Status

func (resp *LoginResp) Status() uint32

func (*LoginResp) String

func (resp *LoginResp) String() string

type MessageHeader

type MessageHeader struct {
	PacketLength uint32
	RequestId    uint32
	SequenceId   uint32
}

func (*MessageHeader) Decode

func (header *MessageHeader) Decode(frame []byte) error

func (*MessageHeader) Encode

func (header *MessageHeader) Encode() []byte

func (*MessageHeader) String

func (header *MessageHeader) String() string

type MtOptions

type MtOptions struct {
	NeedReport    byte          // SP是否要求返回状态报告
	Priority      byte          // 短消息发送优先级,0-3
	ServiceID     string        // 业务代码
	AtTime        time.Time     // 短消息定时发送时间
	ValidDuration time.Duration // 短消息有效时长
	SrcTermID     string        // 会拼接到配置文件的sms-display-no后面
}

type Report

type Report struct {
	// contains filtered or unexported fields
}

func NewReport

func NewReport(id []byte) *Report

func (*Report) Decode

func (rt *Report) Decode(frame []byte) error

func (*Report) Encode

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

func (*Report) String

func (rt *Report) String() string

type Submit

type Submit struct {
	*MessageHeader
	// contains filtered or unexported fields
}

func (*Submit) Decode

func (s *Submit) Decode(header codec.IHead, frame []byte) error

func (*Submit) Encode

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

func (*Submit) SetOptions

func (s *Submit) SetOptions(options MtOptions)

func (*Submit) String

func (s *Submit) String() string

func (*Submit) ToResponse

func (s *Submit) ToResponse(code uint32) interface{}

type SubmitResp

type SubmitResp struct {
	*MessageHeader
	// contains filtered or unexported fields
}

func (*SubmitResp) Decode

func (r *SubmitResp) Decode(header codec.IHead, frame []byte) error

func (*SubmitResp) Encode

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

func (*SubmitResp) MsgId

func (r *SubmitResp) MsgId() []byte

func (*SubmitResp) Status

func (r *SubmitResp) Status() uint32

func (*SubmitResp) String

func (r *SubmitResp) String() string

Jump to

Keyboard shortcuts

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