CDC/ECM driver for mbed, based on USBDevice by mbed-official. Uses PicoTCP to access Ethernet USB device. License: GPLv2
Fork of USB_Ethernet by
pico_tcp.h
00001 /********************************************************************* 00002 PicoTCP. Copyright (c) 2012 TASS Belgium NV. 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 struct __attribute__((packed)) 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 struct __attribute__((packed)) 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 (sizeof(struct pico_tcp_hdr)) 00039 00040 #define PICO_TCP_DEFAULT_MSS 1444 00041 00042 00043 00044 /* TCP options */ 00045 #define PICO_TCP_OPTION_END 0x00 00046 #define PICO_TCPOPTLEN_END 1 00047 #define PICO_TCP_OPTION_NOOP 0x01 00048 #define PICO_TCPOPTLEN_NOOP 1 00049 #define PICO_TCP_OPTION_MSS 0x02 00050 #define PICO_TCPOPTLEN_MSS 4 00051 #define PICO_TCP_OPTION_WS 0x03 00052 #define PICO_TCPOPTLEN_WS 3 00053 #define PICO_TCP_OPTION_SACK_OK 0x04 00054 #define PICO_TCPOPTLEN_SACK_OK 2 00055 #define PICO_TCP_OPTION_SACK 0x05 00056 #define PICO_TCPOPTLEN_SACK 2 /* Plus the block */ 00057 #define PICO_TCP_OPTION_TIMESTAMP 0x08 00058 #define PICO_TCPOPTLEN_TIMESTAMP 10 00059 00060 /* TCP flags */ 00061 #define PICO_TCP_FIN 0x01 00062 #define PICO_TCP_SYN 0x02 00063 #define PICO_TCP_RST 0x04 00064 #define PICO_TCP_PSH 0x08 00065 #define PICO_TCP_ACK 0x10 00066 #define PICO_TCP_URG 0x20 00067 #define PICO_TCP_ECN 0x40 00068 #define PICO_TCP_CWR 0x80 00069 00070 00071 00072 struct __attribute__((packed)) pico_tcp_option 00073 { 00074 uint8_t kind; 00075 uint8_t len; 00076 #if 0 00077 union { 00078 uint16_t mss; 00079 uint8_t wshift; 00080 struct { 00081 uint32_t tsval; 00082 uint32_t tsecr; 00083 } timestamp; 00084 } data; 00085 #endif 00086 }; 00087 00088 struct pico_socket *pico_tcp_open(void); 00089 int pico_tcp_read(struct pico_socket *s, void *buf, int len); 00090 int pico_tcp_initconn(struct pico_socket *s); 00091 int pico_tcp_input(struct pico_socket *s, struct pico_frame *f); 00092 uint16_t pico_tcp_checksum_ipv4(struct pico_frame *f); 00093 int pico_tcp_overhead(struct pico_socket *s); 00094 int pico_tcp_output(struct pico_socket *s, int loop_score); 00095 int pico_tcp_queue_in_is_empty(struct pico_socket *s); 00096 int pico_tcp_reply_rst(struct pico_frame *f); 00097 00098 #endif
Generated on Wed Jul 13 2022 02:20:46 by 1.7.2