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:
Mon Sep 28 13:16:18 2015 +0200
Revision:
152:a3d286bf94e5
Parent:
149:5f4cb161cec3
Child:
154:6c0e92a80c4a
Mercurial: latest development version of PicoTCP

Who changed what in which revision?

UserRevisionLine numberNew contents of line
daniele 3:b4047e8a0123 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.
daniele 3:b4047e8a0123 4
TASS Belgium NV 131:4758606c9316 5 .
daniele 3:b4047e8a0123 6
TASS Belgium NV 131:4758606c9316 7 *********************************************************************/
daniele 3:b4047e8a0123 8 #ifndef _INCLUDE_PICO_IPV6
daniele 3:b4047e8a0123 9 #define _INCLUDE_PICO_IPV6
daniele 3:b4047e8a0123 10 #include "pico_addressing.h"
daniele 3:b4047e8a0123 11 #include "pico_protocol.h"
tass 152:a3d286bf94e5 12 #include "pico_ipv4.h"
tass picotcp@tass.be 149:5f4cb161cec3 13 #define PICO_SIZE_IP6HDR ((uint32_t)(sizeof(struct pico_ipv6_hdr)))
tass picotcp@tass.be 149:5f4cb161cec3 14 #define PICO_IPV6_DEFAULT_HOP 64
tass picotcp@tass.be 149:5f4cb161cec3 15 #define PICO_IPV6_MIN_MTU 1280
tass 152:a3d286bf94e5 16 #define PICO_IPV6_STRING 46
tass 152:a3d286bf94e5 17
tass 152:a3d286bf94e5 18 #define PICO_IPV6_EXTHDR_HOPBYHOP 0
tass 152:a3d286bf94e5 19 #define PICO_IPV6_EXTHDR_ROUTING 43
tass 152:a3d286bf94e5 20 #define PICO_IPV6_EXTHDR_FRAG 44
tass 152:a3d286bf94e5 21 #define PICO_IPV6_EXTHDR_ESP 50
tass 152:a3d286bf94e5 22 #define PICO_IPV6_EXTHDR_AUTH 51
tass 152:a3d286bf94e5 23 #define PICO_IPV6_EXTHDR_NONE 59
tass 152:a3d286bf94e5 24 #define PICO_IPV6_EXTHDR_DESTOPT 60
tass 152:a3d286bf94e5 25
tass 152:a3d286bf94e5 26
tass 152:a3d286bf94e5 27 #define PICO_IPV6_EXTHDR_OPT_ROUTER_ALERT 5
tass 152:a3d286bf94e5 28 #define PICO_IPV6_EXTHDR_OPT_ROUTER_ALERT_DATALEN 2
tass 152:a3d286bf94e5 29
tass 152:a3d286bf94e5 30 #define HBH_LEN(hbh) ((((hbh->ext.hopbyhop.len + 1) << 3) - 2)) /* len in bytes, minus nxthdr and len byte */
tass picotcp@tass.be 149:5f4cb161cec3 31
tass picotcp@tass.be 149:5f4cb161cec3 32 extern const uint8_t PICO_IP6_ANY[PICO_SIZE_IP6];
daniele 3:b4047e8a0123 33 extern struct pico_protocol pico_proto_ipv6;
tass 152:a3d286bf94e5 34 extern struct pico_tree IPV6Routes;
daniele 3:b4047e8a0123 35
tass picotcp@tass.be 149:5f4cb161cec3 36 PACKED_STRUCT_DEF pico_ipv6_hdr {
tass picotcp@tass.be 149:5f4cb161cec3 37 uint32_t vtf;
tass picotcp@tass.be 149:5f4cb161cec3 38 uint16_t len;
tass picotcp@tass.be 149:5f4cb161cec3 39 uint8_t nxthdr;
tass picotcp@tass.be 149:5f4cb161cec3 40 uint8_t hop;
tass picotcp@tass.be 149:5f4cb161cec3 41 struct pico_ip6 src;
tass picotcp@tass.be 149:5f4cb161cec3 42 struct pico_ip6 dst;
tass picotcp@tass.be 149:5f4cb161cec3 43 uint8_t extensions[0];
tass picotcp@tass.be 149:5f4cb161cec3 44 };
daniele 3:b4047e8a0123 45
tass picotcp@tass.be 149:5f4cb161cec3 46 PACKED_STRUCT_DEF pico_ipv6_pseudo_hdr
tass picotcp@tass.be 149:5f4cb161cec3 47 {
tass picotcp@tass.be 149:5f4cb161cec3 48 struct pico_ip6 src;
tass picotcp@tass.be 149:5f4cb161cec3 49 struct pico_ip6 dst;
tass picotcp@tass.be 149:5f4cb161cec3 50 uint32_t len;
tass picotcp@tass.be 149:5f4cb161cec3 51 uint8_t zero[3];
tass picotcp@tass.be 149:5f4cb161cec3 52 uint8_t nxthdr;
tass picotcp@tass.be 149:5f4cb161cec3 53 };
tass picotcp@tass.be 149:5f4cb161cec3 54
tass picotcp@tass.be 149:5f4cb161cec3 55 struct pico_ipv6_link
tass picotcp@tass.be 149:5f4cb161cec3 56 {
tass picotcp@tass.be 149:5f4cb161cec3 57 struct pico_device *dev;
tass picotcp@tass.be 149:5f4cb161cec3 58 struct pico_ip6 address;
tass picotcp@tass.be 149:5f4cb161cec3 59 struct pico_ip6 netmask;
tass picotcp@tass.be 149:5f4cb161cec3 60 uint8_t istentative : 1;
tass picotcp@tass.be 149:5f4cb161cec3 61 uint8_t isduplicate : 1;
tass 152:a3d286bf94e5 62 struct pico_timer *dad_timer;
tass 152:a3d286bf94e5 63 uint16_t dup_detect_retrans;
tass 152:a3d286bf94e5 64 pico_time expire_time;
tass 152:a3d286bf94e5 65 #ifdef PICO_SUPPORT_MCAST
tass 152:a3d286bf94e5 66 struct pico_tree *MCASTGroups;
tass 152:a3d286bf94e5 67 uint8_t mcast_compatibility;
tass 152:a3d286bf94e5 68 uint8_t mcast_last_query_interval;
tass 152:a3d286bf94e5 69 #endif
tass 152:a3d286bf94e5 70
tass 152:a3d286bf94e5 71 };
tass 152:a3d286bf94e5 72 union pico_link {
tass 152:a3d286bf94e5 73 struct pico_ipv4_link ipv4;
tass 152:a3d286bf94e5 74 struct pico_ipv6_link ipv6;
tass 152:a3d286bf94e5 75 };
tass 152:a3d286bf94e5 76
tass 152:a3d286bf94e5 77 struct pico_ipv6_hbhoption {
tass 152:a3d286bf94e5 78 uint8_t type;
tass 152:a3d286bf94e5 79 uint8_t len;
tass 152:a3d286bf94e5 80 uint8_t options[0];
tass 152:a3d286bf94e5 81 };
tass 152:a3d286bf94e5 82 #ifdef PICO_SUPPORT_MCAST
tass 152:a3d286bf94e5 83 struct pico_ipv6_mcast_group {
tass 152:a3d286bf94e5 84 uint8_t filter_mode;
tass 152:a3d286bf94e5 85 uint16_t reference_count;
tass 152:a3d286bf94e5 86 struct pico_ip6 mcast_addr;
tass 152:a3d286bf94e5 87 struct pico_tree MCASTSources;
tass 152:a3d286bf94e5 88 };
tass 152:a3d286bf94e5 89 #endif
tass 152:a3d286bf94e5 90 struct pico_ipv6_destoption {
tass 152:a3d286bf94e5 91 uint8_t type;
tass 152:a3d286bf94e5 92 uint8_t len;
tass 152:a3d286bf94e5 93 uint8_t options[0];
tass 152:a3d286bf94e5 94 };
tass 152:a3d286bf94e5 95
tass 152:a3d286bf94e5 96 struct pico_ipv6_route
tass 152:a3d286bf94e5 97 {
tass 152:a3d286bf94e5 98 struct pico_ip6 dest;
tass 152:a3d286bf94e5 99 struct pico_ip6 netmask;
tass 152:a3d286bf94e5 100 struct pico_ip6 gateway;
tass 152:a3d286bf94e5 101 struct pico_ipv6_link *link;
tass 152:a3d286bf94e5 102 uint32_t metric;
tass picotcp@tass.be 149:5f4cb161cec3 103 };
tass picotcp@tass.be 149:5f4cb161cec3 104
tass picotcp@tass.be 149:5f4cb161cec3 105 PACKED_STRUCT_DEF pico_ipv6_exthdr {
tass picotcp@tass.be 149:5f4cb161cec3 106 uint8_t nxthdr;
tass picotcp@tass.be 149:5f4cb161cec3 107
tass 152:a3d286bf94e5 108 PACKED_UNION_DEF ipv6_ext_u {
tass 152:a3d286bf94e5 109 PEDANTIC_STRUCT_DEF hopbyhop_s {
tass picotcp@tass.be 149:5f4cb161cec3 110 uint8_t len;
tass picotcp@tass.be 149:5f4cb161cec3 111 uint8_t options[0];
tass picotcp@tass.be 149:5f4cb161cec3 112 } hopbyhop;
daniele 3:b4047e8a0123 113
tass 152:a3d286bf94e5 114 PEDANTIC_STRUCT_DEF destopt_s {
tass picotcp@tass.be 149:5f4cb161cec3 115 uint8_t len;
tass picotcp@tass.be 149:5f4cb161cec3 116 uint8_t options[0];
tass picotcp@tass.be 149:5f4cb161cec3 117 } destopt;
tass picotcp@tass.be 149:5f4cb161cec3 118
tass 152:a3d286bf94e5 119 PEDANTIC_STRUCT_DEF routing_s {
tass picotcp@tass.be 149:5f4cb161cec3 120 uint8_t len;
tass picotcp@tass.be 149:5f4cb161cec3 121 uint8_t routtype;
tass picotcp@tass.be 149:5f4cb161cec3 122 uint8_t segleft;
tass picotcp@tass.be 149:5f4cb161cec3 123 } routing;
tass picotcp@tass.be 149:5f4cb161cec3 124
tass 152:a3d286bf94e5 125 PEDANTIC_STRUCT_DEF fragmentation_s {
tass picotcp@tass.be 149:5f4cb161cec3 126 uint8_t res;
tass 152:a3d286bf94e5 127 uint8_t om[2];
tass picotcp@tass.be 149:5f4cb161cec3 128 uint8_t id[4];
tass 152:a3d286bf94e5 129 } frag;
tass picotcp@tass.be 149:5f4cb161cec3 130 } ext;
tass picotcp@tass.be 149:5f4cb161cec3 131 };
daniele 3:b4047e8a0123 132
tass picotcp@tass.be 149:5f4cb161cec3 133 int pico_ipv6_compare(struct pico_ip6 *a, struct pico_ip6 *b);
tass picotcp@tass.be 149:5f4cb161cec3 134 int pico_string_to_ipv6(const char *ipstr, uint8_t *ip);
tass picotcp@tass.be 149:5f4cb161cec3 135 int pico_ipv6_to_string(char *ipbuf, const uint8_t ip[PICO_SIZE_IP6]);
tass picotcp@tass.be 149:5f4cb161cec3 136 int pico_ipv6_is_unicast(struct pico_ip6 *a);
tass picotcp@tass.be 149:5f4cb161cec3 137 int pico_ipv6_is_multicast(const uint8_t addr[PICO_SIZE_IP6]);
tass 152:a3d286bf94e5 138 int pico_ipv6_is_allhosts_multicast(const uint8_t addr[PICO_SIZE_IP6]);
tass 152:a3d286bf94e5 139 int pico_ipv6_is_solnode_multicast(const uint8_t addr[PICO_SIZE_IP6], struct pico_device *dev);
tass picotcp@tass.be 149:5f4cb161cec3 140 int pico_ipv6_is_global(const uint8_t addr[PICO_SIZE_IP6]);
tass picotcp@tass.be 149:5f4cb161cec3 141 int pico_ipv6_is_uniquelocal(const uint8_t addr[PICO_SIZE_IP6]);
tass picotcp@tass.be 149:5f4cb161cec3 142 int pico_ipv6_is_sitelocal(const uint8_t addr[PICO_SIZE_IP6]);
tass picotcp@tass.be 149:5f4cb161cec3 143 int pico_ipv6_is_linklocal(const uint8_t addr[PICO_SIZE_IP6]);
tass picotcp@tass.be 149:5f4cb161cec3 144 int pico_ipv6_is_solicited(const uint8_t addr[PICO_SIZE_IP6]);
tass picotcp@tass.be 149:5f4cb161cec3 145 int pico_ipv6_is_unspecified(const uint8_t addr[PICO_SIZE_IP6]);
tass 152:a3d286bf94e5 146 int pico_ipv6_is_localhost(const uint8_t addr[PICO_SIZE_IP6]);
daniele 3:b4047e8a0123 147
tass 152:a3d286bf94e5 148 int pico_ipv6_frame_push(struct pico_frame *f, struct pico_ip6 *src, struct pico_ip6 *dst, uint8_t proto, int is_dad);
tass picotcp@tass.be 149:5f4cb161cec3 149 int pico_ipv6_route_add(struct pico_ip6 address, struct pico_ip6 netmask, struct pico_ip6 gateway, int metric, struct pico_ipv6_link *link);
tass 152:a3d286bf94e5 150 int pico_ipv6_route_del(struct pico_ip6 address, struct pico_ip6 netmask, struct pico_ip6 gateway, int metric, struct pico_ipv6_link *link);
tass picotcp@tass.be 149:5f4cb161cec3 151 void pico_ipv6_unreachable(struct pico_frame *f, uint8_t code);
daniele 3:b4047e8a0123 152
tass 152:a3d286bf94e5 153 struct pico_ipv6_link *pico_ipv6_link_add(struct pico_device *dev, struct pico_ip6 address, struct pico_ip6 netmask);
tass picotcp@tass.be 149:5f4cb161cec3 154 int pico_ipv6_link_del(struct pico_device *dev, struct pico_ip6 address);
tass picotcp@tass.be 149:5f4cb161cec3 155 int pico_ipv6_cleanup_links(struct pico_device *dev);
tass picotcp@tass.be 149:5f4cb161cec3 156 struct pico_ipv6_link *pico_ipv6_link_istentative(struct pico_ip6 *address);
tass picotcp@tass.be 149:5f4cb161cec3 157 struct pico_ipv6_link *pico_ipv6_link_get(struct pico_ip6 *address);
tass picotcp@tass.be 149:5f4cb161cec3 158 struct pico_device *pico_ipv6_link_find(struct pico_ip6 *address);
tass picotcp@tass.be 149:5f4cb161cec3 159 struct pico_ip6 pico_ipv6_route_get_gateway(struct pico_ip6 *addr);
tass picotcp@tass.be 149:5f4cb161cec3 160 struct pico_ip6 *pico_ipv6_source_find(const struct pico_ip6 *dst);
tass 152:a3d286bf94e5 161 struct pico_device *pico_ipv6_source_dev_find(const struct pico_ip6 *dst);
tass picotcp@tass.be 149:5f4cb161cec3 162 struct pico_ipv6_link *pico_ipv6_link_by_dev(struct pico_device *dev);
tass picotcp@tass.be 149:5f4cb161cec3 163 struct pico_ipv6_link *pico_ipv6_link_by_dev_next(struct pico_device *dev, struct pico_ipv6_link *last);
tass 152:a3d286bf94e5 164 struct pico_ipv6_link *pico_ipv6_global_get(struct pico_device *dev);
tass 152:a3d286bf94e5 165 struct pico_ipv6_link *pico_ipv6_linklocal_get(struct pico_device *dev);
tass 152:a3d286bf94e5 166 struct pico_ipv6_link *pico_ipv6_sitelocal_get(struct pico_device *dev);
tass 152:a3d286bf94e5 167 struct pico_ipv6_link *pico_ipv6_prefix_configured(struct pico_ip6 *prefix);
tass 152:a3d286bf94e5 168 int pico_ipv6_lifetime_set(struct pico_ipv6_link *l, pico_time expire);
tass 152:a3d286bf94e5 169 void pico_ipv6_check_lifetime_expired(pico_time now, void *arg);
tass 152:a3d286bf94e5 170 int pico_ipv6_dev_routing_enable(struct pico_device *dev);
tass 152:a3d286bf94e5 171 int pico_ipv6_dev_routing_disable(struct pico_device *dev);
tass 152:a3d286bf94e5 172 void pico_ipv6_router_down(struct pico_ip6 *address);
tass 152:a3d286bf94e5 173
tass 152:a3d286bf94e5 174 int pico_ipv6_mcast_join(struct pico_ip6 *mcast_link, struct pico_ip6 *mcast_group, uint8_t reference_count, uint8_t filter_mode, struct pico_tree *_MCASTFilter);
tass 152:a3d286bf94e5 175 int pico_ipv6_mcast_leave(struct pico_ip6 *mcast_link, struct pico_ip6 *mcast_group, uint8_t reference_count, uint8_t filter_mode, struct pico_tree *_MCASTFilter);
tass 152:a3d286bf94e5 176
tass 152:a3d286bf94e5 177 struct pico_ipv6_link *pico_ipv6_get_default_mcastlink(void);
tass 152:a3d286bf94e5 178
tass 152:a3d286bf94e5 179 int pico_ipv6_is_null_address(struct pico_ip6 * ip6);
daniele 3:b4047e8a0123 180 #endif