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

📄 defs.h

📁 支持IPv6的adov路由协议(本人修改后)
💻 H
字号:
/***************************************************************************** * * Copyright (C) 2001 Uppsala University & Ericsson AB. * Copyright (C) 2003 Simon Fraser University and NewMIC * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * * Authors: Erik Nordstr鰉, <erik.nordstrom@it.uu.se> *        : Peter Lee       <peter.lee@shaw.ca> * *****************************************************************************/#ifndef DEFS_H#define DEFS_H#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <sys/time.h>#include <sys/types.h>#include <sys/signal.h>#include <netinet/in.h>#include <arpa/inet.h>#include <netinet/ip.h>#include <sys/ioctl.h>#include <syslog.h>#include <errno.h>#include <string.h>#include <fcntl.h>#ifndef NS_PORT#include "timer_queue.h"#endif#ifdef NS_PORT#define NS_CLASS AODVUU::#define NS_OUTSIDE_CLASS ::#define NS_STATIC/* NS_PORT: Using network device 0, with interface index 0. */#define NS_DEV_NR 0#define NS_IFINDEX NS_DEV_NR#else#define NS_CLASS#define NS_OUTSIDE_CLASS#define NS_STATIC static#endif#define AODV_UU_VERSION "0.5"//PL: new define for IPv6#ifdef _IPV6#define AODV6_UU_SFU_VERSION "0.1"#endif#ifdef NS_PORT/* NS_PORT: Log filename split into prefix and suffix. */#define AODV_LOG_PATH_PREFIX "aodv-uu_"#define AODV_RT_LOG_PATH_PREFIX "aodv-uu_rt_"#define AODV_LOG_PATH_SUFFIX ".log"#define AODV_RT_LOG_PATH_SUFFIX AODV_LOG_PATH_SUFFIX#else//PL: Different log file for IPv6#ifdef _IPV6#define AODV6_LOG_PATH "/var/log/aodvd6.log"#define AODV6_RT_LOG_PATH "/var/log/aodvd6_rt.log"#else#define AODV_LOG_PATH "/var/log/aodvd.log"#define AODV_RT_LOG_PATH "/var/log/aodvd_rt.log"#endif /* _IPV6 */#endif				/* NS_PORT */#define INFTY 0xff#define IS_INFTY(x) ((x & INFTY) == INFTY) ? 1 : 0#define max(A,B) ( (A) > (B) ? (A):(B))#define MINTTL 1		/* min TTL in the packets sent locally */#define MAX_NR_INTERFACES 10#define MAX_IFINDEX (MAX_NR_INTERFACES - 1)//PL: because /usr/include/net/if.h also define IFNAMSIZ#ifndef IFNAMSIZ#define IFNAMSIZ 16#endif/* Data for a network device */struct dev_info {    int enabled;		/* 1 if struct is used, else 0 */    int sock;			/* AODV socket associated with this device */    unsigned int ifindex;    char ifname[IFNAMSIZ];/* PL: Change it to IPv6 Address */#ifdef _IPV6    struct in6_addr ipaddr;		// The local IP address    unsigned int prefix_len;            // Prefix Lenght    struct in6_addr multicast;          // Multicast address    int plen;                           // PL:Use plen instead of netmask     struct in6_addr gateway_mcast;      // internet gateway multicast address    //struct in6_addr netmask;		// The netmask we use    //struct in6_addr broadcast;        //PL: IPv6 doesn't have broadcast#else    u_int32_t ipaddr;		// The local IP address    u_int32_t netmask;		// The netmask we use    u_int32_t broadcast;#endif // "_IPV6"};struct host_info {    u_int32_t seqno;		/* Sequence number */    struct timeval bcast_time;	/* The time of the last broadcast msg sent */    u_int32_t rreq_id;		/* RREQ id */    int gateway_mode;    int nif;			/* Number of interfaces to broadcast on */    struct dev_info devs[MAX_NR_INTERFACES];};/*  NS_PORT: TEMPORARY SOLUTION: Moved the two variables into the AODVUU class,  and placed the function definition after the AODVUU class declaration.  (Don't want to run lots of passes through defs.h...)  TODO: Find some smarter way to accomplish this.*/#ifndef NS_PORT/* This will point to a struct containing information about the host */struct host_info this_host;/* Array of interface indexes */unsigned int dev_indices[MAX_NR_INTERFACES];/* Given a network interface index, return the index into the   devs array, Necessary because ifindex is not always 0, 1,   2... */static inline int ifindex2devindex(unsigned int ifindex){    int i;    for (i = 0; i < this_host.nif; i++)	if (dev_indices[i] == ifindex)	    return i;    return -1;}/*ZJH*/static inline int name2index(char *name){    int i;    for (i = 0; i < this_host.nif; i++)	if (strcmp(name, this_host.devs[i].ifname) == 0)	    return this_host.devs[i].ifindex;        return -1;}#endif/* Two macros to simplify retriving of a dev_info struct. Either using   an ifindex or a device number (index into devs array). */#define DEV_IFINDEX(ifindex) (this_host.devs[ifindex2devindex(ifindex)])#define DEV_NR(n) (this_host.devs[n]) /* Broadcast address according to draft (255.255.255.255) */#define AODV_BROADCAST 0xFFFFFFFF//PL: IPv6 Multicase (Not sure what to put yet, so put all 1 for now)#define IPV6_ALL_MANET_NODES { { { 0xff,0x05,0,0,0,0,0,0,0,0,0,0,0,0,0,0x11 } } }extern struct in6_addr ipv6_multicast_addr;//PL: IPV6 default address#define IPV6_DEFAULT_ADDR { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }extern struct in6_addr ipv6_default_addr;//Gateway multicast address#define ALL_MANET_GW_MULTICAST {{{ 0xff,0x1e,0,0,0,0,0,0,0,0,0,0,0,0,0,0x11 }}}extern struct in6_addr gateway_mcast_addr;extern struct in6_addr gw_global_addr;#define IPV6_DEST_DEFAULT     { { { 0x20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }#define IPV6_DEST_DEFAULT_PLEN 3extern struct in6_addr ipv6_dest_default;#define AODV_PORT 654/* AODV Message types */#ifdef _IPV6#define AODV_RREQ     16#define AODV_RREP     17#define AODV_RERR     18 /* PL: Put 18 for now since the draft put TBD */#define AODV_RREP_ACK 19#define AODV_AREQ      20#define AODV_AREP      21#else#define AODV_HELLO    0		/* Really never used as a separate type... */#define AODV_RREQ     1#define AODV_RREP     2#define AODV_RERR     3#define AODV_RREP_ACK 4#endif /* _IPV6 *//* A generic AODV packet header struct... */#ifdef NS_PORTstruct AODV_msg {#elsetypedef struct {#endif    u_int8_t type;/* NS_PORT: Additions for the AODVUU packet type in ns-2 */#ifdef NS_PORT    static int offset_;		// Required by PacketHeaderManager    inline static int &offset() {	return offset_;    } inline static AODV_msg *access(const Packet * p) {	return (AODV_msg *) p->access(offset_);    }    int size();};typedef AODV_msg hdr_aodvuu;	// Name convention for headers#define HDR_AODVUU(p) ((hdr_aodvuu *) hdr_aodvuu::access(p))#else} AODV_msg;#endif/* AODV Extension types */#define RREQ_EXT 1#define RREP_EXT 1#define RREP_HELLO_INTERVAL_EXT 2#define RREP_HELLO_NEIGHBOR_SET_EXT 3/* An generic AODV extensions header */typedef struct {    u_int8_t type;    u_int8_t length;    /* Type specific data follows here */} AODV_ext;/* MACROS to access AODV extensions... */#define AODV_EXT_HDR_SIZE sizeof(AODV_ext)#define AODV_EXT_DATA(ext) ((AODV_ext *)((char *)ext + AODV_EXT_HDR_SIZE))#define AODV_EXT_NEXT(ext) ((AODV_ext *)((char *)ext + AODV_EXT_HDR_SIZE + ext->length))#define AODV_EXT_SIZE(ext) (AODV_EXT_HDR_SIZE + ext->length)#ifndef NS_PORT/* The callback function */typedef void (*callback_func_t) (int);extern int attach_callback_func(int fd, callback_func_t func);#endif#define GW_FIND_NO_NEED 0  /*don't need find gateway*/#define GW_FIND_NEED     1  /*need find gateway*/#define GW_FINDING       2  /*finding gateway*/extern int gw_find_flag;extern struct in6_addr if_link_addr;#endif				/* DEFS_H */

⌨️ 快捷键说明

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