uip_tcpip.c 901 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "uip_pbuf.h"
  2. #include "uip-conf.h"
  3. #include "rtdef.h"
  4. #include "uip.h"
  5. #include "uip_arp.h"
  6. #include "uip_netif.h"
  7. err_t
  8. tcpip_input(struct pbuf *p, struct netif *inp)
  9. {
  10. int i;
  11. u8_t *pdata;
  12. if (uip_len)
  13. {
  14. uip_arp_out();
  15. if (( pdata =(u8_t*)rt_malloc(1500*sizeof(u8_t))) == RT_NULL)
  16. {
  17. pbuf_free(p);
  18. return 1;
  19. }
  20. for (i=0; i < (UIP_LLH_LEN + 40); ++i) // 14+40 =54
  21. {
  22. pdata[i] = uip_buf[i]; /* get dest an src ipaddr */
  23. }
  24. // Copy the data portion part
  25. for(; i < uip_len; ++i)
  26. {
  27. pdata[i] = uip_appdata[i - UIP_LLH_LEN - 40 ];
  28. }
  29. p ->payload = pdata;
  30. p->len = uip_len;
  31. inp->linkoutput(inp,p);
  32. rt_free(pdata);
  33. return 1;
  34. }
  35. else
  36. {
  37. pbuf_free(p);
  38. return 0;
  39. }
  40. }