|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
33 return ctx->srtp_ctx_handle;
49 for (
i = 0;
i < 2;
i++)
51 sp = &
ctx->srtp_policy[
i];
54 srtp_crypto_policy_set_rtp_default (&sp->rtp);
55 srtp_crypto_policy_set_rtcp_default (&sp->rtcp);
61 sp->next =
i < 1 ? &
ctx->srtp_policy[
i + 1] : 0;
77 if (!
ctx->is_migrated)
144 if (srtp_create (&
ctx->srtp_ctx, &
ctx->srtp_policy[0]) != srtp_err_status_ok)
146 SRTP_DBG (0,
"failed to init srtp ctx");
162 ctx->parent_app_api_context))
164 SRTP_DBG (0,
"failed to notify app");
177 ctx->no_app_session = 1;
180 ctx->parent_app_api_context);
191 if (srtp_create (&
ctx->srtp_ctx,
ctx->srtp_policy) != srtp_err_status_ok)
206 SRTP_DBG (1,
"failed to allocate fifos");
219 if (srtp_dealloc (
ctx->srtp_ctx))
220 SRTP_DBG (0,
"%u failed to cleanup srtp state",
ctx->c_c_index);
228 u32 n_wrote = 0, to_deq, dgram_sz;
259 hdr.data_length,
buf);
266 if (
rv != srtp_err_status_ok)
347 if (
rv != srtp_err_status_ok)
437 ctx->srtp_ctx_handle = ctx_handle;
441 ctx->listener_ctx_index = srtp_listener->
opaque;
455 SRTP_DBG (1,
"Accept on listener %u new connection [%u]%x",
496 if (!
ctx->no_app_session)
520 old_thread_index =
ctx->c_thread_index;
521 old_ctx_index =
ctx->c_c_index;
527 ctx->srtp_ctx_handle = ctx_handle;
528 SRTP_DBG (1,
"migrated ctx handle %u", ctx_handle);
532 us->
flags &= ~SESSION_F_IS_MIGRATING;
553 ctx->srtp_session_handle = new_sh;
555 SRTP_DBG (1,
"ctx %u attached to udp %x session migrating",
556 cloned_ctx->c_c_index, new_sh);
559 (
void *) cloned_ctx);
563 ctx->is_migrated = 1;
582 u32 add_segment_size = 256 << 20, first_seg_size = 32 << 20;
587 u32 fifo_size = 128 << 12;
641 return SESSION_E_NOEXTCFG;
648 ctx->parent_app_wrk_index = sep->app_wrk_index;
649 ctx->parent_app_api_context = sep->opaque;
650 ctx->udp_is_ip4 = sep->is_ip4;
651 ctx->srtp_ctx_handle = ctx_index;
656 cargs->sep.transport_proto = TRANSPORT_PROTO_UDP;
659 cargs->api_context = ctx_index;
660 cargs->sep_ext.ns_index = app->
ns_index;
664 SRTP_DBG (1,
"New connect request %u", ctx_index);
672 .handle =
ctx->srtp_session_handle,
677 SRTP_DBG (0,
"disconnect returned");
686 SRTP_DBG (1,
"App disconnecting %x", ctx_handle);
721 return SESSION_E_NOEXTCFG;
728 args->sep_ext = *sep;
729 args->sep_ext.ns_index = app->
ns_index;
730 args->sep_ext.transport_proto = TRANSPORT_PROTO_UDP;
736 udp_al_handle = args->handle;
739 srtp_listener->
opaque = lctx_index;
744 lctx->parent_app_wrk_index = sep->app_wrk_index;
745 lctx->srtp_session_handle = udp_al_handle;
747 lctx->udp_is_ip4 = sep->is_ip4;
751 SRTP_DBG (1,
"Started listening %d", lctx_index);
770 sep.fib_index = lc->fib_index;
771 sep.port = lc->lcl_port;
772 sep.is_ip4 = lc->is_ip4;
773 sep.transport_proto = TRANSPORT_PROTO_SRTP;
774 clib_memcpy (&sep.ip, &lc->lcl_ip, sizeof (lc->lcl_ip));
778 .handle = lctx->srtp_session_handle,
794 return &
ctx->connection;
802 return &
ctx->connection;
812 SESSION_STATE_TRANSPORT_CLOSED))
831 s =
format (s,
"[%d:%d][SRTP] app_wrk %u index %u udp %d:%d",
832 ctx->c_thread_index,
ctx->c_s_index,
ctx->parent_app_wrk_index,
833 ctx->srtp_ctx_handle, udp_ti, udp_si);
849 s =
format (s,
"[%d:%d][SRTP] app_wrk %u udp %d:%d",
ctx->c_thread_index,
850 ctx->c_s_index,
ctx->parent_app_wrk_index,
865 s =
format (s,
"%s",
"LISTEN");
869 s =
format (s,
"%s",
"CLOSED");
871 s =
format (s,
"%s",
"APP-CLOSED");
872 else if (us->
session_state >= SESSION_STATE_TRANSPORT_CLOSING)
873 s =
format (s,
"%s",
"CLOSING");
875 s =
format (s,
"%s",
"ESTABLISHED");
884 u32 ctx_index = va_arg (*args,
u32);
886 u32 verbose = va_arg (*args,
u32);
907 u32 tc_index = va_arg (*args,
u32);
909 u32 verbose = va_arg (*args,
u32);
962 .transport_options = {
983 .version = VPP_BUILD_VER,
984 .description =
"Secure Real-time Transport Protocol (SRTP)",
985 .default_disabled = 1,
int vnet_listen(vnet_listen_args_t *a)
u8 * format_srtp_ctx(u8 *s, va_list *args)
#define SESSION_CLI_STATE_LEN
static u8 svm_fifo_set_event(svm_fifo_t *f)
Set fifo event flag.
u8 * format_srtp_half_open(u8 *s, va_list *args)
static u32 vlib_num_workers()
enum session_error_ session_error_t
void srtp_listener_ctx_free(srtp_tc_t *ctx)
int vnet_connect(vnet_connect_args_t *a)
transport_endpt_cfg_srtp_policy_t policies[2]
description security check failed
int session_dequeue_notify(session_t *s)
static void srtp_init_policy(srtp_tc_t *ctx, transport_endpt_cfg_srtp_t *cfg)
static clib_error_t * srtp_transport_init(vlib_main_t *vm)
int srtp_add_segment_callback(u32 client_index, u64 segment_handle)
@ APP_OPTIONS_RX_FIFO_SIZE
u32 session_index
Index in thread pool where session was allocated.
static void srtp_migrate_ctx(void *arg)
static void srtp_disconnect_transport(srtp_tc_t *ctx)
#define clib_memcpy(d, s, n)
#define SESSION_CLI_ID_LEN
void session_close(session_t *s)
Initialize session closing procedure.
static int srtp_ctx_deinit(srtp_tc_t *ctx)
static void session_parse_handle(session_handle_t handle, u32 *index, u32 *thread_index)
static clib_error_t * srtp_enable(vlib_main_t *vm, u8 is_en)
static uword pointer_to_uword(const void *p)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
void session_get_endpoint(session_t *s, transport_endpoint_t *tep, u8 is_lcl)
int vnet_unlisten(vnet_unlisten_args_t *a)
static u64 listen_session_get_handle(session_t *s)
int svm_fifo_peek(svm_fifo_t *f, u32 offset, u32 len, u8 *dst)
Peek data from fifo.
static void clib_mem_free(void *p)
static u8 svm_fifo_needs_deq_ntf(svm_fifo_t *f, u32 n_last_deq)
Check if fifo needs dequeue notification.
int svm_fifo_fill_chunk_list(svm_fifo_t *f)
Ensure the whole fifo size is writeable.
#define clib_error_return(e, args...)
struct _session_endpoint_cfg session_endpoint_cfg_t
int srtp_app_tx_callback(session_t *us)
struct _transport_proto_vft transport_proto_vft_t
static session_t * listen_session_get(u32 ls_index)
#define APP_INVALID_INDEX
int vnet_application_detach(vnet_app_detach_args_t *a)
Detach application from vpp.
static void srtp_transport_endpoint_get(u32 ctx_handle, u32 thread_index, transport_endpoint_t *tep, u8 is_lcl)
u8 thread_index
Index of the thread that allocated the session.
#define pool_put(P, E)
Free an object E in pool P.
session_type_t session_type
Type built from transport and network protocol types.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static int app_recv_dgram_raw(svm_fifo_t *f, u8 *buf, u32 len, app_session_transport_t *at, u8 clear_evt, u8 peek)
#define SRTP_MAX_KEYLEN
libsrtp AES 256 key len with salt
void transport_connection_reschedule(transport_connection_t *tc)
static void srtp_app_session_cleanup(session_t *s, session_cleanup_ntf_t ntf)
srtp_policy_t srtp_policy[2]
void session_transport_closed_notify(transport_connection_t *tc)
Notification from transport that it is closed.
struct _vnet_unlisten_args_t vnet_unlisten_args_t
@ APP_OPTIONS_SEGMENT_SIZE
static u32 session_thread_from_handle(session_handle_t handle)
struct _vnet_app_detach_args_t vnet_app_detach_args_t
struct _transport_connection transport_connection_t
u32 srtp_listener_ctx_alloc(void)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
void session_free(session_t *s)
static int srtp_ctx_read(srtp_tc_t *ctx, session_t *us)
#define SESSION_CONN_HDR_LEN
int(* session_accept_callback)(session_t *new_session)
Notify server of newly accepted session.
int srtp_app_rx_callback(session_t *us)
@ SESSION_CLEANUP_TRANSPORT
application_t * application_get(u32 app_index)
int srtp_session_accept_callback(session_t *us)
u32 app_wrk_index
Index of the app worker that owns the session.
int app_worker_init_connected(app_worker_t *app_wrk, session_t *s)
@ TRANSPORT_SND_F_DESCHED
static void srtp_session_migrate_callback(session_t *us, session_handle_t new_sh)
@ SVM_FIFO_WANT_DEQ_NOTIF
Notify on dequeue.
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
@ SESSION_IO_EVT_BUILTIN_RX
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define TRANSPORT_PACER_MIN_MSS
int srtp_add_vpp_q_builtin_rx_evt(session_t *s)
struct _vnet_disconnect_args_t vnet_disconnect_args_t
static u32 srtp_start_listen(u32 app_listener_index, transport_endpoint_t *tep)
transport_connection_t * session_get_transport(session_t *s)
static svm_msg_q_t * session_main_get_vpp_event_queue(u32 thread_index)
static_always_inline uword vlib_get_thread_index(void)
app_worker_t * app_worker_get_if_valid(u32 wrk_index)
struct _vnet_bind_args_t vnet_listen_args_t
static int srtp_ctx_init_server(srtp_tc_t *ctx)
void srtp_session_reset_callback(session_t *us)
int svm_fifo_enqueue_segments(svm_fifo_t *f, const svm_fifo_seg_t segs[], u32 n_segs, u8 allow_partial)
Enqueue array of svm_fifo_seg_t in order.
int srtp_custom_tx_callback(void *session, transport_send_params_t *sp)
@ TRANSPORT_SERVICE_APP
app transport service
void session_send_rpc_evt_to_thread(u32 thread_index, void *fp, void *rpc_args)
sll srl srl sll sra u16x4 i
int svm_fifo_dequeue_drop(svm_fifo_t *f, u32 len)
Dequeue and drop bytes from fifo.
#define SRTP_DBG(_lvl, _fmt, _args...)
static session_handle_t session_handle(session_t *s)
@ TRANSPORT_CFG_F_CONNECTED
static int srtp_session_connected_callback(u32 srtp_app_index, u32 ctx_handle, session_t *us, session_error_t err)
u32 ns_index
Namespace the application belongs to.
void transport_register_protocol(transport_proto_t transport_proto, const transport_proto_vft_t *vft, fib_protocol_t fib_proto, u32 output_node)
Register transport virtual function table.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static session_t * session_get_from_handle(session_handle_t handle)
void srtp_session_disconnect_callback(session_t *us)
static void srtp_ctx_free_policy(srtp_tc_t *ctx)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
int app_worker_init_accepted(session_t *s)
static srtp_main_t srtp_main
static int app_send_dgram_raw(svm_fifo_t *f, app_session_transport_t *at, svm_msg_q_t *vpp_evt_q, u8 *data, u32 len, u8 evt_type, u8 do_evt, u8 noblock)
static session_t * session_get(u32 si, u32 thread_index)
int vnet_disconnect_session(vnet_disconnect_args_t *a)
void session_transport_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
int app_worker_connect_notify(app_worker_t *app_wrk, session_t *s, session_error_t err, u32 opaque)
@ TRANSPORT_TX_INTERNAL
apps acting as transports
session_handle_t listener_handle
Parent listener session index if the result of an accept.
static u32 srtp_ctx_alloc_w_thread(u32 thread_index)
app_listener_t * app_listener_get_w_handle(session_handle_t handle)
Get app listener for listener session handle.
static session_type_t session_type_from_proto_and_ip(transport_proto_t proto, u8 is_ip4)
static void srtp_migrate_ctx_reply(void *arg)
int vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
int srtp_del_segment_callback(u32 client_index, u64 segment_handle)
static u32 srtp_ctx_attach(u32 thread_index, void *ctx_ptr)
u32 srtp_stop_listen(u32 lctx_index)
#define vec_free(V)
Free vector's memory (no header).
@ APP_OPTIONS_TX_FIFO_SIZE
#define SESSION_ENDPOINT_NULL
@ TRANSPORT_CONNECTION_F_NO_LOOKUP
Don't register connection in lookup.
static u32 svm_fifo_max_enqueue_prod(svm_fifo_t *f)
Maximum number of bytes that can be enqueued into fifo.
@ APP_OPTIONS_ADD_SEGMENT_SIZE
static srtp_tc_t * srtp_ctx_get_w_thread(u32 ctx_index, u32 thread_index)
description fragment has unexpected format
static session_cb_vft_t srtp_app_cb_vft
u32 opaque
Opaque, for general use.
#define VLIB_INIT_FUNCTION(x)
static struct option options[]
int app_worker_lock_and_send_event(app_worker_t *app, session_t *s, u8 evt_type)
Send event to application.
app_worker_t * app_worker_get(u32 wrk_index)
static u8 * format_srtp_ctx_state(u8 *s, va_list *args)
u8 * format_srtp_listener(u8 *s, va_list *args)
struct _session_endpoint session_endpoint_t
struct _vnet_connect_args vnet_connect_args_t
void srtp_notify_app_enqueue(srtp_tc_t *ctx, session_t *app_session)
#define SESSION_INVALID_HANDLE
static int srtp_ctx_write(srtp_tc_t *ctx, session_t *app_session, transport_send_params_t *sp)
static void srtp_transport_listener_endpoint_get(u32 ctx_handle, transport_endpoint_t *tep, u8 is_lcl)
void srtp_ctx_free(srtp_tc_t *ctx)
transport_connection_t * srtp_listener_get(u32 listener_index)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
#define uword_to_pointer(u, type)
int session_lookup_del_session_endpoint2(session_endpoint_t *sep)
static void * srtp_ctx_detach(srtp_tc_t *ctx)
static int srtp_ctx_init_client(srtp_tc_t *ctx)
transport_snd_flags_t flags
#define clib_warning(format, args...)
int session_dgram_connect_notify(transport_connection_t *tc, u32 old_thread_index, session_t **new_session)
Move dgram session to the right thread.
transport_connection_t * srtp_connection_get(u32 ctx_index, u32 thread_index)
static const transport_proto_vft_t srtp_proto
struct _vnet_app_attach_args_t vnet_app_attach_args_t
u32 app_index
Index of owning app.
srtp_tc_t * listener_ctx_pool
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
u32 srtp_listener_ctx_index(srtp_tc_t *ctx)
static void svm_fifo_add_want_deq_ntf(svm_fifo_t *f, u8 ntf_type)
Set specific want notification flag.
int app_worker_accept_notify(app_worker_t *app_wrk, session_t *s)
session_t * app_listener_get_session(app_listener_t *al)
session_t * session_alloc(u32 thread_index)
int session_send_io_evt_to_thread(svm_fifo_t *f, session_evt_type_t evt_type)
volatile u8 session_state
State in session layer state machine.
int srtp_connect(transport_endpoint_cfg_t *tep)
u32 connection_index
Index of the transport connection associated to the session.
static void * clib_mem_alloc(uword size)
u8 * format_srtp_connection(u8 *s, va_list *args)
static session_t * listen_session_get_from_handle(session_handle_t handle)
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
Fifo max bytes to dequeue.
static u8 * format_srtp_listener_ctx(u8 *s, va_list *args)
static void srtp_disconnect(u32 ctx_handle, u32 thread_index)
srtp_tc_t * srtp_listener_ctx_get(u32 ctx_index)
static void transport_connection_deschedule(transport_connection_t *tc)