Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 29c369053a983cc5d8c880dc6e0a2237 > files > 572

libdtn-devel-2.6.0-2mdv2009.1.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>DTN Reference Implementation: SDNV.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>SDNV.h</h1><a href="SDNV_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> *    Copyright 2005-2006 Intel Corporation</span>
<a name="l00003"></a>00003 <span class="comment"> * </span>
<a name="l00004"></a>00004 <span class="comment"> *    Licensed under the Apache License, Version 2.0 (the "License");</span>
<a name="l00005"></a>00005 <span class="comment"> *    you may not use this file except in compliance with the License.</span>
<a name="l00006"></a>00006 <span class="comment"> *    You may obtain a copy of the License at</span>
<a name="l00007"></a>00007 <span class="comment"> * </span>
<a name="l00008"></a>00008 <span class="comment"> *        http://www.apache.org/licenses/LICENSE-2.0</span>
<a name="l00009"></a>00009 <span class="comment"> * </span>
<a name="l00010"></a>00010 <span class="comment"> *    Unless required by applicable law or agreed to in writing, software</span>
<a name="l00011"></a>00011 <span class="comment"> *    distributed under the License is distributed on an "AS IS" BASIS,</span>
<a name="l00012"></a>00012 <span class="comment"> *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<a name="l00013"></a>00013 <span class="comment"> *    See the License for the specific language governing permissions and</span>
<a name="l00014"></a>00014 <span class="comment"> *    limitations under the License.</span>
<a name="l00015"></a>00015 <span class="comment"> */</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#ifndef _SDNV_H_</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define _SDNV_H_</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;oasys/compat/inttypes.h&gt;</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span>
<a name="l00024"></a>00024 <span class="keyword">namespace </span>dtn {
<a name="l00025"></a>00025 
<a name="l00043"></a>00043 <span class="keyword">class </span>SDNV {
<a name="l00044"></a>00044 <span class="keyword">public</span>:
<a name="l00049"></a>00049     <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">size_t</span> <a class="code" href="SDNV_8cc.html#7a9a231e30b47bc0345749c8bd1e5077">MAX_LENGTH</a> = 10;
<a name="l00050"></a>00050     
<a name="l00054"></a>00054     <span class="keyword">static</span> <span class="keywordtype">size_t</span> <a class="code" href="SDNV_8cc.html#46f4c114c92230c80f6714318251b542">encoding_len</a>(u_int64_t <a class="code" href="num2sdnv_8c.html#455b3605dc605fe8e055b9c1470535cf">val</a>);
<a name="l00055"></a>00055     
<a name="l00061"></a>00061     <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="SDNV_8cc.html#21c54ef3a5345647ad1cada265a03eb4">encode</a>(u_int64_t <a class="code" href="num2sdnv_8c.html#455b3605dc605fe8e055b9c1470535cf">val</a>, u_char* bp, <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>);
<a name="l00062"></a>00062     
<a name="l00069"></a>00069     <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="SDNV_8cc.html#151d178617a7c2f598cfd7630ebeb7b4">decode</a>(<span class="keyword">const</span> u_char* bp, <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>, u_int64_t* <a class="code" href="num2sdnv_8c.html#455b3605dc605fe8e055b9c1470535cf">val</a>);
<a name="l00070"></a>00070 
<a name="l00077"></a>00077     <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="SDNV_8cc.html#151d178617a7c2f598cfd7630ebeb7b4">decode</a>(<span class="keyword">const</span> u_char* bp, <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>, u_int32_t* <a class="code" href="num2sdnv_8c.html#455b3605dc605fe8e055b9c1470535cf">val</a>)
<a name="l00078"></a>00078     {
<a name="l00079"></a>00079         u_int64_t lval;
<a name="l00080"></a>00080         <span class="keywordtype">int</span> ret = <a class="code" href="SDNV_8cc.html#151d178617a7c2f598cfd7630ebeb7b4">decode</a>(bp, len, &amp;lval);
<a name="l00081"></a>00081         
<a name="l00082"></a>00082         <span class="keywordflow">if</span> (lval &gt; 0xffffffffLL) {
<a name="l00083"></a>00083             <span class="keywordflow">return</span> -1;
<a name="l00084"></a>00084         }
<a name="l00085"></a>00085 
<a name="l00086"></a>00086         *val = (u_int32_t)lval;
<a name="l00087"></a>00087         
<a name="l00088"></a>00088         <span class="keywordflow">return</span> ret;
<a name="l00089"></a>00089     }
<a name="l00090"></a>00090 
<a name="l00098"></a>00098     <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="SDNV_8cc.html#21c54ef3a5345647ad1cada265a03eb4">encode</a>(u_int64_t val, <span class="keywordtype">char</span>* bp, <span class="keywordtype">size_t</span> len)
<a name="l00099"></a>00099     {
<a name="l00100"></a>00100         <span class="keywordflow">return</span> <a class="code" href="SDNV_8cc.html#21c54ef3a5345647ad1cada265a03eb4">encode</a>(val, (u_char*)bp, len);
<a name="l00101"></a>00101     }
<a name="l00102"></a>00102     
<a name="l00103"></a>00103     <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="SDNV_8cc.html#151d178617a7c2f598cfd7630ebeb7b4">decode</a>(<span class="keywordtype">char</span>* bp, <span class="keywordtype">size_t</span> len, u_int64_t* val)
<a name="l00104"></a>00104     {
<a name="l00105"></a>00105         <span class="keywordflow">return</span> <a class="code" href="SDNV_8cc.html#151d178617a7c2f598cfd7630ebeb7b4">decode</a>((u_char*)bp, len, val);
<a name="l00106"></a>00106     }
<a name="l00107"></a>00107     
<a name="l00108"></a>00108     <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="SDNV_8cc.html#151d178617a7c2f598cfd7630ebeb7b4">decode</a>(<span class="keywordtype">char</span>* bp, <span class="keywordtype">size_t</span> len, u_int32_t* val)
<a name="l00109"></a>00109     {
<a name="l00110"></a>00110         <span class="keywordflow">return</span> <a class="code" href="SDNV_8cc.html#151d178617a7c2f598cfd7630ebeb7b4">decode</a>((u_char*)bp, len, val);
<a name="l00111"></a>00111     }
<a name="l00113"></a>00113 
<a name="l00118"></a>00118     <span class="keyword">static</span> <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>(<span class="keyword">const</span> u_char* bp);
<a name="l00119"></a>00119 };
<a name="l00120"></a>00120 
<a name="l00121"></a>00121 } <span class="comment">// namespace dtn</span>
<a name="l00122"></a>00122 
<a name="l00123"></a>00123 <span class="preprocessor">#endif </span><span class="comment">/* __cplusplus */</span>
<a name="l00124"></a>00124 
<a name="l00125"></a>00125 <span class="preprocessor">#endif </span><span class="comment">/* _SDNV_H_ */</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:58 2009 for DTN Reference Implementation by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>