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.

Files at this revision

API Documentation at this revision

Comitter:
tass picotcp@tass.be
Date:
Wed Feb 19 15:12:53 2014 +0100
Parent:
140:bb24e339e40b
Child:
143:073e03cc28a5
Commit message:
Fixed some warnings in mbed wrapper code, moved setDnsServer implementation to stack_endpoint

Changed in this revision

EthernetInterface/EthernetInterface.cpp Show annotated file Show diff for this revision Revisions of this file
EthernetInterface/EthernetInterface.h Show annotated file Show diff for this revision Revisions of this file
Socket/Socket.h Show annotated file Show diff for this revision Revisions of this file
Socket/TCPSocketConnection.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/bsd/proxy_endpoint.h Show annotated file Show diff for this revision Revisions of this file
Socket/bsd/stack_endpoint.cpp Show annotated file Show diff for this revision Revisions of this file
include/arch/pico_mbed.h Show annotated file Show diff for this revision Revisions of this file
modules/pico_mbed.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/EthernetInterface/EthernetInterface.cpp	Tue Feb 11 14:48:37 2014 +0100
+++ b/EthernetInterface/EthernetInterface.cpp	Wed Feb 19 15:12:53 2014 +0100
@@ -225,11 +225,9 @@
     return 0;
 }
 
-int EthernetInterface::setDnsServer(const char * name)
+int EthernetInterface::setDnsServer(const char * ip)
 {
-    struct pico_ip4 addr;
-    pico_string_to_ipv4(name,&addr.addr);
-    return pico_dns_client_nameserver(&addr,PICO_DNS_NS_ADD);
+    return picotcp_dns_client_nameserver(ip, PICO_DNS_NS_ADD);
 }
 
 int EthernetInterface::createIpFilter(char *ipAddress, char * netmask, int port, filter_type filter)
@@ -285,4 +283,4 @@
 int EthernetInterface::destroyIpFilter(int filter_id)
 {
     return pico_ipv4_filter_del(filter_id);
-}
\ No newline at end of file
+}
--- a/EthernetInterface/EthernetInterface.h	Tue Feb 11 14:48:37 2014 +0100
+++ b/EthernetInterface/EthernetInterface.h	Wed Feb 19 15:12:53 2014 +0100
@@ -102,10 +102,10 @@
   static int registerLinkStatus(void (*cb)(uint32_t linkStatus));
   
   
-  /** Register a callback to tell the status of the link.
-   * \return 0 if callback was registered.
+  /** Set/Add an ip address of a DNS server
+   * \return 0 on success, a negative number on failure
    */
