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 Jan 28 15:12:00 2016 +0100
Revision:
155:a70f34550c34
Parent:
152:a3d286bf94e5
Adding TCP flag for FIN.

Who changed what in which revision?

UserRevisionLine numberNew 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 68:0847e35d08a6 6
TASS Belgium NV 131:4758606c9316 7 *********************************************************************/
tass picotcp@tass.be 149:5f4cb161cec3 8 #ifndef INCLUDE_PICO_IPV4
tass picotcp@tass.be 149:5f4cb161cec3 9 #define INCLUDE_PICO_IPV4
tass 68:0847e35d08a6 10 #include "pico_addressing.h"
tass 68:0847e35d08a6 11 #include "pico_protocol.h"
tass 68:0847e35d08a6 12 #include "pico_tree.h"
tass picotcp@tass.be 149:5f4cb161cec3 13 #include "pico_device.h"
tass 68:0847e35d08a6 14
tass 68:0847e35d08a6 15 #define PICO_IPV4_INADDR_ANY 0x00000000U
tass 68:0847e35d08a6 16
tass picotcp@tass.be 149:5f4cb161cec3 17 #define PICO_IPV4_MTU (1500u)
tass 74:c146c4e346c4 18 #define PICO_SIZE_IP4HDR (uint32_t)((sizeof(struct pico_ipv4_hdr)))
tass picotcp@tass.be 149:5f4cb161cec3 19 #define PICO_IPV4_MAXPAYLOAD (PICO_IPV4_MTU - PICO_SIZE_IP4HDR)
tass 152:a3d286bf94e5 20 #define PICO_IPV4_DONTFRAG 0x4000U
tass 152:a3d286bf94e5 21 #define PICO_IPV4_MOREFRAG 0x2000U
tass 152:a3d286bf94e5 22 #define PICO_IPV4_EVIL 0x8000U
tass 152:a3d286bf94e5 23 #define PICO_IPV4_FRAG_MASK 0x1FFFU
tass 68:0847e35d08a6 24 #define PICO_IPV4_DEFAULT_TTL 64
tass 111:4003cf17bc15 25 #ifndef MBED
tass picotcp@tass.be 149:5f4cb161cec3 26 #define PICO_IPV4_FRAG_MAX_SIZE (uint32_t)(63 * 1024)
tass 111:4003cf17bc15 27 #else
TASS Belgium NV 131:4758606c9316 28 #define PICO_IPV4_FRAG_MAX_SIZE PICO_DEFAULT_SOCKETQ
tass 111:4003cf17bc15 29 #endif
tass 68:0847e35d08a6 30
tass 68:0847e35d08a6 31 extern struct pico_protocol pico_proto_ipv4;
tass 68:0847e35d08a6 32
tass picotcp@tass.be 149:5f4cb161cec3 33 PACKED_STRUCT_DEF pico_ipv4_hdr {
TASS Belgium NV 131:4758606c9316 34 uint8_t vhl;
TASS Belgium NV 131:4758606c9316 35 uint8_t tos;
TASS Belgium NV 131:4758606c9316 36 uint16_t len;
TASS Belgium NV 131:4758606c9316 37 uint16_t id;
TASS Belgium NV 131:4758606c9316 38 uint16_t frag;
TASS Belgium NV 131:4758606c9316 39 uint8_t ttl;
TASS Belgium NV 131:4758606c9316 40 uint8_t proto;
TASS Belgium NV 131:4758606c9316 41 uint16_t crc;
TASS Belgium NV 131:4758606c9316 42 struct pico_ip4 src;
TASS Belgium NV 131:4758606c9316 43 struct pico_ip4 dst;
TASS Belgium NV 131:4758606c9316 44 uint8_t options[];
tass 68:0847e35d08a6 45 };
tass 68:0847e35d08a6 46
tass picotcp@tass.be 149:5f4cb161cec3 47 PACKED_STRUCT_DEF pico_ipv4_pseudo_hdr
tass 68:0847e35d08a6 48 {
TASS Belgium NV 131:4758606c9316 49 struct pico_ip4 src;
TASS Belgium NV 131:4758606c9316 50 struct pico_ip4 dst;
TASS Belgium NV 131:4758606c9316 51 uint8_t zeros;
TASS Belgium NV 131:4758606c9316 52 uint8_t proto;
TASS Belgium NV 131:4758606c9316 53 uint16_t len;
tass 68:0847e35d08a6 54 };
tass 68:0847e35d08a6 55
tass 68:0847e35d08a6 56 /* Interface: link to device */
tass 68:0847e35d08a6 57 struct pico_mcast_list;
tass 68:0847e35d08a6 58
tass 68:0847e35d08a6 59 struct pico_ipv4_link
tass 68:0847e35d08a6 60 {
TASS Belgium NV 131:4758606c9316 61 struct pico_device *dev;
TASS Belgium NV 131:4758606c9316 62 struct pico_ip4 address;
TASS Belgium NV 131:4758606c9316 63 struct pico_ip4 netmask;
tass 68:0847e35d08a6 64 #ifdef PICO_SUPPORT_MCAST
TASS Belgium NV 131:4758606c9316 65 struct pico_tree *MCASTGroups;
TASS Belgium NV 131:4758606c9316 66 uint8_t mcast_compatibility;
TASS Belgium NV 131:4758606c9316 67 uint8_t mcast_last_query_interval;
tass 68:0847e35d08a6 68 #endif
tass 68:0847e35d08a6 69 };
tass 68:0847e35d08a6 70
tass 68:0847e35d08a6 71 #ifdef PICO_SUPPORT_MCAST
tass 68:0847e35d08a6 72 struct pico_mcast_group {
TASS Belgium NV 131:4758606c9316 73 uint8_t filter_mode;
TASS Belgium NV 131:4758606c9316 74 uint16_t reference_count;
TASS Belgium NV 131:4758606c9316 75 struct pico_ip4 mcast_addr;
TASS Belgium NV 131:4758606c9316 76 struct pico_tree MCASTSources;
tass 68:0847e35d08a6 77 };
tass 68:0847e35d08a6 78 #endif
tass 68:0847e35d08a6 79
tass 152:a3d286bf94e5 80 struct pico_ipv4_route
tass 152:a3d286bf94e5 81 {
tass 152:a3d286bf94e5 82 struct pico_ip4 dest;
tass 152:a3d286bf94e5 83 struct pico_ip4 netmask;
tass 152:a3d286bf94e5 84 struct pico_ip4 gateway;
tass 152:a3d286bf94e5 85 struct pico_ipv4_link *link;
tass 152:a3d286bf94e5 86 uint32_t metric;
tass 152:a3d286bf94e5 87 };
tass 152:a3d286bf94e5 88
tass 152:a3d286bf94e5 89 extern struct pico_tree Routes;
tass 152:a3d286bf94e5 90
tass 152:a3d286bf94e5 91
tass 152:a3d286bf94e5 92 int pico_ipv4_compare(struct pico_ip4 *a, struct pico_ip4 *b);
tass 68:0847e35d08a6 93 int pico_ipv4_to_string(char *ipbuf, const uint32_t ip);
tass 68:0847e35d08a6 94 int pico_string_to_ipv4(const char *ipstr, uint32_t *ip);
tass 68:0847e35d08a6 95 int pico_ipv4_valid_netmask(uint32_t mask);
TASS Belgium NV 131:4758606c9316 96 int pico_ipv4_is_unicast(uint32_t address);
TASS Belgium NV 131:4758606c9316 97 int pico_ipv4_is_multicast(uint32_t address);
tass 68:0847e35d08a6 98 int pico_ipv4_is_broadcast(uint32_t addr);
tass picotcp@tass.be 137:a1c8bfa9d691 99 int pico_ipv4_is_loopback(uint32_t addr);
tass picotcp@tass.be 149:5f4cb161cec3 100 int pico_ipv4_is_valid_src(uint32_t addr, struct pico_device *dev);
tass 68:0847e35d08a6 101
tass 68:0847e35d08a6 102 int pico_ipv4_link_add(struct pico_device *dev, struct pico_ip4 address, struct pico_ip4 netmask);
tass 68:0847e35d08a6 103 int pico_ipv4_link_del(struct pico_device *dev, struct pico_ip4 address);
tass 68:0847e35d08a6 104 int pico_ipv4_rebound(struct pico_frame *f);
tass 68:0847e35d08a6 105
tass 68:0847e35d08a6 106 int pico_ipv4_frame_push(struct pico_frame *f, struct pico_ip4 *dst, uint8_t proto);
tass 68:0847e35d08a6 107 struct pico_ipv4_link *pico_ipv4_link_get(struct pico_ip4 *address);
tass 68:0847e35d08a6 108 struct pico_ipv4_link *pico_ipv4_link_by_dev(struct pico_device *dev);
tass 74:c146c4e346c4 109 struct pico_ipv4_link *pico_ipv4_link_by_dev_next(struct pico_device *dev, struct pico_ipv4_link *last);
tass 68:0847e35d08a6 110 struct pico_device *pico_ipv4_link_find(struct pico_ip4 *address);
tass 68:0847e35d08a6 111 struct pico_ip4 *pico_ipv4_source_find(const struct pico_ip4 *dst);
tass 152:a3d286bf94e5 112 struct pico_device *pico_ipv4_source_dev_find(const struct pico_ip4 *dst);
tass 68:0847e35d08a6 113 int pico_ipv4_route_add(struct pico_ip4 address, struct pico_ip4 netmask, struct pico_ip4 gateway, int metric, struct pico_ipv4_link *link);
tass 72:887bc44746ff 114 int pico_ipv4_route_del(struct pico_ip4 address, struct pico_ip4 netmask, int metric);
tass 68:0847e35d08a6 115 struct pico_ip4 pico_ipv4_route_get_gateway(struct pico_ip4 *addr);
tass 152:a3d286bf94e5 116 void pico_ipv4_route_set_bcast_link(struct pico_ipv4_link *link);
tass 68:0847e35d08a6 117 void pico_ipv4_unreachable(struct pico_frame *f, int err);
tass 68:0847e35d08a6 118
tass 68:0847e35d08a6 119 int pico_ipv4_mcast_join(struct pico_ip4 *mcast_link, struct pico_ip4 *mcast_group, uint8_t reference_count, uint8_t filter_mode, struct pico_tree *MCASTFilter);
tass 68:0847e35d08a6 120 int pico_ipv4_mcast_leave(struct pico_ip4 *mcast_link, struct pico_ip4 *mcast_group, uint8_t reference_count, uint8_t filter_mode, struct pico_tree *MCASTFilter);
tass 68:0847e35d08a6 121 struct pico_ipv4_link *pico_ipv4_get_default_mcastlink(void);
tass picotcp@tass.be 149:5f4cb161cec3 122 int pico_ipv4_cleanup_links(struct pico_device *dev);
tass 68:0847e35d08a6 123
tass 68:0847e35d08a6 124 #endif /* _INCLUDE_PICO_IPV4 */