~ubuntu-branches/debian/sid/kamailio/sid

« back to all changes in this revision

Viewing changes to modules/sctp/sctp_mod.c

  • Committer: Package Import Robot
  • Author(s): Victor Seva
  • Date: 2014-01-06 11:47:13 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140106114713-t8xidp4arzrnyeya
Tags: 4.1.1-1
* New upstream release
* debian/patches:
  - add upstream fixes
* Added tls outbound websocket autheph dnssec modules
  - openssl exception added to their license
* removing sparc and ia64 from supported archs
  for mono module (Closes: #728915)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * $Id$
 
3
 *
 
4
 * Copyright (C) 2008 iptelorg GmbH
 
5
 * Copyright (C) 2013 Daniel-Constantin Mierla (asipto.com)
 
6
 *
 
7
 * This file is part of Kamailio, a free SIP server.
 
8
 *
 
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.
 
12
 *
 
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.
 
20
 */
 
21
 
 
22
 
 
23
#include <stdio.h>
 
24
#include <unistd.h>
 
25
#include <stdlib.h>
 
26
#include <string.h>
 
27
 
 
28
#include "../../sr_module.h"
 
29
#include "../../dprint.h"
 
30
#include "../../shm_init.h"
 
31
#include "../../sctp_core.h"
 
32
 
 
33
#include "sctp_options.h"
 
34
#include "sctp_server.h"
 
35
#include "sctp_rpc.h"
 
36
 
 
37
MODULE_VERSION
 
38
 
 
39
static int mod_init(void);
 
40
static int sctp_mod_pre_init(void);
 
41
 
 
42
 
 
43
static cmd_export_t cmds[]={
 
44
        {0, 0, 0, 0, 0, 0}
 
45
};
 
46
 
 
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},
 
67
 
 
68
        {0, 0, 0}
 
69
};
 
70
 
 
71
struct module_exports exports = {
 
72
        "sctp",
 
73
        DEFAULT_DLFLAGS, /* dlopen flags */
 
74
        cmds,
 
75
        params,
 
76
        0,
 
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 */
 
84
};
 
85
 
 
86
int mod_register(char *path, int *dlflags, void *p1, void *p2)
 
87
{
 
88
        if(!shm_initialized() && init_shm()<0)
 
89
                return -1;
 
90
 
 
91
#ifdef USE_SCTP
 
92
        /* shm is used, be sure it is initialized */
 
93
        if(sctp_mod_pre_init()<0)
 
94
                return -1;
 
95
        return 0;
 
96
#else
 
97
        LOG(L_CRIT, "sctp core support not enabled\n");
 
98
        return -1;
 
99
#endif
 
100
}
 
101
 
 
102
static int mod_init(void)
 
103
{
 
104
#ifdef USE_SCTP
 
105
        char tmp[256];
 
106
        if (sctp_check_compiled_sockopts(tmp, 256)!=0){
 
107
                LM_WARN("sctp unsupported socket options: %s\n", tmp);
 
108
        }
 
109
 
 
110
        if (sctp_register_cfg()){
 
111
                LOG(L_CRIT, "could not register the sctp configuration\n");
 
112
                return -1;
 
113
        }
 
114
        if (sctp_register_rpc()){
 
115
                LOG(L_CRIT, "could not register the sctp rpc commands\n");
 
116
                return -1;
 
117
        }
 
118
        return 0;
 
119
#else /* USE_SCTP */
 
120
        LOG(L_CRIT, "sctp core support not enabled\n");
 
121
        return -1;
 
122
#endif /* USE_SCTP */
 
123
}
 
124
 
 
125
static int sctp_mod_pre_init(void)
 
126
{
 
127
        sctp_srapi_t api;
 
128
 
 
129
        /* set defaults before the config mod params */
 
130
        init_sctp_options();
 
131
 
 
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;
 
139
 
 
140
        if(sctp_core_register_api(&api)<0) {
 
141
                LM_ERR("cannot regiser sctp core api\n");
 
142
                return -1;
 
143
        }
 
144
        return 0;
 
145
}