Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sipsess: add sipsess_msg getter function #1225

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/re_sipsess.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,5 @@ void sipsess_close_all(struct sipsess_sock *sock);
struct sip_dialog *sipsess_dialog(const struct sipsess *sess);
void sipsess_abort(struct sipsess *sess);
bool sipsess_ack_pending(const struct sipsess *sess);
bool sipsess_msg_equal(const struct sipsess *sess, const struct sip_msg *msg);
enum sdp_neg_state sipsess_sdp_neg_state(const struct sipsess *sess);
15 changes: 15 additions & 0 deletions src/sipsess/sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,21 @@ bool sipsess_ack_pending(const struct sipsess *sess)
}


/**
* Compares the sessions SIP message with given SIP message
*
* @param sess SIP Session
* @param msg SIP Message
* @return True if msg matches with sess->msg
*/
bool sipsess_msg_equal(const struct sipsess *sess, const struct sip_msg *msg)
cspiel1 marked this conversation as resolved.
Show resolved Hide resolved
{
if (!sess)
return false;

return sess->msg == msg;
Copy link
Contributor

Choose a reason for hiding this comment

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

is it more robust to compare the Call-ID instead of a raw pointer ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe yes. I have to check how the re-send mechanism is handled in re/baresip and how the postponed call to ua_accept() may influence this.

Copy link
Collaborator Author

@cspiel1 cspiel1 Dec 6, 2024

Choose a reason for hiding this comment

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

The sip->ht_strans hash table is used to avoid that two SIP messages with equal via.branch are processed twice. This avoids also that two SIP message (with different pointers) with equal call-id are processed twice. This is handled all by re.

So I think that comparing the pointers are perfect in order to avoid that multiple call objects are allocated for one SIP INVITE.

edit: Comparing call-id would also work. Does it have any benefit?

Copy link
Member

Choose a reason for hiding this comment

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

edit: Comparing call-id would also work. Does it have any benefit?

Let's say you duplicate the sip_msg for some reason (multi threading...):

struct sip_msg msg = *msg_orig;
sipsess_msg_equal(csess, &msg);

This would fail.

}

/**
* Get the SDP negotiation state of a SIP Session
*
Expand Down
Loading