/[lwip]/lwip/src/core/tcp_out.c
ViewVC logotype

Diff of /lwip/src/core/tcp_out.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22 by jani, Mon May 19 14:41:54 2003 UTC revision 1.23 by likewise, Tue May 20 08:16:29 2003 UTC
# Line 115  tcp_enqueue(struct tcp_pcb *pcb, void *a Line 115  tcp_enqueue(struct tcp_pcb *pcb, void *a
115    }    }
116    
117    /* seqno will be the sequence number of the first segment enqueued    /* seqno will be the sequence number of the first segment enqueued
118    by the call to this function. */     * by the call to this function. */
119    seqno = pcb->snd_lbb;    seqno = pcb->snd_lbb;
120    
121      queue = NULL;    queue = NULL;
122    DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue: queuelen: %d\n", pcb->snd_queuelen));    DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue: queuelen: %d\n", pcb->snd_queuelen));
123    
124    /* Check if the queue length exceeds the configured maximum queue    /* Check if the queue length exceeds the configured maximum queue
125    length. If so, we return an error. */     * length. If so, we return an error. */
126    queuelen = pcb->snd_queuelen;    queuelen = pcb->snd_queuelen;
127    if (queuelen >= TCP_SND_QUEUELEN) {    if (queuelen >= TCP_SND_QUEUELEN) {
128      DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too long queue %d (max %d)\n", queuelen, TCP_SND_QUEUELEN));      DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too long queue %d (max %d)\n", queuelen, TCP_SND_QUEUELEN));
# Line 138  tcp_enqueue(struct tcp_pcb *pcb, void *a Line 138  tcp_enqueue(struct tcp_pcb *pcb, void *a
138    seglen = 0;    seglen = 0;
139    
140    /* First, break up the data into segments and tuck them together in    /* First, break up the data into segments and tuck them together in
141    the local "queue" variable. */     * the local "queue" variable. */
142    while (queue == NULL || left > 0) {    while (queue == NULL || left > 0) {
143    
144      /* The segment length should be the MSS if the data to be enqueued      /* The segment length should be the MSS if the data to be enqueued
145      is larger than the MSS. */       * is larger than the MSS. */
146      seglen = left > pcb->mss? pcb->mss: left;      seglen = left > pcb->mss? pcb->mss: left;
147    
148      /* Allocate memory for tcp_seg, and fill in fields. */      /* Allocate memory for tcp_seg, and fill in fields. */
# Line 159  tcp_enqueue(struct tcp_pcb *pcb, void *a Line 159  tcp_enqueue(struct tcp_pcb *pcb, void *a
159      }      }
160      else {      else {
161        /* Attach the segment to the end of the queued segments. */        /* Attach the segment to the end of the queued segments. */
162        for(useg = queue; useg->next != NULL; useg = useg->next);        for (useg = queue; useg->next != NULL; useg = useg->next);
163        useg->next = seg;        useg->next = seg;
164      }      }
165    
166      /* If copy is set, memory should be allocated      /* If copy is set, memory should be allocated
167      and data copied into pbuf, otherwise data comes from       * and data copied into pbuf, otherwise data comes from
168      ROM or other static memory, and need not be copied. If       * ROM or other static memory, and need not be copied. If
169      optdata is != NULL, we have options instead of data. */       * optdata is != NULL, we have options instead of data. */
170      if (optdata != NULL) {      if (optdata != NULL) {
171        if ((seg->p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) {        if ((seg->p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) {
172          goto memerr;          goto memerr;
# Line 204  tcp_enqueue(struct tcp_pcb *pcb, void *a Line 204  tcp_enqueue(struct tcp_pcb *pcb, void *a
204        /* Second, allocate a pbuf for the headers. */        /* Second, allocate a pbuf for the headers. */
205        if ((seg->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_RAM)) == NULL) {        if ((seg->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_RAM)) == NULL) {
206          /* If allocation fails, we have to deallocate the data pbuf as          /* If allocation fails, we have to deallocate the data pbuf as
207             well. */           * well. */
208          pbuf_free(p);          pbuf_free(p);
209          DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: could not allocate memory for header pbuf\n"));                        DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: could not allocate memory for header pbuf\n"));              
210          goto memerr;          goto memerr;
# Line 214  tcp_enqueue(struct tcp_pcb *pcb, void *a Line 214  tcp_enqueue(struct tcp_pcb *pcb, void *a
214        /* Chain the headers and data pbufs together. */        /* Chain the headers and data pbufs together. */
215        pbuf_chain(seg->p, p);        pbuf_chain(seg->p, p);
216        pbuf_free(p);        pbuf_free(p);
217          p = NULL;
218      }      }
219    
220      /* Now that there are more segments queued, we check again if the      /* Now that there are more segments queued, we check again if the
# Line 224  tcp_enqueue(struct tcp_pcb *pcb, void *a Line 225  tcp_enqueue(struct tcp_pcb *pcb, void *a
225      }      }
226    
227      seg->len = seglen;      seg->len = seglen;
228      /*    if ((flags & TCP_SYN) || (flags & TCP_FIN)) {  #if 0 /* Was commented out. TODO: can someone say why this is here? */
229      ++seg->len;      if ((flags & TCP_SYN) || (flags & TCP_FIN)) {
230      }*/        ++seg->len;
231        }
232    #endif
233      /* Build TCP header. */      /* Build TCP header. */
234      if (pbuf_header(seg->p, TCP_HLEN)) {      if (pbuf_header(seg->p, TCP_HLEN)) {
235    
# Line 275  tcp_enqueue(struct tcp_pcb *pcb, void *a Line 277  tcp_enqueue(struct tcp_pcb *pcb, void *a
277      useg = NULL;      useg = NULL;
278    }    }
279    else {    else {
280      for(useg = pcb->unsent; useg->next != NULL; useg = useg->next);      for (useg = pcb->unsent; useg->next != NULL; useg = useg->next);
281    }    }
282    
283    /* If there is room in the last pbuf on the unsent queue,    /* If there is room in the last pbuf on the unsent queue,
# Line 459  tcp_output(struct tcp_pcb *pcb) Line 461  tcp_output(struct tcp_pcb *pcb)
461                    
462                    
463        } else {        } else {
464          for(useg = pcb->unacked; useg->next != NULL; useg = useg->next);          for (useg = pcb->unacked; useg->next != NULL; useg = useg->next);
465          useg->next = seg;          useg->next = seg;
466        }        }
467      } else {      } else {
# Line 575  tcp_rexmit(struct tcp_pcb *pcb) Line 577  tcp_rexmit(struct tcp_pcb *pcb)
577    }    }
578        
579    /* Move all unacked segments to the unsent queue. */    /* Move all unacked segments to the unsent queue. */
580    for(seg = pcb->unacked; seg->next != NULL; seg = seg->next);    for (seg = pcb->unacked; seg->next != NULL; seg = seg->next);
581        
582    seg->next = pcb->unsent;    seg->next = pcb->unsent;
583    pcb->unsent = pcb->unacked;    pcb->unsent = pcb->unacked;

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26