refactor!: carry the network indicator as pointcode.NetworkIndicator
Merged
GO
15d ago+57+57+01234567890123456789-72-72-01234567890123456789
go-pointcode now provides the network indicator of ITU-T Q.704 (07/96) §14.2.2 (gomaja/go-pointcode#1, merged as 53f963a), and go-m3ua main types the indicator of its protocol data with it (gomaja/go-m3ua#185). Since #20 this package has kept its own copy of that type. RoutingLabel.NI and StackConfig.NetworkIndicator now use pointcode.NetworkIndicator, so an application passes the indicator between the MTP side and the stack without converting it.
Changes
sccp.NetworkIndicatorand its four constants are removed, with no alias, as in go-m3ua. go-pointcode has the same four codes (NIInternational,NIInternationalSpare,NINational,NINationalReserved), withValid,String, text marshaling andParseNetworkIndicator.NewStackandHandleTransfercheck the indicator withValid. They still refuse a value above 3 withErrInvalidRequestand the same message.- stringer no longer generates names for the indicator.
constant_string.gois regenerated with stringer v0.52.0. - Examples: the ASP's
-niis aflag.TextVarthat takes go-pointcode's names (-ni national). Both examples convert theuint8in go-m3ua 6002607's protocol data. The go-m3ua bump that follows removes those conversions. - The library now requires github.com/gomaja/go-pointcode, which uses only the standard library and requires Go 1.26.
Breaking changes
sccp.NetworkIndicator,NIInternational,NISpare,NINationalandNINationalReservedare removed. Usepointcode.NetworkIndicatorand its constants;NISparebecomesNIInternationalSpare.- The indicator prints with go-pointcode's names, for example
nationalwhere it printednational network. - It implements
encoding.TextMarshaler, soencoding/jsonnow writes"NI":"national"instead of"NI":2. A value above 3 fails to marshal withpointcode.ErrRange. That includes the label of a message discarded because of its NI. - The ASP example's
-nitakes a name instead of a number.
Verification
- Library: these are all clean:
go build,go test -count=1,go test -race,go vet, staticcheck (current and the CI pin v0.8.1), golangci-lint andgo fix -diff.- The tests also pass with
GOTOOLCHAIN=go1.26.0. go generatewith stringer v0.52.0 leaves no diff.go mod tidy -diffis clean in both modules.
- The tests also pass with
- Examples:
go build,go vet, both staticchecks and golangci-lint are clean.-ni 2is refused withinvalid value "2" for flag -ni.-hshows(default international).
- Mutations:
- With the
NewStackcheck disabled,TestStackRoutingConfig/invalid_networkfails. - With the
HandleTransfercheck disabled,TestTransferRoutingBounds/nifails.
- With the
encoding/jsonon aRoutingLabel, before and after:- Before:
{"OPC":1,"DPC":2,"SLS":3,"NI":2}. Now:{"OPC":1,"DPC":2,"SLS":3,"NI":"national"}. - NI 4 was written as
4; it is now refused.
- Before:
- RFC 4666, re-checked 2026-10-16:
- It is a Proposed Standard, neither obsoleted nor updated; the RFC Editor and the Datatracker agree.
- Errata 2065 and 4475 are held for document update and 2518 is rejected. None is about §3.3.1.
The wire test over M3UA/SCTP is in the go-m3ua and go-sctp bump that follows.
Summary by cubic
Replaces the package's own network indicator with pointcode.NetworkIndicator from go-pointcode, so applications pass the indicator between the MTP side and the stack without converting it.
sccp.NetworkIndicatorand its constants are removed; usepointcode.NetworkIndicator(NISparebecomesNIInternationalSpare).- The indicator text-marshals with go-pointcode names (
national, not 2), and values above 3 fail to marshal. - The ASP example's
-niflag takes a name instead of a number.