summaryrefslogtreecommitdiff
path: root/src/call.c
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2014-04-21 14:27:37 +0200
committerAlfred E. Heggestad <aeh@db.org>2014-04-21 14:27:37 +0200
commit309ba2242ce410c72ef7b9e22e33c8cf8aaab6c3 (patch)
treea20defd05514dc1f5716ada68d9584ba8fd112b7 /src/call.c
parent397f660e1461168f2edaa9bd519bf9c794a4c18f (diff)
call: check common audio codecs for incoming call
for incoming calls, check that we have at least 1 common audio codec. if there are no common audio codecs, reject the call with 488 status code. Suggested and Tested by Juha Heinanen -- thanks!
Diffstat (limited to 'src/call.c')
-rw-r--r--src/call.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/call.c b/src/call.c
index a947c25..0cf4358 100644
--- a/src/call.c
+++ b/src/call.c
@@ -1171,6 +1171,21 @@ static void sipsess_close_handler(int err, const struct sip_msg *msg,
}
+static bool have_common_audio_codecs(const struct call *call)
+{
+ const struct sdp_format *sc;
+ struct aucodec *ac;
+
+ sc = sdp_media_rformat(stream_sdpmedia(audio_strm(call->audio)), NULL);
+ if (!sc)
+ return false;
+
+ ac = sc->data;
+
+ return ac != NULL;
+}
+
+
int call_accept(struct call *call, struct sipsess_sock *sess_sock,
const struct sip_msg *msg)
{
@@ -1199,6 +1214,21 @@ int call_accept(struct call *call, struct sipsess_sock *sess_sock,
return err;
call->got_offer = true;
+
+ /* Check if we have any common audio codecs, after
+ * the SDP offer has been parsed
+ */
+ if (!have_common_audio_codecs(call)) {
+ info("call: no common audio codecs - rejected\n");
+
+ sip_treply(NULL, uag_sip(), msg,
+ 488, "Not Acceptable Here");
+
+ call_event_handler(call, CALL_EVENT_CLOSED,
+ "No audio codecs");
+
+ return 0;
+ }
}
err = sipsess_accept(&call->sess, sess_sock, msg, 180, "Ringing",