/* Select an interface to send the packet generated in the IP4 driver itself, that is, not by the requests of IP4 child's consumer. Such packets include the ICMP echo replies, and other ICMP error packets. */
IP4_INTERFACE* Ip4SelectInterface(IN IP4_SERVICE *IpSb, IN IP4_ADDR Dst, IN IP4_ADDR Src)
/* Select an interface to send the packet generated in the IP4 driver itself, that is, not by the requests of IP4 child's consumer. Such packets include the ICMP echo replies, and other ICMP error packets. */
IP4_INTERFACE* Ip4SelectInterface(IN IP4_SERVICE *IpSb, IN IP4_ADDR Dst, IN IP4_ADDR Src)
{
  IP4_INTERFACE  *IpIf;
  IP4_INTERFACE  *Selected;
  LIST_ENTRY     *Entry;
  IpIf = Ip4FindNet (IpSb, Dst);
  if ((IpIf != NULL) && (IpIf->Ip != IP4_ALLZERO_ADDRESS)) {
    return IpIf;
  }
  IpIf = Ip4FindInterface (IpSb, Src);
  if ((IpIf != NULL) && (IpIf->Ip != IP4_ALLZERO_ADDRESS)) {
    return IpIf;
  }
  Selected = NULL;
  NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
    IpIf = NET_LIST_USER_STRUCT (Entry, IP4_INTERFACE, Link);
    if (IpIf->Configured && ((Selected == NULL) || (Selected->Ip == 0))) {
      Selected = IpIf;
    }
  }
  return Selected;
}