Lines Matching refs:seg
63 #define TCP_DATA_COPY(dst, src, len, seg) do { \
65 len, &seg->chksum, &seg->chksum_swapped); \
66 seg->flags |= TF_SEG_DATA_CHECKSUMMED; } while(0)
70 #define TCP_DATA_COPY(dst, src, len, seg) MEMCPY(dst, src, len)
81 static void tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb);
161 struct tcp_seg *seg;
164 if ((seg = (struct tcp_seg *)memp_malloc(MEMP_TCP_SEG)) == NULL) {
169 seg->flags = optflags;
170 seg->next = NULL;
171 seg->p = p;
172 seg->len = p->tot_len - optlen;
174 seg->oversize_left = 0;
177 seg->chksum = 0;
178 seg->chksum_swapped = 0;
188 tcp_seg_free(seg);
191 seg->tcphdr = (struct tcp_hdr *)seg->p->payload;
192 seg->tcphdr->src = htons(pcb->local_port);
193 seg->tcphdr->dest = htons(pcb->remote_port);
194 seg->tcphdr->seqno = htonl(seqno);
196 TCPH_HDRLEN_FLAGS_SET(seg->tcphdr, (5 + optlen / 4), flags);
198 seg->tcphdr->urgp = 0;
199 return seg;
357 struct tcp_seg *last_unsent = NULL, *seg = NULL, *prev_seg = NULL, *queue = NULL;
416 * seg points to the last segment tampered with.
450 seg = last_unsent;
469 seg = last_unsent;
586 if ((seg = tcp_create_segment(pcb, p, 0, pcb->snd_lbb + pos, optflags)) == NULL) {
590 seg->oversize_left = oversize;
593 seg->chksum = chksum;
594 seg->chksum_swapped = chksum_swapped;
595 seg->flags |= TF_SEG_DATA_CHECKSUMMED;
600 queue = seg;
604 prev_seg->next = seg;
607 prev_seg = seg;
610 ntohl(seg->tcphdr->seqno),
611 ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg)));
688 if (seg != NULL && seg->tcphdr != NULL && ((apiflags & TCP_WRITE_FLAG_MORE)==0)) {
689 TCPH_SET_FLAG(seg->tcphdr, TCP_PSH);
725 struct tcp_seg *seg;
773 if ((seg = tcp_create_segment(pcb, p, flags, pcb->snd_lbb, optflags)) == NULL) {
778 LWIP_ASSERT("seg->tcphdr not aligned", ((mem_ptr_t)seg->tcphdr % MEM_ALIGNMENT) == 0);
779 LWIP_ASSERT("tcp_enqueue_flags: invalid segment length", seg->len == 0);
783 ntohl(seg->tcphdr->seqno),
784 ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg),
787 /* Now append seg to pcb->unsent queue */
789 pcb->unsent = seg;
793 useg->next = seg;
811 pcb->snd_queuelen += pbuf_clen(seg->p);
900 struct tcp_seg *seg, *useg;
920 seg = pcb->unsent;
929 (seg == NULL ||
930 ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len > wnd)) {
941 if (seg == NULL) {
947 if (seg == NULL) {
950 ", seg == NULL, ack %"U32_F"\n",
957 ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len,
958 ntohl(seg->tcphdr->seqno), pcb->lastack));
962 while (seg != NULL &&
963 ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd) {
965 (TCPH_FLAGS(seg->tcphdr) & TCP_RST) == 0);
970 * either seg->next != NULL or pcb->unacked == NULL;
980 ntohl(seg->tcphdr->seqno) + seg->len -
982 ntohl(seg->tcphdr->seqno), pcb->lastack, i));
986 pcb->unsent = seg->next;
989 TCPH_SET_FLAG(seg->tcphdr, TCP_ACK);
993 tcp_output_segment(seg, pcb);
994 snd_nxt = ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg);
999 if (TCP_TCPLEN(seg) > 0) {
1000 seg->next = NULL;
1003 pcb->unacked = seg;
1004 useg = seg;
1010 if (TCP_SEQ_LT(ntohl(seg->tcphdr->seqno), ntohl(useg->tcphdr->seqno))) {
1014 TCP_SEQ_LT(ntohl((*cur_seg)->tcphdr->seqno), ntohl(seg->tcphdr->seqno))) {
1017 seg->next = (*cur_seg);
1018 (*cur_seg) = seg;
1021 useg->next = seg;
1027 tcp_seg_free(seg);
1029 seg = pcb->unsent;
1045 * @param seg the tcp_seg to send
1049 tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
1060 seg->tcphdr->ackno = htonl(pcb->rcv_nxt);
1063 seg->tcphdr->wnd = htons(pcb->rcv_ann_wnd);
1069 opts = (u32_t *)(void *)(seg->tcphdr + 1);
1070 if (seg->flags & TF_SEG_OPTS_MSS) {
1083 if (seg->flags & TF_SEG_OPTS_TS) {
1107 pcb->rtseq = ntohl(seg->tcphdr->seqno);
1112 htonl(seg->tcphdr->seqno), htonl(seg->tcphdr->seqno) +
1113 seg->len));
1115 len = (u16_t)((u8_t *)seg->tcphdr - (u8_t *)seg->p->payload);
1117 seg->p->len -= len;
1118 seg->p->tot_len -= len;
1120 seg->p->payload = seg->tcphdr;
1122 seg->tcphdr->chksum = 0;
1128 u16_t chksum_slow = inet_chksum_pseudo(seg->p, &(pcb->local_ip),
1130 IP_PROTO_TCP, seg->p->tot_len);
1132 if ((seg->flags & TF_SEG_DATA_CHECKSUMMED) == 0) {
1134 seg->p->tot_len == (TCPH_HDRLEN(seg->tcphdr) * 4));
1138 acc = inet_chksum_pseudo_partial(seg->p, &(pcb->local_ip),
1140 IP_PROTO_TCP, seg->p->tot_len, TCPH_HDRLEN(seg->tcphdr) * 4);
1142 if (seg->chksum_swapped) {
1143 seg->chksum = SWAP_BYTES_IN_WORD(seg->chksum);
1144 seg->chksum_swapped = 0;
1146 acc += (u16_t)~(seg->chksum);
1147 seg->tcphdr->chksum = FOLD_U32T(acc);
1149 if (chksum_slow != seg->tcphdr->chksum) {
1152 seg->tcphdr->chksum, chksum_slow));
1153 seg->tcphdr->chksum = chksum_slow;
1158 seg->tcphdr->chksum = inet_chksum_pseudo(seg->p, &(pcb->local_ip),
1160 IP_PROTO_TCP, seg->p->tot_len);
1166 ip_output_hinted(seg->p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos,
1169 ip_output(seg->p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos,
1241 struct tcp_seg *seg;
1248 for (seg = pcb->unacked; seg->next != NULL; seg = seg->next);
1250 seg->next = pcb->unsent;
1277 struct tcp_seg *seg;
1286 seg = pcb->unacked;
1287 pcb->unacked = seg->next;
1291 TCP_SEQ_LT(ntohl((*cur_seg)->tcphdr->seqno), ntohl(seg->tcphdr->seqno))) {
1294 seg->next = *cur_seg;
1295 *cur_seg = seg;
1297 if (seg->next == NULL) {
1418 struct tcp_seg *seg;
1433 seg = pcb->unacked;
1435 if(seg == NULL) {
1436 seg = pcb->unsent;
1438 if(seg == NULL) {
1442 is_fin = ((TCPH_FLAGS(seg->tcphdr) & TCP_FIN) != 0) && (seg->len == 0);
1446 p = tcp_output_alloc_header(pcb, 0, len, seg->tcphdr->seqno);
1460 (unsent), seg->p->payload points to the IP header or TCP header.
1462 pbuf_copy_partial(seg->p, d, 1, seg->p->tot_len - seg->len);