Wed Jan 27 20:02:48 2016

Asterisk developer's documentation


res_srtp.c File Reference

Secure RTP (SRTP). More...

#include "asterisk.h"
#include <srtp/srtp.h>
#include <srtp/crypto_kernel.h>
#include "asterisk/lock.h"
#include "asterisk/sched.h"
#include "asterisk/module.h"
#include "asterisk/options.h"
#include "asterisk/rtp_engine.h"
#include "asterisk/astobj2.h"

Go to the source code of this file.

Data Structures

struct  ast_srtp
struct  ast_srtp_policy

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int ast_srtp_add_stream (struct ast_srtp *srtp, struct ast_srtp_policy *policy)
static int ast_srtp_change_source (struct ast_srtp *srtp, unsigned int from_ssrc, unsigned int to_ssrc)
static int ast_srtp_create (struct ast_srtp **srtp, struct ast_rtp_instance *rtp, struct ast_srtp_policy *policy)
static void ast_srtp_destroy (struct ast_srtp *srtp)
static int ast_srtp_get_random (unsigned char *key, size_t len)
static struct ast_srtp_policyast_srtp_policy_alloc (void)
static void ast_srtp_policy_destroy (struct ast_srtp_policy *policy)
static int ast_srtp_policy_set_master_key (struct ast_srtp_policy *policy, const unsigned char *key, size_t key_len, const unsigned char *salt, size_t salt_len)
static void ast_srtp_policy_set_ssrc (struct ast_srtp_policy *policy, unsigned long ssrc, int inbound)
static int ast_srtp_policy_set_suite (struct ast_srtp_policy *policy, enum ast_srtp_suite suite)
static int ast_srtp_protect (struct ast_srtp *srtp, void **buf, int *len, int rtcp)
static int ast_srtp_replace (struct ast_srtp **srtp, struct ast_rtp_instance *rtp, struct ast_srtp_policy *policy)
static void ast_srtp_set_cb (struct ast_srtp *srtp, const struct ast_srtp_cb *cb, void *data)
static int ast_srtp_unprotect (struct ast_srtp *srtp, void *buf, int *len, int rtcp)
static struct ast_srtp_policyfind_policy (struct ast_srtp *srtp, const srtp_policy_t *policy, int flags)
static int load_module (void)
static int policy_cmp_fn (void *obj, void *arg, int flags)
static void policy_destructor (void *obj)
static int policy_hash_fn (const void *obj, const int flags)
static int policy_set_suite (crypto_policy_t *p, enum ast_srtp_suite suite)
static int res_srtp_init (void)
static struct ast_srtpres_srtp_new (void)
static void res_srtp_shutdown (void)
static const char * srtp_errstr (int err)
static void srtp_event_cb (srtp_event_data_t *data)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "Secure RTP (SRTP)" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND, }
static struct ast_module_infoast_module_info = &__mod_info
static int g_initialized = 0
static struct ast_srtp_policy_res policy_res
static struct ast_srtp_res srtp_res

Detailed Description

Secure RTP (SRTP).

Secure RTP (SRTP) Specified in RFC 3711.

Author:
Mikael Magnusson <mikma@users.sourceforge.net>

Definition in file res_srtp.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 598 of file res_srtp.c.

static void __unreg_module ( void   )  [static]

Definition at line 598 of file res_srtp.c.

static int ast_srtp_add_stream ( struct ast_srtp srtp,
struct ast_srtp_policy policy 
) [static]

Definition at line 487 of file res_srtp.c.

References ao2_t_link, ao2_t_ref, ao2_t_unlink, ast_debug, ast_log(), AST_LOG_WARNING, find_policy(), match(), OBJ_POINTER, ast_srtp::policies, ast_srtp::session, and ast_srtp_policy::sp.

Referenced by ast_srtp_change_source().

