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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pico_stack.h Source File

pico_stack.h

00001 /*********************************************************************
00002    PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved.
00003    See LICENSE and COPYING for usage.
00004 
00005  *********************************************************************/
00006 #ifndef INCLUDE_PICO_STACK
00007 #define INCLUDE_PICO_STACK
00008 #include "pico_config.h"
00009 #include "pico_frame.h"
00010 
00011 #define PICO_MAX_TIMERS 20
00012 
00013 #define PICO_ETH_MRU (1514u)
00014 #define PICO_IP_MRU (1500u)
00015 
00016 /* ===== RECEIVING FUNCTIONS (from dev up to socket) ===== */
00017 
00018 /* TRANSPORT LEVEL */
00019 /* interface towards network */
00020 int32_t pico_transport_receive(struct pico_frame *f, uint8_t proto);
00021 
00022 /* NETWORK LEVEL */
00023 /* interface towards ethernet */
00024 int32_t pico_network_receive(struct pico_frame *f);
00025 
00026 
00027 /* LOWEST LEVEL: interface towards devices. */
00028 /* Device driver will call this function which returns immediately.
00029  * Incoming packet will be processed later on in the dev loop.
00030  * The zerocopy version will associate the current buffer to the newly created frame.
00031  * Warning: the buffer used in the zerocopy version MUST have been allocated using PICO_ZALLOC()
00032  */
00033 int32_t pico_stack_recv(struct pico_device *dev, uint8_t *buffer, uint32_t len);
00034 int32_t pico_stack_recv_zerocopy(struct pico_device *dev, uint8_t *buffer, uint32_t len);
00035 int32_t pico_stack_recv_zerocopy_ext_buffer(struct pico_device *dev, uint8_t *buffer, uint32_t len);
00036 int32_t pico_stack_recv_zerocopy_ext_buffer_notify(struct pico_device *dev, uint8_t *buffer, uint32_t len, void (*notify_free)(uint8_t *buffer));
00037 
00038 /* ===== SENDING FUNCTIONS (from socket down to dev) ===== */
00039 
00040 int32_t pico_network_send(struct pico_frame *f);
00041 int32_t pico_sendto_dev(struct pico_frame *f);
00042 
00043 #ifdef PICO_SUPPORT_ETH
00044 int32_t pico_ethernet_send(struct pico_frame *f);
00045 
00046 /* The pico_ethernet_receive() function is used by
00047  * those devices supporting ETH in order to push packets up
00048  * into the stack.
00049  */
00050 /* DATALINK LEVEL */
00051 int32_t pico_ethernet_receive(struct pico_frame *f);
00052 #else
00053 /* When ETH is not supported by the stack... */
00054 #   define pico_ethernet_send(f)    (-1)
00055 #   define pico_ethernet_receive(f) (-1)
00056 #endif
00057 
00058 /* ----- Initialization ----- */
00059 int pico_stack_init(void);
00060 
00061 /* ----- Loop Function. ----- */
00062 void pico_stack_tick(void);
00063 void pico_stack_loop(void);
00064 
00065 /* ---- Notifications for stack errors */
00066 int pico_notify_socket_unreachable(struct pico_frame *f);
00067 int pico_notify_proto_unreachable(struct pico_frame *f);
00068 int pico_notify_dest_unreachable(struct pico_frame *f);
00069 int pico_notify_ttl_expired(struct pico_frame *f);
00070 int pico_notify_frag_expired(struct pico_frame *f);
00071 int pico_notify_pkt_too_big(struct pico_frame *f);
00072 
00073 /* Various. */
00074 struct pico_timer;
00075 int pico_source_is_local(struct pico_frame *f);
00076 int pico_frame_dst_is_unicast(struct pico_frame *f);
00077 void pico_store_network_origin(void *src, struct pico_frame *f);
00078 struct pico_timer *pico_timer_add(pico_time expire, void (*timer)(pico_time, void *), void *arg);
00079 void pico_timer_cancel(struct pico_timer *t);
00080 pico_time pico_timer_get_expire(struct pico_timer *t);
00081 uint32_t pico_rand(void);
00082 void pico_rand_feed(uint32_t feed);
00083 void pico_to_lowercase(char *str);
00084 int pico_address_compare(union pico_address *a, union pico_address *b, uint16_t proto);
00085 int32_t pico_seq_compare(uint32_t a, uint32_t b);
00086 
00087 #endif