/[lwip]/lwip/src/api/api_lib.c
ViewVC logotype

Diff of /lwip/src/api/api_lib.c

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

revision 1.14 by jani, Mon May 19 14:41:54 2003 UTC revision 1.15 by likewise, Mon Jun 9 21:14:47 2003 UTC
# Line 165  netbuf_copy_partial(struct netbuf *buf, Line 165  netbuf_copy_partial(struct netbuf *buf,
165        offset -= p->len;        offset -= p->len;
166      } else {          } else {    
167        for(i = offset; i < p->len; ++i) {        for(i = offset; i < p->len; ++i) {
168          ((char *)dataptr)[left] = ((char *)p->payload)[i];    ((char *)dataptr)[left] = ((char *)p->payload)[i];
169          if (++left >= len) {    if (++left >= len) {
170            return;      return;
171          }    }
172        }        }
173        offset = 0;        offset = 0;
174      }      }
# Line 257  netconn_delete(struct netconn *conn) Line 257  netconn_delete(struct netconn *conn)
257    if (conn->recvmbox != SYS_MBOX_NULL) {    if (conn->recvmbox != SYS_MBOX_NULL) {
258      while (sys_arch_mbox_fetch(conn->recvmbox, &mem, 1) != SYS_ARCH_TIMEOUT) {      while (sys_arch_mbox_fetch(conn->recvmbox, &mem, 1) != SYS_ARCH_TIMEOUT) {
259        if (conn->type == NETCONN_TCP) {        if (conn->type == NETCONN_TCP) {
260          pbuf_free((struct pbuf *)mem);    pbuf_free((struct pbuf *)mem);
261        } else {        } else {
262          netbuf_delete((struct netbuf *)mem);    netbuf_delete((struct netbuf *)mem);
263        }        }
264      }      }
265      sys_mbox_free(conn->recvmbox);      sys_mbox_free(conn->recvmbox);
# Line 295  netconn_type(struct netconn *conn) Line 295  netconn_type(struct netconn *conn)
295  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
296  err_t  err_t
297  netconn_peer(struct netconn *conn, struct ip_addr *addr,  netconn_peer(struct netconn *conn, struct ip_addr *addr,
298               u16_t *port)         u16_t *port)
299  {  {
300    switch (conn->type) {    switch (conn->type) {
301    case NETCONN_UDPLITE:    case NETCONN_UDPLITE:
302    case NETCONN_UDPNOCHKSUM:    case NETCONN_UDPNOCHKSUM:
303    case NETCONN_UDP:    case NETCONN_UDP:
304      if (conn->pcb.udp == NULL ||      if (conn->pcb.udp == NULL ||
305          ((conn->pcb.udp->flags & UDP_FLAGS_CONNECTED) == 0))    ((conn->pcb.udp->flags & UDP_FLAGS_CONNECTED) == 0))
306       return ERR_CONN;       return ERR_CONN;
307      *addr = (conn->pcb.udp->remote_ip);      *addr = (conn->pcb.udp->remote_ip);
308      *port = conn->pcb.udp->remote_port;      *port = conn->pcb.udp->remote_port;
# Line 319  netconn_peer(struct netconn *conn, struc Line 319  netconn_peer(struct netconn *conn, struc
319  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
320  err_t  err_t
321  netconn_addr(struct netconn *conn, struct ip_addr **addr,  netconn_addr(struct netconn *conn, struct ip_addr **addr,
322               u16_t *port)         u16_t *port)
323  {  {
324    switch (conn->type) {    switch (conn->type) {
325    case NETCONN_UDPLITE:    case NETCONN_UDPLITE:
# Line 338  netconn_addr(struct netconn *conn, struc Line 338  netconn_addr(struct netconn *conn, struc
338  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
339  err_t  err_t
340  netconn_bind(struct netconn *conn, struct ip_addr *addr,  netconn_bind(struct netconn *conn, struct ip_addr *addr,
341              u16_t port)        u16_t port)
342  {  {
343    struct api_msg *msg;    struct api_msg *msg;
344    
# Line 369  netconn_bind(struct netconn *conn, struc Line 369  netconn_bind(struct netconn *conn, struc
369  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
370  err_t  err_t
371  netconn_connect(struct netconn *conn, struct ip_addr *addr,  netconn_connect(struct netconn *conn, struct ip_addr *addr,
372                     u16_t port)         u16_t port)
373  {  {
374    struct api_msg *msg;    struct api_msg *msg;
375        
# Line 543  netconn_recv(struct netconn *conn) Line 543  netconn_recv(struct netconn *conn)
543      memp_freep(MEMP_API_MSG, msg);      memp_freep(MEMP_API_MSG, msg);
544    } else {    } else {
545      sys_mbox_fetch(conn->recvmbox, (void **)&buf);      sys_mbox_fetch(conn->recvmbox, (void **)&buf);
546          conn->recv_avail -= buf->p->tot_len;    conn->recv_avail -= buf->p->tot_len;
547      /* Register event with callback */      /* Register event with callback */
548      if (conn->callback)      if (conn->callback)
549          (*conn->callback)(conn, NETCONN_EVT_RCVMINUS, buf->p->tot_len);          (*conn->callback)(conn, NETCONN_EVT_RCVMINUS, buf->p->tot_len);
# Line 621  netconn_write(struct netconn *conn, void Line 621  netconn_write(struct netconn *conn, void
621            
622      if (conn->type == NETCONN_TCP) {      if (conn->type == NETCONN_TCP) {
623        if (tcp_sndbuf(conn->pcb.tcp) == 0) {        if (tcp_sndbuf(conn->pcb.tcp) == 0) {
624          sys_sem_wait(conn->sem);    sys_sem_wait(conn->sem);
625          if (conn->err != ERR_OK) {    if (conn->err != ERR_OK) {
626            goto ret;      goto ret;
627          }    }
628        }        }
629        if (size > tcp_sndbuf(conn->pcb.tcp)) {        if (size > tcp_sndbuf(conn->pcb.tcp)) {
630          /* We cannot send more than one send buffer's worth of data at a    /* We cannot send more than one send buffer's worth of data at a
631             time. */       time. */
632          len = tcp_sndbuf(conn->pcb.tcp);    len = tcp_sndbuf(conn->pcb.tcp);
633        } else {        } else {
634          len = size;    len = size;
635        }        }
636      } else {      } else {
637        len = size;        len = size;

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

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