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.

include/pico_tree.h

Committer:
tass
Date:
2016-01-28
Revision:
155:a70f34550c34
Parent:
152:a3d286bf94e5

File content as of revision 155:a70f34550c34:

/*********************************************************************
   PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved.
   See LICENSE and COPYING for usage.

   Author: Andrei Carp <andrei.carp@tass.be>
 *********************************************************************/

#ifndef PICO_RBTREE_H
#define PICO_RBTREE_H

#include "pico_config.h"

/* This is used to declare a new tree, leaf root by default */
#define PICO_TREE_DECLARE(name, compareFunction) \
    struct pico_tree name = \
    { \
        &LEAF, \
        compareFunction \
    }

#define USE_PICO_PAGE0_ZALLOC (1)
#define USE_PICO_ZALLOC (2)

struct pico_tree_node
{
    void*keyValue; /* generic key */
    struct pico_tree_node*parent;
    struct pico_tree_node*leftChild;
    struct pico_tree_node*rightChild;
    uint8_t color;
};

struct pico_tree
{
    struct pico_tree_node *root;  /* root of the tree */

    /* this function directly provides the keys as parameters not the nodes. */
    int (*compare)(void*keyA, void*keyB);
};

extern struct pico_tree_node LEAF; /* generic leaf node */

#ifdef PICO_SUPPORT_MM
void *pico_tree_insert_implementation(struct pico_tree *tree, void *key, uint8_t allocator);
void *pico_tree_delete_implementation(struct pico_tree *tree, void *key, uint8_t allocator);
#endif


/*
 * Manipulation functions
 */
void *pico_tree_insert(struct pico_tree *tree, void *key);
void *pico_tree_delete(struct pico_tree *tree, void *key);
void *pico_tree_findKey(struct pico_tree *tree, void *key);
void    pico_tree_drop(struct pico_tree *tree);
int     pico_tree_empty(struct pico_tree *tree);
struct pico_tree_node *pico_tree_findNode(struct pico_tree *tree, void *key);

void *pico_tree_first(struct pico_tree *tree);
void *pico_tree_last(struct pico_tree *tree);
/*
 * Traverse functions
 */
struct pico_tree_node *pico_tree_lastNode(struct pico_tree_node *node);
struct pico_tree_node *pico_tree_firstNode(struct pico_tree_node *node);
struct pico_tree_node *pico_tree_next(struct pico_tree_node *node);
struct pico_tree_node *pico_tree_prev(struct pico_tree_node *node);

/*
 * For each macros
 */

#define pico_tree_foreach(idx, tree) \
    for ((idx) = pico_tree_firstNode((tree)->root); \
         (idx) != &LEAF; \
         (idx) = pico_tree_next(idx))

#define pico_tree_foreach_reverse(idx, tree) \
    for ((idx) = pico_tree_lastNode((tree)->root); \
         (idx) != &LEAF; \
         (idx) = pico_tree_prev(idx))

#define pico_tree_foreach_safe(idx, tree, idx2) \
    for ((idx) = pico_tree_firstNode((tree)->root); \
         ((idx) != &LEAF) && ((idx2) = pico_tree_next(idx), 1); \
         (idx) = (idx2))

#define pico_tree_foreach_reverse_safe(idx, tree, idx2) \
    for ((idx) = pico_tree_lastNode((tree)->root); \
         ((idx) != &LEAF) && ((idx2) = pico_tree_prev(idx), 1); \
         (idx) = (idx2))

#endif