summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-06-08 12:19:44 +0200
committerAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-06-08 12:19:44 +0200
commitb241a49e977d48a6b8b445447c27da96964f9ce6 (patch)
treeac16836041b317064b7a3deea5d99fa3371f9a4e
parent818a2288f4a523666c2d5fe2c7db98b5adb05cb8 (diff)
ua: handle OPTIONS according to RFC 3261
- the response will contain SDP only if the Accept header is missing or if the Accept header contains application/sdp An Accept header field SHOULD be included to indicate the type of message body the UAC wishes to receive in the response. Typically, this is set to a format that is used to describe the media capabilities of a UA, such as SDP (application/sdp). ref #265
-rw-r--r--src/ua.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/ua.c b/src/ua.c
index 1752061..df60fd5 100644
--- a/src/ua.c
+++ b/src/ua.c
@@ -459,20 +459,33 @@ static void handle_options(struct ua *ua, const struct sip_msg *msg)
struct sip_contact contact;
struct call *call = NULL;
struct mbuf *desc = NULL;
+ const struct sip_hdr *hdr;
+ bool accept_sdp = true;
int err;
debug("ua: incoming OPTIONS message from %r (%J)\n",
&msg->from.auri, &msg->src);
- err = ua_call_alloc(&call, ua, VIDMODE_ON, NULL, NULL, NULL);
- if (err) {
- (void)sip_treply(NULL, uag.sip, msg, 500, "Call Error");
- return;
+ /* application/sdp is the default if the
+ Accept header field is not present */
+ hdr = sip_msg_hdr(msg, SIP_HDR_ACCEPT);
+ if (hdr) {
+ accept_sdp = 0==pl_strcasecmp(&hdr->val, "application/sdp");
}
- err = call_sdp_get(call, &desc, true);
- if (err)
- goto out;
+ if (accept_sdp) {
+
+ err = ua_call_alloc(&call, ua, VIDMODE_ON, NULL, NULL, NULL);
+ if (err) {
+ (void)sip_treply(NULL, uag.sip, msg,
+ 500, "Call Error");
+ return;
+ }
+
+ err = call_sdp_get(call, &desc, true);
+ if (err)
+ goto out;
+ }
sip_contact_set(&contact, ua_cuser(ua), &msg->dst, msg->tp);
@@ -481,16 +494,17 @@ static void handle_options(struct ua *ua, const struct sip_msg *msg)
"Allow: %s\r\n"
"%H"
"%H"
- "Content-Type: application/sdp\r\n"
+ "%s"
"Content-Length: %zu\r\n"
"\r\n"
"%b",
uag_allowed_methods(),
ua_print_supported, ua,
sip_contact_print, &contact,
- mbuf_get_left(desc),
- mbuf_buf(desc),
- mbuf_get_left(desc));
+ desc ? "Content-Type: application/sdp\r\n" : "",
+ desc ? mbuf_get_left(desc) : (size_t)0,
+ desc ? mbuf_buf(desc) : NULL,
+ desc ? mbuf_get_left(desc) : (size_t)0);
if (err) {
warning("ua: options: sip_treplyf: %m\n", err);
}