Version of http://mbed.org/cookbook/NetServicesTribute with setting set the same for LPC2368
Dependents: UDPSocketExample 24LCxx_I2CApp WeatherPlatform_pachube HvZServerLib ... more
lwip/include/lwip/netbuf.h@0:350011bf8be7, 2010-11-23 (annotated)
- Committer:
- simon
- Date:
- Tue Nov 23 14:15:36 2010 +0000
- Revision:
- 0:350011bf8be7
Experimental version for testing UDP
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:350011bf8be7 | 1 | /* |
simon | 0:350011bf8be7 | 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. |
simon | 0:350011bf8be7 | 3 | * All rights reserved. |
simon | 0:350011bf8be7 | 4 | * |
simon | 0:350011bf8be7 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
simon | 0:350011bf8be7 | 6 | * are permitted provided that the following conditions are met: |
simon | 0:350011bf8be7 | 7 | * |
simon | 0:350011bf8be7 | 8 | * 1. Redistributions of source code must retain the above copyright notice, |
simon | 0:350011bf8be7 | 9 | * this list of conditions and the following disclaimer. |
simon | 0:350011bf8be7 | 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
simon | 0:350011bf8be7 | 11 | * this list of conditions and the following disclaimer in the documentation |
simon | 0:350011bf8be7 | 12 | * and/or other materials provided with the distribution. |
simon | 0:350011bf8be7 | 13 | * 3. The name of the author may not be used to endorse or promote products |
simon | 0:350011bf8be7 | 14 | * derived from this software without specific prior written permission. |
simon | 0:350011bf8be7 | 15 | * |
simon | 0:350011bf8be7 | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
simon | 0:350011bf8be7 | 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
simon | 0:350011bf8be7 | 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
simon | 0:350011bf8be7 | 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
simon | 0:350011bf8be7 | 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
simon | 0:350011bf8be7 | 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
simon | 0:350011bf8be7 | 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
simon | 0:350011bf8be7 | 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
simon | 0:350011bf8be7 | 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
simon | 0:350011bf8be7 | 25 | * OF SUCH DAMAGE. |
simon | 0:350011bf8be7 | 26 | * |
simon | 0:350011bf8be7 | 27 | * This file is part of the lwIP TCP/IP stack. |
simon | 0:350011bf8be7 | 28 | * |
simon | 0:350011bf8be7 | 29 | * Author: Adam Dunkels <adam@sics.se> |
simon | 0:350011bf8be7 | 30 | * |
simon | 0:350011bf8be7 | 31 | */ |
simon | 0:350011bf8be7 | 32 | #ifndef __LWIP_NETBUF_H__ |
simon | 0:350011bf8be7 | 33 | #define __LWIP_NETBUF_H__ |
simon | 0:350011bf8be7 | 34 | |
simon | 0:350011bf8be7 | 35 | #include "lwip/opt.h" |
simon | 0:350011bf8be7 | 36 | #include "lwip/pbuf.h" |
simon | 0:350011bf8be7 | 37 | #include "lwip/ip_addr.h" |
simon | 0:350011bf8be7 | 38 | |
simon | 0:350011bf8be7 | 39 | #ifdef __cplusplus |
simon | 0:350011bf8be7 | 40 | extern "C" { |
simon | 0:350011bf8be7 | 41 | #endif |
simon | 0:350011bf8be7 | 42 | |
simon | 0:350011bf8be7 | 43 | /** This netbuf has dest-addr/port set */ |
simon | 0:350011bf8be7 | 44 | #define NETBUF_FLAG_DESTADDR 0x01 |
simon | 0:350011bf8be7 | 45 | /** This netbuf includes a checksum */ |
simon | 0:350011bf8be7 | 46 | #define NETBUF_FLAG_CHKSUM 0x02 |
simon | 0:350011bf8be7 | 47 | |
simon | 0:350011bf8be7 | 48 | struct netbuf { |
simon | 0:350011bf8be7 | 49 | struct pbuf *p, *ptr; |
simon | 0:350011bf8be7 | 50 | ip_addr_t addr; |
simon | 0:350011bf8be7 | 51 | u16_t port; |
simon | 0:350011bf8be7 | 52 | #if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY |
simon | 0:350011bf8be7 | 53 | #if LWIP_CHECKSUM_ON_COPY |
simon | 0:350011bf8be7 | 54 | u8_t flags; |
simon | 0:350011bf8be7 | 55 | #endif /* LWIP_CHECKSUM_ON_COPY */ |
simon | 0:350011bf8be7 | 56 | u16_t toport_chksum; |
simon | 0:350011bf8be7 | 57 | #if LWIP_NETBUF_RECVINFO |
simon | 0:350011bf8be7 | 58 | ip_addr_t toaddr; |
simon | 0:350011bf8be7 | 59 | #endif /* LWIP_NETBUF_RECVINFO */ |
simon | 0:350011bf8be7 | 60 | #endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */ |
simon | 0:350011bf8be7 | 61 | }; |
simon | 0:350011bf8be7 | 62 | |
simon | 0:350011bf8be7 | 63 | /* Network buffer functions: */ |
simon | 0:350011bf8be7 | 64 | struct netbuf * netbuf_new (void); |
simon | 0:350011bf8be7 | 65 | void netbuf_delete (struct netbuf *buf); |
simon | 0:350011bf8be7 | 66 | void * netbuf_alloc (struct netbuf *buf, u16_t size); |
simon | 0:350011bf8be7 | 67 | void netbuf_free (struct netbuf *buf); |
simon | 0:350011bf8be7 | 68 | err_t netbuf_ref (struct netbuf *buf, |
simon | 0:350011bf8be7 | 69 | const void *dataptr, u16_t size); |
simon | 0:350011bf8be7 | 70 | void netbuf_chain (struct netbuf *head, |
simon | 0:350011bf8be7 | 71 | struct netbuf *tail); |
simon | 0:350011bf8be7 | 72 | |
simon | 0:350011bf8be7 | 73 | err_t netbuf_data (struct netbuf *buf, |
simon | 0:350011bf8be7 | 74 | void **dataptr, u16_t *len); |
simon | 0:350011bf8be7 | 75 | s8_t netbuf_next (struct netbuf *buf); |
simon | 0:350011bf8be7 | 76 | void netbuf_first (struct netbuf *buf); |
simon | 0:350011bf8be7 | 77 | |
simon | 0:350011bf8be7 | 78 | |
simon | 0:350011bf8be7 | 79 | #define netbuf_copy_partial(buf, dataptr, len, offset) \ |
simon | 0:350011bf8be7 | 80 | pbuf_copy_partial((buf)->p, (dataptr), (len), (offset)) |
simon | 0:350011bf8be7 | 81 | #define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0) |
simon | 0:350011bf8be7 | 82 | #define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len) |
simon | 0:350011bf8be7 | 83 | #define netbuf_len(buf) ((buf)->p->tot_len) |
simon | 0:350011bf8be7 | 84 | #define netbuf_fromaddr(buf) (&((buf)->addr)) |
simon | 0:350011bf8be7 | 85 | #define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set((&(buf)->addr), fromaddr) |
simon | 0:350011bf8be7 | 86 | #define netbuf_fromport(buf) ((buf)->port) |
simon | 0:350011bf8be7 | 87 | #if LWIP_NETBUF_RECVINFO |
simon | 0:350011bf8be7 | 88 | #define netbuf_destaddr(buf) (&((buf)->toaddr)) |
simon | 0:350011bf8be7 | 89 | #define netbuf_set_destaddr(buf, destaddr) ip_addr_set((&(buf)->addr), destaddr) |
simon | 0:350011bf8be7 | 90 | #define netbuf_destport(buf) (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0) |
simon | 0:350011bf8be7 | 91 | #endif /* LWIP_NETBUF_RECVINFO */ |
simon | 0:350011bf8be7 | 92 | #if LWIP_CHECKSUM_ON_COPY |
simon | 0:350011bf8be7 | 93 | #define netbuf_set_chksum(buf, chksum) do { (buf)->flags = NETBUF_FLAG_CHKSUM; \ |
simon | 0:350011bf8be7 | 94 | (buf)->toport_chksum = chksum; } while(0) |
simon | 0:350011bf8be7 | 95 | #endif /* LWIP_CHECKSUM_ON_COPY */ |
simon | 0:350011bf8be7 | 96 | |
simon | 0:350011bf8be7 | 97 | #ifdef __cplusplus |
simon | 0:350011bf8be7 | 98 | } |
simon | 0:350011bf8be7 | 99 | #endif |
simon | 0:350011bf8be7 | 100 | |
simon | 0:350011bf8be7 | 101 | #endif /* __LWIP_NETBUF_H__ */ |