没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
#include "sysinclude.h"
#include <string.h>
extern void rip_sendIpPkt(unsigned char* pData, UINT16 len, unsigned short dstPort, UINT8 iNo);/*RIP包的发送函数*/
extern struct stud_rip_route_node *g_rip_route_table;/*路由表*/
typedef struct _packet_header /*RIP数据包的头部*/
{
unsigned char command;/*命令只能是REQUEST或者RESONSE*/
unsigned char version;/*版本号,1或者2*/
unsigned short pad0;/*置零*/
} packet_header;
typedef struct _packet_data/*RIP数据包*/
{
unsigned short addrfamily;/*地址族,必须为2*/
unsigned short routetag;/*路由标记*/
unsigned int ipaddr;/*IP地址*/
unsigned int netmask;/*掩码*/
unsigned int nexthop;/*下一跳*/
unsigned int metric;/*跳数*/
} packet_data;
#define DECLAREERROR(pkt,type) {printf("Discard because %d\n",type);ip_DiscardPkt(pkt,type);return 0;}/*定义RIP包出错时的返回类型*/
unsigned char buffer[256];/*缓冲区*/
void dumpPkt(unsigned char*buf,int len)/*实现数据提取功能*/
{
printf("Dumping sending packets:\n");
int l=0;
for (int i=0;i<len;i++)
#include <string.h>
extern void rip_sendIpPkt(unsigned char* pData, UINT16 len, unsigned short dstPort, UINT8 iNo);/*RIP包的发送函数*/
extern struct stud_rip_route_node *g_rip_route_table;/*路由表*/
typedef struct _packet_header /*RIP数据包的头部*/
{
unsigned char command;/*命令只能是REQUEST或者RESONSE*/
unsigned char version;/*版本号,1或者2*/
unsigned short pad0;/*置零*/
} packet_header;
typedef struct _packet_data/*RIP数据包*/
{
unsigned short addrfamily;/*地址族,必须为2*/
unsigned short routetag;/*路由标记*/
unsigned int ipaddr;/*IP地址*/
unsigned int netmask;/*掩码*/
unsigned int nexthop;/*下一跳*/
unsigned int metric;/*跳数*/
} packet_data;
#define DECLAREERROR(pkt,type) {printf("Discard because %d\n",type);ip_DiscardPkt(pkt,type);return 0;}/*定义RIP包出错时的返回类型*/
unsigned char buffer[256];/*缓冲区*/
void dumpPkt(unsigned char*buf,int len)/*实现数据提取功能*/
{
printf("Dumping sending packets:\n");
int l=0;
for (int i=0;i<len;i++)
{
printf("%02x ",(unsigned int)buf[i]);
l++;
if (l++==15)/*l应该小于16*/
{
printf("\n");
l=0;
}
}
printf("\n");
}
void MakePacket(char version, UINT8 iNo)/*该函数实现组装RIP数据包*/
{
stud_rip_route_node *pnow=g_rip_route_table;
/*发送数据包时满足:1.端口必须不相同2.跳数必须小于16*/
while (pnow&&(pnow->if_no==iNo||pnow->metric==16))
pnow=pnow->next;
/*遍历并复制路由链表*/
do
{
/*组装RIP数据包的头部*/
packet_header*ph=(packet_header*)buffer;
ph->command=2; /*响应(RESPONSE)分组*/
ph->version=version; /*版本号*/
ph->pad0=0; /*必须为0*/
/*组装数据包*/
int pCount=0;
while (pCount<25&&pnow)/*一个数据包最多能容纳25条记录*/
{
packet_data*pd=(packet_data*)(buffer+sizeof(packet_header));
printf("%02x ",(unsigned int)buf[i]);
l++;
if (l++==15)/*l应该小于16*/
{
printf("\n");
l=0;
}
}
printf("\n");
}
void MakePacket(char version, UINT8 iNo)/*该函数实现组装RIP数据包*/
{
stud_rip_route_node *pnow=g_rip_route_table;
/*发送数据包时满足:1.端口必须不相同2.跳数必须小于16*/
while (pnow&&(pnow->if_no==iNo||pnow->metric==16))
pnow=pnow->next;
/*遍历并复制路由链表*/
do
{
/*组装RIP数据包的头部*/
packet_header*ph=(packet_header*)buffer;
ph->command=2; /*响应(RESPONSE)分组*/
ph->version=version; /*版本号*/
ph->pad0=0; /*必须为0*/
/*组装数据包*/
int pCount=0;
while (pCount<25&&pnow)/*一个数据包最多能容纳25条记录*/
{
packet_data*pd=(packet_data*)(buffer+sizeof(packet_header));
剩余6页未读,继续阅读
p02569
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Python的图像阴影检测与去除源码(高分期末大作业项目).zip
- 基于C++/Qt实现的井字棋游戏
- 基于 Python 编程语言的 Web 框架Django
- Python和Flask实现的基于体检数据的城市公共健康可视分析系统源码+使用说明.zip
- 基于python实现的华为智慧工地-安全帽检测
- buck-boost_2023-12-16_12-12-13.eprj
- 后端开发关于数据库和API开发的介绍
- 机器学习和数据挖掘课程设计-米其林餐厅数据挖掘管理系统源码+使用文档说明.zip
- html html html展示我与ai的对化
- 数据结构课程设计-全国交通出行咨询模拟系统C语言实现源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页