00488 {
00489    struct ast_srtp_policy *match;
00490 
00491    /* For existing streams, replace if its an SSRC stream, or bail if its a wildcard */
00492    if ((match = find_policy(srtp, &policy->sp, OBJ_POINTER))) {
00493       if (policy->sp.ssrc.type != ssrc_specific) {
00494          ast_log(AST_LOG_WARNING, "Cannot replace an existing wildcard policy\n");
00495          ao2_t_ref(match, -1, "Unreffing already existing policy");
00496          return -1;
00497       } else {
00498          if (srtp_remove_stream(srtp->session, match->sp.ssrc.value) != err_status_ok) {
00499             ast_log(AST_LOG_WARNING, "Failed to remove SRTP stream for SSRC %u\n", match->sp.ssrc.value);
00500          }
00501          ao2_t_unlink(srtp->policies, match, "Remove existing match policy");
00502          ao2_t_ref(match, -1, "Unreffing already existing policy");
00503       }
00504    }
00505 
00506    ast_debug(3, "Adding new policy for %s %u\n",
00507       policy->sp.ssrc.type == ssrc_specific ? "SSRC" : "type",
00508       policy->sp.ssrc.type == ssrc_specific ? policy->sp.ssrc.value : policy->sp.ssrc.type);
00509    if (srtp_add_stream(srtp->session, &policy->sp) != err_status_ok) {
00510       ast_log(AST_LOG_WARNING, "Failed to add SRTP stream for %s %u\n",
00511          policy->sp.ssrc.type == ssrc_specific ? "SSRC" : "type",
00512          policy->sp.ssrc.type == ssrc_specific ? policy->sp.ssrc.value : policy->sp.ssrc.type);
00513       return -1;
00514    }
00515 
00516    ao2_t_link(srtp->policies, policy, "Added additional stream");
00517 
00518    return 0;
00519 }

static int ast_srtp_change_source ( struct ast_srtp srtp,
unsigned int  from_ssrc,
unsigned int  to_ssrc 
) [static]

Definition at line 521 of file res_srtp.c.

References ao2_t_ref, ast_debug, ast_log(), ast_srtp_add_stream(), find_policy(), LOG_WARNING, match(), OBJ_POINTER, OBJ_UNLINK, ast_srtp::session, ast_srtp_policy::sp, and status.

00522 {
00523    struct ast_srtp_policy *match;
00524    struct srtp_policy_t sp = {
00525       .ssrc.type = ssrc_specific,
00526       .ssrc.value = from_ssrc,
00527    };
00528    err_status_t status;
00529 
00530    /* If we find a match, return and unlink it from the container so we
00531     * can change the SSRC (which is part of the hash) and then have
00532     * ast_srtp_add_stream link it back in if all is well */
00533    if ((match = find_policy(srtp, &sp, OBJ_POINTER | OBJ_UNLINK))) {
00534       match->sp.ssrc.value = to_ssrc;
00535       if (ast_srtp_add_stream(srtp, match)) {
00536          ast_log(LOG_WARNING, "Couldn't add stream\n");
00537       } else if ((status = srtp_remove_stream(srtp->session, from_ssrc))) {
00538          ast_debug(3, "Couldn't remove stream (%u)\n", status);
00539       }
00540       ao2_t_ref(match, -1, "Unreffing found policy in change_source");
00541    }
00542 
00543    return 0;
00544 }

static int ast_srtp_create ( struct ast_srtp **  srtp,
struct ast_rtp_instance rtp,
struct ast_srtp_policy policy 
) [static]

Definition at line 441 of file res_srtp.c.

References ao2_t_link, ast_module_ref(), ast_srtp_destroy(), res_srtp_new(), ast_srtp::rtp, ast_srtp::session, and ast_srtp_policy::sp.

Referenced by ast_srtp_replace().

