cmpp

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

Documentation

Index

Constants

View Source
const ConnectPktLen = 12 + 6 + 16 + 1 + 4
View Source
const ConnectRspPktLenV2 = 12 + 1 + 16 + 1
View Source
const ConnectRspPktLenV3 = 12 + 4 + 16 + 1

Variables

View Source
var ConnectStatusMap = map[uint32]string{
	0: "成功",
	1: "消息结构错",
	2: "非法源地址",
	3: "认证错",
	4: "版本太高",
	5: "其他错误",
}
View Source
var DeliveryResultMap = map[uint32]string{
	0: "正确",
	1: "消息结构错",
	2: "命令字错",
	3: "消息序号重复",
	4: "消息长度错",
	5: "资费代码错",
	6: "超过最大信息长",
	7: "业务代码错",
	8: "流量控制错",
	9: "未知错误",
}
View Source
var SubmitResultMap = map[uint32]string{
	0:  "正确",
	1:  "消息结构错",
	2:  "命令字错",
	3:  "消息序号重复",
	4:  "消息长度错",
	5:  "资费代码错",
	6:  "超过最大信息长",
	7:  "业务代码错",
	8:  "流量控制错",
	9:  "本网关不负责服务此计费号码",
	10: "Src_Id 错误",
	11: "Msg_src 错误",
	12: "Fee_terminal_Id 错误",
	13: "Dest_terminal_Id 错误",
}

Functions

func NewDelivery

func NewDelivery(ac *codec.AuthConf, phone, msg, dest, serviceId string, seq uint32) codec.RequestPdu

func NewSubmit

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

Types

type ActiveTest

type ActiveTest MessageHeader

func NewActiveTest

func NewActiveTest(seq uint32) *ActiveTest

func (*ActiveTest) Decode

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

func (*ActiveTest) Encode

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

func (*ActiveTest) Log

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

func (*ActiveTest) ToResponse

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

type ActiveTestRsp

type ActiveTestRsp MessageHeader

func (*ActiveTestRsp) Decode

func (at *ActiveTestRsp) Decode(seqId uint32, _ []byte) error

func (*ActiveTestRsp) Encode

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

func (*ActiveTestRsp) Log

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

type CommandId

type CommandId uint32

CommandId 命令定义

