diff --git a/include/haproxy/proto_udp.h b/include/haproxy/proto_udp.h index 6b91cea7c..f9069d16e 100644 --- a/include/haproxy/proto_udp.h +++ b/include/haproxy/proto_udp.h @@ -26,10 +26,6 @@ int udp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct sockaddr_storage *remote); int udp_pause_listener(struct listener *l); -int udp_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir); -int udp6_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir); -int udp_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir); -int udp6_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir); #endif /* _PROTO_PROTO_UDP_H */ diff --git a/include/haproxy/protocol-t.h b/include/haproxy/protocol-t.h index fe0c9812a..4f5aac221 100644 --- a/include/haproxy/protocol-t.h +++ b/include/haproxy/protocol-t.h @@ -84,21 +84,14 @@ struct protocol { 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() */ - sa_family_t sock_family; /* socket family, for sockaddr */ - socklen_t sock_addrlen; /* socket address length, used by bind() */ - int l3_addrlen; /* layer3 address length, used by hashes */ void (*accept)(int fd); /* generic accept function */ - int (*bind)(struct receiver *rx, void (*handler)(int fd), char **errmsg); /* bind a receiver */ int (*listen)(struct listener *l, char *errmsg, int errlen); /* start a listener */ int (*enable_all)(struct protocol *proto); /* enable all bound listeners */ int (*disable_all)(struct protocol *proto); /* disable all bound listeners */ int (*connect)(struct connection *, int flags); /* connect function if any, see below for flags values */ - int (*get_src)(int fd, struct sockaddr *, socklen_t, int dir); /* syscall used to retrieve src addr */ - int (*get_dst)(int fd, struct sockaddr *, socklen_t, int dir); /* syscall used to retrieve dst addr */ int (*drain)(int fd); /* indicates whether we can safely close the fd */ int (*pause)(struct listener *l); /* temporarily pause this listener for a soft restart */ void (*add)(struct listener *l, int port); /* add a listener for this protocol and port */ - int (*addrcmp)(const struct sockaddr_storage *, const struct sockaddr_storage *); /* compare addresses (like memcmp) */ struct list listeners; /* list of listeners using this protocol (under proto_lock) */ int nb_listeners; /* number of listeners (under proto_lock) */ diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c index a2a9607a8..6b1d69c7f 100644 --- a/src/proto_sockpair.c +++ b/src/proto_sockpair.c @@ -64,17 +64,11 @@ static struct protocol proto_sockpair = { .sock_domain = AF_CUST_SOCKPAIR, .sock_type = SOCK_STREAM, .sock_prot = 0, - .sock_family = AF_UNIX, - .sock_addrlen = sizeof(struct sockaddr_un), - .l3_addrlen = sizeof(((struct sockaddr_un*)0)->sun_path),/* path len */ .accept = &listener_accept, .connect = &sockpair_connect_server, - .bind = sockpair_bind_receiver, .listen = sockpair_bind_listener, .enable_all = enable_all_listeners, .disable_all = disable_all_listeners, - .get_src = NULL, - .get_dst = NULL, .pause = NULL, .add = sockpair_add_listener, .listeners = LIST_HEAD_INIT(proto_sockpair.listeners), diff --git a/src/proto_tcp.c b/src/proto_tcp.c index cb4dc3202..33d39b3d5 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -55,19 +55,12 @@ static struct protocol proto_tcpv4 = { .sock_domain = AF_INET, .sock_type = SOCK_STREAM, .sock_prot = IPPROTO_TCP, - .sock_family = AF_INET, - .sock_addrlen = sizeof(struct sockaddr_in), - .l3_addrlen = 32/8, .accept = &listener_accept, .connect = tcp_connect_server, - .bind = sock_inet_bind_receiver, .listen = tcp_bind_listener, .enable_all = enable_all_listeners, - .get_src = sock_get_src, - .get_dst = sock_inet_get_dst, .pause = tcp_pause_listener, .add = tcpv4_add_listener, - .addrcmp = sock_inet4_addrcmp, .listeners = LIST_HEAD_INIT(proto_tcpv4.listeners), .nb_listeners = 0, }; @@ -81,19 +74,12 @@ static struct protocol proto_tcpv6 = { .sock_domain = AF_INET6, .sock_type = SOCK_STREAM, .sock_prot = IPPROTO_TCP, - .sock_family = AF_INET6, - .sock_addrlen = sizeof(struct sockaddr_in6), - .l3_addrlen = 128/8, .accept = &listener_accept, .connect = tcp_connect_server, - .bind = sock_inet_bind_receiver, .listen = tcp_bind_listener, .enable_all = enable_all_listeners, - .get_src = sock_get_src, - .get_dst = sock_get_dst, .pause = tcp_pause_listener, .add = tcpv6_add_listener, - .addrcmp = sock_inet6_addrcmp, .listeners = LIST_HEAD_INIT(proto_tcpv6.listeners), .nb_listeners = 0, }; diff --git a/src/proto_udp.c b/src/proto_udp.c index d4d6b2afa..d408d7c26 100644 --- a/src/proto_udp.c +++ b/src/proto_udp.c @@ -51,19 +51,12 @@ static struct protocol proto_udp4 = { .sock_domain = AF_CUST_UDP4, .sock_type = SOCK_DGRAM, .sock_prot = IPPROTO_UDP, - .sock_family = AF_INET, - .sock_addrlen = sizeof(struct sockaddr_in), - .l3_addrlen = 32/8, .accept = NULL, .connect = NULL, - .bind = sock_inet_bind_receiver, .listen = udp_bind_listener, .enable_all = enable_all_listeners, - .get_src = udp_get_src, - .get_dst = udp_get_dst, .pause = udp_pause_listener, .add = udp4_add_listener, - .addrcmp = sock_inet4_addrcmp, .listeners = LIST_HEAD_INIT(proto_udp4.listeners), .nb_listeners = 0, }; @@ -77,95 +70,18 @@ static struct protocol proto_udp6 = { .sock_domain = AF_CUST_UDP6, .sock_type = SOCK_DGRAM, .sock_prot = IPPROTO_UDP, - .sock_family = AF_INET6, - .sock_addrlen = sizeof(struct sockaddr_in6), - .l3_addrlen = 128/8, .accept = NULL, .connect = NULL, - .bind = sock_inet_bind_receiver, .listen = udp_bind_listener, .enable_all = enable_all_listeners, - .get_src = udp6_get_src, - .get_dst = udp6_get_dst, .pause = udp_pause_listener, .add = udp6_add_listener, - .addrcmp = sock_inet6_addrcmp, .listeners = LIST_HEAD_INIT(proto_udp6.listeners), .nb_listeners = 0, }; INITCALL1(STG_REGISTER, protocol_register, &proto_udp6); -/* - * Retrieves the source address for the socket , with indicating - * if we're a listener (=0) or an initiator (!=0). It returns 0 in case of - * success, -1 in case of error. The socket's source address is stored in - * for bytes. - */ -int udp_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir) -{ - int ret; - - ret = sock_get_src(fd, sa, salen, dir); - if (!ret) - sa->sa_family = AF_CUST_UDP4; - - return ret; -} - -/* - * Retrieves the source address for the socket , with indicating - * if we're a listener (=0) or an initiator (!=0). It returns 0 in case of - * success, -1 in case of error. The socket's source address is stored in - * for bytes. - */ -int udp6_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir) -{ - int ret; - - ret = sock_get_src(fd, sa, salen, dir); - if (!ret) - sa->sa_family = AF_CUST_UDP6; - - return ret; -} - -/* - * Retrieves the original destination address for the socket , with - * indicating if we're a listener (=0) or an initiator (!=0). In the case of a - * listener, if the original destination address was translated, the original - * address is retrieved. It returns 0 in case of success, -1 in case of error. - * The socket's source address is stored in for bytes. - */ -int udp_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir) -{ - int ret; - - ret = sock_inet_get_dst(fd, sa, salen, dir); - if (!ret) - sa->sa_family = AF_CUST_UDP4; - - return ret; -} - -/* - * Retrieves the original destination address for the socket , with - * indicating if we're a listener (=0) or an initiator (!=0). In the case of a - * listener, if the original destination address was translated, the original - * address is retrieved. It returns 0 in case of success, -1 in case of error. - * The socket's source address is stored in for bytes. - */ -int udp6_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir) -{ - int ret; - - ret = sock_get_dst(fd, sa, salen, dir); - if (!ret) - sa->sa_family = AF_CUST_UDP6; - - return ret; -} - /* This function tries to bind a UDPv4/v6 listener. It may return a warning or * an error message in if the message is at most bytes long * (including '\0'). Note that may be NULL if is also zero. diff --git a/src/proto_uxst.c b/src/proto_uxst.c index 0b8e1767d..0dd03f85b 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -52,20 +52,13 @@ static struct protocol proto_unix = { .sock_domain = PF_UNIX, .sock_type = SOCK_STREAM, .sock_prot = 0, - .sock_family = AF_UNIX, - .sock_addrlen = sizeof(struct sockaddr_un), - .l3_addrlen = sizeof(((struct sockaddr_un*)0)->sun_path),/* path len */ .accept = &listener_accept, .connect = &uxst_connect_server, - .bind = sock_unix_bind_receiver, .listen = uxst_bind_listener, .enable_all = enable_all_listeners, .disable_all = disable_all_listeners, - .get_src = sock_get_src, - .get_dst = sock_get_dst, .pause = uxst_pause_listener, .add = uxst_add_listener, - .addrcmp = sock_unix_addrcmp, .listeners = LIST_HEAD_INIT(proto_unix.listeners), .nb_listeners = 0, };