00442 {
00443    struct ast_srtp *temp;
00444 
00445    if (!(temp = res_srtp_new())) {
00446       return -1;
00447    }
00448    ast_module_ref(ast_module_info->self);
00449 
00450    /* Any failures after this point can use ast_srtp_destroy to destroy the instance */
00451    if (srtp_create(&temp->session, &policy->sp) != err_status_ok) {
00452       /* Session either wasn't created or was created and dealloced. */
00453       temp->session = NULL;
00454       ast_srtp_destroy(temp);
00455       return -1;
00456    }
00457 
00458    temp->rtp = rtp;
00459    *srtp = temp;
00460 
00461    ao2_t_link((*srtp)->policies, policy, "Created initial policy");
00462 
00463    return 0;
00464 }

static void ast_srtp_destroy ( struct ast_srtp srtp  )  [static]

Definition at line 474 of file res_srtp.c.

References ao2_t_callback, ao2_t_ref, ast_free, ast_module_unref(), OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, ast_srtp::policies, and ast_srtp::session.

Referenced by ast_srtp_create(), and ast_srtp_replace().

00475 {
00476    if (srtp->session) {
00477       srtp_dealloc(srtp->session);
00478    }
00479 
00480    ao2_t_callback(srtp->policies, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, NULL, NULL, "Unallocate policy");
00481    ao2_t_ref(srtp->policies, -1, "Destroying container");
00482 
00483    ast_free(srtp);
00484    ast_module_unref(ast_module_info->self);
00485 }

static int ast_srtp_get_random ( unsigned char *  key,
size_t  len 
) [static]

Definition at line 306 of file res_srtp.c.

00307 {
00308    return crypto_get_random(key, len) != err_status_ok ? -1: 0;
00309 }

static struct ast_srtp_policy * ast_srtp_policy_alloc ( void   )  [static, read]

Definition at line 236 of file res_srtp.c.

References ao2_t_alloc, ast_log(), LOG_ERROR, and policy_destructor().

00237 {
00238    struct ast_srtp_policy *tmp;
00239 
00240    if (!(tmp = ao2_t_alloc(sizeof(*tmp), policy_destructor, "Allocating policy"))) {
00241       ast_log(LOG_ERROR, "Unable to allocate memory for srtp_policy\n");
00242    }
00243 
00244    return tmp;
00245 }

static void ast_srtp_policy_destroy ( struct ast_srtp_policy policy  )  [static]

Definition at line 247 of file res_srtp.c.

References ao2_t_ref.

00248 {
00249    ao2_t_ref(policy, -1, "Destroying policy");
00250 }

static int ast_srtp_policy_set_master_key ( struct ast_srtp_policy policy,
const unsigned char *  key,
size_t  key_len,
const unsigned char *  salt,
size_t  salt_len 
) [static]

Definition at line 284 of file res_srtp.c.

References ast_calloc, ast_free, and ast_srtp_policy::sp.

00285 {
00286    size_t size = key_len + salt_len;
00287    unsigned char *master_key;
00288 
00289    if (policy->sp.key) {
00290       ast_free(policy->sp.key);
00291       policy->sp.key = NULL;
00292    }
00293 
00294    if (!(master_key = ast_calloc(1, size))) {
00295       return -1;
00296    }
00297 
00298    memcpy(master_key, key, key_len);
00299    memcpy(master_key + key_len, salt, salt_len);
00300 
00301    policy->sp.key = master_key;
00302 
00303    return 0;
00304 }

static void ast_srtp_policy_set_ssrc ( struct ast_srtp_policy policy,
unsigned long  ssrc,
int  inbound 
) [static]

Definition at line 215 of file res_srtp.c.

References ast_srtp_policy::sp.

00217 {
00218    if (ssrc) {
00219       policy->sp.ssrc.type = ssrc_specific;
00220       policy->sp.ssrc.value = ssrc;
00221    } else {
00222       policy->sp.ssrc.type = inbound ? ssrc_any_inbound : ssrc_any_outbound;
00223    }
00224 }

static int ast_srtp_policy_set_suite ( struct ast_srtp_policy policy,
enum ast_srtp_suite  suite 
) [static]

