Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/include/lwip/netbuf.h need to be fixed.

0001 /*
0002  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
0003  * All rights reserved. 
0004  * 
0005  * Redistribution and use in source and binary forms, with or without modification, 
0006  * are permitted provided that the following conditions are met:
0007  *
0008  * 1. Redistributions of source code must retain the above copyright notice,
0009  *    this list of conditions and the following disclaimer.
0010  * 2. Redistributions in binary form must reproduce the above copyright notice,
0011  *    this list of conditions and the following disclaimer in the documentation
0012  *    and/or other materials provided with the distribution.
0013  * 3. The name of the author may not be used to endorse or promote products
0014  *    derived from this software without specific prior written permission. 
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
0017  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
0018  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
0019  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
0020  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
0021  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
0022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
0023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
0024  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
0025  * OF SUCH DAMAGE.
0026  *
0027  * This file is part of the lwIP TCP/IP stack.
0028  * 
0029  * Author: Adam Dunkels <adam@sics.se>
0030  *
0031  */
0032 #ifndef __LWIP_NETBUF_H__
0033 #define __LWIP_NETBUF_H__
0034 
0035 #include "lwip/opt.h"
0036 #include "lwip/pbuf.h"
0037 #include "lwip/ip_addr.h"
0038 
0039 #ifdef __cplusplus
0040 extern "C" {
0041 #endif
0042 
0043 struct netbuf {
0044   struct pbuf *p, *ptr;
0045   struct ip_addr *addr;
0046   u16_t port;
0047 #if LWIP_NETBUF_RECVINFO
0048   struct ip_addr *toaddr;
0049   u16_t toport;
0050 #endif /* LWIP_NETBUF_RECVINFO */
0051 };
0052 
0053 /* Network buffer functions: */
0054 struct netbuf *   netbuf_new      (void);
0055 void              netbuf_delete   (struct netbuf *buf);
0056 void *            netbuf_alloc    (struct netbuf *buf, u16_t size);
0057 void              netbuf_free     (struct netbuf *buf);
0058 err_t             netbuf_ref      (struct netbuf *buf,
0059            const void *dataptr, u16_t size);
0060 void              netbuf_chain    (struct netbuf *head,
0061            struct netbuf *tail);
0062 
0063 u16_t             netbuf_len      (struct netbuf *buf);
0064 err_t             netbuf_data     (struct netbuf *buf,
0065            void **dataptr, u16_t *len);
0066 s8_t              netbuf_next     (struct netbuf *buf);
0067 void              netbuf_first    (struct netbuf *buf);
0068 
0069 
0070 #define netbuf_copy_partial(buf, dataptr, len, offset) \
0071   pbuf_copy_partial((buf)->p, (dataptr), (len), (offset))
0072 #define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0)
0073 #define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len)
0074 #define netbuf_len(buf)              ((buf)->p->tot_len)
0075 #define netbuf_fromaddr(buf)         ((buf)->addr)
0076 #define netbuf_fromport(buf)         ((buf)->port)
0077 #if LWIP_NETBUF_RECVINFO
0078 #define netbuf_destaddr(buf)         ((buf)->toaddr)
0079 #define netbuf_destport(buf)         ((buf)->toport)
0080 #endif /* LWIP_NETBUF_RECVINFO */
0081 
0082 #ifdef __cplusplus
0083 }
0084 #endif
0085 
0086 #endif /* __LWIP_NETBUF_H__ */