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; |
173 |
} |
} |
174 |
++queuelen; |
++queuelen; |
175 |
seg->dataptr = seg->p->payload; |
seg->dataptr = seg->p->payload; |
176 |
} |
} |
177 |
else if(copy) { |
else if (copy) { |
178 |
if((seg->p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_RAM)) == NULL) { |
if((seg->p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_RAM)) == NULL) { |
179 |
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_enqueue: could not allocate memory for pbuf copy size %u\n", seglen)); |
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_enqueue: could not allocate memory for pbuf copy size %u\n", seglen)); |
180 |
goto memerr; |
goto memerr; |
185 |
} |
} |
186 |
seg->dataptr = seg->p->payload; |
seg->dataptr = seg->p->payload; |
187 |
} |
} |
188 |
|
/* do not copy data */ |
189 |
else { |
else { |
|
/* Do not copy the data. */ |
|
190 |
|
|
191 |
/* First, allocate a pbuf for holding the data. */ |
/* first, allocate a pbuf for holding the data. |
192 |
if((p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_REF)) == NULL) { |
* since the referenced data is available at least until it is sent out on the |
193 |
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_enqueue: could not allocate memory for pbuf non-copy\n")); |
* link (as it has to be ACKed by the remote party) we can safely use PBUF_ROM |
194 |
|
* instead of PBUF_REF here. |
195 |
|
*/ |
196 |
|
if((p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_ROM)) == NULL) { |
197 |
|
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_enqueue: could not allocate memory for zero-copy pbuf\n")); |
198 |
goto memerr; |
goto memerr; |
199 |
} |
} |
200 |
++queuelen; |
++queuelen; |