tcpflow  1.6.1
About: tcpflow is a TCP/IP packet demultiplexer that captures data transmitted as part of TCP connections (flows), and stores the data in a way that is convenient for protocol analysis and debugging.
  Fossies Dox: tcpflow-1.6.1.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

sbuf_t Class Reference

#include <sbuf.h>

Collaboration diagram for sbuf_t:
[legend]

Classes

class  range_exception_t
 

Public Types

enum  byte_order_t { BO_LITTLE_ENDIAN =0 , BO_BIG_ENDIAN =1 }
 

Public Member Functions

 sbuf_t ()
 
 sbuf_t (const sbuf_t &that)
 
 sbuf_t (const pos0_t &that_pos0, const sbuf_t &that_sbuf)
 
 sbuf_t (const sbuf_t &that_sbuf, size_t off)
 
 sbuf_t (const sbuf_t &sbuf, size_t off, size_t len)
 
 sbuf_t (const pos0_t &pos0_, const uint8_t *buf_, size_t bufsize_, size_t pagesize_, int fd_, bool should_unmap_, bool should_free_, bool should_close_)
 
 sbuf_t (const pos0_t &pos0_, const uint8_t *buf_, size_t bufsize_, size_t pagesize_, bool should_free_)
 
sbuf_t operator+ (size_t off) const
 
virtual ~sbuf_t ()
 
size_t size () const
 
size_t left (size_t n) const
 
const sbuf_thighest_parent () const
 
void add_child (const sbuf_t &child) const
 
void del_child (const sbuf_t &child) const
 
size_t offset (const uint8_t *loc) const
 
std::string asString () const
 
int memcmp (const uint8_t *cbuf, size_t at, size_t len) const
 
uint8_t operator[] (size_t i) const
 
ssize_t find (uint8_t ch, size_t start) const
 
ssize_t find (const char *str, size_t start) const
 
std::string substr (size_t loc, size_t len) const
 
bool is_constant (size_t loc, size_t len, uint8_t ch) const
 
bool is_constant (uint8_t ch) const
 
template<class TYPE >
const TYPE * get_struct_ptr (uint32_t pos) const
 
void raw_dump (std::ostream &os, uint64_t start, uint64_t len) const
 
void raw_dump (int fd, uint64_t start, uint64_t len) const
 
void hex_dump (std::ostream &os, uint64_t start, uint64_t len) const
 
void hex_dump (std::ostream &os) const
 
ssize_t write (int fd, size_t loc, size_t len) const
 
ssize_t write (FILE *f, size_t loc, size_t len) const
 
unsigned int Intel (littel-endian) readers

these get functions safely return an unsigned integer value for the offset of i, in Intel (little-endian) byte order or else throw sbuf_range_exception if out of range.

uint8_t get8u (size_t i) const
 
uint16_t get16u (size_t i) const
 
uint32_t get32u (size_t i) const
 
uint64_t get64u (size_t i) const
 
unsigned int Motorola (big-endian) readers

these get functions safely return an unsigned integer value for the offset of i, in Motorola (big-endian) byte order or else throw sbuf_range_exception if out of range.

uint8_t get8uBE (size_t i) const
 
uint16_t get16uBE (size_t i) const
 
uint32_t get32uBE (size_t i) const
 
uint64_t get64uBE (size_t i) const
 
signed int Intel (little-endian) readers

these get functions safely return a signed integer value for the offset of i, in Intel (little-endian) byte order or else throw sbuf_range_exception if out of range.

int8_t get8i (size_t i) const
 
int16_t get16i (size_t i) const
 
int32_t get32i (size_t i) const
 
int64_t get64i (size_t i) const
 
signed int Motorola (big-endian) readers

these get functions safely return a signed integer value for the offset of i, in Motorola (big-endian) byte order or else throw sbuf_range_exception if out of range.

int8_t get8iBE (size_t i) const
 
int16_t get16iBE (size_t i) const
 
int32_t get32iBE (size_t i) const
 
int64_t get64iBE (size_t i) const
 
unsigned int, byte-order specified readers

these get functions safely return an unsigned integer value for the offset of i, in the byte order of your choice or else throw sbuf_range_exception if out of range.

uint8_t get8u (size_t i, byte_order_t bo) const
 
uint16_t get16u (size_t i, byte_order_t bo) const
 
uint32_t get32u (size_t i, byte_order_t bo) const
 
uint64_t get64u (size_t i, byte_order_t bo) const
 
signed int, byte-order specified readers

these get functions safely return a signed integer value for the offset of i, in the byte order of your choice or else throw sbuf_range_exception if out of range.

int8_t get8i (size_t i, byte_order_t bo) const
 
int16_t get16i (size_t i, byte_order_t bo) const
 
int32_t get32i (size_t i, byte_order_t bo) const
 
int64_t get64i (size_t i, byte_order_t bo) const
 
string readers

These get functions safely read string

void getUTF8 (size_t i, size_t num_octets_requested, std::string &utf8_string) const
 
void getUTF8 (size_t i, std::string &utf8_string) const
 
wstring readers

These get functions safely read wstring

void getUTF16 (size_t i, size_t num_code_units_requested, std::wstring &utf16_string) const
 
void getUTF16 (size_t i, std::wstring &utf16_string) const
 
void getUTF16 (size_t i, size_t num_code_units_requested, byte_order_t bo, std::wstring &utf16_string) const
 
void getUTF16 (size_t i, byte_order_t bo, std::wstring &utf16_string) const
 

Static Public Member Functions

static size_t min (size_t a, size_t b)
 
static sbuf_tmap_file (const std::string &fname)
 
static sbuf_tmap_file (const std::string &fname, int fd)
 
static void set_map_file_delimiter (const std::string &new_delim)
 

Public Attributes

bool should_unmap
 
bool should_free
 
bool should_close
 
int page_number
 
pos0_t pos0
 
int children
 
const uint8_tbuf
 
size_t bufsize
 
size_t pagesize
 

Static Public Attributes

static const std::string U10001C
 
static std::string map_file_delimiter
 

Private Member Functions

void release ()
 
sbuf_toperator= (const sbuf_t &that)
 

Private Attributes

int fd
 
const sbuf_tparent
 

Detailed Description

This class describes the search buffer. The accessors are safe so that no buffer overflow can happen. Integer readers may throw sbuf_bounds_exception.

This structure actually holds the data. We use a pos0_t to maintain the address of the first byte.

There are lots of ways for allocating an sbuf_t:

  • map from a file.
  • set from a block of memory.
  • a subset of an existing sbuf_t (sbuf+10 gives you 10 bytes in, and therefore 10 bytes shorter)

The subf_t class remembers how the sbuf_t was allocated and automatically frees whatever resources are needed when it is freed.

Warning
DANGER: You must delete sbuf_t structures First-In, Last-out, otherwise bad things can happen. (For example, if you make a subset sbuf_t from a mapped file and unmap the file, the subset will now point to unallocated memory.)

Definition at line 221 of file sbuf.h.


The documentation for this class was generated from the following files: