⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcp_impl.h

📁 lwip-1.4.0
💻 H
📖 第 1 页 / 共 2 页
字号:
  do {                                                           \    if(((pcb)->recv != NULL)) {                                  \      (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),NULL,ERR_OK);\    } else {                                                     \      (ret) = ERR_OK;                                            \    }                                                            \  } while (0)#define TCP_EVENT_CONNECTED(pcb,err,ret)                         \  do {                                                           \    if((pcb)->connected != NULL)                                 \      (ret) = (pcb)->connected((pcb)->callback_arg,(pcb),(err)); \    else (ret) = ERR_OK;                                         \  } while (0)#define TCP_EVENT_POLL(pcb,ret)                                \  do {                                                         \    if((pcb)->poll != NULL)                                    \      (ret) = (pcb)->poll((pcb)->callback_arg,(pcb));          \    else (ret) = ERR_OK;                                       \  } while (0)#define TCP_EVENT_ERR(errf,arg,err)                            \  do {                                                         \    if((errf) != NULL)                                         \      (errf)((arg),(err));                                     \  } while (0)#endif /* LWIP_EVENT_API *//** Enabled extra-check for TCP_OVERSIZE if LWIP_DEBUG is enabled */#if TCP_OVERSIZE && defined(LWIP_DEBUG)#define TCP_OVERSIZE_DBGCHECK 1#else#define TCP_OVERSIZE_DBGCHECK 0#endif/** Don't generate checksum on copy if CHECKSUM_GEN_TCP is disabled */#define TCP_CHECKSUM_ON_COPY  (LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_TCP)/* This structure represents a TCP segment on the unsent, unacked and ooseq queues */struct tcp_seg {  struct tcp_seg *next;    /* used when putting segements on a queue */  struct pbuf *p;          /* buffer containing data + TCP header */  u16_t len;               /* the TCP length of this segment */#if TCP_OVERSIZE_DBGCHECK  u16_t oversize_left;     /* Extra bytes available at the end of the last                              pbuf in unsent (used for asserting vs.                              tcp_pcb.unsent_oversized only) */#endif /* TCP_OVERSIZE_DBGCHECK */ #if TCP_CHECKSUM_ON_COPY  u16_t chksum;  u8_t  chksum_swapped;#endif /* TCP_CHECKSUM_ON_COPY */  u8_t  flags;#define TF_SEG_OPTS_MSS         (u8_t)0x01U /* Include MSS option. */#define TF_SEG_OPTS_TS          (u8_t)0x02U /* Include timestamp option. */#define TF_SEG_DATA_CHECKSUMMED (u8_t)0x04U /* ALL data (not the header) is                                               checksummed into 'chksum' */  struct tcp_hdr *tcphdr;  /* the TCP header */};#define LWIP_TCP_OPT_LENGTH(flags)              \  (flags & TF_SEG_OPTS_MSS ? 4  : 0) +          \  (flags & TF_SEG_OPTS_TS  ? 12 : 0)/** This returns a TCP header option for MSS in an u32_t */#define TCP_BUILD_MSS_OPTION(x) (x) = PP_HTONL(((u32_t)2 << 24) |          \                                               ((u32_t)4 << 16) |          \                                               (((u32_t)TCP_MSS / 256) << 8) | \                                               (TCP_MSS & 255))/* Global variables: */extern struct tcp_pcb *tcp_input_pcb;extern u32_t tcp_ticks;/* The TCP PCB lists. */union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */  struct tcp_pcb_listen *listen_pcbs;   struct tcp_pcb *pcbs;};extern struct tcp_pcb *tcp_bound_pcbs;extern union tcp_listen_pcbs_t tcp_listen_pcbs;extern struct tcp_pcb *tcp_active_pcbs;  /* List of all TCP PCBs that are in a              state in which they accept or send              data. */extern struct tcp_pcb *tcp_tw_pcbs;      /* List of all TCP PCBs in TIME-WAIT. */extern struct tcp_pcb *tcp_tmp_pcb;      /* Only used for temporary storage. *//* Axioms about the above lists:      1) Every TCP PCB that is not CLOSED is in one of the lists.   2) A PCB is only in one of the lists.   3) All PCBs in the tcp_listen_pcbs list is in LISTEN state.   4) All PCBs in the tcp_tw_pcbs list is in TIME-WAIT state.*//* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB   with a PCB list or removes a PCB from a list, respectively. */#ifndef TCP_DEBUG_PCB_LISTS#define TCP_DEBUG_PCB_LISTS 0#endif#if TCP_DEBUG_PCB_LISTS#define TCP_REG(pcbs, npcb) do {\                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", (npcb), (npcb)->local_port)); \                            for(tcp_tmp_pcb = *(pcbs); \          tcp_tmp_pcb != NULL; \        tcp_tmp_pcb = tcp_tmp_pcb->next) { \                                LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != (npcb)); \                            } \                            LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", ((pcbs) == &tcp_bound_pcbs) || ((npcb)->state != CLOSED)); \                            (npcb)->next = *(pcbs); \                            LWIP_ASSERT("TCP_REG: npcb->next != npcb", (npcb)->next != (npcb)); \                            *(pcbs) = (npcb); \                            LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \              tcp_timer_needed(); \                            } while(0)#define TCP_RMV(pcbs, npcb) do { \                            LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (npcb), *(pcbs))); \                            if(*(pcbs) == (npcb)) { \                               *(pcbs) = (*pcbs)->next; \                            } else for(tcp_tmp_pcb = *(pcbs); tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \                               if(tcp_tmp_pcb->next == (npcb)) { \                                  tcp_tmp_pcb->next = (npcb)->next; \                                  break; \                               } \                            } \                            (npcb)->next = NULL; \                            LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", (npcb), *(pcbs))); \                            } while(0)#else /* LWIP_DEBUG */#define TCP_REG(pcbs, npcb)                        \  do {                                             \    (npcb)->next = *pcbs;                          \    *(pcbs) = (npcb);                              \    tcp_timer_needed();                            \  } while (0)#define TCP_RMV(pcbs, npcb)                        \  do {                                             \    if(*(pcbs) == (npcb)) {                        \      (*(pcbs)) = (*pcbs)->next;                   \    }                                              \    else {                                         \      for(tcp_tmp_pcb = *pcbs;                     \          tcp_tmp_pcb != NULL;                     \          tcp_tmp_pcb = tcp_tmp_pcb->next) {       \        if(tcp_tmp_pcb->next == (npcb)) {          \          tcp_tmp_pcb->next = (npcb)->next;        \          break;                                   \        }                                          \      }                                            \    }                                              \    (npcb)->next = NULL;                           \  } while(0)#endif /* LWIP_DEBUG *//* Internal functions: */struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb);void tcp_pcb_purge(struct tcp_pcb *pcb);void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb);void tcp_segs_free(struct tcp_seg *seg);void tcp_seg_free(struct tcp_seg *seg);struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg);#define tcp_ack(pcb)                               \  do {                                             \    if((pcb)->flags & TF_ACK_DELAY) {              \      (pcb)->flags &= ~TF_ACK_DELAY;               \      (pcb)->flags |= TF_ACK_NOW;                  \    }                                              \    else {                                         \      (pcb)->flags |= TF_ACK_DELAY;                \    }                                              \  } while (0)#define tcp_ack_now(pcb)                           \  do {                                             \    (pcb)->flags |= TF_ACK_NOW;                    \  } while (0)err_t tcp_send_fin(struct tcp_pcb *pcb);err_t tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags);void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg);void tcp_rst(u32_t seqno, u32_t ackno,       ip_addr_t *local_ip, ip_addr_t *remote_ip,       u16_t local_port, u16_t remote_port);u32_t tcp_next_iss(void);void tcp_keepalive(struct tcp_pcb *pcb);void tcp_zero_window_probe(struct tcp_pcb *pcb);#if TCP_CALCULATE_EFF_SEND_MSSu16_t tcp_eff_send_mss(u16_t sendmss, ip_addr_t *addr);#endif /* TCP_CALCULATE_EFF_SEND_MSS */#if LWIP_CALLBACK_APIerr_t tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err);#endif /* LWIP_CALLBACK_API */#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUGvoid tcp_debug_print(struct tcp_hdr *tcphdr);void tcp_debug_print_flags(u8_t flags);void tcp_debug_print_state(enum tcp_state s);void tcp_debug_print_pcbs(void);s16_t tcp_pcbs_sane(void);#else#  define tcp_debug_print(tcphdr)#  define tcp_debug_print_flags(flags)#  define tcp_debug_print_state(s)#  define tcp_debug_print_pcbs()#  define tcp_pcbs_sane() 1#endif /* TCP_DEBUG *//** External function (implemented in timers.c), called when TCP detects * that a timer is needed (i.e. active- or time-wait-pcb found). */void tcp_timer_needed(void);#ifdef __cplusplus}#endif#endif /* LWIP_TCP */#endif /* __LWIP_TCP_H__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -