Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Bonjour by
pbuf.h
00001 /* 00002 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without modification, 00006 * are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright notice, 00011 * this list of conditions and the following disclaimer in the documentation 00012 * and/or other materials provided with the distribution. 00013 * 3. The name of the author may not be used to endorse or promote products 00014 * derived from this software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00017 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00019 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00020 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00021 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00022 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00023 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00024 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00025 * OF SUCH DAMAGE. 00026 * 00027 * This file is part of the lwIP TCP/IP stack. 00028 * 00029 * Author: Adam Dunkels <adam@sics.se> 00030 * 00031 */ 00032 00033 #ifndef __LWIP_PBUF_H__ 00034 #define __LWIP_PBUF_H__ 00035 00036 #include "lwip/opt.h" 00037 #include "lwip/err.h" 00038 00039 #ifdef __cplusplus 00040 extern "C" { 00041 #endif 00042 00043 #define PBUF_TRANSPORT_HLEN 20 00044 #define PBUF_IP_HLEN 20 00045 00046 typedef enum { 00047 PBUF_TRANSPORT, 00048 PBUF_IP, 00049 PBUF_LINK, 00050 PBUF_RAW 00051 } pbuf_layer; 00052 00053 typedef enum { 00054 PBUF_RAM, /* pbuf data is stored in RAM */ 00055 PBUF_ROM, /* pbuf data is stored in ROM */ 00056 PBUF_REF, /* pbuf comes from the pbuf pool */ 00057 PBUF_POOL /* pbuf payload refers to RAM */ 00058 } pbuf_type; 00059 00060 00061 /** indicates this packet's data should be immediately passed to the application */ 00062 #define PBUF_FLAG_PUSH 0x01U 00063 00064 struct pbuf { 00065 /** next pbuf in singly linked pbuf chain */ 00066 struct pbuf *next; 00067 00068 /** pointer to the actual data in the buffer */ 00069 void *payload; 00070 00071 /** 00072 * total length of this buffer and all next buffers in chain 00073 * belonging to the same packet. 00074 * 00075 * For non-queue packet chains this is the invariant: 00076 * p->tot_len == p->len + (p->next? p->next->tot_len: 0) 00077 */ 00078 u16_t tot_len; 00079 00080 /** length of this buffer */ 00081 u16_t len; 00082 00083 /** pbuf_type as u8_t instead of enum to save space */ 00084 u8_t /*pbuf_type*/ type; 00085 00086 /** misc flags */ 00087 u8_t flags; 00088 00089 /** 00090 * the reference count always equals the number of pointers 00091 * that refer to this pbuf. This can be pointers from an application, 00092 * the stack itself, or pbuf->next pointers from a chain. 00093 */ 00094 u16_t ref; 00095 00096 }; 00097 00098 /* Initializes the pbuf module. This call is empty for now, but may not be in future. */ 00099 #define pbuf_init() 00100 00101 struct pbuf *pbuf_alloc(pbuf_layer l, u16_t size, pbuf_type type); 00102 void pbuf_realloc(struct pbuf *p, u16_t size); 00103 u8_t pbuf_header(struct pbuf *p, s16_t header_size); 00104 void pbuf_ref(struct pbuf *p); 00105 void pbuf_ref_chain(struct pbuf *p); 00106 u8_t pbuf_free(struct pbuf *p); 00107 u8_t pbuf_clen(struct pbuf *p); 00108 void pbuf_cat(struct pbuf *head, struct pbuf *tail); 00109 void pbuf_chain(struct pbuf *head, struct pbuf *tail); 00110 struct pbuf *pbuf_dechain(struct pbuf *p); 00111 err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from); 00112 u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset); 00113 err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len); 00114 struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer); 00115 00116 #ifdef __cplusplus 00117 } 00118 #endif 00119 00120 #endif /* __LWIP_PBUF_H__ */
Generated on Tue Jul 12 2022 18:11:30 by
