lwip/core/raw.c
/**
 * Send the raw IP packet to the given address. Note that actually you cannot
 * modify the IP headers (this is inconsitent with the receive callback where
 * you actually get the IP headers), you can only specifiy the ip payload here.
 * It requires some more changes in LWIP. (there will be a raw_send() function
 * then)
 *
 * @param pcb the raw pcb which to send
 * @param p the ip payload to send
 * @param ipaddr the destination address of the whole IP packet
 *
 */
Send the raw IP packet to the given address. Note that actually you cannot
modify the IP headers (this is inconsitent with the receive callback where
you actually get the IP headers), you can only specifiy the ip payload here.
It requires some more changes in LWIP. (there will be a raw_send() function
then)

@param pcb the raw pcb which to send
@param p the ip payload to send
@param ipaddr the destination address of the whole IP packet
Send the raw IP packet to the given address . Note that actually you cannot modify the IP headers ( this is inconsitent with the receive callback where you actually get the IP headers ) you can only specifiy the ip payload here . It requires some more changes in LWIP . ( there will be a raw_send () function then ) @param pcb the raw pcb which to send @param p the ip payload to send @param ipaddr the destination address of the whole IP packet
err_t
raw_send_to(struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *ipaddr)
{
  err_t err;
  struct netif *netif;
  struct ip_addr *src_ip;
  struct pbuf *q; 
  LWIP_DEBUGF(RAW_DEBUG | DBG_TRACE | 3, ("raw_send_to\n"));
  if (pbuf_header(p, IP_HLEN)) {
    q = pbuf_alloc(PBUF_IP, 0, PBUF_RAM);
    if (q == NULL) {
      LWIP_DEBUGF(RAW_DEBUG | DBG_TRACE | 2, ("raw_send_to: could not allocate header\n"));
      return ERR_MEM;
    }
    pbuf_chain(q, p);
    LWIP_DEBUGF(RAW_DEBUG, ("raw_send_to: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p));
  }  else {
    q = p;
    pbuf_header(q, -IP_HLEN);
  }
  if ((netif = ip_route(ipaddr)) == NULL) {
    LWIP_DEBUGF(RAW_DEBUG | 1, ("raw_send_to: No route to 0x%lx\n", ipaddr->addr));
#if RAW_STATS
#endif 
    if (q != p) {
      pbuf_free(q);
    }
    return ERR_RTE;
  }
  if (ip_addr_isany(&pcb->local_ip)) {
    src_ip = &(netif->ip_addr);
  } else {
    src_ip = &(pcb->local_ip);
  }
  err = ip_output_if (q, src_ip, ipaddr, pcb->ttl, pcb->tos, pcb->protocol, netif);
  if (q != p) {
    pbuf_free(q);
  }
  return err;
}
err_t raw_send_to ( struct raw_pcb * pcb , struct pbuf * p , struct ip_addr * ipaddr ) { err_t err ; struct netif * netif ; struct ip_addr * src_ip ; struct pbuf * q ; LWIP_DEBUGF ( RAW_DEBUG | DBG_TRACE | 3 , ( " \n " ) ) ; if ( pbuf_header ( p , IP_HLEN ) ) { q = pbuf_alloc ( PBUF_IP , 0 , PBUF_RAM ) ; if ( q == NULL ) { LWIP_DEBUGF ( RAW_DEBUG | DBG_TRACE | 2 , ( " \n " ) ) ; return ERR_MEM ; } pbuf_chain ( q , p ) ; LWIP_DEBUGF ( RAW_DEBUG , ( " \n " , ( void * ) q , ( void * ) p ) ) ; } else { q = p ; pbuf_header ( q , - IP_HLEN ) ; } if ( ( netif = ip_route ( ipaddr ) ) == NULL ) { LWIP_DEBUGF ( RAW_DEBUG | 1 , ( " \n " , ipaddr -> addr ) ) ; #if RAW_STATS #endif if ( q != p ) { pbuf_free ( q ) ; } return ERR_RTE ; } if ( ip_addr_isany ( & pcb -> local_ip ) ) { src_ip = & ( netif -> ip_addr ) ; } else { src_ip = & ( pcb -> local_ip ) ; } err = ip_output_if ( q , src_ip , ipaddr , pcb -> ttl , pcb -> tos , pcb -> protocol , netif ) ; if ( q != p ) { pbuf_free ( q ) ; } return err ; }
Send the raw IP packet to the given address.
Send the raw IP packet to the given address .
/* q will be sent down the stack */ /* not enough space to add an IP header to first pbuf in given p chain? */ /* allocate header in new pbuf */ /* new header pbuf could not be allocated? */ /* chain header q in front of given pbuf p */ /* { first pbuf q points to header pbuf } */ /* first pbuf q equals given pbuf */ /*    ++lwip_stats.raw.rterr;*/ /* RAW_STATS */ /* use outgoing network interface IP address as source address */ /* use RAW PCB local IP address as source address */ /* did we chain a header earlier? */ /* free the header */