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 picotcp@tass.be
Date:
Tue Feb 11 14:44:54 2014 +0100
Revision:
139:1f7a4a8525ef
Parent:
58:5f6eedbbbd5b
Child:
142:35da43068894
Added support for DHCP server

Who changed what in which revision?

UserRevisionLine numberNew contents of line
daniele 29:1a47b7151851 1 /*********************************************************************
daniele 29:1a47b7151851 2 PicoTCP. Copyright (c) 2013 TASS Belgium NV. Some rights reserved.
daniele 29:1a47b7151851 3 See LICENSE and COPYING for usage.
daniele 29:1a47b7151851 4
daniele 29:1a47b7151851 5 Author: Daniele Lacamera <daniele.lacamera@tass.be>
daniele 29:1a47b7151851 6 *********************************************************************/
daniele 29:1a47b7151851 7
daniele 29:1a47b7151851 8 #ifndef __PICOTCP_BSD_LAYER
daniele 29:1a47b7151851 9 #define __PICOTCP_BSD_LAYER
daniele 29:1a47b7151851 10
daniele 29:1a47b7151851 11 extern "C" {
daniele 29:1a47b7151851 12 #include "pico_stack.h"
daniele 29:1a47b7151851 13 #include "pico_tree.h"
daniele 29:1a47b7151851 14 #include "pico_dns_client.h"
daniele 29:1a47b7151851 15 #include "pico_socket.h"
daniele 29:1a47b7151851 16 #include "pico_addressing.h"
daniele 29:1a47b7151851 17 #include "pico_protocol.h"
daniele 29:1a47b7151851 18 #include "pico_config.h"
daniele 29:1a47b7151851 19 #include "pico_ipv4.h"
daniele 29:1a47b7151851 20 #include "pico_device.h"
daniele 29:1a47b7151851 21 };
daniele 29:1a47b7151851 22 #include "mbed.h"
daniele 29:1a47b7151851 23 #include "rtos.h"
daniele 29:1a47b7151851 24 #include "Queue.h"
daniele 29:1a47b7151851 25 #include "PicoCondition.h"
daniele 29:1a47b7151851 26
daniele 29:1a47b7151851 27 struct sockaddr;
daniele 29:1a47b7151851 28
daniele 29:1a47b7151851 29 struct ip_addr_s {
daniele 29:1a47b7151851 30 uint32_t s_addr;
daniele 29:1a47b7151851 31 };
daniele 29:1a47b7151851 32
daniele 29:1a47b7151851 33 typedef struct ip_addr_s ip_addr_t;
daniele 29:1a47b7151851 34
daniele 29:1a47b7151851 35 struct sockaddr_in
daniele 29:1a47b7151851 36 {
daniele 29:1a47b7151851 37 ip_addr_t sin_addr;
daniele 29:1a47b7151851 38 uint16_t sin_family;
daniele 29:1a47b7151851 39 uint16_t sin_port;
daniele 29:1a47b7151851 40 };
daniele 29:1a47b7151851 41
daniele 29:1a47b7151851 42 struct timeval {
daniele 29:1a47b7151851 43 uint32_t tv_sec;
daniele 29:1a47b7151851 44 uint32_t tv_usec;
daniele 29:1a47b7151851 45 };
daniele 29:1a47b7151851 46
daniele 29:1a47b7151851 47 /* Description of data base entry for a single host. */
daniele 29:1a47b7151851 48 struct hostent
daniele 29:1a47b7151851 49 {
daniele 29:1a47b7151851 50 char *h_name; /* Official name of host. */
daniele 29:1a47b7151851 51 char **h_aliases; /* Alias list. */
daniele 29:1a47b7151851 52 int h_addrtype; /* Host address type. */
daniele 29:1a47b7151851 53 int h_length; /* Length of address. */
daniele 29:1a47b7151851 54 char **h_addr_list; /* List of addresses from name server. */
daniele 29:1a47b7151851 55 # define h_addr h_addr_list[0] /* Address, for backward compatibility.*/
daniele 29:1a47b7151851 56 };
daniele 29:1a47b7151851 57
daniele 29:1a47b7151851 58 #ifndef PF_INET
daniele 29:1a47b7151851 59 #define PF_INET 2
daniele 29:1a47b7151851 60 #define PF_INET6 10
daniele 29:1a47b7151851 61 #define AF_INET PF_INET
daniele 29:1a47b7151851 62 #define AF_INET6 PF_INET6
daniele 29:1a47b7151851 63
daniele 29:1a47b7151851 64 #define SOCK_STREAM 1
daniele 29:1a47b7151851 65 #define SOCK_DGRAM 2
daniele 29:1a47b7151851 66
daniele 29:1a47b7151851 67 #define SOL_SOCKET 1
daniele 29:1a47b7151851 68 #define SO_BROADCAST 6
daniele 29:1a47b7151851 69
daniele 29:1a47b7151851 70 #define INADDR_ANY 0u
daniele 29:1a47b7151851 71
daniele 29:1a47b7151851 72 #endif
daniele 29:1a47b7151851 73
tass 44:ffd9a11d4f95 74 //#define mbed_dbg printf
tass 44:ffd9a11d4f95 75 #define mbed_dbg(...)
tass 44:ffd9a11d4f95 76
daniele 29:1a47b7151851 77 enum socket_state_e {
daniele 29:1a47b7151851 78 SOCK_OPEN,
daniele 29:1a47b7151851 79 SOCK_BOUND,
daniele 29:1a47b7151851 80 SOCK_LISTEN,
daniele 29:1a47b7151851 81 SOCK_CONNECTED,
tass 32:865c101e0874 82 SOCK_RESET_BY_PEER,
daniele 29:1a47b7151851 83 SOCK_CLOSED
daniele 29:1a47b7151851 84 };
daniele 29:1a47b7151851 85
daniele 29:1a47b7151851 86 typedef int socklen_t;
daniele 29:1a47b7151851 87
daniele 29:1a47b7151851 88 void picotcp_init(void);
daniele 29:1a47b7151851 89
daniele 29:1a47b7151851 90 struct stack_endpoint * picotcp_socket(uint16_t net, uint16_t proto, uint16_t flags);
daniele 29:1a47b7151851 91 int picotcp_state(struct stack_endpoint *);
daniele 29:1a47b7151851 92 int picotcp_bind(struct stack_endpoint *, struct sockaddr *local_addr, socklen_t len);
daniele 29:1a47b7151851 93
daniele 29:1a47b7151851 94 int picotcp_listen(struct stack_endpoint *, int queue);
daniele 29:1a47b7151851 95 int picotcp_connect(struct stack_endpoint *, struct sockaddr *srv_addr, socklen_t len);
daniele 29:1a47b7151851 96 struct stack_endpoint * picotcp_accept(struct stack_endpoint *, struct sockaddr *orig, socklen_t *);
daniele 29:1a47b7151851 97 int picotcp_select(struct stack_endpoint *, struct timeval *timeout, int read, int write);
daniele 29:1a47b7151851 98
daniele 29:1a47b7151851 99 int picotcp_send(struct stack_endpoint *,void * buff, int len, int flags);
daniele 29:1a47b7151851 100 int picotcp_recv(struct stack_endpoint *,void * buff, int len, int flags);
daniele 29:1a47b7151851 101 int picotcp_sendto(struct stack_endpoint *,void * buff, int len, struct sockaddr*,socklen_t);
daniele 29:1a47b7151851 102 int picotcp_recvfrom(struct stack_endpoint *,void * buff, int len, struct sockaddr *, socklen_t *);
daniele 29:1a47b7151851 103 int picotcp_read(struct stack_endpoint *,void *buf, int len);
daniele 29:1a47b7151851 104 int picotcp_write(struct stack_endpoint *,void *buf, int len);
daniele 29:1a47b7151851 105 int picotcp_setsockopt(struct stack_endpoint *, int option, void *value);
daniele 29:1a47b7151851 106 int picotcp_getsockopt(struct stack_endpoint *, int option, void *value);
daniele 29:1a47b7151851 107 struct hostent * picotcp_gethostbyname(const char *url);
daniele 29:1a47b7151851 108 char * picotcp_gethostbyaddr(const char *ip);
daniele 29:1a47b7151851 109 int picotcp_close(struct stack_endpoint *);
daniele 29:1a47b7151851 110 // set blocking
daniele 29:1a47b7151851 111 int picotcp_setblocking(struct stack_endpoint *,int blocking);
daniele 29:1a47b7151851 112 int picotcp_join_multicast(struct stack_endpoint *,const char* address,const char* local);
daniele 29:1a47b7151851 113
tass 58:5f6eedbbbd5b 114 void picotcp_async_interrupt(void *arg);
tass 37:bdf736327c71 115 struct hostent *picotcp_gethostbyname(const char *name);
daniele 29:1a47b7151851 116
tass picotcp@tass.be 139:1f7a4a8525ef 117 int picotcp_dhcp_server_start(struct pico_dhcp_server_setting *setting);
daniele 29:1a47b7151851 118 #endif