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 Sep 19 12:38:53 2013 +0000
Revision:
63:97f481e33cb2
Parent:
51:ab4529a384a6
Update from the master branch

Who changed what in which revision?

UserRevisionLine numberNew contents of line
daniele 3:b4047e8a0123 1 /*********************************************************************
daniele 3:b4047e8a0123 2 PicoTCP. Copyright (c) 2012 TASS Belgium NV. Some rights reserved.
daniele 3:b4047e8a0123 3 See LICENSE and COPYING for usage.
daniele 3:b4047e8a0123 4
daniele 3:b4047e8a0123 5 .
daniele 3:b4047e8a0123 6
daniele 3:b4047e8a0123 7 *********************************************************************/
daniele 3:b4047e8a0123 8 #ifndef _INCLUDE_PICO_DHCP_COMMON
daniele 3:b4047e8a0123 9 #define _INCLUDE_PICO_DHCP_COMMON
tass 63:97f481e33cb2 10
tass 63:97f481e33cb2 11
tass 63:97f481e33cb2 12 #include <stdint.h>
tass 63:97f481e33cb2 13
tass 63:97f481e33cb2 14 //minimum size is 576, cfr RFC
tass 63:97f481e33cb2 15 #define DHCPC_DATAGRAM_SIZE 576
tass 63:97f481e33cb2 16 #define DHCPD_DATAGRAM_SIZE 576
tass 63:97f481e33cb2 17
daniele 3:b4047e8a0123 18
daniele 3:b4047e8a0123 19 #define PICO_DHCPD_PORT (short_be(67))
daniele 3:b4047e8a0123 20 #define PICO_DHCP_CLIENT_PORT (short_be(68))
tass 63:97f481e33cb2 21
tass 63:97f481e33cb2 22 #define PICO_DHCP_OP_REQUEST 1
tass 63:97f481e33cb2 23 #define PICO_DHCP_OP_REPLY 2
daniele 3:b4047e8a0123 24
tass 63:97f481e33cb2 25 #define PICO_HTYPE_ETHER 1
tass 63:97f481e33cb2 26 #define PICO_HLEN_ETHER 6
tass 63:97f481e33cb2 27
tass 63:97f481e33cb2 28 #define PICO_DHCPD_MAGIC_COOKIE (long_be(0x63825363))
daniele 3:b4047e8a0123 29
tass 63:97f481e33cb2 30 /* DHCP OPTIONS, RFC2132 */
tass 63:97f481e33cb2 31 #define PICO_DHCPOPT_PAD 0x00
tass 63:97f481e33cb2 32 #define PICO_DHCPOPT_NETMASK 0x01
tass 63:97f481e33cb2 33 #define PICO_DHCPOPT_TIME 0x02
tass 63:97f481e33cb2 34 #define PICO_DHCPOPT_ROUTER 0x03
tass 63:97f481e33cb2 35 #define PICO_DHCPOPT_DNS 0x06
tass 63:97f481e33cb2 36 #define PICO_DHCPOPT_HOSTNAME 0x0c
tass 63:97f481e33cb2 37 #define PICO_DHCPOPT_DOMAINNAME 0x0f
tass 63:97f481e33cb2 38 #define PICO_DHCPOPT_MTU 0x1a
tass 63:97f481e33cb2 39 #define PICO_DHCPOPT_BCAST 0x1c
tass 63:97f481e33cb2 40 #define PICO_DHCPOPT_NETBIOSNS 0x2c
tass 63:97f481e33cb2 41 #define PICO_DHCPOPT_NETBIOSSCOPE 0x2f
daniele 3:b4047e8a0123 42
tass 63:97f481e33cb2 43 #define PICO_DHCPOPT_REQIP 0x32
tass 63:97f481e33cb2 44 #define PICO_DHCPOPT_LEASETIME 0x33
tass 63:97f481e33cb2 45 #define PICO_DHCPOPT_OPTIONOVERLOAD 0x34
tass 63:97f481e33cb2 46 #define PICO_DHCPOPT_MSGTYPE 0x35
tass 63:97f481e33cb2 47 #define PICO_DHCPOPT_SERVERID 0x36
tass 63:97f481e33cb2 48 #define PICO_DHCPOPT_PARMLIST 0x37
tass 63:97f481e33cb2 49 #define PICO_DHCPOPT_MAXMSGSIZE 0x39
tass 63:97f481e33cb2 50 #define PICO_DHCPOPT_RENEWALTIME 0x3a
tass 63:97f481e33cb2 51 #define PICO_DHCPOPT_REBINDINGTIME 0x3b
tass 63:97f481e33cb2 52 #define PICO_DHCPOPT_DOMAINSEARCH 0x77
tass 63:97f481e33cb2 53 #define PICO_DHCPOPT_STATICROUTE 0x79
tass 63:97f481e33cb2 54 #define PICO_DHCPOPT_END 0xFF
tass 51:ab4529a384a6 55
tass 63:97f481e33cb2 56 /* DHCP MESSAGE TYPE */
tass 63:97f481e33cb2 57 #define PICO_DHCP_MSG_DISCOVER 1
tass 63:97f481e33cb2 58 #define PICO_DHCP_MSG_OFFER 2
tass 63:97f481e33cb2 59 #define PICO_DHCP_MSG_REQUEST 3
tass 63:97f481e33cb2 60 #define PICO_DHCP_MSG_DECLINE 4
tass 63:97f481e33cb2 61 #define PICO_DHCP_MSG_ACK 5
tass 63:97f481e33cb2 62 #define PICO_DHCP_MSG_NAK 6
tass 63:97f481e33cb2 63 #define PICO_DHCP_MSG_RELEASE 7
tass 63:97f481e33cb2 64 #define PICO_DHCP_MSG_INFORM 8
tass 63:97f481e33cb2 65
daniele 3:b4047e8a0123 66
tass 63:97f481e33cb2 67 enum dhcp_negotiation_state {
tass 63:97f481e33cb2 68 DHCPSTATE_DISCOVER = 0,
tass 63:97f481e33cb2 69 DHCPSTATE_OFFER,
tass 63:97f481e33cb2 70 DHCPSTATE_REQUEST,
tass 63:97f481e33cb2 71 DHCPSTATE_BOUND,
tass 63:97f481e33cb2 72 DHCPSTATE_RENEWING
tass 63:97f481e33cb2 73 };
tass 51:ab4529a384a6 74
daniele 3:b4047e8a0123 75
tass 63:97f481e33cb2 76 struct __attribute__((packed)) pico_dhcphdr
tass 51:ab4529a384a6 77 {
tass 51:ab4529a384a6 78 uint8_t op;
tass 51:ab4529a384a6 79 uint8_t htype;
tass 51:ab4529a384a6 80 uint8_t hlen;
tass 51:ab4529a384a6 81 uint8_t hops; //zero
tass 51:ab4529a384a6 82 uint32_t xid; //store this in the request
tass 51:ab4529a384a6 83 uint16_t secs; // ignore
tass 51:ab4529a384a6 84 uint16_t flags;
tass 51:ab4529a384a6 85 uint32_t ciaddr; // client address - if asking for renewal
tass 51:ab4529a384a6 86 uint32_t yiaddr; // your address (client)
tass 51:ab4529a384a6 87 uint32_t siaddr; // dhcp offered address
tass 51:ab4529a384a6 88 uint32_t giaddr; // relay agent, bootp.
tass 51:ab4529a384a6 89 uint8_t hwaddr[6];
tass 51:ab4529a384a6 90 uint8_t hwaddr_padding[10];
tass 51:ab4529a384a6 91 char hostname[64];
tass 51:ab4529a384a6 92 char bootp_filename[128];
tass 51:ab4529a384a6 93 uint32_t dhcp_magic;
tass 51:ab4529a384a6 94 uint8_t options[0];
daniele 3:b4047e8a0123 95 };
daniele 3:b4047e8a0123 96
tass 63:97f481e33cb2 97
tass 63:97f481e33cb2 98 //common functions for client and server
daniele 3:b4047e8a0123 99
tass 51:ab4529a384a6 100 uint8_t dhcp_get_next_option(uint8_t *begin, uint8_t *data, int *len, uint8_t **nextopt);
tass 63:97f481e33cb2 101 int is_options_valid(uint8_t *opt_buffer, int len);
daniele 3:b4047e8a0123 102 #endif