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.
Revision 134:cc4e6d2654d9, committed 2014-01-16
- Comitter:
- tass picotcp@tass.be
- Date:
- Thu Jan 16 14:46:07 2014 +0100
- Parent:
- 133:5b075f5e141a
- Child:
- 135:a064a384eae6
- Commit message:
- Update from masterbranch
Changed in this revision
--- a/include/heap.h Thu Jan 16 10:13:37 2014 +0100 +++ b/include/heap.h Thu Jan 16 14:46:07 2014 +0100 @@ -72,10 +72,10 @@ heap_ ## type * p = (heap_ ## type *)pico_zalloc(sizeof(heap_ ## type)); \ return p; \ } \ - static inline void heap_destroy(heap_ ## type * h) \ + /*static inline void heap_destroy(heap_ ## type * h) \ { \ pico_free(h->top); \ pico_free(h); \ - } \ + } \*/
--- a/include/pico_protocol.h Thu Jan 16 10:13:37 2014 +0100 +++ b/include/pico_protocol.h Thu Jan 16 14:46:07 2014 +0100 @@ -72,16 +72,16 @@ #define MAX_PROTOCOL_NAME 16 struct pico_protocol { - const char name[MAX_PROTOCOL_NAME]; + char name[MAX_PROTOCOL_NAME]; uint32_t hash; - const enum pico_layer layer; - const uint16_t proto_number; - struct pico_queue *const q_in; - struct pico_queue *const q_out; - struct pico_frame *(*const alloc)(struct pico_protocol *self, uint16_t size); /* Frame allocation. */ - int (*const push) (struct pico_protocol *self, struct pico_frame *p); /* Push function, for active outgoing pkts from above */ - int (*const process_out) (struct pico_protocol *self, struct pico_frame *p); /* Send loop. */ - int (*const process_in) (struct pico_protocol *self, struct pico_frame *p); /* Recv loop. */ + enum pico_layer layer; + uint16_t proto_number; + struct pico_queue *q_in; + struct pico_queue *q_out; + struct pico_frame *(*alloc)(struct pico_protocol *self, uint16_t size); /* Frame allocation. */ + int (*push) (struct pico_protocol *self, struct pico_frame *p); /* Push function, for active outgoing pkts from above */ + int (*process_out) (struct pico_protocol *self, struct pico_frame *p); /* Send loop. */ + int (*process_in) (struct pico_protocol *self, struct pico_frame *p); /* Recv loop. */ }; int pico_protocols_loop(int loop_score);
--- a/modules/pico_dev_mbed.cpp Thu Jan 16 10:13:37 2014 +0100 +++ b/modules/pico_dev_mbed.cpp Thu Jan 16 14:46:07 2014 +0100 @@ -27,7 +27,6 @@ static int pico_mbed_send(struct pico_device *dev, void *buf, int len) { int ret, sent; - struct pico_device_mbed *mb = (struct pico_device_mbed *) dev; if (len > ETH_MTU) return -1; @@ -46,17 +45,16 @@ static int pico_mbed_poll(struct pico_device *dev, int loop_score) { int len; - struct pico_device_mbed *mb = (struct pico_device_mbed *) dev; - + while(loop_score > 0) { /* check for new frame(s) */ len = (int) ethernet_receive(); - + /* return if no frame has arrived */ if (!len) return loop_score; - + /* read and process frame */ len = ethernet_read((char*)buf, ETH_MTU); printf("ETH> recv %d bytes: %x:%x\r\n", len, buf[0],buf[1]); @@ -113,4 +111,4 @@ ethernet_address(mac); } -} \ No newline at end of file +}
--- a/modules/pico_dns_client.c Thu Jan 16 10:13:37 2014 +0100 +++ b/modules/pico_dns_client.c Thu Jan 16 14:46:07 2014 +0100 @@ -289,14 +289,11 @@ /* determine len of string */ static uint16_t pico_dns_client_strlen(const char *url) { - char p = 0; - uint16_t len = 0; + uint16_t len; - if (!url) - return 0; - - while ((p = *url++) != 0) { - len++; + for (len=0; len<0xFFFF; len++) { + if (url[len] == 0) + break; } return len; } @@ -304,12 +301,12 @@ /* seek end of string */ static char *pico_dns_client_seek(char *ptr) { - char p = 0; - if (!ptr) return NULL; - while ((p = *ptr++) != 0) ; + while (*ptr != 0) + ptr++; + return ptr++; } @@ -776,7 +773,7 @@ return 0; } -int pico_dns_client_init() +int pico_dns_client_init(void) { struct pico_ip4 default_ns = { 0
--- a/modules/pico_dns_client.h Thu Jan 16 10:13:37 2014 +0100 +++ b/modules/pico_dns_client.h Thu Jan 16 14:46:07 2014 +0100 @@ -14,7 +14,7 @@ #define PICO_DNS_NS_ADD 1 #include <stdint.h> -int pico_dns_client_init(); +int pico_dns_client_init(void); /* flag is PICO_DNS_NS_DEL or PICO_DNS_NS_ADD */ int pico_dns_client_nameserver(struct pico_ip4 *ns, uint8_t flag); int pico_dns_client_getaddr(const char *url, void (*callback)(char *ip, void *arg), void *arg);
--- a/modules/pico_http_client.c Thu Jan 16 10:13:37 2014 +0100 +++ b/modules/pico_http_client.c Thu Jan 16 14:46:07 2014 +0100 @@ -414,8 +414,8 @@ readSmallChunk(client, data, size, &lenRead); - - if((value = readBigChunk(client, data, size, &lenRead))) + value = readBigChunk(client, data, size, &lenRead); + if(value) return value; return lenRead;
--- a/modules/pico_http_server.c Thu Jan 16 10:13:37 2014 +0100 +++ b/modules/pico_http_server.c Thu Jan 16 14:46:07 2014 +0100 @@ -586,7 +586,8 @@ { uint16_t length; while( client->bufferSent < client->bufferSize && - (length = (uint16_t)pico_socket_write(client->sck, client->buffer + client->bufferSent, client->bufferSize - client->bufferSent)) > 0 ) + (length = (uint16_t)pico_socket_write(client->sck, client->buffer + client->bufferSent, \ + client->bufferSize - client->bufferSent)) > 0 ) { client->bufferSent = (uint16_t)(client->bufferSent + length); server.wakeup(EV_HTTP_PROGRESS, client->connectionID);
--- a/stack/pico_arp.c Thu Jan 16 10:13:37 2014 +0100 +++ b/stack/pico_arp.c Thu Jan 16 14:46:07 2014 +0100 @@ -355,7 +355,7 @@ struct pico_frame *q = pico_frame_alloc(PICO_SIZE_ETHHDR + PICO_SIZE_ARPHDR); struct pico_eth_hdr *eh; struct pico_arp_hdr *ah; - struct pico_ip4 *src; + struct pico_ip4 *src=NULL; int ret; if (type == PICO_ARP_QUERY) @@ -395,7 +395,7 @@ ah->src.addr = 0; ah->dst.addr = dst->addr; break; - default: + case PICO_ARP_QUERY: ah->src.addr = src->addr; ah->dst.addr = dst->addr; }
--- a/stack/pico_socket.c Thu Jan 16 10:13:37 2014 +0100 +++ b/stack/pico_socket.c Thu Jan 16 14:46:07 2014 +0100 @@ -377,7 +377,6 @@ } so_mcast_dbg("MCAST: IP %08X NOT in included socket source list\n", src->addr); return -1; - break; case PICO_IP_MULTICAST_EXCLUDE: pico_tree_foreach(index, &listen->MCASTSources) @@ -389,11 +388,6 @@ } so_mcast_dbg("MCAST: IP %08X NOT in excluded socket source list\n", src->addr); return 0; - break; - - default: - return -1; - break; } return -1; } @@ -1100,6 +1094,7 @@ int socket_mtu = PICO_SOCKET4_MTU; int header_offset = 0; int total_payload_written = 0; + #ifdef PICO_SUPPORT_IPV4 struct pico_ip4 *src4; #endif @@ -1280,7 +1275,7 @@ return total_payload_written; } - memcpy(f->payload, buf + total_payload_written, f->payload_len); + memcpy(f->payload, (const uint8_t *)buf + total_payload_written, f->payload_len); /* dbg("Pushing segment, hdr len: %d, payload_len: %d\n", header_offset, f->payload_len); */ if (s->proto->push(s->proto, f) > 0) { @@ -1673,7 +1668,6 @@ case PICO_IP_MULTICAST_IF: pico_err = PICO_ERR_EOPNOTSUPP; return -1; - break; case PICO_IP_MULTICAST_TTL: if (s->proto->proto_number == PICO_PROTO_UDP) { @@ -2056,7 +2050,6 @@ case PICO_IP_MULTICAST_IF: pico_err = PICO_ERR_EOPNOTSUPP; return -1; - break; case PICO_IP_MULTICAST_TTL: if (s->proto->proto_number == PICO_PROTO_UDP) {
--- a/stack/pico_stack.c Thu Jan 16 10:13:37 2014 +0100 +++ b/stack/pico_stack.c Thu Jan 16 14:46:07 2014 +0100 @@ -304,8 +304,9 @@ struct pico_ipv4_hdr *hdr = (struct pico_ipv4_hdr *) f->net_hdr; return pico_ipv4_is_broadcast(hdr->dst.addr); } +#else + return 0; #endif - return 0; } #ifdef PICO_SUPPORT_MCAST @@ -322,8 +323,9 @@ struct pico_ipv4_hdr *hdr = (struct pico_ipv4_hdr *) f->net_hdr; return pico_ipv4_is_multicast(hdr->dst.addr); } +#else + return 0; #endif - return 0; } static struct pico_eth *pico_ethernet_mcast_translate(struct pico_frame *f, uint8_t *pico_mcast_mac) @@ -360,7 +362,7 @@ else if (IS_IPV4(f)) { if (IS_BCAST(f) || destination_is_bcast(f)) { - dstmac = (const struct pico_eth *const) PICO_ETHADDR_ALL; + dstmac = (const struct pico_eth *) PICO_ETHADDR_ALL; } #ifdef PICO_SUPPORT_MCAST