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:
152:a3d286bf94e5
Adding TCP flag for FIN.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
daniele 3:b4047e8a0123 1 /*********************************************************************
tass 152:a3d286bf94e5 2 PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved.
TASS Belgium NV 131:4758606c9316 3 See LICENSE and COPYING for usage.
daniele 3:b4047e8a0123 4
TASS Belgium NV 131:4758606c9316 5 *********************************************************************/
tass picotcp@tass.be 149:5f4cb161cec3 6 #ifndef INCLUDE_PICO_FRAME
tass picotcp@tass.be 149:5f4cb161cec3 7 #define INCLUDE_PICO_FRAME
daniele 3:b4047e8a0123 8 #include "pico_config.h"
daniele 3:b4047e8a0123 9
daniele 3:b4047e8a0123 10
tass 152:a3d286bf94e5 11 #define PICO_FRAME_FLAG_BCAST (0x01)
tass 152:a3d286bf94e5 12 #define PICO_FRAME_FLAG_EXT_BUFFER (0x02)
tass 152:a3d286bf94e5 13 #define PICO_FRAME_FLAG_EXT_USAGE_COUNTER (0x04)
tass 152:a3d286bf94e5 14 #define PICO_FRAME_FLAG_SACKED (0x80)
daniele 3:b4047e8a0123 15 #define IS_BCAST(f) ((f->flags & PICO_FRAME_FLAG_BCAST) == PICO_FRAME_FLAG_BCAST)
daniele 3:b4047e8a0123 16
daniele 3:b4047e8a0123 17
daniele 3:b4047e8a0123 18 struct pico_socket;
daniele 3:b4047e8a0123 19
daniele 3:b4047e8a0123 20
daniele 3:b4047e8a0123 21 struct pico_frame {
daniele 3:b4047e8a0123 22
TASS Belgium NV 131:4758606c9316 23 /* Connector for queues */
TASS Belgium NV 131:4758606c9316 24 struct pico_frame *next;
daniele 3:b4047e8a0123 25
TASS Belgium NV 131:4758606c9316 26 /* Start of the whole buffer, total frame length. */
TASS Belgium NV 131:4758606c9316 27 unsigned char *buffer;
TASS Belgium NV 131:4758606c9316 28 uint32_t buffer_len;
daniele 3:b4047e8a0123 29
TASS Belgium NV 131:4758606c9316 30 /* For outgoing packets: this is the meaningful buffer. */
TASS Belgium NV 131:4758606c9316 31 unsigned char *start;
TASS Belgium NV 131:4758606c9316 32 uint32_t len;
daniele 3:b4047e8a0123 33
TASS Belgium NV 131:4758606c9316 34 /* Pointer to usage counter */
TASS Belgium NV 131:4758606c9316 35 uint32_t *usage_count;
daniele 3:b4047e8a0123 36
TASS Belgium NV 131:4758606c9316 37 /* Pointer to protocol headers */
TASS Belgium NV 131:4758606c9316 38 uint8_t *datalink_hdr;
daniele 3:b4047e8a0123 39
TASS Belgium NV 131:4758606c9316 40 uint8_t *net_hdr;
TASS Belgium NV 131:4758606c9316 41 uint16_t net_len;
TASS Belgium NV 131:4758606c9316 42 uint8_t *transport_hdr;
TASS Belgium NV 131:4758606c9316 43 uint16_t transport_len;
TASS Belgium NV 131:4758606c9316 44 uint8_t *app_hdr;
TASS Belgium NV 131:4758606c9316 45 uint16_t app_len;
daniele 3:b4047e8a0123 46
TASS Belgium NV 131:4758606c9316 47 /* Pointer to the phisical device this packet belongs to.
TASS Belgium NV 131:4758606c9316 48 * Should be valid in both routing directions
TASS Belgium NV 131:4758606c9316 49 */
TASS Belgium NV 131:4758606c9316 50 struct pico_device *dev;
daniele 3:b4047e8a0123 51
TASS Belgium NV 131:4758606c9316 52 pico_time timestamp;
daniele 3:b4047e8a0123 53
TASS Belgium NV 131:4758606c9316 54 /* Failures due to bad datalink addressing. */
TASS Belgium NV 131:4758606c9316 55 uint16_t failure_count;
daniele 3:b4047e8a0123 56
TASS Belgium NV 131:4758606c9316 57 /* Protocol over IP */
TASS Belgium NV 131:4758606c9316 58 uint8_t proto;
daniele 3:b4047e8a0123 59
TASS Belgium NV 131:4758606c9316 60 /* PICO_FRAME_FLAG_* */
TASS Belgium NV 131:4758606c9316 61 uint8_t flags;
daniele 3:b4047e8a0123 62
TASS Belgium NV 131:4758606c9316 63 /* Pointer to payload */
TASS Belgium NV 131:4758606c9316 64 unsigned char *payload;
TASS Belgium NV 131:4758606c9316 65 uint16_t payload_len;
daniele 3:b4047e8a0123 66
tass 152:a3d286bf94e5 67 #if defined(PICO_SUPPORT_IPV4FRAG) || defined(PICO_SUPPORT_IPV6FRAG)
tass 152:a3d286bf94e5 68 /* Payload fragmentation info */
TASS Belgium NV 131:4758606c9316 69 uint16_t frag;
daniele 3:b4047e8a0123 70 #endif
daniele 3:b4047e8a0123 71
TASS Belgium NV 131:4758606c9316 72 /* Pointer to socket */
TASS Belgium NV 131:4758606c9316 73 struct pico_socket *sock;
daniele 3:b4047e8a0123 74
tass picotcp@tass.be 149:5f4cb161cec3 75 /* Pointer to transport info, used to store remote UDP endpoint (IP + port) */
TASS Belgium NV 131:4758606c9316 76 void *info;
daniele 3:b4047e8a0123 77
TASS Belgium NV 131:4758606c9316 78 /*Priority. "best-effort" priority, the default value is 0. Priority can be in between -10 and +10*/
TASS Belgium NV 131:4758606c9316 79 int8_t priority;
TASS Belgium NV 131:4758606c9316 80 uint8_t transport_flags_saved;
tass 152:a3d286bf94e5 81
tass 152:a3d286bf94e5 82 /* Callback to notify listener when the buffer has been discarded */
tass 152:a3d286bf94e5 83 void (*notify_free)(uint8_t *);
tass 152:a3d286bf94e5 84
tass 152:a3d286bf94e5 85 uint8_t send_ttl; /* Special TTL/HOPS value, 0 = auto assign */
tass 152:a3d286bf94e5 86 uint8_t send_tos; /* Type of service */
daniele 3:b4047e8a0123 87 };
daniele 3:b4047e8a0123 88
daniele 3:b4047e8a0123 89 /** frame alloc/dealloc/copy **/
daniele 3:b4047e8a0123 90 void pico_frame_discard(struct pico_frame *f);
daniele 3:b4047e8a0123 91 struct pico_frame *pico_frame_copy(struct pico_frame *f);
daniele 3:b4047e8a0123 92 struct pico_frame *pico_frame_deepcopy(struct pico_frame *f);
tass 70:cd218dd180e5 93 struct pico_frame *pico_frame_alloc(uint32_t size);
tass 152:a3d286bf94e5 94 int pico_frame_grow(struct pico_frame *f, uint32_t size);
tass 152:a3d286bf94e5 95 struct pico_frame *pico_frame_alloc_skeleton(uint32_t size, int ext_buffer);
tass picotcp@tass.be 149:5f4cb161cec3 96 int pico_frame_skeleton_set_buffer(struct pico_frame *f, void *buf);
tass 70:cd218dd180e5 97 uint16_t pico_checksum(void *inbuf, uint32_t len);
tass 70:cd218dd180e5 98 uint16_t pico_dualbuffer_checksum(void *b1, uint32_t len1, void *b2, uint32_t len2);
daniele 3:b4047e8a0123 99
daniele 3:b4047e8a0123 100 static inline int pico_is_digit(char c)
daniele 3:b4047e8a0123 101 {
TASS Belgium NV 131:4758606c9316 102 if (c < '0' || c > '9')
TASS Belgium NV 131:4758606c9316 103 return 0;
TASS Belgium NV 131:4758606c9316 104
TASS Belgium NV 131:4758606c9316 105 return 1;
daniele 3:b4047e8a0123 106 }
daniele 3:b4047e8a0123 107
tass picotcp@tass.be 149:5f4cb161cec3 108 static inline int pico_is_hex(char c)
tass picotcp@tass.be 149:5f4cb161cec3 109 {
tass picotcp@tass.be 149:5f4cb161cec3 110 if (c >= '0' && c <= '9')
tass picotcp@tass.be 149:5f4cb161cec3 111 return 1;
tass picotcp@tass.be 149:5f4cb161cec3 112
tass picotcp@tass.be 149:5f4cb161cec3 113 if (c >= 'a' && c <= 'f')
tass picotcp@tass.be 149:5f4cb161cec3 114 return 1;
tass picotcp@tass.be 149:5f4cb161cec3 115
tass picotcp@tass.be 149:5f4cb161cec3 116 if (c >= 'A' && c <= 'F')
tass picotcp@tass.be 149:5f4cb161cec3 117 return 1;
tass picotcp@tass.be 149:5f4cb161cec3 118
tass picotcp@tass.be 149:5f4cb161cec3 119 return 0;
tass picotcp@tass.be 149:5f4cb161cec3 120 }
tass picotcp@tass.be 149:5f4cb161cec3 121
daniele 3:b4047e8a0123 122 #endif