/* Add a route entry to the route table. All the IP4_ADDRs are in host byte order. */
EFI_STATUS Ip4AddRoute(IN OUT IP4_ROUTE_TABLE *RtTable, IN IP4_ADDR Dest, IN IP4_ADDR Netmask, IN IP4_ADDR Gateway)
/* Add a route entry to the route table. All the IP4_ADDRs are in host byte order. */
EFI_STATUS Ip4AddRoute(IN OUT IP4_ROUTE_TABLE *RtTable, IN IP4_ADDR Dest, IN IP4_ADDR Netmask, IN IP4_ADDR Gateway)
{
  LIST_ENTRY       *Head;
  LIST_ENTRY       *Entry;
  IP4_ROUTE_ENTRY  *RtEntry;
  Head = &(RtTable->RouteArea[NetGetMaskLength (Netmask)]);
  NET_LIST_FOR_EACH (Entry, Head) {
    RtEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_ENTRY, Link);
    if (IP4_NET_EQUAL (RtEntry->Dest, Dest, Netmask) && (RtEntry->NextHop == Gateway)) {
      return EFI_ACCESS_DENIED;
    }
  }
  RtEntry = Ip4CreateRouteEntry (Dest, Netmask, Gateway);
  if (RtEntry == NULL) {
    return EFI_OUT_OF_RESOURCES;
  }
  if (Gateway == IP4_ALLZERO_ADDRESS) {
    RtEntry->Flag = IP4_DIRECT_ROUTE;
  }
  InsertHeadList (Head, &RtEntry->Link);
  RtTable->TotalNum++;
  return EFI_SUCCESS;
}