Skip to content

Commit

Permalink
PartyAddress can be two bytes (Route on SSN without PC)
Browse files Browse the repository at this point in the history
  • Loading branch information
linouxis9 committed Mar 21, 2024
1 parent 1c9ff26 commit b234332
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
5 changes: 4 additions & 1 deletion params/party-address.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func ParsePartyAddress(b []byte) (*PartyAddress, error) {

// UnmarshalBinary sets the values retrieved from byte sequence in a SCCP common header.
func (p *PartyAddress) UnmarshalBinary(b []byte) error {
if len(b) < 3 {
if len(b) < 2 {
return io.ErrUnexpectedEOF
}
p.Length = b[0]
Expand All @@ -126,6 +126,9 @@ func (p *PartyAddress) UnmarshalBinary(b []byte) error {
if p.HasSSN() {
p.SubsystemNumber = b[offset]
offset++
}

if p.GTI() != 0 {
if offset >= len(b) {
return io.ErrUnexpectedEOF
}
Expand Down
29 changes: 29 additions & 0 deletions sccp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,35 @@ var testcases = []struct {
return nil, err
}

return v, nil
},
},
{
description: "UDT-2Bytes-PartyAddress",
structured: sccp.NewUDT(
1, // Protocol Class
true, // Message handling
params.NewPartyAddress( // CalledPartyAddress: 1234567890123456
0x42, 0, 6, 0x00, // Indicator, SPC, SSN, TT
0x00, 0x00, 0x00, // NP, ES, NAI
[]byte{}, // GlobalTitleInformation
),
params.NewPartyAddress( // CalledPartyAddress: 1234567890123456
0x42, 0, 7, 0x00, // Indicator, SPC, SSN, TT
0x00, 0x00, 0x00, // NP, ES, NAI
[]byte{}, // GlobalTitleInformation
),
[]byte{},
),
serialized: []byte{
0x09, 0x81, 0x03, 0x05, 0x07, 0x02, 0x42, 0x06, 0x02, 0x42, 0x07, 0x00,
},
decodeFunc: func(b []byte) (serializable, error) {
v, err := sccp.ParseUDT(b)
if err != nil {
return nil, err
}

return v, nil
},
},
Expand Down

0 comments on commit b234332

Please sign in to comment.