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
Date:
Thu Sep 19 13:26:14 2013 +0000
Revision:
68:0847e35d08a6
Child:
70:cd218dd180e5
Imported from masterbranch, again

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tass 68:0847e35d08a6 1 /*********************************************************************
tass 68:0847e35d08a6 2 PicoTCP. Copyright (c) 2012 TASS Belgium NV. Some rights reserved.
tass 68:0847e35d08a6 3 See LICENSE and COPYING for usage.
tass 68:0847e35d08a6 4
tass 68:0847e35d08a6 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 68:0847e35d08a6 10
tass 68:0847e35d08a6 11 extern volatile unsigned long long 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 68:0847e35d08a6 25
tass 68:0847e35d08a6 26 static inline uint16_t short_from(void *_p)
tass 68:0847e35d08a6 27 {
tass 68:0847e35d08a6 28 unsigned char *p = (unsigned char *)_p;
tass 68:0847e35d08a6 29 uint16_t r, p0, p1;
tass 68:0847e35d08a6 30 p0 = p[0];
tass 68:0847e35d08a6 31 p1 = p[1];
tass 68:0847e35d08a6 32 r = (p0 << 8) + p1;
tass 68:0847e35d08a6 33 return r;
tass 68:0847e35d08a6 34 }
tass 68:0847e35d08a6 35
tass 68:0847e35d08a6 36 static inline uint32_t long_from(void *_p)
tass 68:0847e35d08a6 37 {
tass 68:0847e35d08a6 38 unsigned char *p = (unsigned char *)_p;
tass 68:0847e35d08a6 39 uint32_t r, p0, p1, p2, p3;
tass 68:0847e35d08a6 40 p0 = p[0];
tass 68:0847e35d08a6 41 p1 = p[1];
tass 68:0847e35d08a6 42 p2 = p[2];
tass 68:0847e35d08a6 43 p3 = p[3];
tass 68:0847e35d08a6 44 r = (p0 << 24) + (p1 << 16) + (p2 << 8) + p3;
tass 68:0847e35d08a6 45 return r;
tass 68:0847e35d08a6 46 }
tass 68:0847e35d08a6 47
tass 68:0847e35d08a6 48 #else
tass 68:0847e35d08a6 49
tass 68:0847e35d08a6 50 static inline uint16_t short_from(void *_p)
tass 68:0847e35d08a6 51 {
tass 68:0847e35d08a6 52 unsigned char *p = (unsigned char *)_p;
tass 68:0847e35d08a6 53 uint16_t r, p0, p1;
tass 68:0847e35d08a6 54 p0 = p[0];
tass 68:0847e35d08a6 55 p1 = p[1];
tass 68:0847e35d08a6 56 r = (p1 << 8u) + p0;
tass 68:0847e35d08a6 57 return r;
tass 68:0847e35d08a6 58 }
tass 68:0847e35d08a6 59
tass 68:0847e35d08a6 60 static inline uint32_t long_from(void *_p)
tass 68:0847e35d08a6 61 {
tass 68:0847e35d08a6 62 unsigned char *p = (unsigned char *)_p;
tass 68:0847e35d08a6 63 uint32_t r, p0, p1, p2, p3;
tass 68:0847e35d08a6 64 p0 = p[0];
tass 68:0847e35d08a6 65 p1 = p[1];
tass 68:0847e35d08a6 66 p2 = p[2];
tass 68:0847e35d08a6 67 p3 = p[3];
tass 68:0847e35d08a6 68 r = (p3 << 24) + (p2 << 16) + (p1 << 8) + p0;
tass 68:0847e35d08a6 69 return r;
tass 68:0847e35d08a6 70 }
tass 68:0847e35d08a6 71
tass 68:0847e35d08a6 72
tass 68:0847e35d08a6 73 # define PICO_IDETH_IPV4 0x0008
tass 68:0847e35d08a6 74 # define PICO_IDETH_ARP 0x0608
tass 68:0847e35d08a6 75 # define PICO_IDETH_IPV6 0xDD86
tass 68:0847e35d08a6 76
tass 68:0847e35d08a6 77 # define PICO_ARP_REQUEST 0x0100
tass 68:0847e35d08a6 78 # define PICO_ARP_REPLY 0x0200
tass 68:0847e35d08a6 79 # define PICO_ARP_HTYPE_ETH 0x0100
tass 68:0847e35d08a6 80
tass 68:0847e35d08a6 81 static inline uint16_t short_be(uint16_t le)
tass 68:0847e35d08a6 82 {
tass 68:0847e35d08a6 83 return ((le & 0xFFu) << 8) | ((le >> 8u) & 0xFFu);
tass 68:0847e35d08a6 84 }
tass 68:0847e35d08a6 85
tass 68:0847e35d08a6 86 static inline uint32_t long_be(uint32_t le)
tass 68:0847e35d08a6 87 {
tass 68:0847e35d08a6 88 uint8_t *b = (uint8_t *)&le;
tass 68:0847e35d08a6 89 uint32_t be = 0;
tass 68:0847e35d08a6 90 uint32_t b0, b1, b2;
tass 68:0847e35d08a6 91 b0 = b[0];
tass 68:0847e35d08a6 92 b1 = b[1];
tass 68:0847e35d08a6 93 b2 = b[2];
tass 68:0847e35d08a6 94 be = b[3] + (b2 << 8) + (b1 << 16) + (b0 << 24);
tass 68:0847e35d08a6 95 return be;
tass 68:0847e35d08a6 96 }
tass 68:0847e35d08a6 97 #endif
tass 68:0847e35d08a6 98
tass 68:0847e35d08a6 99
tass 68:0847e35d08a6 100 /* Add well-known host numbers here. (bigendian constants only beyond this point) */
tass 68:0847e35d08a6 101 #define PICO_IP4_ANY (0x00000000U)
tass 68:0847e35d08a6 102 #define PICO_IP4_BCAST (0xffffffffU)
tass 68:0847e35d08a6 103
tass 68:0847e35d08a6 104 /* defined in modules/pico_ipv6.c */
tass 68:0847e35d08a6 105 #ifdef PICO_SUPPORT_IPV6
tass 68:0847e35d08a6 106 extern const uint8_t PICO_IPV6_ANY[PICO_SIZE_IP6];
tass 68:0847e35d08a6 107 #endif
tass 68:0847e35d08a6 108
tass 68:0847e35d08a6 109 static inline uint32_t pico_hash(const char *name)
tass 68:0847e35d08a6 110 {
tass 68:0847e35d08a6 111 unsigned long hash = 5381;
tass 68:0847e35d08a6 112 int c;
tass 68:0847e35d08a6 113 while ((c = *name++))
tass 68:0847e35d08a6 114 hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
tass 68:0847e35d08a6 115 return hash;
tass 68:0847e35d08a6 116 }
tass 68:0847e35d08a6 117
tass 68:0847e35d08a6 118 /* Debug */
tass 68:0847e35d08a6 119 //#define PICO_SUPPORT_DEBUG_MEMORY
tass 68:0847e35d08a6 120 //#define PICO_SUPPORT_DEBUG_TOOLS
tass 68:0847e35d08a6 121 #endif