-/*
- * set_listener_mask - set the connection mask for this listener
- */
-static void set_listener_mask(struct Listener* listener, const char* mask)
-{
- int ad[4];
- char ipname[20];
-
- assert(0 != listener);
-
- if (EmptyString(mask) || 0 == strcmp(mask, "*")) {
- listener->mask.s_addr = 0;
- return;
- }
- ad[0] = ad[1] = ad[2] = ad[3] = 0;
- /*
- * do it this way because building ip# from separate values for each
- * byte requires endian knowledge or some nasty messing. Also means
- * easy conversion of "*" 0.0.0.0 or 134.* to 134.0.0.0 :-)
- */
- sscanf(mask, "%d.%d.%d.%d", &ad[0], &ad[1], &ad[2], &ad[3]);
- ircd_snprintf(0, ipname, sizeof(ipname), "%d.%d.%d.%d", ad[0], ad[1], ad[2],
- ad[3]);
- listener->mask.s_addr = inet_addr(ipname);
-}
-
-/*
- * connection_allowed - spin through mask and addr passed to see if connect
- * allowed on a listener, uses mask generated by set_listener_mask
- */
-static int connection_allowed(const char* addr, const char* mask)
-{
- int i = 4;
- for ( ; i > 0; --i) {
- if (*mask && *addr != *mask)
- break;
- ++addr;
- ++mask;
- }
- return (0 == i);
-}
-
-
-/*
- * add_listener- create a new listener
- * port - the port number to listen on
- * vhost_ip - if non-null must contain a valid IP address string in
- * the format "255.255.255.255"
+/** Make sure we have a listener for \a port on \a vhost_ip.
+ * If one does not exist, create it. Then mark it as active and set
+ * the peer mask, server, and hidden flags according to the other
+ * arguments.
+ * @param[in] port Port number to listen on.
+ * @param[in] vhost_ip Local address to listen on.
+ * @param[in] mask Address mask to accept connections from.
+ * @param[in] flags Flags describing listener options.