Pārlūkot izejas kodu

kamailio compatibility header files

- mi, pvar & statistics basic include files. For now they contain only
  basic type declarations and defines to allow compilation (so you cannot
   use them, but the code will compile).
- pvar needs more work or replacement
Andrei Pelinescu-Onciul 17 gadi atpakaļ
vecāks
revīzija
3c72005540
3 mainītis faili ar 316 papildinājumiem un 0 dzēšanām
  1. 99 0
      mi/mi.h
  2. 145 0
      pvar.h
  3. 72 0
      statistics.h

+ 99 - 0
mi/mi.h

@@ -0,0 +1,99 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2008 iptelorg GmbH
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+ * mi compatibility wrapper for kamailio
+ * for now it doesn't do anything, it just a compile helper
+ * (obsolete, do not use anymore)
+ *
+ * History:
+ * --------
+ *  2008-11-17  initial version compatible with kamailio mi/mi.h (andrei)
+ */
+
+#ifndef _mi_h_
+#define _mi_h_
+
+#include "../str.h"
+
+#define MI_DUP_NAME   (1<<0)
+#define MI_DUP_VALUE  (1<<1)
+
+#define MI_OK_S              "OK"
+#define MI_OK_LEN            (sizeof(MI_OK_S)-1)
+#define MI_INTERNAL_ERR_S    "Server Internal Error"
+#define MI_INTERNAL_ERR_LEN  (sizeof(MI_INTERNAL_ERR_S)-1)
+#define MI_MISSING_PARM_S    "Too few or too many arguments"
+#define MI_MISSING_PARM_LEN  (sizeof(MI_MISSING_PARM_S)-1)
+#define MI_BAD_PARM_S        "Bad parameter"
+#define MI_BAD_PARM_LEN      (sizeof(MI_BAD_PARM_S)-1)
+
+#define MI_SSTR(_s)           _s,(sizeof(_s)-1)
+#define MI_OK                 MI_OK_S
+#define MI_INTERNAL_ERR       MI_INTERNAL_ERR_S
+#define MI_MISSING_PARM       MI_MISSING_PARM_S
+#define MI_BAD_PARM           MI_BAD_PARM_S
+
+
+
+struct mi_attr{
+	str name;
+	str value;
+	struct mi_attr *next;
+};
+
+
+struct mi_node {
+	str value;
+	str name;
+	struct mi_node *kids;
+	struct mi_node *next;
+	struct mi_node *last;
+	struct mi_attr *attributes;
+};
+
+
+struct mi_root {
+	unsigned int       code;
+	str                reason;
+	struct mi_handler  *async_hdl;
+	struct mi_node     node;
+};
+
+typedef struct mi_root* (mi_cmd_f)(struct mi_root*, void *param);
+typedef int (mi_child_init_f)(void);
+
+
+typedef struct mi_export_ {
+	char *name;
+	mi_cmd_f *cmd;
+	unsigned int flags;
+	void *param;
+	mi_child_init_f *init_f;
+}mi_export_t;
+
+
+#define init_mi_tree(code, reason, reason_len) 0
+#define free_mi_tree(parent)
+#define add_mi_node_sibling(node, flags, name, name_len, val, val_len) 0
+#define add_mi_node_child(node, flags, name, name_len, val, val_len) 0
+#define addf_mi_node_child(node, flags, name, name_len, fmt, ...) 0
+
+
+#endif /* _mi_h_ */
+
+

+ 145 - 0
pvar.h

