Micro implementation of the AODV ad hoc routing protocol
#include <stdio.h>
#include <stdarg.h>
#include "contiki.h"
#include "net/ipv4/uaodv-def.h"
#include "net/ipv4/uaodv-rt.h"
#include "net/ipv4/uaodv.h"
#include "lib/assert.h"
Macros | |
#define | add_rreq_extensions(p) 0 /* Don't add anything */ |
#define | BUF ((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN]) |
#define | MY_NET_DIAMETER 20 |
#define | MY_ROUTE_TIMEOUT 0x7fffffff /* Should be 0xffffffff! */ |
#define | NDEBUG |
#define | NFWCACHE 16 |
#define | print_debug(...) do{}while(0) |
#define | PRINTF(...) do {} while (0) |
#define | SCMP32(a, b) ((int32_t)((a) - (b))) |
#define | uip_udp_sender() (&BUF->srcipaddr) |
Enumerations | |
enum | { COMMAND_NONE, COMMAND_SEND_RREQ, COMMAND_SEND_RERR } |
Functions | |
static CC_INLINE void | fwc_add (const uip_ipaddr_t *orig, const uint32_t *id) |
static CC_INLINE int | fwc_lookup (const uip_ipaddr_t *orig, const uint32_t *id) |
static void | handle_incoming_packet (void) |
static void | handle_incoming_rerr (void) |
static void | handle_incoming_rrep (void) |
static void | handle_incoming_rreq (void) |
static CC_INLINE uint32_t | last_known_seqno (uip_ipaddr_t *host) |
PROCESS (uaodv_process,"uAODV") | |
PROCESS_THREAD (uaodv_process, ev, data) | |
static void | send_rerr (uip_ipaddr_t *addr, uint32_t *seqno) |
static void | send_rrep (uip_ipaddr_t *dest, uip_ipaddr_t *nexthop, uip_ipaddr_t *orig, uint32_t *seqno, unsigned hop_count) |
static void | send_rreq (uip_ipaddr_t *addr) |
static void | sendto (const uip_ipaddr_t *dest, const void *buf, int len) |
void | uaodv_bad_dest (uip_ipaddr_t *dest) |
struct uaodv_rt_entry * | uaodv_request_route_to (uip_ipaddr_t *host) |
Variables | |
static uip_ipaddr_t | bad_dest |
static uint32_t | bad_seqno |
static struct uip_udp_conn * | bcastconn |
static enum { ... } | command |
struct { | |
uint32_t id | |
uip_ipaddr_t orig | |
} | fwcache [NFWCACHE] |
static uint32_t | my_hseqno |
static struct timer | next_time |
static uip_ipaddr_t | rreq_addr |
static uint32_t | rreq_id |
static struct uip_udp_conn * | unicastconn |
#define add_rreq_extensions | ( | p | ) | 0 /* Don't add anything */ |
Referenced by handle_incoming_rreq(), and send_rreq().
#define BUF ((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN]) |
Referenced by handle_incoming_rerr(), handle_incoming_rrep(), and handle_incoming_rreq().
#define MY_NET_DIAMETER 20 |
Referenced by send_rreq().
#define MY_ROUTE_TIMEOUT 0x7fffffff /* Should be 0xffffffff! */ |
Referenced by send_rrep().
#define NDEBUG |
#define NFWCACHE 16 |
Referenced by fwc_add(), and fwc_lookup().
Referenced by handle_incoming_rerr(), handle_incoming_rrep(), handle_incoming_rreq(), send_rerr(), send_rrep(), and send_rreq().
#define SCMP32 | ( | a, | |
b | |||
) | ((int32_t)((a) - (b))) |
Referenced by handle_incoming_rerr(), handle_incoming_rrep(), and handle_incoming_rreq().
#define uip_udp_sender | ( | ) | (&BUF->srcipaddr) |
Referenced by handle_incoming_rerr(), handle_incoming_rrep(), and handle_incoming_rreq().
|
static |
References fwcache, id, n, NFWCACHE, uip_ip6addr_t::u8, and uip_ipaddr_copy.
Referenced by handle_incoming_rreq().
|
static |
References fwcache, n, NFWCACHE, uip_ip6addr_t::u8, and uip_ipaddr_cmp.
Referenced by handle_incoming_rreq().
|
static |
References handle_incoming_rerr(), handle_incoming_rrep(), handle_incoming_rreq(), uaodv_msg::type, UAODV_RERR_TYPE, UAODV_RREP_TYPE, UAODV_RREQ_TYPE, and uip_appdata.
Referenced by PROCESS_THREAD().
|
static |
References uaodv_msg_rerr::addr, BUF, uaodv_msg_rerr::flags, uaodv_rt_entry::hseqno, uaodv_rt_entry::is_bad, uaodv_rt_entry::nexthop, NULL, print_debug, rt, SCMP32, uaodv_msg_rerr::seqno, UAODV_RERR_UNKNOWN, uaodv_rt_lookup_any(), uip_appdata, uip_hostaddr, uip_htonl(), uip_ipaddr_cmp, uip_ipaddr_to_quad, uip_ntohl, uip_udp_packet_send(), uip_udp_sender, and uaodv_msg_rerr::unreach.
Referenced by handle_incoming_packet().
|
static |
References BUF, uaodv_msg_rrep::dest_addr, uaodv_msg_rrep::dest_seqno, uaodv_msg_rrep::flags, uaodv_msg_rrep::hop_count, uaodv_rt_entry::hseqno, my_hseqno, uaodv_rt_entry::nexthop, NULL, uaodv_msg_rrep::orig_addr, print_debug, uaodv_msg_rrep_ack::reserved, ret, rt, SCMP32, send_rrep(), sendto(), uaodv_msg_rrep_ack::type, UAODV_RREP_ACK, UAODV_RREP_ACK_TYPE, uaodv_rt_add(), uaodv_rt_lookup(), uip_appdata, uip_broadcast_addr, uip_hostaddr, uip_htonl(), uip_ipaddr_cmp, uip_ipaddr_to_quad, uip_ntohl, and uip_udp_sender.
Referenced by handle_incoming_packet().
|
static |
References add_rreq_extensions, uaodv_bad_hop_ext::addrs, BUF, uaodv_msg_rreq::dest_addr, uaodv_msg_rreq::dest_seqno, end, uaodv_msg_rreq::flags, fwc_add(), fwc_lookup(), uaodv_rt_entry::hop_count, uaodv_msg_rreq::hop_count, uaodv_rt_entry::hseqno, len, uaodv_bad_hop_ext::length, my_hseqno, uaodv_rt_entry::nexthop, NULL, uaodv_msg_rreq::orig_addr, uaodv_msg_rreq::orig_seqno, print_debug, ret, RREQ_BAD_HOP_EXT, uaodv_msg_rreq::rreq_id, rt, SCMP32, send_rrep(), uip_udp_conn::ttl, uaodv_bad_hop_ext::type, UAODV_RREQ_DESTONLY, UAODV_RREQ_UNKSEQNO, uaodv_rt_add(), uaodv_rt_lookup(), uip_appdata, uip_hostaddr, uip_htonl(), uip_ipaddr_cmp, uip_ipaddr_copy, uip_ipaddr_to_quad, uip_len, uip_ntohl, uip_udp_packet_send(), and uip_udp_sender.
Referenced by handle_incoming_packet().
|
static |
References uaodv_rt_entry::hseqno, NULL, uaodv_rt_lookup_any(), and uip_htonl().
Referenced by send_rreq().
PROCESS | ( | uaodv_process | , |
"uAODV" | |||
) |
PROCESS_THREAD | ( | uaodv_process | , |
ev | , | ||
data | |||
) |
References command, COMMAND_NONE, COMMAND_SEND_RERR, COMMAND_SEND_RREQ, handle_incoming_packet(), my_hseqno, NULL, printf, PROCESS_BEGIN, PROCESS_END, PROCESS_EVENT_MSG, PROCESS_EXITHANDLER, PROCESS_WAIT_EVENT, send_rerr(), send_rreq(), tcpip_event, tcpip_poll_udp(), uaodv_rt_flush_all(), uaodv_rt_lookup(), UAODV_UDPPORT, udp_broadcast_new(), UIP_HTONS, uip_newdata, uip_poll, and uip_udp_remove.
|
static |
References uaodv_msg_rerr::addr, uaodv_msg_rerr::dest_count, uaodv_msg_rerr::flags, print_debug, uaodv_msg_rerr::reserved, uaodv_msg_rerr::seqno, uaodv_msg_rerr::type, UAODV_RERR_TYPE, UAODV_RERR_UNKNOWN, uip_appdata, uip_ipaddr_copy, uip_ipaddr_to_quad, uip_udp_packet_send(), and uaodv_msg_rerr::unreach.
Referenced by PROCESS_THREAD().
|
static |
References uaodv_msg_rrep::dest_addr, uaodv_msg_rrep::dest_seqno, uaodv_msg_rrep::flags, uaodv_msg_rrep::hop_count, uaodv_msg_rrep::lifetime, MY_ROUTE_TIMEOUT, uaodv_msg_rrep::orig_addr, uaodv_msg_rrep::prefix_sz, print_debug, sendto(), uaodv_msg_rrep::type, UAODV_RREP_TYPE, uip_appdata, UIP_HTONL, uip_ipaddr_copy, and uip_ipaddr_to_quad.
Referenced by handle_incoming_rrep(), and handle_incoming_rreq().
|
static |
References add_rreq_extensions, uaodv_msg_rreq::dest_addr, uaodv_msg_rreq::dest_seqno, uaodv_msg_rreq::flags, uaodv_msg_rreq::hop_count, last_known_seqno(), len, my_hseqno, MY_NET_DIAMETER, uaodv_msg_rreq::orig_addr, uaodv_msg_rreq::orig_seqno, print_debug, uaodv_msg_rreq::reserved, rreq_id, uaodv_msg_rreq::rreq_id, uip_udp_conn::ttl, uaodv_msg_rreq::type, UAODV_RREQ_TYPE, UAODV_RREQ_UNKSEQNO, uip_appdata, uip_gethostaddr, uip_htonl(), uip_ipaddr_copy, uip_ipaddr_to_quad, and uip_udp_packet_send().
Referenced by PROCESS_THREAD().
|
static |
References uip_udp_conn::ripaddr, uip_ipaddr_copy, uip_udp_packet_send(), and unicastconn.
void uaodv_bad_dest | ( | uip_ipaddr_t * | dest | ) |
struct uaodv_rt_entry* uaodv_request_route_to | ( | uip_ipaddr_t * | host | ) |
|
static |
|
static |
|
static |
enum { ... } command |
Referenced by PROCESS_THREAD(), uaodv_bad_dest(), and uaodv_request_route_to().
struct { ... } fwcache[NFWCACHE] |
Referenced by fwc_add(), and fwc_lookup().
uint32_t id |
Referenced by ethernetif_init(), fwc_add(), handle_incoming_reg(), hid_get_reportchar(), hid_serv_def_init(), hid_serv_get_instance(), hid_serv_init(), hid_serv_report_update(), hid_service_dbreg(), NWK_OpenEndpoint(), rtc_tamper_get_config_defaults(), servreg_hack_lookup(), and servreg_hack_register().
|
static |
Referenced by handle_incoming_rrep(), handle_incoming_rreq(), PROCESS_THREAD(), and send_rreq().
|
static |
Referenced by uaodv_request_route_to().
uip_ipaddr_t orig |
|
static |
|
static |
Referenced by send_rreq().
|
static |
Referenced by sendto().