Module: sip-router
Branch: master
Commit: 61472e04704e99836743c833eb66c33ea0d81724
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=61472e04704e99836743c833eb66c33ea0d81724

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date:   Tue Nov 20 23:10:28 2012 +0100

sdpops: added sdp_content()

- return true of there is a sdp part in the body of sip message

---

 modules/sdpops/README               |   17 +++++++++++++++++
 modules/sdpops/doc/sdpops_admin.xml |   21 +++++++++++++++++++++
 modules/sdpops/sdpops_mod.c         |   13 +++++++++++++
 3 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/modules/sdpops/README b/modules/sdpops/README
index 931f80d..7556c42 100644
--- a/modules/sdpops/README
+++ b/modules/sdpops/README
@@ -37,6 +37,7 @@ Daniel-Constantin Mierla
               4.9. sdp_with_codecs_by_name(list)
               4.10. sdp_print(level)
               4.11. sdp_get(avpvar)
+              4.12. sdp_content()
 
    List of Examples
 
@@ -51,6 +52,7 @@ Daniel-Constantin Mierla
    1.9. sdp_with_codecs_by_name usage
    1.10. sdp_print usage
    1.11. sdp_get usage
+   1.12. sdp_content usage
 
 Chapter 1. Admin Guide
 
@@ -76,6 +78,7 @@ Chapter 1. Admin Guide
         4.9. sdp_with_codecs_by_name(list)
         4.10. sdp_print(level)
         4.11. sdp_get(avpvar)
+        4.12. sdp_content()
 
 1. Overview
 
@@ -120,6 +123,7 @@ Chapter 1. Admin Guide
    4.9. sdp_with_codecs_by_name(list)
    4.10. sdp_print(level)
    4.11. sdp_get(avpvar)
+   4.12. sdp_content()
 
 4.1. sdp_remove_codecs_by_id(list)
 
@@ -301,3 +305,16 @@ sdp_print("1");
 ...
 sdp_get("$avp(sdp)");
 ...
+
+4.12. sdp_content()
+
+   Return true if the SIP message has SDP body or a SDP part in body.
+
+   This function can be used from ANY_ROUTE.
+
+   Example 1.12. sdp_content usage
+...
+if(sdp_content()) {
+    ...
+}
+...
diff --git a/modules/sdpops/doc/sdpops_admin.xml 
b/modules/sdpops/doc/sdpops_admin.xml
index 14525b7..b816c89 100644
--- a/modules/sdpops/doc/sdpops_admin.xml
+++ b/modules/sdpops/doc/sdpops_admin.xml
@@ -344,6 +344,27 @@ sdp_get("$avp(sdp)");
 </programlisting>
            </example>
        </section>
+       <section>
+           <title>
+               <function moreinfo="none">sdp_content()</function>
+           </title>
+           <para>
+               Return true if the SIP message has SDP body or a SDP part in 
body.
+           </para>
+               <para>
+                       This function can be used from ANY_ROUTE.
+           </para>
+               <example>
+               <title><function>sdp_content</function> usage</title>
+               <programlisting format="linespecific">
+...
+if(sdp_content()) {
+    ...
+}
+...
+</programlisting>
+           </example>
+       </section>
        </section>
 </chapter>
 
diff --git a/modules/sdpops/sdpops_mod.c b/modules/sdpops/sdpops_mod.c
index 745ca2b..2d2e668 100644
--- a/modules/sdpops/sdpops_mod.c
+++ b/modules/sdpops/sdpops_mod.c
@@ -51,6 +51,7 @@ static int w_sdp_with_codecs_by_name(sip_msg_t* msg, char* 
codec, char *bar);
 static int w_sdp_remove_media(sip_msg_t* msg, char* media, char *bar);
 static int w_sdp_print(sip_msg_t* msg, char* level, char *bar);
 static int w_sdp_get(sip_msg_t* msg, char *bar);
+static int w_sdp_content(sip_msg_t* msg, char* foo, char *bar);
 
 static int mod_init(void);
 
@@ -81,6 +82,8 @@ static cmd_export_t cmds[] = {
                1, fixup_igp_null,  0, ANY_ROUTE},
        {"sdp_get",                  (cmd_function)w_sdp_get,
                1, 0,  0, ANY_ROUTE},
+       {"sdp_content",                (cmd_function)w_sdp_content,
+               0, 0,  0, ANY_ROUTE},
        {"bind_sdpops",                (cmd_function)bind_sdpops,
                1, 0, 0, 0},
        {0, 0, 0, 0, 0, 0}
@@ -1109,6 +1112,16 @@ static int w_sdp_get(sip_msg_t* msg, char *avp)
 /**
  *
  */
+static int w_sdp_content(sip_msg_t* msg, char* foo, char *bar)
+{
+       if(parse_sdp(msg)==0 && msg->body!=NULL)
+               return 1;
+       return -1;
+}
+
+/**
+ *
+ */
 int bind_sdpops(struct sdpops_binds *sob){
        if (sob == NULL) {
                LM_WARN("bind_sdpops: Cannot load sdpops API into a NULL 
pointer\n");


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to