This problem is produced when remove the IP address from route tree. After, any call of IP_find_if() function returns error.
My solution is change the order of one line into IPIF_unbind() function. First, we call the IGMP_UNBIND function pointer, and after we remove the IP address.
I have obtained good results with this solution without need of a break variable.
void IPIF_unbind
(
IPIF_PARM_PTR parms
)
{ /* Body */
#if RTCSCFG_ENABLE_IP4
_ip_address mask;
// IP_route_remove_direct(parms->address, 0xFFFFFFFF, parms->ihandle); // move this line below
#if RTCSCFG_ENABLE_IGMP
if (parms->ihandle) {
((IP_IF_PTR)(parms->ihandle))->IGMP_UNBIND((IP_IF_PTR)parms->ihandle,
parms->address);
} /* Endif */
#endif
IP_route_remove_direct(parms->address, 0xFFFFFFFF, parms->ihandle); // this line was higher
IP_get_netmask(parms->ihandle, parms->address, &mask);
/* If mask is invalid do not try to remove direct route */
if (mask != 1)
{
IP_route_remove_direct(parms->address, mask, parms->ihandle);
}
RTCSCMD_complete(parms, RTCS_OK);
#else
RTCSCMD_complete(parms, RTCSERR_IP_IS_DISABLED);
#endif /* RTCSCFG_ENABLE_IP4 */
} /* Endbody */