Module: kamailio
Branch: master
Commit: 0aae63818588952280e901ea2c529cb936ce5cf6
URL: 
https://github.com/kamailio/kamailio/commit/0aae63818588952280e901ea2c529cb936ce5cf6

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2018-03-14T13:00:23+01:00

core: added xflags field to sip_msg_t

- holds extended flags - 64 new flags in addition to the old 32 flags

---

Modified: src/core/flags.c
Modified: src/core/flags.h
Modified: src/core/parser/msg_parser.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/0aae63818588952280e901ea2c529cb936ce5cf6.diff
Patch: 
https://github.com/kamailio/kamailio/commit/0aae63818588952280e901ea2c529cb936ce5cf6.patch

---

diff --git a/src/core/flags.c b/src/core/flags.c
index 5dbdd4ffbc..043824895f 100644
--- a/src/core/flags.c
+++ b/src/core/flags.c
@@ -317,5 +317,42 @@ static int fixup_t_flag(void** param, int param_no)
        return E_CFG;
 }
 
+/**
+ *
+ */
+int setxflag(struct sip_msg* msg, flag_t flag)
+{
+       uint32_t fi;
+       uint32_t fb;
+       fi = flag / (sizeof(flag_t)*CHAR_BIT);
+       fb = flag % (sizeof(flag_t)*CHAR_BIT);
+       msg->xflags[fi] |= 1 << fb;
+       return 1;
+}
+
+/**
+ *
+ */
+int resetxflag(struct sip_msg* msg, flag_t flag)
+{
+       uint32_t fi;
+       uint32_t fb;
+       fi = flag / (sizeof(flag_t)*CHAR_BIT);
+       fb = flag % (sizeof(flag_t)*CHAR_BIT);
+       msg->xflags[fi] &= ~ (1 << fb);
+       return 1;
+}
+
+/**
+ *
+ */
+int isxflagset(struct sip_msg* msg, flag_t flag)
+{
+       uint32_t fi;
+       uint32_t fb;
+       fi = flag / (sizeof(flag_t)*CHAR_BIT);
+       fb = flag % (sizeof(flag_t)*CHAR_BIT);
+       return (msg->xflags[fi] & (1<<fb)) ? 1 : -1;
+}
 
 #endif
diff --git a/src/core/flags.h b/src/core/flags.h
index 3876082472..e1186dbf79 100644
--- a/src/core/flags.h
+++ b/src/core/flags.h
@@ -34,6 +34,10 @@ enum { FL_WHITE=1, FL_YELLOW, FL_GREEN, FL_RED, FL_BLUE, 
FL_MAGENTA,
 
 typedef unsigned int flag_t;
 
+#define KSR_XFLAGS_SIZE 2
+#define KSR_MAX_XFLAG \
+       ((unsigned int)(KSR_XFLAGS_SIZE * sizeof(flag_t) * CHAR_BIT - 1 ))
+
 #define MAX_FLAG  ((unsigned int)( sizeof(flag_t) * CHAR_BIT - 1 ))
 
 struct sip_msg;
@@ -43,6 +47,10 @@ int resetflag( struct sip_msg* msg, flag_t flag );
 int isflagset( struct sip_msg* msg, flag_t flag );
 
 
+int setxflag(struct sip_msg* msg, flag_t flag);
+int resetxflag(struct sip_msg* msg, flag_t flag);
+int isxflagset(struct sip_msg* msg, flag_t flag);
+
 /* Script flag functions. Script flags are global flags that keep their
  * value regardless of the SIP message being processed.
  */
diff --git a/src/core/parser/msg_parser.h b/src/core/parser/msg_parser.h
index 41e6deeb33..9270e0bba9 100644
--- a/src/core/parser/msg_parser.h
+++ b/src/core/parser/msg_parser.h
@@ -359,6 +359,7 @@ typedef struct sip_msg {
                                                                to avoid 
unnecessary calculations */
        unsigned int msg_flags; /*!< internal flags used by core */
        flag_t flags; /*!< config flags */
+       flag_t xflags[KSR_XFLAGS_SIZE]; /*!< config extended flags */
        str set_global_address;
        str set_global_port;
        struct socket_info* force_send_socket; /*!< force sending on this 
socket */


_______________________________________________
Kamailio (SER) - Development Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to