Skip to content

feat: preload the Service-Route set as Route headers on out-of-dialog requests - #143

Open
rizwan3659 wants to merge 2 commits into
restsend:mainfrom
rizwan3659:feat/rfc3608-preload-route-set
Open

feat: preload the Service-Route set as Route headers on out-of-dialog requests#143
rizwan3659 wants to merge 2 commits into
restsend:mainfrom
rizwan3659:feat/rfc3608-preload-route-set

Conversation

@rizwan3659

Copy link
Copy Markdown

Depends on #142

⚠️ Stacked on #142. This branch contains the #142 commit plus one more. Please review/merge #142 first; GitHub will then collapse this PR to just the second commit. The net-new diff here is 4 files / +128 lines.

What

Consumes the Service-Route set that #142 learns at registration and preloads it as a Route set on outgoing out-of-dialog requests (RFC 3608 §5.2):

  • impl From<ServiceRoute> for Route — carries the name-addr over verbatim (only the field name differs on the wire);
  • Registration::preloaded_route_set() — returns the learned set as Vec<typed::Route>, in registrar order;
  • InviteOption::route_set — a new field whose entries make_invite_request emits as ordered Route headers ahead of caller-supplied headers.

Why

RFC 3608 §5.2: after registering, a UA uses the returned Service-Route as the route set for subsequent out-of-dialog requests. In IMS this is how an INVITE is forced through the S-CSCF (and any P-CSCF) the network assigned at registration. #142 only learned the set; this PR lets a caller actually apply it:

opt.route_set = registration.preloaded_route_set();
let (dialog, resp) = dialog_layer.do_invite(opt, tx).await?;

Compatibility

InviteOption::route_set defaults to empty (the struct derives Default and all call sites use ..Default::default()), so requests that don't set it produce byte-for-byte the same headers as before. Route entries are pushed (not unique_pushed) because a route set legitimately has multiple Route headers.

Tests

  • ServiceRoute -> Route conversion preserves the name-addr;
  • make_invite_request preloads both hops as Route headers in the advertised order;
  • an empty route_set adds no Route header.

cargo build --all-targets, cargo fmt --check and cargo clippy are clean (no new warnings); the full lib suite passes locally apart from the unrelated test_sip_dns_lookup, which needs DNS my sandbox lacks.

Model Service-Route as a typed header alongside Route/Record-Route:
untyped storage, the Header enum wiring and parser dispatch, a typed
`ServiceRoute` (display-name, uri, params) reusing the shared name-addr
parser and list splitter, and `service_route_headers()` /
`typed_service_route_headers()` accessors on HeadersExt.

Registration now records the Service-Route set from a REGISTER 200 OK and
exposes it via `Registration::service_route()`. This is the route set an
IMS S-CSCF advertises for originating requests. Applying it to outgoing
requests (preloading Route headers) is intentionally left to the caller,
so this change adds no behavioural change to existing dialogs.

Adds unit tests for single/multi-value parsing, display round-trip, the
typed<->header conversion, and end-to-end extraction from a 200 OK.
… requests

Builds on the Service-Route parsing added previously. Adds a
`ServiceRoute -> Route` conversion (RFC 3608 §5.2) and
`Registration::preloaded_route_set()`, which turns the learned
Service-Route set into the Route set a UA preloads on later requests.

`InviteOption` gains a `route_set` field; `make_invite_request` emits
those entries as Route headers, in order, ahead of caller-supplied
headers. The field defaults to empty, so requests that do not set it are
unchanged.

Tests cover the conversion, ordered Route preloading in
`make_invite_request`, and the empty-route-set no-op.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant