Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix v2 imports, add *RespSeq(seq uint32) PDU functions with tests #103

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SMPP 3.4

[![GoDoc](https://godoc.org/github.com/fiorix/go-smpp?status.svg)](https://godoc.org/github.com/fiorix/go-smpp) [![Go Report Card](https://goreportcard.com/badge/github.com/fiorix/go-smpp)](https://goreportcard.com/report/github.com/fiorix/go-smpp) [![Build Status](https://secure.travis-ci.org/fiorix/go-smpp.png)](https://travis-ci.org/fiorix/go-smpp)
[![GoDoc](https://godoc.org/github.com/fiorix/go-smpp/v2?status.svg)](https://godoc.org/github.com/fiorix/go-smpp/v2) [![Go Report Card](https://goreportcard.com/badge/github.com/fiorix/go-smpp/v2)](https://goreportcard.com/report/github.com/fiorix/go-smpp/v2) [![Build Status](https://secure.travis-ci.org/fiorix/go-smpp.png)](https://travis-ci.org/fiorix/go-smpp)

This is an implementation of SMPP 3.4 for Go, based on the original
[smpp34](https://github.com/CodeMonkeyKevin/smpp34) from Kevin Patel.
Expand Down
6 changes: 3 additions & 3 deletions cmd/sms/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (

"github.com/urfave/cli"

"github.com/fiorix/go-smpp/smpp"
"github.com/fiorix/go-smpp/smpp/pdu/pdufield"
"github.com/fiorix/go-smpp/smpp/pdu/pdutext"
"github.com/fiorix/go-smpp/v2/smpp"
"github.com/fiorix/go-smpp/v2/smpp/pdu/pdufield"
"github.com/fiorix/go-smpp/v2/smpp/pdu/pdutext"
)

// Version of smppcli.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/fiorix/go-smpp/v2
go 1.15

require (
github.com/fiorix/go-smpp v0.0.0-20210403173735-2894b96e70ba
github.com/stretchr/testify v1.7.0
github.com/urfave/cli v1.22.5
golang.org/x/text v0.3.6
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
Expand Down
11 changes: 9 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/fiorix/go-smpp v0.0.0-20210403173735-2894b96e70ba h1:vBqABUa2HUSc6tj22Tw+ZMVGHuBzKtljM38kbRanmrM=
github.com/fiorix/go-smpp v0.0.0-20210403173735-2894b96e70ba/go.mod h1:VfKFK7fGeCP81xEhbrOqUEh45n73Yy6jaPWwTVbxprI=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba h1:O8mE0/t419eoIwhTFpKVkHiTs/Igowgfkj25AcZrtiE=
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 2 additions & 2 deletions smpp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"sync"
"time"

"github.com/fiorix/go-smpp/smpp/pdu"
"github.com/fiorix/go-smpp/smpp/pdu/pdufield"
"github.com/fiorix/go-smpp/v2/smpp/pdu"
"github.com/fiorix/go-smpp/v2/smpp/pdu/pdufield"
)

// ConnStatus is an abstract interface for a connection status change.
Expand Down
2 changes: 1 addition & 1 deletion smpp/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"net"
"sync"

"github.com/fiorix/go-smpp/smpp/pdu"
"github.com/fiorix/go-smpp/v2/smpp/pdu"
)

var (
Expand Down
6 changes: 3 additions & 3 deletions smpp/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ package smpp
import (
"testing"

"github.com/fiorix/go-smpp/smpp/pdu"
"github.com/fiorix/go-smpp/smpp/pdu/pdufield"
"github.com/fiorix/go-smpp/smpp/smpptest"
"github.com/fiorix/go-smpp/v2/smpp/pdu"
"github.com/fiorix/go-smpp/v2/smpp/pdu/pdufield"
"github.com/fiorix/go-smpp/v2/smpp/smpptest"
)

func TestConn(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions smpp/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (

"golang.org/x/time/rate"

"github.com/fiorix/go-smpp/smpp"
"github.com/fiorix/go-smpp/smpp/pdu"
"github.com/fiorix/go-smpp/smpp/pdu/pdufield"
"github.com/fiorix/go-smpp/smpp/pdu/pdutext"
"github.com/fiorix/go-smpp/v2/smpp"
"github.com/fiorix/go-smpp/v2/smpp/pdu"
"github.com/fiorix/go-smpp/v2/smpp/pdu/pdufield"
"github.com/fiorix/go-smpp/v2/smpp/pdu/pdutext"
)

func ExampleReceiver() {
Expand Down
4 changes: 2 additions & 2 deletions smpp/pdu/body.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ package pdu
import (
"io"

"github.com/fiorix/go-smpp/smpp/pdu/pdufield"
"github.com/fiorix/go-smpp/smpp/pdu/pdutlv"
"github.com/fiorix/go-smpp/v2/smpp/pdu/pdufield"
"github.com/fiorix/go-smpp/v2/smpp/pdu/pdutlv"
)

// MaxSize is the maximum size allowed for a PDU.
Expand Down
4 changes: 2 additions & 2 deletions smpp/pdu/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"io"
"sync/atomic"

"github.com/fiorix/go-smpp/smpp/pdu/pdufield"
"github.com/fiorix/go-smpp/smpp/pdu/pdutlv"
"github.com/fiorix/go-smpp/v2/smpp/pdu/pdufield"
"github.com/fiorix/go-smpp/v2/smpp/pdu/pdutlv"
)

var nextSeq uint32
Expand Down
2 changes: 1 addition & 1 deletion smpp/pdu/pdufield/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package pdufield
import (
"fmt"

"github.com/fiorix/go-smpp/smpp/pdu/pdutext"
"github.com/fiorix/go-smpp/v2/smpp/pdu/pdutext"
)

// Map is a collection of PDU field data indexed by name.
Expand Down
2 changes: 1 addition & 1 deletion smpp/pdu/pdufield/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"bytes"
"testing"

"github.com/fiorix/go-smpp/smpp/pdu/pdutext"
"github.com/fiorix/go-smpp/v2/smpp/pdu/pdutext"
)

func TestMapSet(t *testing.T) {
Expand Down
30 changes: 15 additions & 15 deletions smpp/pdu/pdutext/gsm7.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@
package pdutext

import (
"golang.org/x/text/transform"
"github.com/fiorix/go-smpp/smpp/encoding"
"github.com/fiorix/go-smpp/v2/smpp/encoding"
"golang.org/x/text/transform"
)

// GSM 7-bit (unpacked)
type GSM7 []byte

// Type implements the Codec interface.
func (s GSM7) Type() DataCoding {
return DefaultType
return DefaultType
}

// Encode to GSM 7-bit (unpacked)
func (s GSM7) Encode() []byte {
e := encoding.GSM7(false).NewEncoder()
es, _, err := transform.Bytes(e, s)
if err != nil {
return s
}
return es
e := encoding.GSM7(false).NewEncoder()
es, _, err := transform.Bytes(e, s)
if err != nil {
return s
}
return es
}

// Decode from GSM 7-bit (unpacked)
func (s GSM7) Decode() []byte {
e := encoding.GSM7(false).NewDecoder()
es, _, err := transform.Bytes(e, s)
if err != nil {
return s
}
return es
e := encoding.GSM7(false).NewDecoder()
es, _, err := transform.Bytes(e, s)
if err != nil {
return s
}
return es
}
30 changes: 15 additions & 15 deletions smpp/pdu/pdutext/gsm7packed.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@
package pdutext

import (
"golang.org/x/text/transform"
"github.com/fiorix/go-smpp/smpp/encoding"
"github.com/fiorix/go-smpp/v2/smpp/encoding"
"golang.org/x/text/transform"
)

// GSM 7-bit (packed)
type GSM7Packed []byte

// Type implements the Codec interface.
func (s GSM7Packed) Type() DataCoding {
return DefaultType
return DefaultType
}

// Encode to GSM 7-bit (packed)
func (s GSM7Packed) Encode() []byte {
e := encoding.GSM7(true).NewEncoder()
es, _, err := transform.Bytes(e, s)
if err != nil {
return s
}
return es
e := encoding.GSM7(true).NewEncoder()
es, _, err := transform.Bytes(e, s)
if err != nil {
return s
}
return es
}

// Decode from GSM 7-bit (packed)
func (s GSM7Packed) Decode() []byte {
e := encoding.GSM7(true).NewDecoder()
es, _, err := transform.Bytes(e, s)
if err != nil {
return s
}
return es
e := encoding.GSM7(true).NewDecoder()
es, _, err := transform.Bytes(e, s)
if err != nil {
return s
}
return es
}
60 changes: 58 additions & 2 deletions smpp/pdu/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
package pdu

import (
"github.com/fiorix/go-smpp/smpp/pdu/pdufield"
"github.com/fiorix/go-smpp/smpp/pdu/pdutlv"
"github.com/fiorix/go-smpp/v2/smpp/pdu/pdufield"
"github.com/fiorix/go-smpp/v2/smpp/pdu/pdutlv"
)

// PDU Types.
Expand Down Expand Up @@ -54,6 +54,13 @@ func NewGenericNACK() Body {
return b
}

// NewGenericNACKSeq creates and initializes a new GenericNACK PDU for a specific seq.
func NewGenericNACKSeq(seq uint32) Body {
b := newGenericNACK(&Header{ID: GenericNACKID, Seq: seq})
b.init()
return b
}

// Bind PDU.
type Bind struct{ *codec }

Expand Down Expand Up @@ -109,20 +116,41 @@ func NewBindReceiverResp() Body {
return b
}

// NewBindReceiverRespSeq creates and initializes a new BindResp PDU for a specific seq.
func NewBindReceiverRespSeq(seq uint32) Body {
b := newBindResp(&Header{ID: BindReceiverRespID, Seq: seq})
b.init()
return b
}

// NewBindTransceiverResp creates and initializes a new BindResp PDU.
func NewBindTransceiverResp() Body {
b := newBindResp(&Header{ID: BindTransceiverRespID})
b.init()
return b
}

// NewBindTransceiverRespSeq creates and initializes a new BindResp PDU for a specific seq.
func NewBindTransceiverRespSeq(seq uint32) Body {
b := newBindResp(&Header{ID: BindTransceiverRespID, Seq: seq})
b.init()
return b
}

// NewBindTransmitterResp creates and initializes a new BindResp PDU.
func NewBindTransmitterResp() Body {
b := newBindResp(&Header{ID: BindTransmitterRespID})
b.init()
return b
}

// NewBindTransmitterRespSeq creates and initializes a new BindResp PDU for a specific seq.
func NewBindTransmitterRespSeq(seq uint32) Body {
b := newBindResp(&Header{ID: BindTransmitterRespID, Seq: seq})
b.init()
return b
}

// QuerySM PDU.
type QuerySM struct{ *codec }

Expand Down Expand Up @@ -167,6 +195,13 @@ func NewQuerySMResp() Body {
return b
}

// NewQuerySMRespSeq creates and initializes a new QuerySMResp PDU for a specific seq.
func NewQuerySMRespSeq(seq uint32) Body {
b := newQuerySMResp(&Header{ID: QuerySMRespID, Seq: seq})
b.init()
return b
}

// SubmitSM PDU.
type SubmitSM struct{ *codec }

Expand Down Expand Up @@ -225,6 +260,13 @@ func NewSubmitSMResp() Body {
return b
}

// NewSubmitSMRespSeq creates and initializes a new SubmitSMResp PDU for a specific seq.
func NewSubmitSMRespSeq(seq uint32) Body {
b := newSubmitSMResp(&Header{ID: SubmitSMRespID, Seq: seq})
b.init()
return b
}

// SubmitMulti PDU.
type SubmitMulti struct{ *codec }

Expand Down Expand Up @@ -284,6 +326,13 @@ func NewSubmitMultiResp() Body {
return b
}

// NewSubmitMultiRespSeq creates and initializes a new SubmitMultiResp PDU for a specific seq.
func NewSubmitMultiRespSeq(seq uint32) Body {
b := newSubmitMultiResp(&Header{ID: SubmitMultiRespID, Seq: seq})
b.init()
return b
}

// DeliverSM PDU.
type DeliverSM struct{ *codec }

Expand Down Expand Up @@ -374,6 +423,13 @@ func NewUnbindResp() Body {
return b
}

// NewUnbindRespSeq creates and initializes a UnbindResp PDU for a specific seq.
func NewUnbindRespSeq(seq uint32) Body {
b := newUnbindResp(&Header{ID: UnbindRespID, Seq: seq})
b.init()
return b
}

// EnquireLink PDU.
type EnquireLink struct{ *codec }

Expand Down
Loading