Browse code

core: added sctp callbacks api

- functions needed in core - callbacks to be set by sctp module

Daniel-Constantin Mierla authored on 25/05/2013 08:56:11
Showing 2 changed files
... ...
@@ -20,40 +20,93 @@
20 20
 
21 21
 #include "sctp_core.h"
22 22
 
23
-int sctp_core_msg_send(struct dest_info* dst, char* buf, unsigned len)
23
+/**
24
+ *
25
+ */
26
+static sctp_srapi_t _sctp_srapi = { 0 };
27
+static int _sctp_srapi_set = 0;
28
+
29
+/**
30
+ *
31
+ */
32
+int sctp_core_init(void)
24 33
 {
25
-	return 0;
34
+	if(_sctp_srapi_set==0) {
35
+		LM_ERR("SCTP API not initialized\n");
36
+		return -1;
37
+	}
38
+
39
+	return _sctp_srapi.init();
26 40
 }
27 41
 
42
+/**
43
+ *
44
+ */
28 45
 void sctp_core_destroy(void)
29 46
 {
30 47
 }
31 48
 
49
+/**
50
+ *
51
+ */
32 52
 int sctp_core_init_sock(struct socket_info* sock_info)
33 53
 {
34 54
 	return 0;
35 55
 }
36 56
 
37
-int sctp_core_rcv_loop(void)
57
+/**
58
+ *
59
+ */
60
+void sctp_core_init_options(void)
61
+{
62
+}
63
+
64
+/**
65
+ *
66
+ */
67
+int sctp_core_check_compiled_sockopts(char* buf, int size)
38 68
 {
39 69
 	return 0;
40 70
 }
41 71
 
42
-void sctp_core_init_options(void)
72
+/**
73
+ *
74
+ */
75
+int sctp_core_check_support(void)
43 76
 {
77
+	return 0;
44 78
 }
45 79
 
46
-int sctp_core_check_compiled_sockopts(char* buf, int size)
80
+/**
81
+ *
82
+ */
83
+int sctp_core_rcv_loop(void)
47 84
 {
48 85
 	return 0;
49 86
 }
50 87
 
51
-int sctp_core_check_support(void)
88
+/**
89
+ *
90
+ */
91
+int sctp_core_msg_send(struct dest_info* dst, char* buf, unsigned len)
52 92
 {
53 93
 	return 0;
54 94
 }
55 95
 
56
-int sctp_core_init(void)
96
+/**
97
+ *
98
+ */
99
+int sctp_core_register_api(sctp_srapi_t *api)
57 100
 {
101
+	if(api==NULL || api->init==NULL) {
102
+		LM_ERR("invalid parameters\n");
103
+		return -1;
104
+	}
105
+	if(_sctp_srapi_set==1) {
106
+		LM_ERR("SCTP API already initialized\n");
107
+		return -1;
108
+	}
109
+	_sctp_srapi_set = 1;
110
+	memcpy(&_sctp_srapi, api, sizeof(sctp_srapi_t));
58 111
 	return 0;
59 112
 }
... ...
@@ -24,19 +24,41 @@
24 24
 #include "ip_addr.h"
25 25
 
26 26
 int sctp_core_init(void);
27
+typedef int (*sctp_srapi_init_f)(void);
27 28
 
28 29
 void sctp_core_destroy(void);
30
+typedef void (*sctp_srapi_destroy_f)(void);
29 31
 
30 32
 int sctp_core_init_sock(struct socket_info* sock_info);
33
+typedef int (*sctp_srapi_init_sock_f)(struct socket_info* sock_info);
31 34
 
32 35
 void sctp_core_init_options(void);
36
+typedef void (*sctp_srapi_init_options_f)(void);
33 37
 
34 38
 int sctp_core_check_compiled_sockopts(char* buf, int size);
39
+typedef int (*sctp_srapi_check_compiled_sockopts_f)(char* buf, int size);
35 40
 
36 41
 int sctp_core_check_support(void);
42
+typedef int (*sctp_srapi_check_support_f)(void);
37 43
 
38 44
 int sctp_core_rcv_loop(void);
45
+typedef int (*sctp_srapi_rcv_loop_f)(void);
39 46
 
40 47
 int sctp_core_msg_send(struct dest_info* dst, char* buf, unsigned len);
48
+typedef int (*sctp_srapi_msg_send_f)(struct dest_info* dst, char* buf,
49
+		unsigned len);
50
+
51
+typedef struct sctp_srapi {
52
+	sctp_srapi_init_f init;
53
+	sctp_srapi_destroy_f destroy;
54
+	sctp_srapi_init_sock_f init_sock;
55
+	sctp_srapi_init_options_f init_options;
56
+	sctp_srapi_check_compiled_sockopts_f check_compiled_sockopts;
57
+	sctp_srapi_check_support_f check_support;
58
+	sctp_srapi_rcv_loop_f rcv_loop;
59
+	sctp_srapi_msg_send_f msg_send;
60
+} sctp_srapi_t;
61
+
62
+int sctp_core_register_api(sctp_srapi_t *api);
41 63
 
42 64
 #endif