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

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

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

revision 1.12 by kieranm, Mon Mar 31 09:35:47 2003 UTC revision 1.12.2.1 by likewise, Wed May 14 14:38:27 2003 UTC
# Line 47  recv_udp(void *arg, struct udp_pcb *pcb, Line 47  recv_udp(void *arg, struct udp_pcb *pcb,
47    
48    conn = arg;    conn = arg;
49        
50    if(conn == NULL) {    if (conn == NULL) {
51      pbuf_free(p);      pbuf_free(p);
52      return;      return;
53    }    }
54    if(conn->recvmbox != SYS_MBOX_NULL) {    if (conn->recvmbox != SYS_MBOX_NULL) {
55      buf = memp_mallocp(MEMP_NETBUF);      buf = memp_mallocp(MEMP_NETBUF);
56      if(buf == NULL) {      if (buf == NULL) {
57        pbuf_free(p);        pbuf_free(p);
58        return;        return;
59      } else {      } else {
# Line 81  recv_tcp(void *arg, struct tcp_pcb *pcb, Line 81  recv_tcp(void *arg, struct tcp_pcb *pcb,
81        
82    conn = arg;    conn = arg;
83    
84    if(conn == NULL) {    if (conn == NULL) {
85      pbuf_free(p);      pbuf_free(p);
86      return ERR_VAL;      return ERR_VAL;
87    }    }
88    
89    if(conn->recvmbox != SYS_MBOX_NULL) {    if (conn->recvmbox != SYS_MBOX_NULL) {
90                        
91      conn->err = err;      conn->err = err;
92      if (p != NULL) {      if (p != NULL) {
# Line 110  poll_tcp(void *arg, struct tcp_pcb *pcb) Line 110  poll_tcp(void *arg, struct tcp_pcb *pcb)
110    struct netconn *conn;    struct netconn *conn;
111    
112    conn = arg;    conn = arg;
113    if(conn != NULL &&    if (conn != NULL &&
114       (conn->state == NETCONN_WRITE || conn->state == NETCONN_CLOSE) &&       (conn->state == NETCONN_WRITE || conn->state == NETCONN_CLOSE) &&
115       conn->sem != SYS_SEM_NULL) {       conn->sem != SYS_SEM_NULL) {
116      sys_sem_signal(conn->sem);      sys_sem_signal(conn->sem);
# Line 124  sent_tcp(void *arg, struct tcp_pcb *pcb, Line 124  sent_tcp(void *arg, struct tcp_pcb *pcb,
124    struct netconn *conn;    struct netconn *conn;
125    
126    conn = arg;    conn = arg;
127    if(conn != NULL && conn->sem != SYS_SEM_NULL) {    if (conn != NULL && conn->sem != SYS_SEM_NULL) {
128      sys_sem_signal(conn->sem);      sys_sem_signal(conn->sem);
129    }    }
130    
# Line 146  err_tcp(void *arg, err_t err) Line 146  err_tcp(void *arg, err_t err)
146    
147        
148    conn->err = err;    conn->err = err;
149    if(conn->recvmbox != SYS_MBOX_NULL) {    if (conn->recvmbox != SYS_MBOX_NULL) {
150      /* Register event with callback */      /* Register event with callback */
151      if (conn->callback)      if (conn->callback)
152        (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, 0);        (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, 0);
153      sys_mbox_post(conn->recvmbox, NULL);      sys_mbox_post(conn->recvmbox, NULL);
154    }    }
155    if(conn->mbox != SYS_MBOX_NULL) {    if (conn->mbox != SYS_MBOX_NULL) {
156      sys_mbox_post(conn->mbox, NULL);      sys_mbox_post(conn->mbox, NULL);
157    }    }
158    if(conn->acceptmbox != SYS_MBOX_NULL) {    if (conn->acceptmbox != SYS_MBOX_NULL) {
159       /* Register event with callback */       /* Register event with callback */
160      if (conn->callback)      if (conn->callback)
161        (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, 0);        (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, 0);
162      sys_mbox_post(conn->acceptmbox, NULL);      sys_mbox_post(conn->acceptmbox, NULL);
163    }    }
164    if(conn->sem != SYS_SEM_NULL) {    if (conn->sem != SYS_SEM_NULL) {
165      sys_sem_signal(conn->sem);      sys_sem_signal(conn->sem);
166    }    }
167  }  }
# Line 194  accept_function(void *arg, struct tcp_pc Line 194  accept_function(void *arg, struct tcp_pc
194    conn = (struct netconn *)arg;    conn = (struct netconn *)arg;
195    mbox = conn->acceptmbox;    mbox = conn->acceptmbox;
196    newconn = memp_mallocp(MEMP_NETCONN);    newconn = memp_mallocp(MEMP_NETCONN);
197    if(newconn == NULL) {    if (newconn == NULL) {
198      return ERR_MEM;      return ERR_MEM;
199    }    }
200    newconn->type = NETCONN_TCP;    newconn->type = NETCONN_TCP;
201    newconn->pcb.tcp = newpcb;    newconn->pcb.tcp = newpcb;
202    setup_tcp(newconn);    setup_tcp(newconn);
203    newconn->recvmbox = sys_mbox_new();    newconn->recvmbox = sys_mbox_new();
204    if(newconn->recvmbox == SYS_MBOX_NULL) {    if (newconn->recvmbox == SYS_MBOX_NULL) {
205      memp_free(MEMP_NETCONN, newconn);      memp_free(MEMP_NETCONN, newconn);
206      return ERR_MEM;      return ERR_MEM;
207    }    }
208    newconn->mbox = sys_mbox_new();    newconn->mbox = sys_mbox_new();
209    if(newconn->mbox == SYS_MBOX_NULL) {    if (newconn->mbox == SYS_MBOX_NULL) {
210      sys_mbox_free(newconn->recvmbox);      sys_mbox_free(newconn->recvmbox);
211      memp_free(MEMP_NETCONN, newconn);      memp_free(MEMP_NETCONN, newconn);
212      return ERR_MEM;      return ERR_MEM;
213    }    }
214    newconn->sem = sys_sem_new(0);    newconn->sem = sys_sem_new(0);
215    if(newconn->sem == SYS_SEM_NULL) {    if (newconn->sem == SYS_SEM_NULL) {
216      sys_mbox_free(newconn->recvmbox);      sys_mbox_free(newconn->recvmbox);
217      sys_mbox_free(newconn->mbox);      sys_mbox_free(newconn->mbox);
218      memp_free(MEMP_NETCONN, newconn);      memp_free(MEMP_NETCONN, newconn);
# Line 243  do_newconn(struct api_msg_msg *msg) Line 243  do_newconn(struct api_msg_msg *msg)
243  static void  static void
244  do_delconn(struct api_msg_msg *msg)  do_delconn(struct api_msg_msg *msg)
245  {  {
246    if(msg->conn->pcb.tcp != NULL) {    if (msg->conn->pcb.tcp != NULL) {
247      switch(msg->conn->type) {      switch (msg->conn->type) {
248  #if LWIP_UDP  #if LWIP_UDP
249      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
250        /* FALLTHROUGH */        /* FALLTHROUGH */
# Line 257  do_delconn(struct api_msg_msg *msg) Line 257  do_delconn(struct api_msg_msg *msg)
257  #endif /* LWIP_UDP */  #endif /* LWIP_UDP */
258  #if LWIP_TCP        #if LWIP_TCP      
259      case NETCONN_TCP:      case NETCONN_TCP:
260        if(msg->conn->pcb.tcp->state == LISTEN) {        if (msg->conn->pcb.tcp->state == LISTEN) {
261          tcp_arg(msg->conn->pcb.tcp, NULL);          tcp_arg(msg->conn->pcb.tcp, NULL);
262          tcp_accept(msg->conn->pcb.tcp, NULL);            tcp_accept(msg->conn->pcb.tcp, NULL);  
263          tcp_close(msg->conn->pcb.tcp);          tcp_close(msg->conn->pcb.tcp);
# Line 267  do_delconn(struct api_msg_msg *msg) Line 267  do_delconn(struct api_msg_msg *msg)
267          tcp_recv(msg->conn->pcb.tcp, NULL);              tcp_recv(msg->conn->pcb.tcp, NULL);    
268          tcp_poll(msg->conn->pcb.tcp, NULL, 0);          tcp_poll(msg->conn->pcb.tcp, NULL, 0);
269          tcp_err(msg->conn->pcb.tcp, NULL);          tcp_err(msg->conn->pcb.tcp, NULL);
270          if(tcp_close(msg->conn->pcb.tcp) != ERR_OK) {          if (tcp_close(msg->conn->pcb.tcp) != ERR_OK) {
271            tcp_abort(msg->conn->pcb.tcp);            tcp_abort(msg->conn->pcb.tcp);
272          }          }
273        }        }
# Line 283  do_delconn(struct api_msg_msg *msg) Line 283  do_delconn(struct api_msg_msg *msg)
283        (*msg->conn->callback)(msg->conn, NETCONN_EVT_SENDPLUS, 0);        (*msg->conn->callback)(msg->conn, NETCONN_EVT_SENDPLUS, 0);
284    }    }
285        
286    if(msg->conn->mbox != SYS_MBOX_NULL) {    if (msg->conn->mbox != SYS_MBOX_NULL) {
287      sys_mbox_post(msg->conn->mbox, NULL);      sys_mbox_post(msg->conn->mbox, NULL);
288    }    }
289  }  }
# Line 291  do_delconn(struct api_msg_msg *msg) Line 291  do_delconn(struct api_msg_msg *msg)
291  static void  static void
292  do_bind(struct api_msg_msg *msg)  do_bind(struct api_msg_msg *msg)
293  {  {
294    if(msg->conn->pcb.tcp == NULL) {    if (msg->conn->pcb.tcp == NULL) {
295      switch(msg->conn->type) {      switch (msg->conn->type) {
296  #if LWIP_UDP  #if LWIP_UDP
297      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
298        msg->conn->pcb.udp = udp_new();        msg->conn->pcb.udp = udp_new();
# Line 318  do_bind(struct api_msg_msg *msg) Line 318  do_bind(struct api_msg_msg *msg)
318      break;      break;
319      }      }
320    }    }
321    switch(msg->conn->type) {    switch (msg->conn->type) {
322  #if LWIP_UDP  #if LWIP_UDP
323    case NETCONN_UDPLITE:    case NETCONN_UDPLITE:
324      /* FALLTHROUGH */      /* FALLTHROUGH */
# Line 347  do_connected(void *arg, struct tcp_pcb * Line 347  do_connected(void *arg, struct tcp_pcb *
347    
348    conn = arg;    conn = arg;
349    
350    if(conn == NULL) {    if (conn == NULL) {
351      return ERR_VAL;      return ERR_VAL;
352    }    }
353        
354    conn->err = err;    conn->err = err;
355    if(conn->type == NETCONN_TCP && err == ERR_OK) {    if (conn->type == NETCONN_TCP && err == ERR_OK) {
356      setup_tcp(conn);      setup_tcp(conn);
357    }        }    
358    sys_mbox_post(conn->mbox, NULL);    sys_mbox_post(conn->mbox, NULL);
# Line 363  do_connected(void *arg, struct tcp_pcb * Line 363  do_connected(void *arg, struct tcp_pcb *
363  static void  static void
364  do_connect(struct api_msg_msg *msg)  do_connect(struct api_msg_msg *msg)
365  {  {
366    if(msg->conn->pcb.tcp == NULL) {    if (msg->conn->pcb.tcp == NULL) {
367      switch(msg->conn->type) {      switch (msg->conn->type) {
368  #if LWIP_UDP  #if LWIP_UDP
369      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
370        msg->conn->pcb.udp = udp_new();        msg->conn->pcb.udp = udp_new();
371        if(msg->conn->pcb.udp == NULL) {        if (msg->conn->pcb.udp == NULL) {
372          msg->conn->err = ERR_MEM;          msg->conn->err = ERR_MEM;
373          sys_mbox_post(msg->conn->mbox, NULL);          sys_mbox_post(msg->conn->mbox, NULL);
374          return;          return;
# Line 378  do_connect(struct api_msg_msg *msg) Line 378  do_connect(struct api_msg_msg *msg)
378        break;        break;
379      case NETCONN_UDPNOCHKSUM:      case NETCONN_UDPNOCHKSUM:
380        msg->conn->pcb.udp = udp_new();        msg->conn->pcb.udp = udp_new();
381        if(msg->conn->pcb.udp == NULL) {        if (msg->conn->pcb.udp == NULL) {
382          msg->conn->err = ERR_MEM;          msg->conn->err = ERR_MEM;
383          sys_mbox_post(msg->conn->mbox, NULL);          sys_mbox_post(msg->conn->mbox, NULL);
384          return;          return;
# Line 388  do_connect(struct api_msg_msg *msg) Line 388  do_connect(struct api_msg_msg *msg)
388        break;        break;
389      case NETCONN_UDP:      case NETCONN_UDP:
390        msg->conn->pcb.udp = udp_new();        msg->conn->pcb.udp = udp_new();
391        if(msg->conn->pcb.udp == NULL) {        if (msg->conn->pcb.udp == NULL) {
392          msg->conn->err = ERR_MEM;          msg->conn->err = ERR_MEM;
393          sys_mbox_post(msg->conn->mbox, NULL);          sys_mbox_post(msg->conn->mbox, NULL);
394          return;          return;
# Line 399  do_connect(struct api_msg_msg *msg) Line 399  do_connect(struct api_msg_msg *msg)
399  #if LWIP_TCP        #if LWIP_TCP      
400      case NETCONN_TCP:      case NETCONN_TCP:
401        msg->conn->pcb.tcp = tcp_new();              msg->conn->pcb.tcp = tcp_new();      
402        if(msg->conn->pcb.tcp == NULL) {        if (msg->conn->pcb.tcp == NULL) {
403          msg->conn->err = ERR_MEM;          msg->conn->err = ERR_MEM;
404          sys_mbox_post(msg->conn->mbox, NULL);          sys_mbox_post(msg->conn->mbox, NULL);
405          return;          return;
# Line 409  do_connect(struct api_msg_msg *msg) Line 409  do_connect(struct api_msg_msg *msg)
409        break;        break;
410      }      }
411    }    }
412    switch(msg->conn->type) {    switch (msg->conn->type) {
413  #if LWIP_UDP  #if LWIP_UDP
414    case NETCONN_UDPLITE:    case NETCONN_UDPLITE:
415      /* FALLTHROUGH */      /* FALLTHROUGH */
# Line 437  static void Line 437  static void
437  do_disconnect(struct api_msg_msg *msg)  do_disconnect(struct api_msg_msg *msg)
438  {  {
439    
440    switch(msg->conn->type) {    switch (msg->conn->type) {
441  #if LWIP_UDP  #if LWIP_UDP
442    case NETCONN_UDPLITE:    case NETCONN_UDPLITE:
443      /* FALLTHROUGH */      /* FALLTHROUGH */
# Line 457  do_disconnect(struct api_msg_msg *msg) Line 457  do_disconnect(struct api_msg_msg *msg)
457  static void  static void
458  do_listen(struct api_msg_msg *msg)  do_listen(struct api_msg_msg *msg)
459  {  {
460    if(msg->conn->pcb.tcp != NULL) {    if (msg->conn->pcb.tcp != NULL) {
461      switch(msg->conn->type) {      switch (msg->conn->type) {
462  #if LWIP_UDP  #if LWIP_UDP
463      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
464        /* FALLTHROUGH */        /* FALLTHROUGH */
# Line 471  do_listen(struct api_msg_msg *msg) Line 471  do_listen(struct api_msg_msg *msg)
471  #if LWIP_TCP        #if LWIP_TCP      
472      case NETCONN_TCP:      case NETCONN_TCP:
473        msg->conn->pcb.tcp = tcp_listen(msg->conn->pcb.tcp);        msg->conn->pcb.tcp = tcp_listen(msg->conn->pcb.tcp);
474        if(msg->conn->pcb.tcp == NULL) {        if (msg->conn->pcb.tcp == NULL) {
475          msg->conn->err = ERR_MEM;          msg->conn->err = ERR_MEM;
476        } else {        } else {
477          if(msg->conn->acceptmbox == SYS_MBOX_NULL) {          if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
478            msg->conn->acceptmbox = sys_mbox_new();            msg->conn->acceptmbox = sys_mbox_new();
479            if(msg->conn->acceptmbox == SYS_MBOX_NULL) {            if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
480              msg->conn->err = ERR_MEM;              msg->conn->err = ERR_MEM;
481              break;              break;
482            }            }
# Line 495  do_listen(struct api_msg_msg *msg) Line 495  do_listen(struct api_msg_msg *msg)
495  static void  static void
496  do_accept(struct api_msg_msg *msg)  do_accept(struct api_msg_msg *msg)
497  {  {
498    if(msg->conn->pcb.tcp != NULL) {    if (msg->conn->pcb.tcp != NULL) {
499      switch(msg->conn->type) {      switch (msg->conn->type) {
500  #if LWIP_UDP  #if LWIP_UDP
501      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
502        /* FALLTHROUGH */        /* FALLTHROUGH */
# Line 515  do_accept(struct api_msg_msg *msg) Line 515  do_accept(struct api_msg_msg *msg)
515  static void  static void
516  do_send(struct api_msg_msg *msg)  do_send(struct api_msg_msg *msg)
517  {  {
518    if(msg->conn->pcb.tcp != NULL) {    if (msg->conn->pcb.tcp != NULL) {
519      switch(msg->conn->type) {      switch (msg->conn->type) {
520  #if LWIP_UDP  #if LWIP_UDP
521      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
522        /* FALLTHROUGH */        /* FALLTHROUGH */
# Line 537  static void Line 537  static void
537  do_recv(struct api_msg_msg *msg)  do_recv(struct api_msg_msg *msg)
538  {  {
539  #if LWIP_TCP  #if LWIP_TCP
540    if(msg->conn->pcb.tcp != NULL) {    if (msg->conn->pcb.tcp != NULL) {
541      if(msg->conn->type == NETCONN_TCP) {      if (msg->conn->type == NETCONN_TCP) {
542        tcp_recved(msg->conn->pcb.tcp, msg->msg.len);        tcp_recved(msg->conn->pcb.tcp, msg->msg.len);
543      }      }
544    }    }
# Line 552  do_write(struct api_msg_msg *msg) Line 552  do_write(struct api_msg_msg *msg)
552  #if LWIP_TCP      #if LWIP_TCP    
553    err_t err;    err_t err;
554  #endif    #endif  
555    if(msg->conn->pcb.tcp != NULL) {    if (msg->conn->pcb.tcp != NULL) {
556      switch(msg->conn->type) {      switch (msg->conn->type) {
557  #if LWIP_UDP  #if LWIP_UDP
558      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
559        /* FALLTHROUGH */        /* FALLTHROUGH */
# Line 571  do_write(struct api_msg_msg *msg) Line 571  do_write(struct api_msg_msg *msg)
571           segments when new outgoing data arrives from the user if any           segments when new outgoing data arrives from the user if any
572           previously transmitted data on the connection remains           previously transmitted data on the connection remains
573           unacknowledged. */           unacknowledged. */
574        if(err == ERR_OK && msg->conn->pcb.tcp->unacked == NULL) {        if (err == ERR_OK && msg->conn->pcb.tcp->unacked == NULL) {
575          tcp_output(msg->conn->pcb.tcp);          tcp_output(msg->conn->pcb.tcp);
576        }        }
577        msg->conn->err = err;        msg->conn->err = err;
# Line 596  do_close(struct api_msg_msg *msg) Line 596  do_close(struct api_msg_msg *msg)
596    
597    err = ERR_OK;    err = ERR_OK;
598    
599    if(msg->conn->pcb.tcp != NULL) {    if (msg->conn->pcb.tcp != NULL) {
600      switch(msg->conn->type) {      switch (msg->conn->type) {
601  #if LWIP_UDP  #if LWIP_UDP
602      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
603        /* FALLTHROUGH */        /* FALLTHROUGH */
# Line 608  do_close(struct api_msg_msg *msg) Line 608  do_close(struct api_msg_msg *msg)
608  #endif /* LWIP_UDP */  #endif /* LWIP_UDP */
609  #if LWIP_TCP  #if LWIP_TCP
610      case NETCONN_TCP:      case NETCONN_TCP:
611        if(msg->conn->pcb.tcp->state == LISTEN) {        if (msg->conn->pcb.tcp->state == LISTEN) {
612          err = tcp_close(msg->conn->pcb.tcp);          err = tcp_close(msg->conn->pcb.tcp);
613        }        }
614        msg->conn->err = err;              msg->conn->err = err;      

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.12.2.1

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