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.
modules/pico_ipv4.h@137:a1c8bfa9d691, 2014-02-07 (annotated)
- Committer:
- tass picotcp@tass.be
- Date:
- Fri Feb 07 11:21:12 2014 +0100
- Revision:
- 137:a1c8bfa9d691
- Parent:
- 131:4758606c9316
- Child:
- 149:5f4cb161cec3
Update from masterbranch
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tass | 68:0847e35d08a6 | 1 | /********************************************************************* |
TASS Belgium NV |
131:4758606c9316 | 2 | PicoTCP. Copyright (c) 2012 TASS Belgium NV. Some rights reserved. |
TASS Belgium NV |
131:4758606c9316 | 3 | See LICENSE and COPYING for usage. |
tass | 68:0847e35d08a6 | 4 | |
TASS Belgium NV |
131:4758606c9316 | 5 | . |
tass | 68:0847e35d08a6 | 6 | |
TASS Belgium NV |
131:4758606c9316 | 7 | *********************************************************************/ |
tass | 68:0847e35d08a6 | 8 | #ifndef _INCLUDE_PICO_IPV4 |
tass | 68:0847e35d08a6 | 9 | #define _INCLUDE_PICO_IPV4 |
tass | 68:0847e35d08a6 | 10 | #include "pico_addressing.h" |
tass | 68:0847e35d08a6 | 11 | #include "pico_protocol.h" |
tass | 68:0847e35d08a6 | 12 | #include "pico_tree.h" |
tass | 68:0847e35d08a6 | 13 | |
tass | 68:0847e35d08a6 | 14 | #define PICO_IPV4_INADDR_ANY 0x00000000U |
tass | 68:0847e35d08a6 | 15 | |
tass | 74:c146c4e346c4 | 16 | #define PICO_SIZE_IP4HDR (uint32_t)((sizeof(struct pico_ipv4_hdr))) |
tass | 68:0847e35d08a6 | 17 | #define PICO_IPV4_DONTFRAG 0x4000 |
tass | 68:0847e35d08a6 | 18 | #define PICO_IPV4_MOREFRAG 0x2000 |
tass | 68:0847e35d08a6 | 19 | #define PICO_IPV4_FRAG_MASK 0x1FFF |
tass | 68:0847e35d08a6 | 20 | #define PICO_IPV4_DEFAULT_TTL 64 |
tass | 111:4003cf17bc15 | 21 | #ifndef MBED |
tass | 111:4003cf17bc15 | 22 | #define PICO_IPV4_FRAG_MAX_SIZE (63 * 1024) |
tass | 111:4003cf17bc15 | 23 | #else |
TASS Belgium NV |
131:4758606c9316 | 24 | #define PICO_IPV4_FRAG_MAX_SIZE PICO_DEFAULT_SOCKETQ |
tass | 111:4003cf17bc15 | 25 | #endif |
tass | 68:0847e35d08a6 | 26 | |
tass | 68:0847e35d08a6 | 27 | extern struct pico_protocol pico_proto_ipv4; |
tass | 68:0847e35d08a6 | 28 | |
tass | 68:0847e35d08a6 | 29 | struct __attribute__((packed)) pico_ipv4_hdr { |
TASS Belgium NV |
131:4758606c9316 | 30 | uint8_t vhl; |
TASS Belgium NV |
131:4758606c9316 | 31 | uint8_t tos; |
TASS Belgium NV |
131:4758606c9316 | 32 | uint16_t len; |
TASS Belgium NV |
131:4758606c9316 | 33 | uint16_t id; |
TASS Belgium NV |
131:4758606c9316 | 34 | uint16_t frag; |
TASS Belgium NV |
131:4758606c9316 | 35 | uint8_t ttl; |
TASS Belgium NV |
131:4758606c9316 | 36 | uint8_t proto; |
TASS Belgium NV |
131:4758606c9316 | 37 | uint16_t crc; |
TASS Belgium NV |
131:4758606c9316 | 38 | struct pico_ip4 src; |
TASS Belgium NV |
131:4758606c9316 | 39 | struct pico_ip4 dst; |
TASS Belgium NV |
131:4758606c9316 | 40 | uint8_t options[]; |
tass | 68:0847e35d08a6 | 41 | }; |
tass | 68:0847e35d08a6 | 42 | |
tass | 68:0847e35d08a6 | 43 | struct __attribute__((packed)) pico_ipv4_pseudo_hdr |
tass | 68:0847e35d08a6 | 44 | { |
TASS Belgium NV |
131:4758606c9316 | 45 | struct pico_ip4 src; |
TASS Belgium NV |
131:4758606c9316 | 46 | struct pico_ip4 dst; |
TASS Belgium NV |
131:4758606c9316 | 47 | uint8_t zeros; |
TASS Belgium NV |
131:4758606c9316 | 48 | uint8_t proto; |
TASS Belgium NV |
131:4758606c9316 | 49 | uint16_t len; |
tass | 68:0847e35d08a6 | 50 | }; |
tass | 68:0847e35d08a6 | 51 | |
tass | 68:0847e35d08a6 | 52 | /* Interface: link to device */ |
tass | 68:0847e35d08a6 | 53 | struct pico_mcast_list; |
tass | 68:0847e35d08a6 | 54 | |
tass | 68:0847e35d08a6 | 55 | struct pico_ipv4_link |
tass | 68:0847e35d08a6 | 56 | { |
TASS Belgium NV |
131:4758606c9316 | 57 | struct pico_device *dev; |
TASS Belgium NV |
131:4758606c9316 | 58 | struct pico_ip4 address; |
TASS Belgium NV |
131:4758606c9316 | 59 | struct pico_ip4 netmask; |
tass | 68:0847e35d08a6 | 60 | #ifdef PICO_SUPPORT_MCAST |
TASS Belgium NV |
131:4758606c9316 | 61 | struct pico_tree *MCASTGroups; |
TASS Belgium NV |
131:4758606c9316 | 62 | uint8_t mcast_compatibility; |
TASS Belgium NV |
131:4758606c9316 | 63 | uint8_t mcast_last_query_interval; |
tass | 68:0847e35d08a6 | 64 | #endif |
tass | 68:0847e35d08a6 | 65 | }; |
tass | 68:0847e35d08a6 | 66 | |
tass | 68:0847e35d08a6 | 67 | #ifdef PICO_SUPPORT_MCAST |
tass | 68:0847e35d08a6 | 68 | struct pico_mcast_group { |
TASS Belgium NV |
131:4758606c9316 | 69 | uint8_t filter_mode; |
TASS Belgium NV |
131:4758606c9316 | 70 | uint16_t reference_count; |
TASS Belgium NV |
131:4758606c9316 | 71 | struct pico_ip4 mcast_addr; |
TASS Belgium NV |
131:4758606c9316 | 72 | struct pico_tree MCASTSources; |
tass | 68:0847e35d08a6 | 73 | }; |
tass | 68:0847e35d08a6 | 74 | #endif |
tass | 68:0847e35d08a6 | 75 | |
tass | 68:0847e35d08a6 | 76 | int pico_ipv4_to_string(char *ipbuf, const uint32_t ip); |
tass | 68:0847e35d08a6 | 77 | int pico_string_to_ipv4(const char *ipstr, uint32_t *ip); |
tass | 68:0847e35d08a6 | 78 | int pico_ipv4_valid_netmask(uint32_t mask); |
TASS Belgium NV |
131:4758606c9316 | 79 | int pico_ipv4_is_unicast(uint32_t address); |
TASS Belgium NV |
131:4758606c9316 | 80 | int pico_ipv4_is_multicast(uint32_t address); |
tass | 68:0847e35d08a6 | 81 | int pico_ipv4_is_broadcast(uint32_t addr); |
tass picotcp@tass.be | 137:a1c8bfa9d691 | 82 | int pico_ipv4_is_loopback(uint32_t addr); |
tass picotcp@tass.be | 137:a1c8bfa9d691 | 83 | int pico_ipv4_is_valid_src(uint32_t addr); |
tass | 68:0847e35d08a6 | 84 | |
tass | 68:0847e35d08a6 | 85 | int pico_ipv4_link_add(struct pico_device *dev, struct pico_ip4 address, struct pico_ip4 netmask); |
tass | 68:0847e35d08a6 | 86 | int pico_ipv4_link_del(struct pico_device *dev, struct pico_ip4 address); |
tass | 68:0847e35d08a6 | 87 | int pico_ipv4_rebound(struct pico_frame *f); |
tass | 68:0847e35d08a6 | 88 | |
tass | 68:0847e35d08a6 | 89 | int pico_ipv4_frame_push(struct pico_frame *f, struct pico_ip4 *dst, uint8_t proto); |
tass | 68:0847e35d08a6 | 90 | struct pico_ipv4_link *pico_ipv4_link_get(struct pico_ip4 *address); |
tass | 68:0847e35d08a6 | 91 | struct pico_ipv4_link *pico_ipv4_link_by_dev(struct pico_device *dev); |
tass | 74:c146c4e346c4 | 92 | struct pico_ipv4_link *pico_ipv4_link_by_dev_next(struct pico_device *dev, struct pico_ipv4_link *last); |
tass | 68:0847e35d08a6 | 93 | struct pico_device *pico_ipv4_link_find(struct pico_ip4 *address); |
tass | 68:0847e35d08a6 | 94 | struct pico_ip4 *pico_ipv4_source_find(const struct pico_ip4 *dst); |
tass | 68:0847e35d08a6 | 95 | int pico_ipv4_route_add(struct pico_ip4 address, struct pico_ip4 netmask, struct pico_ip4 gateway, int metric, struct pico_ipv4_link *link); |
tass | 72:887bc44746ff | 96 | int pico_ipv4_route_del(struct pico_ip4 address, struct pico_ip4 netmask, int metric); |
tass | 68:0847e35d08a6 | 97 | struct pico_ip4 pico_ipv4_route_get_gateway(struct pico_ip4 *addr); |
tass | 68:0847e35d08a6 | 98 | void pico_ipv4_unreachable(struct pico_frame *f, int err); |
tass | 68:0847e35d08a6 | 99 | |
tass | 68:0847e35d08a6 | 100 | int pico_ipv4_mcast_join(struct pico_ip4 *mcast_link, struct pico_ip4 *mcast_group, uint8_t reference_count, uint8_t filter_mode, struct pico_tree *MCASTFilter); |
tass | 68:0847e35d08a6 | 101 | int pico_ipv4_mcast_leave(struct pico_ip4 *mcast_link, struct pico_ip4 *mcast_group, uint8_t reference_count, uint8_t filter_mode, struct pico_tree *MCASTFilter); |
tass | 68:0847e35d08a6 | 102 | struct pico_ipv4_link *pico_ipv4_get_default_mcastlink(void); |
tass | 68:0847e35d08a6 | 103 | |
tass | 68:0847e35d08a6 | 104 | #endif /* _INCLUDE_PICO_IPV4 */ |