The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tlvhelper.c File Reference

TLV helper functions. More...

#include <string.h>
#include <glib.h>
#include <tlvhelper.h>
Include dependency graph for tlvhelper.c:

Go to the source code of this file.

Functions

guint8 tlv_get_guint8 (const void *vitem, const void *bufend)
 Retrieve an unsigned 8 bit integer from the given location with error checking. More...
 
void tlv_set_guint8 (void *vitem, guint8 item, const void *bufend)
 Set an unsigned 8 bit integer to the given location with error checking. More...
 
guint16 tlv_get_guint16 (const void *vitem, const void *bufend)
 Retrieve an unsigned 16 bit integer from the given location with error checking and without caring about byte alignment. More...
 
void tlv_set_guint16 (void *vitem, guint16 item, const void *bufend)
 Set an unsigned 16 bit integer to the given location with error checking and without caring about byte alignment. More...
 
guint32 tlv_get_guint32 (const void *vitem, const void *bufend)
 Retrieve an unsigned 32 bit integer from the given location with error checking and without caring about byte alignment. More...
 
void tlv_set_guint32 (void *vitem, guint32 item, const void *bufend)
 Set an unsigned 32 bit integer to the given location with error checking and without caring about byte alignment. More...
 
guint64 tlv_get_guint64 (const void *vitem, const void *bufend)
 Retrieve an unsigned 64 bit integer from the given location with error checking and without caring about byte alignment. More...
 
void tlv_set_guint64 (void *vitem, guint64 item, const void *bufend)
 Set an unsigned 64 bit integer to the given location with error checking and without caring about byte alignment. More...
 
guint32 tlv_get_guint24 (const void *vitem, const void *bufend)
 Retrieve an unsigned 24 bit (3-byte) integer from the given location with error checking and without caring about byte alignment. More...
 
void tlv_set_guint24 (void *vitem, guint32 item, const void *bufend)
 Set an unsigned 24 bit (3-byte) integer to the given location with error checking and without caring about byte alignment. More...
 

Detailed Description

TLV helper functions.

The file provides a variety of getter and setter functions for TLV integers - all with lots of error checking.

This file is part of the Assimilation Project.

Author
Copyright © 2011, 2012 - Alan Robertson alanr.nosp@m.@uni.nosp@m.x.sh
The Assimilation software is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Assimilation software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the Assimilation Project software. If not, see http://www.gnu.org/licenses/

Definition in file tlvhelper.c.

Function Documentation

guint16 tlv_get_guint16 ( const void *  vitem,
const void *  bufend 
)

Retrieve an unsigned 16 bit integer from the given location with error checking and without caring about byte alignment.

Parameters
vitemLocation to get int from
bufendone byte past end of buffer

Definition at line 53 of file tlvhelper.c.

Referenced by _addrframe_default_isvalid(), _decode_packet_get_frameset_data(), _ipportframe_default_isvalid(), addrframe_tlvconstructor(), get_cdp_cksum(), get_cdptlv_len(), get_cdptlv_type(), get_generic_tlv_type(), intframe_tlvconstructor(), ipportframe_tlvconstructor(), seqnoframe_tlvconstructor(), and tlv_get_guint24().

Here is the caller graph for this function:

guint32 tlv_get_guint24 ( const void *  vitem,
const void *  bufend 
)

Retrieve an unsigned 24 bit (3-byte) integer from the given location with error checking and without caring about byte alignment.

This is used for IEEE OUI values.

Todo:
verify that this 3-byte ordering is correct - it has to match the IEEE OUI layout...
Parameters
vitemLocation to get int from
bufendone byte past end of buffer

Definition at line 131 of file tlvhelper.c.

References tlv_get_guint16().

Referenced by _compressframe_isvalid(), compressframe_tlvconstructor(), get_generic_tlv_len(), and intframe_tlvconstructor().

Here is the call graph for this function:

Here is the caller graph for this function:

guint32 tlv_get_guint32 ( const void *  vitem,
const void *  bufend 
)

Retrieve an unsigned 32 bit integer from the given location with error checking and without caring about byte alignment.

