From 2b3fe33c07b17b6bbc6515f73aef5efac89fd542 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 18 Mar 2013 23:56:48 +0100 Subject: Implement hello and IHU sending and receiving --- src/neigh.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/neigh.h (limited to 'src/neigh.h') diff --git a/src/neigh.h b/src/neigh.h new file mode 100644 index 0000000..022cffe --- /dev/null +++ b/src/neigh.h @@ -0,0 +1,57 @@ +/* + 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_ */ -- cgit v1.2.3