Traffic scripts: Move valid_ipv* to a library