refactor!: carry the network indicator as pointcode.NetworkIndicator

Merged
GO
15d ago
+57-72

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.NetworkIndicator and its four constants are removed, with no alias, as in go-m3ua. go-pointcode has the same four codes (NIInternational, NIInternationalSpare, NINational, NINationalReserved), with Valid, String, text marshaling and ParseNetworkIndicator.
  • NewStack and HandleTransfer check the indicator with Valid. They still refuse a value above 3 with ErrInvalidRequest and the same message.
  • stringer no longer generates names for the indicator. constant_string.go is regenerated with stringer v0.52.0.
  • Examples: the ASP's -ni is a flag.TextVar that takes go-pointcode's names (-ni national). Both examples convert the uint8 in 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, NINational and NINationalReserved are removed. Use pointcode.NetworkIndicator and its constants; NISpare becomes NIInternationalSpare.
  • The indicator prints with go-pointcode's names, for example national where it printed national network.
  • It implements encoding.TextMarshaler, so encoding/json now writes "NI":"national" instead of "NI":2. A value above 3 fails to marshal with pointcode.ErrRange. That includes the label of a message discarded because of its NI.
  • The ASP example's -ni takes 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 and go fix -diff.
    • The tests also pass with GOTOOLCHAIN=go1.26.0.
    • go generate with stringer v0.52.0 leaves no diff.
    • go mod tidy -diff is clean in both modules.
  • Examples:
    • go build, go vet, both staticchecks and golangci-lint are clean.
    • -ni 2 is refused with invalid value "2" for flag -ni.
    • -h shows (default international).
  • Mutations:
    • With the NewStack check disabled, TestStackRoutingConfig/invalid_network fails.
    • With the HandleTransfer check disabled, TestTransferRoutingBounds/ni fails.
  • encoding/json on a RoutingLabel, 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.
  • 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.NetworkIndicator and its constants are removed; use pointcode.NetworkIndicator (NISpare becomes NIInternationalSpare).
  • The indicator text-marshals with go-pointcode names (national, not 2), and values above 3 fail to marshal.
  • The ASP example's -ni flag takes a name instead of a number.