Index: include/tcp.h =================================================================== --- include/tcp.h (Revision 629) +++ include/tcp.h (Arbeitskopie) @@ -102,7 +102,12 @@ void* data; }; +struct tcp_out_buffer { + size_t size; + void* data; +}; + void init_tcp(); struct tcp_connection* tcp_open_connection(dword ip, word port); Index: tcp.c =================================================================== --- tcp.c (Revision 629) +++ tcp.c (Arbeitskopie) @@ -136,10 +136,9 @@ if (list_is_empty(conn->out_buffer)) { tcp_send_packet(conn, NULL, 0, TCPF_ACK); } else { - void* data = list_pop(conn->out_buffer); - DEBUG_MSG1("Sende %d Bytes", strlen(data)); - tcp_send_packet(conn, data, strlen(data), TCPF_ACK | TCPF_PSH); - DEBUG_MSG("Gesendet"); + struct tcp_out_buffer* data = list_pop(conn->out_buffer); + DEBUG_MSG1("Sende %d Bytes", data->size); + tcp_send_packet(conn, data->data, data->size, TCPF_ACK | TCPF_PSH); // TODO free } } @@ -286,6 +285,7 @@ big_endian_word(header->source_port), big_endian_word(header->dest_port)); + DEBUG_MSG("--"); if (conn == NULL) { DEBUG_MSG1("Verbindung nicht gefunden. IP = %08x", source_ip); return; @@ -354,9 +354,10 @@ payload = data + (4 * header->data_offset); payload_size = data_size - (4 * header->data_offset); - DEBUG_MSG1("Ack: %08x", header->ack); - DEBUG_MSG1("Seq: %08x", header->seq); + DEBUG_MSG1("Ack: %08x", header->ack); + DEBUG_MSG1("Seq: %08x", header->seq); DEBUG_MSG1("Flags: %02x", header->flags); + DEBUG_MSG1("Size: %02x", payload_size); // FIXME Eigentlich müssen nicht nur die Daten in die richtige Reihenfolge // gebracht werden, sondern alle Pakete. Ansonsten könnte z.B. ein FIN vor Index: lostio_if.c =================================================================== --- lostio_if.c (Revision 629) +++ lostio_if.c (Arbeitskopie) @@ -223,12 +223,12 @@ v(); return 0; } - - char xdata[blocksize * count + 1]; - memcpy(xdata, data, blocksize * count + 1); - xdata[blocksize * count] = '\0'; - list_insert(conn->out_buffer, list_size(conn->out_buffer), xdata); + struct tcp_out_buffer* out_buffer = malloc(sizeof(*out_buffer)); + out_buffer->data = data; + out_buffer->size = blocksize * count; + + list_insert(conn->out_buffer, list_size(conn->out_buffer), out_buffer); //list_push(conn->out_buffer, "GET / HTTP/1.0\r\n\r\n"); while (!list_is_empty(conn->out_buffer)) {