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