]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: protocol: export protocol definitions
authorWilly Tarreau <w@1wt.eu>
Tue, 8 Dec 2020 13:13:11 +0000 (14:13 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 8 Dec 2020 13:54:08 +0000 (14:54 +0100)
The various protocols were made static since there was no point in
exporting them in the past. Nowadays with QUIC relying on UDP we'll
significantly benefit from UDP being exported and more generally from
being able to declare some functions as being the same as other
protocols'.

In an ideal world it should not be these protocols which should be
exported, but the intermediary levels:
  - socket layer (sock.c only right now), already exported as functions
    but nothing structured at the moment ;
  - family layer (sock_inet, sock_unix, sockpair etc): already structured
    and exported
  - binding layer (the part that relies on the receiver): currently fused
    within the protocol
  - connectiong layer (the part that manipulates connections): currently
    fused within the protocol
  - protocol (connection's control): shouldn't need to be exposed
    ultimately once the elements above are in an easily sharable way.

include/haproxy/proto_sockpair.h
include/haproxy/proto_tcp.h
include/haproxy/proto_udp.h
include/haproxy/proto_uxst.h [new file with mode: 0644]
src/proto_sockpair.c
src/proto_tcp.c
src/proto_udp.c
src/proto_uxst.c

index e012407d7eb555ba0d540197f399b4b33c10912e..bb0256e8d4cc515dc2e833b679149c21fd4f85e1 100644 (file)
@@ -22,6 +22,7 @@
 #define _HAPROXY_PROTO_SOCKPAIR_H
 
 extern struct proto_fam proto_fam_sockpair;
+extern struct protocol proto_sockpair;
 
 int recv_fd_uxst(int sock);
 int send_fd_uxst(int fd, int send_fd);
index 63bbb573387990f8a51119c89a4270241adc7d38..52566dbf3520506aa63efd9e53aaba33e1dc05fd 100644 (file)
@@ -28,6 +28,9 @@
 #include <haproxy/listener-t.h>
 #include <haproxy/sample-t.h>
 
+extern struct protocol proto_tcp4;
+extern struct protocol proto_tcp6;
+
 int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct sockaddr_storage *remote);
 int tcp_connect_server(struct connection *conn, int flags);
 int tcp_is_foreign(int fd, sa_family_t family);
index 25c14235ea6be432519bb1fc3d273bc76efc17d5..7de84130c6cc1bd47169a61652c6494a312c76e4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * include/proto/proto_udp.h
+ * include/haproxy/proto_udp.h
  * This file contains UDP socket protocol definitions.
  *
  * Copyright 2019 HAProxy Technologies, Frédéric Lécaille <flecaille@haproxy.com>
@@ -24,6 +24,9 @@
 #ifndef _PROTO_PROTO_UDP_H
 #define _PROTO_PROTO_UDP_H
 
+extern struct protocol proto_udp4;
+extern struct protocol proto_udp6;
+
 int udp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct sockaddr_storage *remote);
 
 #endif /* _PROTO_PROTO_UDP_H */
diff --git a/include/haproxy/proto_uxst.h b/include/haproxy/proto_uxst.h
new file mode 100644 (file)
index 0000000..77caf3d
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * include/haproxy/proto_uxst.h
+ * This file contains UNIX stream socket protocol definitions.
+ *
+ * Copyright (C) 2000-2013 Willy Tarreau - w@1wt.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _PROTO_PROTO_UXST_H
+#define _PROTO_PROTO_UXST_H
+
+extern struct protocol proto_uxst;
+
+#endif /* _PROTO_PROTO_UXST_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */
index 2f691f7ecd10cc2aff23f3b938efd9e5807033d2..9d2fb118621b9197198f303349154da580afd4af 100644 (file)
@@ -63,7 +63,7 @@ struct proto_fam proto_fam_sockpair = {
 };
 
 /* Note: must not be declared <const> as its list will be overwritten */
-static struct protocol proto_sockpair = {
+struct protocol proto_sockpair = {
        .name = "sockpair",
        .fam = &proto_fam_sockpair,
        .ctrl_type = SOCK_STREAM,
index eecb299e6cfc9c555ca6d9e2ca354d850be30434..b3f648efa58bc98b45a5368252a9f504e74a28fa 100644 (file)
@@ -51,7 +51,7 @@ static void tcp_enable_listener(struct listener *listener);
 static void tcp_disable_listener(struct listener *listener);
 
 /* Note: must not be declared <const> as its list will be overwritten */
-static struct protocol proto_tcpv4 = {
+struct protocol proto_tcpv4 = {
        .name = "tcpv4",
        .fam = &proto_fam_inet4,
        .ctrl_type = SOCK_STREAM,
@@ -80,7 +80,7 @@ static struct protocol proto_tcpv4 = {
 INITCALL1(STG_REGISTER, protocol_register, &proto_tcpv4);
 
 /* Note: must not be declared <const> as its list will be overwritten */
-static struct protocol proto_tcpv6 = {
+struct protocol proto_tcpv6 = {
        .name = "tcpv6",
        .fam = &proto_fam_inet6,
        .ctrl_type = SOCK_STREAM,
index 12e25afdf17773a8b8251d0bd0b5068bc098e0ca..a883967f0b929f7887d17b106a1fb96292014bf3 100644 (file)
@@ -47,7 +47,7 @@ static void udp_enable_listener(struct listener *listener);
 static void udp_disable_listener(struct listener *listener);
 
 /* Note: must not be declared <const> as its list will be overwritten */
-static struct protocol proto_udp4 = {
+struct protocol proto_udp4 = {
        .name = "udp4",
        .fam = &proto_fam_inet4,
        .ctrl_type = SOCK_DGRAM,
@@ -72,7 +72,7 @@ static struct protocol proto_udp4 = {
 INITCALL1(STG_REGISTER, protocol_register, &proto_udp4);
 
 /* Note: must not be declared <const> as its list will be overwritten */
-static struct protocol proto_udp6 = {
+struct protocol proto_udp6 = {
        .name = "udp6",
        .fam = &proto_fam_inet6,
        .ctrl_type = SOCK_DGRAM,
index 52e90ae4a25f42603b9c1a405dc2b195be756db0..8cf541d98aaa1e9db4dc824de3434bbd3353944d 100644 (file)
@@ -33,6 +33,7 @@
 #include <haproxy/listener.h>
 #include <haproxy/log.h>
 #include <haproxy/protocol.h>
+#include <haproxy/proto_uxst.h>
 #include <haproxy/sock.h>
 #include <haproxy/sock_unix.h>
 #include <haproxy/time.h>
@@ -47,7 +48,7 @@ static void uxst_disable_listener(struct listener *listener);
 static int uxst_suspend_receiver(struct receiver *rx);
 
 /* Note: must not be declared <const> as its list will be overwritten */
-static struct protocol proto_unix = {
+struct protocol proto_uxst = {
        .name = "unix_stream",
        .fam = &proto_fam_unix,
        .ctrl_type = SOCK_STREAM,
@@ -67,11 +68,11 @@ static struct protocol proto_unix = {
        .rx_listening = sock_accepting_conn,
        .default_iocb = &sock_accept_iocb,
        .connect = &uxst_connect_server,
-       .receivers = LIST_HEAD_INIT(proto_unix.receivers),
+       .receivers = LIST_HEAD_INIT(proto_uxst.receivers),
        .nb_receivers = 0,
 };
 
-INITCALL1(STG_REGISTER, protocol_register, &proto_unix);
+INITCALL1(STG_REGISTER, protocol_register, &proto_uxst);
 
 /********************************
  * 1) low-level socket functions