Logo Search packages:      
Sourcecode: srtp version File versions  Download package

err_status_t srtp_create ( srtp_t session,
const srtp_policy_t policy 

srtp_create() allocates and initializes an SRTP session.

The function call srtp_create(session, policy, key) allocates and initializes an SRTP session context, applying the given policy and key.

session is the SRTP session to which the policy is to be added.
policy is the srtp_policy_t struct that describes the policy for the session. The struct may be a single element, or it may be the head of a list, in which case each element of the list is processed. It may also be NULL, in which case streams should be added later using srtp_add_stream(). The final element of the list must have its `next' field set to NULL.
  • err_status_ok if creation succeded.
  • err_status_alloc_fail if allocation failed.
  • err_status_init_fail if initialization failed.

Definition at line 1243 of file srtp.c.

References err_status_alloc_fail, err_status_bad_param, err_status_ok, srtp_policy_t::next, srtp_add_stream(), and srtp_dealloc().

                                       { /* SRTP policy (list)     */
  err_status_t stat;
  srtp_ctx_t *ctx;

  /* sanity check arguments */
  if (session == NULL)
    return err_status_bad_param;

  /* allocate srtp context and set ctx_ptr */
  ctx = (srtp_ctx_t *) crypto_alloc(sizeof(srtp_ctx_t));
  if (ctx == NULL)
    return err_status_alloc_fail;
  *session = ctx;

   * loop over elements in the policy list, allocating and
   * initializing a stream for each element
  ctx->stream_template = NULL;
  ctx->stream_list = NULL;
  while (policy != NULL) {    

    stat = srtp_add_stream(ctx, policy);
    if (stat) {
      /* clean up everything */
      return stat;

    /* set policy to next item in list  */
    policy = policy->next;

  return err_status_ok;

Generated by  Doxygen 1.6.0   Back to index