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.

Committer:
tass
Date:
Thu Jan 28 15:12:00 2016 +0100
Revision:
155:a70f34550c34
Parent:
44:ffd9a11d4f95
Adding TCP flag for FIN.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
daniele 20:3fa3db9fd4a4 1 /*
daniele 20:3fa3db9fd4a4 2 *
daniele 20:3fa3db9fd4a4 3 * PicoTCP Socket interface for mbed.
daniele 20:3fa3db9fd4a4 4 * Copyright (C) 2013 TASS Belgium NV
daniele 20:3fa3db9fd4a4 5 *
daniele 20:3fa3db9fd4a4 6 * Released under GPL v2
daniele 20:3fa3db9fd4a4 7 *
daniele 20:3fa3db9fd4a4 8 * Other licensing models might apply at the sole discretion of the copyright holders.
daniele 20:3fa3db9fd4a4 9 *
daniele 20:3fa3db9fd4a4 10 *
daniele 20:3fa3db9fd4a4 11 * This software is based on the mbed.org EthernetInterface implementation:
daniele 20:3fa3db9fd4a4 12 * Copyright (C) 2012 mbed.org, MIT License
daniele 20:3fa3db9fd4a4 13 *
daniele 20:3fa3db9fd4a4 14 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
daniele 20:3fa3db9fd4a4 15 * and associated documentation files (the "Software"), to deal in the Software without restriction,
daniele 20:3fa3db9fd4a4 16 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
daniele 20:3fa3db9fd4a4 17 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
daniele 20:3fa3db9fd4a4 18 * furnished to do so, subject to the following conditions:
daniele 20:3fa3db9fd4a4 19 *
daniele 20:3fa3db9fd4a4 20 * The above copyright notice and this permission notice shall be included in all copies or
daniele 20:3fa3db9fd4a4 21 * substantial portions of the Software.
daniele 20:3fa3db9fd4a4 22 *
daniele 20:3fa3db9fd4a4 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
daniele 20:3fa3db9fd4a4 24 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
daniele 20:3fa3db9fd4a4 25 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
daniele 20:3fa3db9fd4a4 26 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
daniele 20:3fa3db9fd4a4 27 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
daniele 20:3fa3db9fd4a4 28 */
daniele 20:3fa3db9fd4a4 29 #include "Socket/Socket.h"
daniele 20:3fa3db9fd4a4 30 #include "Socket/Endpoint.h"
daniele 20:3fa3db9fd4a4 31 #include "wrapper.h"
daniele 20:3fa3db9fd4a4 32 #include "proxy_endpoint.h"
daniele 20:3fa3db9fd4a4 33
daniele 20:3fa3db9fd4a4 34 extern "C"
daniele 20:3fa3db9fd4a4 35 {
daniele 20:3fa3db9fd4a4 36 #include "pico_ipv4.h"
daniele 20:3fa3db9fd4a4 37 }
daniele 20:3fa3db9fd4a4 38 #include <cstring>
daniele 20:3fa3db9fd4a4 39 #include <cstdio>
daniele 20:3fa3db9fd4a4 40
daniele 20:3fa3db9fd4a4 41 Endpoint::Endpoint() {
daniele 20:3fa3db9fd4a4 42 reset_address();
daniele 20:3fa3db9fd4a4 43 }
daniele 20:3fa3db9fd4a4 44 Endpoint::~Endpoint() {}
daniele 20:3fa3db9fd4a4 45
daniele 20:3fa3db9fd4a4 46 void Endpoint::reset_address(void) {
daniele 20:3fa3db9fd4a4 47 memset(&_remoteHost,0,sizeof(_remoteHost));
daniele 20:3fa3db9fd4a4 48 }
daniele 20:3fa3db9fd4a4 49
daniele 20:3fa3db9fd4a4 50 #include "stdio.h"
daniele 20:3fa3db9fd4a4 51
daniele 20:3fa3db9fd4a4 52 int Endpoint::set_address(const char* host, const int port) {
daniele 20:3fa3db9fd4a4 53 _remoteHost.sin_port = short_be(port);
tass 37:bdf736327c71 54 if(pico_string_to_ipv4(host,&_remoteHost.sin_addr.s_addr) < 0)
tass 37:bdf736327c71 55 {
tass 37:bdf736327c71 56 // execute a dns query because this is a name
tass 37:bdf736327c71 57 struct hostent * _host = gethostbyname(host);
tass 37:bdf736327c71 58 if(_host && _host->h_addr_list[0])
tass 37:bdf736327c71 59 {
tass 37:bdf736327c71 60 memcpy(_ipAddress,_host->h_addr_list[0],strlen(_host->h_addr_list[0])+1);
tass 44:ffd9a11d4f95 61 mbed_dbg("Dns result : %s\n",_ipAddress);
tass 37:bdf736327c71 62 pico_string_to_ipv4(_ipAddress,&_remoteHost.sin_addr.s_addr);
tass 37:bdf736327c71 63 delete _host->h_name;
tass 37:bdf736327c71 64 delete _host->h_addr_list;
tass 37:bdf736327c71 65 delete _host;
tass 37:bdf736327c71 66 }
tass 37:bdf736327c71 67 else
tass 37:bdf736327c71 68 return -1;
tass 37:bdf736327c71 69 }
tass 37:bdf736327c71 70 else
tass 37:bdf736327c71 71 memcpy(_ipAddress,host, strlen(host)+1);
tass 37:bdf736327c71 72
daniele 20:3fa3db9fd4a4 73 return 0;
daniele 20:3fa3db9fd4a4 74 }
daniele 20:3fa3db9fd4a4 75
daniele 20:3fa3db9fd4a4 76 char* Endpoint::get_address() {
daniele 20:3fa3db9fd4a4 77 return _ipAddress;
daniele 20:3fa3db9fd4a4 78 }
daniele 20:3fa3db9fd4a4 79
daniele 20:3fa3db9fd4a4 80 int Endpoint::get_port() {
daniele 20:3fa3db9fd4a4 81 return short_be(_remoteHost.sin_port);
daniele 20:3fa3db9fd4a4 82 }