From 19194c38a837fd423bd82a1306d3b25617d10aaf Mon Sep 17 00:00:00 2001 From: Christian Spielberger Date: Wed, 4 Dec 2024 15:29:09 +0100 Subject: [PATCH 1/2] sipsess: add compare function for sess->msg --- include/re_sipsess.h | 1 + src/sipsess/sess.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/re_sipsess.h b/include/re_sipsess.h index b1f0087e1..5c9db188b 100644 --- a/include/re_sipsess.h +++ b/include/re_sipsess.h @@ -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); diff --git a/src/sipsess/sess.c b/src/sipsess/sess.c index 18123aa91..a14ef8180 100644 --- a/src/sipsess/sess.c +++ b/src/sipsess/sess.c @@ -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) +{ + if (!sess) + return false; + + return sess->msg == msg; +} + /** * Get the SDP negotiation state of a SIP Session * From 4685f8abd9039ac460d9ef025d1a2092b6721e85 Mon Sep 17 00:00:00 2001 From: Christian Spielberger Date: Mon, 9 Dec 2024 08:18:47 +0100 Subject: [PATCH 2/2] sess: replace compare function by getter --- include/re_sipsess.h | 2 +- src/sipsess/sess.c | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/include/re_sipsess.h b/include/re_sipsess.h index 5c9db188b..b228be5f5 100644 --- a/include/re_sipsess.h +++ b/include/re_sipsess.h @@ -83,5 +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); +const struct sip_msg *sipsess_msg(const struct sipsess *sess); enum sdp_neg_state sipsess_sdp_neg_state(const struct sipsess *sess); diff --git a/src/sipsess/sess.c b/src/sipsess/sess.c index a14ef8180..016524182 100644 --- a/src/sipsess/sess.c +++ b/src/sipsess/sess.c @@ -373,18 +373,14 @@ bool sipsess_ack_pending(const struct sipsess *sess) /** - * Compares the sessions SIP message with given SIP message + * Get the SIP message of a SIP Session * * @param sess SIP Session - * @param msg SIP Message - * @return True if msg matches with sess->msg + * @return SIP Message */ -bool sipsess_msg_equal(const struct sipsess *sess, const struct sip_msg *msg) +const struct sip_msg *sipsess_msg(const struct sipsess *sess) { - if (!sess) - return false; - - return sess->msg == msg; + return sess ? sess->msg : NULL; } /**