utils.c: Add ip address validation