Browse code

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 authored on 17/11/2008 23:21:51
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,99 @@
0
+/*
1
+ * $Id$
2
+ *
3
+ * Copyright (C) 2008 iptelorg GmbH
4
+ *
5
+ * Permission to use, copy, modify, and distribute this software for any
6
+ * purpose with or without fee is hereby granted, provided that the above
7
+ * copyright notice and this permission notice appear in all copies.
8
+ *
9
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+ */
17
+/*
18
+ * mi compatibility wrapper for kamailio
19
+ * for now it doesn't do anything, it just a compile helper
20
+ * (obsolete, do not use anymore)
21
+ *
22
+ * History:
23
+ * --------
24
+ *  2008-11-17  initial version compatible with kamailio mi/mi.h (andrei)
25
+ */
26
+
27
+#ifndef _mi_h_
28
+#define _mi_h_
29
+
30
+#include "../str.h"
31
+
32
+#define MI_DUP_NAME   (1<<0)
33
+#define MI_DUP_VALUE  (1<<1)
34
+
35
+#define MI_OK_S              "OK"
36
+#define MI_OK_LEN            (sizeof(MI_OK_S)-1)
37
+#define MI_INTERNAL_ERR_S    "Server Internal Error"
38
+#define MI_INTERNAL_ERR_LEN  (sizeof(MI_INTERNAL_ERR_S)-1)
39
+#define MI_MISSING_PARM_S    "Too few or too many arguments"
40
+#define MI_MISSING_PARM_LEN  (sizeof(MI_MISSING_PARM_S)-1)
41
+#define MI_BAD_PARM_S        "Bad parameter"
42
+#define MI_BAD_PARM_LEN      (sizeof(MI_BAD_PARM_S)-1)
43
+
44
+#define MI_SSTR(_s)           _s,(sizeof(_s)-1)
45
+#define MI_OK                 MI_OK_S
46
+#define MI_INTERNAL_ERR       MI_INTERNAL_ERR_S
47
+#define MI_MISSING_PARM       MI_MISSING_PARM_S
48
+#define MI_BAD_PARM           MI_BAD_PARM_S
49
+
50
+
51
+
52
+struct mi_attr{
53
+	str name;
54
+	str value;
55
+	struct mi_attr *next;
56
+};
57
+
58
+
59
+struct mi_node {
60
+	str value;
61
+	str name;
62
+	struct mi_node *kids;
63
+	struct mi_node *next;
64
+	struct mi_node *last;
65
+	struct mi_attr *attributes;
66
+};
67
+
68
+
69
+struct mi_root {
70
+	unsigned int       code;
71
+	str                reason;
72
+	struct mi_handler  *async_hdl;
73
+	struct mi_node     node;
74
+};
75
+
76
+typedef struct mi_root* (mi_cmd_f)(struct mi_root*, void *param);
77
+typedef int (mi_child_init_f)(void);
78
+
79
+
80
+typedef struct mi_export_ {
81
+	char *name;
82
+	mi_cmd_f *cmd;
83
+	unsigned int flags;
84
+	void *param;
85
+	mi_child_init_f *init_f;
86
+}mi_export_t;
87
+
88
+
89
+#define init_mi_tree(code, reason, reason_len) 0
90
+#define free_mi_tree(parent)
91
+#define add_mi_node_sibling(node, flags, name, name_len, val, val_len) 0
92
+#define add_mi_node_child(node, flags, name, name_len, val, val_len) 0
93
+#define addf_mi_node_child(node, flags, name, name_len, fmt, ...) 0
94
+
95
+
96
+#endif /* _mi_h_ */
97
+
98
+
0 99
new file mode 100644
... ...
@@ -0,0 +1,145 @@
0
+/*
1
+ * $Id$
2
+ *
3
+ * Copyright (C) 2008 
4
+ *
5
+ * Permission to use, copy, modify, and distribute this software for any
6
+ * purpose with or without fee is hereby granted, provided that the above
7
+ * copyright notice and this permission notice appear in all copies.
8
+ *
9
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+ */
17
+/*
18
+ * pvar compatibility wrapper for kamailio
19
+ * for now it doesn't do anything (feel free to rm & replace the file)
20
+ *
21
+ * History:
22
+ * --------
23
+ *  2008-11-17  initial version compatible with kamailio pvar.h (andrei)
24
+ */
25
+
26
+#ifndef _pvar_h_
27
+#define _pvar_h_
28
+
29
+#include "str.h"
30
+#include "usr_avp.h"
31
+#include "parser/msg_parser.h"
32
+
33
+
34
+
35
+
36
+enum _pv_type { 
37
+	PVT_NONE=0,           PVT_EMPTY,             PVT_NULL, 
38
+	PVT_MARKER,           PVT_AVP,               PVT_HDR,
39
+	PVT_PID,              PVT_RETURN_CODE,       PVT_TIMES,
40
+	PVT_TIMEF,            PVT_MSGID,             PVT_METHOD,
41
+	PVT_STATUS,           PVT_REASON,            PVT_RURI,
42
+	PVT_RURI_USERNAME,    PVT_RURI_DOMAIN,       PVT_RURI_PORT,
43
+	PVT_FROM,             PVT_FROM_USERNAME,     PVT_FROM_DOMAIN,
44
+	PVT_FROM_TAG,         PVT_TO,                PVT_TO_USERNAME,
45
+	PVT_TO_DOMAIN,        PVT_TO_TAG,            PVT_CSEQ,
46
+	PVT_CONTACT,          PVT_CALLID,            PVT_USERAGENT,
47
+	PVT_MSG_BUF,          PVT_MSG_LEN,           PVT_FLAGS,
48
+	PVT_HEXFLAGS,         PVT_SRCIP,             PVT_SRCPORT,
49
+	PVT_RCVIP,            PVT_RCVPORT,           PVT_REFER_TO,
50
+	PVT_DSET,             PVT_DSTURI,            PVT_COLOR,
51
+	PVT_BRANCH,           PVT_BRANCHES,          PVT_CONTENT_TYPE,
52
+	PVT_CONTENT_LENGTH,   PVT_MSG_BODY,          PVT_AUTH_USERNAME,
53
+	PVT_AUTH_REALM,       PVT_RURI_PROTOCOL,     PVT_DSTURI_DOMAIN,
54
+	PVT_DSTURI_PORT,      PVT_DSTURI_PROTOCOL,   PVT_FROM_DISPLAYNAME,
55
+	PVT_TO_DISPLAYNAME,   PVT_OURI,              PVT_OURI_USERNAME,
56
+	PVT_OURI_DOMAIN,      PVT_OURI_PORT,         PVT_OURI_PROTOCOL,
57
+	PVT_FORCE_SOCK,       PVT_RPID_URI,          PVT_DIVERSION_URI,
58
+	PVT_ACC_USERNAME,     PVT_PPI,               PVT_PPI_DISPLAYNAME,
59
+	PVT_PPI_DOMAIN,       PVT_PPI_USERNAME,      PVT_PAI_URI,
60
+	PVT_BFLAGS,           PVT_HEXBFLAGS,         PVT_SFLAGS,
61
+	PVT_HEXSFLAGS,        PVT_ERR_CLASS,         PVT_ERR_LEVEL,
62
+	PVT_ERR_INFO,         PVT_ERR_RCODE,         PVT_ERR_RREASON,
63
+	PVT_SCRIPTVAR,        PVT_PROTO,             PVT_AUTH_USERNAME_WHOLE,
64
+	PVT_AUTH_DURI,        PVT_DIV_REASON,        PVT_DIV_PRIVACY,
65
+	PVT_AUTH_DOMAIN,      PVT_EXTRA /* keep it last */
66
+};
67
+
68
+typedef enum _pv_type pv_type_t;
69
+typedef int pv_flags_t;
70
+
71
+typedef struct _pv_value
72
+{
73
+	str rs;    /*!< string value */
74
+	int ri;    /*!< integer value */
75
+	int flags; /*!< flags about the type of value */
76
+} pv_value_t, *pv_value_p;
77
+
78
+typedef struct _pv_name
79
+{
80
+	int type;             /*!< type of name */
81
+	union {
82
+		struct {
83
+			int type;     /*!< type of int_str name - compatibility with AVPs */
84
+			int_str name; /*!< the value of the name */
85
+		} isname;
86
+		void *dname;      /*!< PV value - dynamic name */
87
+	} u;
88
+} pv_name_t, *pv_name_p;
89
+
90
+typedef struct _pv_index
91
+{
92
+	int type; /*!< type of PV index */
93
+	union {
94
+		int ival;   /*!< integer value */
95
+		void *dval; /*!< PV value - dynamic index */
96
+	} u;
97
+} pv_index_t, *pv_index_p;
98
+
99
+typedef struct _pv_param
100
+{
101
+	pv_name_t    pvn; /*!< PV name */
102
+	pv_index_t   pvi; /*!< PV index */
103
+} pv_param_t, *pv_param_p;
104
+
105
+typedef int (*pv_getf_t) (struct sip_msg*,  pv_param_t*, pv_value_t*);
106
+typedef int (*pv_setf_t) (struct sip_msg*,  pv_param_t*, int, pv_value_t*);
107
+
108
+typedef struct _pv_spec {
109
+	pv_type_t    type;   /*!< type of PV */
110
+	pv_getf_t    getf;   /*!< get PV value function */
111
+	pv_setf_t    setf;   /*!< set PV value function */
112
+	pv_param_t   pvp;    /*!< parameter to be given to get/set functions */
113
+	void         *trans; /*!< transformations */
114
+} pv_spec_t, *pv_spec_p;
115
+
116
+
117
+
118
+typedef int (*pv_parse_name_f)(pv_spec_p sp, str *in);
119
+typedef int (*pv_parse_index_f)(pv_spec_p sp, str *in);
120
+typedef int (*pv_init_param_f)(pv_spec_p sp, int param);
121
+
122
+/*! \brief
123
+ * PV spec format:
124
+ * - $class_name
125
+ * - $class_name(inner_name)
126
+ * - $(class_name[index])
127
+ * - $(class_name(inner_name)[index])
128
+ * - $(class_name{transformation})
129
+ * - $(class_name(inner_name){transformation})
130
+ * - $(class_name[index]{transformation})
131
+ * - $(class_name(inner_name)[index]{transformation})
132
+ */
133
+typedef struct _pv_export {
134
+	str name;                      /*!< class name of PV */
135
+	pv_type_t type;                /*!< type of PV */
136
+	pv_getf_t  getf;               /*!< function to get the value */
137
+	pv_setf_t  setf;               /*!< function to set the value */
138
+	pv_parse_name_f parse_name;    /*!< function to parse the inner name */
139
+	pv_parse_index_f parse_index;  /*!< function to parse the index of PV */
140
+	pv_init_param_f init_param;    /*!< function to init the PV spec */
141
+	int iparam;                    /*!< parameter for the init function */
142
+} pv_export_t;
143
+
144
+#endif /* _pvar_h_ */
0 145
new file mode 100644
... ...
@@ -0,0 +1,72 @@
0
+/*
1
+ * $Id$
2
+ *
3
+ * Copyright (C) 2008 iptelorg GmbH
4
+ *
5
+ * Permission to use, copy, modify, and distribute this software for any
6
+ * purpose with or without fee is hereby granted, provided that the above
7
+ * copyright notice and this permission notice appear in all copies.
8
+ *
9
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+ */
17
+/*
18
+ * statistics compatibility wrapper for kamailio
19
+ * for now it doesn't do anything
20
+ * (obsolete, do not use anymore)
21
+ *
22
+ * History:
23
+ * --------
24
+ *  2008-11-17  initial version compatible with kamailio statistics.h (andrei)
25
+ */
26
+
27
+#ifndef _STATISTICS_H_
28
+#define _STATISTICS_H_
29
+
30
+#include "str.h"
31
+
32
+#define STAT_NO_RESET  1
33
+#define STAT_NO_SYNC   2
34
+#define STAT_SHM_NAME  4
35
+#define STAT_IS_FUNC   8
36
+
37
+
38
+
39
+typedef unsigned int stat_val;
40
+typedef unsigned long (*stat_function)(void);
41
+
42
+typedef struct stat_var_{
43
+	unsigned int mod_idx;
44
+	str name;
45
+	int flags;
46
+	union{
47
+		stat_val *val;
48
+		stat_function f;
49
+	}u;
50
+	struct stat_var_ *hnext;
51
+	struct stat_var_ *lnext;
52
+} stat_var;
53
+
54
+
55
+typedef struct stat_export_ {
56
+	char* name;                /* null terminated statistic name */
57
+	int flags;                 /* flags */
58
+	stat_var** stat_pointer;   /* pointer to the variable's shm mem location */
59
+} stat_export_t;
60
+
61
+#define get_stat(name)  0
62
+#define get_stat_val(v) 0
63
+#define update_stat(v, n)
64
+#define reset_stat(v)
65
+#define if_update_stat (cond, v, n)
66
+
67
+#ifdef STATISTICS
68
+#warning "sorry sip-router does not support STATISTICS"
69
+#endif
70
+
71
+#endif /* _STATISTICS_H_ */