/[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.3 by kieranm, Wed Sep 10 17:14:27 2003 UTC revision 1.16.2.4 by likewise, Fri Nov 14 09:42:51 2003 UTC
# Line 38  Line 38 
38  #include "lwip/api_msg.h"  #include "lwip/api_msg.h"
39  #include "lwip/memp.h"  #include "lwip/memp.h"
40    
41  /*-----------------------------------------------------------------------------------*/  
42  struct  struct
43  netbuf *netbuf_new(void)  netbuf *netbuf_new(void)
44  {  {
# Line 53  netbuf *netbuf_new(void) Line 53  netbuf *netbuf_new(void)
53      return NULL;      return NULL;
54    }    }
55  }  }
56  /*-----------------------------------------------------------------------------------*/  
57  void  void
58  netbuf_delete(struct netbuf *buf)  netbuf_delete(struct netbuf *buf)
59  {  {
# Line 65  netbuf_delete(struct netbuf *buf) Line 65  netbuf_delete(struct netbuf *buf)
65      memp_free(MEMP_NETBUF, buf);      memp_free(MEMP_NETBUF, buf);
66    }    }
67  }  }
68  /*-----------------------------------------------------------------------------------*/  
69  void *  void *
70  netbuf_alloc(struct netbuf *buf, u16_t size)  netbuf_alloc(struct netbuf *buf, u16_t size)
71  {  {
# Line 80  netbuf_alloc(struct netbuf *buf, u16_t s Line 80  netbuf_alloc(struct netbuf *buf, u16_t s
80    buf->ptr = buf->p;    buf->ptr = buf->p;
81    return buf->p->payload;    return buf->p->payload;
82  }  }
83  /*-----------------------------------------------------------------------------------*/  
84  void  void
85  netbuf_free(struct netbuf *buf)  netbuf_free(struct netbuf *buf)
86  {  {
# Line 89  netbuf_free(struct netbuf *buf) Line 89  netbuf_free(struct netbuf *buf)
89    }    }
90    buf->p = buf->ptr = NULL;    buf->p = buf->ptr = NULL;
91  }  }
92  /*-----------------------------------------------------------------------------------*/  
93  void  void
94  netbuf_ref(struct netbuf *buf, void *dataptr, u16_t size)  netbuf_ref(struct netbuf *buf, void *dataptr, u16_t size)
95  {  {
# Line 101  netbuf_ref(struct netbuf *buf, void *dat Line 101  netbuf_ref(struct netbuf *buf, void *dat
101    buf->p->len = buf->p->tot_len = size;    buf->p->len = buf->p->tot_len = size;
102    buf->ptr = buf->p;    buf->ptr = buf->p;
103  }  }
104  /*-----------------------------------------------------------------------------------*/  
105  void  void
106  netbuf_chain(struct netbuf *head, struct netbuf *tail)  netbuf_chain(struct netbuf *head, struct netbuf *tail)
107  {  {
# Line 109  netbuf_chain(struct netbuf *head, struct Line 109  netbuf_chain(struct netbuf *head, struct
109    head->ptr = head->p;    head->ptr = head->p;
110    memp_free(MEMP_NETBUF, tail);    memp_free(MEMP_NETBUF, tail);
111  }  }
112  /*-----------------------------------------------------------------------------------*/  
113  u16_t  u16_t
114  netbuf_len(struct netbuf *buf)  netbuf_len(struct netbuf *buf)
115  {  {
116    return buf->p->tot_len;    return buf->p->tot_len;
117  }  }
118  /*-----------------------------------------------------------------------------------*/  
119  err_t  err_t
120  netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len)  netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len)
121  {  {
# Line 126  netbuf_data(struct netbuf *buf, void **d Line 126  netbuf_data(struct netbuf *buf, void **d
126    *len = buf->ptr->len;    *len = buf->ptr->len;
127    return ERR_OK;    return ERR_OK;
128  }  }
129  /*-----------------------------------------------------------------------------------*/  
130  s8_t  s8_t
131  netbuf_next(struct netbuf *buf)  netbuf_next(struct netbuf *buf)
132  {  {
# Line 139  netbuf_next(struct netbuf *buf) Line 139  netbuf_next(struct netbuf *buf)
139    }    }
140    return 0;    return 0;
141  }  }
142  /*-----------------------------------------------------------------------------------*/  
143  void  void
144  netbuf_first(struct netbuf *buf)  netbuf_first(struct netbuf *buf)
145  {  {
146    buf->ptr = buf->p;    buf->ptr = buf->p;
147  }  }
148  /*-----------------------------------------------------------------------------------*/  
149  void  void
150  netbuf_copy_partial(struct netbuf *buf, void *dataptr, u16_t len, u16_t offset)  netbuf_copy_partial(struct netbuf *buf, void *dataptr, u16_t len, u16_t offset)
151  {  {
# Line 174  netbuf_copy_partial(struct netbuf *buf, Line 174  netbuf_copy_partial(struct netbuf *buf,
174      }      }
175    }    }
176  }  }
177  /*-----------------------------------------------------------------------------------*/  
178  void  void
179  netbuf_copy(struct netbuf *buf, void *dataptr, u16_t len)  netbuf_copy(struct netbuf *buf, void *dataptr, u16_t len)
180  {  {
181    netbuf_copy_partial(buf, dataptr, len, 0);    netbuf_copy_partial(buf, dataptr, len, 0);
182  }  }
183  /*-----------------------------------------------------------------------------------*/  
184  struct ip_addr *  struct ip_addr *
185  netbuf_fromaddr(struct netbuf *buf)  netbuf_fromaddr(struct netbuf *buf)
186  {  {
187    return buf->fromaddr;    return buf->fromaddr;
188  }  }
189  /*-----------------------------------------------------------------------------------*/  
190  u16_t  u16_t
191  netbuf_fromport(struct netbuf *buf)  netbuf_fromport(struct netbuf *buf)
192  {  {
193    return buf->fromport;    return buf->fromport;
194  }  }
195  /*-----------------------------------------------------------------------------------*/  
196  struct  struct
197  netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u16_t proto,  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))                                     void (*callback)(struct netconn *, enum netconn_evt, u16_t len))
# Line 241  netconn *netconn_new_with_proto_and_call Line 241  netconn *netconn_new_with_proto_and_call
241    return conn;    return conn;
242  }  }
243    
244  /*-----------------------------------------------------------------------------------*/  
245  struct  struct
246  netconn *netconn_new(enum netconn_type t)  netconn *netconn_new(enum netconn_type t)
247  {  {
248    return netconn_new_with_proto_and_callback(t,0,NULL);    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))
# Line 255  netconn *netconn_new_with_callback(enum Line 255  netconn *netconn_new_with_callback(enum
255    return netconn_new_with_proto_and_callback(t,0,callback);    return netconn_new_with_proto_and_callback(t,0,callback);
256  }  }
257    
258  /*-----------------------------------------------------------------------------------*/  
259  err_t  err_t
260  netconn_delete(struct netconn *conn)  netconn_delete(struct netconn *conn)
261  {  {
# Line 309  netconn_delete(struct netconn *conn) Line 309  netconn_delete(struct netconn *conn)
309    memp_free(MEMP_NETCONN, conn);    memp_free(MEMP_NETCONN, conn);
310    return ERR_OK;    return ERR_OK;
311  }  }
312  /*-----------------------------------------------------------------------------------*/  
313  enum netconn_type  enum netconn_type
314  netconn_type(struct netconn *conn)  netconn_type(struct netconn *conn)
315  {  {
316    return conn->type;    return conn->type;
317  }  }
318  /*-----------------------------------------------------------------------------------*/  
319  err_t  err_t
320  netconn_peer(struct netconn *conn, struct ip_addr *addr,  netconn_peer(struct netconn *conn, struct ip_addr *addr,
321         u16_t *port)         u16_t *port)
# Line 342  netconn_peer(struct netconn *conn, struc Line 342  netconn_peer(struct netconn *conn, struc
342    }    }
343    return (conn->err = ERR_OK);    return (conn->err = ERR_OK);
344  }  }
345  /*-----------------------------------------------------------------------------------*/  
346  err_t  err_t
347  netconn_addr(struct netconn *conn, struct ip_addr **addr,  netconn_addr(struct netconn *conn, struct ip_addr **addr,
348         u16_t *port)         u16_t *port)
# Line 365  netconn_addr(struct netconn *conn, struc Line 365  netconn_addr(struct netconn *conn, struc
365    }    }
366    return (conn->err = ERR_OK);    return (conn->err = ERR_OK);
367  }  }
368  /*-----------------------------------------------------------------------------------*/  
369  err_t  err_t
370  netconn_bind(struct netconn *conn, struct ip_addr *addr,  netconn_bind(struct netconn *conn, struct ip_addr *addr,
371        u16_t port)        u16_t port)
# Line 396  netconn_bind(struct netconn *conn, struc Line 396  netconn_bind(struct netconn *conn, struc
396    return conn->err;    return conn->err;
397  }  }
398    
399  /*-----------------------------------------------------------------------------------*/  
400  err_t  err_t
401  netconn_connect(struct netconn *conn, struct ip_addr *addr,  netconn_connect(struct netconn *conn, struct ip_addr *addr,
402         u16_t port)         u16_t port)
# Line 447  netconn_disconnect(struct netconn *conn) Line 447  netconn_disconnect(struct netconn *conn)
447    return conn->err;    return conn->err;
448    
449  }  }
450  /*-----------------------------------------------------------------------------------*/  
451  err_t  err_t
452  netconn_listen(struct netconn *conn)  netconn_listen(struct netconn *conn)
453  {  {
# Line 474  netconn_listen(struct netconn *conn) Line 474  netconn_listen(struct netconn *conn)
474    memp_free(MEMP_API_MSG, msg);    memp_free(MEMP_API_MSG, msg);
475    return conn->err;    return conn->err;
476  }  }
477  /*-----------------------------------------------------------------------------------*/  
478  struct netconn *  struct netconn *
479  netconn_accept(struct netconn *conn)  netconn_accept(struct netconn *conn)
480  {  {
# Line 491  netconn_accept(struct netconn *conn) Line 491  netconn_accept(struct netconn *conn)
491        
492    return newconn;    return newconn;
493  }  }
494  /*-----------------------------------------------------------------------------------*/  
495  struct netbuf *  struct netbuf *
496  netconn_recv(struct netconn *conn)  netconn_recv(struct netconn *conn)
497  {  {
# Line 587  netconn_recv(struct netconn *conn) Line 587  netconn_recv(struct netconn *conn)
587    
588    return buf;    return buf;
589  }  }
590  /*-----------------------------------------------------------------------------------*/  
591  err_t  err_t
592  netconn_send(struct netconn *conn, struct netbuf *buf)  netconn_send(struct netconn *conn, struct netbuf *buf)
593  {  {
# Line 615  netconn_send(struct netconn *conn, struc Line 615  netconn_send(struct netconn *conn, struc
615    memp_free(MEMP_API_MSG, msg);    memp_free(MEMP_API_MSG, msg);
616    return conn->err;    return conn->err;
617  }  }
618  /*-----------------------------------------------------------------------------------*/  
619  err_t  err_t
620  netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)  netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)
621  {  {
# Line 691  netconn_write(struct netconn *conn, void Line 691  netconn_write(struct netconn *conn, void
691        
692    return conn->err;    return conn->err;
693  }  }
694  /*-----------------------------------------------------------------------------------*/  
695  err_t  err_t
696  netconn_close(struct netconn *conn)  netconn_close(struct netconn *conn)
697  {  {
# Line 719  netconn_close(struct netconn *conn) Line 719  netconn_close(struct netconn *conn)
719    memp_free(MEMP_API_MSG, msg);    memp_free(MEMP_API_MSG, msg);
720    return conn->err;    return conn->err;
721  }  }
722  /*-----------------------------------------------------------------------------------*/  
723  err_t  err_t
724  netconn_err(struct netconn *conn)  netconn_err(struct netconn *conn)
725  {  {
726    return conn->err;    return conn->err;
727  }  }
728  /*-----------------------------------------------------------------------------------*/  

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

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