Tue Aug 20 16:35:14 2013

Asterisk developer's documentation


res_srtp.c File Reference

Secure RTP (SRTP). More...

#include "asterisk.h"
#include <srtp/srtp.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 594 of file res_srtp.c.

static void __unreg_module ( void   )  [static]

Definition at line 594 of file res_srtp.c.

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

Definition at line 486 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().

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

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

Definition at line 520 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.

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

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

Definition at line 440 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().

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

static void ast_srtp_destroy ( struct ast_srtp srtp  )  [static]

Definition at line 473 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().

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

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

Definition at line 305 of file res_srtp.c.

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

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

Definition at line 235 of file res_srtp.c.

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

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

static void ast_srtp_policy_destroy ( struct ast_srtp_policy policy  )  [static]

Definition at line 246 of file res_srtp.c.

References ao2_t_ref.

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

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 283 of file res_srtp.c.

References ast_calloc, ast_free, and ast_srtp_policy::sp.

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

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

Definition at line 214 of file res_srtp.c.

References ast_srtp_policy::sp.

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

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

Definition at line 278 of file res_srtp.c.

References policy_set_suite(), and ast_srtp_policy::sp.

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

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

Definition at line 418 of file res_srtp.c.

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

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

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

Definition at line 465 of file res_srtp.c.

References ast_srtp_create(), and ast_srtp_destroy().

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

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

Definition at line 310 of file res_srtp.c.

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

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

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

Definition at line 321 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.

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

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

Definition at line 162 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().

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

static int load_module ( void   )  [static]

Definition at line 579 of file res_srtp.c.

References res_srtp_init().

00580 {
00581    return res_srtp_init();
00582 }

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

Definition at line 155 of file res_srtp.c.

References ast_srtp_policy::sp.

Referenced by res_srtp_new().

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

static void policy_destructor ( void *  obj  )  [static]

Definition at line 225 of file res_srtp.c.

References ast_free, and ast_srtp_policy::sp.

Referenced by ast_srtp_policy_alloc().

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

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

Definition at line 148 of file res_srtp.c.

References ast_srtp_policy::sp.

Referenced by res_srtp_new().

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

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

Definition at line 251 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().

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

static int res_srtp_init ( void   )  [static]

Definition at line 552 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().

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

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

Definition at line 174 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().

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

static void res_srtp_shutdown ( void   )  [static]

Definition at line 545 of file res_srtp.c.

References ast_rtp_engine_unregister_srtp().

Referenced by res_srtp_init(), and unload_module().

00546 {
00547    srtp_install_event_handler(NULL);
00548    ast_rtp_engine_unregister_srtp();
00549    g_initialized = 0;
00550 }

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

Definition at line 108 of file res_srtp.c.

Referenced by ast_srtp_protect(), and ast_srtp_unprotect().

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

static void srtp_event_cb ( srtp_event_data_t *  data  )  [static]

Definition at line 196 of file res_srtp.c.

References ast_debug.

Referenced by res_srtp_init().

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

static int unload_module ( void   )  [static]

Definition at line 584 of file res_srtp.c.

References res_srtp_shutdown().

00585 {
00586    res_srtp_shutdown();
00587    return 0;
00588 }


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 594 of file res_srtp.c.

Definition at line 594 of file res_srtp.c.

int g_initialized = 0 [static]

Tracks whether or not we've initialized the libsrtp library

Definition at line 67 of file res_srtp.c.

Definition at line 100 of file res_srtp.c.

struct ast_srtp_res srtp_res [static]

Definition at line 88 of file res_srtp.c.


Generated on 20 Aug 2013 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1