资源简介
代码包括OLSR协议的C++代码实现,以及OLSRD的实现,其实就是你们搜到的olsrd协议实现程序或者olsrd-0.5.6-r4.rar。
代码片段和文件信息
/*
* NetsimPcap - a userspace network bridge with simulated packet loss
* Copyright 2008 H. Rogge (rogge@fgan.de)
*
* 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 3 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 see .
*/
#include
#include
#include
#include “config.h“
#include “debug.h“
/*
* stripString
*
* this function strips leading and trailing whitespaces from a string
*
* @param string to strip
* @return stripped string
*/
char *
stripString(char *str)
{
/* strip left whitespaces */
while (*str == ‘ ‘ || *str == ‘\t‘) {
str++;
}
/* strip right whitespaces */
int i = strlen(str);
while (--i >= 0) {
if (str[i] == ‘ ‘ || str[i] == ‘\r‘ || str[i] == ‘\n‘ || str[i] == ‘\t‘) {
str[i] = 0;
break;
}
}
return str;
}
/*
* readConnectionMatrix
*
* This function reads the network settings and place them in the
* connection matrix (float array with size “len“ x “len“.
*
* @param pointer to begin of connection matrix
* @param pointer to filename
* @param number of elements in each connection matrix line
* @return 0 if function was successfull 1 if an error happened
*/
int
readConnectionMatrix(float *connectionMatrix char *filename int len)
{
FILE *file = fopen(filename “r“);
if (!file) {
return 1;
}
char buffer[1024];
while (fgets(buffer 1024 file)) {
int from to;
float propability;
char *line = stripString(buffer);
DPRINT(“%s\n“ line);
if (line[0] == ‘#‘ || line[0] == 0) {
continue;
}
if (sscanf(line “%d %d %f“ &from &to &propability) != 3) {
continue;
}
if (from < 0 || from >= len || to < 0 || to >= len || from == to) {
continue;
}
connectionMatrix[GRID(from to len)] = propability;
if (connectionMatrix[GRID(to from len)] == 0) {
connectionMatrix[GRID(to from len)] = propability;
}
}
fclose(file);
return 0;
}
/*
* Local Variables:
* c-basic-offset: 2
* indent-tabs-mode: nil
* End:
*/
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 12049 2009-02-21 18:48 olsrd-0.5.6-r4\.cproject
文件 2356 2009-02-21 18:48 olsrd-0.5.6-r4\.project
文件 63899 2009-03-26 22:34 olsrd-0.5.6-r4\CHANGELOG
文件 35147 2009-02-02 03:54 olsrd-0.5.6-r4\contrib\netsimpcap\LICENCE
文件 311 2009-02-02 03:54 olsrd-0.5.6-r4\contrib\netsimpcap\Makefile
文件 54 2009-02-02 03:54 olsrd-0.5.6-r4\contrib\netsimpcap\sampleconf.txt
文件 2590 2009-02-02 03:57 olsrd-0.5.6-r4\contrib\netsimpcap\src\config.c
文件 1048 2009-02-02 03:57 olsrd-0.5.6-r4\contrib\netsimpcap\src\config.h
文件 1368 2009-02-02 03:57 olsrd-0.5.6-r4\contrib\netsimpcap\src\debug.h
文件 9833 2009-02-02 03:57 olsrd-0.5.6-r4\contrib\netsimpcap\src\netsimpcap.c
文件 5328 2009-02-02 03:57 olsrd-0.5.6-r4\contrib\netsimpcap\src\network_tap.c
文件 1127 2009-02-02 03:57 olsrd-0.5.6-r4\contrib\netsimpcap\src\network_tap.h
文件 43 2009-02-02 03:54 olsrd-0.5.6-r4\contrib\README
文件 1061 2009-02-02 03:54 olsrd-0.5.6-r4\features.txt
文件 1690 2009-02-02 03:54 olsrd-0.5.6-r4\files\olsrd.8.gz
文件 4755 2009-03-26 23:58 olsrd-0.5.6-r4\files\olsrd.conf.5.gz
文件 10979 2009-03-26 22:16 olsrd-0.5.6-r4\files\olsrd.conf.default.lq
文件 10980 2009-03-26 22:17 olsrd-0.5.6-r4\files\olsrd.conf.default.lq-fisheye
文件 11040 2009-03-26 22:15 olsrd-0.5.6-r4\files\olsrd.conf.default.rfc
文件 721 2009-02-02 03:54 olsrd-0.5.6-r4\files\olsr_switch.8.gz
文件 1268 2009-02-02 03:54 olsrd-0.5.6-r4\gcc-warnings
文件 1133 2009-02-02 03:57 olsrd-0.5.6-r4\gnu-indent.sh
文件 895 2009-02-02 03:54 olsrd-0.5.6-r4\gui\linux-gtk\CHANGELOG
文件 361 2009-02-02 03:54 olsrd-0.5.6-r4\gui\linux-gtk\Makefile
文件 1093 2009-02-02 03:57 olsrd-0.5.6-r4\gui\linux-gtk\README
文件 5656 2009-02-02 03:57 olsrd-0.5.6-r4\gui\linux-gtk\src\callbacks.c
文件 3612 2009-02-02 03:57 olsrd-0.5.6-r4\gui\linux-gtk\src\common.h
文件 38225 2009-02-02 03:57 olsrd-0.5.6-r4\gui\linux-gtk\src\interface.c
文件 2130 2009-02-02 03:57 olsrd-0.5.6-r4\gui\linux-gtk\src\interface.h
文件 17029 2009-02-02 03:57 olsrd-0.5.6-r4\gui\linux-gtk\src\ipc.c
............此处省略575个文件信息
- 上一篇:C++学生宿舍管理系统
- 下一篇:mfc通过鼠标移动画线
相关资源
- 超级玛丽c++代码(经典小游戏)
- GMM C++代码
- 数据结构课程设计(C++代码+报告)
- DICOM图片转换BMP的C++代码
- QSplat:基于点绘制的图形学开山之作
- 飞行棋c++代码
- Delphi2Cppdelphi代码转换为C++代码
- snake算法的C++代码
- 外卖管理系统含界面C++代码
- TLD 全C++代码 OpenCV3.0.0 VS2013 工程文件
- Microsoft+VisualC++6.0代码提示插件
- 史上最全C++代码
- Visual C++代码 获取本地网络信息
- 操作系统文件管理C++代码实现
- DX9.0小游戏C++代码
- 傅里叶变换和傅里叶逆变换的C++代码
- 课程设计---c++代码相似度计算
- 遥感图像融合C++代码
- 控制网平差C++代码实现
- C++:面向对象程序设计陈良银 李涛
- 基于opencv的傅里叶描述子VC++代码
- 《数据结构与算法C++版实验和课程设
- 倍福TwinCAT3上位机与PLC通信测试(AD
- k-means的C++代码vs
- 82道华为校招历年机试编程题C++代码附
- 用于图像边缘提取的prewitt算子的C++代
- 经典手眼标定算法C++代码
- 简单实现凯撒密码的c++代码
- 信息网络 双机通信 C++代码
- 中文分词C++代码
评论
共有 条评论