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:
128:ae39e6e81531
Child:
133:5b075f5e141a
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 #ifndef _INCLUDE_PICO_CONST
tass 68:0847e35d08a6 7 #define _INCLUDE_PICO_CONST
tass 68:0847e35d08a6 8 /* Included from pico_config.h */
tass 68:0847e35d08a6 9 /** Endian-dependant constants **/
tass 128:ae39e6e81531 10 typedef uint64_t pico_time;
tass 128:ae39e6e81531 11 extern volatile uint64_t pico_tick;
tass 68:0847e35d08a6 12
tass 68:0847e35d08a6 13 #ifdef PICO_BIGENDIAN
tass 68:0847e35d08a6 14
tass 68:0847e35d08a6 15 # define PICO_IDETH_IPV4 0x0800
tass 68:0847e35d08a6 16 # define PICO_IDETH_ARP 0x0806
tass 68:0847e35d08a6 17 # define PICO_IDETH_IPV6 0x86DD
tass 68:0847e35d08a6 18
tass 68:0847e35d08a6 19 # define PICO_ARP_REQUEST 0x0001
tass 68:0847e35d08a6 20 # define PICO_ARP_REPLY 0x0002
tass 68:0847e35d08a6 21 # define PICO_ARP_HTYPE_ETH 0x0001
tass 68:0847e35d08a6 22
tass 68:0847e35d08a6 23 #define short_be(x) (x)
tass 68:0847e35d08a6 24 #define long_be(x) (x)
tass 70:cd218dd180e5 25 #define long_long_be(x) (x)
tass 68:0847e35d08a6 26
tass 68:0847e35d08a6 27 static inline uint16_t short_from(void *_p)
tass 68:0847e35d08a6 28 {
TASS Belgium NV 131:4758606c9316 29 unsigned char *p = (unsigned char *)_p;
TASS Belgium NV 131:4758606c9316 30 uint16_t r, p0, p1;
TASS Belgium NV 131:4758606c9316 31 p0 = p[0];
TASS Belgium NV 131:4758606c9316 32 p1 = p[1];
TASS Belgium NV 131:4758606c9316 33 r = (p0 << 8) + p1;
TASS Belgium NV 131:4758606c9316 34 return r;
tass 68:0847e35d08a6 35 }
tass 68:0847e35d08a6 36
tass 68:0847e35d08a6 37 static inline uint32_t long_from(void *_p)
tass 68:0847e35d08a6 38 {
TASS Belgium NV 131:4758606c9316 39 unsigned char *p = (unsigned char *)_p;
TASS Belgium NV 131:4758606c9316 40 uint32_t r, p0, p1, p2, p3;
TASS Belgium NV 131:4758606c9316 41 p0 = p[0];
TASS Belgium NV 131:4758606c9316 42 p1 = p[1];
TASS Belgium NV 131:4758606c9316 43 p2 = p[2];
TASS Belgium NV 131:4758606c9316 44 p3 = p[3];
TASS Belgium NV 131:4758606c9316 45 r = (p0 << 24) + (p1 << 16) + (p2 << 8) + p3;
TASS Belgium NV 131:4758606c9316 46 return r;
tass 68:0847e35d08a6 47 }
tass 68:0847e35d08a6 48
tass 68:0847e35d08a6 49 #else
tass 68:0847e35d08a6 50
tass 68:0847e35d08a6 51 static inline uint16_t short_from(void *_p)
tass 68:0847e35d08a6 52 {
TASS Belgium NV 131:4758606c9316 53 unsigned char *p = (unsigned char *)_p;
TASS Belgium NV 131:4758606c9316 54 uint16_t r, _p0, _p1;
TASS Belgium NV 131:4758606c9316 55 _p0 = p[0];
TASS Belgium NV 131:4758606c9316 56 _p1 = p[1];
TASS Belgium NV 131:4758606c9316 57 r = (uint16_t)((_p1 << 8u) + _p0);
TASS Belgium NV 131:4758606c9316 58 return r;
tass 68:0847e35d08a6 59 }
tass 68:0847e35d08a6 60
tass 68:0847e35d08a6 61 static inline uint32_t long_from(void *_p)
tass 68:0847e35d08a6 62 {
TASS Belgium NV 131:4758606c9316 63 unsigned char *p = (unsigned char *)_p;
TASS Belgium NV 131:4758606c9316 64 uint32_t r, _p0, _p1, _p2, _p3;
TASS Belgium NV 131:4758606c9316 65 _p0 = p[0];
TASS Belgium NV 131:4758606c9316 66 _p1 = p[1];
TASS Belgium NV 131:4758606c9316 67 _p2 = p[2];
TASS Belgium NV 131:4758606c9316 68 _p3 = p[3];
TASS Belgium NV 131:4758606c9316 69 r = (_p3 << 24) + (_p2 << 16) + (_p1 << 8) + _p0;
TASS Belgium NV 131:4758606c9316 70 return r;
tass 68:0847e35d08a6 71 }
tass 68:0847e35d08a6 72
tass 68:0847e35d08a6 73
tass 68:0847e35d08a6 74 # define PICO_IDETH_IPV4 0x0008
tass 68:0847e35d08a6 75 # define PICO_IDETH_ARP 0x0608
tass 68:0847e35d08a6 76 # define PICO_IDETH_IPV6 0xDD86
tass 68:0847e35d08a6 77
tass 68:0847e35d08a6 78 # define PICO_ARP_REQUEST 0x0100
tass 68:0847e35d08a6 79 # define PICO_ARP_REPLY 0x0200
tass 68:0847e35d08a6 80 # define PICO_ARP_HTYPE_ETH 0x0100
tass 68:0847e35d08a6 81
tass 68:0847e35d08a6 82 static inline uint16_t short_be(uint16_t le)
tass 68:0847e35d08a6 83 {
TASS Belgium NV 131:4758606c9316 84 return (uint16_t)(((le & 0xFFu) << 8) | ((le >> 8u) & 0xFFu));
tass 68:0847e35d08a6 85 }
tass 68:0847e35d08a6 86
tass 68:0847e35d08a6 87 static inline uint32_t long_be(uint32_t le)
tass 68:0847e35d08a6 88 {
TASS Belgium NV 131:4758606c9316 89 uint8_t *b = (uint8_t *)&le;
TASS Belgium NV 131:4758606c9316 90 uint32_t be = 0;
TASS Belgium NV 131:4758606c9316 91 uint32_t b0, b1, b2;
TASS Belgium NV 131:4758606c9316 92 b0 = b[0];
TASS Belgium NV 131:4758606c9316 93 b1 = b[1];
TASS Belgium NV 131:4758606c9316 94 b2 = b[2];
TASS Belgium NV 131:4758606c9316 95 be = b[3] + (b2 << 8) + (b1 << 16) + (b0 << 24);
TASS Belgium NV 131:4758606c9316 96 return be;
tass 68:0847e35d08a6 97 }
tass 70:cd218dd180e5 98 static inline uint64_t long_long_be(uint64_t le)
tass 70:cd218dd180e5 99 {
TASS Belgium NV 131:4758606c9316 100 uint8_t *b = (uint8_t *)&le;
TASS Belgium NV 131:4758606c9316 101 uint64_t be = 0;
TASS Belgium NV 131:4758606c9316 102 uint64_t b0, b1, b2, b3, b4, b5, b6;
TASS Belgium NV 131:4758606c9316 103 b0 = b[0];
TASS Belgium NV 131:4758606c9316 104 b1 = b[1];
TASS Belgium NV 131:4758606c9316 105 b2 = b[2];
TASS Belgium NV 131:4758606c9316 106 b3 = b[3];
TASS Belgium NV 131:4758606c9316 107 b4 = b[4];
TASS Belgium NV 131:4758606c9316 108 b5 = b[5];
TASS Belgium NV 131:4758606c9316 109 b6 = b[6];
TASS Belgium NV 131:4758606c9316 110 be = b[7] + (b6 << 8) + (b5 << 16) + (b4 << 24) + (b3 << 32) + (b2 << 40) + (b1 << 48) + (b0 << 56);
TASS Belgium NV 131:4758606c9316 111 return be;
tass 70:cd218dd180e5 112 }
tass 68:0847e35d08a6 113 #endif
tass 68:0847e35d08a6 114
tass 68:0847e35d08a6 115
tass 68:0847e35d08a6 116 /* Add well-known host numbers here. (bigendian constants only beyond this point) */
tass 68:0847e35d08a6 117 #define PICO_IP4_ANY (0x00000000U)
tass 68:0847e35d08a6 118 #define PICO_IP4_BCAST (0xffffffffU)
tass 68:0847e35d08a6 119
tass 68:0847e35d08a6 120 /* defined in modules/pico_ipv6.c */
tass 68:0847e35d08a6 121 #ifdef PICO_SUPPORT_IPV6
tass 68:0847e35d08a6 122 extern const uint8_t PICO_IPV6_ANY[PICO_SIZE_IP6];
tass 68:0847e35d08a6 123 #endif
tass 68:0847e35d08a6 124
tass 68:0847e35d08a6 125 static inline uint32_t pico_hash(const char *name)
tass 68:0847e35d08a6 126 {
TASS Belgium NV 131:4758606c9316 127 uint32_t hash = 5381;
TASS Belgium NV 131:4758606c9316 128 uint8_t c;
TASS Belgium NV 131:4758606c9316 129 while ((c = (uint8_t)*name++))
TASS Belgium NV 131:4758606c9316 130 hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
TASS Belgium NV 131:4758606c9316 131 return hash;
tass 68:0847e35d08a6 132 }
tass 68:0847e35d08a6 133
tass 68:0847e35d08a6 134 /* Debug */
TASS Belgium NV 131:4758606c9316 135 /* #define PICO_SUPPORT_DEBUG_MEMORY */
TASS Belgium NV 131:4758606c9316 136 /* #define PICO_SUPPORT_DEBUG_TOOLS */
tass 68:0847e35d08a6 137 #endif