Module: kamailio
Branch: master
Commit: d2047859ad4b64ac9c62242df0088cf94d755e69
URL:
https://github.com/kamailio/kamailio/commit/d2047859ad4b64ac9c62242df0088cf…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-05-14T09:10:28+02:00
sdpops: exported sdp_content() to kemi framework
---
Modified: src/modules/sdpops/sdpops_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/d2047859ad4b64ac9c62242df0088cf…
Patch:
https://github.com/kamailio/kamailio/commit/d2047859ad4b64ac9c62242df0088cf…
---
diff --git a/src/modules/sdpops/sdpops_mod.c b/src/modules/sdpops/sdpops_mod.c
index d06affc..6cc511d 100644
--- a/src/modules/sdpops/sdpops_mod.c
+++ b/src/modules/sdpops/sdpops_mod.c
@@ -1637,41 +1637,69 @@ static int w_sdp_content(sip_msg_t* msg, char* foo, char *bar)
/**
*
*/
-static int w_sdp_content_sloppy(sip_msg_t* msg, char* foo, char *bar)
+static int ki_sdp_content(sip_msg_t* msg)
+{
+ if(parse_sdp(msg)==0 && msg->body!=NULL)
+ return 1;
+ return -1;
+}
+
+/**
+ *
+ */
+static int ki_sdp_content_flags(sip_msg_t *msg, int flags)
{
str body;
int mime;
+ if(flags==0) {
+ return ki_sdp_content(msg);
+ }
+
body.s = get_body(msg);
- if (body.s == NULL) return -1;
+ if(body.s == NULL)
+ return -1;
body.len = msg->len - (int)(body.s - msg->buf);
- if (body.len == 0) return -1;
+ if(body.len == 0)
+ return -1;
mime = parse_content_type_hdr(msg);
- if (mime < 0) return -1; /* error */
- if (mime == 0) return 1; /* default is application/sdp */
-
- switch (((unsigned int)mime) >> 16) {
- case TYPE_APPLICATION:
- if ((mime & 0x00ff) == SUBTYPE_SDP) return 1; else return -1;
- case TYPE_MULTIPART:
- if ((mime & 0x00ff) == SUBTYPE_MIXED) {
- if (_strnistr(body.s, "application/sdp", body.len) == NULL) {
+ if(mime < 0)
+ return -1; /* error */
+ if(mime == 0)
+ return 1; /* default is application/sdp */
+
+ switch(((unsigned int)mime) >> 16) {
+ case TYPE_APPLICATION:
+ if((mime & 0x00ff) == SUBTYPE_SDP)
+ return 1;
+ else
return -1;
+ case TYPE_MULTIPART:
+ if((mime & 0x00ff) == SUBTYPE_MIXED) {
+ if(_strnistr(body.s, "application/sdp", body.len) == NULL) {
+ return -1;
+ } else {
+ return 1;
+ }
} else {
- return 1;
+ return -1;
}
- } else {
+ default:
return -1;
- }
- default:
- return -1;
}
}
/**
*
*/
+static int w_sdp_content_sloppy(sip_msg_t *msg, char *foo, char *bar)
+{
+ return ki_sdp_content_flags(msg, 1);
+}
+/**
+ *
+ */
int sdp_with_ice(sip_msg_t* msg)
{
str ice, body;
@@ -1937,6 +1965,16 @@ static sr_kemi_t sr_kemi_sdpops_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("sdpops"), str_init("sdp_content"),
+ SR_KEMIP_INT, ki_sdp_content,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("sdpops"), str_init("sdp_content_flags"),
+ SR_KEMIP_INT, ki_sdp_content_flags,
+ { SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
};