Skip to content

res_pjsip_header_funcs.c: Add new PJSIP_HANGUP_HEADER(S) functions#1409

Open
IgorrG wants to merge 1 commit into
asterisk:masterfrom
IgorrG:master-feature-bye-headers
Open

res_pjsip_header_funcs.c: Add new PJSIP_HANGUP_HEADER(S) functions#1409
IgorrG wants to merge 1 commit into
asterisk:masterfrom
IgorrG:master-feature-bye-headers

Conversation

@IgorrG
Copy link
Copy Markdown
Contributor

@IgorrG IgorrG commented Aug 29, 2025

These new functions allow retrieving information from headers in
BYE message of add additional headers in outbound BYE. Implementation
based on existing PJSIP_HEADER and PJSIP_RESPONSE_HEADER
implementation. Functions could be used for better integration with
SIP proxies and sending custom call data to remote party in SIP on
call hangup.

UserNote: Functions PJSIP_HANGUP_HEADERS() and PJSIP_HANGUP_HEADER()
added. To get headers from incoming BYE functions could be called from
the hangup handler. To set headers use add or update options before call
hangup.

@github-actions
Copy link
Copy Markdown

Workflow PRCheck completed successfully

@IgorrG
Copy link
Copy Markdown
Contributor Author

IgorrG commented Aug 29, 2025

This feature 100% based on existing PJSIP_HEADER and PJSIP_RESPONSE_HEADER implementation.

Copy link
Copy Markdown
Member

@gtjoseph gtjoseph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cherry-pick-to lines must be in a comment by themselves and must include the 23 branch.

You should also add a UserNote so the new capability shows up at the top of the ChangeLog.

See:
https://docs.asterisk.org/Development/Policies-and-Procedures/Code-Contribution/
https://docs.asterisk.org/Development/Policies-and-Procedures/Commit-Messages/

@IgorrG
Copy link
Copy Markdown
Contributor Author

IgorrG commented Sep 4, 2025

cherry-pick-to: 20
cherry-pick-to: 22
cherry-pick-to: 23

These new functions allow retrieving information from headers in
BYE message of add additional headers in outbound BYE. Implementation
based on existing PJSIP_HEADER and PJSIP_RESPONSE_HEADER
implementation. Functions could be used for better integration with
SIP proxies and sending custom call data to remote party in SIP on
call hangup.

UserNote: Functions PJSIP_HANGUP_HEADERS() and PJSIP_HANGUP_HEADER()
added. To get headers from incoming BYE functions could be called from
the hangup handler. To set headers use add or update options before call
hangup.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Sep 4, 2025

Workflow PRCheck completed successfully

@gtjoseph
Copy link
Copy Markdown
Member

gtjoseph commented Sep 4, 2025

@IgorrG You need to fix up the PR description to match the commit message. Just copy and paste.

@IgorrG
Copy link
Copy Markdown
Contributor Author

IgorrG commented Sep 4, 2025

@IgorrG You need to fix up the PR description to match the commit message. Just copy and paste.

Thanks. Updated.

@asterisk asterisk deleted a comment from github-actions Bot Sep 4, 2025
@gtjoseph gtjoseph dismissed their stale review September 4, 2025 14:33

Changes made.

@gtjoseph gtjoseph removed the has-pr-checklist A PR Checklist is present on the PR label Sep 4, 2025
@alex2grad
Copy link
Copy Markdown
Contributor

What about the CANCEL method?

CANCEL is used when the caller hangs up before the callee answers.

With the current naming (PJSIP_HANGUP_HEADERS() / PJSIP_HANGUP_HEADER()), it isn’t clear whether these functions cover only BYE or also CANCEL.

To avoid confusion, maybe:
Rename functions to PJSIP_BYE_HEADER(S) if the scope is explicitly BYE only.
Or, if feasible, extend support to CANCEL as well, so the functions really apply to all hangup scenarios.

@IgorrG
Copy link
Copy Markdown
Contributor Author

IgorrG commented Sep 10, 2025

What about the CANCEL method?
CANCEL is used when the caller hangs up before the callee answers.

Yes, we think about this, but decided that 'HANGUP' name fit the case, because often used of already established call being disconnected. Neither PJSIP_HEADER nor PJSIP_RESPONSE_HEADER function use SIP method name in its name also.

@jcolp
Copy link
Copy Markdown
Member

jcolp commented Sep 22, 2025

What about the CANCEL method?
CANCEL is used when the caller hangs up before the callee answers.

Yes, we think about this, but decided that 'HANGUP' name fit the case, because often used of already established call being disconnected. Neither PJSIP_HEADER nor PJSIP_RESPONSE_HEADER function use SIP method name in its name also.

We keep accepting more functions for specific situations. I think we've reached the point where functionality needs to be defined and implemented which allows access to headers for every point of the SIP exchange, and to add headers to them. Perhaps a new dialplan function that supersedes the others (though they won't be removed or deprecated) that allows type (request or response) to be specified, and the SIP method or SIP response code alongside the header name (and value for setting). A count function could also be provided to return how many messages there are matching, and a value for which one to use could be provided to the get function (it could also accept first or last as an argument).

Thoughts?

@IgorrG
Copy link
Copy Markdown
Contributor Author

IgorrG commented Sep 30, 2025

What about the CANCEL method?
CANCEL is used when the caller hangs up before the callee answers.

Yes, we think about this, but decided that 'HANGUP' name fit the case, because often used of already established call being disconnected. Neither PJSIP_HEADER nor PJSIP_RESPONSE_HEADER function use SIP method name in its name also.

We keep accepting more functions for specific situations. I think we've reached the point where functionality needs to be defined and implemented which allows access to headers for every point of the SIP exchange, and to add headers to them. Perhaps a new dialplan function that supersedes the others (though they won't be removed or deprecated) that allows type (request or response) to be specified, and the SIP method or SIP response code alongside the header name (and value for setting). A count function could also be provided to return how many messages there are matching, and a value for which one to use could be provided to the get function (it could also accept first or last as an argument).

Thoughts?

100% agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants