res_pjsip_geolocation: Add support for Geolocation loc-src parameter

This adds support for the Geolocation 'loc-src' parameter to res_pjsip_geolocation.
The already existing config option 'location_source` in res_geolocation is documented to add a 'loc-src' parameter containing a user-defined FQDN to the 'Geolocation:' header,
but that option had no effect as it was not implemented by res_pjsip_geolocation.

If the `location_source` configuration option is not set or invalid, that parameter will not be added (this is already checked by res_geolocation).

This commits adds already documented functionality.
This commit is contained in:
Max Grobecker
2025-09-21 15:34:56 +02:00
parent b1e410c4b5
commit 6dca261bdd

View File

@@ -602,10 +602,13 @@ static void handle_outgoing_request(struct ast_sip_session *session, struct pjsi
uri = ast_strdupa(ast_str_buffer(buf)); uri = ast_strdupa(ast_str_buffer(buf));
ast_str_reset(buf); ast_str_reset(buf);
ast_str_set(&buf, 0, "<%s>", uri); ast_str_set(&buf, 0, "<%s>", uri);
if (!ast_strlen_zero(final_eprofile->location_source)) {
ast_str_append(&buf, 0, ";loc-src=%s", final_eprofile->location_source);
}
uri = ast_strdupa(ast_str_buffer(buf)); uri = ast_strdupa(ast_str_buffer(buf));
ast_trace(4, "%s: Using URI '%s'\n", session_name, uri); ast_trace(4, "%s: Using URI '%s'\n", session_name, uri);
/* It's almost impossible for add header to fail but you never know */ /* It's almost impossible for add header to fail but you never know */
geoloc_hdr = ast_sip_add_header2(tdata, "Geolocation", uri); geoloc_hdr = ast_sip_add_header2(tdata, "Geolocation", uri);
if (geoloc_hdr == NULL) { if (geoloc_hdr == NULL) {