/*****************************************************************************
*
* Copyright (C) 2001 Uppsala University and Ericsson AB.
*
* 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
*
* Author: Erik Nordstr�m, <erik.nordstrom@it.uu.se>
*
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <linux/sockios.h>
#include <linux/if.h>
#include <linux/wireless.h>
#include <getopt.h>
#include <ctype.h>
#include "defs.h"
#include "debug.h"
#include "timer_queue.h"
#include "params.h"
#include "aodv_socket.h"
#include "aodv_timeout.h"
#include "routing_table.h"
#include "aodv_hello.h"
#include "nl.h"
#ifdef LLFEEDBACK
#include "llf.h"
#endif
/* Global variables: */
int log_to_file = 0;
int rt_log_interval = 0; /* msecs between routing table logging 0=off */
int unidir_hack = 0;
int rreq_gratuitous = 0;
int expanding_ring_search = 1;
int internet_gw_mode = 0;
int local_repair = 0;
int receive_n_hellos = 0;
int hello_jittering = 1;
int optimized_hellos = 0;
int ratelimit = 1; /* Option for rate limiting RREQs and RERRs. */
char *progname;
int wait_on_reboot = 1;
int qual_threshold = 0;
int llfeedback = 0;
int gw_prefix = 1;
struct timer worb_timer; /* Wait on reboot timer */
/* Dynamic configuration values */
int active_route_timeout = ACTIVE_ROUTE_TIMEOUT_HELLO;
int ttl_start = TTL_START_HELLO;
int delete_period = DELETE_PERIOD_HELLO;
static void cleanup();
struct option longopts[] = {
{"interface", required_argument, NULL, 'i'},
{"hello-jitter", no_argument, NULL, 'j'},
{"log", no_argument, NULL, 'l'},
{"n-hellos", required_argument, NULL, 'n'},
{"daemon", no_argument, NULL, 'd'},
{"force-gratuitous", no_argument, NULL, 'g'},
{"opt-hellos", no_argument, NULL, 'o'},
{"quality-threshold", required_argument, NULL, 'q'},
{"log-rt-table", required_argument, NULL, 'r'},
{"unidir_hack", no_argument, NULL, 'u'},
{"gateway-mode", no_argument, NULL, 'w'},
{"help", no_argument, NULL, 'h'},
{"no-expanding-ring", no_argument, NULL, 'x'},
{"no-worb", no_argument, NULL, 'D'},
{"local-repair", no_argument, NULL, 'L'},
{"rate-limit", no_argument, NULL, 'R'},
{"version", no_argument, NULL, 'V'},
{"llfeedback", no_argument, NULL, 'f'},
{0}
};
void usage(int status)
{
if (status != 0) {
fprintf(stderr, "Try `%s --help' for more information.\n", progname);
exit(status);
}
printf
("\nUsage: %s [-dghjlouwxLDRV] [-i if0,if1,..] [-r N] [-n N] [-q THR]\n\n"
"-d, --daemon Daemon mode, i.e. detach from the console.\n"
"-g, --force-gratuitous Force the gratuitous flag to be set on all RREQ's.\n"
"-h, --help This information.\n"
"-i, --interface Network interfaces to attach to. Defaults to first\n"
" wireless interface.\n"
"-j, --hello-jitter Toggle hello jittering (default ON).\n"
"-l, --log Log debug output to %s.\n"
"-o, --opt-hellos Send HELLOs only when forwarding data (experimental).\n"
"-r, --log-rt-table Log routing table to %s every N secs.\n"
"-n, --n-hellos Receive N hellos from host before treating as neighbor.\n"
"-u, --unidir-hack Detect and avoid unidirectional links (experimental).\n"
"-w, --gateway-mode Enable experimental Internet gateway support.\n"
"-x, --no-expanding-ring Disable expanding ring search for RREQs.\n"
"-D, --no-worb Disable 15 seconds wait on reboot delay.\n"
"-L, --local-repair Enable local repair.\n"
"-f, --llfeedback Enable link layer feedback.\n"
"-R, --rate-limit Toggle rate limiting of RREQs and RERRs (default ON).\n"
"-q, --quality-threshold Set a minimum signal quality threshold for control packets.\n"
"-V, --version Show version.\n\n"
"Erik Nordstr�m, <erik.nordstrom@it.uu.se>\n\n",
progname, AODV_LOG_PATH, AODV_RT_LOG_PATH);
exit(status);
}
int set_kernel_options()
{
int i, fd = -1;
char on = '1';
char off = '0';
char command[64];
if ((fd = open("/proc/sys/net/ipv4/ip_forward", O_WRONLY)) < 0)
return -1;
if (write(fd, &on, sizeof(char)) < 0)
return -1;
close(fd);
/*
Disabled for kernel 2.6.28.
if ((fd = open("/proc/sys/net/ipv4/route/max_delay", O_WRONLY)) < 0)
return -1;
if (write(fd, &off, sizeof(char)) < 0)
return -1;
close(fd);
if ((fd = open("/proc/sys/net/ipv4/route/min_delay", O_WRONLY)) < 0)
return -1;
if (write(fd, &off, sizeof(char)) < 0)
return -1;
close(fd);
*/
/* Disable ICMP redirects on all interfaces: */
for (i = 0; i < MAX_NR_INTERFACES; i++) {
if (!DEV_NR(i).enabled)
continue;
memset(command, '\0', 64);
sprintf(command, "/proc/sys/net/ipv4/conf/%s/send_redirects",
DEV_NR(i).ifname);
if ((fd = open(command, O_WRONLY)) < 0)
return -1;
if (write(fd, &off, sizeof(char)) < 0)
return -1;
close(fd);
memset(command, '\0', 64);
sprintf(command, "/proc/sys/net/ipv4/conf/%s/accept_redirects",
DEV_NR(i).ifname);
if ((fd = open(command, O_WRONLY)) < 0)
return -1;
if (write(fd, &off, sizeof(char)) < 0)
return -1;
close(fd);
}
memset(command, '\0', 64);
sprintf(command, "/proc/sys/net/ipv4/conf/all/send_redirects");
if ((fd = open(command, O_WRONLY)) < 0)
return -1;
if (write(fd, &off, sizeof(char)) < 0)
return -1;
close(fd);
memset(command, '\0', 64);
sprintf(command, "/proc/sys/net/ipv4/conf/all/accept_redirects");
if ((fd = open(command, O_WRONLY)) < 0)
return -1;
if (write(fd, &off, sizeof(char)) < 0)
return -1;
close(fd);
return 0;
}
int find_default_gw(void)
{
FILE *route;
char buf[100], *l;
route = fopen("/proc/net/route", "r");
if (route == NULL) {
perror("open /proc/net/route");
exit(-1);
}
while (fgets(buf, sizeof(buf), route)) {
l = strtok(buf, " \t");
l = strtok(NULL, " \t");
if (l != NULL) {
if (strcmp("00000000", l) == 0) {
l = strtok(NULL, " \t");
l = strtok(NULL, " \t");
if (strcmp("0003", l) == 0) {
fclose(route);
return 1;
}
}
}
}
fclose(route);
return 0;
}
/*
* Returns information on a network interface given its name...
*/
struct sockaddr_in *get_if_info(char *ifname, int type)
{
int skfd;
struct sockaddr_in *ina;
static struct ifreq ifr;
/* Get address of interface... */
skfd = socket(AF_INET, SOCK_DGRAM, 0);
strcpy(ifr.ifr_name, ifname);
if (ioctl(skfd, type, &ifr) < 0) {
alog(LOG_ERR, errno, __FUNCTION__,
"Could not get address of %s ", ifname);
close(skfd);
return NULL;
} else {
ina = (struct sockaddr_in *) &ifr.ifr_addr;
close(skfd);
return ina;
}
}
/* This will limit the number of handler functions we can have for
sockets and file descriptors and so on... */
#define CALLBACK_FUNCS 5
static struct callback {
int fd;
callback_func_t func;
} callbacks[CALLBACK_FUNCS];
static int nr_callbacks = 0;
int attach_callback_func(int fd, callback_func_t func)
{
if (nr_callbacks >= CALLBACK_FUNCS) {
fprintf(stderr, "callback attach limit reached!!\n");
exit(-1);
}
没有合适的资源?快使用搜索试试~ 我知道了~
aodv-uu-0.9.6.zip_aodv_aodv-uu_aodv-uu-0.9.6_aodv-uu协议
共75个文件
h:24个
c:23个
patch:8个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 180 浏览量
2022-09-24
04:38:47
上传
评论
收藏 293KB ZIP 举报
温馨提示
aodv路由协议源代码。用c语言编写的aodv路由协议,代码齐全,是网络层编程很好的参考资料。
资源推荐
资源详情
资源评论
收起资源包目录
aodv-uu-0.9.6.zip (75个子文件)
aodv-uu-0.9.6
llf.h 1KB
lnx
kaodv-queue.c 8KB
kaodv-debug.h 2KB
kaodv-netlink.h 4KB
kaodv-ipenc.c 4KB
kaodv-netlink.c 9KB
kaodv-queue.h 1KB
kaodv-expl.h 2KB
kaodv-expl.c 9KB
kaodv-ipenc.h 2KB
TAGS 5KB
Makefile 3KB
kaodv-mod.h 2KB
kaodv-debug.c 1KB
kaodv.h 2KB
kaodv-mod.c 11KB
locality.h 1KB
timer_queue.h 3KB
aodv_rerr.h 2KB
asnt.PS 150KB
asnt.IMB 20KB
aodv_rreq.h 3KB
asnt.PRI 97KB
GPL 18KB
aodv_rrep.h 3KB
main.c 18KB
params.h 3KB
aodv_socket.h 2KB
aodv_timeout.c 7KB
seek_list.h 2KB
aodv_rreq.c 18KB
aodv_neighbor.c 6KB
README.ns 15KB
seek_list.c 3KB
patches
ns-2.27-aodv-uu-0.9.1.patch 21KB
ns-2.29-aodv-uu-0.9.1-dsr-uu-0.2-oolsr-0.99.15.patch 339KB
ns-2.26-aodv-uu-0.8.patch 21KB
ns-2.28-aodv-uu-0.9.1.patch 23KB
ns-2.27-aodv-uu-0.9.patch 21KB
ns-2.27-aodv-uu-0.8.patch 21KB
ns-2.32-aodv-uu.patch 17KB
ns-2.29.3-aodv-uu-0.9.2.patch 18KB
TODO 107B
asnt.PO 776B
aodv_rerr.c 6KB
asnt.IAD 888B
aodv_hello.c 8KB
asnt.PFI 196B
aodv_rrep.c 12KB
aodv_socket.c 15KB
README 11KB
list.c 2KB
timer_queue.c 5KB
nl.h 1KB
asnt.SearchResults 504B
TAGS 13KB
asnt.IAB 56KB
list.h 2KB
llf.c 10KB
debug.h 2KB
aodv_hello.h 2KB
debug.c 11KB
Makefile 7KB
defs.h 6KB
routing_table.h 4KB
ChangeLog 10KB
locality.c 2KB
aodv_timeout.h 1KB
routing_table.c 15KB
asnt.WK3 99KB
asnt.IMD 528B
endian.c 2KB
nl.c 14KB
asnt.PR 15KB
aodv_neighbor.h 1KB
共 75 条
- 1
资源评论
四散
- 粉丝: 49
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功