MEDIUM: sock_inet: implement sock_inet_bind_receiver()
This function collects all the receiver-specific code from both
tcp_bind_listener() and udp_bind_listener() in order to provide a more
generic AF_INET/AF_INET6 socket binding function. For now the API is
not very elegant because some info are still missing from the receiver
while there's no ideal place to fill them except when calling ->listen()
at the protocol level. It looks like some polishing code is needed in
check_config_validity() or somewhere around this in order to finalize
the receivers' setup. The main issue is that listeners and receivers
are created *before* bind_conf options are parsed and that there's no
finishing step to resolve some of them.
The function currently sets up a receiver and subscribes it to the
poller. In an ideal world we wouldn't subscribe it but let the caller
do it after having finished to configure the L4 stuff. The problem is
that the caller would then need to perform an fd_insert() call and to
possibly set the exported flag on the FD while it's not its job. Maybe
an improvement could be to have a separate sock_start_receiver() call
in sock.c.
For now the function is not used but it will soon be. It's already
referenced as tcp and udp's ->bind().
diff --git a/src/proto_udp.c b/src/proto_udp.c
index eea2583..130c921 100644
--- a/src/proto_udp.c
+++ b/src/proto_udp.c
@@ -55,6 +55,7 @@
.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,
@@ -79,6 +80,7 @@
.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,