/** * 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: tos.interfaces.Packet

Interface: tos.interfaces.Packet

interface Packet

The basic message data type accessors. Protocols may use additional packet interfaces for their protocol specific data/metadata.

Author:
Philip Levis
Date:
January 5 2005
See:
TEP 116: Packet Protocols

Commands
command void clear(message_t *msg) Clear out this packet.
command void *getPayload(message_t *msg, uint8_t len) Return a pointer to a protocol's payload region in a packet.
command uint8_t maxPayloadLength() Return the maximum payload length that this communication layer can provide.
command uint8_t payloadLength(message_t *msg) Return the length of the payload of msg.
command void setPayloadLength(message_t *msg, uint8_t len) Set the length field of the packet.

Commands - Details

clear

command void clear(message_t *msg)

Clear out this packet. Note that this is a deep operation and total operation: calling clear() on any layer will completely clear the packet for reuse.

Parameters:
'message_t* ONE msg' the packet to clear

getPayload

command void *getPayload(message_t *msg, uint8_t len)

Return a pointer to a protocol's payload region in a packet. If the caller intends to write to the payload region then the len parameter must reflect the maximum required length. If the caller (only) wants to read from the payload region, then len may be set to the value of payloadLength(). If the payload region is smaller than len this command returns NULL. The offset where the payload region starts within a packet is fixed, i.e. for a given msg this command will always return the same pointer or NULL.

Parameters:
'message_t* ONE msg' the packet
len - the length of payload required
Returns:
'void* COUNT_NOK(len)' a pointer to the packet's data payload for this layer or NULL if len is too big

maxPayloadLength

command uint8_t maxPayloadLength()

Return the maximum payload length that this communication layer can provide. Note that, depending on protocol fields, a given request to send a packet may not be able to send the maximum payload length (e.g., if there are variable length fields). Protocols may provide specialized interfaces for these circumstances.

Returns:
the maximum size payload allowed by this layer

payloadLength

command uint8_t payloadLength(message_t *msg)

Return the length of the payload of msg. This value may be less than what maxPayloadLength() returns, if the packet is smaller than the MTU. If a communication component does not support variably sized data regions, then payloadLength() will always return the same value as maxPayloadLength().

Parameters:
'message_t* ONE msg' the packet to examine
Returns:
the length of its current payload

setPayloadLength

command void setPayloadLength(message_t *msg, uint8_t len)

Set the length field of the packet. This value is not checked for validity (e.g., if it is larger than the maximum payload size). This command is not used when sending packets, as calls to send include a length parameter. Rather, it is used by components, such as queues, that need to buffer requests to send. This command allows the component to store the length specified in the request and later recover it when actually sending.

Parameters:
'message_t* ONE msg' the packet
len - the value to set its length field to