⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aodv.h

📁 一种AODV实现方法
💻 H
字号:
#ifndef AODV_H#define AODV_H#include <linux/if_ether.h>#include <linux/if.h>#define AODVPORT               654#define TRUE		1#define FALSE 		0#define MAX(a,b) (((a)>(b))?(a):(b))#define ACTIVE_ROUTE_TIMEOUT   3000#define ALLOWED_HELLO_LOSS     3#define DELETE_PERIOD           MAX((ACTIVE_ROUTE_TIMEOUT),((ALLOWED_HELLO_LOSS)*(HELLO_INTERVAL)))#define HELLO_INTERVAL         1000#define MY_ROUTE_TIMEOUT       2 * (ACTIVE_ROUTE_TIMEOUT)#define NET_DIAMETER           35#define NET_TRAVERSAL_TIME 3 * NODE_TRAVERSAL_TIME * NET_DIAMETER / 2#define NEXT_HOP_WAIT          (NODE_TRAVERSAL_TIME) + 10#define NODE_TRAVERSAL_TIME    50#define PATH_TRAVERSAL_TIME  2 * NET_TRAVERSAL_TIME#define RREQ_RETRIES           2#define TTL_START              1#define TTL_INCREMENT          2#define TTL_THRESHOLD           7#define RREQ                   1#define RREP                   2#define RERR                   3#define EVENT_RREQ 1#define EVENT_RREP 2#define EVENT_RERR 3#define EVENT_RREP_ACK 4#define EVENT_HELLO 102#define EVENT_CLEANUP 101#define EVENT_NEIGHBOR 103#define FLAGS_ALL 255u_int8_t	USE_LO;char g_block_dev[8];char g_aodv_dev[8];u_int32_t g_aodv_subnet;// Route tablestruct route_table_entry{    u_int32_t dst_ip;    u_int32_t dst_seq;    u_int32_t old_dst_seq;    u_int8_t hop_count;    u_int32_t next_hop;    struct precursor_entry *precursors;    u_int64_t lifetime;    struct net_device *dev;    u_int8_t link;u_int8_t	route_valid:1;u_int8_t	route_seq_valid:1;    struct route_table_entry *next;    struct route_table_entry *prev;    u_int32_t rreq_id;u_int8_t self_route:1;};struct precursor_entry{    u_int32_t ip;    struct precursor_entry *next;    struct precursor_entry *prev;    int ishead;};// Used to stores a list of the different interfacesstruct interface_list_entry{    struct net_device * dev;    struct route_table_entry *route_entry;    int	index;    u_int32_t	ip;    char	name[IFNAMSIZ];    struct interface_list_entry *next;    struct socket *sock;    u_int64_t last_hello;    u_int64_t last_broadcast;};struct neighbor_list_entry{    u_int32_t	ip;    u_int64_t	lifetime;    unsigned char hw_addr[ETH_ALEN];    struct net_device *dev;    struct route_table_entry *route_entry;    u_int8_t link;    struct neighbor_list_entry *next;};struct rreq_id_queue_entry{    u_int32_t          src_ip;    u_int32_t dst_ip;    u_int32_t          rreq_id;    u_int64_t          lifetime;    struct rreq_id_queue_entry *prev;    struct rreq_id_queue_entry *next;};//Used to queue events which Aodv Thread has to act onstruct event_queue_entry{    u_int32_t dst_ip;    u_int32_t src_ip;    struct net_device	 *dev;    int       type;    int       size;    int 	id;    u_int8_t	ttl;    void	*data;    u_int64_t time;    unsigned char src_hw_addr[ETH_ALEN];    struct event_queue_entry *next;};struct timer_queue_entry{    u_int64_t tv;  /* Time the event should happend in ms since 1 jan 1970 */    int size;    u_int32_t id;  /* An id used to match one or a group of entrys */    u_int8_t ttl;    u_int16_t	retries;    unsigned char flags;  /* Flag which represents what's in the dataportion */    struct timer_queue_entry *next;  /* A pointer to the next entry in the list */    void *data;    /* Data stored in the entry */};//Route reply message typestruct rrep_ack{    u_int8_t type;    u_int8_t reserved;};struct rrep{    u_int8_t     type;#if defined(__BIG_ENDIAN_BITFIELD)unsigned int r:1;unsigned int a:1;unsigned int reserved1:6;unsigned int reserved2:3;unsigned int prefix_sz:5;#elif defined(__LITTLE_ENDIAN_BITFIELD)unsigned int reserved1:6;unsigned int r:1;unsigned int a:1;unsigned int prefix_sz:5;unsigned int reserved2:3;#else#error "Please fix <asm/byteorder.h>"#endif    u_int8_t     hop_count;    u_int32_t    dst_ip;    u_int32_t    dst_seq;    u_int32_t    src_ip;    u_int32_t    lifetime;};//Endian handling based on DSR implemetation by Alex Song s369677@student.uq.edu.austruct rreq{    u_int8_t     type;#if defined(__BIG_ENDIAN_BITFIELD)u_int8_t  j:1;u_int8_t  r:1;u_int8_t  g:1;u_int8_t  d:1;u_int8_t  u:1;u_int8_t  reserved:3;#elif defined(__LITTLE_ENDIAN_BITFIELD)u_int8_t  reserved:3;u_int8_t  u:1;u_int8_t  d:1;u_int8_t  g:1;u_int8_t  r:1;u_int8_t  j:1;#else#error "Please fix <asm/byteorder.h>"#endif    u_int8_t second_reserved;    u_int8_t     hop_count;    u_int32_t    rreq_id;    u_int32_t    dst_ip;    u_int32_t    dst_seq;    u_int32_t    src_ip;    u_int32_t    src_seq;};// An unreacable destination, contained in an RERRstruct rerr_unr_dst{    u_int32_t unr_dst_ip;    u_int32_t unr_dst_seq;    struct rerr_unr_dst *next;};struct rerrhdr{    u_int8_t type;    unsigned int dst_count;    struct rerr_unr_dst *unr_dst;};struct rerr{    u_int8_t type;#if defined(__BIG_ENDIAN_BITFIELD)unsigned int n:1;unsigned int reserved:15;#elif defined(__LITTLE_ENDIAN_BITFIELD)unsigned int reserved:15;unsigned int n:1;#else#error "Please fix <asm/byteorder.h>"#endifunsigned int dst_count:8;};struct rerrdst{    u_int32_t unr_dst_ip;    u_int32_t unr_dst_seq;};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -