|
@@ -58,15 +58,19 @@ static int mod_init(void);
|
|
|
|
|
|
static int xlog_1(struct sip_msg*, char*, char*);
|
|
static int xlog_1(struct sip_msg*, char*, char*);
|
|
static int xlog_2(struct sip_msg*, char*, char*);
|
|
static int xlog_2(struct sip_msg*, char*, char*);
|
|
|
|
+static int xlog_3(struct sip_msg*, char*, char*, char*);
|
|
static int xdbg(struct sip_msg*, char*, char*);
|
|
static int xdbg(struct sip_msg*, char*, char*);
|
|
|
|
|
|
static int xlogl_1(struct sip_msg*, char*, char*);
|
|
static int xlogl_1(struct sip_msg*, char*, char*);
|
|
static int xlogl_2(struct sip_msg*, char*, char*);
|
|
static int xlogl_2(struct sip_msg*, char*, char*);
|
|
|
|
+static int xlogl_3(struct sip_msg*, char*, char*, char*);
|
|
static int xdbgl(struct sip_msg*, char*, char*);
|
|
static int xdbgl(struct sip_msg*, char*, char*);
|
|
|
|
|
|
static int xlog_fixup(void** param, int param_no);
|
|
static int xlog_fixup(void** param, int param_no);
|
|
|
|
+static int xlog3_fixup(void** param, int param_no);
|
|
static int xdbg_fixup(void** param, int param_no);
|
|
static int xdbg_fixup(void** param, int param_no);
|
|
static int xlogl_fixup(void** param, int param_no);
|
|
static int xlogl_fixup(void** param, int param_no);
|
|
|
|
+static int xlogl3_fixup(void** param, int param_no);
|
|
static int xdbgl_fixup(void** param, int param_no);
|
|
static int xdbgl_fixup(void** param, int param_no);
|
|
|
|
|
|
static void destroy(void);
|
|
static void destroy(void);
|
|
@@ -100,9 +104,11 @@ static pv_export_t mod_items[] = {
|
|
static cmd_export_t cmds[]={
|
|
static cmd_export_t cmds[]={
|
|
{"xlog", (cmd_function)xlog_1, 1, xdbg_fixup, 0, ANY_ROUTE},
|
|
{"xlog", (cmd_function)xlog_1, 1, xdbg_fixup, 0, ANY_ROUTE},
|
|
{"xlog", (cmd_function)xlog_2, 2, xlog_fixup, 0, ANY_ROUTE},
|
|
{"xlog", (cmd_function)xlog_2, 2, xlog_fixup, 0, ANY_ROUTE},
|
|
|
|
+ {"xlog", (cmd_function)xlog_3, 3, xlog3_fixup, 0, ANY_ROUTE},
|
|
{"xdbg", (cmd_function)xdbg, 1, xdbg_fixup, 0, ANY_ROUTE},
|
|
{"xdbg", (cmd_function)xdbg, 1, xdbg_fixup, 0, ANY_ROUTE},
|
|
{"xlogl", (cmd_function)xlogl_1, 1, xdbgl_fixup, 0, ANY_ROUTE},
|
|
{"xlogl", (cmd_function)xlogl_1, 1, xdbgl_fixup, 0, ANY_ROUTE},
|
|
{"xlogl", (cmd_function)xlogl_2, 2, xlogl_fixup, 0, ANY_ROUTE},
|
|
{"xlogl", (cmd_function)xlogl_2, 2, xlogl_fixup, 0, ANY_ROUTE},
|
|
|
|
+ {"xlogl", (cmd_function)xlogl_3, 3, xlogl3_fixup,0, ANY_ROUTE},
|
|
{"xdbgl", (cmd_function)xdbgl, 1, xdbgl_fixup, 0, ANY_ROUTE},
|
|
{"xdbgl", (cmd_function)xdbgl, 1, xdbgl_fixup, 0, ANY_ROUTE},
|
|
{0,0,0,0,0,0}
|
|
{0,0,0,0,0,0}
|
|
};
|
|
};
|
|
@@ -254,6 +260,52 @@ static int xlogl_2(struct sip_msg* msg, char* lev, char* frm)
|
|
return xlog_2_helper(msg, lev, frm, 1, NOFACILITY);
|
|
return xlog_2_helper(msg, lev, frm, 1, NOFACILITY);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int xlog_3_helper(struct sip_msg* msg, char* fac, char* lev, char* frm, int mode)
|
|
|
|
+{
|
|
|
|
+ long level;
|
|
|
|
+ int facility;
|
|
|
|
+ xl_level_p xlp;
|
|
|
|
+ pv_value_t value;
|
|
|
|
+
|
|
|
|
+ xlp = (xl_level_p)lev;
|
|
|
|
+ if(xlp->type==1)
|
|
|
|
+ {
|
|
|
|
+ if(pv_get_spec_value(msg, &xlp->v.sp, &value)!=0
|
|
|
|
+ || value.flags&PV_VAL_NULL || !(value.flags&PV_VAL_INT))
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("invalid log level value [%d]\n", value.flags);
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ level = (long)value.ri;
|
|
|
|
+ } else {
|
|
|
|
+ level = xlp->v.level;
|
|
|
|
+ }
|
|
|
|
+ facility = *(int*)fac;
|
|
|
|
+
|
|
|
|
+ if(!is_printable((int)level))
|
|
|
|
+ return 1;
|
|
|
|
+
|
|
|
|
+ return xlog_helper(msg, (xl_msg_t*)frm, (int)level, mode, facility);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * print log message to level given in parameter
|
|
|
|
+ * add dedicated logfacility
|
|
|
|
+ */
|
|
|
|
+static int xlog_3(struct sip_msg* msg, char* fac, char* lev, char* frm)
|
|
|
|
+{
|
|
|
|
+ return xlog_3_helper(msg, fac, lev, frm, 0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * print log message to level given in parameter along with cfg line
|
|
|
|
+ * add dedicated logfacility
|
|
|
|
+ */
|
|
|
|
+static int xlogl_3(struct sip_msg* msg, char* fac, char* lev, char* frm)
|
|
|
|
+{
|
|
|
|
+ return xlog_3_helper(msg, fac, lev, frm, 1);
|
|
|
|
+}
|
|
|
|
+
|
|
static int xdbg_helper(struct sip_msg* msg, char* frm, char* str2, int mode, int facility)
|
|
static int xdbg_helper(struct sip_msg* msg, char* frm, char* str2, int mode, int facility)
|
|
{
|
|
{
|
|
if(!is_printable(L_DBG))
|
|
if(!is_printable(L_DBG))
|
|
@@ -369,6 +421,37 @@ static int xlog_fixup_helper(void** param, int param_no, int mode)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * fixup log facility
|
|
|
|
+ */
|
|
|
|
+static int xlog3_fixup_helper(void** param, int param_no)
|
|
|
|
+{
|
|
|
|
+ int *facility;
|
|
|
|
+ str s;
|
|
|
|
+
|
|
|
|
+ s.s = (char*)(*param);
|
|
|
|
+ if(s.s==NULL)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("wrong log facility\n");
|
|
|
|
+ return E_UNSPEC;
|
|
|
|
+ }
|
|
|
|
+ facility = (int*)pkg_malloc(sizeof(int));
|
|
|
|
+ if(facility == NULL)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("no more memory\n");
|
|
|
|
+ return E_UNSPEC;
|
|
|
|
+ }
|
|
|
|
+ *facility = str2facility(s.s);
|
|
|
|
+ if (*facility == -1) {
|
|
|
|
+ LM_ERR("invalid syslog facility %s\n", s.s);
|
|
|
|
+ return E_UNSPEC;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ pkg_free(*param);
|
|
|
|
+ *param = (void*)facility;
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
static int xlog_fixup(void** param, int param_no)
|
|
static int xlog_fixup(void** param, int param_no)
|
|
{
|
|
{
|
|
if(param==NULL || *param==NULL)
|
|
if(param==NULL || *param==NULL)
|
|
@@ -379,6 +462,25 @@ static int xlog_fixup(void** param, int param_no)
|
|
return xlog_fixup_helper(param, param_no, 0);
|
|
return xlog_fixup_helper(param, param_no, 0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int xlog3_fixup(void** param, int param_no)
|
|
|
|
+{
|
|
|
|
+ if(param==NULL || *param==NULL)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("invalid parameter number %d\n", param_no);
|
|
|
|
+ return E_UNSPEC;
|
|
|
|
+ }
|
|
|
|
+ /* fixup loglevel */
|
|
|
|
+ if (param_no == 2) {
|
|
|
|
+ return xlog_fixup_helper(param, 1, 0);
|
|
|
|
+ }
|
|
|
|
+ /* fixup log message */
|
|
|
|
+ if (param_no == 3) {
|
|
|
|
+ return xdbg_fixup_helper(param, 3, 0);
|
|
|
|
+ }
|
|
|
|
+ /* fixup facility */
|
|
|
|
+ return xlog3_fixup_helper(param, param_no);
|
|
|
|
+}
|
|
|
|
+
|
|
static int xdbg_fixup(void** param, int param_no)
|
|
static int xdbg_fixup(void** param, int param_no)
|
|
{
|
|
{
|
|
if(param_no!=1 || param==NULL || *param==NULL)
|
|
if(param_no!=1 || param==NULL || *param==NULL)
|
|
@@ -389,6 +491,25 @@ static int xdbg_fixup(void** param, int param_no)
|
|
return xdbg_fixup_helper(param, param_no, 0);
|
|
return xdbg_fixup_helper(param, param_no, 0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int xlogl3_fixup(void** param, int param_no)
|
|
|
|
+{
|
|
|
|
+ if(param==NULL || *param==NULL)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("invalid parameter number %d\n", param_no);
|
|
|
|
+ return E_UNSPEC;
|
|
|
|
+ }
|
|
|
|
+ /* fixup loglevel */
|
|
|
|
+ if (param_no == 2) {
|
|
|
|
+ return xlog_fixup_helper(param, 1, 1);
|
|
|
|
+ }
|
|
|
|
+ /* fixup log message */
|
|
|
|
+ if (param_no == 3) {
|
|
|
|
+ return xdbg_fixup_helper(param, 3, 1);
|
|
|
|
+ }
|
|
|
|
+ /* fixup facility */
|
|
|
|
+ return xlog3_fixup_helper(param, param_no);
|
|
|
|
+}
|
|
|
|
+
|
|
static int xlogl_fixup(void** param, int param_no)
|
|
static int xlogl_fixup(void** param, int param_no)
|
|
{
|
|
{
|
|
if(param==NULL || *param==NULL)
|
|
if(param==NULL || *param==NULL)
|