/**
* This file is part of license combination gpl version 3 license and eCos.
* The corresponding license terms are below.
*
* gpl version 3 Licence:
*
* The file were developed during the student thesis "Datensammlung in Wireless
* Sensor Networks fuer Autonomic Home NetworkingÒ of Thomas Kothmayr and is
* included in the dissertation "Secure Data Transmission in Wireless
* Sensor Networks" by Corinna Schmitt during employment at the Technische
* UniversitŠt MŸnchen, Department Computer Science, Chair Network
* Architectures and Services (Germany).
* Copyright (C) 2013
* Authors: Thomas Kothmayr and Corinna Schmitt (schmitt[at]net.in.tum.de)
*
* This program 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, version 3 of the License
*
* This program 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 this program. If not, see .
*
*
* eCos Licence: (http://ecos.sourceware.org)
*
* This file is part of eCos, the Embedded Configurable Operating System.
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
* 2007, 2008, 2009 Free Software Foundation, Inc.
*
* eCos 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 any later version.
*
* eCos 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 eCos; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* As a special exception, if other files instantiate templates or use
* macros or inline functions from this file, or you compile this file and * link it with other works to produce a work based on this file, this file
* does not by itself cause the resulting work to be covered by the GNU
* General Public License. However the source code for this file must still
* be made available in accordance with section (3) of the GNU General
* Public License v2.
*
* This exception does not invalidate any other reasons why a work based on
* this file might be covered by the GNU General Public License.
*
*/
Interface: ..ipfix.tinyIPFIX
Interface: ..ipfix.tinyIPFIX
interface tinyIPFIX
This is a implementation of basic IPFIX functionality for TinyOS Motes.
Currently it is supporting multiple Template sets and records in one IPFIX
Message, as well as Multiple Data sets and records in one IPFIX Message.
Option Templates and Fields of variable length are unsupported.
Author:
Thomas Kothmayr <kothmayr@in.tum.de>
Date:
13/08/09
Commands
command ipfixstate_t cancel_data_set (uint8_t bufferno)
Removes an open data set.
command ipfixstate_t cancel_template_record (uint8_t bufferno)
Removes the currently unfinished template record from the buffer.
command ipfixstate_t cancel_template_set (uint8_t bufferno)
Removes the currently unfinished template set from the buffer.
command ipfixstate_t end_data_record (uint8_t bufferno)
completes writing a data record.
command ipfixstate_t end_data_set (uint8_t bufferno)
completes writing a data set.
command ipfixstate_t end_template_record (uint8_t bufferno)
Completes writing a template record.
command ipfixstate_t end_template_set (uint8_t bufferno)
Completes writing a template set.
command ipfixstate_t net_finish_data (uint8_t bufferno)
Prepares the data record for sending by adding the IPFIX Message header.
command ipfixstate_t net_finish_template (uint8_t bufferno)
Prepares the template record for sending by adding the IPFIX Message header.
command ipfixstate_t net_start_data (uint8_t bufferno)
Prepares the data record for sending by adding the IPFIX Message header.
command ipfixstate_t net_start_template (uint8_t bufferno)
Prepares the template record for sending by adding the IPFIX Message header.
command ipfixstate_t put_data_field (uint8_t bufferno, uint8_t *field, uint16_t field_length)
Writes one data field to the data record.
command ipfixstate_t put_data_field16 (uint8_t bufferno, uint16_t field)
Writes a uint16_t to the data set.
command ipfixstate_t put_data_field32 (uint8_t bufferno, uint32_t field)
Writes a uint32_t to the data set.
command ipfixstate_t put_data_field8 (uint8_t bufferno, uint8_t field)
Writes a uint8_t to the data set.
command ipfixstate_t put_data_field_check (uint8_t bufferno, uint8_t template_bufferno, uint8_t *field, uint16_t field_length, uint16_t template_id, uint16_t field_id, uint32_t enterprise_id)
Writes one data field to the data record.
command ipfixstate_t put_data_field_check16 (uint8_t bufferno, uint8_t template_bufferno, uint16_t field, uint16_t template_id, uint16_t field_id, uint32_t enterprise_id)
Writes a uint16_t to the data record.
command ipfixstate_t put_data_field_check32 (uint8_t bufferno, uint8_t template_bufferno, uint32_t field, uint16_t template_id, uint16_t field_id, uint32_t enterprise_id)
Writes a uint32_t to the data record.
command ipfixstate_t put_data_field_check8 (uint8_t bufferno, uint8_t template_bufferno, uint8_t field, uint16_t template_id, uint16_t field_id, uint32_t enterprise_id)
Writes a uint8_t to the data record.
command ipfixstate_t put_template_field (uint8_t bufferno, uint16_t type, uint16_t length, uint32_t enterprise_id)
Writes one field descriptor to the template record.
command ipfixstate_t start_data_record (uint8_t bufferno)
Used to start a new data record.
command ipfixstate_t start_data_set (uint8_t bufferno, uint16_t template_id)
Used to start writing a new data set into the buffer.
command ipfixstate_t start_template_record (uint8_t bufferno, uint16_t template_id)
Start writing a new template record into the specified buffer.
command ipfixstate_t start_template_set (uint8_t bufferno)
Start writing a new template set into the specified buffer.
Events
event void packet_ready (uint8_t *payload, uint16_t payload_length)
An IPFIX Message has been prepared and is ready to be sent over the network card.
Commands - Details
cancel_data_record
command ipfixstate_t cancel_data_record (uint8_t bufferno)
Removes an open data record. Once end_data_record() has
been called it is not possible to remove the data record.
Parameters:
bufferno
- Index of the buffer.
Returns:
SUCCESS if the data set was removed
cancel_data_set
command ipfixstate_t cancel_data_set (uint8_t bufferno)
Removes an open data set. Once end_data_set() has
been called it is not possible to remove the data set.
Parameters:
bufferno
- Index of the buffer.
Returns:
SUCCESS if the data set was removed
cancel_template_record
command ipfixstate_t cancel_template_record (uint8_t bufferno)
Removes the currently unfinished template record from the buffer. Once end_template_record() has
been called, it is not possible to remove the template set.
Parameters:
bufferno
- Index of the buffer.
Returns:
SUCCESS if the template record was removed
cancel_template_set
command ipfixstate_t cancel_template_set (uint8_t bufferno)
Removes the currently unfinished template set from the buffer. Once end_template_set() has
been called, it is not possible to remove the template set.
Parameters:
bufferno
- Index of the buffer.
Returns:
SUCCESS if the template record was removed
end_data_record
command ipfixstate_t end_data_record (uint8_t bufferno)
completes writing a data record.
Parameters:
bufferno
- Index of the buffer.
Returns:
SUCCESS if the currently open record was closed.
end_data_set
command ipfixstate_t end_data_set (uint8_t bufferno)
completes writing a data set.
Parameters:
bufferno
- Index of the buffer.
Returns:
SUCCESS if the currently open set was closed.
end_template_record
command ipfixstate_t end_template_record (uint8_t bufferno)
Completes writing a template record.
Parameters:
bufferno
- Index of the buffer.
Returns:
SUCCESS if the currently open set was closed.
end_template_set
command ipfixstate_t end_template_set (uint8_t bufferno)
Completes writing a template set.
Parameters:
bufferno
- Index of the buffer.
Returns:
SUCCESS if the currently open set was closed.
get_current_templateid
command uint16_t get_current_templateid (uint8_t bufferno)
Returns:
the ID of the current template set
get_next_templateid
command uint16_t get_next_templateid (uint8_t bufferno)
Returns:
The ID of the next template set
net_finish_data
command ipfixstate_t net_finish_data (uint8_t bufferno)
Prepares the data record for sending by adding the IPFIX Message header.
Parameters:
bufferno
- Index of the buffer.
Returns:
SUCCESS
net_finish_template
command ipfixstate_t net_finish_template (uint8_t bufferno)
Prepares the template record for sending by adding the IPFIX Message header.
Parameters:
bufferno
- Index of the buffer.
Returns:
SUCCESS
net_start_data
command ipfixstate_t net_start_data (uint8_t bufferno)
Prepares the data record for sending by adding the IPFIX Message header.
Parameters:
bufferno
- Index of the buffer.
Returns:
SUCCESS
net_start_template
command ipfixstate_t net_start_template (uint8_t bufferno)
Prepares the template record for sending by adding the IPFIX Message header.
Parameters:
bufferno
- Index of the buffer.
Returns:
SUCCESS
put_data_field
command ipfixstate_t put_data_field (uint8_t bufferno, uint8_t *field, uint16_t field_length)
Writes one data field to the data record. This function simply writes the fields in the
order it recieves them. If you want to write values to random positions in the dataset
use the put_data_field_check() command.
Parameters:
bufferno
- Index of the buffer.
field
- pointer to the byte array that contains the field values
field_length
- The length of the data field in byte
Returns:
SUCCESS if the field could be written to the dataset.
put_data_field16
command ipfixstate_t put_data_field16 (uint8_t bufferno, uint16_t field)
Writes a uint16_t to the data set.
Parameters:
bufferno
- Index of the buffer.
field
- value to be written.
Returns:
SUCCESS if the field could be written to the dataset.
put_data_field32
command ipfixstate_t put_data_field32 (uint8_t bufferno, uint32_t field)
Writes a uint32_t to the data set.
Parameters:
bufferno
- Index of the buffer.
field
- value to be written.
Returns:
SUCCESS if the field could be written to the dataset.
put_data_field8
command ipfixstate_t put_data_field8 (uint8_t bufferno, uint8_t field)
Writes a uint8_t to the data set.
Parameters:
bufferno
- Index of the buffer.
field
- value to be written.
Returns:
SUCCESS if the field could be written to the dataset.
put_data_field_check
command ipfixstate_t put_data_field_check (uint8_t bufferno, uint8_t template_bufferno, uint8_t *field, uint16_t field_length, uint16_t template_id, uint16_t field_id, uint32_t enterprise_id)
Writes one data field to the data record. This allows for a random order of
write commands inside of one data record.
Parameters:
bufferno
- Index of the buffer.
template_bufferno
- Index of the buffer which contains the template record against which the call will be checked.
field
- pointer to the byte array that contains the field values
field_length
- The length of the data field in byte
template_id
- ID of the template against which the call will be checked
field_id
- ID of the field which describes the data
enterprise_id
- enterprise ID forthe data field
Returns:
SUCCESS if the field could be written to the data record under the specified constraints.
put_data_field_check16
command ipfixstate_t put_data_field_check16 (uint8_t bufferno, uint8_t template_bufferno, uint16_t field, uint16_t template_id, uint16_t field_id, uint32_t enterprise_id)
Writes a uint16_t to the data record. This allows for a random order of
write commands inside of one data record.
Parameters:
bufferno
- Index of the buffer.
template_bufferno
- Index of the buffer which contains the template record against which the call will be checked.
field
- pointer to the byte array that contains the field values
field_length
- The length of the data field in byte
template_id
- ID of the template against which the call will be checked
field_id
- ID of the field which describes the data
enterprise_id
- enterprise ID forthe data field
Returns:
SUCCESS if the field could be written to the data record under the specified constraints.
put_data_field_check32
command ipfixstate_t put_data_field_check32 (uint8_t bufferno, uint8_t template_bufferno, uint32_t field, uint16_t template_id, uint16_t field_id, uint32_t enterprise_id)
Writes a uint32_t to the data record. This allows for a random order of
write commands inside of one data record.
Parameters:
bufferno
- Index of the buffer.
template_bufferno
- Index of the buffer which contains the template record against which the call will be checked.
field
- pointer to the byte array that contains the field values
field_length
- The length of the data field in byte
template_id
- ID of the template against which the call will be checked
field_id
- ID of the field which describes the data
enterprise_id
- enterprise ID forthe data field
Returns:
SUCCESS if the field could be written to the data record under the specified constraints.
put_data_field_check8
command ipfixstate_t put_data_field_check8 (uint8_t bufferno, uint8_t template_bufferno, uint8_t field, uint16_t template_id, uint16_t field_id, uint32_t enterprise_id)
Writes a uint8_t to the data record. This allows for a random order of
write commands inside of one data record.
Parameters:
bufferno
- Index of the buffer.
template_bufferno
- Index of the buffer which contains the template record against which the call will be checked.
field
- pointer to the byte array that contains the field values
field_length
- The length of the data field in byte
template_id
- ID of the template against which the call will be checked
field_id
- ID of the field which describes the data
enterprise_id
- enterprise ID forthe data field
Returns:
SUCCESS if the field could be written to the data record under the specified constraints.
put_template_field
command ipfixstate_t put_template_field (uint8_t bufferno, uint16_t type, uint16_t length, uint32_t enterprise_id)
Writes one field descriptor to the template record.
Parameters:
bufferno
- Index of the buffer.
type
- The field ID of that describes the datatype that will be send in the data records
length
- The length of the data field in byte
enterprise_id
- The enterprise ID for non standard fieldID. Will only
be written if the enterprise bit (= leftmost bit) of the parameter type equals 1.
Returns:
SUCCESS if the field descriptor could be written to the buffer.
set_template_transmission_timer
command void set_template_transmission_timer (uint32_t timer)
Sets the timer for retransmitting the current templates
Parameters:
timer
- Time in binary milliseconds (=1024 milliseconds per second)
start_data_record
command ipfixstate_t start_data_record (uint8_t bufferno)
Used to start a new data record.
Add fields with put_data_field() or put_data_field_check() and then close the data set with
end_data_set(). This does not check if the specified template has already been send.
Parameters:
bufferno
- Index of the buffer.
template_id
- Used to set the template_id of the current data set
Returns:
SUCCESS if there were no problems with starting a data record.
start_data_set
command ipfixstate_t start_data_set (uint8_t bufferno, uint16_t template_id)
Used to start writing a new data set into the buffer.
Follow by calling start_data_record().
This does not check if the specified template has already been send.
Parameters:
bufferno
- Index of the buffer.
template_id
- Used to set the template_id of the current data set
Returns:
SUCCESS if there were no problems with allocating a data set header in the buffer.
start_template_record
command ipfixstate_t start_template_record (uint8_t bufferno, uint16_t template_id)
Start writing a new template record into the specified buffer.
Add fields with put_template_field() and then close the template set with end_template_record().
Parameters:
bufferno
- Index of the buffer.
template_id
- Used to set the template_id. Use get_next_templateid() to fill in an autogenerated value;
Returns:
SUCCESS if there were no problems with allocating a template set header in the buffer.
start_template_set
command ipfixstate_t start_template_set (uint8_t bufferno)
Start writing a new template set into the specified buffer.
Follow by writing a new template record by calling start_template_record().
Parameters:
bufferno
- Index of the buffer.
Returns:
SUCCESS if there were no problems with allocating a template set header in the buffer.
Events - Details
packet_ready
event void packet_ready (uint8_t *payload, uint16_t payload_length)
An IPFIX Message has been prepared and is ready to be sent over the network card.
Parameters:
payload
- Pointer to the Address of the Payload in memory
payload_length
- Length of the Payload in bytes