<html>
<head>
<title>embedded IPsec - IPsec library</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="doxygen.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<table width="98%" border="0" align="center">
  <tr>
    <td>
      <h2 align="left"><img src="logo_small.gif" alt="embedded IPsec"> source 
        code documentation </h2>
<hr>

<!-- Generated by Doxygen 1.3.4 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</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> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<h1>util.c File Reference</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
A collection of common helper functions and macros used everywhere in the IPsec library. 
<p>
<dl compact><dt><b>Author:</b></dt><dd>Niklaus Schild &lt;<a href="mailto:n.schild@gmx.ch">n.schild@gmx.ch</a>&gt; <br>
</dd></dl>
<b>OUTLINE:</b> The following functions are implemented in this module:<ul>
<li>logging</li></ul>
<p>
<b>IMPLEMENTATION:</b><p>
There are no implementation hints to be mentioned.<p>
<b>NOTES:</b><p>
This document is part of <em>embedded IPsec<br>
 Copyright (c) 2003 Niklaus Schild and Christian Scheurer, HTI Biel/Bienne<br>
 All rights reserved.<br>
 This file contains code from the lwIP project by Adam Dunkels and others<br>
 Copyright (c) 2001, 2002 Swedish Institute of Computer Science.<br>
 All rights reserved.</em><hr>

<p>
Definition in file <a class="el" href="util_8c-source.html">util.c</a>.
<p>
<code>#include &lt;string.h&gt;</code><br>
<code>#include &lt;ctype.h&gt;</code><br>
<code>#include "<a class="el" href="ipsec_8h-source.html">ipsec/ipsec.h</a>"</code><br>
<code>#include "<a class="el" href="util_8h-source.html">ipsec/util.h</a>"</code><br>
<code>#include "<a class="el" href="debug_8h-source.html">ipsec/debug.h</a>"</code><br>

<p>
<a href="util_8c-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="util_8c.html#a0">ipsec_print_ip</a> (<a class="el" href="structipsec__ip__hdr__struct.html">ipsec_ip_header</a> *header)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="types_8h.html#a4">__u32</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="util_8c.html#a1">ipsec_inet_addr</a> (const  char *cp)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="util_8c.html#a2">ipsec_inet_aton</a> (const  char *cp, struct <a class="el" href="structipsec__in__addr.html">ipsec_in_addr</a> *addr)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="types_8h.html#a0">__u8</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="util_8c.html#a3">ipsec_inet_ntoa</a> (<a class="el" href="types_8h.html#a4">__u32</a> addr)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="types_8h.html#a2">__u16</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="util_8c.html#a4">ipsec_htons</a> (<a class="el" href="types_8h.html#a2">__u16</a> n)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="types_8h.html#a2">__u16</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="util_8c.html#a5">ipsec_ntohs</a> (<a class="el" href="types_8h.html#a2">__u16</a> n)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="types_8h.html#a4">__u32</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="util_8c.html#a6">ipsec_htonl</a> (<a class="el" href="types_8h.html#a4">__u32</a> n)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="types_8h.html#a4">__u32</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="util_8c.html#a7">ipsec_ntohl</a> (<a class="el" href="types_8h.html#a4">__u32</a> n)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="types_8h.html#a2">__u16</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="util_8c.html#a8">chksum</a> (void *dataptr, int len)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="types_8h.html#a2">__u16</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="util_8c.html#a9">ipsec_ip_chksum</a> (void *dataptr, <a class="el" href="types_8h.html#a2">__u16</a> len)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="util_8c.html#a10">ipsec_dump_buffer</a> (char *prefix, unsigned char *data, int offs, int length)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="types_8h.html#a7">ipsec_audit</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="util_8c.html#a11">ipsec_check_replay_window</a> (<a class="el" href="types_8h.html#a4">__u32</a> seq, <a class="el" href="types_8h.html#a4">__u32</a> lastSeq, <a class="el" href="types_8h.html#a4">__u32</a> bitField)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="types_8h.html#a7">ipsec_audit</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="util_8c.html#a12">ipsec_update_replay_window</a> (<a class="el" href="types_8h.html#a4">__u32</a> seq, <a class="el" href="types_8h.html#a4">__u32</a> *lastSeq, <a class="el" href="types_8h.html#a4">__u32</a> *bitField)</td></tr>

</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="a8" doxytag="util.c::chksum" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="types_8h.html#a2">__u16</a> chksum </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void *&nbsp;</td>
          <td class="mdname" nowrap> <em>dataptr</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>int&nbsp;</td>
          <td class="mdname" nowrap> <em>len</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"><code> [static]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
