/[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.16.2.2 by kieranm, Thu Aug 21 09:59:21 2003 UTC revision 1.16.2.3 by kieranm, Wed Sep 10 17:14:27 2003 UTC
# Line 194  netbuf_fromport(struct netbuf *buf) Line 194  netbuf_fromport(struct netbuf *buf)
194  }  }
195  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
196  struct  struct
197  netconn *netconn_new(enum netconn_type t)  netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u16_t proto,
198                                       void (*callback)(struct netconn *, enum netconn_evt, u16_t len))
199  {  {
200    struct netconn *conn;    struct netconn *conn;
201    struct api_msg *msg;    struct api_msg *msg;
# Line 217  netconn *netconn_new(enum netconn_type t Line 218  netconn *netconn_new(enum netconn_type t
218    conn->sem = SYS_SEM_NULL;    conn->sem = SYS_SEM_NULL;
219    conn->state = NETCONN_NONE;    conn->state = NETCONN_NONE;
220    conn->socket = 0;    conn->socket = 0;
221    conn->callback = 0;    conn->callback = callback;
222    conn->recv_avail = 0;    conn->recv_avail = 0;
223    
224    if((msg = memp_malloc(MEMP_API_MSG)) == NULL) {    if((msg = memp_malloc(MEMP_API_MSG)) == NULL) {
# Line 226  netconn *netconn_new(enum netconn_type t Line 227  netconn *netconn_new(enum netconn_type t
227    }    }
228        
229    msg->type = API_MSG_NEWCONN;    msg->type = API_MSG_NEWCONN;
230      msg->msg.msg.bc.port = proto; /* misusing the port field */
231    msg->msg.conn = conn;    msg->msg.conn = conn;
232    api_msg_post(msg);      api_msg_post(msg);  
233    sys_mbox_fetch(conn->mbox, NULL);    sys_mbox_fetch(conn->mbox, NULL);
# Line 238  netconn *netconn_new(enum netconn_type t Line 240  netconn *netconn_new(enum netconn_type t
240    
241    return conn;    return conn;
242  }  }
243    
244    /*-----------------------------------------------------------------------------------*/
245    struct
246    netconn *netconn_new(enum netconn_type t)
247    {
248      return netconn_new_with_proto_and_callback(t,0,NULL);
249    }
250  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
251  struct  struct
252  netconn *netconn_new_with_callback(enum netconn_type t,  netconn *netconn_new_with_callback(enum netconn_type t,
253                                     void (*callback)(struct netconn *, enum netconn_evt, u16_t len))                                     void (*callback)(struct netconn *, enum netconn_evt, u16_t len))
254  {  {
255      struct netconn *conn;    return netconn_new_with_proto_and_callback(t,0,callback);
       
     /* get a netconn and then initialize callback pointer and socket */  
     conn = netconn_new(t);  
     if (conn)  
         conn->callback = callback;  
     return conn;  
256  }  }
257    
258  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
# Line 318  netconn_peer(struct netconn *conn, struc Line 321  netconn_peer(struct netconn *conn, struc
321         u16_t *port)         u16_t *port)
322  {  {
323    switch (conn->type) {    switch (conn->type) {
324      case NETCONN_RAW:
325        /* return an error as connecting is only a helper for upper layers */
326        return ERR_CONN;
327    case NETCONN_UDPLITE:    case NETCONN_UDPLITE:
328    case NETCONN_UDPNOCHKSUM:    case NETCONN_UDPNOCHKSUM:
329    case NETCONN_UDP:    case NETCONN_UDP:
# Line 342  netconn_addr(struct netconn *conn, struc Line 348  netconn_addr(struct netconn *conn, struc
348         u16_t *port)         u16_t *port)
349  {  {
350    switch (conn->type) {    switch (conn->type) {
351      case NETCONN_RAW:
352        *addr = &(conn->pcb.raw->local_ip);
353        *port = conn->pcb.raw->protocol;
354        break;
355    case NETCONN_UDPLITE:    case NETCONN_UDPLITE:
356    case NETCONN_UDPNOCHKSUM:    case NETCONN_UDPNOCHKSUM:
357    case NETCONN_UDP:    case NETCONN_UDP:

Legend:
Removed from v.1.16.2.2  
changed lines
  Added in v.1.16.2.3

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