/** * 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.chips.rf230.Neighborhood

Interface: tos.chips.rf230.Neighborhood

interface Neighborhood

Every component maintains its own neighborhood data. The Neighboorhood component maintains only the nodeids and ages of the neighbors, and evicts old entries from the table when necessary.

Commands
command uint8_t getAge(uint8_t index) Returns the age of the given entry.
command uint8_t getIndex(am_addr_t id) Returns the index of the neighbor in the table.
command am_addr_t getNode(uint8_t index) Returns the node address for the given entry.
command uint8_t insertNode(am_addr_t id) Adds a new node into the neighborhood table.

Events
event void evicted(uint8_t index) This event is fired when the oldest entry is replaced with a new node.

Commands - Details

getAge

command uint8_t getAge(uint8_t index)

Returns the age of the given entry. The age is incremented by one every time a new node is inserted into the neighborhood table that is not already at the very end. If the age would get too large to fit into a byte, then it is periodically reset to a smaller value.

getIndex

command uint8_t getIndex(am_addr_t id)

Returns the index of the neighbor in the table. If the node was not found in the table, then the value NEIGHBORHOOD is returned, otherwise an index in the range [0, NEIGHBORHOOD-1] is returned.

getNode

command am_addr_t getNode(uint8_t index)

Returns the node address for the given entry.

insertNode

command uint8_t insertNode(am_addr_t id)

Adds a new node into the neighborhood table. If this node was already in the table, then it is just brought to the front (its age is reset to zero). If the node was not in the table, then the oldest is evicted and its entry is replaced with this node. The index of the entry is returned in the range [0, NEIGHBORHOOD-1].

Events - Details

evicted

event void evicted(uint8_t index)

This event is fired when the oldest entry is replaced with a new node. The same interface is used by many users, so all of them will receive this event and can clear the corresponding entry. After this event is fired, all flags for this entry are cleared (see the NeighborhoodFlag interface)