This could be tested before the string/regex comparisons above, so might as well be folded together with the ip == NULL check.