]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: protocol: add the control layer type in the protocol struct
authorWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2020 15:50:45 +0000 (17:50 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2020 20:08:08 +0000 (22:08 +0200)
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.

include/haproxy/protocol-t.h
src/proto_sockpair.c
src/proto_tcp.c
src/proto_udp.c
src/proto_uxst.c

index cacd3fc316a17b42131085810efdb6cda03032c6..f74a2e1a6c72616250c17fd7c3d842bde8e88383 100644 (file)
@@ -82,6 +82,7 @@ struct proto_fam {
 struct protocol {
        char name[PROTO_NAME_LEN];                      /* protocol name, zero-terminated */
        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_type;                                  /* socket type, as passed to socket()     */
        int sock_prot;                                  /* socket protocol, as passed to socket() */
index 6b1d69c7f9a7d67ba422b13e759bad4e35446d71..fc26a80d5ac280e0938d90b46ce43ebf999dc137 100644 (file)
@@ -61,6 +61,7 @@ struct proto_fam proto_fam_sockpair = {
 static struct protocol proto_sockpair = {
        .name = "sockpair",
        .fam = &proto_fam_sockpair,
+       .ctrl_type = SOCK_STREAM,
        .sock_domain = AF_CUST_SOCKPAIR,
        .sock_type = SOCK_STREAM,
        .sock_prot = 0,
index 33d39b3d58d9544bf96b668dcf253b157eaefcd4..09d3e861922370825c2c9dbdfd203d0ff24f6189 100644 (file)
@@ -52,6 +52,7 @@ static void tcpv6_add_listener(struct listener *listener, int port);
 static struct protocol proto_tcpv4 = {
        .name = "tcpv4",
        .fam = &proto_fam_inet4,
+       .ctrl_type = SOCK_STREAM,
        .sock_domain = AF_INET,
        .sock_type = SOCK_STREAM,
        .sock_prot = IPPROTO_TCP,
@@ -71,6 +72,7 @@ INITCALL1(STG_REGISTER, protocol_register, &proto_tcpv4);
 static struct protocol proto_tcpv6 = {
        .name = "tcpv6",
        .fam = &proto_fam_inet6,
+       .ctrl_type = SOCK_STREAM,
        .sock_domain = AF_INET6,
        .sock_type = SOCK_STREAM,
        .sock_prot = IPPROTO_TCP,
index d408d7c26e1ef881dfcdc299ffb65110935e7686..74408b4ec7678f53134303881197c90027114700 100644 (file)
@@ -48,6 +48,7 @@ static void udp6_add_listener(struct listener *listener, int port);
 static struct protocol proto_udp4 = {
        .name = "udp4",
        .fam = &proto_fam_inet4,
+       .ctrl_type = SOCK_DGRAM,
        .sock_domain = AF_CUST_UDP4,
        .sock_type = SOCK_DGRAM,
        .sock_prot = IPPROTO_UDP,
@@ -67,6 +68,7 @@ INITCALL1(STG_REGISTER, protocol_register, &proto_udp4);
 static struct protocol proto_udp6 = {
        .name = "udp6",
        .fam = &proto_fam_inet6,
+       .ctrl_type = SOCK_DGRAM,
        .sock_domain = AF_CUST_UDP6,
        .sock_type = SOCK_DGRAM,
        .sock_prot = IPPROTO_UDP,
index 0dd03f85b6c9cd512b236be10b8e29240dbd537b..6cf35b754627b333449fcd69a6f0409591a0ae16 100644 (file)
@@ -49,6 +49,7 @@ static int uxst_pause_listener(struct listener *l);
 static struct protocol proto_unix = {
        .name = "unix_stream",
        .fam = &proto_fam_unix,
+       .ctrl_type = SOCK_STREAM,
        .sock_domain = PF_UNIX,
        .sock_type = SOCK_STREAM,
        .sock_prot = 0,