Newer
Older
ubixos-pre / doc / doxygen / html / pbuf_8h-source.html
@reddawg reddawg on 18 Jun 2004 10 KB UbixOS PreRelease
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Ubixos: pbuf.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.3 -->
<h1>pbuf.h</h1><div class="fragment"><pre>00001 <span class="comment">/*</span>
00002 <span class="comment"> * Copyright (c) 2001, Swedish Institute of Computer Science.</span>
00003 <span class="comment"> * All rights reserved. </span>
00004 <span class="comment"> *</span>
00005 <span class="comment"> * Redistribution and use in source and binary forms, with or without </span>
00006 <span class="comment"> * modification, are permitted provided that the following conditions </span>
00007 <span class="comment"> * are met: </span>
00008 <span class="comment"> * 1. Redistributions of source code must retain the above copyright </span>
00009 <span class="comment"> *    notice, this list of conditions and the following disclaimer. </span>
00010 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright </span>
00011 <span class="comment"> *    notice, this list of conditions and the following disclaimer in the </span>
00012 <span class="comment"> *    documentation and/or other materials provided with the distribution. </span>
00013 <span class="comment"> * 3. Neither the name of the Institute nor the names of its contributors </span>
00014 <span class="comment"> *    may be used to endorse or promote products derived from this software </span>
00015 <span class="comment"> *    without specific prior written permission. </span>
00016 <span class="comment"> *</span>
00017 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND </span>
00018 <span class="comment"> * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE </span>
00019 <span class="comment"> * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE </span>
00020 <span class="comment"> * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE </span>
00021 <span class="comment"> * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL </span>
00022 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS </span>
00023 <span class="comment"> * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) </span>
00024 <span class="comment"> * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT </span>
00025 <span class="comment"> * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY </span>
00026 <span class="comment"> * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF </span>
00027 <span class="comment"> * SUCH DAMAGE. </span>
00028 <span class="comment"> *</span>
00029 <span class="comment"> * This file is part of the lwIP TCP/IP stack.</span>
00030 <span class="comment"> * </span>
00031 <span class="comment"> * Author: Adam Dunkels &lt;adam@sics.se&gt;</span>
00032 <span class="comment"> *</span>
00033 <span class="comment"> * $Id$</span>
00034 <span class="comment"> */</span>
00035 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
00036 <span class="preprocessor">#ifndef __LWIP_PBUF_H__</span>
00037 <span class="preprocessor"></span><span class="preprocessor">#define __LWIP_PBUF_H__</span>
00038 <span class="preprocessor"></span>
00039 <span class="preprocessor">#include "net/debug.h"</span>
00040 <span class="preprocessor">#include "net/arch.h"</span>
00041 
00042 
00043 <span class="preprocessor">#define PBUF_TRANSPORT_HLEN 20</span>
00044 <span class="preprocessor"></span><span class="preprocessor">#define PBUF_IP_HLEN        20</span>
00045 <span class="preprocessor"></span>
00046 <span class="keyword">typedef</span> <span class="keyword">enum</span> {
00047   PBUF_TRANSPORT,
00048   PBUF_IP,
00049   PBUF_LINK,
00050   PBUF_RAW
00051 } pbuf_layer;
00052 
00053 <span class="keyword">typedef</span> <span class="keyword">enum</span> {
00054   PBUF_RAM,
00055   PBUF_ROM,
00056   PBUF_POOL
00057 } pbuf_flag;
00058 
00059 <span class="comment">/* Definitions for the pbuf flag field (these are not the flags that</span>
00060 <span class="comment">   are passed to pbuf_alloc()). */</span>
00061 <span class="preprocessor">#define PBUF_FLAG_RAM   0x00    </span><span class="comment">/* Flags that pbuf data is stored in RAM. */</span>
00062 <span class="preprocessor">#define PBUF_FLAG_ROM   0x01    </span><span class="comment">/* Flags that pbuf data is stored in ROM. */</span>
00063 <span class="preprocessor">#define PBUF_FLAG_POOL  0x02    </span><span class="comment">/* Flags that the pbuf comes from the</span>
00064 <span class="comment">                                   pbuf pool. */</span>
00065 
00066 <span class="keyword">struct </span>pbuf {
00067   <span class="keyword">struct </span>pbuf *next;
00068   
00069   <span class="comment">/* high 4 bits, flags, low 4 bits reference count */</span>
00070   uInt8 flags, ref;
00071   <span class="keywordtype">void</span> *payload;
00072   
00073   <span class="comment">/* Total length of buffer + additionally chained buffers. */</span>
00074   uInt16 tot_len;
00075   <span class="comment">/* Length of this buffer. */</span>
00076   uInt16 len;  
00077   
00078 };
00079 
00080 <span class="comment">/* pbuf_init():</span>
00081 <span class="comment"></span>
00082 <span class="comment">   Initializes the pbuf module. The num parameter determines how many</span>
00083 <span class="comment">   pbufs that should be allocated to the pbuf pool, and the size</span>
00084 <span class="comment">   parameter specifies the size of the data allocated to those.  */</span>
00085 <span class="keywordtype">void</span> pbuf_init(<span class="keywordtype">void</span>);
00086 
00087 <span class="comment">/* pbuf_alloc():</span>
00088 <span class="comment">   </span>
00089 <span class="comment">   Allocates a pbuf at protocol layer l. The actual memory allocated</span>
00090 <span class="comment">   for the pbuf is determined by the layer at which the pbuf is</span>
00091 <span class="comment">   allocated and the requested size (from the size parameter). The</span>
00092 <span class="comment">   flag parameter decides how and where the pbuf should be allocated</span>
00093 <span class="comment">   as follows:</span>
00094 <span class="comment"> </span>
00095 <span class="comment">   * PBUF_RAM: buffer memory for pbuf is allocated as one large</span>
00096 <span class="comment">               chunk. This includesprotocol headers as well.</span>
00097 <span class="comment">   </span>
00098 <span class="comment">   * RBUF_ROM: no buffer memory is allocated for the pbuf, even for</span>
00099 <span class="comment">                protocol headers.  Additional headers must be</span>
00100 <span class="comment">                prepended by allocating another pbuf and chain in to</span>
00101 <span class="comment">                the front of the ROM pbuf.</span>
00102 <span class="comment"></span>
00103 <span class="comment">   * PBUF_ROOL: the pbuf is allocated as a pbuf chain, with pbufs from</span>
00104 <span class="comment">                the pbuf pool that is allocated during pbuf_init().  */</span>
00105 <span class="keyword">struct </span>pbuf *pbuf_alloc(pbuf_layer l, uInt16 size, pbuf_flag flag);
00106 
00107 <span class="comment">/* pbuf_realloc():</span>
00108 <span class="comment"></span>
00109 <span class="comment">   Shrinks the pbuf to the size given by the size parameter. </span>
00110 <span class="comment"> */</span>
00111 <span class="keywordtype">void</span> pbuf_realloc(<span class="keyword">struct</span> pbuf *p, uInt16 size); 
00112 
00113 <span class="comment">/* pbuf_header():</span>
00114 <span class="comment"></span>
00115 <span class="comment">   Tries to move the p-&gt;payload pointer header_size number of bytes</span>
00116 <span class="comment">   upward within the pbuf. The return value is non-zero if it</span>
00117 <span class="comment">   fails. If so, an additional pbuf should be allocated for the header</span>
00118 <span class="comment">   and it should be chained to the front. */</span>
00119 uInt8 pbuf_header(<span class="keyword">struct</span> pbuf *p, Int16 header_size);
00120 
00121 <span class="comment">/* pbuf_ref():</span>
00122 <span class="comment"></span>
00123 <span class="comment">   Increments the reference count of the pbuf p.</span>
00124 <span class="comment"> */</span>
00125 <span class="keywordtype">void</span> pbuf_ref(<span class="keyword">struct</span> pbuf *p);
00126 
00127 <span class="comment">/* pbuf_free():</span>
00128 <span class="comment"></span>
00129 <span class="comment">   Decrements the reference count and deallocates the pbuf if the</span>
00130 <span class="comment">   reference count is zero. If the pbuf is a chain all pbufs in the</span>
00131 <span class="comment">   chain are deallocated.  */</span>
00132 uInt8 pbuf_free(<span class="keyword">struct</span> pbuf *p);
00133 
00134 <span class="comment">/* pbuf_clen():</span>
00135 <span class="comment"></span>
00136 <span class="comment">   Returns the length of the pbuf chain. */</span>
00137 uInt8 pbuf_clen(<span class="keyword">struct</span> pbuf *p);  
00138 
00139 <span class="comment">/* pbuf_chain():</span>
00140 <span class="comment"></span>
00141 <span class="comment">   Chains pbuf t on the end of pbuf h. Pbuf h will have it's tot_len</span>
00142 <span class="comment">   field adjusted accordingly. Pbuf t should no be used any more after</span>
00143 <span class="comment">   a call to this function, since pbuf t is now a part of pbuf h.  */</span>
00144 <span class="keywordtype">void</span> pbuf_chain(<span class="keyword">struct</span> pbuf *h, <span class="keyword">struct</span> pbuf *t);
00145 
00146 <span class="comment">/* pbuf_dechain():</span>
00147 <span class="comment"></span>
00148 <span class="comment">   Picks off the first pbuf from the pbuf chain p. Returns the tail of</span>
00149 <span class="comment">   the pbuf chain or NULL if the pbuf p was not chained. */</span>
00150 <span class="keyword">struct </span>pbuf *pbuf_dechain(<span class="keyword">struct</span> pbuf *p);
00151 
00152 <span class="preprocessor">#endif </span><span class="comment">/* __LWIP_PBUF_H__ */</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Wed Apr 28 17:49:39 2004 for Ubixos by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
</a>1.3.3 </small></address>
</body>
</html>