4
* Copyright (C) 2008 iptelorg GmbH
5
* Copyright (C) 2013 Daniel-Constantin Mierla (asipto.com)
7
* This file is part of Kamailio, a free SIP server.
9
* Permission to use, copy, modify, and distribute this software for any
10
* purpose with or without fee is hereby granted, provided that the above
11
* copyright notice and this permission notice appear in all copies.
13
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
28
#include "../../sr_module.h"
29
#include "../../dprint.h"
30
#include "../../shm_init.h"
31
#include "../../sctp_core.h"
33
#include "sctp_options.h"
34
#include "sctp_server.h"
39
static int mod_init(void);
40
static int sctp_mod_pre_init(void);
43
static cmd_export_t cmds[]={
47
static param_export_t params[]={
48
{"sctp_socket_rcvbuf", PARAM_INT, &sctp_default_cfg.so_rcvbuf},
49
{"sctp_socket_sndbuf", PARAM_INT, &sctp_default_cfg.so_sndbuf},
50
{"sctp_autoclose", PARAM_INT, &sctp_default_cfg.autoclose},
51
{"sctp_send_ttl", PARAM_INT, &sctp_default_cfg.send_ttl},
52
{"sctp_send_retries", PARAM_INT, &sctp_default_cfg.send_retries},
53
{"sctp_assoc_tracking", PARAM_INT, &sctp_default_cfg.assoc_tracking},
54
{"sctp_assoc_reuse", PARAM_INT, &sctp_default_cfg.assoc_reuse},
55
{"sctp_max_assocs", PARAM_INT, &sctp_default_cfg.max_assocs},
56
{"sctp_srto_initial", PARAM_INT, &sctp_default_cfg.srto_initial},
57
{"sctp_srto_max", PARAM_INT, &sctp_default_cfg.srto_max},
58
{"sctp_srto_min", PARAM_INT, &sctp_default_cfg.srto_min},
59
{"sctp_asocmaxrxt", PARAM_INT, &sctp_default_cfg.asocmaxrxt},
60
{"sctp_init_max_attempts", PARAM_INT, &sctp_default_cfg.init_max_attempts},
61
{"sctp_init_max_timeo", PARAM_INT, &sctp_default_cfg.init_max_timeo},
62
{"sctp_hbinterval", PARAM_INT, &sctp_default_cfg.hbinterval},
63
{"sctp_pathmaxrxt", PARAM_INT, &sctp_default_cfg.pathmaxrxt},
64
{"sctp_sack_delay", PARAM_INT, &sctp_default_cfg.sack_delay},
65
{"sctp_sack_freq", PARAM_INT, &sctp_default_cfg.sack_freq},
66
{"sctp_max_burst", PARAM_INT, &sctp_default_cfg.max_burst},
71
struct module_exports exports = {
73
DEFAULT_DLFLAGS, /* dlopen flags */
77
0, /* exported MI functions */
78
0, /* exported pseudo-variables */
79
0, /* extra processes */
80
mod_init, /* module initialization function */
81
0, /* response function */
82
0, /* destroy function */
83
0 /* per child init function */
86
int mod_register(char *path, int *dlflags, void *p1, void *p2)
88
if(!shm_initialized() && init_shm()<0)
92
/* shm is used, be sure it is initialized */
93
if(sctp_mod_pre_init()<0)
97
LOG(L_CRIT, "sctp core support not enabled\n");
102
static int mod_init(void)
106
if (sctp_check_compiled_sockopts(tmp, 256)!=0){
107
LM_WARN("sctp unsupported socket options: %s\n", tmp);
110
if (sctp_register_cfg()){
111
LOG(L_CRIT, "could not register the sctp configuration\n");
114
if (sctp_register_rpc()){
115
LOG(L_CRIT, "could not register the sctp rpc commands\n");
120
LOG(L_CRIT, "sctp core support not enabled\n");
122
#endif /* USE_SCTP */
125
static int sctp_mod_pre_init(void)
129
/* set defaults before the config mod params */
132
memset(&api, 0, sizeof(sctp_srapi_t));
133
api.init = init_sctp;
134
api.destroy = destroy_sctp;
135
api.init_sock = sctp_init_sock;
136
api.check_support = sctp_check_support;
137
api.rcv_loop = sctp_rcv_loop;
138
api.msg_send = sctp_msg_send;
140
if(sctp_core_register_api(&api)<0) {
141
LM_ERR("cannot regiser sctp core api\n");