diff --git a/internal/db/sms_delivery.go b/internal/db/sms_delivery.go index 21fb436e..1bb8d302 100644 --- a/internal/db/sms_delivery.go +++ b/internal/db/sms_delivery.go @@ -218,29 +218,33 @@ func MarkSMSDeliveryPartReport(inReplyTo, callID, deviceID string, rpMR int, sta var part SMSDeliveryPart var err error - if inReplyTo != "" { - part, err = findLatest(baseQuery().Where("sms_delivery_part.call_id = ?", inReplyTo)) - } - if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - return SMSDeliveryPart{}, err - } - if part.ID == 0 && callID != "" { - part, err = findLatest(baseQuery().Where("sms_delivery_part.call_id = ?", callID)) + if keys := smsCallIDLookupValues(inReplyTo); len(keys) > 0 { + part, err = findLatest(baseQuery().Where("sms_delivery_part.call_id IN ?", keys)) if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { return SMSDeliveryPart{}, err } - } - if part.ID == 0 && rpMR >= 0 { - cutoff := at.Add(-120 * time.Second) - part, err = findLatest(baseQuery(). - Where("sms_delivery_part.rp_mr = ? AND sms_delivery_part.created_at >= ?", rpMR, cutoff). - Where("sms_delivery_part.state IN ?", []string{SMSDeliveryPartStatePending, SMSDeliveryPartStateAcked, SMSDeliveryPartStateFailed, SMSDeliveryPartStateTimeout})) - if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - return SMSDeliveryPart{}, err + if part.ID == 0 { + return SMSDeliveryPart{}, gorm.ErrRecordNotFound + } + } else { + if callID != "" { + part, err = findLatest(baseQuery().Where("sms_delivery_part.call_id IN ?", smsCallIDLookupValues(callID))) + if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { + return SMSDeliveryPart{}, err + } + } + if part.ID == 0 && rpMR >= 0 { + cutoff := at.Add(-120 * time.Second) + part, err = findLatest(baseQuery(). + Where("sms_delivery_part.rp_mr = ? AND sms_delivery_part.created_at >= ?", rpMR, cutoff). + Where("sms_delivery_part.state IN ?", []string{SMSDeliveryPartStatePending, SMSDeliveryPartStateAcked, SMSDeliveryPartStateFailed, SMSDeliveryPartStateTimeout})) + if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { + return SMSDeliveryPart{}, err + } + } + if part.ID == 0 { + return SMSDeliveryPart{}, gorm.ErrRecordNotFound } - } - if part.ID == 0 { - return SMSDeliveryPart{}, gorm.ErrRecordNotFound } reportAt := at @@ -267,6 +271,30 @@ func MarkSMSDeliveryPartReport(inReplyTo, callID, deviceID string, rpMR int, sta return part, nil } +func smsCallIDLookupValues(value string) []string { + value = strings.TrimSpace(value) + if value == "" { + return nil + } + seen := map[string]struct{}{value: {}} + out := []string{value} + add := func(candidate string) { + candidate = strings.TrimSpace(candidate) + if candidate == "" { + return + } + if _, ok := seen[candidate]; ok { + return + } + seen[candidate] = struct{}{} + out = append(out, candidate) + } + trimmed := strings.Trim(value, "<>\"") + add(trimmed) + add(strings.ToLower(trimmed)) + return out +} + func RecomputeSMSDelivery(messageID string, at time.Time) error { if DB == nil { return nil diff --git a/internal/device/vowifi_delivery_store_test.go b/internal/device/vowifi_delivery_store_test.go index 7264956e..fe7bbffe 100644 --- a/internal/device/vowifi_delivery_store_test.go +++ b/internal/device/vowifi_delivery_store_test.go @@ -1,12 +1,13 @@ package device import ( + "errors" "path/filepath" "testing" "time" - "github.com/yibaiba/hideck/internal/db" "github.com/iniwex5/vowifi-go/runtimehost/messaging" + "github.com/yibaiba/hideck/internal/db" ) var _ messaging.InboundFragmentStore = vowifiDeliveryStore{} @@ -69,6 +70,32 @@ func TestVoWiFiDeliveryStoreReportsMatchedPart(t *testing.T) { assertInboundFragmentStoreRoundTrip(t, store, now) } +func TestVoWiFiDeliveryStoreRejectsMismatchedInReplyTo(t *testing.T) { + previousDB := db.DB + if err := db.Init(filepath.Join(t.TempDir(), "delivery.db")); err != nil { + t.Fatal(err) + } + t.Cleanup(func() { + if sqlDB, err := db.DB.DB(); err == nil { + _ = sqlDB.Close() + } + db.DB = previousDB + }) + + store := vowifiDeliveryStore{} + now := time.Now() + if err := store.CreateSMSDelivery("message-1", "imsi-1", "wwan0", "+10086", "hello", 1, now); err != nil { + t.Fatal(err) + } + if err := store.UpsertSMSDeliveryPart("message-1", 1, "call-1", 17, "pending", now); err != nil { + t.Fatal(err) + } + _, err := store.MarkSMSDeliveryPartReport("other-call", "report-1", "wwan0", 17, "acked", 200, 0, "", now) + if !errors.Is(err, messaging.ErrDeliveryNotFound) { + t.Fatalf("mismatched In-Reply-To err = %v", err) + } +} + func assertInboundFragmentStoreRoundTrip(t *testing.T, store vowifiDeliveryStore, at time.Time) { t.Helper() scope := messaging.InboundFragmentScope{ diff --git a/third_party/vowifi-go/internal/runtimehostcarrier/convert.go b/third_party/vowifi-go/internal/runtimehostcarrier/convert.go index 05e930f0..a90ec9fb 100644 --- a/third_party/vowifi-go/internal/runtimehostcarrier/convert.go +++ b/third_party/vowifi-go/internal/runtimehostcarrier/convert.go @@ -82,7 +82,7 @@ func toInternalBase(cfg carrier.EffectiveCarrierConfig) policy.EffectiveCarrierC Websheet: cfg.E911.Websheet, EntitlementEndpoint: cfg.E911.EntitlementEndpoint, }, IPStackType: cfg.IPStackType, EPDGAddr: cfg.EPDGAddr, EPDGAddrSource: cfg.EPDGAddrSource, - EPDGPort: cfg.EPDGPort, APN: cfg.APN, DNSServer: cfg.DNSServer, + EmergencyEPDGAddr: cfg.EmergencyEPDGAddr, EPDGPort: cfg.EPDGPort, APN: cfg.APN, DNSServer: cfg.DNSServer, } } @@ -132,7 +132,7 @@ func fromInternalBase(cfg policy.EffectiveCarrierConfig) carrier.EffectiveCarrie Websheet: cfg.E911.Websheet, EntitlementEndpoint: cfg.E911.EntitlementEndpoint, }, IPStackType: cfg.IPStackType, EPDGAddr: cfg.EPDGAddr, EPDGAddrSource: cfg.EPDGAddrSource, - EPDGPort: cfg.EPDGPort, APN: cfg.APN, DNSServer: cfg.DNSServer, + EmergencyEPDGAddr: cfg.EmergencyEPDGAddr, EPDGPort: cfg.EPDGPort, APN: cfg.APN, DNSServer: cfg.DNSServer, } } diff --git a/third_party/vowifi-go/internal/runtimehostcarrier/convert_test.go b/third_party/vowifi-go/internal/runtimehostcarrier/convert_test.go index 2d5e21e6..0b8e49f2 100644 --- a/third_party/vowifi-go/internal/runtimehostcarrier/convert_test.go +++ b/third_party/vowifi-go/internal/runtimehostcarrier/convert_test.go @@ -69,7 +69,8 @@ func populatedCarrierConfig() carrier.EffectiveCarrierConfig { EntitlementEndpoint: "https://endpoint.example", }, IPStackType: "dual", EPDGAddr: "epdg.example", EPDGAddrSource: "carrier", - EPDGPort: 4500, APN: "ims", DNSServer: "192.0.2.53", NATKeepaliveSeconds: 20, + EmergencyEPDGAddr: "sos.epdg.example", + EPDGPort: 4500, APN: "ims", DNSServer: "192.0.2.53", NATKeepaliveSeconds: 20, DPDIntervalSeconds: 30, AKAChallengeMode: "relay", IKEIdentityMode: "impi", AKAIdentityMode: "isim", IKEProposals: []string{"ike-a", "ike-b"}, ESPProposals: []string{"esp-a", "esp-b"}, EnableLegacyCiphers: true, diff --git a/third_party/vowifi-go/internal/vowifi/imscore/register_transport_test.go b/third_party/vowifi-go/internal/vowifi/imscore/register_transport_test.go index 7befab7c..9ff41bdb 100644 --- a/third_party/vowifi-go/internal/vowifi/imscore/register_transport_test.go +++ b/third_party/vowifi-go/internal/vowifi/imscore/register_transport_test.go @@ -260,7 +260,7 @@ func TestRegisterContactUsesRecoveredCarrierTemplate(t *testing.T) { RegisterTemplate: IMSRegisterTemplate{ AccessType: "wlan1", ICSIRef: icsi, ContactOrder: []string{ - "access_type", "sip_instance", "audio", "smsip", "icsi_ref", + "access_type", "sip_instance", "audio", "smsip", "smsip_msisdn_less", "icsi_ref", "mid_call", "srvcc_alerting", "ps2cs_srvcc_orig_pre_alerting", }, }, @@ -275,7 +275,7 @@ func TestRegisterContactUsesRecoveredCarrierTemplate(t *testing.T) { want := `` + `;+g.3gpp.accesstype="wlan1"` + `;+sip.instance=""` + - `;audio;+g.3gpp.smsip` + + `;audio;+g.3gpp.smsip;+g.3gpp.smsip-msisdn-less` + `;+g.3gpp.icsi-ref="` + icsi + `"` + `;+g.3gpp.mid-call;+g.3gpp.srvcc-alerting` + `;+g.3gpp.ps2cs-srvcc-orig-pre-alerting` diff --git a/third_party/vowifi-go/internal/vowifi/imscore/sms_delivery_report.go b/third_party/vowifi-go/internal/vowifi/imscore/sms_delivery_report.go index c2a40f2d..6e547153 100644 --- a/third_party/vowifi-go/internal/vowifi/imscore/sms_delivery_report.go +++ b/third_party/vowifi-go/internal/vowifi/imscore/sms_delivery_report.go @@ -10,9 +10,12 @@ import ( "github.com/iniwex5/vowifi-go/internal/smscodec" "github.com/iniwex5/vowifi-go/internal/vowifi/events" "github.com/iniwex5/vowifi-go/internal/vowifi/logging" + "github.com/iniwex5/vowifi-go/internal/vowifi/smsdelivery" "github.com/warthog618/sms/encoding/tpdu" ) +var errSMSDeliveryReportUnmatched = errors.New("imscore: SMS delivery report did not match a pending part") + const ( smsDeliveryStateAcked = "acked" smsSubmitReportAck = "submit report ack" @@ -28,10 +31,6 @@ type smsDeliveryReport struct { } func (s *Service) handleInboundRPReport(raw string, info smscodec.RPDUInfo, state, errorText string) (inboundSIPResult, error) { - response, err := buildSIPRequestResponse(raw, 200) - if err != nil { - return inboundSIPResult{}, err - } if state == smsDeliveryStateAcked && strings.TrimSpace(errorText) == "" { errorText = smsSubmitReportAck } @@ -39,7 +38,27 @@ func (s *Service) handleInboundRPReport(raw string, info smscodec.RPDUInfo, stat reference: int(info.MR), state: state, sipCode: 0, rpCause: info.Cause, errorText: errorText, } - return inboundSIPResult{response: response}, s.recordSMSDeliveryReport(raw, report) + inReplyTo := strings.TrimSpace(rawSIPHeaderValue(raw, "In-Reply-To")) + matchedPending := false + if inReplyTo != "" { + s.outboundMu.Lock() + matchedPending = s.matchPendingByCallIDLocked(inReplyTo) != nil + s.outboundMu.Unlock() + } + recordErr := s.recordSMSDeliveryReport(raw, report) + status := 200 + if inReplyTo != "" && !matchedPending && (s.delivery == nil || unmatchedSMSDeliveryReport(recordErr)) { + status = 488 + recordErr = nil + logging.WarnRate("sms-rp-report-unmatched-"+s.DeviceID(), 30*time.Second, + "IMS RP-ACK/RP-ERROR In-Reply-To did not match a submitted SM", + "device", s.DeviceID()) + } + response, err := buildSIPRequestResponse(raw, status) + if err != nil { + return inboundSIPResult{}, err + } + return inboundSIPResult{response: response}, recordErr } func (s *Service) handleInboundTPStatusReport(raw string, rpMR byte, payload []byte) (inboundSIPResult, error) { @@ -87,7 +106,6 @@ func parseTPStatusReport(payload []byte) (smsDeliveryReport, error) { } func (s *Service) recordSMSDeliveryReport(raw string, report smsDeliveryReport) error { - s.handleMORPError(report.rpCause, report.errorText) inReplyTo := rawSIPHeaderValue(raw, "In-Reply-To") callID := rawSIPHeaderValue(raw, "Call-ID") if s.delivery == nil { @@ -103,11 +121,15 @@ func (s *Service) recordSMSDeliveryReport(raw string, report smsDeliveryReport) report.rpCause, report.errorText, reportedAt, ) if err != nil { + if unmatchedSMSDeliveryReport(err) { + return errSMSDeliveryReportUnmatched + } return fmt.Errorf("imscore: persist SMS delivery report: %w", err) } if !match.Matched || strings.TrimSpace(match.MessageID) == "" { - return errors.New("imscore: SMS delivery report did not match a pending part") + return errSMSDeliveryReportUnmatched } + s.handleMORPError(report.rpCause, report.errorText) if err := s.delivery.RecomputeSMSDelivery(match.MessageID, time.Now()); err != nil { return fmt.Errorf("imscore: recompute SMS delivery: %w", err) } @@ -228,6 +250,16 @@ func recommendCSFallback(sipCode int) bool { return sipCode == 408 || sipCode == 480 || sipCode == 503 } +func unmatchedSMSDeliveryReport(err error) bool { + if err == nil { + return false + } + if errors.Is(err, errSMSDeliveryReportUnmatched) || errors.Is(err, smsdelivery.ErrDeliveryNotFound) { + return true + } + return strings.Contains(strings.ToLower(err.Error()), "not found") +} + func (s *Service) waitDeliveryReport( ctx context.Context, pending *smsPendingInfo, diff --git a/third_party/vowifi-go/internal/vowifi/imscore/sms_delivery_report_test.go b/third_party/vowifi-go/internal/vowifi/imscore/sms_delivery_report_test.go index 7770d95d..2ffd9a30 100644 --- a/third_party/vowifi-go/internal/vowifi/imscore/sms_delivery_report_test.go +++ b/third_party/vowifi-go/internal/vowifi/imscore/sms_delivery_report_test.go @@ -125,14 +125,29 @@ func TestSuccessfulSIPResponseRetainsRPReportCorrelation(t *testing.T) { } } -func TestUnmatchedDeliveryReportReturnsErrorAfterSIPResponse(t *testing.T) { +func TestUnmatchedDeliveryReportWithInReplyToReturns488(t *testing.T) { service, _, _, _ := newDeliveryReportTestService(t) var response string err := service.dispatchInboundSIP(deliveryReportRequest([]byte{0x03, 0x42}, "missing"), func(value string) error { response = value return nil }) - if err == nil || !strings.Contains(err.Error(), "not found") { + if err != nil { + t.Fatalf("dispatch error = %v", err) + } + if !strings.HasPrefix(response, "SIP/2.0 488") { + t.Fatalf("SIP response = %q", response) + } +} + +func TestUnmatchedDeliveryReportWithoutInReplyToKeeps200(t *testing.T) { + service, _, _, _ := newDeliveryReportTestService(t) + var response string + err := service.dispatchInboundSIP(deliveryReportRequestWithoutInReplyTo([]byte{0x03, 0x42}), func(value string) error { + response = value + return nil + }) + if err == nil || !errors.Is(err, errSMSDeliveryReportUnmatched) { t.Fatalf("dispatch error = %v", err) } if !strings.HasPrefix(response, "SIP/2.0 200") { @@ -140,6 +155,37 @@ func TestUnmatchedDeliveryReportReturnsErrorAfterSIPResponse(t *testing.T) { } } +func TestLateDeliveryReportMatchesStoreAfterPendingExpiry(t *testing.T) { + service, subscriber, store, outbound := newDeliveryReportTestService(t) + outcome := sendDeliveryTestSMS(t, service, subscriber, outbound, "hello") + part := store.part(outcome.MessageID, 1) + if service.takePendingSMSByCallID(part.callID) == nil { + t.Fatal("expected pending SMS before the late report") + } + response := dispatchDeliveryReport(t, service, deliveryReportRequest([]byte{0x03, byte(part.rpMR)}, part.callID)) + if !strings.HasPrefix(response, "SIP/2.0 200") { + t.Fatalf("SIP response = %q", response) + } + assertDeliveryStatus(t, store, outcome.MessageID, smsDeliveryStateAcked, smsDeliveryStateAcked) +} + +func TestMismatchedInReplyToDoesNotStealRPReference(t *testing.T) { + service, subscriber, store, outbound := newDeliveryReportTestService(t) + outcome := sendDeliveryTestSMS(t, service, subscriber, outbound, "hello") + part := store.part(outcome.MessageID, 1) + response := dispatchDeliveryReport(t, service, deliveryReportRequest([]byte{0x03, byte(part.rpMR)}, "other-call")) + if !strings.HasPrefix(response, "SIP/2.0 488") { + t.Fatalf("SIP response = %q", response) + } + assertDeliveryStatus(t, store, outcome.MessageID, smsDeliveryStatePending, smsDeliveryStatePending) + service.outboundMu.Lock() + pending := service.matchPendingByCallIDLocked(part.callID) + service.outboundMu.Unlock() + if pending == nil { + t.Fatal("mismatched In-Reply-To completed the pending send") + } +} + func TestReportPersistenceFailureDoesNotCompletePendingSend(t *testing.T) { service, subscriber, store, outbound := newDeliveryReportTestService(t) outcome := sendDeliveryTestSMS(t, service, subscriber, outbound, "hello") @@ -234,6 +280,15 @@ func deliveryReportRequest(body []byte, inReplyTo string) string { "Content-Length: %d\r\n\r\n%s", inReplyTo, imsSMSContentType, len(body), body) } +func deliveryReportRequestWithoutInReplyTo(body []byte) string { + return fmt.Sprintf("MESSAGE sip:user@ims.example SIP/2.0\r\n"+ + "Via: SIP/2.0/TCP 10.0.0.1:5060;branch=z9hG4bK-report\r\n"+ + "From: ;tag=remote\r\n"+ + "To: \r\nCall-ID: report-call\r\n"+ + "CSeq: 1 MESSAGE\r\nContent-Type: %s\r\n"+ + "Content-Length: %d\r\n\r\n%s", imsSMSContentType, len(body), body) +} + func networkRPData(t *testing.T, rpMR byte, payload []byte) []byte { t.Helper() originator := smscodec.EncodeAddress("+447802002606") diff --git a/third_party/vowifi-go/internal/vowifi/imscore/sms_delivery_test_store_test.go b/third_party/vowifi-go/internal/vowifi/imscore/sms_delivery_test_store_test.go index 38ce82bf..56446450 100644 --- a/third_party/vowifi-go/internal/vowifi/imscore/sms_delivery_test_store_test.go +++ b/third_party/vowifi-go/internal/vowifi/imscore/sms_delivery_test_store_test.go @@ -95,14 +95,30 @@ func (s *memoryDeliveryStore) MarkSMSDeliveryPartReport(inReplyTo, callID, _ str } func (s *memoryDeliveryStore) findPart(inReplyTo, callID string, rpMR int) *memoryDeliveryPart { + if key := normalizeSMSCallID(inReplyTo); key != "" { + for _, parts := range s.parts { + for _, part := range parts { + if normalizeSMSCallID(part.callID) == key { + return part + } + } + } + return nil + } + if key := normalizeSMSCallID(callID); key != "" { + for _, parts := range s.parts { + for _, part := range parts { + if normalizeSMSCallID(part.callID) == key { + return part + } + } + } + } + if rpMR < 0 { + return nil + } for _, parts := range s.parts { for _, part := range parts { - if inReplyTo != "" && part.callID == inReplyTo { - return part - } - if callID != "" && part.callID == callID { - return part - } if part.rpMR == rpMR { return part } diff --git a/third_party/vowifi-go/internal/vowifi/imscore/sms_outbound_test.go b/third_party/vowifi-go/internal/vowifi/imscore/sms_outbound_test.go index 8e682efe..f04f736b 100644 --- a/third_party/vowifi-go/internal/vowifi/imscore/sms_outbound_test.go +++ b/third_party/vowifi-go/internal/vowifi/imscore/sms_outbound_test.go @@ -79,19 +79,38 @@ func (s *captureDeliveryStore) MarkSMSDeliveryPartReport(inReplyTo, callID, _ st s.mu.Lock() defer s.mu.Unlock() s.reportCalls++ - for _, key := range []string{inReplyTo, callID} { - if part, ok := s.parts[key]; ok { - return DeliveryPartMatch{MessageID: part.messageID, PartNo: part.partNo, State: state, Matched: true}, nil - } + if part, ok := s.lookupPartByCallID(inReplyTo); ok { + return DeliveryPartMatch{MessageID: part.messageID, PartNo: part.partNo, State: state, Matched: true}, nil } - for _, part := range s.parts { - if part.rpMR == rpMR { - return DeliveryPartMatch{MessageID: part.messageID, PartNo: part.partNo, State: state, Matched: true}, nil + if strings.TrimSpace(inReplyTo) != "" { + return DeliveryPartMatch{}, errors.New("delivery part not found") + } + if part, ok := s.lookupPartByCallID(callID); ok { + return DeliveryPartMatch{MessageID: part.messageID, PartNo: part.partNo, State: state, Matched: true}, nil + } + if rpMR >= 0 { + for _, part := range s.parts { + if part.rpMR == rpMR { + return DeliveryPartMatch{MessageID: part.messageID, PartNo: part.partNo, State: state, Matched: true}, nil + } } } return DeliveryPartMatch{}, errors.New("delivery part not found") } +func (s *captureDeliveryStore) lookupPartByCallID(callID string) (capturedDeliveryPart, bool) { + key := normalizeSMSCallID(callID) + if key == "" { + return capturedDeliveryPart{}, false + } + for storedID, part := range s.parts { + if normalizeSMSCallID(storedID) == key || normalizeSMSCallID(part.callID) == key { + return part, true + } + } + return capturedDeliveryPart{}, false +} + func (s *captureDeliveryStore) RecomputeSMSDelivery(messageID string, _ time.Time) error { s.mu.Lock() if s.created != nil && s.created.MessageID == messageID { diff --git a/third_party/vowifi-go/internal/vowifi/imsheaders/contact.go b/third_party/vowifi-go/internal/vowifi/imsheaders/contact.go index 12339412..3fb90553 100644 --- a/third_party/vowifi-go/internal/vowifi/imsheaders/contact.go +++ b/third_party/vowifi-go/internal/vowifi/imsheaders/contact.go @@ -199,6 +199,8 @@ func contactParam(name string, values contactParamValues) (ContactParam, bool) { return ContactParam{Name: "audio"}, true case "smsip": return ContactParam{Name: "+g.3gpp.smsip"}, true + case "smsip_msisdn_less": + return ContactParam{Name: "+g.3gpp.smsip-msisdn-less"}, true case "sos": return ContactParam{Name: "sos"}, true case "reg_id": diff --git a/third_party/vowifi-go/internal/vowifi/imsheaders/contact_test.go b/third_party/vowifi-go/internal/vowifi/imsheaders/contact_test.go index 3a4ca190..db326b6c 100644 --- a/third_party/vowifi-go/internal/vowifi/imsheaders/contact_test.go +++ b/third_party/vowifi-go/internal/vowifi/imsheaders/contact_test.go @@ -58,7 +58,7 @@ func TestContactParamsRecoveredOrderAndValues(t *testing.T) { options := ContactOptions{ AccessType: " IEEE-802.11 ", IMEI: "356938035643809", ContactParamOrder: []string{ - "access_type", "sip_instance", "audio", "smsip", "sos", "reg_id", + "access_type", "sip_instance", "audio", "smsip", "smsip_msisdn_less", "sos", "reg_id", "icsi_ref", "mid_call", "srvcc_alerting", "ps2cs_srvcc_orig_pre_alerting", "UNKNOWN", " audio ", }, @@ -66,7 +66,7 @@ func TestContactParamsRecoveredOrderAndValues(t *testing.T) { want := []ContactParam{ {Name: "+g.3gpp.accesstype", Value: `"IEEE-802.11"`}, {Name: "+sip.instance", Value: `""`}, - {Name: "audio"}, {Name: "+g.3gpp.smsip"}, {Name: "sos"}, + {Name: "audio"}, {Name: "+g.3gpp.smsip"}, {Name: "+g.3gpp.smsip-msisdn-less"}, {Name: "sos"}, {Name: "reg-id", Value: "1"}, {Name: "+g.3gpp.icsi-ref", Value: `"` + defaultICSIRef + `"`}, {Name: "+g.3gpp.mid-call"}, {Name: "+g.3gpp.srvcc-alerting"}, diff --git a/third_party/vowifi-go/internal/vowifi/policy/carrier_plan.go b/third_party/vowifi-go/internal/vowifi/policy/carrier_plan.go index 3163ec0f..a9cfcda3 100644 --- a/third_party/vowifi-go/internal/vowifi/policy/carrier_plan.go +++ b/third_party/vowifi-go/internal/vowifi/policy/carrier_plan.go @@ -1,6 +1,9 @@ package policy -import "reflect" +import ( + "reflect" + "strings" +) func (plan CarrierPlan) IsZero() bool { return reflect.DeepEqual(plan, CarrierPlan{}) @@ -18,7 +21,8 @@ func CarrierPlanFromEffectiveConfig(config EffectiveCarrierConfig) CarrierPlan { }, EPDG: EPDGPlan{ IPStackType: config.IPStackType, Addr: config.EPDGAddr, AddrSource: config.EPDGAddrSource, - Port: config.EPDGPort, APN: config.APN, DNSServer: config.DNSServer, + EmergencyAddr: emergencyEPDGAddr(config), + Port: config.EPDGPort, APN: config.APN, DNSServer: config.DNSServer, }, IKE: IKEPlan{ NATKeepaliveSeconds: config.NATKeepaliveSeconds, DPDIntervalSeconds: config.DPDIntervalSeconds, @@ -55,8 +59,9 @@ func EffectiveCarrierConfigFromCarrierPlan(plan CarrierPlan) EffectiveCarrierCon EntitlementURL: plan.E911.EntitlementURL, WebsheetHostPolicy: plan.E911.WebsheetHostPolicy, }, IPStackType: plan.EPDG.IPStackType, EPDGAddr: plan.EPDG.Addr, - EPDGAddrSource: plan.EPDG.AddrSource, EPDGPort: plan.EPDG.Port, - APN: plan.EPDG.APN, DNSServer: plan.EPDG.DNSServer, + EPDGAddrSource: plan.EPDG.AddrSource, EmergencyEPDGAddr: planEmergencyEPDGAddr(plan), + EPDGPort: plan.EPDG.Port, + APN: plan.EPDG.APN, DNSServer: plan.EPDG.DNSServer, NATKeepaliveSeconds: plan.IKE.NATKeepaliveSeconds, DPDIntervalSeconds: plan.IKE.DPDIntervalSeconds, AKAChallengeMode: plan.IKE.AKAChallengeMode, IKEIdentityMode: plan.IKE.IKEIdentityMode, AKAIdentityMode: plan.IKE.AKAIdentityMode, IKEProposals: cloneStrings(plan.IKE.IKEProposals), @@ -79,6 +84,20 @@ func EffectiveCarrierConfigFromCarrierPlan(plan CarrierPlan) EffectiveCarrierCon return config } +func emergencyEPDGAddr(config EffectiveCarrierConfig) string { + if value := strings.TrimSpace(config.EmergencyEPDGAddr); value != "" { + return value + } + return DefaultCarrierEmergencyEPDGAddr(config.MCC, config.MNC) +} + +func planEmergencyEPDGAddr(plan CarrierPlan) string { + if value := strings.TrimSpace(plan.EPDG.EmergencyAddr); value != "" { + return value + } + return DefaultCarrierEmergencyEPDGAddr(plan.Metadata.MCC, plan.Metadata.MNC) +} + func cloneIMSRegisterTemplate(template IMSRegisterTemplate) IMSRegisterTemplate { template.ContactParamOrder = cloneStrings(template.ContactParamOrder) template.SecurityClientMechanisms = cloneMechanisms(template.SecurityClientMechanisms) diff --git a/third_party/vowifi-go/internal/vowifi/policy/defaults.go b/third_party/vowifi-go/internal/vowifi/policy/defaults.go index 4ae36b52..eb8bd42c 100644 --- a/third_party/vowifi-go/internal/vowifi/policy/defaults.go +++ b/third_party/vowifi-go/internal/vowifi/policy/defaults.go @@ -26,7 +26,7 @@ var ( defaultTemporaryStatusCodes = []int{408, 429, 500, 502, 503, 504} defaultForbiddenStatusCodes = []int{403} defaultFallbackStatusCodes = []int{400, 403, 500} - defaultContactParams = []string{"access_type", "sip_instance", "audio", "smsip", "icsi_ref"} + defaultContactParams = []string{"access_type", "sip_instance", "audio", "smsip", "smsip_msisdn_less", "icsi_ref"} defaultSecurityMechanisms = []IPSec3GPPSecurityMechanism{ {Alg: "hmac-md5-96", EAlg: "des-ede3-cbc", Prot: "esp", Mode: "trans"}, {Alg: "hmac-md5-96", EAlg: "aes-cbc", Prot: "esp", Mode: "trans"}, diff --git a/third_party/vowifi-go/internal/vowifi/policy/merge.go b/third_party/vowifi-go/internal/vowifi/policy/merge.go index 6acad11a..03d5eb14 100644 --- a/third_party/vowifi-go/internal/vowifi/policy/merge.go +++ b/third_party/vowifi-go/internal/vowifi/policy/merge.go @@ -12,7 +12,8 @@ func GetGlobalDefaultConfig(mcc, mnc string) EffectiveCarrierConfig { config := EffectiveCarrierConfig{ MCC: mcc, MNC: mnc, IPStackType: "ipv4v6", EPDGAddr: DefaultCarrierStandardEPDGAddr(mcc, mnc), EPDGAddrSource: "standard", - EPDGPort: 500, APN: "ims", DNSServer: defaultDNS, + EmergencyEPDGAddr: DefaultCarrierEmergencyEPDGAddr(mcc, mnc), + EPDGPort: 500, APN: "ims", DNSServer: defaultDNS, NATKeepaliveSeconds: 20, DPDIntervalSeconds: 120, AKAChallengeMode: "minimal", IKEIdentityMode: "epc_nai", AKAIdentityMode: "epc_nai", IKEProposals: DefaultCarrierIKEProposals(), ESPProposals: DefaultCarrierESPProposals(), diff --git a/third_party/vowifi-go/internal/vowifi/policy/policy_test.go b/third_party/vowifi-go/internal/vowifi/policy/policy_test.go index fc4a539a..0331ca6b 100644 --- a/third_party/vowifi-go/internal/vowifi/policy/policy_test.go +++ b/third_party/vowifi-go/internal/vowifi/policy/policy_test.go @@ -23,6 +23,9 @@ func TestDefaultIMSRegisterTemplate(t *testing.T) { if template.SMSReceiverTransport != "" || NormalizeIMSRegisterTemplate(template).SMSReceiverTransport != "dual" { t.Fatalf("receiver defaults = raw %q normalized %q", template.SMSReceiverTransport, NormalizeIMSRegisterTemplate(template).SMSReceiverTransport) } + if !reflect.DeepEqual(template.ContactParamOrder, defaultContactParams) { + t.Fatalf("default contact order = %v", template.ContactParamOrder) + } } func TestNormalizeIMSRegisterPolicy(t *testing.T) { @@ -96,7 +99,8 @@ func TestVoWiFiBlocklistAndErrorChain(t *testing.T) { func TestResolveEmbeddedCarrierPresets(t *testing.T) { giffgaff := ResolveEffectiveCarrierConfig("234", "10") if giffgaff.PresetID != "giffgaff_23410" || giffgaff.DeviceModel != "rmx3366" || - giffgaff.ReauthIntervalSeconds != 0 || giffgaff.EPDGAddrSource != "standard" { + giffgaff.ReauthIntervalSeconds != 0 || giffgaff.EPDGAddrSource != "standard" || + giffgaff.EmergencyEPDGAddr != DefaultCarrierEmergencyEPDGAddr("234", "10") { t.Fatalf("giffgaff = %+v", giffgaff) } if !reflect.DeepEqual(giffgaff.IKEProposals, []string{"aes256-sha512-prfsha512-modp2048"}) { @@ -105,8 +109,8 @@ func TestResolveEmbeddedCarrierPresets(t *testing.T) { cteUK := ResolveEffectiveCarrierConfig("234", "33") if cteUK.PresetID != "CTEUK_23433" || cteUK.IMSRegisterTemplate.SupportedHeader != "path,sec-agree,outbound" || - !reflect.DeepEqual(cteUK.IMSRegisterTemplate.ContactParamOrder[:3], []string{ - "access_type", "sip_instance", "reg_id", + !reflect.DeepEqual(cteUK.IMSRegisterTemplate.ContactParamOrder, []string{ + "access_type", "sip_instance", "reg_id", "audio", "smsip", "smsip_msisdn_less", "icsi_ref", }) || !reflect.DeepEqual(cteUK.IMSRegisterTemplate.ContactOrder, cteUK.IMSRegisterTemplate.ContactParamOrder) { t.Fatalf("CTEUK outbound registration = %+v", cteUK.IMSRegisterTemplate) @@ -114,7 +118,7 @@ func TestResolveEmbeddedCarrierPresets(t *testing.T) { vodafoneUK := ResolveEffectiveCarrierConfig("234", "15") if vodafoneUK.PresetID != "vodafone_uk_23415" || vodafoneUK.DeviceModel != "rmx3366" || vodafoneUK.EPDGAddr != "epdg.epc.mnc015.mcc234.pub.3gppnetwork.org" || - DefaultCarrierEmergencyEPDGAddr("234", "15") != "sos.epdg.epc.mnc015.mcc234.pub.3gppnetwork.org" || + vodafoneUK.EmergencyEPDGAddr != "sos.epdg.epc.mnc015.mcc234.pub.3gppnetwork.org" || vodafoneUK.EPDGAddrSource != "standard" || vodafoneUK.IMSRegisterTemplate.ID != "vodafone_uk_23415" { t.Fatalf("vodafone uk = %+v", vodafoneUK) @@ -122,8 +126,8 @@ func TestResolveEmbeddedCarrierPresets(t *testing.T) { if !strings.Contains(vodafoneUK.IMSRegisterTemplate.ICSIRef, "ims.icsi.sms") { t.Fatalf("vodafone uk ICSI missing SMS: %q", vodafoneUK.IMSRegisterTemplate.ICSIRef) } - if !reflect.DeepEqual(vodafoneUK.IMSRegisterTemplate.ContactParamOrder[:5], []string{ - "access_type", "sip_instance", "audio", "smsip", "icsi_ref", + if !reflect.DeepEqual(vodafoneUK.IMSRegisterTemplate.ContactParamOrder[:6], []string{ + "access_type", "sip_instance", "audio", "smsip", "smsip_msisdn_less", "icsi_ref", }) { t.Fatalf("vodafone uk contact order = %v", vodafoneUK.IMSRegisterTemplate.ContactParamOrder) } @@ -137,8 +141,8 @@ func TestResolveEmbeddedCarrierPresets(t *testing.T) { if !strings.Contains(lebaraUK.IMSRegisterTemplate.ICSIRef, "ims.icsi.sms") { t.Fatalf("lebara uk ICSI missing SMS: %q", lebaraUK.IMSRegisterTemplate.ICSIRef) } - if !reflect.DeepEqual(lebaraUK.IMSRegisterTemplate.ContactParamOrder[:5], []string{ - "access_type", "sip_instance", "audio", "smsip", "icsi_ref", + if !reflect.DeepEqual(lebaraUK.IMSRegisterTemplate.ContactParamOrder[:6], []string{ + "access_type", "sip_instance", "audio", "smsip", "smsip_msisdn_less", "icsi_ref", }) { t.Fatalf("lebara uk contact order = %v", lebaraUK.IMSRegisterTemplate.ContactParamOrder) } @@ -147,6 +151,7 @@ func TestResolveEmbeddedCarrierPresets(t *testing.T) { } att := ResolveEffectiveCarrierConfig("310", "280") if att.PresetID != "att_310280" || att.EPDGAddr != "epdg.epc.att.net" || + att.EmergencyEPDGAddr != DefaultCarrierEmergencyEPDGAddr("310", "280") || att.IMSRegisterTemplate.RegisterPolicy.ID != "att_main" || att.IMSRegisterPolicySource != "preset" { t.Fatalf("AT&T = %+v", att) } diff --git a/third_party/vowifi-go/internal/vowifi/policy/preset_original_test.go b/third_party/vowifi-go/internal/vowifi/policy/preset_original_test.go index e059889e..463ede03 100644 --- a/third_party/vowifi-go/internal/vowifi/policy/preset_original_test.go +++ b/third_party/vowifi-go/internal/vowifi/policy/preset_original_test.go @@ -15,19 +15,19 @@ func TestOriginalCarrierPresetAssetsRemainExact(t *testing.T) { "att_310410.yaml": "06c030e8bd636271f9a23400cd4a622187cb38792fdc01b5422a4d719ff59b95", "csl_454000.yaml": "250f9ec40e6c6a4203a5f29063491317c96276753c42980dd37c491f7d3cfc56", "cteuk_23433.yaml": "52ec96bdca5e6e789862f47d9200eb5de3ddacd103c3374882898c8ec8b74517", - "giffgaff_23410.yaml": "011ead8b3e068fbabf34d05b0a6d11eb7e445ea9ff61f132a7fb0a80b22dd8c5", - "lebara_uk_23487.yaml": "517744d02af103bf396102297003d116998368100826879873bfb7e6456d8c91", + "giffgaff_23410.yaml": "eef48a627da016888187fbe28f59213a22b6f584e9267b9b3236bd7cb6bba531", + "lebara_uk_23487.yaml": "b972d1eb613659a6fbad16791f8b5aca8d2aed6ccab59cea53680eed59aab7bc", "o2_de_26203.yaml": "4772a3f0babe9f5da7cc160315f3344b63e0221b1d94fb8d18ee8739eec0d5a6", "o2_de_26207_alias.yaml": "a9a182ff9bc59e262d0c348dc8a65ff9c86cdd8ded3fe04803f1c1b7ea214cf2", "one_nz_53001.yaml": "3a8bf0b20d12a121d226621472b855166208426bb75ff58b4b9fef67480340f5", "spark_nz_53005.yaml": "6f155b103e975d8355ed1a35ec3b4b4ecf508187fd88cddc281f697fb300a443", "sunrise_22802.yaml": "2160911e6d4fca664fbc9c474eee71a468d282703760f3c87e99df9043872e7b", "three_hk_454003.yaml": "a3a84a436646cddd80df30aa2493f4b4076f08664a478d0b954c4142ef196d61", - "three_uk_234020.yaml": "a1f0ab61edf2ae016675fda613f6b6af45e4f40de035b598c3ec4c35796d527f", + "three_uk_234020.yaml": "49cf6d64d8e180ff475e28718f70f6bdf6da1b388fdd8996cc6921d8e3d6d9c3", "tmobile_310240.yaml": "bed3bfcb871282eab4c446004c1837c39426aa94e1206ab18c41f52aa82c4cb1", "tmobile_310260.yaml": "57619113de3cfbe9ddb4afda13885501415f534f580fc55a8e7f54a15f2b93a6", "vodafone_nl_20404.yaml": "ca847e87abe516603cd92f05ef0a9e5ba8ad0869f7cca3ea2aabe9f49694df8b", - "vodafone_uk_23415.yaml": "63fb1642b77a291de5795827200a1589117fed25fab843748a3bea39dc1d6a62", + "vodafone_uk_23415.yaml": "0bf7ac5040de8847dab0c473e11d1600b791a3b0cb16dfa5afd054b488217d79", } entries, err := carrierPresetFiles.ReadDir("presets") if err != nil { diff --git a/third_party/vowifi-go/internal/vowifi/policy/presets/giffgaff_23410.yaml b/third_party/vowifi-go/internal/vowifi/policy/presets/giffgaff_23410.yaml index 03f0349c..4e0b943c 100644 --- a/third_party/vowifi-go/internal/vowifi/policy/presets/giffgaff_23410.yaml +++ b/third_party/vowifi-go/internal/vowifi/policy/presets/giffgaff_23410.yaml @@ -16,6 +16,7 @@ ims_register_template: - sip_instance - audio - smsip + - smsip_msisdn_less - icsi_ref - mid_call - srvcc_alerting diff --git a/third_party/vowifi-go/internal/vowifi/policy/presets/lebara_uk_23487.yaml b/third_party/vowifi-go/internal/vowifi/policy/presets/lebara_uk_23487.yaml index 750492f1..3eddd8eb 100644 --- a/third_party/vowifi-go/internal/vowifi/policy/presets/lebara_uk_23487.yaml +++ b/third_party/vowifi-go/internal/vowifi/policy/presets/lebara_uk_23487.yaml @@ -28,6 +28,7 @@ ims_register_template: - sip_instance - audio - smsip + - smsip_msisdn_less - icsi_ref - mid_call - srvcc_alerting diff --git a/third_party/vowifi-go/internal/vowifi/policy/presets/three_uk_234020.yaml b/third_party/vowifi-go/internal/vowifi/policy/presets/three_uk_234020.yaml index f13e2c24..0f96ab67 100644 --- a/third_party/vowifi-go/internal/vowifi/policy/presets/three_uk_234020.yaml +++ b/third_party/vowifi-go/internal/vowifi/policy/presets/three_uk_234020.yaml @@ -20,6 +20,7 @@ ims_register_template: - access_type - audio - smsip + - smsip_msisdn_less - icsi_ref - sip_instance include_pani_authenticated: true diff --git a/third_party/vowifi-go/internal/vowifi/policy/presets/vodafone_uk_23415.yaml b/third_party/vowifi-go/internal/vowifi/policy/presets/vodafone_uk_23415.yaml index edda98c9..2f180f3c 100644 --- a/third_party/vowifi-go/internal/vowifi/policy/presets/vodafone_uk_23415.yaml +++ b/third_party/vowifi-go/internal/vowifi/policy/presets/vodafone_uk_23415.yaml @@ -28,6 +28,7 @@ ims_register_template: - sip_instance - audio - smsip + - smsip_msisdn_less - icsi_ref - mid_call - srvcc_alerting diff --git a/third_party/vowifi-go/internal/vowifi/policy/resolve.go b/third_party/vowifi-go/internal/vowifi/policy/resolve.go index 188371f6..826bd638 100644 --- a/third_party/vowifi-go/internal/vowifi/policy/resolve.go +++ b/third_party/vowifi-go/internal/vowifi/policy/resolve.go @@ -43,7 +43,7 @@ func applyBuiltInCarrierExtensions(key string, preset CarrierPreset) CarrierPres } preset.IMSRegisterTemplate.SupportedHeader = "path,sec-agree,outbound" contactOrder := []string{ - "access_type", "sip_instance", "reg_id", "audio", "smsip", "icsi_ref", + "access_type", "sip_instance", "reg_id", "audio", "smsip", "smsip_msisdn_less", "icsi_ref", } preset.IMSRegisterTemplate.ContactParamOrder = cloneStrings(contactOrder) preset.IMSRegisterTemplate.ContactOrder = cloneStrings(contactOrder) diff --git a/third_party/vowifi-go/internal/vowifi/policy/types.go b/third_party/vowifi-go/internal/vowifi/policy/types.go index 32af0862..52c01388 100644 --- a/third_party/vowifi-go/internal/vowifi/policy/types.go +++ b/third_party/vowifi-go/internal/vowifi/policy/types.go @@ -189,6 +189,7 @@ type EffectiveCarrierConfig struct { MCC, MNC, PresetID, MatchedTemplate string E911 E911Policy IPStackType, EPDGAddr, EPDGAddrSource string + EmergencyEPDGAddr string EPDGPort uint16 APN, DNSServer string NATKeepaliveSeconds, DPDIntervalSeconds int @@ -218,9 +219,9 @@ type E911Plan struct { Provider, EntitlementURL, WebsheetHostPolicy string } type EPDGPlan struct { - IPStackType, Addr, AddrSource string - Port uint16 - APN, DNSServer string + IPStackType, Addr, AddrSource, EmergencyAddr string + Port uint16 + APN, DNSServer string } type IKEPlan struct { NATKeepaliveSeconds, DPDIntervalSeconds int diff --git a/third_party/vowifi-go/internal/vowifi/runtimecore/compat.go b/third_party/vowifi-go/internal/vowifi/runtimecore/compat.go index b364263c..9e0b35d5 100644 --- a/third_party/vowifi-go/internal/vowifi/runtimecore/compat.go +++ b/third_party/vowifi-go/internal/vowifi/runtimecore/compat.go @@ -247,7 +247,8 @@ func carrierPlanFromCompatibility(value carrier.EffectiveCarrierConfig) policy.C MCC: value.MCC, MNC: value.MNC, PresetID: value.PresetID, MatchedTemplate: value.MatchedTemplate, IPStackType: value.IPStackType, EPDGAddr: value.EPDGAddr, EPDGAddrSource: value.EPDGAddrSource, - EPDGPort: value.EPDGPort, APN: value.APN, DNSServer: value.DNSServer, + EmergencyEPDGAddr: value.EmergencyEPDGAddr, + EPDGPort: value.EPDGPort, APN: value.APN, DNSServer: value.DNSServer, NATKeepaliveSeconds: value.NATKeepaliveSeconds, DPDIntervalSeconds: value.DPDIntervalSeconds, AKAChallengeMode: value.AKAChallengeMode, IKEIdentityMode: value.IKEIdentityMode, AKAIdentityMode: value.AKAIdentityMode, IKEProposals: append([]string(nil), value.IKEProposals...), diff --git a/third_party/vowifi-go/internal/vowifi/startup/carrier_presets_production_test.go b/third_party/vowifi-go/internal/vowifi/startup/carrier_presets_production_test.go index 67be14a7..99ce3960 100644 --- a/third_party/vowifi-go/internal/vowifi/startup/carrier_presets_production_test.go +++ b/third_party/vowifi-go/internal/vowifi/startup/carrier_presets_production_test.go @@ -3,6 +3,7 @@ package startup import ( "testing" + "github.com/iniwex5/vowifi-go/internal/vowifi/policy" "github.com/iniwex5/vowifi-go/internal/vowifi/profile" ) @@ -67,6 +68,10 @@ func assertOriginalCarrierProjection( if prepared.EPDGAddr != want.epdg || prepared.EPDGSource != want.epdgSource { t.Fatalf("ePDG = %q source %q", prepared.EPDGAddr, prepared.EPDGSource) } + wantEmergency := policy.DefaultCarrierEmergencyEPDGAddr(want.mcc, want.normalizedMNC) + if plan.EPDG.EmergencyAddr != wantEmergency || prepared.EPDGAddr == wantEmergency { + t.Fatalf("emergency ePDG = %q ordinary = %q", plan.EPDG.EmergencyAddr, prepared.EPDGAddr) + } if plan.IKE.DPDIntervalSeconds != want.dpdSeconds || plan.IKE.ReauthIntervalSeconds != want.reauthSeconds || plan.IKE.AKAChallengeMode != want.akaMode || len(plan.IKE.ESPProposals) == 0 || plan.IKE.ESPProposals[0] != want.espFirst { diff --git a/third_party/vowifi-go/internal/vowifi/startup/prepare.go b/third_party/vowifi-go/internal/vowifi/startup/prepare.go index 2e736314..a164e9a9 100644 --- a/third_party/vowifi-go/internal/vowifi/startup/prepare.go +++ b/third_party/vowifi-go/internal/vowifi/startup/prepare.go @@ -176,6 +176,9 @@ func selectEPDG(override string, plan policy.CarrierPlan) (string, string) { if override = strings.TrimSpace(override); override != "" { return override, redirectEPDGSource } + // Ordinary VoWiFi IKE always uses the standard/custom ePDG. The IR.51 + // emergency FQDN stays on the carrier plan for future SIMs and is never + // selected here. return strings.TrimSpace(plan.EPDG.Addr), strings.TrimSpace(plan.EPDG.AddrSource) } diff --git a/third_party/vowifi-go/internal/vowifi/startup/prepare_test.go b/third_party/vowifi-go/internal/vowifi/startup/prepare_test.go index d0e76372..c1249905 100644 --- a/third_party/vowifi-go/internal/vowifi/startup/prepare_test.go +++ b/third_party/vowifi-go/internal/vowifi/startup/prepare_test.go @@ -77,6 +77,9 @@ func TestPrepareStartDerivedIdentityAndRedirect(t *testing.T) { if prepared.EPDGAddr != "redirect.epdg.example" || prepared.EPDGSource != "redirect" { t.Fatalf("ePDG = %q source %q", prepared.EPDGAddr, prepared.EPDGSource) } + if prepared.CarrierPlan.EPDG.EmergencyAddr != "sos.epdg.epc.mnc010.mcc234.pub.3gppnetwork.org" { + t.Fatalf("emergency ePDG = %q", prepared.CarrierPlan.EPDG.EmergencyAddr) + } if HasIMSIdentityResolution(prepared.IMSIdentity) { t.Fatalf("derived identity was applied during startup: %+v", prepared.IMSIdentity) } diff --git a/third_party/vowifi-go/runtimehost/carrier/conversion.go b/third_party/vowifi-go/runtimehost/carrier/conversion.go index fb3bd80c..3c3b6d5e 100644 --- a/third_party/vowifi-go/runtimehost/carrier/conversion.go +++ b/third_party/vowifi-go/runtimehost/carrier/conversion.go @@ -50,8 +50,9 @@ func carrierConfigBaseFromInternal(value policy.EffectiveCarrierConfig) Effectiv EntitlementEndpoint: value.E911.EntitlementEndpoint, }, IPStackType: value.IPStackType, EPDGAddr: value.EPDGAddr, - EPDGAddrSource: value.EPDGAddrSource, EPDGPort: value.EPDGPort, - APN: value.APN, DNSServer: value.DNSServer, + EPDGAddrSource: value.EPDGAddrSource, EmergencyEPDGAddr: value.EmergencyEPDGAddr, + EPDGPort: value.EPDGPort, + APN: value.APN, DNSServer: value.DNSServer, } } diff --git a/third_party/vowifi-go/runtimehost/carrier/types.go b/third_party/vowifi-go/runtimehost/carrier/types.go index 66e29f65..e7cfc18c 100644 --- a/third_party/vowifi-go/runtimehost/carrier/types.go +++ b/third_party/vowifi-go/runtimehost/carrier/types.go @@ -114,6 +114,7 @@ type EffectiveCarrierConfig struct { IPStackType string EPDGAddr string EPDGAddrSource string + EmergencyEPDGAddr string EPDGPort uint16 APN string DNSServer string diff --git a/third_party/vowifi-go/runtimehost/carrier/validation.go b/third_party/vowifi-go/runtimehost/carrier/validation.go index eeb6d86c..760b676f 100644 --- a/third_party/vowifi-go/runtimehost/carrier/validation.go +++ b/third_party/vowifi-go/runtimehost/carrier/validation.go @@ -13,7 +13,7 @@ const maxIMSExpiresSeconds = int64(1<<63-1) / int64(time.Second) var knownContactParameters = map[string]struct{}{ "access_type": {}, "sip_instance": {}, "reg_id": {}, "audio": {}, "smsip": {}, - "icsi_ref": {}, "mid_call": {}, "srvcc_alerting": {}, + "smsip_msisdn_less": {}, "icsi_ref": {}, "mid_call": {}, "srvcc_alerting": {}, "ps2cs_srvcc_orig_pre_alerting": {}, } diff --git a/third_party/vowifi-go/runtimehost/ims_contact_profile_test.go b/third_party/vowifi-go/runtimehost/ims_contact_profile_test.go index d08ab3de..7749dcfb 100644 --- a/third_party/vowifi-go/runtimehost/ims_contact_profile_test.go +++ b/third_party/vowifi-go/runtimehost/ims_contact_profile_test.go @@ -20,7 +20,7 @@ func TestIMSRegisterConfigForGiffgaff(t *testing.T) { t.Fatalf("imsRegisterConfigForPrepared() error = %v", err) } wantOrder := []string{ - "access_type", "sip_instance", "audio", "smsip", "icsi_ref", + "access_type", "sip_instance", "audio", "smsip", "smsip_msisdn_less", "icsi_ref", "mid_call", "srvcc_alerting", "ps2cs_srvcc_orig_pre_alerting", } if !reflect.DeepEqual(template.ContactOrder, wantOrder) || template.AccessType != "wlan1" {