Embedded WebSockets Experiment

Dependencies:   mbed MD5

Committer:
nandgate
Date:
Tue Jul 26 05:30:53 2011 +0000
Revision:
0:6dee052a3fa4

        

Who changed what in which revision?

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