-  static int setDnsServer(const char *);
+  static int setDnsServer(const char *ip);
   
   /**
   * Creates a custom rule for dropping packets.
--- a/Socket/Socket.h	Tue Feb 11 14:48:37 2014 +0100
+++ b/Socket/Socket.h	Wed Feb 19 15:12:53 2014 +0100
@@ -93,7 +93,7 @@
     int is_writable(void);
     
     bool _blocking;
-    unsigned int _timeout;
+    pico_time _timeout;
     
 private:
     int select(struct timeval *timeout, bool read, bool write);
--- a/Socket/TCPSocketConnection.cpp	Tue Feb 11 14:48:37 2014 +0100
+++ b/Socket/TCPSocketConnection.cpp	Wed Feb 19 15:12:53 2014 +0100
@@ -66,8 +66,8 @@
 
 int TCPSocketConnection::send(char* data, int length) {
     int ret;
-    int localTimeout = _timeout;
-    int finalTimeout = PICO_TIME_MS() + _timeout;
+    pico_time localTimeout = _timeout;
+    pico_time finalTimeout = PICO_TIME_MS() + _timeout;
     if (!is_connected())
         return -1;
     
--- a/Socket/bsd/proxy_endpoint.h	Tue Feb 11 14:48:37 2014 +0100
+++ b/Socket/bsd/proxy_endpoint.h	Wed Feb 19 15:12:53 2014 +0100
@@ -115,4 +115,6 @@
 struct hostent *picotcp_gethostbyname(const char *name);
 
 int picotcp_dhcp_server_start(struct pico_dhcp_server_setting *setting);
+int picotcp_dns_client_nameserver(const char *ip, int flag);
+
 #endif
--- a/Socket/bsd/stack_endpoint.cpp	Tue Feb 11 14:48:37 2014 +0100
+++ b/Socket/bsd/stack_endpoint.cpp	Wed Feb 19 15:12:53 2014 +0100
@@ -11,6 +11,7 @@
 #include "mbed.h"
 #include "Socket.h"
 #include "Mutex.h"
+#include "PicoTerm.h"
 
 extern "C"
 {
@@ -22,7 +23,7 @@
 //#define ptsock_dbg mbed_dbg
 #define ptsock_dbg(...)
 #define SCHEDULER_BASE  4u
-#define SCHEDULER_MAX   10u
+#define SCHEDULER_MAX   10
 
 int scheduler_timeout = 0;
 int in_the_stack = 0;
@@ -545,6 +546,20 @@
 
 
 // *************** DNS part *************** 
+
+int picotcp_dns_client_nameserver(const char *ip, int flag)
+{
+    int ret;
+    struct pico_ip4 addr;
+    pico_string_to_ipv4(ip, &addr.addr);
+
+    PicoTcpLock->lock();
+    ret = pico_dns_client_nameserver(&addr, flag);
+    PicoTcpLock->unlock();
+
+    return ret;
+}
+
 void dns_cb(char *ip,void *arg)
 {
   if(!arg)
--- a/include/arch/pico_mbed.h	Tue Feb 11 14:48:37 2014 +0100
+++ b/include/arch/pico_mbed.h	Wed Feb 19 15:12:53 2014 +0100
@@ -86,9 +86,8 @@
 #ifdef TIME_PRESCALE
 extern int32_t prescale_time;
 #endif
-extern uint32_t os_time;
 
-#define UPDATE_LOCAL_TIME() do{local_time=local_time+(os_time-last_os_time);last_os_time=os_time;}while(0)
+#define UPDATE_LOCAL_TIME() do {local_time = local_time + ((pico_time)os_time - (pico_time)last_os_time);last_os_time = os_time;} while(0)
 
 static inline uint64_t PICO_TIME(void)
 {
--- a/modules/pico_mbed.cpp	Tue Feb 11 14:48:37 2014 +0100
+++ b/modules/pico_mbed.cpp	Wed Feb 19 15:12:53 2014 +0100
@@ -4,7 +4,7 @@
 extern "C" {
 #include "pico_config.h"
 
-    uint64_t local_time;
+    pico_time local_time;
     uint32_t last_os_time;
 
     void *pico_mutex_init(void)
@@ -29,8 +29,8 @@
 int freeStack = STACK_TOTAL_WORDS;
 void stack_fill_pattern(void * ptr)
 {
-    int * movingPtr = (int *)ptr;
-    int * finalPtr = movingPtr - STACK_TOTAL_WORDS;
+    uint32_t * movingPtr = (uint32_t *)ptr;
+    uint32_t * finalPtr = movingPtr - STACK_TOTAL_WORDS;
     while(movingPtr >= finalPtr)
     {
         *movingPtr = STACK_PATTERN;
@@ -40,8 +40,8 @@
 
 void stack_count_free_words(void *ptr)
 {
-    int * movingPtr = (int *)ptr;
-    int * finalPtr = movingPtr - STACK_TOTAL_WORDS;
+    uint32_t * movingPtr = (uint32_t *)ptr;
+    uint32_t * finalPtr = movingPtr - STACK_TOTAL_WORDS;
     int tmpFreeStack = 0;
     
     while(finalPtr != movingPtr)