helper function to calculate the IP header checksum<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>len</em>&nbsp;</td><td>length of the buffer </td></tr>
    <tr><td valign=top><em>dataptr</em>&nbsp;</td><td>pointer the buffer </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>16-bit value of the checksum </dd></dl>

<p>
Definition at line <a class="el" href="util_8c-source.html#l00322">322</a> of file <a class="el" href="util_8c-source.html">util.c</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a11" doxytag="util.c::ipsec_check_replay_window" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="types_8h.html#a7">ipsec_audit</a> ipsec_check_replay_window </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="types_8h.html#a4">__u32</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>seq</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="types_8h.html#a4">__u32</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>lastSeq</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="types_8h.html#a4">__u32</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>bitField</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Verify the sequence number of the AH packet is inside the window (defined as IPSEC_SEQ_MAX_WINDOW) Note: this function does NOT update the lastSeq variable and may safely be called prior to IVC check.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>seq</em>&nbsp;</td><td>sequence number of the current packet </td></tr>
    <tr><td valign=top><em>lastSeq</em>&nbsp;</td><td>sequence number of the last known packet </td></tr>
    <tr><td valign=top><em>bitField</em>&nbsp;</td><td>field used to verify resent data within the window </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>IPSEC_AUDIT_SUCCESS if check passed (packet allowed) <p>
IPSEC_AUDIT_SEQ_MISMATCH if check failed (packet disallowed) </dd></dl>

<p>
Definition at line <a class="el" href="util_8c-source.html#l00431">431</a> of file <a class="el" href="util_8c-source.html">util.c</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a10" doxytag="util.c::ipsec_dump_buffer" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void ipsec_dump_buffer </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">char *&nbsp;</td>
          <td class="mdname" nowrap> <em>prefix</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>unsigned char *&nbsp;</td>
          <td class="mdname" nowrap> <em>data</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>int&nbsp;</td>
          <td class="mdname" nowrap> <em>offs</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>int&nbsp;</td>
          <td class="mdname" nowrap> <em>length</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Dump (print) a memory location<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>prefix</em>&nbsp;</td><td>print this text at the beginning of each line </td></tr>
    <tr><td valign=top><em>data</em>&nbsp;</td><td>pointer the buffer which should be printed </td></tr>
    <tr><td valign=top><em>offs</em>&nbsp;</td><td>offset from the buffer's start address </td></tr>
    <tr><td valign=top><em>length</em>&nbsp;</td><td>number of bytes to be printed initialized with IP, netmask and gateway address. </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>void </dd></dl>

<p>
Definition at line <a class="el" href="util_8c-source.html#l00381">381</a> of file <a class="el" href="util_8c-source.html">util.c</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a6" doxytag="util.c::ipsec_htonl" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="types_8h.html#a4">__u32</a> ipsec_htonl </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="types_8h.html#a4">__u32</a>&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>n</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Converts long types from host to network order<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>n</em>&nbsp;</td><td>long value in host order </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>long value in network order </dd></dl>

<p>
Definition at line <a class="el" href="util_8c-source.html#l00296">296</a> of file <a class="el" href="util_8c-source.html">util.c</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a4" doxytag="util.c::ipsec_htons" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="types_8h.html#a2">__u16</a> ipsec_htons </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="types_8h.html#a2">__u16</a>&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>n</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Converts short types from host to network order<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>n</em>&nbsp;</td><td>short value in host order </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>short value in network order </dd></dl>

<p>
Definition at line <a class="el" href="util_8c-source.html#l00274">274</a> of file <a class="el" href="util_8c-source.html">util.c</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a1" doxytag="util.c::ipsec_inet_addr" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="types_8h.html#a4">__u32</a> ipsec_inet_addr </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const char *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>cp</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Converts an IP address from the dotted notation into a 32-bit network order<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>cp</em>&nbsp;</td><td>IP address in dotted notation </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>address in network order <p>
IP_ADDR_NONE on failure the return value has all bits set to 1 </dd></dl>

<p>
Definition at line <a class="el" href="util_8c-source.html#l00117">117</a> of file <a class="el" href="util_8c-source.html">util.c</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a2" doxytag="util.c::ipsec_inet_aton" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> int ipsec_inet_aton </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const char *&nbsp;</td>
          <td class="mdname" nowrap> <em>cp</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>struct <a class="el" href="structipsec__in__addr.html">ipsec_in_addr</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>addr</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Converts an IP address from dotted notation into a 32-bit value. This function is used by inet_addr().<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>cp</em>&nbsp;</td><td>IP address in dotted notation </td></tr>
    <tr><td valign=top><em>addr</em>&nbsp;</td><td>binary IP address </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>1 Address is valid <p>
