Version of http://mbed.org/cookbook/NetServicesTribute with setting set the same for LPC2368

Dependents:   UDPSocketExample 24LCxx_I2CApp WeatherPlatform_pachube HvZServerLib ... more

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?

UserRevisionLine numberNew 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
simon 0:350011bf8be7 33 #ifndef __LWIP_PBUF_H__
simon 0:350011bf8be7 34 #define __LWIP_PBUF_H__
simon 0:350011bf8be7 35
simon 0:350011bf8be7 36 #include "lwip/opt.h"
simon 0:350011bf8be7 37 #include "lwip/err.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 /* Currently, the pbuf_custom code is only needed for one specific configuration
simon 0:350011bf8be7 44 * of IP_FRAG */
simon 0:350011bf8be7 45 #define LWIP_SUPPORT_CUSTOM_PBUF (IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF)
simon 0:350011bf8be7 46
simon 0:350011bf8be7 47 #define PBUF_TRANSPORT_HLEN 20
simon 0:350011bf8be7 48 #define PBUF_IP_HLEN 20
simon 0:350011bf8be7 49
simon 0:350011bf8be7 50 typedef enum {
simon 0:350011bf8be7 51 PBUF_TRANSPORT,
simon 0:350011bf8be7 52 PBUF_IP,
simon 0:350011bf8be7 53 PBUF_LINK,
simon 0:350011bf8be7 54 PBUF_RAW
simon 0:350011bf8be7 55 } pbuf_layer;
simon 0:350011bf8be7 56
simon 0:350011bf8be7 57 typedef enum {
simon 0:350011bf8be7 58 PBUF_RAM, /* pbuf data is stored in RAM */
simon 0:350011bf8be7 59 PBUF_ROM, /* pbuf data is stored in ROM */
simon 0:350011bf8be7 60 PBUF_REF, /* pbuf comes from the pbuf pool */
simon 0:350011bf8be7 61 PBUF_POOL /* pbuf payload refers to RAM */
simon 0:350011bf8be7 62 } pbuf_type;
simon 0:350011bf8be7 63
simon 0:350011bf8be7 64
simon 0:350011bf8be7 65 /* indicates this packet's data should be immediately passed to the application */
simon 0:350011bf8be7 66 #define PBUF_FLAG_PUSH 0x01U
simon 0:350011bf8be7 67 /* indicates this is a custom pbuf: pbuf_free and pbuf_header handle such a
simon 0:350011bf8be7 68 a pbuf differently */
simon 0:350011bf8be7 69 #define PBUF_FLAG_IS_CUSTOM 0x02U
simon 0:350011bf8be7 70 /* indicates this pbuf is UDP multicast to be looped back */
simon 0:350011bf8be7 71 #define PBUF_FLAG_MCASTLOOP 0x04U
simon 0:350011bf8be7 72
simon 0:350011bf8be7 73 struct pbuf {
simon 0:350011bf8be7 74 /* next pbuf in singly linked pbuf chain */
simon 0:350011bf8be7 75 struct pbuf *next;
simon 0:350011bf8be7 76
simon 0:350011bf8be7 77 /* pointer to the actual data in the buffer */
simon 0:350011bf8be7 78 void *payload;
simon 0:350011bf8be7 79
simon 0:350011bf8be7 80 /**
simon 0:350011bf8be7 81 * total length of this buffer and all next buffers in chain
simon 0:350011bf8be7 82 * belonging to the same packet.
simon 0:350011bf8be7 83 *
simon 0:350011bf8be7 84 * For non-queue packet chains this is the invariant:
simon 0:350011bf8be7 85 * p->tot_len == p->len + (p->next? p->next->tot_len: 0)
simon 0:350011bf8be7 86 */
simon 0:350011bf8be7 87 u16_t tot_len;
simon 0:350011bf8be7 88
simon 0:350011bf8be7 89 /* length of this buffer */
simon 0:350011bf8be7 90 u16_t len;
simon 0:350011bf8be7 91
simon 0:350011bf8be7 92 /* pbuf_type as u8_t instead of enum to save space */
simon 0:350011bf8be7 93 u8_t /*pbuf_type*/ type;
simon 0:350011bf8be7 94
simon 0:350011bf8be7 95 /* misc flags */
simon 0:350011bf8be7 96 u8_t flags;
simon 0:350011bf8be7 97
simon 0:350011bf8be7 98 /**
simon 0:350011bf8be7 99 * the reference count always equals the number of pointers
simon 0:350011bf8be7 100 * that refer to this pbuf. This can be pointers from an application,
simon 0:350011bf8be7 101 * the stack itself, or pbuf->next pointers from a chain.
simon 0:350011bf8be7 102 */
simon 0:350011bf8be7 103 u16_t ref;
simon 0:350011bf8be7 104 };
simon 0:350011bf8be7 105
simon 0:350011bf8be7 106 #if LWIP_SUPPORT_CUSTOM_PBUF
simon 0:350011bf8be7 107 /* Prototype for a function to free a custom pbuf */
simon 0:350011bf8be7 108 typedef void (*pbuf_free_custom_fn)(struct pbuf *p);
simon 0:350011bf8be7 109
simon 0:350011bf8be7 110 /* A custom pbuf: like a pbuf, but following a function pointer to free it. */
simon 0:350011bf8be7 111 struct pbuf_custom {
simon 0:350011bf8be7 112 /* The actual pbuf */
simon 0:350011bf8be7 113 struct pbuf pbuf;
simon 0:350011bf8be7 114 /* This function is called when pbuf_free deallocates this pbuf(_custom) */
simon 0:350011bf8be7 115 pbuf_free_custom_fn custom_free_function;
simon 0:350011bf8be7 116 };
simon 0:350011bf8be7 117 #endif /* LWIP_SUPPORT_CUSTOM_PBUF */
simon 0:350011bf8be7 118
simon 0:350011bf8be7 119 /* Initializes the pbuf module. This call is empty for now, but may not be in future. */
simon 0:350011bf8be7 120 #define pbuf_init()
simon 0:350011bf8be7 121
simon 0:350011bf8be7 122 struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type);
simon 0:350011bf8be7 123 #if LWIP_SUPPORT_CUSTOM_PBUF
simon 0:350011bf8be7 124 struct pbuf *pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type,
simon 0:350011bf8be7 125 struct pbuf_custom *p, void *payload_mem,
simon 0:350011bf8be7 126 u16_t payload_mem_len);
simon 0:350011bf8be7 127 #endif /* LWIP_SUPPORT_CUSTOM_PBUF */
simon 0:350011bf8be7 128 void pbuf_realloc(struct pbuf *p, u16_t size);
simon 0:350011bf8be7 129 u8_t pbuf_header(struct pbuf *p, s16_t header_size);
simon 0:350011bf8be7 130 void pbuf_ref(struct pbuf *p);
simon 0:350011bf8be7 131 u8_t pbuf_free(struct pbuf *p);
simon 0:350011bf8be7 132 u8_t pbuf_clen(struct pbuf *p);
simon 0:350011bf8be7 133 void pbuf_cat(struct pbuf *head, struct pbuf *tail);
simon 0:350011bf8be7 134 void pbuf_chain(struct pbuf *head, struct pbuf *tail);
simon 0:350011bf8be7 135 struct pbuf *pbuf_dechain(struct pbuf *p);
simon 0:350011bf8be7 136 err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from);
simon 0:350011bf8be7 137 u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset);
simon 0:350011bf8be7 138 err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len);
simon 0:350011bf8be7 139 struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer);
simon 0:350011bf8be7 140 #if LWIP_CHECKSUM_ON_COPY
simon 0:350011bf8be7 141 err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr,
simon 0:350011bf8be7 142 u16_t len, u16_t *chksum);
simon 0:350011bf8be7 143 #endif /* LWIP_CHECKSUM_ON_COPY */
simon 0:350011bf8be7 144
simon 0:350011bf8be7 145 u8_t pbuf_get_at(struct pbuf* p, u16_t offset);
simon 0:350011bf8be7 146 u16_t pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n);
simon 0:350011bf8be7 147 u16_t pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset);
simon 0:350011bf8be7 148 u16_t pbuf_strstr(struct pbuf* p, const char* substr);
simon 0:350011bf8be7 149
simon 0:350011bf8be7 150 #ifdef __cplusplus
simon 0:350011bf8be7 151 }
simon 0:350011bf8be7 152 #endif
simon 0:350011bf8be7 153
simon 0:350011bf8be7 154 #endif /* __LWIP_PBUF_H__ */