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
pico_tcp.h
00001 /********************************************************************* 00002 PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved. 00003 See LICENSE and COPYING for usage. 00004 00005 . 00006 00007 *********************************************************************/ 00008 #ifndef INCLUDE_PICO_TCP 00009 #define INCLUDE_PICO_TCP 00010 #include "pico_addressing.h" 00011 #include "pico_protocol.h" 00012 #include "pico_socket.h" 00013 00014 extern struct pico_protocol pico_proto_tcp; 00015 00016 PACKED_STRUCT_DEF pico_tcp_hdr { 00017 struct pico_trans trans; 00018 uint32_t seq; 00019 uint32_t ack; 00020 uint8_t len; 00021 uint8_t flags; 00022 uint16_t rwnd; 00023 uint16_t crc; 00024 uint16_t urgent; 00025 }; 00026 00027 PACKED_STRUCT_DEF tcp_pseudo_hdr_ipv4 00028 { 00029 struct pico_ip4 src; 00030 struct pico_ip4 dst; 00031 uint16_t tcp_len; 00032 uint8_t res; 00033 uint8_t proto; 00034 }; 00035 00036 #define PICO_TCPHDR_SIZE 20 00037 #define PICO_SIZE_TCPOPT_SYN 20 00038 #define PICO_SIZE_TCPHDR (uint32_t)(sizeof(struct pico_tcp_hdr)) 00039 00040 /* TCP options */ 00041 #define PICO_TCP_OPTION_END 0x00 00042 #define PICO_TCPOPTLEN_END 1u 00043 #define PICO_TCP_OPTION_NOOP 0x01 00044 #define PICO_TCPOPTLEN_NOOP 1 00045 #define PICO_TCP_OPTION_MSS 0x02 00046 #define PICO_TCPOPTLEN_MSS 4 00047 #define PICO_TCP_OPTION_WS 0x03 00048 #define PICO_TCPOPTLEN_WS 3u 00049 #define PICO_TCP_OPTION_SACK_OK 0x04 00050 #define PICO_TCPOPTLEN_SACK_OK 2 00051 #define PICO_TCP_OPTION_SACK 0x05 00052 #define PICO_TCPOPTLEN_SACK 2 /* Plus the block */ 00053 #define PICO_TCP_OPTION_TIMESTAMP 0x08 00054 #define PICO_TCPOPTLEN_TIMESTAMP 10u 00055 00056 /* TCP flags */ 00057 #define PICO_TCP_FIN 0x01u 00058 #define PICO_TCP_SYN 0x02u 00059 #define PICO_TCP_RST 0x04u 00060 #define PICO_TCP_PSH 0x08u 00061 #define PICO_TCP_ACK 0x10u 00062 #define PICO_TCP_URG 0x20u 00063 #define PICO_TCP_ECN 0x40u 00064 #define PICO_TCP_CWR 0x80u 00065 00066 #define PICO_TCP_SYNACK (PICO_TCP_SYN | PICO_TCP_ACK) 00067 #define PICO_TCP_PSHACK (PICO_TCP_PSH | PICO_TCP_ACK) 00068 #define PICO_TCP_FINACK (PICO_TCP_FIN | PICO_TCP_ACK) 00069 #define PICO_TCP_FINPSHACK (PICO_TCP_FIN | PICO_TCP_PSH | PICO_TCP_ACK) 00070 #define PICO_TCP_RSTACK (PICO_TCP_RST | PICO_TCP_ACK) 00071 00072 00073 PACKED_STRUCT_DEF pico_tcp_option 00074 { 00075 uint8_t kind; 00076 uint8_t len; 00077 }; 00078 00079 struct pico_socket *pico_tcp_open(uint16_t family); 00080 uint32_t pico_tcp_read(struct pico_socket *s, void *buf, uint32_t len); 00081 int pico_tcp_initconn(struct pico_socket *s); 00082 int pico_tcp_input(struct pico_socket *s, struct pico_frame *f); 00083 uint16_t pico_tcp_checksum(struct pico_frame *f); 00084 uint16_t pico_tcp_checksum_ipv4(struct pico_frame *f); 00085 #ifdef PICO_SUPPORT_IPV6 00086 uint16_t pico_tcp_checksum_ipv6(struct pico_frame *f); 00087 #endif 00088 uint16_t pico_tcp_overhead(struct pico_socket *s); 00089 int pico_tcp_output(struct pico_socket *s, int loop_score); 00090 int pico_tcp_queue_in_is_empty(struct pico_socket *s); 00091 int pico_tcp_reply_rst(struct pico_frame *f); 00092 void pico_tcp_cleanup_queues(struct pico_socket *sck); 00093 void pico_tcp_notify_closing(struct pico_socket *sck); 00094 void pico_tcp_flags_update(struct pico_frame *f, struct pico_socket *s); 00095 int pico_tcp_set_bufsize_in(struct pico_socket *s, uint32_t value); 00096 int pico_tcp_set_bufsize_out(struct pico_socket *s, uint32_t value); 00097 int pico_tcp_get_bufsize_in(struct pico_socket *s, uint32_t *value); 00098 int pico_tcp_get_bufsize_out(struct pico_socket *s, uint32_t *value); 00099 int pico_tcp_set_keepalive_probes(struct pico_socket *s, uint32_t value); 00100 int pico_tcp_set_keepalive_intvl(struct pico_socket *s, uint32_t value); 00101 int pico_tcp_set_keepalive_time(struct pico_socket *s, uint32_t value); 00102 int pico_tcp_set_linger(struct pico_socket *s, uint32_t value); 00103 uint16_t pico_tcp_get_socket_mss(struct pico_socket *s); 00104 int pico_tcp_check_listen_close(struct pico_socket *s); 00105 00106 #endif
Generated on Tue Jul 12 2022 15:59:22 by 1.7.2