0 Address is not valid </dd></dl>

<p>
Definition at line <a class="el" href="util_8c-source.html#l00136">136</a> of file <a class="el" href="util_8c-source.html">util.c</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a3" doxytag="util.c::ipsec_inet_ntoa" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="types_8h.html#a0">__u8</a>* ipsec_inet_ntoa </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="types_8h.html#a4">__u32</a>&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>addr</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Converts an binary IP address to a dotted notation Beware that this function is not reentrant.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>addr</em>&nbsp;</td><td>binary IP address </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>pointer to the character string representing the dotted notation </dd></dl>

<p>
Definition at line <a class="el" href="util_8c-source.html#l00240">240</a> of file <a class="el" href="util_8c-source.html">util.c</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a9" doxytag="util.c::ipsec_ip_chksum" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="types_8h.html#a2">__u16</a> ipsec_ip_chksum </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void *&nbsp;</td>
          <td class="mdname" nowrap> <em>dataptr</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="types_8h.html#a2">__u16</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>len</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
calculates the checksum of the IP header<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>dataptr</em>&nbsp;</td><td>pointer to the buffer </td></tr>
    <tr><td valign=top><em>len</em>&nbsp;</td><td>length of the buffer </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>16-bit value of the checksum </dd></dl>

<p>
Definition at line <a class="el" href="util_8c-source.html#l00354">354</a> of file <a class="el" href="util_8c-source.html">util.c</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a7" doxytag="util.c::ipsec_ntohl" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="types_8h.html#a4">__u32</a> ipsec_ntohl </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="types_8h.html#a4">__u32</a>&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>n</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Converts long types from network to host order<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>n</em>&nbsp;</td><td>long value in network order </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>long value in host order </dd></dl>

<p>
Definition at line <a class="el" href="util_8c-source.html#l00310">310</a> of file <a class="el" href="util_8c-source.html">util.c</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a5" doxytag="util.c::ipsec_ntohs" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="types_8h.html#a2">__u16</a> ipsec_ntohs </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="types_8h.html#a2">__u16</a>&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>n</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Converts short types from network to host order<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>n</em>&nbsp;</td><td>short value in network order </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>short value in host order </dd></dl>

<p>
Definition at line <a class="el" href="util_8c-source.html#l00285">285</a> of file <a class="el" href="util_8c-source.html">util.c</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a0" doxytag="util.c::ipsec_print_ip" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void ipsec_print_ip </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="structipsec__ip__hdr__struct.html">ipsec_ip_header</a> *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>header</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Prints the header of an IP packet<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>header</em>&nbsp;</td><td>pointer to an IP header </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>void </dd></dl>

<p>
Definition at line <a class="el" href="util_8c-source.html#l00069">69</a> of file <a class="el" href="util_8c-source.html">util.c</a>.    </td>
  </tr>
</table>
<a class="anchor" name="a12" doxytag="util.c::ipsec_update_replay_window" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="types_8h.html#a7">ipsec_audit</a> ipsec_update_replay_window </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="types_8h.html#a4">__u32</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>seq</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="types_8h.html#a4">__u32</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>lastSeq</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="types_8h.html#a4">__u32</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>bitField</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Verify and update the sequence number. Note: this function is UPDATING the lastSeq variable and must be called only AFTER checking the IVC.<p>
This code is based on RFC2401, Appendix C -- Sequence Space Window Code Example<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>seq</em>&nbsp;</td><td>sequence number of the current packet </td></tr>
    <tr><td valign=top><em>lastSeq</em>&nbsp;</td><td>pointer to sequence number of the last known packet </td></tr>
    <tr><td valign=top><em>bitField</em>&nbsp;</td><td>pointer to field used to verify resent data within the window </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>IPSEC_AUDIT_SUCCESS if check passed (packet allowed) <p>
IPSEC_AUDIT_SEQ_MISMATCH if check failed (packet disallowed) </dd></dl>

<p>
Definition at line <a class="el" href="util_8c-source.html#l00468">468</a> of file <a class="el" href="util_8c-source.html">util.c</a>.    </td>
  </tr>
</table>
	</td>
  </tr>
</table>
<hr>
<div align="center">Copyright 2003 by Christian Scheurer and Niklaus Schild</div>
</html>