CLEANUP: protocol: group protocol struct members by usage
For the sake of an improved readability, let's group the protocol
field members according to where they're supposed to be defined:
- connection layer (note: for now even UDP needs one)
- binding layer
- address family
- socket layer
Nothing else was changed.
diff --git a/include/haproxy/protocol-t.h b/include/haproxy/protocol-t.h
index 0119cf2..137a09a 100644
--- a/include/haproxy/protocol-t.h
+++ b/include/haproxy/protocol-t.h
@@ -95,20 +95,20 @@
int (*suspend)(struct listener *l); /* try to suspend the listener */
int (*resume)(struct listener *l); /* try to resume a suspended listener */
struct connection *(*accept_conn)(struct listener *l, int *status); /* accept a new connection */
+ /* functions acting on connections */
+ int (*connect)(struct connection *, int flags); /* connect function if any, see below for flags values */
/* functions acting on the receiver */
+ int (*rx_suspend)(struct receiver *rx); /* temporarily suspend this receiver for a soft restart */
+ int (*rx_resume)(struct receiver *rx); /* try to resume a temporarily suspended receiver */
void (*rx_enable)(struct receiver *rx); /* enable receiving on the receiver */
void (*rx_disable)(struct receiver *rx); /* disable receiving on the receiver */
void (*rx_unbind)(struct receiver *rx); /* unbind the receiver, most often closing the FD */
- int (*rx_suspend)(struct receiver *rx); /* temporarily suspend this receiver for a soft restart */
- int (*rx_resume)(struct receiver *rx); /* try to resume a temporarily suspended receiver */
int (*rx_listening)(const struct receiver *rx); /* is the receiver listening ? 0=no, >0=OK, <0=unrecoverable */
/* default I/O handler */
void (*default_iocb)(int fd); /* generic I/O handler (typically accept callback) */
- /* functions acting on connections */
- int (*connect)(struct connection *, int flags); /* connect function if any, see below for flags values */
struct list receivers; /* list of receivers using this protocol (under proto_lock) */
int nb_receivers; /* number of receivers (under proto_lock) */
diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c
index 9d2fb11..d3a6b98 100644
--- a/src/proto_sockpair.c
+++ b/src/proto_sockpair.c
@@ -64,25 +64,34 @@
/* Note: must not be declared <const> as its list will be overwritten */
struct protocol proto_sockpair = {
- .name = "sockpair",
- .fam = &proto_fam_sockpair,
- .ctrl_type = SOCK_STREAM,
- .sock_type = SOCK_STREAM,
- .sock_prot = 0,
- .add = default_add_listener,
- .listen = sockpair_bind_listener,
- .enable = sockpair_enable_listener,
- .disable = sockpair_disable_listener,
- .unbind = default_unbind_listener,
- .accept_conn = sockpair_accept_conn,
- .rx_unbind = sock_unbind,
- .rx_enable = sock_enable,
- .rx_disable = sock_disable,
- .rx_listening = sockpair_accepting_conn,
- .default_iocb = &sock_accept_iocb,
- .connect = &sockpair_connect_server,
- .receivers = LIST_HEAD_INIT(proto_sockpair.receivers),
- .nb_receivers = 0,
+ .name = "sockpair",
+
+ /* connection layer */
+ .ctrl_type = SOCK_STREAM,
+ .listen = sockpair_bind_listener,
+ .enable = sockpair_enable_listener,
+ .disable = sockpair_disable_listener,
+ .add = default_add_listener,
+ .unbind = default_unbind_listener,
+ .accept_conn = sockpair_accept_conn,
+ .connect = sockpair_connect_server,
+
+ /* binding layer */
+ /* Note: suspend/resume not supported */
+
+ /* address family */
+ .fam = &proto_fam_sockpair,
+
+ /* socket layer */
+ .sock_type = SOCK_STREAM,
+ .sock_prot = 0,
+ .rx_enable = sock_enable,
+ .rx_disable = sock_disable,
+ .rx_unbind = sock_unbind,
+ .rx_listening = sockpair_accepting_conn,
+ .default_iocb = sock_accept_iocb,
+ .receivers = LIST_HEAD_INIT(proto_sockpair.receivers),
+ .nb_receivers = 0,
};
INITCALL1(STG_REGISTER, protocol_register, &proto_sockpair);
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index b3f648e..19651c0 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -52,58 +52,74 @@
/* Note: must not be declared <const> as its list will be overwritten */
struct protocol proto_tcpv4 = {
- .name = "tcpv4",
- .fam = &proto_fam_inet4,
- .ctrl_type = SOCK_STREAM,
- .sock_type = SOCK_STREAM,
- .sock_prot = IPPROTO_TCP,
- .add = default_add_listener,
- .listen = tcp_bind_listener,
- .enable = tcp_enable_listener,
- .disable = tcp_disable_listener,
- .unbind = default_unbind_listener,
- .suspend = default_suspend_listener,
- .resume = default_resume_listener,
- .accept_conn = sock_accept_conn,
- .rx_enable = sock_enable,
- .rx_disable = sock_disable,
- .rx_unbind = sock_unbind,
- .rx_suspend = tcp_suspend_receiver,
- .rx_resume = tcp_resume_receiver,
- .rx_listening = sock_accepting_conn,
- .default_iocb = &sock_accept_iocb,
- .connect = tcp_connect_server,
- .receivers = LIST_HEAD_INIT(proto_tcpv4.receivers),
- .nb_receivers = 0,
+ .name = "tcpv4",
+
+ /* connection layer */
+ .ctrl_type = SOCK_STREAM,
+ .listen = tcp_bind_listener,
+ .enable = tcp_enable_listener,
+ .disable = tcp_disable_listener,
+ .add = default_add_listener,
+ .unbind = default_unbind_listener,
+ .suspend = default_suspend_listener,
+ .resume = default_resume_listener,
+ .accept_conn = sock_accept_conn,
+ .connect = tcp_connect_server,
+
+ /* binding layer */
+ .rx_suspend = tcp_suspend_receiver,
+ .rx_resume = tcp_resume_receiver,
+
+ /* address family */
+ .fam = &proto_fam_inet4,
+
+ /* socket layer */
+ .sock_type = SOCK_STREAM,
+ .sock_prot = IPPROTO_TCP,
+ .rx_enable = sock_enable,
+ .rx_disable = sock_disable,
+ .rx_unbind = sock_unbind,
+ .rx_listening = sock_accepting_conn,
+ .default_iocb = sock_accept_iocb,
+ .receivers = LIST_HEAD_INIT(proto_tcpv4.receivers),
+ .nb_receivers = 0,
};
INITCALL1(STG_REGISTER, protocol_register, &proto_tcpv4);
/* Note: must not be declared <const> as its list will be overwritten */
struct protocol proto_tcpv6 = {
- .name = "tcpv6",
- .fam = &proto_fam_inet6,
- .ctrl_type = SOCK_STREAM,
- .sock_type = SOCK_STREAM,
- .sock_prot = IPPROTO_TCP,
- .add = default_add_listener,
- .listen = tcp_bind_listener,
- .enable = tcp_enable_listener,
- .disable = tcp_disable_listener,
- .unbind = default_unbind_listener,
- .suspend = default_suspend_listener,
- .resume = default_resume_listener,
- .accept_conn = sock_accept_conn,
- .rx_enable = sock_enable,
- .rx_disable = sock_disable,
- .rx_unbind = sock_unbind,
- .rx_suspend = tcp_suspend_receiver,
- .rx_resume = tcp_resume_receiver,
- .rx_listening = sock_accepting_conn,
- .default_iocb = &sock_accept_iocb,
- .connect = tcp_connect_server,
- .receivers = LIST_HEAD_INIT(proto_tcpv6.receivers),
- .nb_receivers = 0,
+ .name = "tcpv6",
+
+ /* connection layer */
+ .ctrl_type = SOCK_STREAM,
+ .listen = tcp_bind_listener,
+ .enable = tcp_enable_listener,
+ .disable = tcp_disable_listener,
+ .add = default_add_listener,
+ .unbind = default_unbind_listener,
+ .suspend = default_suspend_listener,
+ .resume = default_resume_listener,
+ .accept_conn = sock_accept_conn,
+ .connect = tcp_connect_server,
+
+ /* binding layer */
+ .rx_suspend = tcp_suspend_receiver,
+ .rx_resume = tcp_resume_receiver,
+
+ /* address family */
+ .fam = &proto_fam_inet6,
+
+ /* socket layer */
+ .sock_type = SOCK_STREAM,
+ .sock_prot = IPPROTO_TCP,
+ .rx_enable = sock_enable,
+ .rx_disable = sock_disable,
+ .rx_unbind = sock_unbind,
+ .rx_listening = sock_accepting_conn,
+ .default_iocb = sock_accept_iocb,
+ .receivers = LIST_HEAD_INIT(proto_tcpv6.receivers),
+ .nb_receivers = 0,
};
INITCALL1(STG_REGISTER, protocol_register, &proto_tcpv6);
diff --git a/src/proto_udp.c b/src/proto_udp.c
index a883967..d054317 100644
--- a/src/proto_udp.c
+++ b/src/proto_udp.c
@@ -48,50 +48,66 @@
/* Note: must not be declared <const> as its list will be overwritten */
struct protocol proto_udp4 = {
- .name = "udp4",
- .fam = &proto_fam_inet4,
- .ctrl_type = SOCK_DGRAM,
- .sock_type = SOCK_DGRAM,
- .sock_prot = IPPROTO_UDP,
- .add = default_add_listener,
- .listen = udp_bind_listener,
- .enable = udp_enable_listener,
- .disable = udp_disable_listener,
- .unbind = default_unbind_listener,
- .suspend = default_suspend_listener,
- .resume = default_resume_listener,
- .rx_enable = sock_enable,
- .rx_disable = sock_disable,
- .rx_unbind = sock_unbind,
- .rx_suspend = udp_suspend_receiver,
- .rx_resume = udp_resume_receiver,
- .receivers = LIST_HEAD_INIT(proto_udp4.receivers),
- .nb_receivers = 0,
+ .name = "udp4",
+
+ /* connection layer */
+ .ctrl_type = SOCK_DGRAM,
+ .listen = udp_bind_listener,
+ .enable = udp_enable_listener,
+ .disable = udp_disable_listener,
+ .add = default_add_listener,
+ .unbind = default_unbind_listener,
+ .suspend = default_suspend_listener,
+ .resume = default_resume_listener,
+
+ /* binding layer */
+ .rx_suspend = udp_suspend_receiver,
+ .rx_resume = udp_resume_receiver,
+
+ /* address family */
+ .fam = &proto_fam_inet4,
+
+ /* socket layer */
+ .sock_type = SOCK_DGRAM,
+ .sock_prot = IPPROTO_UDP,
+ .rx_enable = sock_enable,
+ .rx_disable = sock_disable,
+ .rx_unbind = sock_unbind,
+ .receivers = LIST_HEAD_INIT(proto_udp4.receivers),
+ .nb_receivers = 0,
};
INITCALL1(STG_REGISTER, protocol_register, &proto_udp4);
/* Note: must not be declared <const> as its list will be overwritten */
struct protocol proto_udp6 = {
- .name = "udp6",
- .fam = &proto_fam_inet6,
- .ctrl_type = SOCK_DGRAM,
- .sock_type = SOCK_DGRAM,
- .sock_prot = IPPROTO_UDP,
- .add = default_add_listener,
- .listen = udp_bind_listener,
- .enable = udp_enable_listener,
- .disable = udp_disable_listener,
- .unbind = default_unbind_listener,
- .suspend = default_suspend_listener,
- .resume = default_resume_listener,
- .rx_enable = sock_enable,
- .rx_disable = sock_disable,
- .rx_unbind = sock_unbind,
- .rx_suspend = udp_suspend_receiver,
- .rx_resume = udp_resume_receiver,
- .receivers = LIST_HEAD_INIT(proto_udp6.receivers),
- .nb_receivers = 0,
+ .name = "udp6",
+
+ /* connection layer */
+ .ctrl_type = SOCK_DGRAM,
+ .listen = udp_bind_listener,
+ .enable = udp_enable_listener,
+ .disable = udp_disable_listener,
+ .add = default_add_listener,
+ .unbind = default_unbind_listener,
+ .suspend = default_suspend_listener,
+ .resume = default_resume_listener,
+
+ /* binding layer */
+ .rx_suspend = udp_suspend_receiver,
+ .rx_resume = udp_resume_receiver,
+
+ /* address family */
+ .fam = &proto_fam_inet6,
+
+ /* socket layer */
+ .sock_type = SOCK_DGRAM,
+ .sock_prot = IPPROTO_UDP,
+ .rx_enable = sock_enable,
+ .rx_disable = sock_disable,
+ .rx_unbind = sock_unbind,
+ .receivers = LIST_HEAD_INIT(proto_udp6.receivers),
+ .nb_receivers = 0,
};
INITCALL1(STG_REGISTER, protocol_register, &proto_udp6);
diff --git a/src/proto_uxst.c b/src/proto_uxst.c
index 8cf541d..1714e10 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -49,27 +49,35 @@
/* Note: must not be declared <const> as its list will be overwritten */
struct protocol proto_uxst = {
- .name = "unix_stream",
- .fam = &proto_fam_unix,
- .ctrl_type = SOCK_STREAM,
- .sock_type = SOCK_STREAM,
- .sock_prot = 0,
- .add = default_add_listener,
- .listen = uxst_bind_listener,
- .enable = uxst_enable_listener,
- .disable = uxst_disable_listener,
- .unbind = default_unbind_listener,
- .suspend = default_suspend_listener,
- .accept_conn = sock_accept_conn,
- .rx_enable = sock_enable,
- .rx_disable = sock_disable,
- .rx_unbind = sock_unbind,
- .rx_suspend = uxst_suspend_receiver,
- .rx_listening = sock_accepting_conn,
- .default_iocb = &sock_accept_iocb,
- .connect = &uxst_connect_server,
- .receivers = LIST_HEAD_INIT(proto_uxst.receivers),
- .nb_receivers = 0,
+ .name = "unix_stream",
+
+ /* connection layer */
+ .ctrl_type = SOCK_STREAM,
+ .listen = uxst_bind_listener,
+ .enable = uxst_enable_listener,
+ .disable = uxst_disable_listener,
+ .add = default_add_listener,
+ .unbind = default_unbind_listener,
+ .suspend = default_suspend_listener,
+ .accept_conn = sock_accept_conn,
+ .connect = uxst_connect_server,
+
+ /* binding layer */
+ .rx_suspend = uxst_suspend_receiver,
+
+ /* address family */
+ .fam = &proto_fam_unix,
+
+ /* socket layer */
+ .sock_type = SOCK_STREAM,
+ .sock_prot = 0,
+ .rx_enable = sock_enable,
+ .rx_disable = sock_disable,
+ .rx_unbind = sock_unbind,
+ .rx_listening = sock_accepting_conn,
+ .default_iocb = sock_accept_iocb,
+ .receivers = LIST_HEAD_INIT(proto_uxst.receivers),
+ .nb_receivers = 0,
};
INITCALL1(STG_REGISTER, protocol_register, &proto_uxst);