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.

Revision:
152:a3d286bf94e5
Parent:
149:5f4cb161cec3
Child:
154:6c0e92a80c4a
--- a/include/pico_socket.h	Wed Apr 09 17:32:25 2014 +0200
+++ b/include/pico_socket.h	Mon Sep 28 13:16:18 2015 +0200
@@ -1,5 +1,5 @@
 /*********************************************************************
-   PicoTCP. Copyright (c) 2012 TASS Belgium NV. Some rights reserved.
+   PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved.
    See LICENSE and COPYING for usage.
 
  *********************************************************************/
@@ -14,13 +14,26 @@
 #ifdef __linux__
     #define PICO_DEFAULT_SOCKETQ (16 * 1024) /* Linux host, so we want full throttle */
 #else
-    #define PICO_DEFAULT_SOCKETQ (4 * 1024) /* seems like an acceptable default for small embedded systems */
+    #define PICO_DEFAULT_SOCKETQ (6 * 1024) /* seems like an acceptable default for small embedded systems */
 #endif
 
 #define PICO_SHUT_RD   1
 #define PICO_SHUT_WR   2
 #define PICO_SHUT_RDWR 3
 
+#ifdef PICO_SUPPORT_IPV4
+# define IS_SOCK_IPV4(s) ((s->net == &pico_proto_ipv4))
+#else
+# define IS_SOCK_IPV4(s) (0)
+#endif
+
+#ifdef PICO_SUPPORT_IPV6
+# define IS_SOCK_IPV6(s) ((s->net == &pico_proto_ipv6))
+#else
+# define IS_SOCK_IPV6(s) (0)
+#endif
+
+
 struct pico_sockport
 {
     struct pico_tree socks; /* how you make the connection ? */
@@ -55,6 +68,9 @@
 #endif
 #ifdef PICO_SUPPORT_MCAST
     struct pico_tree *MCASTListen;
+#ifdef PICO_SUPPORT_IPV6
+    struct pico_tree *MCASTListen_ipv6;
+#endif 
 #endif
     uint16_t ev_pending;
 
@@ -75,6 +91,7 @@
 
 
 /* request struct for multicast socket opt */
+// Deprecated!
 struct pico_ip_mreq {
     struct pico_ip4 mcast_group_addr;
     struct pico_ip4 mcast_link_addr;
@@ -85,6 +102,18 @@
     struct pico_ip4 mcast_source_addr;
     struct pico_ip4 mcast_link_addr;
 };
+// [end] Deprecated
+// Use this instead:
+struct pico_mreq {
+    union pico_address mcast_group_addr;
+    union pico_address mcast_link_addr;
+};
+struct pico_mreq_source {
+    union pico_address mcast_group_addr;
+    union pico_address mcast_source_addr;
+    union pico_address mcast_link_addr;
+};
+
 
 #define PICO_SOCKET_STATE_UNDEFINED       0x0000u
 #define PICO_SOCKET_STATE_SHUT_LOCAL      0x0001u
@@ -127,15 +156,22 @@
 # define PICO_IP_DROP_SOURCE_MEMBERSHIP       40
 
 # define PICO_SOCKET_OPT_MULTICAST_LOOP       1
+# define PICO_SOCKET_OPT_KEEPIDLE              4
+# define PICO_SOCKET_OPT_KEEPINTVL             5
+# define PICO_SOCKET_OPT_KEEPCNT               6
+
+#define PICO_SOCKET_OPT_LINGER                13
 
 # define PICO_SOCKET_OPT_RCVBUF               52
 # define PICO_SOCKET_OPT_SNDBUF               53
 
+
 /* Constants */
 # define PICO_IP_DEFAULT_MULTICAST_TTL        1
 # define PICO_IP_DEFAULT_MULTICAST_LOOP       1
 
-#define PICO_SOCKET_TIMEOUT                   90000u /* 90 seconds */
+#define PICO_SOCKET_TIMEOUT                   5000u /* 5 seconds */
+#define PICO_SOCKET_LINGER_TIMEOUT            3000u /* 3 seconds */
 #define PICO_SOCKET_BOUND_TIMEOUT             30000u /* 30 seconds */
 
 #define PICO_SOCKET_SHUTDOWN_WRITE 0x01u
@@ -149,6 +185,11 @@
 #define PICO_SOCK_EV_FIN 0x10u
 #define PICO_SOCK_EV_ERR 0x80u
 
+struct pico_msginfo {
+    struct pico_device *dev;
+    uint8_t ttl;
+    uint8_t tos;
+};
 
 struct pico_socket *pico_socket_open(uint16_t net, uint16_t proto, void (*wakeup)(uint16_t ev, struct pico_socket *s));
 
@@ -156,13 +197,19 @@
 int pico_socket_write(struct pico_socket *s, const void *buf, int len);
 
 int pico_socket_sendto(struct pico_socket *s, const void *buf, int len, void *dst, uint16_t remote_port);
+int pico_socket_sendto_extended(struct pico_socket *s, const void *buf, const int len,
+                                void *dst, uint16_t remote_port, struct pico_msginfo *msginfo);
+
 int pico_socket_recvfrom(struct pico_socket *s, void *buf, int len, void *orig, uint16_t *local_port);
+int pico_socket_recvfrom_extended(struct pico_socket *s, void *buf, int len, void *orig,
+                                  uint16_t *remote_port, struct pico_msginfo *msginfo);
 
 int pico_socket_send(struct pico_socket *s, const void *buf, int len);
 int pico_socket_recv(struct pico_socket *s, void *buf, int len);
 
 int pico_socket_bind(struct pico_socket *s, void *local_addr, uint16_t *port);
 int pico_socket_getname(struct pico_socket *s, void *local_addr, uint16_t *port, uint16_t *proto);
+int pico_socket_getpeername(struct pico_socket *s, void *remote_addr, uint16_t *port, uint16_t *proto);
 
 int pico_socket_connect(struct pico_socket *s, const void *srv_addr, uint16_t remote_port);
 int pico_socket_listen(struct pico_socket *s, const int backlog);
@@ -190,13 +237,13 @@
 #endif
 
 #ifdef PICO_SUPPORT_UDP
-# define is_sock_udp(x) (x->net == &pico_proto_udp)
+# define is_sock_udp(x) (x->proto == &pico_proto_udp)
 #else
 # define is_sock_udp(x) (0)
 #endif
 
 #ifdef PICO_SUPPORT_TCP
-# define is_sock_tcp(x) (x->net == &pico_proto_tcp)
+# define is_sock_tcp(x) (x->proto == &pico_proto_tcp)
 #else
 # define is_sock_tcp(x) (0)
 #endif
@@ -215,9 +262,11 @@
 
 struct pico_sockport *pico_get_sockport(uint16_t proto, uint16_t port);
 
-uint16_t pico_socket_get_mtu(struct pico_socket *s);
+uint32_t pico_socket_get_mss(struct pico_socket *s);
 int pico_socket_set_family(struct pico_socket *s, uint16_t family);
 
+int pico_count_sockets(uint8_t proto);
+
 #define PICO_SOCKET_SETOPT_EN(socket, index)  (socket->opt_flags |=  (1 << index))
 #define PICO_SOCKET_SETOPT_DIS(socket, index) (socket->opt_flags &= (uint16_t) ~(1 << index))
 #define PICO_SOCKET_GETOPT(socket, index) ((socket->opt_flags & (1u << index)) != 0)