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 RTOSgeneric mbed Ethernet driverhigh performance NXP LPC1768 specific Ethernet driverMulti-threading support for mbed RTOSBerkeley sockets and integration with the New Socket APIFork of the apps running on top of the New Socket APIScheduling 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@152:a3d286bf94e5, 2015-09-28 (annotated)
- Committer:
- tass
- Date:
- Mon Sep 28 13:16:18 2015 +0200
- Revision:
- 152:a3d286bf94e5
- Parent:
- 149:5f4cb161cec3
Mercurial: latest development version of PicoTCP
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tass | 68:0847e35d08a6 | 1 | /********************************************************************* |
tass | 152:a3d286bf94e5 | 2 | PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. 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 picotcp@tass.be | 149:5f4cb161cec3 | 6 | #ifndef INCLUDE_PICO_PROTOCOL |
tass picotcp@tass.be | 149:5f4cb161cec3 | 7 | #define INCLUDE_PICO_PROTOCOL |
tass | 152:a3d286bf94e5 | 8 | #include "pico_config.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 picotcp@tass.be | 149:5f4cb161cec3 | 23 | PICO_ERR_EPERM = 1, |
tass picotcp@tass.be | 149:5f4cb161cec3 | 24 | PICO_ERR_ENOENT = 2, |
TASS Belgium NV |
131:4758606c9316 | 25 | /* ... */ |
TASS Belgium NV |
131:4758606c9316 | 26 | PICO_ERR_EINTR = 4, |
tass picotcp@tass.be | 149:5f4cb161cec3 | 27 | PICO_ERR_EIO = 5, |
tass picotcp@tass.be | 149:5f4cb161cec3 | 28 | PICO_ERR_ENXIO = 6, |
TASS Belgium NV |
131:4758606c9316 | 29 | /* ... */ |
TASS Belgium NV |
131:4758606c9316 | 30 | PICO_ERR_EAGAIN = 11, |
tass picotcp@tass.be | 149:5f4cb161cec3 | 31 | PICO_ERR_ENOMEM = 12, |
tass picotcp@tass.be | 149:5f4cb161cec3 | 32 | PICO_ERR_EACCESS = 13, |
tass picotcp@tass.be | 149:5f4cb161cec3 | 33 | PICO_ERR_EFAULT = 14, |
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 picotcp@tass.be | 149:5f4cb161cec3 | 40 | PICO_ERR_ENONET = 64, |
tass picotcp@tass.be | 149:5f4cb161cec3 | 41 | /* ... */ |
TASS Belgium NV |
131:4758606c9316 | 42 | PICO_ERR_EPROTO = 71, |
tass picotcp@tass.be | 149:5f4cb161cec3 | 43 | /* ... */ |
TASS Belgium NV |
131:4758606c9316 | 44 | PICO_ERR_ENOPROTOOPT = 92, |
TASS Belgium NV |
131:4758606c9316 | 45 | PICO_ERR_EPROTONOSUPPORT = 93, |
TASS Belgium NV |
131:4758606c9316 | 46 | /* ... */ |
tass picotcp@tass.be | 137:a1c8bfa9d691 | 47 | PICO_ERR_EOPNOTSUPP = 95, |
TASS Belgium NV |
131:4758606c9316 | 48 | PICO_ERR_EADDRINUSE = 98, |
tass picotcp@tass.be | 149:5f4cb161cec3 | 49 | PICO_ERR_EADDRNOTAVAIL = 99, |
tass picotcp@tass.be | 149:5f4cb161cec3 | 50 | PICO_ERR_ENETDOWN = 100, |
tass picotcp@tass.be | 149:5f4cb161cec3 | 51 | PICO_ERR_ENETUNREACH = 101, |
TASS Belgium NV |
131:4758606c9316 | 52 | /* ... */ |
TASS Belgium NV |
131:4758606c9316 | 53 | PICO_ERR_ECONNRESET = 104, |
TASS Belgium NV |
131:4758606c9316 | 54 | /* ... */ |
TASS Belgium NV |
131:4758606c9316 | 55 | PICO_ERR_EISCONN = 106, |
tass picotcp@tass.be | 149:5f4cb161cec3 | 56 | PICO_ERR_ENOTCONN = 107, |
tass picotcp@tass.be | 149:5f4cb161cec3 | 57 | PICO_ERR_ESHUTDOWN = 108, |
TASS Belgium NV |
131:4758606c9316 | 58 | /* ... */ |
TASS Belgium NV |
131:4758606c9316 | 59 | PICO_ERR_ETIMEDOUT = 110, |
TASS Belgium NV |
131:4758606c9316 | 60 | PICO_ERR_ECONNREFUSED = 111, |
tass picotcp@tass.be | 149:5f4cb161cec3 | 61 | PICO_ERR_EHOSTDOWN = 112, |
tass picotcp@tass.be | 149:5f4cb161cec3 | 62 | PICO_ERR_EHOSTUNREACH = 113, |
tass | 68:0847e35d08a6 | 63 | }; |
tass | 68:0847e35d08a6 | 64 | |
tass | 68:0847e35d08a6 | 65 | typedef enum pico_err_e pico_err_t; |
tass | 68:0847e35d08a6 | 66 | extern volatile pico_err_t pico_err; |
tass | 68:0847e35d08a6 | 67 | |
tass picotcp@tass.be | 137:a1c8bfa9d691 | 68 | #define IS_IPV6(f) (f && f->net_hdr && ((((uint8_t *)(f->net_hdr))[0] & 0xf0) == 0x60)) |
tass picotcp@tass.be | 137:a1c8bfa9d691 | 69 | #define IS_IPV4(f) (f && f->net_hdr && ((((uint8_t *)(f->net_hdr))[0] & 0xf0) == 0x40)) |
tass | 68:0847e35d08a6 | 70 | |
tass | 68:0847e35d08a6 | 71 | #define MAX_PROTOCOL_NAME 16 |
tass | 68:0847e35d08a6 | 72 | |
tass | 68:0847e35d08a6 | 73 | struct pico_protocol { |
tass picotcp@tass.be | 134:cc4e6d2654d9 | 74 | char name[MAX_PROTOCOL_NAME]; |
TASS Belgium NV |
131:4758606c9316 | 75 | uint32_t hash; |
tass picotcp@tass.be | 134:cc4e6d2654d9 | 76 | enum pico_layer layer; |
tass picotcp@tass.be | 134:cc4e6d2654d9 | 77 | uint16_t proto_number; |
tass picotcp@tass.be | 134:cc4e6d2654d9 | 78 | struct pico_queue *q_in; |
tass picotcp@tass.be | 134:cc4e6d2654d9 | 79 | struct pico_queue *q_out; |
tass picotcp@tass.be | 134:cc4e6d2654d9 | 80 | struct pico_frame *(*alloc)(struct pico_protocol *self, uint16_t size); /* Frame allocation. */ |
tass picotcp@tass.be | 137:a1c8bfa9d691 | 81 | int (*push)(struct pico_protocol *self, struct pico_frame *p); /* Push function, for active outgoing pkts from above */ |
tass picotcp@tass.be | 137:a1c8bfa9d691 | 82 | int (*process_out)(struct pico_protocol *self, struct pico_frame *p); /* Send loop. */ |
tass picotcp@tass.be | 137:a1c8bfa9d691 | 83 | int (*process_in)(struct pico_protocol *self, struct pico_frame *p); /* Recv loop. */ |
tass picotcp@tass.be | 149:5f4cb161cec3 | 84 | uint16_t (*get_mtu)(struct pico_protocol *self); |
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 |