fix program in sample and add check ip format func