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_PROTOCOL
tass 68:0847e35d08a6 7 #define _INCLUDE_PICO_PROTOCOL
tass 68:0847e35d08a6 8 #include <stdint.h>
tass 68:0847e35d08a6 9 #include "pico_queue.h"
tass 68:0847e35d08a6 10
tass 68:0847e35d08a6 11 #define PICO_LOOP_DIR_IN 1
tass 68:0847e35d08a6 12 #define PICO_LOOP_DIR_OUT 2
tass 68:0847e35d08a6 13
tass 68:0847e35d08a6 14 enum pico_layer {
tass 68:0847e35d08a6 15 PICO_LAYER_DATALINK = 2, /* Ethernet only. */
tass 68:0847e35d08a6 16 PICO_LAYER_NETWORK = 3, /* IPv4, IPv6, ARP. Arp is there because it communicates with L2 */
tass 68:0847e35d08a6 17 PICO_LAYER_TRANSPORT = 4, /* UDP, TCP, ICMP */
tass 68:0847e35d08a6 18 PICO_LAYER_SOCKET = 5 /* Socket management */
tass 68:0847e35d08a6 19 };
tass 68:0847e35d08a6 20
tass 68:0847e35d08a6 21 enum pico_err_e {
tass 68:0847e35d08a6 22 PICO_ERR_NOERR = 0,
tass 68:0847e35d08a6 23 PICO_ERR_EPERM,
tass 68:0847e35d08a6 24 PICO_ERR_ENOENT,
tass 68:0847e35d08a6 25 /* ... */
tass 68:0847e35d08a6 26 PICO_ERR_EINTR = 4,
tass 68:0847e35d08a6 27 PICO_ERR_EIO,
tass 68:0847e35d08a6 28 PICO_ERR_ENXIO,
tass 68:0847e35d08a6 29 /* ... */
tass 68:0847e35d08a6 30 PICO_ERR_EAGAIN = 11,
tass 68:0847e35d08a6 31 PICO_ERR_ENOMEM,
tass 68:0847e35d08a6 32 PICO_ERR_EACCESS,
tass 68:0847e35d08a6 33 PICO_ERR_EFAULT,
tass 68:0847e35d08a6 34 /* ... */
tass 68:0847e35d08a6 35 PICO_ERR_EBUSY = 16,
tass 68:0847e35d08a6 36 PICO_ERR_EEXIST = 17,
tass 68:0847e35d08a6 37 /* ... */
tass 68:0847e35d08a6 38 PICO_ERR_EINVAL = 22,
tass 68:0847e35d08a6 39 /* ... */
tass 68:0847e35d08a6 40 PICO_ERR_EPROTO = 71,
tass 68:0847e35d08a6 41 PICO_ERR_ENOPROTOOPT = 92,
tass 68:0847e35d08a6 42 PICO_ERR_EPROTONOSUPPORT = 93,
tass 68:0847e35d08a6 43
tass 68:0847e35d08a6 44 /* ... */
tass 68:0847e35d08a6 45 PICO_ERR_EADDRINUSE = 98,
tass 68:0847e35d08a6 46 PICO_ERR_EADDRNOTAVAIL,
tass 68:0847e35d08a6 47 PICO_ERR_ENETUNREACH,
tass 68:0847e35d08a6 48
tass 68:0847e35d08a6 49 /* ... */
tass 68:0847e35d08a6 50 PICO_ERR_ECONNRESET = 104,
tass 68:0847e35d08a6 51
tass 68:0847e35d08a6 52 /* ... */
tass 68:0847e35d08a6 53 PICO_ERR_EISCONN = 106,
tass 68:0847e35d08a6 54 PICO_ERR_ENOTCONN,
tass 68:0847e35d08a6 55 PICO_ERR_ESHUTDOWN,
tass 68:0847e35d08a6 56 /* ... */
tass 68:0847e35d08a6 57 PICO_ERR_ETIMEDOUT = 110,
tass 68:0847e35d08a6 58 PICO_ERR_ECONNREFUSED = 111,
tass 68:0847e35d08a6 59 PICO_ERR_EHOSTDOWN,
tass 68:0847e35d08a6 60 PICO_ERR_EHOSTUNREACH,
tass 68:0847e35d08a6 61 /* ... */
tass 68:0847e35d08a6 62 PICO_ERR_EOPNOTSUPP = 122,
tass 68:0847e35d08a6 63
tass 68:0847e35d08a6 64 };
tass 68:0847e35d08a6 65
tass 68:0847e35d08a6 66 typedef enum pico_err_e pico_err_t;
tass 68:0847e35d08a6 67 extern volatile pico_err_t pico_err;
tass 68:0847e35d08a6 68
tass 68:0847e35d08a6 69 #define IS_IPV6(f) ((((uint8_t *)(f->net_hdr))[0] & 0xf0) == 0x60)
tass 68:0847e35d08a6 70 #define IS_IPV4(f) ((((uint8_t *)(f->net_hdr))[0] & 0xf0) == 0x40)
tass 68:0847e35d08a6 71
tass 68:0847e35d08a6 72 #define MAX_PROTOCOL_NAME 16
tass 68:0847e35d08a6 73
tass 68:0847e35d08a6 74 struct pico_protocol {
tass 68:0847e35d08a6 75 const char name[MAX_PROTOCOL_NAME];
tass 68:0847e35d08a6 76 uint32_t hash;
tass 68:0847e35d08a6 77 const enum pico_layer layer;
tass 68:0847e35d08a6 78 const int proto_number;
tass 68:0847e35d08a6 79 struct pico_queue * const q_in;
tass 68:0847e35d08a6 80 struct pico_queue * const q_out;
tass 68:0847e35d08a6 81 struct pico_frame *(* const alloc)(struct pico_protocol *self, int size); /* Frame allocation. */
tass 68:0847e35d08a6 82 int (* const push) (struct pico_protocol *self, struct pico_frame *p); /* Push function, for active outgoing pkts from above */
tass 68:0847e35d08a6 83 int (* const process_out)(struct pico_protocol *self, struct pico_frame *p); /* Send loop. */
tass 68:0847e35d08a6 84 int (* const process_in)(struct pico_protocol *self, struct pico_frame *p); /* Recv loop. */
tass 68:0847e35d08a6 85 };
tass 68:0847e35d08a6 86
tass 68:0847e35d08a6 87 int pico_protocols_loop(int loop_score);
tass 68:0847e35d08a6 88 void pico_protocol_init(struct pico_protocol *p);
tass 68:0847e35d08a6 89
tass 68:0847e35d08a6 90 int pico_protocol_datalink_loop(int loop_score, int direction);
tass 68:0847e35d08a6 91 int pico_protocol_network_loop(int loop_score, int direction);
tass 68:0847e35d08a6 92 int pico_protocol_transport_loop(int loop_score, int direction);
tass 68:0847e35d08a6 93 int pico_protocol_socket_loop(int loop_score, int direction);
tass 68:0847e35d08a6 94
tass 68:0847e35d08a6 95 #endif