MINOR: protocol: export protocol definitions
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.
This commit is contained in:
parent
f9ad06cb26
commit
b9b2fd7cf4
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
34
include/haproxy/proto_uxst.h
Normal file
34
include/haproxy/proto_uxst.h
Normal file
@ -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:
|
||||
*/
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user