Definition at line 279 of file res_srtp.c.

References policy_set_suite(), and ast_srtp_policy::sp.

00280 {
00281    return policy_set_suite(&policy->sp.rtp, suite) | policy_set_suite(&policy->sp.rtcp, suite);
00282 }

static int ast_srtp_protect ( struct ast_srtp srtp,
void **  buf,
int *  len,
int  rtcp 
) [static]

Definition at line 419 of file res_srtp.c.

References ast_log(), ast_srtp::buf, LOG_WARNING, ast_srtp::rtcpbuf, ast_srtp::session, and srtp_errstr().

00420 {
00421    int res;
00422    unsigned char *localbuf;
00423 
00424    if ((*len + SRTP_MAX_TRAILER_LEN) > sizeof(srtp->buf)) {
00425       return -1;
00426    }
00427    
00428    localbuf = rtcp ? srtp->rtcpbuf : srtp->buf;
00429 
00430    memcpy(localbuf, *buf, *len);
00431 
00432    if ((res = rtcp ? srtp_protect_rtcp(srtp->session, localbuf, len) : srtp_protect(srtp->session, localbuf, len)) != err_status_ok && res != err_status_replay_fail) {
00433       ast_log(LOG_WARNING, "SRTP protect: %s\n", srtp_errstr(res));
00434       return -1;
00435    }
00436 
00437    *buf = localbuf;
00438    return *len;
00439 }

static int ast_srtp_replace ( struct ast_srtp **  srtp,
struct ast_rtp_instance rtp,
struct ast_srtp_policy policy 
) [static]

Definition at line 466 of file res_srtp.c.

References ast_srtp_create(), and ast_srtp_destroy().

00467 {
00468    if ((*srtp) != NULL) {
00469       ast_srtp_destroy(*srtp);
00470    }
00471    return ast_srtp_create(srtp, rtp, policy);
00472 }

static void ast_srtp_set_cb ( struct ast_srtp srtp,
const struct ast_srtp_cb cb,
void *  data 
) [static]

Definition at line 311 of file res_srtp.c.

References ast_srtp::cb, and ast_srtp::data.

00312 {
00313    if (!srtp) {
00314       return;
00315    }
00316 
00317    srtp->cb = cb;
00318    srtp->data = data;
00319 }

static int ast_srtp_unprotect ( struct ast_srtp srtp,
void *  buf,
int *  len,
int  rtcp 
) [static]

Definition at line 322 of file res_srtp.c.

References ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_t_ref, ast_debug, ast_log(), AST_LOG_NOTICE, AST_LOG_WARNING, ast_rtp_instance_get_stats(), AST_RTP_INSTANCE_STAT_REMOTE_SSRC, ast_srtp::cb, ast_srtp::data, errno, LOG_ERROR, ast_srtp_cb::no_ctx, ast_srtp::policies, ast_rtp_instance_stats::remote_ssrc, ast_srtp::rtp, ast_srtp::session, ast_srtp_policy::sp, srtp_errstr(), and ast_srtp::warned.

