Browse code

core: sip routing api - custom callid generator callback

- allow registration of callback functions for different callid
generators

Daniel-Constantin Mierla authored on 01/02/2016 17:48:55
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,46 @@
0
+/*
1
+ * Copyright (C) 2016 Daniel-Constantin Mierla (asipto.com)
2
+ *
3
+ * This file is part of Kamailio, a free SIP server.
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
+
19
+#include <stdio.h>
20
+#include <stdlib.h>
21
+#include "dprint.h"
22
+
23
+#include "srapi.h"
24
+
25
+static sr_generate_callid_f _sr_generate_callid_func = NULL;
26
+
27
+/**
28
+ *
29
+ */
30
+int sr_register_callid_func(sr_generate_callid_f f)
31
+{
32
+	if(_sr_generate_callid_func!=NULL) {
33
+		LM_INFO("overwriting generate callid function\n");
34
+	}
35
+	_sr_generate_callid_func = f;
36
+	return 0;
37
+}
38
+
39
+/**
40
+ *
41
+ */
42
+sr_generate_callid_f sr_get_callid_func(void)
43
+{
44
+	return _sr_generate_callid_func;
45
+}
0 46
new file mode 100644
... ...
@@ -0,0 +1,30 @@
0
+/*
1
+ * Copyright (C) 2016 Daniel-Constantin Mierla (asipto.com)
2
+ *
3
+ * This file is part of Kamailio, a free SIP server.
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
+#ifndef __SRAPI_H__
19
+#define __SRAPI_H__
20
+
21
+#include "str.h"
22
+
23
+typedef void (*sr_generate_callid_f)(str*);
24
+
25
+int sr_register_callid_func(sr_generate_callid_f f);
26
+
27
+sr_generate_callid_f sr_get_callid_func(void);
28
+
29
+#endif