Annotation of embedaddon/libnet/doc/html/libnet-asn1_8h-source.html, revision 1.1.1.1

1.1       misho       1: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
                      2: <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
                      3: <title>libnet: libnet-asn1.h Source File</title>
                      4: <link href="doxygen.css" rel="stylesheet" type="text/css">
                      5: </head><body>
                      6: <!-- Generated by Doxygen 1.3.4 -->
                      7: <div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
                      8: <h1>libnet-asn1.h</h1><div class="fragment"><pre>00001 <span class="comment">/*</span>
                      9: 00002 <span class="comment"> *  $Id: libnet-asn1.h,v 1.3 2004/01/17 07:51:19 mike Exp $</span>
                     10: 00003 <span class="comment"> *</span>
                     11: 00004 <span class="comment"> *  libnet-asn1.h - Network routine library ASN.1 header file</span>
                     12: 00005 <span class="comment"> *</span>
                     13: 00006 <span class="comment"> *  Copyright (c) 1998 - 2004 Mike D. Schiffman &lt;mike@infonexus.com&gt;</span>
                     14: 00007 <span class="comment"> *  All rights reserved.</span>
                     15: 00008 <span class="comment"> *</span>
                     16: 00009 <span class="comment"> *  Definitions for Abstract Syntax Notation One, ASN.1</span>
                     17: 00010 <span class="comment"> *  As defined in ISO/IS 8824 and ISO/IS 8825</span>
                     18: 00011 <span class="comment"> *</span>
                     19: 00012 <span class="comment"> *  Copyright 1988, 1989 by Carnegie Mellon University</span>
                     20: 00013 <span class="comment"> *  All rights reserved.</span>
                     21: 00014 <span class="comment"> *</span>
                     22: 00015 <span class="comment"> *  Permission to use, copy, modify, and distribute this software and its</span>
                     23: 00016 <span class="comment"> *  documentation for any purpose and without fee is hereby granted,</span>
                     24: 00017 <span class="comment"> *  provided that the above copyright notice appear in all copies and that</span>
                     25: 00018 <span class="comment"> *  both that copyright notice and this permission notice appear in</span>
                     26: 00019 <span class="comment"> *  supporting documentation, and that the name of CMU not be</span>
                     27: 00020 <span class="comment"> *  used in advertising or publicity pertaining to distribution of the</span>
                     28: 00021 <span class="comment"> *  software without specific, written prior permission.</span>
                     29: 00022 <span class="comment"> *</span>
                     30: 00023 <span class="comment"> *  CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING</span>
                     31: 00024 <span class="comment"> *  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL</span>
                     32: 00025 <span class="comment"> *  CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR</span>
                     33: 00026 <span class="comment"> *  ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,</span>
                     34: 00027 <span class="comment"> *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,</span>
                     35: 00028 <span class="comment"> *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS</span>
                     36: 00029 <span class="comment"> *  SOFTWARE.</span>
                     37: 00030 <span class="comment"> *</span>
                     38: 00031 <span class="comment"> *  Copyright (c) 1998 - 2001 Mike D. Schiffman &lt;mike@infonexus.com&gt;</span>
                     39: 00032 <span class="comment"> *  All rights reserved.</span>
                     40: 00033 <span class="comment"> *</span>
                     41: 00034 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
                     42: 00035 <span class="comment"> * modification, are permitted provided that the following conditions</span>
                     43: 00036 <span class="comment"> * are met:</span>
                     44: 00037 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span>
                     45: 00038 <span class="comment"> *    notice, this list of conditions and the following disclaimer.</span>
                     46: 00039 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright</span>
                     47: 00040 <span class="comment"> *    notice, this list of conditions and the following disclaimer in the</span>
                     48: 00041 <span class="comment"> *    documentation and/or other materials provided with the distribution.</span>
                     49: 00042 <span class="comment"> *</span>
                     50: 00043 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND</span>
                     51: 00044 <span class="comment"> * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE</span>
                     52: 00045 <span class="comment"> * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
                     53: 00046 <span class="comment"> * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE</span>
                     54: 00047 <span class="comment"> * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span>
                     55: 00048 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS</span>
                     56: 00049 <span class="comment"> * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)</span>
                     57: 00050 <span class="comment"> * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT</span>
                     58: 00051 <span class="comment"> * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY</span>
                     59: 00052 <span class="comment"> * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</span>
                     60: 00053 <span class="comment"> * SUCH DAMAGE.</span>
                     61: 00054 <span class="comment"> */</span>
                     62: 00055 
                     63: 00056 <span class="preprocessor">#ifndef __LIBNET_ASN1_H</span>
                     64: 00057 <span class="preprocessor"></span><span class="preprocessor">#define __LIBNET_ASN1_H</span>
                     65: 00058 <span class="preprocessor"></span>
                     66: 00059 <span class="preprocessor">#ifndef EIGHTBIT_SUBIDS</span>
                     67: 00060 <span class="preprocessor"></span><span class="keyword">typedef</span> u_int32_t  oid;
                     68: 00061 <span class="preprocessor">#define MAX_SUBID   0xFFFFFFFF</span>
                     69: 00062 <span class="preprocessor"></span><span class="preprocessor">#else</span>
                     70: 00063 <span class="preprocessor"></span><span class="keyword">typedef</span> u_int8_t  oid;
                     71: 00064 <span class="preprocessor">#define MAX_SUBID   0xFF</span>
                     72: 00065 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
                     73: 00066 <span class="preprocessor"></span>
                     74: 00067 <span class="preprocessor">#define MAX_OID_LEN         64  </span><span class="comment">/* max subid's in an oid */</span>
                     75: 00068 
                     76: 00069 <span class="preprocessor">#define ASN_BOOLEAN         (0x01)</span>
                     77: 00070 <span class="preprocessor"></span><span class="preprocessor">#define ASN_INTEGER         (0x02)</span>
                     78: 00071 <span class="preprocessor"></span><span class="preprocessor">#define ASN_BIT_STR         (0x03)</span>
                     79: 00072 <span class="preprocessor"></span><span class="preprocessor">#define ASN_OCTET_STR       (0x04)</span>
                     80: 00073 <span class="preprocessor"></span><span class="preprocessor">#define ASN_NULL            (0x05)</span>
                     81: 00074 <span class="preprocessor"></span><span class="preprocessor">#define ASN_OBJECT_ID       (0x06)</span>
                     82: 00075 <span class="preprocessor"></span><span class="preprocessor">#define ASN_SEQUENCE        (0x10)</span>
                     83: 00076 <span class="preprocessor"></span><span class="preprocessor">#define ASN_SET             (0x11)</span>
                     84: 00077 <span class="preprocessor"></span>
                     85: 00078 <span class="preprocessor">#define ASN_UNIVERSAL       (0x00)</span>
                     86: 00079 <span class="preprocessor"></span><span class="preprocessor">#define ASN_APPLICATION     (0x40)</span>
                     87: 00080 <span class="preprocessor"></span><span class="preprocessor">#define ASN_CONTEXT         (0x80)</span>
                     88: 00081 <span class="preprocessor"></span><span class="preprocessor">#define ASN_PRIVATE         (0xC0)</span>
                     89: 00082 <span class="preprocessor"></span>
                     90: 00083 <span class="preprocessor">#define ASN_PRIMITIVE       (0x00)</span>
                     91: 00084 <span class="preprocessor"></span><span class="preprocessor">#define ASN_CONSTRUCTOR     (0x20)</span>
                     92: 00085 <span class="preprocessor"></span>
                     93: 00086 <span class="preprocessor">#define ASN_LONG_LEN        (0x80)</span>
                     94: 00087 <span class="preprocessor"></span><span class="preprocessor">#define ASN_EXTENSION_ID    (0x1F)</span>
                     95: 00088 <span class="preprocessor"></span><span class="preprocessor">#define ASN_BIT8            (0x80)</span>
                     96: 00089 <span class="preprocessor"></span>
                     97: 00090 <span class="preprocessor">#define IS_CONSTRUCTOR(byte)  ((byte) &amp; ASN_CONSTRUCTOR)</span>
                     98: 00091 <span class="preprocessor"></span><span class="preprocessor">#define IS_EXTENSION_ID(byte) (((byte) &amp; ASN_EXTENSION_ID) = ASN_EXTENSION_ID)</span>
                     99: 00092 <span class="preprocessor"></span>
                    100: 00093 <span class="comment">/*</span>
                    101: 00094 <span class="comment"> *  All of the build_asn1_* (build_asn1_length being an exception) functions</span>
                    102: 00095 <span class="comment"> *  take the same first 3 arguments:</span>
                    103: 00096 <span class="comment"> *</span>
                    104: 00097 <span class="comment"> *  u_int8_t *data:   This is a pointer to the start of the data object to be</span>
                    105: 00098 <span class="comment"> *                  manipulated.</span>
                    106: 00099 <span class="comment"> *  int *datalen:   This is a pointer to the number of valid bytes following</span>
                    107: 00100 <span class="comment"> *                  "data".  This should be not be exceeded in any function.</span>
                    108: 00101 <span class="comment"> *                  Upon exiting a function, this value will reflect the</span>
                    109: 00102 <span class="comment"> *                  changed "data" and then refer to the new number of valid</span>
                    110: 00103 <span class="comment"> *                  bytes until the end of "data".</span>
                    111: 00104 <span class="comment"> *  u_int8_t type:    The ASN.1 object type.</span>
                    112: 00105 <span class="comment"> */</span>
                    113: 00106 
                    114: 00107 
                    115: 00108 <span class="comment">/*</span>
                    116: 00109 <span class="comment"> *  Builds an ASN object containing an integer.</span>
                    117: 00110 <span class="comment"> *</span>
                    118: 00111 <span class="comment"> *  Returns NULL upon error or a pointer to the first byte past the end of</span>
                    119: 00112 <span class="comment"> *  this object (the start of the next object).</span>
                    120: 00113 <span class="comment"> */</span>
                    121: 00114 
                    122: 00115 u_int8_t *
                    123: 00116 libnet_build_asn1_int(
                    124: 00117     u_int8_t *,           <span class="comment">/* Pointer to the output buffer */</span>
                    125: 00118     <span class="keywordtype">int</span> *,              <span class="comment">/* Number of valid bytes left in the buffer */</span>
                    126: 00119     u_int8_t,             <span class="comment">/* ASN object type */</span>
                    127: 00120     int32_t *,             <span class="comment">/* Pointer to a int32_t integer */</span>
                    128: 00121     <span class="keywordtype">int</span>                 <span class="comment">/* Size of a int32_t integer */</span>
                    129: 00122     );
                    130: 00123 
                    131: 00124 
                    132: 00125 <span class="comment">/*</span>
                    133: 00126 <span class="comment"> *  Builds an ASN object containing an unsigned integer.</span>
                    134: 00127 <span class="comment"> *</span>
                    135: 00128 <span class="comment"> *  Returns NULL upon error or a pointer to the first byte past the end of</span>
                    136: 00129 <span class="comment"> *  this object (the start of the next object).</span>
                    137: 00130 <span class="comment"> */</span>
                    138: 00131 
                    139: 00132 u_int8_t *
                    140: 00133 libnet_build_asn1_uint(
                    141: 00134     u_int8_t *,           <span class="comment">/* Pointer to the output buffer */</span>
                    142: 00135     <span class="keywordtype">int</span> *,              <span class="comment">/* Number of valid bytes left in the buffer */</span>
                    143: 00136     u_int8_t,             <span class="comment">/* ASN object type */</span>
                    144: 00137     u_int32_t *,           <span class="comment">/* Pointer to an unsigned int32_t integer */</span>
                    145: 00138     <span class="keywordtype">int</span>                 <span class="comment">/* Size of a int32_t integer */</span>
                    146: 00139     );
                    147: 00140 
                    148: 00141 
                    149: 00142 <span class="comment">/*</span>
                    150: 00143 <span class="comment"> *  Builds an ASN object containing an octect string.</span>
                    151: 00144 <span class="comment"> *</span>
                    152: 00145 <span class="comment"> *  Returns NULL upon error or a pointer to the first byte past the end of</span>
                    153: 00146 <span class="comment"> *  this object (the start of the next object).</span>
                    154: 00147 <span class="comment"> */</span>
                    155: 00148 
                    156: 00149 u_int8_t *
                    157: 00150 libnet_build_asn1_string(
                    158: 00151     u_int8_t *,           <span class="comment">/* Pointer to the output buffer */</span>
                    159: 00152     <span class="keywordtype">int</span> *,              <span class="comment">/* Number of valid bytes left in the buffer */</span>
                    160: 00153     u_int8_t,             <span class="comment">/* ASN object type */</span>
                    161: 00154     u_int8_t *,           <span class="comment">/* Pointer to a string to be built into an object */</span>
                    162: 00155     <span class="keywordtype">int</span>                 <span class="comment">/* Size of the string */</span>
                    163: 00156     );
                    164: 00157 
                    165: 00158 
                    166: 00159 <span class="comment">/*</span>
                    167: 00160 <span class="comment"> *  Builds an ASN header for an object with the ID and length specified.  This</span>
                    168: 00161 <span class="comment"> *  only works on data types &lt; 30, i.e. no extension octets.  The maximum</span>
                    169: 00162 <span class="comment"> *  length is 0xFFFF;</span>
                    170: 00163 <span class="comment"> *</span>
                    171: 00164 <span class="comment"> *  Returns a pointer to the first byte of the contents of this object or</span>
                    172: 00165 <span class="comment"> *  NULL upon error</span>
                    173: 00166 <span class="comment"> */</span>
                    174: 00167 
                    175: 00168 u_int8_t *
                    176: 00169 libnet_build_asn1_header(
                    177: 00170     u_int8_t *,       <span class="comment">/* Pointer to the start of the object */</span>
                    178: 00171     <span class="keywordtype">int</span> *,          <span class="comment">/* Number of valid bytes left in buffer */</span>
                    179: 00172     u_int8_t,         <span class="comment">/* ASN object type */</span>
                    180: 00173     <span class="keywordtype">int</span>             <span class="comment">/* ASN object length */</span>
                    181: 00174     );
                    182: 00175 
                    183: 00176 
                    184: 00177 u_int8_t *
                    185: 00178 libnet_build_asn1_length(
                    186: 00179     u_int8_t *,       <span class="comment">/* Pointer to start of object */</span>
                    187: 00180     <span class="keywordtype">int</span> *,          <span class="comment">/* Number of valid bytes in buffer */</span>
                    188: 00181     <span class="keywordtype">int</span>             <span class="comment">/* Length of object */</span>
                    189: 00182     );
                    190: 00183 
                    191: 00184 
                    192: 00185 <span class="comment">/*</span>
                    193: 00186 <span class="comment"> *  Builds an ASN header for a sequence with the ID and length specified.</span>
                    194: 00187 <span class="comment"> *</span>
                    195: 00188 <span class="comment"> *  This only works on data types &lt; 30, i.e. no extension octets.</span>
                    196: 00189 <span class="comment"> *  The maximum length is 0xFFFF;</span>
                    197: 00190 <span class="comment"> *</span>
                    198: 00191 <span class="comment"> *  Returns a pointer to the first byte of the contents of this object.</span>
                    199: 00192 <span class="comment"> *  Returns NULL on any error.</span>
                    200: 00193 <span class="comment"> */</span>
                    201: 00194 
                    202: 00195 u_int8_t *
                    203: 00196 libnet_build_asn1_sequence(
                    204: 00197     u_int8_t *,
                    205: 00198     <span class="keywordtype">int</span> *,
                    206: 00199     u_int8_t,
                    207: 00200     <span class="keywordtype">int</span>
                    208: 00201     );
                    209: 00202 
                    210: 00203 
                    211: 00204 <span class="comment">/*</span>
                    212: 00205 <span class="comment"> *  Builds an ASN object identifier object containing the input string.</span>
                    213: 00206 <span class="comment"> *</span>
                    214: 00207 <span class="comment"> *  Returns NULL upon error or a pointer to the first byte past the end of</span>
                    215: 00208 <span class="comment"> *  this object (the start of the next object).</span>
                    216: 00209 <span class="comment"> */</span>
                    217: 00210 
                    218: 00211 u_int8_t *
                    219: 00212 libnet_build_asn1_objid(
                    220: 00213     u_int8_t *,
                    221: 00214     <span class="keywordtype">int</span> *,
                    222: 00215     u_int8_t,
                    223: 00216     oid *,
                    224: 00217     <span class="keywordtype">int</span>
                    225: 00218     );
                    226: 00219 
                    227: 00220 
                    228: 00221 <span class="comment">/*</span>
                    229: 00222 <span class="comment"> *  Builds an ASN null object.</span>
                    230: 00223 <span class="comment"> *</span>
                    231: 00224 <span class="comment"> *  Returns NULL upon error or a pointer to the first byte past the end of</span>
                    232: 00225 <span class="comment"> *  this object (the start of the next object).</span>
                    233: 00226 <span class="comment"> */</span>
                    234: 00227 
                    235: 00228 u_int8_t *
                    236: 00229 libnet_build_asn1_null(
                    237: 00230     u_int8_t *,
                    238: 00231     <span class="keywordtype">int</span> *,
                    239: 00232     u_int8_t
                    240: 00233     );
                    241: 00234 
                    242: 00235 
                    243: 00236 <span class="comment">/*</span>
                    244: 00237 <span class="comment"> *  Builds an ASN bitstring.</span>
                    245: 00238 <span class="comment"> *</span>
                    246: 00239 <span class="comment"> *  Returns NULL upon error or a pointer to the first byte past the end of</span>
                    247: 00240 <span class="comment"> *  this object (the start of the next object).</span>
                    248: 00241 <span class="comment"> */</span>
                    249: 00242 
                    250: 00243 u_int8_t *
                    251: 00244 libnet_build_asn1_bitstring(
                    252: 00245     u_int8_t *,
                    253: 00246     <span class="keywordtype">int</span> *,
                    254: 00247     u_int8_t,
                    255: 00248     u_int8_t *,       <span class="comment">/* Pointer to the input buffer */</span>
                    256: 00249     <span class="keywordtype">int</span>             <span class="comment">/* Length of the input buffer */</span>
                    257: 00250     );
                    258: 00251 
                    259: 00252 
                    260: 00253 <span class="preprocessor">#endif  </span><span class="comment">/* __LIBNET_ASN1_H */</span>
                    261: 00254 
                    262: 00255 <span class="comment">/* EOF */</span>
                    263: </pre></div><hr size="1"><address style="align: right;"><small>Generated on Wed Mar 10 13:23:37 2004 for libnet by
                    264: <a href="http://www.doxygen.org/index.html">
                    265: <img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
                    266: </a>1.3.4 </small></address>
                    267: </body>
                    268: </html>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>