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:
51:ab4529a384a6
Parent:
3:b4047e8a0123
--- a/modules/pico_http_util.c	Tue Aug 06 08:04:03 2013 +0000
+++ b/modules/pico_http_util.c	Mon Sep 02 08:02:21 2013 +0000
@@ -11,176 +11,176 @@
 #include "pico_protocol.h"
 #include "pico_http_util.h"
 
-#define TRUE    1
+#define TRUE	1
 #define FALSE 0
 
-#define HTTP_PROTO_TOK        "http://"
-#define HTTP_PROTO_LEN        7u
+#define HTTP_PROTO_TOK		"http://"
+#define HTTP_PROTO_LEN		7u
 
 #if defined PICO_SUPPORT_HTTP_CLIENT || defined PICO_SUPPORT_HTTP_SERVER
 
 int pico_itoaHex(uint16_t port, char * ptr)
 {
-    int size = 0;
-    int index;
+	int size = 0;
+	int index;
 
-    // transform to from number to string [ in backwards ]
-    while(port)
-    {
-        ptr[size] = ((port & 0xF) < 10) ? ((port & 0xF) + '0') : ((port & 0xF) - 10 + 'a');
-        port = port>>4u; //divide by 16
-        size++;
-    }
+	// transform to from number to string [ in backwards ]
+	while(port)
+	{
+		ptr[size] = ((port & 0xF) < 10) ? ((port & 0xF) + '0') : ((port & 0xF) - 10 + 'a');
+		port = port>>4u; //divide by 16
+		size++;
+	}
 
-    // invert positions
-    for(index=0 ;index < size>>1u ;index++)
-    {
-        char c = ptr[index];
-        ptr[index] = ptr[size-index-1];
-        ptr[size-index-1] = c;
-    }
-    ptr[size] = '\0';
-    return size;
+	// invert positions
+	for(index=0 ;index < size>>1u ;index++)
+	{
+		char c = ptr[index];
+		ptr[index] = ptr[size-index-1];
+		ptr[size-index-1] = c;
+	}
+	ptr[size] = '\0';
+	return size;
 }
 
 int pico_itoa(uint16_t port, char * ptr)
 {
-    int size = 0;
-    int index;
+	int size = 0;
+	int index;
 
-    // transform to from number to string [ in backwards ]
-    while(port)
-    {
-        ptr[size] = port%10 + '0';
-        port = port/10;
-        size++;
-    }
+	// transform to from number to string [ in backwards ]
+	while(port)
+	{
+		ptr[size] = port%10 + '0';
+		port = port/10;
+		size++;
+	}
 
-    // invert positions
-    for(index=0 ;index < size>>1u ;index++)
-    {
-        char c = ptr[index];
-        ptr[index] = ptr[size-index-1];
-        ptr[size-index-1] = c;
-    }
-    ptr[size] = '\0';
-    return size;
+	// invert positions
+	for(index=0 ;index < size>>1u ;index++)
+	{
+		char c = ptr[index];
+		ptr[index] = ptr[size-index-1];
+		ptr[size-index-1] = c;
+	}
+	ptr[size] = '\0';
+	return size;
 }
 
 
 int pico_processURI(const char * uri, struct pico_http_uri * urikey)
 {
 
-    uint16_t lastIndex = 0, index;
+	uint16_t lastIndex = 0, index;
 
-    if(!uri || !urikey || uri[0] == '/')
-    {
-        pico_err = PICO_ERR_EINVAL;
-        goto error;
-    }
+	if(!uri || !urikey || uri[0] == '/')
+	{
+		pico_err = PICO_ERR_EINVAL;
+		goto error;
+	}
 
-    // detect protocol => search for  "://"
-    if(memcmp(uri,HTTP_PROTO_TOK,HTTP_PROTO_LEN) == 0) // could be optimized
-    { // protocol identified, it is http
-        urikey->protoHttp = TRUE;
-        lastIndex = HTTP_PROTO_LEN;
-    }
-    else
-    {
-        if(strstr(uri,"://")) // different protocol specified
-        {
-            urikey->protoHttp = FALSE;
-            goto error;
-        }
-        // no protocol specified, assuming by default it's http
-        urikey->protoHttp = TRUE;
-    }
+	// detect protocol => search for  "://"
+	if(memcmp(uri,HTTP_PROTO_TOK,HTTP_PROTO_LEN) == 0) // could be optimized
+	{ // protocol identified, it is http
+		urikey->protoHttp = TRUE;
+		lastIndex = HTTP_PROTO_LEN;
+	}
+	else
+	{
+		if(strstr(uri,"://")) // different protocol specified
+		{
+			urikey->protoHttp = FALSE;
+			goto error;
+		}
+		// no protocol specified, assuming by default it's http
+		urikey->protoHttp = TRUE;
+	}
 
-    // detect hostname
-    index = lastIndex;
-    while(uri[index] && uri[index]!='/' && uri[index]!=':') index++;
+	// detect hostname
+	index = lastIndex;
+	while(uri[index] && uri[index]!='/' && uri[index]!=':') index++;
 
-    if(index == lastIndex)
-    {
-        // wrong format
-        urikey->host = urikey->resource = NULL;
-        urikey->port = urikey->protoHttp = 0u;
+	if(index == lastIndex)
+	{
+		// wrong format
+		urikey->host = urikey->resource = NULL;
+		urikey->port = urikey->protoHttp = 0u;
 
-        goto error;
-    }
-    else
-    {
-        // extract host
-        urikey->host = (char *)pico_zalloc(index-lastIndex+1);
+		goto error;
+	}
+	else
+	{
+		// extract host
+		urikey->host = (char *)pico_zalloc(index-lastIndex+1);
 
-        if(!urikey->host)
-        {
-            // no memory
-            goto error;
-        }
-        memcpy(urikey->host,uri+lastIndex,index-lastIndex);
-    }
+		if(!urikey->host)
+		{
+			// no memory
+			goto error;
+		}
+		memcpy(urikey->host,uri+lastIndex,index-lastIndex);
+	}
 
-    if(!uri[index])
-    {
-        // nothing specified
-        urikey->port = 80u;
-        urikey->resource = pico_zalloc(2u);
-        urikey->resource[0] = '/';
-        return HTTP_RETURN_OK;
-    }
-    else if(uri[index] == '/')
-    {
-        urikey->port = 80u;
-    }
-    else if(uri[index] == ':')
-    {
-        urikey->port = 0u;
-        index++;
-        while(uri[index] && uri[index]!='/')
-        {
-            // should check if every component is a digit
-            urikey->port = urikey->port*10 + (uri[index] - '0');
-            index++;
-        }
-    }
+	if(!uri[index])
+	{
+		// nothing specified
+		urikey->port = 80u;
+		urikey->resource = pico_zalloc(2u);
+		urikey->resource[0] = '/';
+		return HTTP_RETURN_OK;
+	}
+	else if(uri[index] == '/')
+	{
+		urikey->port = 80u;
+	}
+	else if(uri[index] == ':')
+	{
+		urikey->port = 0u;
+		index++;
+		while(uri[index] && uri[index]!='/')
+		{
+			// should check if every component is a digit
+			urikey->port = urikey->port*10 + (uri[index] - '0');
+			index++;
+		}
+	}
 
   // extract resource
-    if(!uri[index])
-    {
-        urikey->resource = pico_zalloc(2u);
-        urikey->resource[0] = '/';
-    }
-    else
-    {
-        lastIndex = index;
-        while(uri[index] && uri[index]!='?' && uri[index]!='&' && uri[index]!='#') index++;
-        urikey->resource = (char *)pico_zalloc(index-lastIndex+1);
+	if(!uri[index])
+	{
+		urikey->resource = pico_zalloc(2u);
+		urikey->resource[0] = '/';
+	}
+	else
+	{
+		lastIndex = index;
+		while(uri[index] && uri[index]!='?' && uri[index]!='&' && uri[index]!='#') index++;
+		urikey->resource = (char *)pico_zalloc(index-lastIndex+1);
 
-        if(!urikey->resource)
-        {
-            // no memory
-            pico_err = PICO_ERR_ENOMEM;
-            goto error;
-        }
+		if(!urikey->resource)
+		{
+			// no memory
+			pico_err = PICO_ERR_ENOMEM;
+			goto error;
+		}
 
-        memcpy(urikey->resource,uri+lastIndex,index-lastIndex);
-    }
+		memcpy(urikey->resource,uri+lastIndex,index-lastIndex);
+	}
 
-    return HTTP_RETURN_OK;
+	return HTTP_RETURN_OK;
 
-    error :
-    if(urikey->resource)
-    {
-        pico_free(urikey->resource);
-        urikey->resource = NULL;
-    }
-    if(urikey->host)
-    {
-        pico_free(urikey->host);
-        urikey->host = NULL;
-    }
+	error :
+	if(urikey->resource)
+	{
+		pico_free(urikey->resource);
+		urikey->resource = NULL;
+	}
+	if(urikey->host)
+	{
+		pico_free(urikey->host);
+		urikey->host = NULL;
+	}
 
-    return HTTP_RETURN_ERROR;
+	return HTTP_RETURN_ERROR;
 }
 #endif