smgp

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: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	LoginLen     = 42
	LoginRespLen = 33
)
View Source
const (
	V30 Version = 0x30
	V20 Version = 0x20
	V13 Version = 0x13

	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 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 (
	GbEncoder = simplifiedchinese.GB18030.NewEncoder()
	GbDecoder = simplifiedchinese.GB18030.NewDecoder()
)
View Source
var StatMap = map[Status]string{
	0:  "成功",
	1:  "系统忙",
	2:  "超过最大连接数",
	10: "消息结构错",
	11: "命令字错",
	12: "序列号重复",
	20: "IP地址错",
	21: "认证错",
	22: "版本太高",
	30: "非法消息类型(MsgType)",
	31: "非法优先级(LruPriority)",
	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(ac *codec.AuthConf, phone string, destNo string, txt string, seq uint32) codec.RequestPdu

func NewSubmit

func NewSubmit(ac *codec.AuthConf, phones []string, content string, seq uint32, options ...codec.OptionFunc) (messages []codec.RequestPdu)

Types

type ActiveTest

type ActiveTest MessageHeader

func NewActiveTest

func NewActiveTest(seq uint32) *ActiveTest

func (*ActiveTest) Decode

func (t *ActiveTest) Decode(seq uint32, _ []byte) error

func (*ActiveTest) Encode

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

func (*ActiveTest) Log

func (t *ActiveTest) Log() []log.Field

func (*ActiveTest) String

func (t *ActiveTest) String() string

func (*ActiveTest) ToResponse

func (t *ActiveTest) ToResponse(_ uint32) codec.Pdu

type ActiveTestRsp

type ActiveTestRsp MessageHeader

func (*ActiveTestRsp) Decode

func (r *ActiveTestRsp) Decode(seq uint32, _ []byte) error

func (*ActiveTestRsp) Encode

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

func (*ActiveTestRsp) Log

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

func (*ActiveTestRsp) String

func (r *ActiveTestRsp) String() string

type CommandId

type CommandId uint32

CommandId 命令定义

const (
	SMGP_REQUEST_MIN, SMGP_RESPONSE_MIN CommandId = iota, 0x80000000 + iota
	SMGP_LOGIN, SMGP_LOGIN_RESP
	SMGP_SUBMIT, SMGP_SUBMIT_RESP
	SMGP_DELIVER, SMGP_DELIVER_RESP
	SMGP_ACTIVE_TEST, SMGP_ACTIVE_TEST_RESP

	SMGP_EXIT, SMGP_EXIT_RESP
	SMGP_REQUEST_MAX, SMGP_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 DeliverRsp

type DeliverRsp struct {
	MessageHeader

	// 协议版本,不是报文内容,但在调用encode方法前需要设置此值
	Version Version
	// contains filtered or unexported fields
}

func (*DeliverRsp) Decode

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

func (*DeliverRsp) Encode

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

func (*DeliverRsp) Log

func (r *DeliverRsp) Log() (rt []log.Field)

func (*DeliverRsp) MsgId

func (r *DeliverRsp) MsgId() string

func (*DeliverRsp) Status

func (r *DeliverRsp) Status() Status

func (*DeliverRsp) String

func (r *DeliverRsp) String() string

type Delivery

type Delivery struct {
	MessageHeader

	// 协议版本,不是报文内容,但在调用encode方法前需要设置此值
	Version Version
	// contains filtered or unexported fields
}

func NewDeliveryReport

func NewDeliveryReport(ac *codec.AuthConf, mt *Submit, seq uint32, msgId []byte) *Delivery

func (*Delivery) Decode

func (d *Delivery) Decode(seq uint32, frame []byte) error

func (*Delivery) DestTermID

func (d *Delivery) DestTermID() string

func (*Delivery) Encode

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

func (*Delivery) IsReport

func (d *Delivery) IsReport() bool

func (*Delivery) Log

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

func (*Delivery) MsgBytes

func (d *Delivery) MsgBytes() []byte

func (*Delivery) MsgContent

func (d *Delivery) MsgContent() string

func (*Delivery) MsgFormat

func (d *Delivery) MsgFormat() byte

func (*Delivery) MsgId

func (d *Delivery) MsgId() []byte

func (*Delivery) MsgLength

func (d *Delivery) MsgLength() byte

func (*Delivery) RecvTime

func (d *Delivery) RecvTime() string

func (*Delivery) Report

func (d *Delivery) Report() *Report

func (*Delivery) Reserve

func (d *Delivery) Reserve() string

func (*Delivery) SrcTermID

func (d *Delivery) SrcTermID() string

func (*Delivery) String

func (d *Delivery) String() string

func (*Delivery) TlvList

func (d *Delivery) TlvList() *utils.TlvList

func (*Delivery) ToResponse

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

type Exit

type Exit MessageHeader

func NewExit

func NewExit(seq uint32) *Exit

func (*Exit) Decode

func (t *Exit) Decode(seq uint32, _ []byte) error

func (*Exit) Encode

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

func (*Exit) Log

func (t *Exit) Log() []log.Field

func (*Exit) String

func (t *Exit) String() string

func (*Exit) ToResponse

func (t *Exit) ToResponse(_ uint32) codec.Pdu

type ExitRsp

type ExitRsp MessageHeader

func (*ExitRsp) Decode

func (r *ExitRsp) Decode(seq uint32, _ []byte) error

func (*ExitRsp) Encode

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

func (*ExitRsp) Log

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

func (*ExitRsp) String

func (r *ExitRsp) String() string

type Login

type Login struct {
	MessageHeader //  【12字节】消息头

	Version Version //  【1字节】客户端支持的协议版本号
	// contains filtered or unexported fields
}

func NewLogin

func NewLogin(ac *codec.AuthConf, seq uint32) *Login

func (*Login) AuthenticatorClient

func (l *Login) AuthenticatorClient() []byte

func (*Login) Check

func (l *Login) Check(cli *codec.AuthConf) Status

func (*Login) ClientID

func (l *Login) ClientID() string

func (*Login) Decode

func (l *Login) Decode(seq uint32, frame []byte) error

func (*Login) Encode

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

func (*Login) Log

func (l *Login) Log() []log.Field

func (*Login) LoginMode

func (l *Login) LoginMode() byte

func (*Login) SetSecret

func (l *Login) SetSecret(secret string)

func (*Login) String

func (l *Login) String() string

func (*Login) Timestamp

func (l *Login) Timestamp() uint32

func (*Login) ToResponse

func (l *Login) ToResponse(code uint32) codec.Pdu

type LoginRsp

type LoginRsp struct {
	MessageHeader // 协议头, 12字节

	Version Version // 版本,1字节
	// contains filtered or unexported fields
}

func (*LoginRsp) AuthenticatorServer

func (r *LoginRsp) AuthenticatorServer() []byte

func (*LoginRsp) Decode

func (r *LoginRsp) Decode(seq uint32, frame []byte) error

func (*LoginRsp) Encode

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

func (*LoginRsp) Log

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

func (*LoginRsp) Status

func (r *LoginRsp) Status() Status

func (*LoginRsp) String

func (r *LoginRsp) String() string

type MessageHeader

type MessageHeader struct {
	PacketLength uint32
	RequestId    CommandId
	SequenceId   uint32
}

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) String

func (h *MessageHeader) String() string

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) Dlvrd

func (rt *Report) Dlvrd() string

func (*Report) DoneDate

func (rt *Report) DoneDate() string

func (*Report) Encode

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

func (*Report) Id

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

func (*Report) Stat

func (rt *Report) Stat() string

func (*Report) String

func (rt *Report) String() string

func (*Report) Sub

func (rt *Report) Sub() string

func (*Report) SubmitDate

func (rt *Report) SubmitDate() string

type Status

type Status uint32

Status 状态码

func (Status) String

func (s Status) String() string

type Submit

type Submit struct {
	MessageHeader

	// 协议版本,不是报文内容,但在调用encode方法前需要设置此值
	Version Version
	// contains filtered or unexported fields
}

func (*Submit) AtTime

func (s *Submit) AtTime() string

func (*Submit) ChargeTermID

func (s *Submit) ChargeTermID() string

func (*Submit) Decode

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

func (*Submit) DestTermID

func (s *Submit) DestTermID() []string

func (*Submit) DestTermIDCount

func (s *Submit) DestTermIDCount() byte

func (*Submit) Encode

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

func (*Submit) FeeCode

func (s *Submit) FeeCode() string

func (*Submit) FeeType

func (s *Submit) FeeType() string

func (*Submit) FixedFee

func (s *Submit) FixedFee() string

func (*Submit) Log

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

func (*Submit) MsgContent

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

func (*Submit) MsgFormat

func (s *Submit) MsgFormat() byte

func (*Submit) MsgLength

func (s *Submit) MsgLength() byte

func (*Submit) MsgType

func (s *Submit) MsgType() byte

func (*Submit) NeedReport

func (s *Submit) NeedReport() byte

func (*Submit) Priority

func (s *Submit) Priority() byte

func (*Submit) Reserve

func (s *Submit) Reserve() string

func (*Submit) ServiceID

func (s *Submit) ServiceID() string

func (*Submit) SetOptions

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

func (*Submit) SrcTermID

func (s *Submit) SrcTermID() string

func (*Submit) String

func (s *Submit) String() string

func (*Submit) TlvList

func (s *Submit) TlvList() *utils.TlvList

func (*Submit) ToResponse

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

func (*Submit) ValidTime

func (s *Submit) ValidTime() string

type SubmitRsp

type SubmitRsp struct {
	MessageHeader

	// 协议版本,不是报文内容,但在调用encode方法前需要设置此值
	Version Version
	// contains filtered or unexported fields
}

func (*SubmitRsp) Decode

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

func (*SubmitRsp) Encode

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

func (*SubmitRsp) Log

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

func (*SubmitRsp) MsgId

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

func (*SubmitRsp) Status

func (r *SubmitRsp) Status() Status

func (*SubmitRsp) String

func (r *SubmitRsp) String() string

type Version

type Version uint8

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