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.

include/pico_protocol.h

Committer:
TASS Belgium NV
Date:
2013-12-16
Revision:
131:4758606c9316
Parent:
70:cd218dd180e5
Child:
134:cc4e6d2654d9

File content as of revision 131:4758606c9316:

/*********************************************************************
   PicoTCP. Copyright (c) 2012 TASS Belgium NV. Some rights reserved.
   See LICENSE and COPYING for usage.

 *********************************************************************/
#ifndef _INCLUDE_PICO_PROTOCOL
#define _INCLUDE_PICO_PROTOCOL
#include <stdint.h>
#include "pico_queue.h"

#define PICO_LOOP_DIR_IN   1
#define PICO_LOOP_DIR_OUT  2

enum pico_layer {
    PICO_LAYER_DATALINK = 2, /* Ethernet only. */
    PICO_LAYER_NETWORK = 3, /* IPv4, IPv6, ARP. Arp is there because it communicates with L2 */
    PICO_LAYER_TRANSPORT = 4, /* UDP, TCP, ICMP */
    PICO_LAYER_SOCKET = 5   /* Socket management */
};

enum pico_err_e {
    PICO_ERR_NOERR = 0,
    PICO_ERR_EPERM,
    PICO_ERR_ENOENT,
    /* ... */
    PICO_ERR_EINTR = 4,
    PICO_ERR_EIO,
    PICO_ERR_ENXIO,
    /* ... */
    PICO_ERR_EAGAIN = 11,
    PICO_ERR_ENOMEM,
    PICO_ERR_EACCESS,
    PICO_ERR_EFAULT,
    /* ... */
    PICO_ERR_EBUSY = 16,
    PICO_ERR_EEXIST = 17,
    /* ... */
    PICO_ERR_EINVAL = 22,
    /* ... */
    PICO_ERR_EPROTO = 71,
    PICO_ERR_ENOPROTOOPT = 92,
    PICO_ERR_EPROTONOSUPPORT = 93,

    /* ... */
    PICO_ERR_EADDRINUSE = 98,
    PICO_ERR_EADDRNOTAVAIL,
    PICO_ERR_ENETUNREACH,

    /* ... */
    PICO_ERR_ECONNRESET = 104,

    /* ... */
    PICO_ERR_EISCONN = 106,
    PICO_ERR_ENOTCONN,
    PICO_ERR_ESHUTDOWN,
    /* ... */
    PICO_ERR_ETIMEDOUT = 110,
    PICO_ERR_ECONNREFUSED = 111,
    PICO_ERR_EHOSTDOWN,
    PICO_ERR_EHOSTUNREACH,
    /* ... */
    PICO_ERR_EOPNOTSUPP = 122,

};

typedef enum pico_err_e pico_err_t;
extern volatile pico_err_t pico_err;

#define IS_IPV6(f) ((((uint8_t *)(f->net_hdr))[0] & 0xf0) == 0x60)
#define IS_IPV4(f) ((((uint8_t *)(f->net_hdr))[0] & 0xf0) == 0x40)

#define MAX_PROTOCOL_NAME 16

struct pico_protocol {
    const char name[MAX_PROTOCOL_NAME];
    uint32_t hash;
    const enum pico_layer layer;
    const uint16_t proto_number;
    struct pico_queue *const q_in;
    struct pico_queue *const q_out;
    struct pico_frame *(*const alloc)(struct pico_protocol *self, uint16_t size); /* Frame allocation. */
    int (*const push) (struct pico_protocol *self, struct pico_frame *p);   /* Push function, for active outgoing pkts from above */
    int (*const process_out) (struct pico_protocol *self, struct pico_frame *p); /* Send loop. */
    int (*const process_in) (struct pico_protocol *self, struct pico_frame *p); /* Recv loop. */
};

int pico_protocols_loop(int loop_score);
void pico_protocol_init(struct pico_protocol *p);

int pico_protocol_datalink_loop(int loop_score, int direction);
int pico_protocol_network_loop(int loop_score, int direction);
int pico_protocol_transport_loop(int loop_score, int direction);
int pico_protocol_socket_loop(int loop_score, int direction);

#endif