Free (GPLv2) TCP/IP stack developed by TASS Belgium
Dependents: lpc1768-picotcp-demo ZeroMQ_PicoTCP_Publisher_demo TCPSocket_HelloWorld_PicoTCP Pico_TCP_UDP_Test ... more
PicoTCP. Copyright (c) 2013 TASS Belgium NV.
Released under the GNU General Public License, version 2.
Different licensing models may exist, at the sole discretion of the Copyright holders.
Official homepage: http://www.picotcp.com
Bug tracker: https://github.com/tass-belgium/picotcp/issues
Development steps:
initial integration with mbed RTOSgeneric mbed Ethernet driverhigh performance NXP LPC1768 specific Ethernet driverMulti-threading support for mbed RTOSBerkeley sockets and integration with the New Socket APIFork of the apps running on top of the New Socket APIScheduling optimizations- Debugging/benchmarking/testing
Demo application (measuring TCP sender performance):
Import programlpc1768-picotcp-demo
A PicoTCP demo app testing the ethernet throughput on the lpc1768 mbed board.
Diff: modules/pico_ipv4.c
- Revision:
- 74:c146c4e346c4
- Parent:
- 73:dfb737147f6e
- Child:
- 88:0e827d0d8017
--- a/modules/pico_ipv4.c Fri Sep 27 12:43:36 2013 +0000 +++ b/modules/pico_ipv4.c Tue Oct 01 06:13:42 2013 +0000 @@ -241,6 +241,18 @@ #endif /* PICO_SUPPORT_IPFRAG */ #ifdef PICO_SUPPORT_IPFRAG + +static inline struct pico_ipv4_fragmented_packet *fragment_find_by_hdr(struct pico_ipv4_hdr *hdr) +{ + struct pico_ipv4_fragmented_packet frag = {0}; + frag.id = short_be(hdr->id); + frag.proto = hdr->proto; + frag.src.addr = long_be(hdr->src.addr); + frag.dst.addr = long_be(hdr->dst.addr); + return pico_tree_findKey(&pico_ipv4_fragmented_tree, &frag); +} + + static inline int8_t pico_ipv4_fragmented_check(struct pico_protocol *self, struct pico_frame **f) { uint8_t *running_pointer = NULL; @@ -250,7 +262,7 @@ struct pico_ipv4_hdr *f_frag_hdr = NULL, *hdr = (struct pico_ipv4_hdr *) (*f)->net_hdr; struct pico_udp_hdr *udp_hdr = NULL; struct pico_tcp_hdr *tcp_hdr = NULL; - struct pico_ipv4_fragmented_packet *pfrag = NULL, frag; + struct pico_ipv4_fragmented_packet *pfrag = NULL; struct pico_frame *f_new = NULL, *f_frag = NULL; struct pico_tree_node *index, *_tmp; @@ -291,11 +303,7 @@ } else { reassembly_dbg("REASSEMBLY: intermediate element of a fragmented packet with id %X and offset %u\n", short_be(hdr->id), offset); - frag.id = short_be(hdr->id); - frag.proto = hdr->proto; - frag.src.addr = long_be(hdr->src.addr); - frag.dst.addr = long_be(hdr->dst.addr); - pfrag = pico_tree_findKey(&pico_ipv4_fragmented_tree, &frag); + pfrag = fragment_find_by_hdr(hdr); if (pfrag) { pfrag->total_len = (uint16_t)(pfrag->total_len + (short_be(hdr->len) - (*f)->net_len)); pico_tree_insert(pfrag->t, *f); @@ -308,11 +316,7 @@ } } else if (offset) { reassembly_dbg("REASSEMBLY: last element of a fragmented packet with id %X and offset %u\n", short_be(hdr->id), offset); - frag.id = short_be(hdr->id); - frag.proto = hdr->proto; - frag.src.addr = long_be(hdr->src.addr); - frag.dst.addr = long_be(hdr->dst.addr); - pfrag = pico_tree_findKey(&pico_ipv4_fragmented_tree, &frag); + pfrag = fragment_find_by_hdr(hdr); if (pfrag) { pfrag->total_len = (uint16_t)(pfrag->total_len + (short_be(hdr->len) - (*f)->net_len)); reassembly_dbg("REASSEMBLY: fragmented packet in tree, reassemble packet of %u data bytes\n", pfrag->total_len); @@ -1317,6 +1321,27 @@ return NULL; } +struct pico_ipv4_link *pico_ipv4_link_by_dev_next(struct pico_device *dev, struct pico_ipv4_link *last) +{ + struct pico_tree_node *index = NULL; + struct pico_ipv4_link *link = NULL; + int valid = 0; + + if (last == NULL) + valid = 1; + + pico_tree_foreach(index, &Tree_dev_link) + { + link = index->keyValue; + if (link->dev == dev) { + if (last == link) + valid = 1; + else if (valid > 0) + return link; + } + } + return NULL; +} struct pico_device *pico_ipv4_link_find(struct pico_ip4 *address) {