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 picotcp@tass.be
Date:
Wed Apr 09 14:31:41 2014 +0200
Revision:
149:5f4cb161cec3
Parent:
137:a1c8bfa9d691
Child:
152:a3d286bf94e5
Update from git masterbranch

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 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 68:0847e35d08a6 20 #define PICO_IPV4_DONTFRAG 0x4000
tass 68:0847e35d08a6 21 #define PICO_IPV4_MOREFRAG 0x2000
tass 68:0847e35d08a6 22 #define PICO_IPV4_FRAG_MASK 0x1FFF
tass 68:0847e35d08a6 23 #define PICO_IPV4_DEFAULT_TTL 64
tass 111:4003cf17bc15 24 #ifndef MBED
tass picotcp@tass.be 149:5f4cb161cec3 25 #define PICO_IPV4_FRAG_MAX_SIZE (uint32_t)(63 * 1024)
tass 111:4003cf17bc15 26 #else
TASS Belgium NV 131:4758606c9316 27 #define PICO_IPV4_FRAG_MAX_SIZE PICO_DEFAULT_SOCKETQ
tass 111:4003cf17bc15 28 #endif
tass 68:0847e35d08a6 29
tass 68:0847e35d08a6 30 extern struct pico_protocol pico_proto_ipv4;
tass 68:0847e35d08a6 31
tass picotcp@tass.be 149:5f4cb161cec3 32 PACKED_STRUCT_DEF pico_ipv4_hdr {
TASS Belgium NV 131:4758606c9316 33 uint8_t vhl;
TASS Belgium NV 131:4758606c9316 34 uint8_t tos;
TASS Belgium NV 131:4758606c9316 35 uint16_t len;
TASS Belgium NV 131:4758606c9316 36 uint16_t id;
TASS Belgium NV 131:4758606c9316 37 uint16_t frag;
TASS Belgium NV 131:4758606c9316 38 uint8_t ttl;
TASS Belgium NV 131:4758606c9316 39 uint8_t proto;
TASS Belgium NV 131:4758606c9316 40 uint16_t crc;
TASS Belgium NV 131:4758606c9316 41 struct pico_ip4 src;
TASS Belgium NV 131:4758606c9316 42 struct pico_ip4 dst;
TASS Belgium NV 131:4758606c9316 43 uint8_t options[];
tass 68:0847e35d08a6 44 };
tass 68:0847e35d08a6 45
tass picotcp@tass.be 149:5f4cb161cec3 46 PACKED_STRUCT_DEF pico_ipv4_pseudo_hdr
tass 68:0847e35d08a6 47 {
TASS Belgium NV 131:4758606c9316 48 struct pico_ip4 src;
TASS Belgium NV 131:4758606c9316 49 struct pico_ip4 dst;
TASS Belgium NV 131:4758606c9316 50 uint8_t zeros;
TASS Belgium NV 131:4758606c9316 51 uint8_t proto;
TASS Belgium NV 131:4758606c9316 52 uint16_t len;
tass 68:0847e35d08a6 53 };
tass 68:0847e35d08a6 54
tass 68:0847e35d08a6 55 /* Interface: link to device */
tass 68:0847e35d08a6 56 struct pico_mcast_list;
tass 68:0847e35d08a6 57
tass 68:0847e35d08a6 58 struct pico_ipv4_link
tass 68:0847e35d08a6 59 {
TASS Belgium NV 131:4758606c9316 60 struct pico_device *dev;
TASS Belgium NV 131:4758606c9316 61 struct pico_ip4 address;
TASS Belgium NV 131:4758606c9316 62 struct pico_ip4 netmask;
tass 68:0847e35d08a6 63 #ifdef PICO_SUPPORT_MCAST
TASS Belgium NV 131:4758606c9316 64 struct pico_tree *MCASTGroups;
TASS Belgium NV 131:4758606c9316 65 uint8_t mcast_compatibility;
TASS Belgium NV 131:4758606c9316 66 uint8_t mcast_last_query_interval;
tass 68:0847e35d08a6 67 #endif
tass 68:0847e35d08a6 68 };
tass 68:0847e35d08a6 69
tass 68:0847e35d08a6 70 #ifdef PICO_SUPPORT_MCAST
tass 68:0847e35d08a6 71 struct pico_mcast_group {
TASS Belgium NV 131:4758606c9316 72 uint8_t filter_mode;
TASS Belgium NV 131:4758606c9316 73 uint16_t reference_count;
TASS Belgium NV 131:4758606c9316 74 struct pico_ip4 mcast_addr;
TASS Belgium NV 131:4758606c9316 75 struct pico_tree MCASTSources;
tass 68:0847e35d08a6 76 };
tass 68:0847e35d08a6 77 #endif
tass 68:0847e35d08a6 78
tass 68:0847e35d08a6 79 int pico_ipv4_to_string(char *ipbuf, const uint32_t ip);
tass 68:0847e35d08a6 80 int pico_string_to_ipv4(const char *ipstr, uint32_t *ip);
tass 68:0847e35d08a6 81 int pico_ipv4_valid_netmask(uint32_t mask);
TASS Belgium NV 131:4758606c9316 82 int pico_ipv4_is_unicast(uint32_t address);
TASS Belgium NV 131:4758606c9316 83 int pico_ipv4_is_multicast(uint32_t address);
tass 68:0847e35d08a6 84 int pico_ipv4_is_broadcast(uint32_t addr);
tass picotcp@tass.be 137:a1c8bfa9d691 85 int pico_ipv4_is_loopback(uint32_t addr);
tass picotcp@tass.be 149:5f4cb161cec3 86 int pico_ipv4_is_valid_src(uint32_t addr, struct pico_device *dev);
tass 68:0847e35d08a6 87
tass 68:0847e35d08a6 88 int pico_ipv4_link_add(struct pico_device *dev, struct pico_ip4 address, struct pico_ip4 netmask);
tass 68:0847e35d08a6 89 int pico_ipv4_link_del(struct pico_device *dev, struct pico_ip4 address);
tass 68:0847e35d08a6 90 int pico_ipv4_rebound(struct pico_frame *f);
tass 68:0847e35d08a6 91
tass 68:0847e35d08a6 92 int pico_ipv4_frame_push(struct pico_frame *f, struct pico_ip4 *dst, uint8_t proto);
tass 68:0847e35d08a6 93 struct pico_ipv4_link *pico_ipv4_link_get(struct pico_ip4 *address);
tass 68:0847e35d08a6 94 struct pico_ipv4_link *pico_ipv4_link_by_dev(struct pico_device *dev);
tass 74:c146c4e346c4 95 struct pico_ipv4_link *pico_ipv4_link_by_dev_next(struct pico_device *dev, struct pico_ipv4_link *last);
tass 68:0847e35d08a6 96 struct pico_device *pico_ipv4_link_find(struct pico_ip4 *address);
tass 68:0847e35d08a6 97 struct pico_ip4 *pico_ipv4_source_find(const struct pico_ip4 *dst);
tass 68:0847e35d08a6 98 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 99 int pico_ipv4_route_del(struct pico_ip4 address, struct pico_ip4 netmask, int metric);
tass 68:0847e35d08a6 100 struct pico_ip4 pico_ipv4_route_get_gateway(struct pico_ip4 *addr);
tass 68:0847e35d08a6 101 void pico_ipv4_unreachable(struct pico_frame *f, int err);
tass 68:0847e35d08a6 102
tass 68:0847e35d08a6 103 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 104 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 105 struct pico_ipv4_link *pico_ipv4_get_default_mcastlink(void);
tass picotcp@tass.be 149:5f4cb161cec3 106 int pico_ipv4_cleanup_links(struct pico_device *dev);
tass 68:0847e35d08a6 107
tass 68:0847e35d08a6 108 #endif /* _INCLUDE_PICO_IPV4 */