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
--- a/modules/pico_udp.c	Wed Apr 09 17:32:25 2014 +0200
+++ b/modules/pico_udp.c	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.
 
    .
@@ -15,7 +15,7 @@
 #include "pico_stack.h"
 
 #define UDP_FRAME_OVERHEAD (sizeof(struct pico_frame))
-
+#define udp_dbg(...) do {} while(0)
 
 /* Queues */
 static struct pico_queue udp_in = {
@@ -37,12 +37,12 @@
 
     if (s) {
         /* Case of outgoing frame */
-        /* dbg("UDP CRC: on outgoing frame\n"); */
+        udp_dbg("UDP CRC: on outgoing frame\n");
         pseudo.src.addr = s->local_addr.ip4.addr;
         pseudo.dst.addr = s->remote_addr.ip4.addr;
     } else {
         /* Case of incomming frame */
-        /* dbg("UDP CRC: on incomming frame\n"); */
+        udp_dbg("UDP CRC: on incomming frame\n");
         pseudo.src.addr = hdr->src.addr;
         pseudo.dst.addr = hdr->dst.addr;
     }
@@ -59,7 +59,9 @@
 {
     struct pico_ipv6_hdr *ipv6_hdr = (struct pico_ipv6_hdr *)f->net_hdr;
     struct pico_udp_hdr *udp_hdr = (struct pico_udp_hdr *)f->transport_hdr;
-    struct pico_ipv6_pseudo_hdr pseudo;
+    struct pico_ipv6_pseudo_hdr pseudo = {
+        .src = {{0}}, .dst = {{0}}, .len = 0, .zero = {0}, .nxthdr = 0
+    };
     struct pico_socket *s = f->sock;
     struct pico_remote_endpoint *remote_endpoint = (struct pico_remote_endpoint *)f->info;
 
@@ -154,7 +156,28 @@
     return &u->sock;
 }
 
-uint16_t pico_udp_recv(struct pico_socket *s, void *buf, uint16_t len, void *src, uint16_t *port)
+static void pico_udp_get_msginfo(struct pico_frame *f, struct pico_msginfo *msginfo)
+{
+    msginfo->dev = f->dev;
+    if (!msginfo || !f->net_hdr)
+        return;
+
+    if (IS_IPV4(f)) { /* IPV4 */
+#ifdef PICO_SUPPORT_IPV4
+        struct pico_ipv4_hdr *hdr = (struct pico_ipv4_hdr *)(f->net_hdr);
+        msginfo->ttl = hdr->ttl;
+        msginfo->tos = hdr->tos;
+#endif
+    } else {
+#ifdef PICO_SUPPORT_IPV6
+        struct pico_ipv6_hdr *hdr = (struct pico_ipv6_hdr *)(f->net_hdr);
+        msginfo->ttl = hdr->hop;
+        msginfo->tos = (hdr->vtf >> 20) & 0xFF; /* IPv6 traffic class */
+#endif
+    }
+}
+
+uint16_t pico_udp_recv(struct pico_socket *s, void *buf, uint16_t len, void *src, uint16_t *port, struct pico_msginfo *msginfo)
 {
     struct pico_frame *f = pico_queue_peek(&s->q_in);
     if (f) {
@@ -163,7 +186,7 @@
             f->payload_len = (uint16_t)(f->transport_len - sizeof(struct pico_udp_hdr));
         }
 
-        /*    dbg("expected: %d, got: %d\n", len, f->payload_len); */
+        udp_dbg("expected: %d, got: %d\n", len, f->payload_len);
         if (src)
             pico_store_network_origin(src, f);
 
@@ -172,6 +195,10 @@
             *port = hdr->sport;
         }
 
+        if (msginfo) {
+            pico_udp_get_msginfo(f, msginfo);
+        }
+
         if (f->payload_len > len) {
             memcpy(buf, f->payload, len);
             f->payload += len;