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:
149:5f4cb161cec3
Parent:
131:4758606c9316
Child:
152:a3d286bf94e5
--- a/modules/pico_igmp.c	Tue Mar 11 15:34:51 2014 +0100
+++ b/modules/pico_igmp.c	Wed Apr 09 14:31:41 2014 +0200
@@ -79,14 +79,14 @@
 #define IP_OPTION_ROUTER_ALERT_LEN        (4u)
 #define IGMP_MAX_GROUPS                   (32) /* max 255 */
 
-struct __attribute__((packed)) igmp_message {
+PACKED_STRUCT_DEF igmp_message {
     uint8_t type;
     uint8_t max_resp_time;
     uint16_t crc;
     uint32_t mcast_group;
 };
 
-struct __attribute__((packed)) igmpv3_query {
+PACKED_STRUCT_DEF igmpv3_query {
     uint8_t type;
     uint8_t max_resp_time;
     uint16_t crc;
@@ -97,7 +97,7 @@
     uint32_t source_addr[];
 };
 
-struct __attribute__((packed)) igmpv3_group_record {
+PACKED_STRUCT_DEF igmpv3_group_record {
     uint8_t type;
     uint8_t aux;
     uint16_t sources;
@@ -105,7 +105,7 @@
     uint32_t source_addr[];
 };
 
-struct __attribute__((packed)) igmpv3_report {
+PACKED_STRUCT_DEF igmpv3_report {
     uint8_t type;
     uint8_t res0;
     uint16_t crc;
@@ -215,6 +215,9 @@
     struct igmp_parameters test = {
         0
     };
+    if (!mcast_link || !mcast_group)
+        return NULL;
+
     test.mcast_link.addr = mcast_link->addr;
     test.mcast_group.addr = mcast_group->addr;
     return pico_tree_findKey(&IGMPParameters, &test);
@@ -223,7 +226,7 @@
 static int pico_igmp_delete_parameter(struct igmp_parameters *p)
 {
     if (pico_tree_delete(&IGMPParameters, p))
-        pico_free(p);
+        PICO_FREE(p);
     else
         return -1;
 
@@ -248,7 +251,7 @@
     }
 
     if (timer->stopped == IGMP_TIMER_STOPPED) {
-        pico_free(t);
+        PICO_FREE(t);
         return;
     }
 
@@ -257,7 +260,7 @@
         if (timer->callback)
             timer->callback(timer);
 
-        pico_free(timer);
+        PICO_FREE(timer);
     } else {
         igmp_dbg("IGMP: restart timer for %08X, delay %lu, new delay %lu\n", t->mcast_group.addr, t->delay,  (timer->start + timer->delay) - PICO_TIME_MS());
         pico_timer_add((timer->start + timer->delay) - PICO_TIME_MS(), &pico_igmp_timer_expired, timer);
@@ -299,7 +302,7 @@
     if (timer)
         return pico_igmp_timer_reset(t);
 
-    timer = pico_zalloc(sizeof(struct igmp_timer));
+    timer = PICO_ZALLOC(sizeof(struct igmp_timer));
     if (!timer) {
         pico_err = PICO_ERR_ENOMEM;
         return -1;
@@ -488,7 +491,7 @@
     mcast_group.addr = message->mcast_group;
     p = pico_igmp_find_parameter(&link->address, &mcast_group);
     if (!p && mcast_group.addr == 0) { /* general query */
-        p = pico_zalloc(sizeof(struct igmp_parameters));
+        p = PICO_ZALLOC(sizeof(struct igmp_parameters));
         if (!p)
             return NULL;
 
@@ -572,12 +575,17 @@
 
     p = pico_igmp_find_parameter(mcast_link, mcast_group);
     if (!p && state == PICO_IGMP_STATE_CREATE) {
-        p = pico_zalloc(sizeof(struct igmp_parameters));
+        p = PICO_ZALLOC(sizeof(struct igmp_parameters));
         if (!p) {
             pico_err = PICO_ERR_ENOMEM;
             return -1;
         }
 
+        if (!mcast_link || !mcast_group) {
+            pico_err = PICO_ERR_EINVAL;
+            return -1;
+        }
+
         p->state = IGMP_STATE_NON_MEMBER;
         p->mcast_link = *mcast_link;
         p->mcast_group = *mcast_group;
@@ -1154,7 +1162,7 @@
         return -1;
 
     time_to_run = (uint32_t)(t->start + t->delay - PICO_TIME_MS());
-    if ((p->max_resp_time * 100) < time_to_run) { /* max_resp_time in units of 1/10 seconds */
+    if ((p->max_resp_time * 100u) < time_to_run) { /* max_resp_time in units of 1/10 seconds */
         t->delay = pico_rand() % (p->max_resp_time * 100u);
         pico_igmp_timer_reset(t);
     }