00323 {
00324    int res = 0;
00325    int i;
00326    int retry = 0;
00327    struct ast_rtp_instance_stats stats = {0,};
00328 
00329 tryagain:
00330 
00331    for (i = 0; i < 2; i++) {
00332       res = rtcp ? srtp_unprotect_rtcp(srtp->session, buf, len) : srtp_unprotect(srtp->session, buf, len);
00333       if (res != err_status_no_ctx) {
00334          break;
00335       }
00336 
00337       if (srtp->cb && srtp->cb->no_ctx) {
00338          if (ast_rtp_instance_get_stats(srtp->rtp, &stats, AST_RTP_INSTANCE_STAT_REMOTE_SSRC)) {
00339             break;
00340          }
00341          if (srtp->cb->no_ctx(srtp->rtp, stats.remote_ssrc, srtp->data) < 0) {
00342             break;
00343          }
00344       } else {
00345          break;
00346       }
00347    }
00348 
00349    if (retry == 0  && res == err_status_replay_old) {
00350       ast_log(AST_LOG_NOTICE, "SRTP unprotect failed with %s, retrying\n", srtp_errstr(res));
00351 
00352       if (srtp->session) {
00353          struct ast_srtp_policy *policy;
00354          struct ao2_iterator it;
00355          int policies_count;
00356 
00357          /* dealloc first */
00358          ast_debug(5, "SRTP destroy before re-create\n");
00359          srtp_dealloc(srtp->session);
00360 
00361          /* get the count */
00362          policies_count = ao2_container_count(srtp->policies);
00363 
00364          /* get the first to build up */
00365          it = ao2_iterator_init(srtp->policies, 0);
00366          policy = ao2_iterator_next(&it);
00367 
00368          ast_debug(5, "SRTP try to re-create\n");
00369          if (policy) {
00370             int res_srtp_create = srtp_create(&srtp->session, &policy->sp);
00371             if (res_srtp_create == err_status_ok) {
00372                ast_debug(5, "SRTP re-created with first policy\n");
00373                ao2_t_ref(policy, -1, "Unreffing first policy for re-creating srtp session");
00374 
00375                /* if we have more than one policy, add them */
00376                if (policies_count > 1) {
00377                   ast_debug(5, "Add all the other %d policies\n",
00378                      policies_count - 1);
00379                   while ((policy = ao2_iterator_next(&it))) {
00380                      srtp_add_stream(srtp->session, &policy->sp);
00381                      ao2_t_ref(policy, -1, "Unreffing n-th policy for re-creating srtp session");
00382                   }
00383                }
00384 
00385                retry++;
00386                ao2_iterator_destroy(&it);
00387                goto tryagain;
00388             }
00389             ast_log(LOG_ERROR, "SRTP session could not be re-created after unprotect failure: %s\n", srtp_errstr(res_srtp_create));
00390 
00391             /* If srtp_create() fails with a previously alloced session, it will have been dealloced before returning. */
00392             srtp->session = NULL;
00393 
00394             ao2_t_ref(policy, -1, "Unreffing first policy after srtp_create failed");
00395          }
00396          ao2_iterator_destroy(&it);
00397       }
00398    }
00399 
00400    if (!srtp->session) {
00401       errno = EINVAL;
00402       return -1;
00403    }
00404 
00405    if (res != err_status_ok && res != err_status_replay_fail ) {
00406       if ((srtp->warned >= 10) && !((srtp->warned - 10) % 100)) {
00407          ast_log(AST_LOG_WARNING, "SRTP unprotect failed with: %s %d\n", srtp_errstr(res), srtp->warned);
00408          srtp->warned = 11;
00409       } else {
00410          srtp->warned++;
00411       }
00412       errno = EAGAIN;
00413       return -1;
00414    }
00415 
00416    return *len;
00417 }

static struct ast_srtp_policy* find_policy ( struct ast_srtp srtp,
const srtp_policy_t *  policy,
int  flags 
) [static, read]

Definition at line 163 of file res_srtp.c.

References ao2_t_find, ast_srtp::policies, and ast_srtp_policy::sp.

Referenced by ast_srtp_add_stream(), and ast_srtp_change_source().

00164 {
00165    struct ast_srtp_policy tmp = {
00166       .sp = {
00167          .ssrc.type = policy->ssrc.type,
00168          .ssrc.value = policy->ssrc.value,
00169       },
00170    };
00171 
00172    return ao2_t_find(srtp->policies, &tmp, flags, "Looking for policy");
00173 }

static int load_module ( void   )  [static]

Definition at line 583 of file res_srtp.c.

References res_srtp_init().

00584 {
00585    return res_srtp_init();
00586 }

static int policy_cmp_fn ( void *  obj,
void *  arg,
int  flags 
) [static]