Parameters
vitemLocation to get int from
bufendone byte past end of buffer

Definition at line 81 of file tlvhelper.c.

Referenced by intframe_tlvconstructor(), and seqnoframe_tlvconstructor().

Here is the caller graph for this function:

guint64 tlv_get_guint64 ( const void *  vitem,
const void *  bufend 
)

Retrieve an unsigned 64 bit integer from the given location with error checking and without caring about byte alignment.

Parameters
vitemLocation to get int from
bufendone byte past end of buffer

Definition at line 107 of file tlvhelper.c.

Referenced by intframe_tlvconstructor(), and seqnoframe_tlvconstructor().

Here is the caller graph for this function:

guint8 tlv_get_guint8 ( const void *  vitem,
const void *  bufend 
)

Retrieve an unsigned 8 bit integer from the given location with error checking.

Parameters
vitemLocation to get int from
bufendone byte past end of buffer

Definition at line 30 of file tlvhelper.c.

Referenced by _compressframe_isvalid(), _signframe_isvalid(), compressframe_tlvconstructor(), get_cdp_ttl(), get_cdp_vers(), get_lldptlv_len(), get_lldptlv_type(), intframe_tlvconstructor(), and signframe_tlvconstructor().

Here is the caller graph for this function:

void tlv_set_guint16 ( void *  vitem,
guint16  item,
const void *  bufend 
)

Set an unsigned 16 bit integer to the given location with error checking and without caring about byte alignment.

Parameters
vitemLocation to stuff the int into
itemValue to stuff into 'vitem'
bufendone byte past the end of this buffer

Definition at line 68 of file tlvhelper.c.

Referenced by _addrframe_setaddr(), _intframe_updatedata(), _ipportframe_setaddr(), _seqnoframe_updatedata(), cast_frameset_tests(), frame_append_to_frameset_packet(), frameset_construct_packet(), set_generic_tlv_type(), and tlv_set_guint24().

Here is the caller graph for this function:

void tlv_set_guint24 ( void *  vitem,
guint32  item,
const void *  bufend 
)

Set an unsigned 24 bit (3-byte) integer to the given location with error checking and without caring about byte alignment.

This is used for IEEE OUI values.

Todo:
verify that this 3-byte ordering is correct - it has to match the IEEE OUI layout...
Parameters
vitemLocation to stuff the int into
itemValue to stuff into 'vitem'
bufendone byte past the end of this buffer

Definition at line 146 of file tlvhelper.c.

References tlv_set_guint16().

Referenced by _compressframe_updatedata(), _intframe_updatedata(), and set_generic_tlv_len().

Here is the call graph for this function:

Here is the caller graph for this function:

void tlv_set_guint32 ( void *  vitem,
guint32  item,
const void *  bufend 
)

Set an unsigned 32 bit integer to the given location with error checking and without caring about byte alignment.

Parameters
vitemLocation to stuff the int into
itemValue to stuff into 'vitem'
bufendone byte past the end of this buffer

Definition at line 93 of file tlvhelper.c.

Referenced by _intframe_updatedata(), and _seqnoframe_updatedata().

Here is the caller graph for this function:

void tlv_set_guint64 ( void *  vitem,
guint64  item,
const void *  bufend 
)

Set an unsigned 64 bit integer to the given location with error checking and without caring about byte alignment.

Parameters
vitemLocation to stuff the int into
itemValue to stuff into 'vitem'
bufendone byte past the end of this buffer

Definition at line 119 of file tlvhelper.c.

Referenced by _intframe_updatedata(), and _seqnoframe_updatedata().

Here is the caller graph for this function:

void tlv_set_guint8 ( void *  vitem,
guint8  item,
const void *  bufend 
)

Set an unsigned 8 bit integer to the given location with error checking.

Parameters
vitemLocation to stuff the int into
itemValue to stuff into 'vitem'
bufendone byte past the end of this buffer

Definition at line 41 of file tlvhelper.c.

Referenced by _compressframe_updatedata(), _intframe_updatedata(), and _signframe_updatedata().

Here is the caller graph for this function: