Marco Zecchini
/
Example_RTOS
Rtos API example
Embed:
(wiki syntax)
Show/hide line numbers
tcp.h
Go to the documentation of this file.
00001 /** 00002 * @file 00003 * TCP protocol definitions 00004 */ 00005 00006 /* 00007 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without modification, 00011 * are permitted provided that the following conditions are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. The name of the author may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00024 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00026 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00029 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00030 * OF SUCH DAMAGE. 00031 * 00032 * This file is part of the lwIP TCP/IP stack. 00033 * 00034 * Author: Adam Dunkels <adam@sics.se> 00035 * 00036 */ 00037 #ifndef LWIP_HDR_PROT_TCP_H 00038 #define LWIP_HDR_PROT_TCP_H 00039 00040 #include "lwip/arch.h" 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00046 /* Length of the TCP header, excluding options. */ 00047 #define TCP_HLEN 20 00048 00049 /* Fields are (of course) in network byte order. 00050 * Some fields are converted to host byte order in tcp_input(). 00051 */ 00052 #ifdef PACK_STRUCT_USE_INCLUDES 00053 # include "arch/bpstruct.h" 00054 #endif 00055 PACK_STRUCT_BEGIN 00056 struct tcp_hdr { 00057 PACK_STRUCT_FIELD(u16_t src); 00058 PACK_STRUCT_FIELD(u16_t dest); 00059 PACK_STRUCT_FIELD(u32_t seqno); 00060 PACK_STRUCT_FIELD(u32_t ackno); 00061 PACK_STRUCT_FIELD(u16_t _hdrlen_rsvd_flags); 00062 PACK_STRUCT_FIELD(u16_t wnd); 00063 PACK_STRUCT_FIELD(u16_t chksum); 00064 PACK_STRUCT_FIELD(u16_t urgp); 00065 } PACK_STRUCT_STRUCT; 00066 PACK_STRUCT_END 00067 #ifdef PACK_STRUCT_USE_INCLUDES 00068 # include "arch/epstruct.h" 00069 #endif 00070 00071 /* TCP header flags bits */ 00072 #define TCP_FIN 0x01U 00073 #define TCP_SYN 0x02U 00074 #define TCP_RST 0x04U 00075 #define TCP_PSH 0x08U 00076 #define TCP_ACK 0x10U 00077 #define TCP_URG 0x20U 00078 #define TCP_ECE 0x40U 00079 #define TCP_CWR 0x80U 00080 /* Valid TCP header flags */ 00081 #define TCP_FLAGS 0x3fU 00082 00083 #define TCPH_HDRLEN(phdr) ((u16_t)(lwip_ntohs((phdr)->_hdrlen_rsvd_flags) >> 12)) 00084 #define TCPH_FLAGS(phdr) ((u16_t)(lwip_ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS)) 00085 00086 #define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = lwip_htons(((len) << 12) | TCPH_FLAGS(phdr)) 00087 #define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS(~TCP_FLAGS)) | lwip_htons(flags)) 00088 #define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = (u16_t)(lwip_htons((u16_t)((len) << 12) | (flags))) 00089 00090 #define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | lwip_htons(flags)) 00091 #define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags & ~lwip_htons(flags)) 00092 00093 #ifdef __cplusplus 00094 } 00095 #endif 00096 00097 #endif /* LWIP_HDR_PROT_TCP_H */
Generated on Sun Jul 17 2022 08:25:31 by 1.7.2