Module: kamailio
Branch: master
Commit: d2ff3dd39766e4ee859c115f1fc5bf93d72abed9
URL:
https://github.com/kamailio/kamailio/commit/d2ff3dd39766e4ee859c115f1fc5bf9…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-06-05T20:25:20+02:00
siputils: added function is_sip()
- return true if it is a SIP message
---
Modified: src/modules/siputils/checks.c
Modified: src/modules/siputils/checks.h
Modified: src/modules/siputils/siputils.c
---
Diff:
https://github.com/kamailio/kamailio/commit/d2ff3dd39766e4ee859c115f1fc5bf9…
Patch:
https://github.com/kamailio/kamailio/commit/d2ff3dd39766e4ee859c115f1fc5bf9…
---
diff --git a/src/modules/siputils/checks.c b/src/modules/siputils/checks.c
index 2822e24b7c8..7caeb809b2f 100644
--- a/src/modules/siputils/checks.c
+++ b/src/modules/siputils/checks.c
@@ -101,6 +101,36 @@ int is_reply(struct sip_msg *msg)
}
+/**
+ * return 1 (true) if it is a SIP message
+ */
+int w_is_sip(sip_msg_t *msg, char *foo, char *bar)
+{
+ if(msg == NULL)
+ return -1;
+
+ if(msg->first_line.flags & FLINE_FLAG_PROTO_SIP) {
+ return 1;
+ }
+
+ return -1;
+}
+
+/**
+ * return 1 (true) if it is a SIP message
+ */
+int is_sip(sip_msg_t *msg)
+{
+ if(msg == NULL)
+ return -1;
+
+ if(msg->first_line.flags & FLINE_FLAG_PROTO_SIP) {
+ return 1;
+ }
+
+ return -1;
+}
+
/*
* Checks if From includes a To-tag -- good to identify
* if a request creates a new dialog
diff --git a/src/modules/siputils/checks.h b/src/modules/siputils/checks.h
index 5aa67295ba5..fa914ecc0da 100644
--- a/src/modules/siputils/checks.h
+++ b/src/modules/siputils/checks.h
@@ -116,6 +116,13 @@ int is_request(struct sip_msg *msg);
int w_is_reply(struct sip_msg *msg, char *foo, char *bar);
int is_reply(struct sip_msg *msg);
+/*
+ * Return true (1) if it is a SIP message, otherwise false (-1)
+ */
+int w_is_sip(struct sip_msg *msg, char *foo, char *bar);
+int is_sip(struct sip_msg *msg);
+
+
/*
* Find if Request URI has a given parameter with matching value
*/
diff --git a/src/modules/siputils/siputils.c b/src/modules/siputils/siputils.c
index d31671db79f..0912c6b132b 100644
--- a/src/modules/siputils/siputils.c
+++ b/src/modules/siputils/siputils.c
@@ -174,6 +174,7 @@ static cmd_export_t cmds[] = {
fixup_free_set_uri, ANY_ROUTE},
{"is_request", (cmd_function)w_is_request, 0, 0, 0, ANY_ROUTE},
{"is_reply", (cmd_function)w_is_reply, 0, 0, 0, ANY_ROUTE},
+ {"is_sip", (cmd_function)w_is_sip, 0, 0, 0, ANY_ROUTE},
{"is_gruu", (cmd_function)w_is_gruu, 0, 0, 0, ANY_ROUTE},
{"is_gruu", (cmd_function)w_is_gruu, 1, fixup_spve_null, 0, ANY_ROUTE},
{"is_supported", (cmd_function)w_is_supported, 1, fixup_option, 0,
@@ -623,6 +624,11 @@ static sr_kemi_t sr_kemi_siputils_exports[] = {
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("siputils"), str_init("is_sip"),
+ SR_KEMIP_INT, is_sip,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ str_init("siputils"), str_init("is_first_hop"),
SR_KEMIP_INT, is_first_hop,
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,