const (
	CMPP_REQUEST_MIN, CMPP_RESPONSE_MIN CommandId = iota, 0x80000000 + iota
	CMPP_CONNECT, CMPP_CONNECT_RESP
	CMPP_TERMINATE, CMPP_TERMINATE_RESP

	CMPP_SUBMIT, CMPP_SUBMIT_RESP
	CMPP_DELIVER, CMPP_DELIVER_RESP
	CMPP_QUERY, CMPP_QUERY_RESP
	CMPP_CANCEL, CMPP_CANCEL_RESP
	CMPP_ACTIVE_TEST, CMPP_ACTIVE_TEST_RESP
	CMPP_FWD, CMPP_FWD_RESP
	CMPP_REQUEST_MAX, CMPP_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 ConnStatus

type ConnStatus byte
const (
	ConnStatusOK ConnStatus = iota
	ConnStatusInvalidStruct
	ConnStatusInvalidSrcAddr
	ConnStatusAuthFailed
	ConnStatusVerTooHigh
	ConnStatusOthers
)

func (ConnStatus) String

func (i ConnStatus) String() string

type Connect

type Connect struct {
	MessageHeader // +12 = 12:消息头

	Version Version // +1 = 35:双方协商的版本号(高位 4bit 表示主 版本号,低位 4bit 表示次版本号),对 于3.0的版本,高4bit为3,低4位为 0
	// contains filtered or unexported fields
}

func NewConnect

func NewConnect(ac *codec.AuthConf, seq uint32) *Connect

func (*Connect) AuthenticatorSource

func (c *Connect) AuthenticatorSource() []byte

func (*Connect) Check

func (c *Connect) Check(ac *codec.AuthConf) ConnStatus

func (*Connect) Decode

func (c *Connect) Decode(seq uint32, frame []byte) error

func (*Connect) Encode

func (c *Connect) Encode() []byte

func (*Connect) Log

func (c *Connect) Log() []log.Field

func (*Connect) SetSecret

func (c *Connect) SetSecret(secret string)

func (*Connect) SourceAddr

func (c *Connect) SourceAddr() string

func (*Connect) Timestamp

func (c *Connect) Timestamp() uint32

func (*Connect) ToResponse

func (c *Connect) ToResponse(code uint32) codec.Pdu

type ConnectResp

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

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

func (*ConnectResp) AuthenticatorISMG

func (r *ConnectResp) AuthenticatorISMG() []byte

func (*ConnectResp) Decode

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

func (*ConnectResp) Encode

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

func (*ConnectResp) Log

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

func (*ConnectResp) Status

func (r *ConnectResp) Status() ConnStatus

type Delivery

type Delivery struct {
	MessageHeader

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

Delivery 上行短信或状态报告,不支持长短信

func (*Delivery) Decode

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

func (*Delivery) DestId

func (d *Delivery) DestId() string

func (*Delivery) Encode

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

Encode 调用前需设置版本号 Version

func (*Delivery) IsReport

func (d *Delivery) IsReport() bool

func (*Delivery) LinkID

func (d *Delivery) LinkID() string

func (*Delivery) Log

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

func (*Delivery) MsgContent

func (d *Delivery) MsgContent() string

func (*Delivery) MsgFmt

func (d *Delivery) MsgFmt() uint8

func (*Delivery) MsgId

func (d *Delivery) MsgId() uint64

func (*Delivery) MsgLength

func (d *Delivery) MsgLength() uint8

func (*Delivery) Report

func (d *Delivery) Report() *Report

func (*Delivery) ServiceId

func (d *Delivery) ServiceId() string

func (*Delivery) SrcTerminalId

func (d *Delivery) SrcTerminalId() string

func (*Delivery) SrcTerminalType

func (d *Delivery) SrcTerminalType() uint8

func (*Delivery) ToResponse

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

func (*Delivery) TpPid

func (d *Delivery) TpPid() uint8

func (*Delivery) TpUdhi

func (d *Delivery) TpUdhi() uint8

type DeliveryRsp

type DeliveryRsp struct {
	MessageHeader

	// 协议版本,不是报文内容,ToResponse 会设置此值
	Version Version
	// contains filtered or unexported fields
}

func (*DeliveryRsp) Decode

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

func (*DeliveryRsp) Encode

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

func (*DeliveryRsp) Log

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

func (*DeliveryRsp) SetResult

func (r *DeliveryRsp) SetResult(result DlyResult)

type DlyResult

type DlyResult uint32

func (DlyResult) String

func (i DlyResult) String() string

type MessageHeader

type MessageHeader struct {
	TotalLength uint32
	CommandId   CommandId
	SequenceId  uint32
}

func (*MessageHeader) Decode

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

func (*MessageHeader) Encode

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

func (*MessageHeader) Log

func (header *MessageHeader) Log() []log.Field

type MtResult

type MtResult uint32
const (
	MtStatusOK MtResult = 0
	MtFlowCtrl MtResult = 8
)

func (MtResult) String

func (i MtResult) String() string

type Report

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

func NewReport

func NewReport(msgId uint64, destTerminalId string, submitTime string, doneTime string) *Report

func (*Report) Decode

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

func (*Report) DestTerminalId

func (rt *Report) DestTerminalId() string

func (*Report) DoneTime

func (rt *Report) DoneTime() string

func (*Report) Encode

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

func (*Report) MsgId

func (rt *Report) MsgId() uint64

func (*Report) SmscSequence

func (rt *Report) SmscSequence() uint32

func (*Report) Stat

func (rt *Report) Stat() string

func (*Report) String

func (rt *Report) String() string

func (*Report) SubmitTime

func (rt *Report) SubmitTime() string

type Submit

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

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

func (*Submit) AtTime

func (s *Submit) AtTime() string

func (*Submit) Decode

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

func (*Submit) DestTerminalId

func (s *Submit) DestTerminalId() string

func (*Submit) DestTerminalType

func (s *Submit) DestTerminalType() uint8

func (*Submit) DestUsrTl

func (s *Submit) DestUsrTl() uint8

func (*Submit) Encode

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

func (*Submit) FeeCode

func (s *Submit) FeeCode() string

func (*Submit) FeeTerminalId

func (s *Submit) FeeTerminalId() string

func (*Submit) FeeTerminalType

func (s *Submit) FeeTerminalType() uint8

func (*Submit) FeeType

func (s *Submit) FeeType() string

func (*Submit) FeeUsertype

func (s *Submit) FeeUsertype() uint8

func (*Submit) LinkID

func (s *Submit) LinkID() string

func (*Submit) Log

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

func (*Submit) MsgContent

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

func (*Submit) MsgFmt

func (s *Submit) MsgFmt() uint8

func (*Submit) MsgId

func (s *Submit) MsgId() uint64

func (*Submit) MsgLength

func (s *Submit) MsgLength() uint8

func (*Submit) MsgLevel

func (s *Submit) MsgLevel() uint8

func (*Submit) MsgSrc

func (s *Submit) MsgSrc() string

func (*Submit) PkNumber

func (s *Submit) PkNumber() uint8

func (*Submit) PkTotal

func (s *Submit) PkTotal() uint8

func (*Submit) RegisteredDel

func (s *Submit) RegisteredDel() uint8

func (*Submit) ServiceId

func (s *Submit) ServiceId() string

func (*Submit) SrcId

func (s *Submit) SrcId() string

func (*Submit) TermIds

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

func (*Submit) ToDeliveryReport

func (s *Submit) ToDeliveryReport(msgId uint64) *Delivery

func (*Submit) ToResponse

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

func (*Submit) TpPid

func (s *Submit) TpPid() uint8

func (*Submit) TpUdhi

func (s *Submit) TpUdhi() uint8

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() uint64

func (*SubmitRsp) Result

func (r *SubmitRsp) Result() uint32

type Terminate

type Terminate MessageHeader

func NewTerminate

func NewTerminate(seq uint32) *Terminate

func (*Terminate) Decode

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

func (*Terminate) Encode

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

func (*Terminate) Log

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

func (*Terminate) ToResponse

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

type TerminateRsp

type TerminateRsp MessageHeader

func (*TerminateRsp) Decode

func (r *TerminateRsp) Decode(seqId uint32, _ []byte) error

func (*TerminateRsp) Encode

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

func (*TerminateRsp) Log

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

type Version

type Version uint8
const (
	V30 Version = 0x30
	V21 Version = 0x21
	V20 Version = 0x20
)

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