/[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.15.2.2 by kieranm, Thu Aug 21 09:59:21 2003 UTC revision 1.15.2.3 by kieranm, Wed Sep 10 17:14:27 2003 UTC
# Line 37  Line 37 
37  #include "lwip/sys.h"  #include "lwip/sys.h"
38  #include "lwip/tcpip.h"  #include "lwip/tcpip.h"
39    
40    #if LWIP_RAW
41    static int
42    recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p,
43        struct ip_addr *addr)
44    {
45      struct netbuf *buf;
46      struct netconn *conn;
47    
48      conn = arg;
49      if (!conn) return 0;
50    
51      if (conn->recvmbox != SYS_MBOX_NULL) {
52        if (!(buf = memp_malloc(MEMP_NETBUF))) {
53          return 0;
54        }
55        pbuf_ref(p);
56        buf->p = p;
57        buf->ptr = p;
58        buf->fromaddr = addr;
59        buf->fromport = pcb->protocol;
60    
61        conn->recv_avail += p->tot_len;
62        /* Register event with callback */
63        if (conn->callback)
64            (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, p->tot_len);
65        sys_mbox_post(conn->recvmbox, buf);
66      }
67    
68      return 0; /* do not eat the packet */
69    }
70    #endif
71  #if LWIP_UDP  #if LWIP_UDP
72  static void  static void
73  recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,  recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
# Line 250  do_newconn(struct api_msg_msg *msg) Line 281  do_newconn(struct api_msg_msg *msg)
281    
282     /* Allocate a PCB for this connection */     /* Allocate a PCB for this connection */
283     switch(msg->conn->type) {     switch(msg->conn->type) {
284    #if LWIP_RAW
285       case NETCONN_RAW:
286          msg->conn->pcb.raw = raw_new(msg->msg.bc.port); /* misusing the port field */
287          raw_recv(msg->conn->pcb.raw, recv_raw, msg->conn);
288         break;
289    #endif
290  #if LWIP_UDP  #if LWIP_UDP
291     case NETCONN_UDPLITE:     case NETCONN_UDPLITE:
292        msg->conn->pcb.udp = udp_new();        msg->conn->pcb.udp = udp_new();
# Line 300  do_delconn(struct api_msg_msg *msg) Line 337  do_delconn(struct api_msg_msg *msg)
337  {  {
338    if (msg->conn->pcb.tcp != NULL) {    if (msg->conn->pcb.tcp != NULL) {
339      switch (msg->conn->type) {      switch (msg->conn->type) {
340    #if LWIP_RAW
341        case NETCONN_RAW:
342          raw_remove(msg->conn->pcb.raw);
343          break;
344    #endif
345  #if LWIP_UDP  #if LWIP_UDP
346      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
347        /* FALLTHROUGH */        /* FALLTHROUGH */
# Line 348  do_bind(struct api_msg_msg *msg) Line 390  do_bind(struct api_msg_msg *msg)
390  {  {
391    if (msg->conn->pcb.tcp == NULL) {    if (msg->conn->pcb.tcp == NULL) {
392      switch (msg->conn->type) {      switch (msg->conn->type) {
393    #if LWIP_RAW
394        case NETCONN_RAW:
395          msg->conn->pcb.raw = raw_new(msg->msg.bc.port); /* misusing the port field as protocol */
396          raw_recv(msg->conn->pcb.raw, recv_raw, msg->conn);
397          break;
398    #endif
399  #if LWIP_UDP  #if LWIP_UDP
400      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
401        msg->conn->pcb.udp = udp_new();        msg->conn->pcb.udp = udp_new();
# Line 374  do_bind(struct api_msg_msg *msg) Line 422  do_bind(struct api_msg_msg *msg)
422      }      }
423    }    }
424    switch (msg->conn->type) {    switch (msg->conn->type) {
425    #if LWIP_RAW
426      case NETCONN_RAW:
427        msg->conn->err = raw_bind(msg->conn->pcb.raw,msg->msg.bc.ipaddr);
428        break;
429    #endif
430  #if LWIP_UDP  #if LWIP_UDP
431    case NETCONN_UDPLITE:    case NETCONN_UDPLITE:
432      /* FALLTHROUGH */      /* FALLTHROUGH */
# Line 420  do_connect(struct api_msg_msg *msg) Line 473  do_connect(struct api_msg_msg *msg)
473  {  {
474    if (msg->conn->pcb.tcp == NULL) {    if (msg->conn->pcb.tcp == NULL) {
475      switch (msg->conn->type) {      switch (msg->conn->type) {
476    #if LWIP_RAW
477        case NETCONN_RAW:
478          msg->conn->pcb.raw = raw_new(msg->msg.bc.port); /* misusing the port field as protocol */
479          raw_recv(msg->conn->pcb.raw, recv_raw, msg->conn);
480          break;
481    #endif
482  #if LWIP_UDP  #if LWIP_UDP
483      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
484        msg->conn->pcb.udp = udp_new();        msg->conn->pcb.udp = udp_new();
# Line 465  do_connect(struct api_msg_msg *msg) Line 524  do_connect(struct api_msg_msg *msg)
524      }      }
525    }    }
526    switch (msg->conn->type) {    switch (msg->conn->type) {
527    #if LWIP_RAW
528      case NETCONN_RAW:
529        raw_connect(msg->conn->pcb.raw, msg->msg.bc.ipaddr);
530        sys_mbox_post(msg->conn->mbox, NULL);
531        break;
532    #endif
533  #if LWIP_UDP  #if LWIP_UDP
534    case NETCONN_UDPLITE:    case NETCONN_UDPLITE:
535      /* FALLTHROUGH */      /* FALLTHROUGH */
# Line 483  do_connect(struct api_msg_msg *msg) Line 548  do_connect(struct api_msg_msg *msg)
548      do_connected);      do_connected);
549      /*tcp_output(msg->conn->pcb.tcp);*/      /*tcp_output(msg->conn->pcb.tcp);*/
550  #endif  #endif
551    
552    default:    default:
553      break;      break;
554    }    }
# Line 493  do_disconnect(struct api_msg_msg *msg) Line 559  do_disconnect(struct api_msg_msg *msg)
559  {  {
560    
561    switch (msg->conn->type) {    switch (msg->conn->type) {
562    #if LWIP_RAW
563      case NETCONN_RAW:
564        /* Do nothing as connecting is only a helper for upper lwip layers */
565        break;
566    #endif
567  #if LWIP_UDP  #if LWIP_UDP
568    case NETCONN_UDPLITE:    case NETCONN_UDPLITE:
569      /* FALLTHROUGH */      /* FALLTHROUGH */
# Line 514  do_listen(struct api_msg_msg *msg) Line 585  do_listen(struct api_msg_msg *msg)
585  {  {
586    if (msg->conn->pcb.tcp != NULL) {    if (msg->conn->pcb.tcp != NULL) {
587      switch (msg->conn->type) {      switch (msg->conn->type) {
588    #if LWIP_RAW
589        case NETCONN_RAW:
590          LWIP_DEBUGF(API_MSG_DEBUG, ("api_msg: listen RAW: cannot listen for RAW.\n"));
591          break;
592    #endif
593  #if LWIP_UDP  #if LWIP_UDP
594      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
595        /* FALLTHROUGH */        /* FALLTHROUGH */
# Line 552  do_accept(struct api_msg_msg *msg) Line 628  do_accept(struct api_msg_msg *msg)
628  {  {
629    if (msg->conn->pcb.tcp != NULL) {    if (msg->conn->pcb.tcp != NULL) {
630      switch (msg->conn->type) {      switch (msg->conn->type) {
631    #if LWIP_RAW
632        case NETCONN_RAW:
633          LWIP_DEBUGF(API_MSG_DEBUG, ("api_msg: accept RAW: cannot accept for RAW.\n"));
634          break;
635    #endif
636  #if LWIP_UDP  #if LWIP_UDP
637      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
638        /* FALLTHROUGH */        /* FALLTHROUGH */
# Line 572  do_send(struct api_msg_msg *msg) Line 653  do_send(struct api_msg_msg *msg)
653  {  {
654    if (msg->conn->pcb.tcp != NULL) {    if (msg->conn->pcb.tcp != NULL) {
655      switch (msg->conn->type) {      switch (msg->conn->type) {
656    #if LWIP_RAW
657        case NETCONN_RAW:
658          raw_send(msg->conn->pcb.raw, msg->msg.p);
659          break;
660    #endif
661  #if LWIP_UDP  #if LWIP_UDP
662      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
663        /* FALLTHROUGH */        /* FALLTHROUGH */
# Line 609  do_write(struct api_msg_msg *msg) Line 695  do_write(struct api_msg_msg *msg)
695  #endif    #endif  
696    if (msg->conn->pcb.tcp != NULL) {    if (msg->conn->pcb.tcp != NULL) {
697      switch (msg->conn->type) {      switch (msg->conn->type) {
698    #if LWIP_RAW
699        case NETCONN_RAW:
700          msg->conn->err = ERR_VAL;
701          break;
702    #endif
703  #if LWIP_UDP  #if LWIP_UDP
704      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
705        /* FALLTHROUGH */        /* FALLTHROUGH */
# Line 653  do_close(struct api_msg_msg *msg) Line 744  do_close(struct api_msg_msg *msg)
744    
745    if (msg->conn->pcb.tcp != NULL) {    if (msg->conn->pcb.tcp != NULL) {
746      switch (msg->conn->type) {      switch (msg->conn->type) {
747    #if LWIP_RAW
748        case NETCONN_RAW:
749          break;
750    #endif
751  #if LWIP_UDP  #if LWIP_UDP
752      case NETCONN_UDPLITE:      case NETCONN_UDPLITE:
753        /* FALLTHROUGH */        /* FALLTHROUGH */

Legend:
Removed from v.1.15.2.2  
changed lines
  Added in v.1.15.2.3

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