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