Definition at line 156 of file res_srtp.c.

References ast_srtp_policy::sp.

Referenced by res_srtp_new().

00157 {
00158    const struct ast_srtp_policy *one = obj, *two = arg;
00159 
00160    return one->sp.ssrc.type == two->sp.ssrc.type && one->sp.ssrc.value == two->sp.ssrc.value;
00161 }

static void policy_destructor ( void *  obj  )  [static]

Definition at line 226 of file res_srtp.c.

References ast_free, and ast_srtp_policy::sp.

Referenced by ast_srtp_policy_alloc().

00227 {
00228    struct ast_srtp_policy *policy = obj;
00229 
00230    if (policy->sp.key) {
00231       ast_free(policy->sp.key);
00232       policy->sp.key = NULL;
00233    }
00234 }

static int policy_hash_fn ( const void *  obj,
const int  flags 
) [static]

Definition at line 149 of file res_srtp.c.

References ast_srtp_policy::sp.

Referenced by res_srtp_new().

00150 {
00151    const struct ast_srtp_policy *policy = obj;
00152 
00153    return policy->sp.ssrc.type == ssrc_specific ? policy->sp.ssrc.value : policy->sp.ssrc.type;
00154 }

static int policy_set_suite ( crypto_policy_t *  p,
enum ast_srtp_suite  suite 
) [static]

Definition at line 252 of file res_srtp.c.

References AST_AES_CM_128_HMAC_SHA1_32, AST_AES_CM_128_HMAC_SHA1_80, ast_log(), and LOG_ERROR.

Referenced by ast_srtp_policy_set_suite().

00253 {
00254    switch (suite) {
00255    case AST_AES_CM_128_HMAC_SHA1_80:
00256       p->cipher_type = AES_128_ICM;
00257       p->cipher_key_len = 30;
00258       p->auth_type = HMAC_SHA1;
00259       p->auth_key_len = 20;
00260       p->auth_tag_len = 10;
00261       p->sec_serv = sec_serv_conf_and_auth;
00262       return 0;
00263 
00264    case AST_AES_CM_128_HMAC_SHA1_32:
00265       p->cipher_type = AES_128_ICM;
00266       p->cipher_key_len = 30;
00267       p->auth_type = HMAC_SHA1;
00268       p->auth_key_len = 20;
00269       p->auth_tag_len = 4;
00270       p->sec_serv = sec_serv_conf_and_auth;
00271       return 0;
00272 
00273    default:
00274       ast_log(LOG_ERROR, "Invalid crypto suite: %u\n", suite);
00275       return -1;
00276    }
00277 }

static int res_srtp_init ( void   )  [static]

Definition at line 556 of file res_srtp.c.

References ast_log(), AST_LOG_WARNING, ast_rtp_engine_register_srtp(), res_srtp_shutdown(), and srtp_event_cb().

Referenced by load_module().

00557 {
00558    if (g_initialized) {
00559       return 0;
00560    }
00561 
00562    if (srtp_init() != err_status_ok) {
00563       ast_log(AST_LOG_WARNING, "Failed to initialize libsrtp\n");
00564       return -1;
00565    }
00566 
00567    srtp_install_event_handler(srtp_event_cb);
00568 
00569    if (ast_rtp_engine_register_srtp(&srtp_res, &policy_res)) {
00570       ast_log(AST_LOG_WARNING, "Failed to register SRTP with rtp engine\n");
00571       res_srtp_shutdown();
00572       return -1;
00573    }
00574 
00575    g_initialized = 1;
00576    return 0;
00577 }

static struct ast_srtp* res_srtp_new ( void   )  [static, read]

Definition at line 175 of file res_srtp.c.

References ao2_t_container_alloc, ast_calloc, ast_free, ast_log(), LOG_ERROR, ast_srtp::policies, policy_cmp_fn(), policy_hash_fn(), and ast_srtp::warned.

Referenced by ast_srtp_create().

