Module: kamailio
Branch: master
Commit: 9789b423da91ecf0d2fad30c90f6ad717884cde7
URL:
https://github.com/kamailio/kamailio/commit/9789b423da91ecf0d2fad30c90f6ad7…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-06-14T08:08:16+02:00
siputils: added is_http() function
---
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/9789b423da91ecf0d2fad30c90f6ad7…
Patch:
https://github.com/kamailio/kamailio/commit/9789b423da91ecf0d2fad30c90f6ad7…
---
diff --git a/src/modules/siputils/checks.c b/src/modules/siputils/checks.c
index 19250567479..fa4332ec756 100644
--- a/src/modules/siputils/checks.c
+++ b/src/modules/siputils/checks.c
@@ -131,6 +131,36 @@ int ki_is_sip(sip_msg_t *msg)
return -1;
}
+/**
+ * return 1 (true) if it is a HTTP message
+ */
+int w_is_http(sip_msg_t *msg, char *foo, char *bar)
+{
+ if(msg == NULL)
+ return -1;
+
+ if(msg->first_line.flags & FLINE_FLAG_PROTO_HTTP) {
+ return 1;
+ }
+
+ return -1;
+}
+
+/**
+ * return 1 (true) if it is a HTTP message
+ */
+int ki_is_http(sip_msg_t *msg)
+{
+ if(msg == NULL)
+ return -1;
+
+ if(msg->first_line.flags & FLINE_FLAG_PROTO_HTTP) {
+ 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 7ce632b6116..8dd0a22b81d 100644
--- a/src/modules/siputils/checks.h
+++ b/src/modules/siputils/checks.h
@@ -122,6 +122,11 @@ int is_reply(struct sip_msg *msg);
int w_is_sip(struct sip_msg *msg, char *foo, char *bar);
int ki_is_sip(struct sip_msg *msg);
+/*
+ * Return true (1) if it is a HTTP message, otherwise false (-1)
+ */
+int w_is_http(sip_msg_t *msg, char *foo, char *bar);
+int ki_is_http(sip_msg_t *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 f22f0c8f485..372da25b041 100644
--- a/src/modules/siputils/siputils.c
+++ b/src/modules/siputils/siputils.c
@@ -175,6 +175,7 @@ static cmd_export_t cmds[] = {
{"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_http", (cmd_function)w_is_http, 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,
@@ -629,6 +630,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_http"),
+ SR_KEMIP_INT, ki_is_http,
+ { 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,