function tcp_input

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

function tcp_input

VEROPDUR@terra.es
Hello, I'm a student of Computer Science and I'm working with lwIP in my final project. I'm using lwIP 1.1.1. and I need to use the TCP layer.
I have a problem when I want to send a message to TCP layer with the tcp_input function. I'm not sure how is the correct format of the struct pbuf to pass to this function, because although at the document "Design and Implementation of the lwIP TCP/IP Stack" at the point "6. Buffer and memory management", the payload of a PBUF_RAM pbuf doesn't point to the TCP and IP headers, in the code of the function tcp_input this pointer is used to access to these headers, this is the code:
iphdr = (struct ip_hdr*)p->payload;
tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4);
And this is how I build the struct pbuf to send to tcp_input:
struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT, pkt->length, PBUF_RAM);
p->len = pkt->length;
p->tot_len = pkt->length;
p->next = NULL;
memcpy(p->payload,pkt->data,pkt->length);
where pkt->length is the size of the data include headers, and pkt->data is the data to send TCP layer include headers too.
The function tcp_input process the struct pbuf adequately, but when this function calls tcp_listen_input I have a segmentation fault at the point where it calls to tcp_enqueue.
I'm working with a empty definition of the functions that manage shared memory because only a process need to access to the memory.
I'm sorry for my english.
Thanks a lot


Prueba el Nuevo Correo Terra; Seguro, rápido, fiable.

_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users