Example self-announcing webserver which controls a servo through a smallHTML userinterface.

Dependencies:   mbed

Committer:
dirkx
Date:
Sat Aug 14 15:56:01 2010 +0000
Revision:
0:a259777c45a3

        

Who changed what in which revision?

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