MINOR: listener: now use a generic add_listener() function

With the removal of the family-specific port setting, all protocol had
exactly the same implementation of ->add(). A generic one was created
with the name "default_add_listener" so that all other ones can now be
removed. The API was slightly adjusted so that the protocol and the
listener are passed instead of the listener and the port.

Note that all protocols continue to provide this ->add() method instead
of routinely calling default_add_listener() from create_listeners(). This
makes sure that any non-standard protocol will still be able to intercept
the listener addition if needed.

This could be backported to 2.3 along with the few previous patches on
listners as a pure code cleanup.

(cherry picked from commit d1f250f87b8850f24456e62140509e612f8b3415)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/listener.c b/src/listener.c
index 7689ceb..87b2bd2 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -323,6 +323,21 @@
 		HA_RWLOCK_WRUNLOCK(PROXY_LOCK, &px->lock);
 }
 
+/* This function adds the specified <listener> to the protocol <proto>. It
+ * does nothing if the protocol was already added. The listener's state is
+ * automatically updated from LI_INIT to LI_ASSIGNED. The number of listeners
+ * for the protocol is updated. This must be called with the proto lock held.
+ */
+void default_add_listener(struct protocol *proto, struct listener *listener)
+{
+	if (listener->state != LI_INIT)
+		return;
+	listener_set_state(listener, LI_ASSIGNED);
+	listener->rx.proto = proto;
+	LIST_ADDQ(&proto->receivers, &listener->rx.proto_list);
+	proto->nb_receivers++;
+}
+
 /* default function called to suspend a listener: it simply passes the call to
  * the underlying receiver. This is find for most socket-based protocols. This
  * must be called under the listener's lock. It will return non-zero on success,
@@ -616,13 +631,13 @@
 		l->rx.fd = fd;
 
 		memcpy(&l->rx.addr, ss, sizeof(*ss));
-		if (proto->fam.set_port)
-			proto->fam.set_port(&l->rx.addr, port);
+		if (proto->fam->set_port)
+			proto->fam->set_port(&l->rx.addr, port);
 
 		MT_LIST_INIT(&l->wait_queue);
 		listener_set_state(l, LI_INIT);
 
-		proto->add(l, port);
+		proto->add(proto, l);
 
 		if (fd != -1)
 			l->rx.flags |= RX_F_INHERITED;