#include "lwip/opt.h"#include "lwip/pbuf.h"#include "lwip/sys.h"#include "lwip/ip.h"#include "lwip/udp.h"#include "lwip/tcp.h"#include "lwip/err.h"Include dependency graph for api.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
|
|
Definition at line 54 of file api.h. Referenced by lwip_send(), and tcp_client(). |
|
|
|
|
|
Definition at line 72 of file api.h.
00072 {
00073 NETCONN_EVT_RCVPLUS,
00074 NETCONN_EVT_RCVMINUS,
00075 NETCONN_EVT_SENDPLUS,
00076 NETCONN_EVT_SENDMINUS
00077 };
|
|
|
Definition at line 63 of file api.h.
00063 {
00064 NETCONN_NONE,
00065 NETCONN_WRITE,
00066 NETCONN_ACCEPT,
00067 NETCONN_RECV,
00068 NETCONN_CONNECT,
00069 NETCONN_CLOSE
00070 };
|
|
|
Definition at line 56 of file api.h. Referenced by lwip_recvfrom(), and lwip_send().
00056 {
00057 NETCONN_TCP,
00058 NETCONN_UDP,
00059 NETCONN_UDPLITE,
00060 NETCONN_UDPNOCHKSUM
00061 };
|
|
||||||||||||
|
Definition at line 73 of file api_lib.c. References NULL, netbuf::p, pbuf::payload, pbuf_alloc(), pbuf_free(), PBUF_RAM, PBUF_TRANSPORT, netbuf::ptr, and u16_t.
|
Here is the call graph for this function:
|
||||||||||||
|
Definition at line 109 of file api_lib.c. References memp_freep(), MEMP_NETBUF, netbuf::p, pbuf_chain(), and netbuf::ptr.
00110 {
00111 pbuf_chain(head->p, tail->p);
00112 head->ptr = head->p;
00113 memp_freep(MEMP_NETBUF, tail);
00114 }
|
Here is the call graph for this function:
|
||||||||||||||||
|
Definition at line 182 of file api_lib.c. References len, netbuf_copy_partial(), and u16_t. Referenced by udpecho_thread().
00183 {
00184 netbuf_copy_partial(buf, dataptr, len, 0);
00185 }
|
Here is the call graph for this function:
|
||||||||||||||||||||
|
Definition at line 153 of file api_lib.c. References len, NULL, netbuf::p, and u16_t. Referenced by lwip_recvfrom(), and netbuf_copy().
00154 {
00155 struct pbuf *p;
00156 u16_t i, left;
00157
00158 left = 0;
00159
00160 if(buf == NULL) {
00161 return;
00162 }
00163
00164 /* This implementation is bad. It should use bcopy
00165 instead. */
00166 for(p = buf->p; left < len && p != NULL; p = p->next) {
00167 if(offset != 0 && offset >= p->len) {
00168 offset -= p->len;
00169 } else {
00170 for(i = offset; i < p->len; ++i) {
00171 ((char *)dataptr)[left] = ((char *)p->payload)[i];
00172 if(++left >= len) {
00173 return;
00174 }
00175 }
00176 offset = 0;
00177 }
00178 }
00179 }
|
|
||||||||||||||||
|
Definition at line 123 of file api_lib.c. References ERR_BUF, ERR_OK, pbuf::len, len, NULL, pbuf::payload, netbuf::ptr, and u16_t. Referenced by serve_echo(), and tcpecho_thread().
|
|
|
Definition at line 61 of file api_lib.c. References memp_freep(), MEMP_NETBUF, NULL, netbuf::p, pbuf_free(), and netbuf::ptr. Referenced by lwip_close(), lwip_recvfrom(), lwip_send(), netconn_delete(), serve_echo(), tcpecho_thread(), and udpecho_thread().
|
Here is the call graph for this function:
|
|
Definition at line 147 of file api_lib.c. References netbuf::p, and netbuf::ptr.
|
|
|
Definition at line 88 of file api_lib.c. References NULL, netbuf::p, pbuf_free(), and netbuf::ptr.
|
Here is the call graph for this function:
|
|
Definition at line 188 of file api_lib.c. References netbuf::fromaddr. Referenced by lwip_recvfrom().
00189 {
00190 return buf->fromaddr;
00191 }
|
|
|
Definition at line 194 of file api_lib.c. References netbuf::fromport. Referenced by lwip_recvfrom().
00195 {
00196 return buf->fromport;
00197 }
|
|
|
Definition at line 117 of file api_lib.c. References netbuf::p, and pbuf::tot_len. Referenced by lwip_recvfrom().
|
|
|
Definition at line 46 of file api_lib.c. References memp_mallocp(), MEMP_NETBUF, and NULL. Referenced by lwip_send(), and udpclient().
|
Here is the call graph for this function:
|
|
Definition at line 134 of file api_lib.c. References pbuf::next, NULL, and netbuf::ptr. Referenced by serve_echo(), and tcpecho_thread().
|
|
||||||||||||||||
|
Definition at line 97 of file api_lib.c. References pbuf::len, NULL, netbuf::p, pbuf::payload, pbuf_alloc(), pbuf_free(), PBUF_REF, PBUF_TRANSPORT, netbuf::ptr, pbuf::tot_len, and u16_t. Referenced by lwip_send(), and udpclient().
|
Here is the call graph for this function:
|
|
Definition at line 452 of file api_lib.c. References netconn::acceptmbox, netconn::callback, conn, NETCONN_EVT_RCVMINUS, newconn, NULL, and sys_mbox_fetch(). Referenced by lwip_accept(), and tcpecho_thread().
00453 {
00454 struct netconn *newconn;
00455
00456 if(conn == NULL) {
00457 return NULL;
00458 }
00459
00460 sys_mbox_fetch(conn->acceptmbox, (void **)&newconn);
00461 /* Register event with callback */
00462 if (conn->callback)
00463 (*conn->callback)(conn, NETCONN_EVT_RCVMINUS, 0);
00464
00465 return newconn;
00466 }
|
Here is the call graph for this function:
|
||||||||||||||||
|
Definition at line 324 of file api_lib.c. References conn, netconn::err, ERR_OK, NETCONN_TCP, NETCONN_UDP, NETCONN_UDPLITE, NETCONN_UDPNOCHKSUM, netconn::pcb, netconn::type, and u16_t. Referenced by lwip_getsockname().
00326 {
00327 switch(conn->type) {
00328 case NETCONN_UDPLITE:
00329 case NETCONN_UDPNOCHKSUM:
00330 case NETCONN_UDP:
00331 *addr = &(conn->pcb.udp->local_ip);
00332 *port = conn->pcb.udp->local_port;
00333 break;
00334 case NETCONN_TCP:
00335 *addr = &(conn->pcb.tcp->local_ip);
00336 *port = conn->pcb.tcp->local_port;
00337 break;
00338 }
00339 return (conn->err = ERR_OK);
00340 }
|
|
||||||||||||||||
|
Definition at line 343 of file api_lib.c. References API_MSG_BIND, api_msg_post(), conn, netconn::err, ERR_MEM, ERR_VAL, netconn::mbox, MEMP_API_MSG, memp_freep(), memp_mallocp(), NETCONN_TCP, NULL, netconn::recvmbox, sys_mbox_fetch(), sys_mbox_new(), SYS_MBOX_NULL, netconn::type, and u16_t. Referenced by lwip_bind(), tcp_client(), tcpecho_thread(), and udpecho_thread().
00345 {
00346 struct api_msg *msg;
00347
00348 if(conn == NULL) {
00349 return ERR_VAL;
00350 }
00351
00352 if(conn->type != NETCONN_TCP &&
00353 conn->recvmbox == SYS_MBOX_NULL) {
00354 if((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
00355 return ERR_MEM;
00356 }
00357 }
00358
00359 if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
00360 return (conn->err = ERR_MEM);
00361 }
00362 msg->type = API_MSG_BIND;
00363 msg->msg.conn = conn;
00364 msg->msg.msg.bc.ipaddr = addr;
00365 msg->msg.msg.bc.port = port;
00366 api_msg_post(msg);
00367 sys_mbox_fetch(conn->mbox, NULL);
00368 memp_freep(MEMP_API_MSG, msg);
00369 return conn->err;
00370 }
|
Here is the call graph for this function:
|
|
Definition at line 669 of file api_lib.c. References API_MSG_CLOSE, api_msg_post(), conn, netconn::err, ERR_MEM, ERR_VAL, netconn::mbox, MEMP_API_MSG, memp_freep(), memp_mallocp(), NETCONN_CLOSE, NETCONN_NONE, NULL, netconn::sem, netconn::state, sys_mbox_fetch(), SYS_SEM_NULL, and sys_sem_wait(). Referenced by serve_echo().
00670 {
00671 struct api_msg *msg;
00672
00673 if(conn == NULL) {
00674 return ERR_VAL;
00675 }
00676 if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
00677 return (conn->err = ERR_MEM);
00678 }
00679
00680 conn->state = NETCONN_CLOSE;
00681 again:
00682 msg->type = API_MSG_CLOSE;
00683 msg->msg.conn = conn;
00684 api_msg_post(msg);
00685 sys_mbox_fetch(conn->mbox, NULL);
00686 if(conn->err == ERR_MEM &&
00687 conn->sem != SYS_SEM_NULL) {
00688 sys_sem_wait(conn->sem);
00689 goto again;
00690 }
00691 conn->state = NETCONN_NONE;
00692 memp_freep(MEMP_API_MSG, msg);
00693 return conn->err;
00694 }
|
Here is the call graph for this function:
|
||||||||||||||||
|
Definition at line 374 of file api_lib.c. References API_MSG_CONNECT, api_msg_post(), conn, netconn::err, ERR_MEM, ERR_VAL, netconn::mbox, MEMP_API_MSG, memp_freep(), memp_mallocp(), NULL, netconn::recvmbox, sys_mbox_fetch(), sys_mbox_new(), SYS_MBOX_NULL, and u16_t. Referenced by lwip_connect(), lwip_sendto(), tcp_client(), and udpclient().
00376 {
00377 struct api_msg *msg;
00378
00379 if(conn == NULL) {
00380 return ERR_VAL;
00381 }
00382
00383
00384 if(conn->recvmbox == SYS_MBOX_NULL) {
00385 if((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
00386 return ERR_MEM;
00387 }
00388 }
00389
00390 if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
00391 return ERR_MEM;
00392 }
00393 msg->type = API_MSG_CONNECT;
00394 msg->msg.conn = conn;
00395 msg->msg.msg.bc.ipaddr = addr;
00396 msg->msg.msg.bc.port = port;
00397 api_msg_post(msg);
00398 sys_mbox_fetch(conn->mbox, NULL);
00399 memp_freep(MEMP_API_MSG, msg);
00400 return conn->err;
00401 }
|
Here is the call graph for this function:
|
|
Definition at line 240 of file api_lib.c. References netconn::acceptmbox, API_MSG_DELCONN, api_msg_post(), conn, ERR_MEM, ERR_OK, netconn::mbox, MEMP_API_MSG, memp_free(), memp_freep(), memp_mallocp(), MEMP_NETCONN, netbuf_delete(), NETCONN_TCP, NULL, pbuf_free(), netconn::recvmbox, netconn::sem, sys_arch_mbox_fetch(), sys_mbox_fetch(), sys_mbox_free(), SYS_MBOX_NULL, sys_sem_free(), SYS_SEM_NULL, and netconn::type. Referenced by cleanup_module(), lwip_accept(), lwip_close(), lwip_socket(), serve_echo(), and tcp_client().
00241 {
00242 struct api_msg *msg;
00243 void *mem;
00244
00245 if(conn == NULL) {
00246 return ERR_OK;
00247 }
00248
00249 if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
00250 return ERR_MEM;
00251 }
00252
00253 msg->type = API_MSG_DELCONN;
00254 msg->msg.conn = conn;
00255 api_msg_post(msg);
00256 sys_mbox_fetch(conn->mbox, NULL);
00257 memp_freep(MEMP_API_MSG, msg);
00258
00259 /* Drain the recvmbox. */
00260 if(conn->recvmbox != SYS_MBOX_NULL) {
00261 while(sys_arch_mbox_fetch(conn->recvmbox, &mem, 1) != 0) {
00262 if(conn->type == NETCONN_TCP) {
00263 pbuf_free((struct pbuf *)mem);
00264 } else {
00265 netbuf_delete((struct netbuf *)mem);
00266 }
00267 }
00268 sys_mbox_free(conn->recvmbox);
00269 conn->recvmbox = SYS_MBOX_NULL;
00270 }
00271
00272
00273 /* Drain the acceptmbox. */
00274 if(conn->acceptmbox != SYS_MBOX_NULL) {
00275 while(sys_arch_mbox_fetch(conn->acceptmbox, &mem, 1) != 0) {
00276 netconn_delete((struct netconn *)mem);
00277 }
00278
00279 sys_mbox_free(conn->acceptmbox);
00280 conn->acceptmbox = SYS_MBOX_NULL;
00281 }
00282
00283 sys_mbox_free(conn->mbox);
00284 conn->mbox = SYS_MBOX_NULL;
00285 if(conn->sem != SYS_SEM_NULL) {
00286 sys_sem_free(conn->sem);
00287 }
00288 /* conn->sem = SYS_SEM_NULL;*/
00289 memp_free(MEMP_NETCONN, conn);
00290 return ERR_OK;
00291 }
|
Here is the call graph for this function:
|
|
Definition at line 404 of file api_lib.c. References API_MSG_DISCONNECT, api_msg_post(), conn, netconn::err, ERR_MEM, ERR_VAL, netconn::mbox, MEMP_API_MSG, memp_freep(), memp_mallocp(), NULL, and sys_mbox_fetch(). Referenced by lwip_connect(), and lwip_sendto().
00405 {
00406 struct api_msg *msg;
00407
00408 if(conn == NULL) {
00409 return ERR_VAL;
00410 }
00411
00412 if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
00413 return ERR_MEM;
00414 }
00415 msg->type = API_MSG_DISCONNECT;
00416 msg->msg.conn = conn;
00417 api_msg_post(msg);
00418 sys_mbox_fetch(conn->mbox, NULL);
00419 memp_freep(MEMP_API_MSG, msg);
00420 return conn->err;
00421
00422 }
|
Here is the call graph for this function:
|
|
Definition at line 697 of file api_lib.c. References conn, and netconn::err.
|
|
|
Definition at line 425 of file api_lib.c. References netconn::acceptmbox, API_MSG_LISTEN, api_msg_post(), conn, netconn::err, ERR_MEM, ERR_VAL, netconn::mbox, MEMP_API_MSG, memp_freep(), memp_mallocp(), NULL, sys_mbox_fetch(), sys_mbox_new(), and SYS_MBOX_NULL. Referenced by lwip_listen(), and tcpecho_thread().
00426 {
00427 struct api_msg *msg;
00428
00429 if(conn == NULL) {
00430 return ERR_VAL;
00431 }
00432
00433 if(conn->acceptmbox == SYS_MBOX_NULL) {
00434 conn->acceptmbox = sys_mbox_new();
00435 if(conn->acceptmbox == SYS_MBOX_NULL) {
00436 return ERR_MEM;
00437 }
00438 }
00439
00440 if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
00441 return (conn->err = ERR_MEM);
00442 }
00443 msg->type = API_MSG_LISTEN;
00444 msg->msg.conn = conn;
00445 api_msg_post(msg);
00446 sys_mbox_fetch(conn->mbox, NULL);
00447 memp_freep(MEMP_API_MSG, msg);
00448 return conn->err;
00449 }
|
Here is the call graph for this function:
|
Here is the call graph for this function:
|
||||||||||||
|
Definition at line 226 of file api_lib.c. References netconn::callback, conn, netconn_new(), and u16_t. Referenced by lwip_socket().
|
Here is the call graph for this function:
|
||||||||||||||||
|
Definition at line 300 of file api_lib.c. References conn, netconn::err, ERR_CONN, ERR_OK, NETCONN_TCP, NETCONN_UDP, NETCONN_UDPLITE, NETCONN_UDPNOCHKSUM, NULL, netconn::pcb, netconn::type, u16_t, and UDP_FLAGS_CONNECTED. Referenced by lwip_accept(), lwip_getpeername(), and lwip_sendto().
00302 {
00303 switch(conn->type) {
00304 case NETCONN_UDPLITE:
00305 case NETCONN_UDPNOCHKSUM:
00306 case NETCONN_UDP:
00307 if (conn->pcb.udp == NULL ||
00308 ((conn->pcb.udp->flags & UDP_FLAGS_CONNECTED) == 0))
00309 return ERR_CONN;
00310 *addr = (conn->pcb.udp->remote_ip);
00311 *port = conn->pcb.udp->remote_port;
00312 break;
00313 case NETCONN_TCP:
00314 if(conn->pcb.tcp == NULL)
00315 return ERR_CONN;
00316 *addr = (conn->pcb.tcp->remote_ip);
00317 *port = conn->pcb.tcp->remote_port;
00318 break;
00319 }
00320 return (conn->err = ERR_OK);
00321 }
|
|
|
Definition at line 469 of file api_lib.c. References API_LIB_DEBUG, api_msg_post(), API_MSG_RECV, netconn::callback, conn, DEBUGF, netconn::err, ERR_CONN, ERR_MEM, ERR_OK, len, LISTEN, netconn::mbox, MEMP_API_MSG, memp_freep(), memp_mallocp(), MEMP_NETBUF, NETCONN_EVT_RCVMINUS, NETCONN_TCP, NULL, netconn::pcb, netconn::recv_avail, netconn::recvmbox, sys_mbox_fetch(), sys_mbox_free(), SYS_MBOX_NULL, netconn::type, and u16_t. Referenced by lwip_recvfrom(), serve_echo(), tcpecho_thread(), and udpecho_thread().
00470 {
00471 struct api_msg *msg;
00472 struct netbuf *buf;
00473 struct pbuf *p;
00474 u16_t len;
00475
00476 if(conn == NULL) {
00477 return NULL;
00478 }
00479
00480 if(conn->recvmbox == SYS_MBOX_NULL) {
00481 conn->err = ERR_CONN;
00482 return NULL;
00483 }
00484
00485 if(conn->err != ERR_OK) {
00486 return NULL;
00487 }
00488
00489 if(conn->type == NETCONN_TCP) {
00490 if(conn->pcb.tcp->state == LISTEN) {
00491 conn->err = ERR_CONN;
00492 return NULL;
00493 }
00494
00495
00496 buf = memp_mallocp(MEMP_NETBUF);
00497
00498 if(buf == NULL) {
00499 conn->err = ERR_MEM;
00500 return NULL;
00501 }
00502
00503 sys_mbox_fetch(conn->recvmbox, (void **)&p);
00504
00505 if (p != NULL)
00506 {
00507 len = p->tot_len;
00508 conn->recv_avail -= len;
00509 }
00510 else
00511 len = 0;
00512
00513 /* Register event with callback */
00514 if (conn->callback)
00515 (*conn->callback)(conn, NETCONN_EVT_RCVMINUS, len);
00516
00517 /* If we are closed, we indicate that we no longer wish to recieve
00518 data by setting conn->recvmbox to SYS_MBOX_NULL. */
00519 if(p == NULL) {
00520 memp_freep(MEMP_NETBUF, buf);
00521 sys_mbox_free(conn->recvmbox);
00522 conn->recvmbox = SYS_MBOX_NULL;
00523 return NULL;
00524 }
00525
00526 buf->p = p;
00527 buf->ptr = p;
00528 buf->fromport = 0;
00529 buf->fromaddr = NULL;
00530
00531 /* Let the stack know that we have taken the data. */
00532 if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
00533 conn->err = ERR_MEM;
00534 return buf;
00535 }
00536 msg->type = API_MSG_RECV;
00537 msg->msg.conn = conn;
00538 if(buf != NULL) {
00539 msg->msg.msg.len = buf->p->tot_len;
00540 } else {
00541 msg->msg.msg.len = 1;
00542 }
00543 api_msg_post(msg);
00544
00545 sys_mbox_fetch(conn->mbox, NULL);
00546 memp_freep(MEMP_API_MSG, msg);
00547 } else {
00548 sys_mbox_fetch(conn->recvmbox, (void **)&buf);
00549 conn->recv_avail -= buf->p->tot_len;
00550 /* Register event with callback */
00551 if (conn->callback)
00552 (*conn->callback)(conn, NETCONN_EVT_RCVMINUS, buf->p->tot_len);
00553 }
00554
00555
00556
00557
00558 DEBUGF(API_LIB_DEBUG, ("netconn_recv: received %p (err %d)\n", (void *)buf, conn->err));
00559
00560
00561 return buf;
00562 }
|
Here is the call graph for this function:
|
||||||||||||
|
Definition at line 565 of file api_lib.c. References API_LIB_DEBUG, api_msg_post(), API_MSG_SEND, conn, DEBUGF, netconn::err, ERR_MEM, ERR_OK, ERR_VAL, netconn::mbox, MEMP_API_MSG, memp_freep(), memp_mallocp(), NULL, netbuf::p, sys_mbox_fetch(), and pbuf::tot_len. Referenced by lwip_send(), and udpclient().
00566 {
00567 struct api_msg *msg;
00568
00569 if(conn == NULL) {
00570 return ERR_VAL;
00571 }
00572
00573 if(conn->err != ERR_OK) {
00574 return conn->err;
00575 }
00576
00577 if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
00578 return (conn->err = ERR_MEM);
00579 }
00580
00581 DEBUGF(API_LIB_DEBUG, ("netconn_send: sending %d bytes\n", buf->p->tot_len));
00582 msg->type = API_MSG_SEND;
00583 msg->msg.conn = conn;
00584 msg->msg.msg.p = buf->p;
00585 api_msg_post(msg);
00586
00587 sys_mbox_fetch(conn->mbox, NULL);
00588 memp_freep(MEMP_API_MSG, msg);
00589 return conn->err;
00590 }
|
Here is the call graph for this function:
|
|
Definition at line 294 of file api_lib.c. References conn, and netconn::type.
|
|
||||||||||||||||||||
|
Definition at line 593 of file api_lib.c. References API_LIB_DEBUG, api_msg_post(), API_MSG_WRITE, conn, DEBUGF, netconn::err, ERR_MEM, ERR_OK, ERR_VAL, len, netconn::mbox, MEMP_API_MSG, memp_freep(), memp_mallocp(), NETCONN_NONE, NETCONN_TCP, NETCONN_WRITE, NULL, netconn::pcb, netconn::sem, netconn::state, sys_mbox_fetch(), sys_sem_free(), sys_sem_new(), SYS_SEM_NULL, sys_sem_wait(), tcp_sndbuf, netconn::type, u16_t, and u8_t. Referenced by lwip_send(), and tcp_client().
00594 {
00595 struct api_msg *msg;
00596 u16_t len;
00597
00598 if(conn == NULL) {
00599 return ERR_VAL;
00600 }
00601
00602 if(conn->err != ERR_OK) {
00603 return conn->err;
00604 }
00605
00606 if(conn->sem == SYS_SEM_NULL) {
00607 conn->sem = sys_sem_new(0);
00608 if(conn->sem == SYS_SEM_NULL) {
00609 return ERR_MEM;
00610 }
00611 }
00612
00613 if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
00614 return (conn->err = ERR_MEM);
00615 }
00616 msg->type = API_MSG_WRITE;
00617 msg->msg.conn = conn;
00618
00619
00620 conn->state = NETCONN_WRITE;
00621 while(conn->err == ERR_OK && size > 0) {
00622 msg->msg.msg.w.dataptr = dataptr;
00623 msg->msg.msg.w.copy = copy;
00624
00625 if(conn->type == NETCONN_TCP) {
00626 if(tcp_sndbuf(conn->pcb.tcp) == 0) {
00627 sys_sem_wait(conn->sem);
00628 if(conn->err != ERR_OK) {
00629 goto ret;
00630 }
00631 }
00632 if(size > tcp_sndbuf(conn->pcb.tcp)) {
00633 /* We cannot send more than one send buffer's worth of data at a
00634 time. */
00635 len = tcp_sndbuf(conn->pcb.tcp);
00636 } else {
00637 len = size;
00638 }
00639 } else {
00640 len = size;
00641 }
00642
00643 DEBUGF(API_LIB_DEBUG, ("netconn_write: writing %d bytes (%d)\n", len, copy));
00644 msg->msg.msg.w.len = len;
00645 api_msg_post(msg);
00646 sys_mbox_fetch(conn->mbox, NULL);
00647 if(conn->err == ERR_OK) {
00648 dataptr = (void *)((char *)dataptr + len);
00649 size -= len;
00650 } else if(conn->err == ERR_MEM) {
00651 conn->err = ERR_OK;
00652 sys_sem_wait(conn->sem);
00653 } else {
00654 goto ret;
00655 }
00656 }
00657 ret:
00658 memp_freep(MEMP_API_MSG, msg);
00659 conn->state = NETCONN_NONE;
00660 if(conn->sem != SYS_SEM_NULL) {
00661 sys_sem_free(conn->sem);
00662 conn->sem = SYS_SEM_NULL;
00663 }
00664
00665 return conn->err;
00666 }
|
Here is the call graph for this function:
1.3.4