+ char* mask = NULL;
+
+ /* The caller is trying to match ident@<mask>/bits.
+ * Chop off the ident@ portion, use match() on it
+ * seperately.
+ */
+ if (match_with_username)
+ {
+ /* Duplicate the strings, and try to find the position
+ * of the @ symbol in each */
+ char* address_dupe = strdup(address);
+ char* cidr_dupe = strdup(cidr_mask);
+
+ char* username_mask_pos = strchr(cidr_dupe, '@');
+ char* username_addr_pos = strchr(address_dupe, '@');
+
+ if (username_mask_pos && username_addr_pos)
+ {
+ *username_mask_pos = *username_addr_pos = 0;
+
+ bool result = (match(address_dupe, cidr_dupe) && MatchCIDR(username_addr_pos + 1, username_mask_pos + 1));
+
+ free(address_dupe);
+ free(cidr_dupe);
+
+ return result;
+ }
+ else
+ {
+ free(address_dupe);
+ free(cidr_dupe);
+ mask = strdup(cidr_mask);
+ }
+ }
+ else
+ {
+ mask = strdup(cidr_mask);
+ }