Skip to content

Commit

Permalink
remove old stream list
Browse files Browse the repository at this point in the history
  • Loading branch information
jmillan committed Jan 11, 2024
1 parent eba0436 commit c5d7540
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 127 deletions.
19 changes: 0 additions & 19 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,6 @@ ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_debug_logging
enable_stream_index
enable_openssl
enable_nss
with_openssl_dir
Expand Down Expand Up @@ -5327,24 +5326,6 @@ fi
$as_echo "$enable_debug_logging" >&6; }


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable stream index" >&5
$as_echo_n "checking whether to enable stream index... " >&6; }
# Check whether --enable-stream-index was given.
if test "${enable-stream-index+set}" = set; then :
enableval=$enable_stream_index;
else
enable_stream_index=no
fi

if test "$enable_stream_index" = "yes"; then

$as_echo "#define ENABLE_STREAM_INDEX 1" >>confdefs.h

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_stream_index" >&5
$as_echo "$enable_stream_index" >&6; }





Expand Down
8 changes: 0 additions & 8 deletions include/srtp_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,6 @@ typedef struct srtp_stream_ctx_t_ {
int *enc_xtn_hdr;
int enc_xtn_hdr_count;
uint32_t pending_roc;
/*
The next and prev pointers are here to allow for a stream list to be
implemented as an intrusive doubly-linked list (the former being the
default). Other stream list implementations can ignore these fields or use
them for some other purpose specific to the stream list implementation.
*/
struct srtp_stream_ctx_t_ *next;
struct srtp_stream_ctx_t_ *prev;
} strp_stream_ctx_t_;

/*
Expand Down
3 changes: 1 addition & 2 deletions include/stream_list_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ extern "C" {
* the API was extracted to allow downstreams to override its
* implementation by defining the `SRTP_NO_STREAM_LIST` preprocessor
* directive, which removes the default implementation of these
* functions. if this is done, the `next` & `prev` fields are free for
* the implementation to use.
* functions.
*
* this is still an internal interface; there is no stability
* guarantee--downstreams should watch this file for changes in
Expand Down
4 changes: 0 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ if get_option('debug-logging')
cdata.set('ENABLE_DEBUG_LOGGING', true)
endif

if get_option('stream-index')
cdata.set('ENABLE_STREAM_INDEX', true)
endif

use_openssl = false
use_nss = false
use_mbedtls = false
Expand Down
2 changes: 0 additions & 2 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ option('crypto-library', type: 'combo', choices : ['none', 'openssl', 'nss', 'mb
description : 'What external crypto library to leverage, if any (OpenSSL, NSS, or mbedtls)')
option('crypto-library-kdf', type : 'feature', value : 'auto',
description : 'Use the external crypto library for Key Derivation Function support')
option('stream-index', type : 'boolean', value : 'false',
description : 'Enable stream index for fast stream retrieval')
option('fuzzer', type : 'feature', value : 'disabled',
description : 'Build libsrtp2 fuzzer (requires build with clang)')
option('tests', type : 'feature', value : 'auto', yield : true,
Expand Down
92 changes: 0 additions & 92 deletions srtp/srtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,6 @@ static srtp_err_status_t srtp_stream_clone(
str->enc_xtn_hdr = stream_template->enc_xtn_hdr;
str->enc_xtn_hdr_count = stream_template->enc_xtn_hdr_count;

/* defensive coding */
str->next = NULL;
str->prev = NULL;
return srtp_err_status_ok;
}

Expand Down Expand Up @@ -4841,94 +4838,6 @@ srtp_err_status_t srtp_get_stream_roc(srtp_t session,

#ifndef SRTP_NO_STREAM_LIST

#ifndef ENABLE_STREAM_INDEX
/* in the default implementation, we have an intrusive doubly-linked list */
typedef struct srtp_stream_list_ctx_t_ {
/* a stub stream that just holds pointers to the beginning and end of the
* list */
srtp_stream_ctx_t data;
} srtp_stream_list_ctx_t_;

srtp_err_status_t srtp_stream_list_alloc(srtp_stream_list_t *list_ptr)
{
srtp_stream_list_t list =
srtp_crypto_alloc(sizeof(srtp_stream_list_ctx_t_));
if (list == NULL) {
return srtp_err_status_alloc_fail;
}

list->data.next = NULL;
list->data.prev = NULL;

*list_ptr = list;
return srtp_err_status_ok;
}

srtp_err_status_t srtp_stream_list_dealloc(srtp_stream_list_t list)
{
/* list must be empty */
if (list->data.next) {
return srtp_err_status_fail;
}
srtp_crypto_free(list);
return srtp_err_status_ok;
}

srtp_err_status_t srtp_stream_list_insert(srtp_stream_list_t list,
srtp_stream_t stream)
{
/* insert at the head of the list */
stream->next = list->data.next;
if (stream->next != NULL) {
stream->next->prev = stream;
}
list->data.next = stream;
stream->prev = &(list->data);

return srtp_err_status_ok;
}

srtp_stream_t srtp_stream_list_get(srtp_stream_list_t list, uint32_t ssrc)
{
/* walk down list until ssrc is found */
srtp_stream_t stream = list->data.next;
while (stream != NULL) {
if (stream->ssrc == ssrc) {
return stream;
}
stream = stream->next;
}

/* we haven't found our ssrc, so return a null */
return NULL;
}

void srtp_stream_list_remove(srtp_stream_list_t list,
srtp_stream_t stream_to_remove)
{
(void)list;

stream_to_remove->prev->next = stream_to_remove->next;
if (stream_to_remove->next != NULL) {
stream_to_remove->next->prev = stream_to_remove->prev;
}
}

void srtp_stream_list_for_each(srtp_stream_list_t list,
int (*callback)(srtp_stream_t, void *),
void *data)
{
srtp_stream_t stream = list->data.next;
while (stream != NULL) {
srtp_stream_t tmp = stream;
stream = stream->next;
if (callback(tmp, data))
break;
}
}

#else

#define INITIAL_STREAM_INDEX_SIZE 2

typedef struct list_entry {
Expand Down Expand Up @@ -5084,4 +4993,3 @@ void srtp_stream_list_for_each(srtp_stream_list_t list,
}

#endif
#endif

0 comments on commit c5d7540

Please sign in to comment.