예제 #1
0
uint_32 IP_route_local
   (
      RTCSPCB_PTR    pcb,
            /* [IN] the packet to send */
      _ip_address    ipdest
            /* [IN] the ultimate destination */
   )
{ /* Body */
   IP_CFG_STRUCT_PTR          IP_cfg_ptr = RTCS_getcfg(IP);
   struct ip_route_local_test testdata;

   /* 
   ** RFC 2131 says:
   ** "In the case of a client using DHCP for initial configuration (before
   ** the client's TCP/IP software has been completely configured), DHCP
   ** requires creative use of the client's TCP/IP software and liberal
   ** interpretation of RFC 1122.  The TCP/IP software SHOULD accept and
   ** forward to the IP layer any IP packets delivered to the client's
   ** hardware address before the IP address is configured."
   **
   ** So if the broadcast flag is disabled, we check, and if the packet's 
   ** source interface is not bound, we send the packet to IF_LOCALHOST.
   ** This is paired with the same test in ip.c:IP_service(), which sends 
   ** the packet here.
   */
   if ((ipdest == INADDR_BROADCAST) 
       || IN_MULTICAST(ipdest)
       || (!_DHCP_broadcast && (IP_get_ipif_addr(pcb->IFSRC) == INADDR_ANY))) { 
      /* Accept broadcasts and multicasts and unbound unicasts */
      testdata.ifdest = IP_cfg_ptr->IF_LOCALHOST;
   } else {

      /* If unicast, check routing table */
      testdata.ifdest = NULL;
      testdata.ipdest = ipdest;
      testdata.pcb    = pcb;
      IPRADIX_findbest(&IP_cfg_ptr->ROUTE_ROOT.NODE, ipdest,
                       IP_route_local_test, &testdata);
   } /* Endif */

   /* Send the packet to the interface. */
   if (testdata.ifdest) {
      return IP_send_dgram(IP_cfg_ptr->IF_LOCALHOST, pcb, 0, ipdest, ipdest, 0,
         NULL);
   } /* Endif */

   /* No interface was found. Discard the packet */
   IF_IP_STATS_ENABLED(IP_cfg_ptr->STATS.COMMON.ST_RX_DISCARDED++);
   IF_IP_STATS_ENABLED(IP_cfg_ptr->STATS.ST_RX_ADDR_ERRORS++);
   RTCSLOG_PCB_FREE(pcb, RTCSERR_IP_UNREACH);
   RTCSPCB_free(pcb);
   return RTCSERR_IP_UNREACH;

} /* Endbody */
예제 #2
0
static boolean NAT_IPREASM_expire
   (
      TCPIP_EVENT_PTR   event    /* [IN/OUT] the expire event */
   )
{ /* Body */
   IP_CFG_STRUCT_PTR IP_cfg_ptr = RTCS_getcfg(IP);
   IP_DGRAM_PTR      dgram = event->PRIVATE;

   IF_IP_STATS_ENABLED(IP_cfg_ptr->STATS.ST_RX_FRAG_DISCARDED++);

   /* Send a ICMP Time Exceeded */
   if (dgram->DIRECT[0]
    && dgram->DIRECT[0]->BUSYINT & 1
    && dgram->TYPE & RTCSPCB_TYPE_UNICAST) {
      ICMP_send_error_internal(ICMPTYPE_TIMEEXCEED, ICMPCODE_TE_REASM, 0, 
         &dgram->IPH, NULL, 0);
   } /* Endif */

   NAT_IPREASM_del_dgram(dgram);
   return FALSE;

} /* Endbody */