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 RTOS
  • generic mbed Ethernet driver
  • high performance NXP LPC1768 specific Ethernet driver
  • Multi-threading support for mbed RTOS
  • Berkeley sockets and integration with the New Socket API
  • Fork of the apps running on top of the New Socket API
  • Scheduling 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.

Committer:
TASS Belgium NV
Date:
Mon Dec 16 11:25:54 2013 +0100
Revision:
131:4758606c9316
Parent:
70:cd218dd180e5
Child:
134:cc4e6d2654d9
Syncronized with master branch

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tass 68:0847e35d08a6 1 /*********************************************************************
TASS Belgium NV 131:4758606c9316 2 PicoTCP. Copyright (c) 2012 TASS Belgium NV. Some rights reserved.
TASS Belgium NV 131:4758606c9316 3 See LICENSE and COPYING for usage.
tass 68:0847e35d08a6 4
TASS Belgium NV 131:4758606c9316 5 *********************************************************************/
tass 68:0847e35d08a6 6
tass 68:0847e35d08a6 7 #define DECLARE_HEAP(type, orderby) \
TASS Belgium NV 131:4758606c9316 8 struct heap_ ## type { \
TASS Belgium NV 131:4758606c9316 9 uint32_t size; \
TASS Belgium NV 131:4758606c9316 10 uint32_t n; \
TASS Belgium NV 131:4758606c9316 11 type *top; \
TASS Belgium NV 131:4758606c9316 12 }; \
TASS Belgium NV 131:4758606c9316 13 typedef struct heap_ ## type heap_ ## type; \
TASS Belgium NV 131:4758606c9316 14 static inline int heap_insert(struct heap_ ## type *heap, type * el) \
TASS Belgium NV 131:4758606c9316 15 { \
TASS Belgium NV 131:4758606c9316 16 uint32_t i; \
TASS Belgium NV 131:4758606c9316 17 type *newTop; \
TASS Belgium NV 131:4758606c9316 18 if (++heap->n >= heap->size) { \
TASS Belgium NV 131:4758606c9316 19 newTop = pico_zalloc((heap->n + 1) * sizeof(type)); \
TASS Belgium NV 131:4758606c9316 20 if(!newTop) \
TASS Belgium NV 131:4758606c9316 21 return -1; \
TASS Belgium NV 131:4758606c9316 22 if (heap->top) { \
TASS Belgium NV 131:4758606c9316 23 memcpy(newTop, heap->top, heap->n * sizeof(type)); \
TASS Belgium NV 131:4758606c9316 24 pico_free(heap->top); \
TASS Belgium NV 131:4758606c9316 25 } \
TASS Belgium NV 131:4758606c9316 26 heap->top = newTop; \
TASS Belgium NV 131:4758606c9316 27 heap->size++; \
TASS Belgium NV 131:4758606c9316 28 } \
TASS Belgium NV 131:4758606c9316 29 if (heap->n == 1) { \
TASS Belgium NV 131:4758606c9316 30 memcpy(&heap->top[1], el, sizeof(type)); \
TASS Belgium NV 131:4758606c9316 31 return 0; \
TASS Belgium NV 131:4758606c9316 32 } \
TASS Belgium NV 131:4758606c9316 33 for (i = heap->n; ((i > 1) && (heap->top[i / 2].orderby > el->orderby)); i /= 2) { \
TASS Belgium NV 131:4758606c9316 34 memcpy(&heap->top[i], &heap->top[i / 2], sizeof(type)); \
TASS Belgium NV 131:4758606c9316 35 } \
TASS Belgium NV 131:4758606c9316 36 memcpy(&heap->top[i], el, sizeof(type)); \
TASS Belgium NV 131:4758606c9316 37 return 0; \
tass 68:0847e35d08a6 38 } \
TASS Belgium NV 131:4758606c9316 39 static inline int heap_peek(struct heap_ ## type *heap, type * first) \
TASS Belgium NV 131:4758606c9316 40 { \
TASS Belgium NV 131:4758606c9316 41 type *last; \
TASS Belgium NV 131:4758606c9316 42 uint32_t i, child; \
TASS Belgium NV 131:4758606c9316 43 if(heap->n == 0) { \
TASS Belgium NV 131:4758606c9316 44 return -1; \
TASS Belgium NV 131:4758606c9316 45 } \
TASS Belgium NV 131:4758606c9316 46 memcpy(first, &heap->top[1], sizeof(type)); \
TASS Belgium NV 131:4758606c9316 47 last = &heap->top[heap->n--]; \
TASS Belgium NV 131:4758606c9316 48 for(i = 1; (i * 2) <= heap->n; i = child) { \
TASS Belgium NV 131:4758606c9316 49 child = 2 * i; \
TASS Belgium NV 131:4758606c9316 50 if ((child != heap->n) && \
TASS Belgium NV 131:4758606c9316 51 (heap->top[child + 1]).orderby \
TASS Belgium NV 131:4758606c9316 52 < (heap->top[child]).orderby) \
TASS Belgium NV 131:4758606c9316 53 child++; \
TASS Belgium NV 131:4758606c9316 54 if (last->orderby > \
TASS Belgium NV 131:4758606c9316 55 heap->top[child].orderby) \
TASS Belgium NV 131:4758606c9316 56 memcpy(&heap->top[i], &heap->top[child], \
TASS Belgium NV 131:4758606c9316 57 sizeof(type)); \
TASS Belgium NV 131:4758606c9316 58 else \
TASS Belgium NV 131:4758606c9316 59 break; \
TASS Belgium NV 131:4758606c9316 60 } \
TASS Belgium NV 131:4758606c9316 61 memcpy(&heap->top[i], last, sizeof(type)); \
TASS Belgium NV 131:4758606c9316 62 return 0; \
TASS Belgium NV 131:4758606c9316 63 } \
TASS Belgium NV 131:4758606c9316 64 static inline type *heap_first(heap_ ## type * heap) \
TASS Belgium NV 131:4758606c9316 65 { \
TASS Belgium NV 131:4758606c9316 66 if (heap->n == 0) \
TASS Belgium NV 131:4758606c9316 67 return NULL; \
TASS Belgium NV 131:4758606c9316 68 return &heap->top[1]; \
TASS Belgium NV 131:4758606c9316 69 } \
TASS Belgium NV 131:4758606c9316 70 static inline heap_ ## type *heap_init(void) \
TASS Belgium NV 131:4758606c9316 71 { \
TASS Belgium NV 131:4758606c9316 72 heap_ ## type * p = (heap_ ## type *)pico_zalloc(sizeof(heap_ ## type)); \
TASS Belgium NV 131:4758606c9316 73 return p; \
TASS Belgium NV 131:4758606c9316 74 } \
TASS Belgium NV 131:4758606c9316 75 static inline void heap_destroy(heap_ ## type * h) \
TASS Belgium NV 131:4758606c9316 76 { \
TASS Belgium NV 131:4758606c9316 77 pico_free(h->top); \
TASS Belgium NV 131:4758606c9316 78 pico_free(h); \
TASS Belgium NV 131:4758606c9316 79 } \
tass 68:0847e35d08a6 80
tass 68:0847e35d08a6 81