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 Belgium NV 131:4758606c9316 6 #ifndef _INCLUDE_PICO_PROTOCOL
TASS Belgium NV 131:4758606c9316 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 Belgium NV 131:4758606c9316 15 PICO_LAYER_DATALINK = 2, /* Ethernet only. */
TASS Belgium NV 131:4758606c9316 16 PICO_LAYER_NETWORK = 3, /* IPv4, IPv6, ARP. Arp is there because it communicates with L2 */
TASS Belgium NV 131:4758606c9316 17 PICO_LAYER_TRANSPORT = 4, /* UDP, TCP, ICMP */
TASS Belgium NV 131:4758606c9316 18 PICO_LAYER_SOCKET = 5 /* Socket management */
tass 68:0847e35d08a6 19 };
tass 68:0847e35d08a6 20
tass 68:0847e35d08a6 21 enum pico_err_e {
TASS Belgium NV 131:4758606c9316 22 PICO_ERR_NOERR = 0,
TASS Belgium NV 131:4758606c9316 23 PICO_ERR_EPERM,
TASS Belgium NV 131:4758606c9316 24 PICO_ERR_ENOENT,
TASS Belgium NV 131:4758606c9316 25 /* ... */
TASS Belgium NV 131:4758606c9316 26 PICO_ERR_EINTR = 4,
TASS Belgium NV 131:4758606c9316 27 PICO_ERR_EIO,
TASS Belgium NV 131:4758606c9316 28 PICO_ERR_ENXIO,
TASS Belgium NV 131:4758606c9316 29 /* ... */
TASS Belgium NV 131:4758606c9316 30 PICO_ERR_EAGAIN = 11,
TASS Belgium NV 131:4758606c9316 31 PICO_ERR_ENOMEM,
TASS Belgium NV 131:4758606c9316 32 PICO_ERR_EACCESS,
TASS Belgium NV 131:4758606c9316 33 PICO_ERR_EFAULT,
TASS Belgium NV 131:4758606c9316 34 /* ... */
TASS Belgium NV 131:4758606c9316 35 PICO_ERR_EBUSY = 16,
TASS Belgium NV 131:4758606c9316 36 PICO_ERR_EEXIST = 17,
TASS Belgium NV 131:4758606c9316 37 /* ... */
TASS Belgium NV 131:4758606c9316 38 PICO_ERR_EINVAL = 22,
TASS Belgium NV 131:4758606c9316 39 /* ... */
TASS Belgium NV 131:4758606c9316 40 PICO_ERR_EPROTO = 71,
TASS Belgium NV 131:4758606c9316 41 PICO_ERR_ENOPROTOOPT = 92,
TASS Belgium NV 131:4758606c9316 42 PICO_ERR_EPROTONOSUPPORT = 93,
tass 68:0847e35d08a6 43
TASS Belgium NV 131:4758606c9316 44 /* ... */
TASS Belgium NV 131:4758606c9316 45 PICO_ERR_EADDRINUSE = 98,
TASS Belgium NV 131:4758606c9316 46 PICO_ERR_EADDRNOTAVAIL,
TASS Belgium NV 131:4758606c9316 47 PICO_ERR_ENETUNREACH,
tass 68:0847e35d08a6 48
TASS Belgium NV 131:4758606c9316 49 /* ... */
TASS Belgium NV 131:4758606c9316 50 PICO_ERR_ECONNRESET = 104,
tass 68:0847e35d08a6 51
TASS Belgium NV 131:4758606c9316 52 /* ... */
TASS Belgium NV 131:4758606c9316 53 PICO_ERR_EISCONN = 106,
TASS Belgium NV 131:4758606c9316 54 PICO_ERR_ENOTCONN,
TASS Belgium NV 131:4758606c9316 55 PICO_ERR_ESHUTDOWN,
TASS Belgium NV 131:4758606c9316 56 /* ... */
TASS Belgium NV 131:4758606c9316 57 PICO_ERR_ETIMEDOUT = 110,
TASS Belgium NV 131:4758606c9316 58 PICO_ERR_ECONNREFUSED = 111,
TASS Belgium NV 131:4758606c9316 59 PICO_ERR_EHOSTDOWN,
TASS Belgium NV 131:4758606c9316 60 PICO_ERR_EHOSTUNREACH,
TASS Belgium NV 131:4758606c9316 61 /* ... */
TASS Belgium NV 131:4758606c9316 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 Belgium NV 131:4758606c9316 75 const char name[MAX_PROTOCOL_NAME];
TASS Belgium NV 131:4758606c9316 76 uint32_t hash;
TASS Belgium NV 131:4758606c9316 77 const enum pico_layer layer;
TASS Belgium NV 131:4758606c9316 78 const uint16_t proto_number;
TASS Belgium NV 131:4758606c9316 79 struct pico_queue *const q_in;
TASS Belgium NV 131:4758606c9316 80 struct pico_queue *const q_out;
TASS Belgium NV 131:4758606c9316 81 struct pico_frame *(*const alloc)(struct pico_protocol *self, uint16_t size); /* Frame allocation. */
TASS Belgium NV 131:4758606c9316 82 int (*const push) (struct pico_protocol *self, struct pico_frame *p); /* Push function, for active outgoing pkts from above */
TASS Belgium NV 131:4758606c9316 83 int (*const process_out) (struct pico_protocol *self, struct pico_frame *p); /* Send loop. */
TASS Belgium NV 131:4758606c9316 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