diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-03-18 23:56:48 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-03-18 23:56:48 +0100 |
commit | 2b3fe33c07b17b6bbc6515f73aef5efac89fd542 (patch) | |
tree | 9b56d8de707cc72d8bd6f64b3cc73516c652bd73 /src/neigh.h | |
parent | 27389a5a61cfc22c0481150cfc3d6cf1afe3bc51 (diff) | |
download | babel-2b3fe33c07b17b6bbc6515f73aef5efac89fd542.tar babel-2b3fe33c07b17b6bbc6515f73aef5efac89fd542.zip |
Implement hello and IHU sending and receiving
Diffstat (limited to 'src/neigh.h')
-rw-r--r-- | src/neigh.h | 57 |
1 files changed, 57 insertions, 0 deletions
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 <mschiffer@universe-factory.net> + 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_ */ |