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 26 07:05:22 2013 +0000
Revision:
70:cd218dd180e5
Parent:
68:0847e35d08a6
Child:
73:dfb737147f6e
Update from masterbranch

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 70:cd218dd180e5 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 68:0847e35d08a6 29 unsigned char *p = (unsigned char *)_p;
tass 68:0847e35d08a6 30 uint16_t r, p0, p1;
tass 68:0847e35d08a6 31 p0 = p[0];
tass 68:0847e35d08a6 32 p1 = p[1];
tass 68:0847e35d08a6 33 r = (p0 << 8) + p1;
tass 68:0847e35d08a6 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 68:0847e35d08a6 39 unsigned char *p = (unsigned char *)_p;
tass 68:0847e35d08a6 40 uint32_t r, p0, p1, p2, p3;
tass 68:0847e35d08a6 41 p0 = p[0];
tass 68:0847e35d08a6 42 p1 = p[1];
tass 68:0847e35d08a6 43 p2 = p[2];
tass 68:0847e35d08a6 44 p3 = p[3];
tass 68:0847e35d08a6 45 r = (p0 << 24) + (p1 << 16) + (p2 << 8) + p3;
tass 68:0847e35d08a6 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 68:0847e35d08a6 53 unsigned char *p = (unsigned char *)_p;
tass 68:0847e35d08a6 54 uint16_t r, p0, p1;
tass 68:0847e35d08a6 55 p0 = p[0];
tass 68:0847e35d08a6 56 p1 = p[1];
tass 70:cd218dd180e5 57 r = (uint16_t)((p1 << 8u) + p0);
tass 68:0847e35d08a6 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 68:0847e35d08a6 63 unsigned char *p = (unsigned char *)_p;
tass 68:0847e35d08a6 64 uint32_t r, p0, p1, p2, p3;
tass 68:0847e35d08a6 65 p0 = p[0];
tass 68:0847e35d08a6 66 p1 = p[1];
tass 68:0847e35d08a6 67 p2 = p[2];
tass 68:0847e35d08a6 68 p3 = p[3];
tass 68:0847e35d08a6 69 r = (p3 << 24) + (p2 << 16) + (p1 << 8) + p0;
tass 68:0847e35d08a6 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 70:cd218dd180e5 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 68:0847e35d08a6 89 uint8_t *b = (uint8_t *)&le;
tass 68:0847e35d08a6 90 uint32_t be = 0;
tass 68:0847e35d08a6 91 uint32_t b0, b1, b2;
tass 68:0847e35d08a6 92 b0 = b[0];
tass 68:0847e35d08a6 93 b1 = b[1];
tass 68:0847e35d08a6 94 b2 = b[2];
tass 68:0847e35d08a6 95 be = b[3] + (b2 << 8) + (b1 << 16) + (b0 << 24);
tass 68:0847e35d08a6 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 70:cd218dd180e5 100 uint8_t *b = (uint8_t *)&le;
tass 70:cd218dd180e5 101 uint64_t be = 0;
tass 70:cd218dd180e5 102 uint64_t b0, b1, b2, b3, b4, b5, b6;
tass 70:cd218dd180e5 103 b0 = b[0];
tass 70:cd218dd180e5 104 b1 = b[1];
tass 70:cd218dd180e5 105 b2 = b[2];
tass 70:cd218dd180e5 106 b3 = b[3];
tass 70:cd218dd180e5 107 b4 = b[4];
tass 70:cd218dd180e5 108 b5 = b[5];
tass 70:cd218dd180e5 109 b6 = b[6];
tass 70:cd218dd180e5 110 be = b[7] + (b6 << 8) + (b5 << 16) + (b4 << 24) + (b3 << 32) + (b2 << 40) + (b1 << 48) + (b0 << 56);
tass 70:cd218dd180e5 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 68:0847e35d08a6 127 unsigned long hash = 5381;
tass 70:cd218dd180e5 128 int8_t c;
tass 68:0847e35d08a6 129 while ((c = *name++))
tass 70:cd218dd180e5 130 hash = ((hash << 5) + hash) + (unsigned long)c; /* hash * 33 + c */
tass 68:0847e35d08a6 131 return hash;
tass 68:0847e35d08a6 132 }
tass 68:0847e35d08a6 133
tass 68:0847e35d08a6 134 /* Debug */
tass 68:0847e35d08a6 135 //#define PICO_SUPPORT_DEBUG_MEMORY
tass 68:0847e35d08a6 136 //#define PICO_SUPPORT_DEBUG_TOOLS
tass 68:0847e35d08a6 137 #endif