#include <vnet/session/application_interface.h>
#include <vnet/session/application.h>
#include <vnet/session/session.h>
-#include <vnet/tls/tls_types.h>
typedef struct
{
return -1;
}
- cm->alpn_proto_selected = tls_get_alpn_selected (s->connection_index);
+ cm->alpn_proto_selected = transport_get_alpn_selected (
+ session_get_transport_proto (s), s->connection_index, s->thread_index);
a->handle = session_handle (s);
a->app_index = cm->app_index;
#include <vnet/session/application_interface.h>
#include <vnet/session/session.h>
-#include <vnet/tls/tls_types.h>
typedef struct
{
ts->session_state = SESSION_STATE_READY;
- alpn_proto = tls_get_alpn_selected (ts->connection_index);
+ alpn_proto = transport_get_alpn_selected (
+ session_get_transport_proto (ts), ts->connection_index, ts->thread_index);
clib_warning ("ALPN selected: %U", format_tls_alpn_proto, alpn_proto);
return 0;
#include <vnet/session/application.h>
#include <vnet/session/application_interface.h>
#include <vnet/session/session.h>
-#include <vnet/tls/tls_types.h>
#include <http/http.h>
#include <http/http_header_names.h>
#include <http/http_content_types.h>
#include <http/http_content_types.h>
#include <http/http_status_codes.h>
#include <vppinfra/unix.h>
-#include <vnet/tls/tls_types.h>
#define foreach_hc_s_flag \
_ (1, IS_CLOSED) \
#include <vnet/session/session.h>
#include <http/http.h>
#include <http/http_status_codes.h>
-#include <vnet/tls/tls_types.h>
#include <vnet/tcp/tcp.h>
#include <vppinfra/tw_timer_2t_1w_2048sl.h>
#include <hs_apps/proxy.h>
#include <vnet/tcp/tcp.h>
#include <http/http_header_names.h>
-#include <vnet/tls/tls_types.h>
proxy_main_t proxy_main;
#include <vpp/app/version.h>
#include <vnet/session/application_interface.h>
#include <vnet/session/application.h>
-#include <vnet/tls/tls_types.h>
#include <http/http.h>
#include <http/http_private.h>
tp = session_get_transport_proto (ts);
if (tp == TRANSPORT_PROTO_TLS)
{
- alpn_proto = tls_get_alpn_selected (ts->connection_index);
+ alpn_proto = transport_get_alpn_selected (tp, ts->connection_index,
+ ts->thread_index);
HTTP_DBG (1, "ALPN selected: %U", format_tls_alpn_proto, alpn_proto);
switch (alpn_proto)
{
/* TLS set by ALPN result, TCP: prior knowledge (set in ho) */
if (tp == TRANSPORT_PROTO_TLS)
{
- alpn_proto = tls_get_alpn_selected (ts->connection_index);
+ alpn_proto = transport_get_alpn_selected (tp, ts->connection_index,
+ ts->thread_index);
HTTP_DBG (1, "ALPN selected: %U", format_tls_alpn_proto, alpn_proto);
switch (alpn_proto)
{
#include <http_static/http_static.h>
#include <vnet/session/application.h>
-#include <vnet/tls/tls_types.h>
#include <sys/types.h>
#include <sys/stat.h>
tls/tls_inlines.h
tls/tls_record.h
tls/tls_test.h
- tls/tls_types.h
)
u16 port_allocator_max_src_port;
u8 lcl_endpts_cleanup_pending;
clib_spinlock_t local_endpoints_lock;
+ uword *alpn_proto_by_str;
} transport_main_t;
static transport_main_t tp_main;
return tp_vfts[tp].attribute (conn_index, thread_index, is_get, attr);
}
+tls_alpn_proto_t
+transport_get_alpn_selected (transport_proto_t tp, u32 conn_index,
+ clib_thread_index_t thread_index)
+{
+ if (!tp_vfts[tp].get_alpn_selected)
+ return TLS_ALPN_PROTO_NONE;
+
+ return tp_vfts[tp].get_alpn_selected (conn_index, thread_index);
+}
+
#define PORT_MASK ((1 << 16)- 1)
void
}
}
+tls_alpn_proto_t
+tls_alpn_proto_by_str (tls_alpn_proto_id_t *alpn_id)
+{
+ transport_main_t *tm = &tp_main;
+ uword *p;
+
+ p = hash_get_mem (tm->alpn_proto_by_str, alpn_id);
+ if (p)
+ return p[0];
+
+ return TLS_ALPN_PROTO_NONE;
+}
+
+u8 *
+format_tls_alpn_proto (u8 *s, va_list *args)
+{
+ tls_alpn_proto_t alpn_proto = va_arg (*args, int);
+ u8 *t = 0;
+
+ switch (alpn_proto)
+ {
+#define _(sym, str) \
+ case TLS_ALPN_PROTO_##sym: \
+ t = (u8 *) str; \
+ break;
+ foreach_tls_alpn_protos
+#undef _
+ default : return format (s, "BUG: unknown");
+ }
+ return format (s, "%s", t);
+}
+
+static uword
+tls_alpn_proto_hash_key_sum (hash_t *h, uword key)
+{
+ tls_alpn_proto_id_t *id = uword_to_pointer (key, tls_alpn_proto_id_t *);
+ return hash_memory (id->base, id->len, 0);
+}
+
+static uword
+tls_alpn_proto_hash_key_equal (hash_t *h, uword key1, uword key2)
+{
+ tls_alpn_proto_id_t *id1 = uword_to_pointer (key1, tls_alpn_proto_id_t *);
+ tls_alpn_proto_id_t *id2 = uword_to_pointer (key2, tls_alpn_proto_id_t *);
+ return id1 && id2 && tls_alpn_proto_id_eq (id1, id2);
+}
+
void
transport_fifos_init_ooo (transport_connection_t * tc)
{
vlib_thread_main_t *vtm = vlib_get_thread_main ();
session_main_t *smm = vnet_get_session_main ();
transport_main_t *tm = &tp_main;
+ const tls_alpn_proto_id_t *alpn_proto;
u32 num_threads;
if (smm->local_endpoints_table_buckets == 0)
/* Main not polled if there are workers */
smm->transport_cl_thread = 1;
}
+
+ tm->alpn_proto_by_str = hash_create2 (
+ 0, sizeof (tls_alpn_proto_id_t), sizeof (uword),
+ tls_alpn_proto_hash_key_sum, tls_alpn_proto_hash_key_equal, 0, 0);
+
+#define _(sym, str) \
+ alpn_proto = &tls_alpn_proto_ids[TLS_ALPN_PROTO_##sym]; \
+ hash_set_mem (tm->alpn_proto_by_str, alpn_proto, TLS_ALPN_PROTO_##sym);
+ foreach_tls_alpn_protos
+#undef _
}
/*
u8 is_lcl);
int (*attribute) (u32 conn_index, clib_thread_index_t thread_index,
u8 is_get, transport_endpt_attr_t *attr);
+ tls_alpn_proto_t (*get_alpn_selected) (u32 conn_index,
+ clib_thread_index_t thread_index);
/*
* Properties
int transport_connection_attribute (transport_proto_t tp, u32 conn_index,
u8 thread_index, u8 is_get,
transport_endpt_attr_t *attr);
+tls_alpn_proto_t
+transport_get_alpn_selected (transport_proto_t tp, u32 conn_index,
+ clib_thread_index_t thread_index);
static inline transport_connection_t *
transport_get_connection (transport_proto_t tp, u32 conn_index,
#undef _
} __clib_packed tls_alpn_proto_t;
+typedef struct tls_alpn_proto_id_
+{
+ u8 len;
+ u8 *base;
+} tls_alpn_proto_id_t;
+
+static const tls_alpn_proto_id_t tls_alpn_proto_ids[] = {
+#define _(sym, str) { (u8) (sizeof (str) - 1), (u8 *) str },
+ foreach_tls_alpn_protos
+#undef _
+};
+
+static_always_inline u8
+tls_alpn_proto_id_eq (tls_alpn_proto_id_t *actual,
+ tls_alpn_proto_id_t *expected)
+{
+ if (actual->len != expected->len)
+ return 0;
+ return memcmp (actual->base, expected->base, expected->len) == 0 ? 1 : 0;
+}
+
+tls_alpn_proto_t tls_alpn_proto_by_str (tls_alpn_proto_id_t *alpn_id);
+format_function_t format_tls_alpn_proto;
+
typedef struct transport_endpt_crypto_cfg_
{
u32 ckpair_index; /**< index of ck pair in application crypto layer */
void tls_disconnect (u32 ctx_handle, clib_thread_index_t thread_index);
-static const tls_alpn_proto_id_t tls_alpn_proto_ids[] = {
-#define _(sym, str) { (u8) (sizeof (str) - 1), (u8 *) str },
- foreach_tls_alpn_protos
-#undef _
-};
-
void
tls_disconnect_transport (tls_ctx_t * ctx)
{
}
tls_alpn_proto_t
-tls_alpn_proto_by_str (tls_alpn_proto_id_t *alpn_id)
-{
- tls_main_t *tm = &tls_main;
- uword *p;
-
- p = hash_get_mem (tm->alpn_proto_by_str, alpn_id);
- if (p)
- return p[0];
-
- return TLS_ALPN_PROTO_NONE;
-}
-
-tls_alpn_proto_t
-tls_get_alpn_selected (u32 ctx_handle)
+tls_get_alpn_selected (u32 ctx_handle, clib_thread_index_t thread_index)
{
- tls_ctx_t *ctx;
- ctx = tls_ctx_get (ctx_handle);
+ tls_ctx_t *ctx = tls_ctx_get_w_thread (ctx_handle, thread_index);
return ctx->alpn_selected;
}
-u8 *
-format_tls_alpn_proto (u8 *s, va_list *args)
-{
- tls_alpn_proto_t alpn_proto = va_arg (*args, int);
- u8 *t = 0;
-
- switch (alpn_proto)
- {
-#define _(sym, str) \
- case TLS_ALPN_PROTO_##sym: \
- t = (u8 *) str; \
- break;
- foreach_tls_alpn_protos
-#undef _
- default : return format (s, "BUG: unknown");
- }
- return format (s, "%s", t);
-}
-
u32
tls_listener_ctx_alloc (void)
{
.format_listener = format_tls_listener,
.get_transport_endpoint = tls_transport_endpoint_get,
.get_transport_listener_endpoint = tls_transport_listener_endpoint_get,
+ .get_alpn_selected = tls_get_alpn_selected,
.transport_options = {
.name = "tls",
.short_name = "J",
.format_listener = format_tls_listener,
.get_transport_endpoint = tls_transport_endpoint_get,
.get_transport_listener_endpoint = tls_transport_listener_endpoint_get,
+ .get_alpn_selected = tls_get_alpn_selected,
.transport_options = {
.name = "dtls",
.short_name = "D",
tls_vfts[type] = *vft;
}
-static uword
-tls_alpn_proto_hash_key_sum (hash_t *h, uword key)
-{
- tls_alpn_proto_id_t *id = uword_to_pointer (key, tls_alpn_proto_id_t *);
- return hash_memory (id->base, id->len, 0);
-}
-
-static uword
-tls_alpn_proto_hash_key_equal (hash_t *h, uword key1, uword key2)
-{
- tls_alpn_proto_id_t *id1 = uword_to_pointer (key1, tls_alpn_proto_id_t *);
- tls_alpn_proto_id_t *id2 = uword_to_pointer (key2, tls_alpn_proto_id_t *);
- return id1 && id2 && tls_alpn_proto_id_eq (id1, id2);
-}
-
static clib_error_t *
tls_init (vlib_main_t * vm)
{
vlib_thread_main_t *vtm = vlib_get_thread_main ();
tls_main_t *tm = &tls_main;
u32 num_threads;
- const tls_alpn_proto_id_t *alpn_proto;
num_threads = 1 /* main thread */ + vtm->n_threads;
transport_register_protocol (TRANSPORT_PROTO_DTLS, &dtls_proto,
FIB_PROTOCOL_IP6, ~0);
- tm->alpn_proto_by_str = hash_create2 (
- 0, sizeof (tls_alpn_proto_id_t), sizeof (uword),
- tls_alpn_proto_hash_key_sum, tls_alpn_proto_hash_key_equal, 0, 0);
-
-#define _(sym, str) \
- alpn_proto = &tls_alpn_proto_ids[TLS_ALPN_PROTO_##sym]; \
- hash_set_mem (tm->alpn_proto_by_str, alpn_proto, TLS_ALPN_PROTO_##sym);
- foreach_tls_alpn_protos
-#undef _
-
return 0;
}
#include <vnet/session/application_interface.h>
#include <vnet/session/application.h>
#include <vnet/session/session.h>
-#include <vnet/tls/tls_types.h>
#include <vppinfra/lock.h>
#ifndef SRC_VNET_TLS_TLS_H_
u8 **rx_bufs;
u8 **tx_bufs;
- uword *alpn_proto_by_str;
/*
* Config
*/
+++ /dev/null
-/* SPDX-License-Identifier: Apache-2.0
- * Copyright(c) 2025 Cisco Systems, Inc.
- */
-
-#ifndef SRC_VNET_TLS_TLS_TYPES_H_
-#define SRC_VNET_TLS_TLS_TYPES_H_
-
-#include <vppinfra/types.h>
-
-typedef struct tls_alpn_proto_id_
-{
- u8 len;
- u8 *base;
-} tls_alpn_proto_id_t;
-
-static inline u8
-tls_alpn_proto_id_eq (tls_alpn_proto_id_t *actual,
- tls_alpn_proto_id_t *expected)
-{
- if (actual->len != expected->len)
- return 0;
- return memcmp (actual->base, expected->base, expected->len) == 0 ? 1 : 0;
-}
-
-tls_alpn_proto_t tls_alpn_proto_by_str (tls_alpn_proto_id_t *alpn_id);
-
-tls_alpn_proto_t tls_get_alpn_selected (u32 ctx_handle);
-
-format_function_t format_tls_alpn_proto;
-
-#endif /* SRC_VNET_TLS_TLS_TYPES_H_ */