00176 {
00177    struct ast_srtp *srtp;
00178 
00179    if (!(srtp = ast_calloc(1, sizeof(*srtp)))) {
00180       ast_log(LOG_ERROR, "Unable to allocate memory for srtp\n");
00181       return NULL;
00182    }
00183 
00184    if (!(srtp->policies = ao2_t_container_alloc(5, policy_hash_fn, policy_cmp_fn, "SRTP policy container"))) {
00185       ast_free(srtp);
00186       return NULL;
00187    }
00188    
00189    srtp->warned = 1;
00190 
00191    return srtp;
00192 }

static void res_srtp_shutdown ( void   )  [static]

Definition at line 546 of file res_srtp.c.

References ast_rtp_engine_unregister_srtp().

Referenced by res_srtp_init(), and unload_module().

00547 {
00548    srtp_install_event_handler(NULL);
00549    ast_rtp_engine_unregister_srtp();
00550 #ifdef HAVE_SRTP_SHUTDOWN
00551    srtp_shutdown();
00552 #endif
00553    g_initialized = 0;
00554 }

static const char* srtp_errstr ( int  err  )  [static]

Definition at line 109 of file res_srtp.c.

Referenced by ast_srtp_protect(), and ast_srtp_unprotect().

00110 {
00111    switch(err) {
00112    case err_status_ok:
00113       return "nothing to report";
00114    case err_status_fail:
00115       return "unspecified failure";
00116    case err_status_bad_param:
00117       return "unsupported parameter";
00118    case err_status_alloc_fail:
00119       return "couldn't allocate memory";
00120    case err_status_dealloc_fail:
00121       return "couldn't deallocate properly";
00122    case err_status_init_fail:
00123       return "couldn't initialize";
00124    case err_status_terminus:
00125       return "can't process as much data as requested";
00126    case err_status_auth_fail:
00127       return "authentication failure";
00128    case err_status_cipher_fail:
00129       return "cipher failure";
00130    case err_status_replay_fail:
00131       return "replay check failed (bad index)";
00132    case err_status_replay_old:
00133       return "replay check failed (index too old)";
00134    case err_status_algo_fail:
00135       return "algorithm failed test routine";
00136    case err_status_no_such_op:
00137       return "unsupported operation";
00138    case err_status_no_ctx:
00139       return "no appropriate context found";
00140    case err_status_cant_check:
00141       return "unable to perform desired validation";
00142    case err_status_key_expired:
00143       return "can't use key any more";
00144    default:
00145       return "unknown";
00146    }
00147 }

static void srtp_event_cb ( srtp_event_data_t *  data  )  [static]

Definition at line 197 of file res_srtp.c.

References ast_debug.

Referenced by res_srtp_init().

00198 {
00199    switch (data->event) {
00200    case event_ssrc_collision:
00201       ast_debug(1, "SSRC collision\n");
00202       break;
00203    case event_key_soft_limit:
00204       ast_debug(1, "event_key_soft_limit\n");
00205       break;
00206    case event_key_hard_limit:
00207       ast_debug(1, "event_key_hard_limit\n");
00208       break;
00209    case event_packet_index_limit:
00210       ast_debug(1, "event_packet_index_limit\n");
00211       break;
00212    }
00213 }

static int unload_module ( void   )  [static]

Definition at line 588 of file res_srtp.c.

References res_srtp_shutdown().

00589 {
00590    res_srtp_shutdown();
00591    return 0;
00592 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "Secure RTP (SRTP)" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND, } [static]

Definition at line 598 of file res_srtp.c.

Definition at line 598 of file res_srtp.c.

int g_initialized = 0 [static]

Tracks whether or not we've initialized the libsrtp library

Definition at line 68 of file res_srtp.c.

Definition at line 101 of file res_srtp.c.

struct ast_srtp_res srtp_res [static]

Definition at line 89 of file res_srtp.c.


Generated on 27 Jan 2016 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1