icmp_main() is called during the initialization of the network service to initialize each of the icmp ports on a system. During the initialization of an icmp port, ip_open() is called to acquire an ip file descriptor. ip_ioctl() is then called to initialize this newly-opened ip file descriptor. Finally, icmp_read() is called to read any packets that have arrived at the ip file descriptor.
icmp_main() is called later by icmp_getdata() if, for whatever reason, the initialization steps were not able to complete.