MINOR: protocol: add the control layer type in the protocol struct

This one will be needed to more accurately select a protocol. It may
differ from the socket type for QUIC, which uses dgram at the socket
layer and provides stream at the control layer. The upper level requests
a control layer only so we need this field.
This commit is contained in:
Willy Tarreau 2020-09-16 17:50:45 +02:00
parent 65ec4e3ff7
commit a54553f74f
5 changed files with 7 additions and 0 deletions

View File

@ -82,6 +82,7 @@ struct proto_fam {
struct protocol { struct protocol {
char name[PROTO_NAME_LEN]; /* protocol name, zero-terminated */ char name[PROTO_NAME_LEN]; /* protocol name, zero-terminated */
struct proto_fam *fam; /* protocol family */ struct proto_fam *fam; /* protocol family */
int ctrl_type; /* control layer type (SOCK_STREAM/SOCK_DGRAM) */
int sock_domain; /* socket domain, as passed to socket() */ int sock_domain; /* socket domain, as passed to socket() */
int sock_type; /* socket type, as passed to socket() */ int sock_type; /* socket type, as passed to socket() */
int sock_prot; /* socket protocol, as passed to socket() */ int sock_prot; /* socket protocol, as passed to socket() */

View File

@ -61,6 +61,7 @@ struct proto_fam proto_fam_sockpair = {
static struct protocol proto_sockpair = { static struct protocol proto_sockpair = {
.name = "sockpair", .name = "sockpair",
.fam = &proto_fam_sockpair, .fam = &proto_fam_sockpair,
.ctrl_type = SOCK_STREAM,
.sock_domain = AF_CUST_SOCKPAIR, .sock_domain = AF_CUST_SOCKPAIR,
.sock_type = SOCK_STREAM, .sock_type = SOCK_STREAM,
.sock_prot = 0, .sock_prot = 0,

View File

@ -52,6 +52,7 @@ static void tcpv6_add_listener(struct listener *listener, int port);
static struct protocol proto_tcpv4 = { static struct protocol proto_tcpv4 = {
.name = "tcpv4", .name = "tcpv4",
.fam = &proto_fam_inet4, .fam = &proto_fam_inet4,
.ctrl_type = SOCK_STREAM,
.sock_domain = AF_INET, .sock_domain = AF_INET,
.sock_type = SOCK_STREAM, .sock_type = SOCK_STREAM,
.sock_prot = IPPROTO_TCP, .sock_prot = IPPROTO_TCP,
@ -71,6 +72,7 @@ INITCALL1(STG_REGISTER, protocol_register, &proto_tcpv4);
static struct protocol proto_tcpv6 = { static struct protocol proto_tcpv6 = {
.name = "tcpv6", .name = "tcpv6",
.fam = &proto_fam_inet6, .fam = &proto_fam_inet6,
.ctrl_type = SOCK_STREAM,
.sock_domain = AF_INET6, .sock_domain = AF_INET6,
.sock_type = SOCK_STREAM, .sock_type = SOCK_STREAM,
.sock_prot = IPPROTO_TCP, .sock_prot = IPPROTO_TCP,

View File

@ -48,6 +48,7 @@ static void udp6_add_listener(struct listener *listener, int port);
static struct protocol proto_udp4 = { static struct protocol proto_udp4 = {
.name = "udp4", .name = "udp4",
.fam = &proto_fam_inet4, .fam = &proto_fam_inet4,
.ctrl_type = SOCK_DGRAM,
.sock_domain = AF_CUST_UDP4, .sock_domain = AF_CUST_UDP4,
.sock_type = SOCK_DGRAM, .sock_type = SOCK_DGRAM,
.sock_prot = IPPROTO_UDP, .sock_prot = IPPROTO_UDP,
@ -67,6 +68,7 @@ INITCALL1(STG_REGISTER, protocol_register, &proto_udp4);
static struct protocol proto_udp6 = { static struct protocol proto_udp6 = {
.name = "udp6", .name = "udp6",
.fam = &proto_fam_inet6, .fam = &proto_fam_inet6,
.ctrl_type = SOCK_DGRAM,
.sock_domain = AF_CUST_UDP6, .sock_domain = AF_CUST_UDP6,
.sock_type = SOCK_DGRAM, .sock_type = SOCK_DGRAM,
.sock_prot = IPPROTO_UDP, .sock_prot = IPPROTO_UDP,

View File

@ -49,6 +49,7 @@ static int uxst_pause_listener(struct listener *l);
static struct protocol proto_unix = { static struct protocol proto_unix = {
.name = "unix_stream", .name = "unix_stream",
.fam = &proto_fam_unix, .fam = &proto_fam_unix,
.ctrl_type = SOCK_STREAM,
.sock_domain = PF_UNIX, .sock_domain = PF_UNIX,
.sock_type = SOCK_STREAM, .sock_type = SOCK_STREAM,
.sock_prot = 0, .sock_prot = 0,