Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

XDR.h File Reference

#include <sys/types.h>
#include <netinet/in.h>
#include "util.h"

Include dependency graph for XDR.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Functions

int XDR_aligned (const u_char *buf)
uint32 extract_XDR_uint32 (const u_char *&buf, int &len)
double extract_XDR_uint64_as_double (const u_char *&buf, int &len)
double extract_XDR_time (const u_char *&buf, int &len)
const u_char * extract_XDR_opaque (const u_char *&buf, int &len, int &n, int max_len=8192)
uint32 skip_XDR_opaque_auth (const u_char *&buf, int &len)


Function Documentation

const u_char* extract_XDR_opaque const u_char *&  buf,
int &  len,
int &  n,
int  max_len = 8192
 

Definition at line 74 of file XDR.cc.

References extract_XDR_uint32(), int, and len.

Referenced by PortmapperInterp::ExtractCallItRequest(), NFS_Interp::ExtractFH(), NFS_Interp::RPC_BuildCall(), PortmapperInterp::RPC_BuildReply(), and skip_XDR_opaque_auth().

00075         {
00076         n = int(extract_XDR_uint32(buf, len));
00077         if ( ! buf )
00078                 return 0;
00079 
00080         if ( n < 0 || n > len || n > max_len )
00081                 { // ### Should really flag this as a different sort of error.
00082                 buf = 0;
00083                 return 0;
00084                 }
00085 
00086         int n4 = ((n + 3) >> 2) << 2;   // n rounded up to next multiple of 4
00087 
00088         len -= n4;
00089         const u_char* opaque = buf;
00090         buf += n4;
00091 
00092         return opaque;
00093         }

double extract_XDR_time const u_char *&  buf,
int &  len
 

Definition at line 60 of file XDR.cc.

References double, extract_XDR_uint32(), len, and uint32.

Referenced by NFS_Interp::ExtractTime().

00061         {
00062         if ( ! buf || len < 8 )
00063                 {
00064                 buf = 0;
00065                 return 0.0;
00066                 }
00067 
00068         uint32 uhi = extract_XDR_uint32(buf, len);
00069         uint32 ulo = extract_XDR_uint32(buf, len);
00070 
00071         return double(uhi) + double(ulo) / 1e9;
00072         }

uint32 extract_XDR_uint32 const u_char *&  buf,
int &  len
 

Definition at line 26 of file XDR.cc.

References len, uint32, and XDR_aligned().

Referenced by TCP_Contents_RPC::Deliver(), RPC_Interpreter::DeliverRPC(), extract_XDR_opaque(), extract_XDR_time(), extract_XDR_uint64_as_double(), PortmapperInterp::ExtractCallItRequest(), NFS_Interp::ExtractCount(), NFS_Interp::ExtractInterval(), PortmapperInterp::ExtractMapping(), NFS_Interp::ExtractOptAttrs(), PortmapperInterp::ExtractPortRequest(), PortmapperInterp::RPC_BuildReply(), NFS_Interp::RPC_BuildReply(), RPC_CallInfo::RPC_CallInfo(), and skip_XDR_opaque_auth().

00027         {
00028         if ( ! buf )
00029                 return 0;
00030 
00031         if ( len < 4 )
00032                 {
00033                 buf = 0;
00034                 return 0;
00035                 }
00036 
00037         uint32 bits32 = XDR_aligned(buf) ? *(uint32*) buf :
00038                 ((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]);
00039 
00040         buf += 4;
00041         len -= 4;
00042 
00043         return ntohl(bits32);
00044         }

double extract_XDR_uint64_as_double const u_char *&  buf,
int &  len
 

Definition at line 46 of file XDR.cc.

References double, extract_XDR_uint32(), len, and uint32.

Referenced by NFS_Interp::ExtractLongAsDouble().

00047         {
00048         if ( ! buf || len < 8 )
00049                 {
00050                 buf = 0;
00051                 return 0.0;
00052                 }
00053 
00054         uint32 uhi = extract_XDR_uint32(buf, len);
00055         uint32 ulo = extract_XDR_uint32(buf, len);
00056 
00057         return double(uhi) * 4294967296.0 + double(ulo);
00058         }

uint32 skip_XDR_opaque_auth const u_char *&  buf,
int &  len
 

Definition at line 95 of file XDR.cc.

References extract_XDR_opaque(), extract_XDR_uint32(), len, and uint32.

Referenced by RPC_Interpreter::DeliverRPC(), and RPC_CallInfo::RPC_CallInfo().

00096         {
00097         uint32 auth_flavor = extract_XDR_uint32(buf, len);
00098         if ( ! buf )
00099                 return 0;
00100 
00101         int n;
00102         (void) extract_XDR_opaque(buf, len, n, 400);
00103 
00104         return auth_flavor;
00105         }

int XDR_aligned const u_char *  buf  )  [inline]
 

Definition at line 30 of file XDR.h.

Referenced by extract_XDR_uint32().

00031         {
00032         return (((unsigned long) buf) & 0x3) == 0;
00033         }


Generated on Wed Sep 14 03:07:28 2005 for bro_docs by doxygen 1.3.5