Skip to content

Commit

Permalink
core: added xflags field to sip_msg_t
Browse files Browse the repository at this point in the history
- holds extended flags - 64 new flags in addition to the old 32 flags
  • Loading branch information
miconda committed Mar 14, 2018
1 parent 021e7e5 commit 0aae638
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/core/flags.c
Expand Up @@ -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
8 changes: 8 additions & 0 deletions src/core/flags.h
Expand Up @@ -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;
Expand All @@ -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.
*/
Expand Down
1 change: 1 addition & 0 deletions src/core/parser/msg_parser.h
Expand Up @@ -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 */
Expand Down

0 comments on commit 0aae638

Please sign in to comment.