@@ -0,0 +1,145 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2008 
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+ * pvar compatibility wrapper for kamailio
+ * for now it doesn't do anything (feel free to rm & replace the file)
+ *
+ * History:
+ * --------
+ *  2008-11-17  initial version compatible with kamailio pvar.h (andrei)
+ */
+
+#ifndef _pvar_h_
+#define _pvar_h_
+
+#include "str.h"
+#include "usr_avp.h"
+#include "parser/msg_parser.h"
+
+
+
+
+enum _pv_type { 
+	PVT_NONE=0,           PVT_EMPTY,             PVT_NULL, 
+	PVT_MARKER,           PVT_AVP,               PVT_HDR,
+	PVT_PID,              PVT_RETURN_CODE,       PVT_TIMES,
+	PVT_TIMEF,            PVT_MSGID,             PVT_METHOD,
+	PVT_STATUS,           PVT_REASON,            PVT_RURI,
+	PVT_RURI_USERNAME,    PVT_RURI_DOMAIN,       PVT_RURI_PORT,
+	PVT_FROM,             PVT_FROM_USERNAME,     PVT_FROM_DOMAIN,
+	PVT_FROM_TAG,         PVT_TO,                PVT_TO_USERNAME,
+	PVT_TO_DOMAIN,        PVT_TO_TAG,            PVT_CSEQ,
+	PVT_CONTACT,          PVT_CALLID,            PVT_USERAGENT,
+	PVT_MSG_BUF,          PVT_MSG_LEN,           PVT_FLAGS,
+	PVT_HEXFLAGS,         PVT_SRCIP,             PVT_SRCPORT,
+	PVT_RCVIP,            PVT_RCVPORT,           PVT_REFER_TO,
+	PVT_DSET,             PVT_DSTURI,            PVT_COLOR,
+	PVT_BRANCH,           PVT_BRANCHES,          PVT_CONTENT_TYPE,
+	PVT_CONTENT_LENGTH,   PVT_MSG_BODY,          PVT_AUTH_USERNAME,
+	PVT_AUTH_REALM,       PVT_RURI_PROTOCOL,     PVT_DSTURI_DOMAIN,
+	PVT_DSTURI_PORT,      PVT_DSTURI_PROTOCOL,   PVT_FROM_DISPLAYNAME,
+	PVT_TO_DISPLAYNAME,   PVT_OURI,              PVT_OURI_USERNAME,
+	PVT_OURI_DOMAIN,      PVT_OURI_PORT,         PVT_OURI_PROTOCOL,
+	PVT_FORCE_SOCK,       PVT_RPID_URI,          PVT_DIVERSION_URI,
+	PVT_ACC_USERNAME,     PVT_PPI,               PVT_PPI_DISPLAYNAME,
+	PVT_PPI_DOMAIN,       PVT_PPI_USERNAME,      PVT_PAI_URI,
+	PVT_BFLAGS,           PVT_HEXBFLAGS,         PVT_SFLAGS,
+	PVT_HEXSFLAGS,        PVT_ERR_CLASS,         PVT_ERR_LEVEL,
+	PVT_ERR_INFO,         PVT_ERR_RCODE,         PVT_ERR_RREASON,
+	PVT_SCRIPTVAR,        PVT_PROTO,             PVT_AUTH_USERNAME_WHOLE,
+	PVT_AUTH_DURI,        PVT_DIV_REASON,        PVT_DIV_PRIVACY,
+	PVT_AUTH_DOMAIN,      PVT_EXTRA /* keep it last */
+};
+
+typedef enum _pv_type pv_type_t;
+typedef int pv_flags_t;
+
+typedef struct _pv_value
+{
+	str rs;    /*!< string value */
+	int ri;    /*!< integer value */
+	int flags; /*!< flags about the type of value */
+} pv_value_t, *pv_value_p;
+
+typedef struct _pv_name
+{
+	int type;             /*!< type of name */
+	union {
+		struct {
+			int type;     /*!< type of int_str name - compatibility with AVPs */
+			int_str name; /*!< the value of the name */
+		} isname;
+		void *dname;      /*!< PV value - dynamic name */
+	} u;
+} pv_name_t, *pv_name_p;
+
+typedef struct _pv_index
+{
+	int type; /*!< type of PV index */
+	union {
+		int ival;   /*!< integer value */
+		void *dval; /*!< PV value - dynamic index */
+	} u;
+} pv_index_t, *pv_index_p;
+
+typedef struct _pv_param
+{
+	pv_name_t    pvn; /*!< PV name */
+	pv_index_t   pvi; /*!< PV index */
+} pv_param_t, *pv_param_p;
+
+typedef int (*pv_getf_t) (struct sip_msg*,  pv_param_t*, pv_value_t*);
+typedef int (*pv_setf_t) (struct sip_msg*,  pv_param_t*, int, pv_value_t*);
+
+typedef struct _pv_spec {
+	pv_type_t    type;   /*!< type of PV */
+	pv_getf_t    getf;   /*!< get PV value function */
+	pv_setf_t    setf;   /*!< set PV value function */
+	pv_param_t   pvp;    /*!< parameter to be given to get/set functions */
+	void         *trans; /*!< transformations */
+} pv_spec_t, *pv_spec_p;
+
+
+
+typedef int (*pv_parse_name_f)(pv_spec_p sp, str *in);
+typedef int (*pv_parse_index_f)(pv_spec_p sp, str *in);
+typedef int (*pv_init_param_f)(pv_spec_p sp, int param);
+
+/*! \brief
+ * PV spec format:
+ * - $class_name
+ * - $class_name(inner_name)
+ * - $(class_name[index])
+ * - $(class_name(inner_name)[index])
+ * - $(class_name{transformation})
+ * - $(class_name(inner_name){transformation})
+ * - $(class_name[index]{transformation})
+ * - $(class_name(inner_name)[index]{transformation})
+ */
+typedef struct _pv_export {
+	str name;                      /*!< class name of PV */
+	pv_type_t type;                /*!< type of PV */
+	pv_getf_t  getf;               /*!< function to get the value */
+	pv_setf_t  setf;               /*!< function to set the value */
+	pv_parse_name_f parse_name;    /*!< function to parse the inner name */
+	pv_parse_index_f parse_index;  /*!< function to parse the index of PV */
+	pv_init_param_f init_param;    /*!< function to init the PV spec */
+	int iparam;                    /*!< parameter for the init function */
+} pv_export_t;
+
+#endif /* _pvar_h_ */

+ 72 - 0
statistics.h

@@ -0,0 +1,72 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2008 iptelorg GmbH
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+ * statistics compatibility wrapper for kamailio
+ * for now it doesn't do anything
+ * (obsolete, do not use anymore)
+ *
+ * History:
+ * --------
+ *  2008-11-17  initial version compatible with kamailio statistics.h (andrei)
+ */
+
+#ifndef _STATISTICS_H_
+#define _STATISTICS_H_
+
+#include "str.h"
+
+#define STAT_NO_RESET  1
+#define STAT_NO_SYNC   2
+#define STAT_SHM_NAME  4
+#define STAT_IS_FUNC   8
+
+
+
+typedef unsigned int stat_val;
+typedef unsigned long (*stat_function)(void);
+
+typedef struct stat_var_{
+	unsigned int mod_idx;
+	str name;
+	int flags;
+	union{
+		stat_val *val;
+		stat_function f;
+	}u;
+	struct stat_var_ *hnext;
+	struct stat_var_ *lnext;
+} stat_var;
+
+
+typedef struct stat_export_ {
+	char* name;                /* null terminated statistic name */
+	int flags;                 /* flags */
+	stat_var** stat_pointer;   /* pointer to the variable's shm mem location */
+} stat_export_t;
+
+#define get_stat(name)  0
+#define get_stat_val(v) 0
+#define update_stat(v, n)
+#define reset_stat(v)
+#define if_update_stat (cond, v, n)
+
+#ifdef STATISTICS
+#warning "sorry sip-router does not support STATISTICS"
+#endif
+
+#endif /* _STATISTICS_H_ */