u32 transport_proto = va_arg (*args, u32);
switch (transport_proto)
{
- case TRANSPORT_PROTO_TCP:
- s = format (s, "TCP");
+#define _(sym, str, sstr) \
+ case TRANSPORT_PROTO_ ## sym: \
+ s = format (s, str); \
break;
- case TRANSPORT_PROTO_UDP:
- s = format (s, "UDP");
- break;
- case TRANSPORT_PROTO_SCTP:
- s = format (s, "SCTP");
- break;
- case TRANSPORT_PROTO_UDPC:
- s = format (s, "UDPC");
- break;
- case TRANSPORT_PROTO_QUIC:
- s = format (s, "QUIC");
+ foreach_transport_proto
+#undef _
+ default:
+ s = format (s, "UNKNOWN");
break;
}
return s;
u32 transport_proto = va_arg (*args, u32);
switch (transport_proto)
{
- case TRANSPORT_PROTO_TCP:
- s = format (s, "T");
- break;
- case TRANSPORT_PROTO_UDP:
- s = format (s, "U");
- break;
- case TRANSPORT_PROTO_SCTP:
- s = format (s, "S");
- break;
- case TRANSPORT_PROTO_UDPC:
- s = format (s, "U");
+#define _(sym, str, sstr) \
+ case TRANSPORT_PROTO_ ## sym: \
+ s = format (s, sstr); \
break;
- case TRANSPORT_PROTO_QUIC:
- s = format (s, "Q");
+ foreach_transport_proto
+#undef _
+ default:
+ s = format (s, "?");
break;
}
return s;
unformat_transport_proto (unformat_input_t * input, va_list * args)
{
u32 *proto = va_arg (*args, u32 *);
- if (unformat (input, "tcp"))
- *proto = TRANSPORT_PROTO_TCP;
- else if (unformat (input, "TCP"))
- *proto = TRANSPORT_PROTO_TCP;
- else if (unformat (input, "udpc"))
- *proto = TRANSPORT_PROTO_UDPC;
- else if (unformat (input, "UDPC"))
- *proto = TRANSPORT_PROTO_UDPC;
- else if (unformat (input, "udp"))
- *proto = TRANSPORT_PROTO_UDP;
- else if (unformat (input, "UDP"))
- *proto = TRANSPORT_PROTO_UDP;
- else if (unformat (input, "sctp"))
- *proto = TRANSPORT_PROTO_SCTP;
- else if (unformat (input, "SCTP"))
- *proto = TRANSPORT_PROTO_SCTP;
- else if (unformat (input, "tls"))
- *proto = TRANSPORT_PROTO_TLS;
- else if (unformat (input, "TLS"))
- *proto = TRANSPORT_PROTO_TLS;
- else if (unformat (input, "quic"))
- *proto = TRANSPORT_PROTO_QUIC;
- else if (unformat (input, "QUIC"))
- *proto = TRANSPORT_PROTO_QUIC;
- else
+
+#define _(sym, str, sstr) \
+ if (unformat (input, str)) \
+ { \
+ *proto = TRANSPORT_PROTO_ ## sym; \
+ return 1; \
+ }
+ foreach_transport_proto
+#undef _
return 0;
- return 1;
}
u32
return &tp_vfts[transport_proto];
}
+u8
+transport_half_open_has_fifos (transport_proto_t tp)
+{
+ return tp_vfts[tp].transport_options.half_open_has_fifos;
+}
+
transport_service_type_t
transport_protocol_service_type (transport_proto_t tp)
{
- return tp_vfts[tp].service_type;
+ return tp_vfts[tp].transport_options.service_type;
}
transport_tx_fn_type_t
transport_protocol_tx_fn_type (transport_proto_t tp)
{
- return tp_vfts[tp].tx_type;
+ return tp_vfts[tp].transport_options.tx_type;
}
void
tp_vfts[tp].close (conn_index, thread_index);
}
+void
+transport_reset (transport_proto_t tp, u32 conn_index, u8 thread_index)
+{
+ if (tp_vfts[tp].reset)
+ tp_vfts[tp].reset (conn_index, thread_index);
+ else
+ tp_vfts[tp].close (conn_index, thread_index);
+}
+
u32
transport_start_listen (transport_proto_t tp, u32 session_index,
transport_endpoint_t * tep)
u8
transport_protocol_is_cl (transport_proto_t tp)
{
- return (tp_vfts[tp].service_type == TRANSPORT_SERVICE_CL);
+ return (tp_vfts[tp].transport_options.service_type == TRANSPORT_SERVICE_CL);
}
always_inline void
{
spacer_t *pacer = va_arg (*args, spacer_t *);
- s = format (s, "bucket %u max_burst %u tokens/period %.3f last_update %x",
- pacer->bucket, pacer->max_burst_size, pacer->tokens_per_period,
- pacer->last_update);
+ s = format (s, "bucket %u tokens/period %.3f last_update %x",
+ pacer->bucket, pacer->tokens_per_period, pacer->last_update);
return s;
}
pacer->tokens_per_period = rate_bytes_per_sec / transport_pacer_period;
}
+static inline u64
+spacer_pace_rate (spacer_t * pacer)
+{
+ return pacer->tokens_per_period * transport_pacer_period;
+}
+
void
transport_connection_tx_pacer_reset (transport_connection_t * tc,
u32 rate_bytes_per_sec,
return snd_space;
}
+u64
+transport_connection_tx_pacer_rate (transport_connection_t * tc)
+{
+ return spacer_pace_rate (&tc->pacer);
+}
+
void
-transport_connection_update_tx_stats (transport_connection_t * tc, u32 bytes)
+transport_connection_update_tx_bytes (transport_connection_t * tc, u32 bytes)
{
- tc->stats.tx_bytes += bytes;
if (transport_connection_is_tx_paced (tc))
spacer_update_bucket (&tc->pacer, bytes);
}