/* Copyright (c) 2012, Matthias Schiffer All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _GMRF_PROTO_BABEL_NEIGH_H_ #define _GMRF_PROTO_BABEL_NEIGH_H_ #include "babel.h" static inline gp_babel_neigh_t* gp_babel_neigh_find(const gp_babel_iface_t *iface, const gmrf_addr_t *addr) { gp_babel_neigh_t *neigh; for (neigh = iface->neighbours; neigh; neigh = neigh->next) { if (gmrf_addr_equal(addr, &neigh->addr)) return neigh; } return NULL; } static inline void gp_babel_neigh_ref(gp_babel_neigh_t *neigh) { neigh->ref++; } gp_babel_neigh_t* gp_babel_neigh_get(gp_babel_iface_t *iface, const gmrf_addr_t *addr); void gp_babel_neigh_unref(gp_babel_neigh_t *neigh); void gp_babel_neigh_unref_list(gp_babel_neigh_t *neigh); uint16_t gp_babel_neigh_get_rxcost(gmrf_t *gmrf, const gp_babel_neigh_t *neigh); uint16_t gp_babel_neigh_get_txcost(gmrf_t *gmrf, const gp_babel_neigh_t *neigh); uint16_t gp_babel_neigh_get_cost(gmrf_t *gmrf, const gp_babel_neigh_t *neigh); void gp_babel_neigh_reset(gp_babel_iface_t *iface, gp_babel_neigh_t *neigh); #endif /* _GMRF_PROTO_BABEL_NEIGH_H_ */