A version of LWIP, provided for backwards compatibility.

Dependents:   AA_DemoBoard DemoBoard HelloServerDemo DemoBoard_RangeIndicator ... more

Committer:
root@mbed.org
Date:
Tue May 08 15:32:10 2012 +0100
Revision:
0:5e1631496985
initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
root@mbed.org 0:5e1631496985 1 /*
root@mbed.org 0:5e1631496985 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
root@mbed.org 0:5e1631496985 3 * All rights reserved.
root@mbed.org 0:5e1631496985 4 *
root@mbed.org 0:5e1631496985 5 * Redistribution and use in source and binary forms, with or without modification,
root@mbed.org 0:5e1631496985 6 * are permitted provided that the following conditions are met:
root@mbed.org 0:5e1631496985 7 *
root@mbed.org 0:5e1631496985 8 * 1. Redistributions of source code must retain the above copyright notice,
root@mbed.org 0:5e1631496985 9 * this list of conditions and the following disclaimer.
root@mbed.org 0:5e1631496985 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
root@mbed.org 0:5e1631496985 11 * this list of conditions and the following disclaimer in the documentation
root@mbed.org 0:5e1631496985 12 * and/or other materials provided with the distribution.
root@mbed.org 0:5e1631496985 13 * 3. The name of the author may not be used to endorse or promote products
root@mbed.org 0:5e1631496985 14 * derived from this software without specific prior written permission.
root@mbed.org 0:5e1631496985 15 *
root@mbed.org 0:5e1631496985 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
root@mbed.org 0:5e1631496985 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
root@mbed.org 0:5e1631496985 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
root@mbed.org 0:5e1631496985 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
root@mbed.org 0:5e1631496985 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
root@mbed.org 0:5e1631496985 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
root@mbed.org 0:5e1631496985 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
root@mbed.org 0:5e1631496985 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
root@mbed.org 0:5e1631496985 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
root@mbed.org 0:5e1631496985 25 * OF SUCH DAMAGE.
root@mbed.org 0:5e1631496985 26 *
root@mbed.org 0:5e1631496985 27 * This file is part of the lwIP TCP/IP stack.
root@mbed.org 0:5e1631496985 28 *
root@mbed.org 0:5e1631496985 29 * Author: Adam Dunkels <adam@sics.se>
root@mbed.org 0:5e1631496985 30 *
root@mbed.org 0:5e1631496985 31 */
root@mbed.org 0:5e1631496985 32
root@mbed.org 0:5e1631496985 33 #ifndef __LWIP_PBUF_H__
root@mbed.org 0:5e1631496985 34 #define __LWIP_PBUF_H__
root@mbed.org 0:5e1631496985 35
root@mbed.org 0:5e1631496985 36 #include "lwip/opt.h"
root@mbed.org 0:5e1631496985 37 #include "lwip/err.h"
root@mbed.org 0:5e1631496985 38
root@mbed.org 0:5e1631496985 39 #ifdef __cplusplus
root@mbed.org 0:5e1631496985 40 extern "C" {
root@mbed.org 0:5e1631496985 41 #endif
root@mbed.org 0:5e1631496985 42
root@mbed.org 0:5e1631496985 43 #define PBUF_TRANSPORT_HLEN 20
root@mbed.org 0:5e1631496985 44 #define PBUF_IP_HLEN 20
root@mbed.org 0:5e1631496985 45
root@mbed.org 0:5e1631496985 46 typedef enum {
root@mbed.org 0:5e1631496985 47 PBUF_TRANSPORT,
root@mbed.org 0:5e1631496985 48 PBUF_IP,
root@mbed.org 0:5e1631496985 49 PBUF_LINK,
root@mbed.org 0:5e1631496985 50 PBUF_RAW
root@mbed.org 0:5e1631496985 51 } pbuf_layer;
root@mbed.org 0:5e1631496985 52
root@mbed.org 0:5e1631496985 53 typedef enum {
root@mbed.org 0:5e1631496985 54 PBUF_RAM, /* pbuf data is stored in RAM */
root@mbed.org 0:5e1631496985 55 PBUF_ROM, /* pbuf data is stored in ROM */
root@mbed.org 0:5e1631496985 56 PBUF_REF, /* pbuf comes from the pbuf pool */
root@mbed.org 0:5e1631496985 57 PBUF_POOL /* pbuf payload refers to RAM */
root@mbed.org 0:5e1631496985 58 } pbuf_type;
root@mbed.org 0:5e1631496985 59
root@mbed.org 0:5e1631496985 60
root@mbed.org 0:5e1631496985 61 /** indicates this packet's data should be immediately passed to the application */
root@mbed.org 0:5e1631496985 62 #define PBUF_FLAG_PUSH 0x01U
root@mbed.org 0:5e1631496985 63
root@mbed.org 0:5e1631496985 64 struct pbuf {
root@mbed.org 0:5e1631496985 65 /** next pbuf in singly linked pbuf chain */
root@mbed.org 0:5e1631496985 66 struct pbuf *next;
root@mbed.org 0:5e1631496985 67
root@mbed.org 0:5e1631496985 68 /** pointer to the actual data in the buffer */
root@mbed.org 0:5e1631496985 69 void *payload;
root@mbed.org 0:5e1631496985 70
root@mbed.org 0:5e1631496985 71 /**
root@mbed.org 0:5e1631496985 72 * total length of this buffer and all next buffers in chain
root@mbed.org 0:5e1631496985 73 * belonging to the same packet.
root@mbed.org 0:5e1631496985 74 *
root@mbed.org 0:5e1631496985 75 * For non-queue packet chains this is the invariant:
root@mbed.org 0:5e1631496985 76 * p->tot_len == p->len + (p->next? p->next->tot_len: 0)
root@mbed.org 0:5e1631496985 77 */
root@mbed.org 0:5e1631496985 78 u16_t tot_len;
root@mbed.org 0:5e1631496985 79
root@mbed.org 0:5e1631496985 80 /** length of this buffer */
root@mbed.org 0:5e1631496985 81 u16_t len;
root@mbed.org 0:5e1631496985 82
root@mbed.org 0:5e1631496985 83 /** pbuf_type as u8_t instead of enum to save space */
root@mbed.org 0:5e1631496985 84 u8_t /*pbuf_type*/ type;
root@mbed.org 0:5e1631496985 85
root@mbed.org 0:5e1631496985 86 /** misc flags */
root@mbed.org 0:5e1631496985 87 u8_t flags;
root@mbed.org 0:5e1631496985 88
root@mbed.org 0:5e1631496985 89 /**
root@mbed.org 0:5e1631496985 90 * the reference count always equals the number of pointers
root@mbed.org 0:5e1631496985 91 * that refer to this pbuf. This can be pointers from an application,
root@mbed.org 0:5e1631496985 92 * the stack itself, or pbuf->next pointers from a chain.
root@mbed.org 0:5e1631496985 93 */
root@mbed.org 0:5e1631496985 94 u16_t ref;
root@mbed.org 0:5e1631496985 95
root@mbed.org 0:5e1631496985 96 };
root@mbed.org 0:5e1631496985 97
root@mbed.org 0:5e1631496985 98 /* Initializes the pbuf module. This call is empty for now, but may not be in future. */
root@mbed.org 0:5e1631496985 99 #define pbuf_init()
root@mbed.org 0:5e1631496985 100
root@mbed.org 0:5e1631496985 101 struct pbuf *pbuf_alloc(pbuf_layer l, u16_t size, pbuf_type type);
root@mbed.org 0:5e1631496985 102 void pbuf_realloc(struct pbuf *p, u16_t size);
root@mbed.org 0:5e1631496985 103 u8_t pbuf_header(struct pbuf *p, s16_t header_size);
root@mbed.org 0:5e1631496985 104 void pbuf_ref(struct pbuf *p);
root@mbed.org 0:5e1631496985 105 void pbuf_ref_chain(struct pbuf *p);
root@mbed.org 0:5e1631496985 106 u8_t pbuf_free(struct pbuf *p);
root@mbed.org 0:5e1631496985 107 u8_t pbuf_clen(struct pbuf *p);
root@mbed.org 0:5e1631496985 108 void pbuf_cat(struct pbuf *head, struct pbuf *tail);
root@mbed.org 0:5e1631496985 109 void pbuf_chain(struct pbuf *head, struct pbuf *tail);
root@mbed.org 0:5e1631496985 110 struct pbuf *pbuf_dechain(struct pbuf *p);
root@mbed.org 0:5e1631496985 111 err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from);
root@mbed.org 0:5e1631496985 112 u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset);
root@mbed.org 0:5e1631496985 113 err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len);
root@mbed.org 0:5e1631496985 114 struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer);
root@mbed.org 0:5e1631496985 115
root@mbed.org 0:5e1631496985 116 #ifdef __cplusplus
root@mbed.org 0:5e1631496985 117 }
root@mbed.org 0:5e1631496985 118 #endif
root@mbed.org 0:5e1631496985 119
root@mbed.org 0:5e1631496985 120 #endif /* __LWIP_PBUF_H__ */