xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 64KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-06-08
  • 語(yǔ)言: 其他
  • 標(biāo)簽: 靜態(tài)路由??linux??

資源簡(jiǎn)介

在linux環(huán)境下模擬了基本的靜態(tài)路由,網(wǎng)絡(luò)搭建在幾臺(tái)虛擬機(jī)之間。

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?

#define?MAX_ROUTE_INFO?8;
#define?MAX_ARP_SIZE?8;
#define?MAX_DEVICE?4;
#define?BUFFER_MAX?2048

typedef?struct?route_item{
unsigned?int?destination;
unsigned?int?gateway;
unsigned?int?netmask;
unsigned?char?interface[14];
};
struct?route_item?route_info[8];
int?route_item_index;

typedef?struct?arp_table_item{
unsigned?int?ip_addr;
unsigned?char?mac_addr[6];
};
struct?arp_table_item?arp_table[8];
int?arp_item_index;

typedef?struct?device_item{
unsigned?char?interface[14];
unsigned?char?mac_addr[6];
unsigned?int?ip_addr;
};
struct?device_item?device[4];
int?device_index;


/*初始化函數(shù),首先是把你的靜態(tài)路由信息添加到你的route_info[]這個(gè)數(shù)組中
??我在自己機(jī)器上時(shí)如下添加的,具體情況根據(jù)你的網(wǎng)絡(luò)拓?fù)淝闆r添加
??參照l(shuí)inux自帶的路由結(jié)構(gòu),destination表示的是目的網(wǎng)絡(luò)號(hào),gateway表示要經(jīng)過(guò)
??的網(wǎng)關(guān),如果為零說(shuō)明已經(jīng)到達(dá)最后一個(gè)路由節(jié)點(diǎn),下一條就是目的地,netmask:
??用來(lái)提取目的網(wǎng)絡(luò)號(hào):實(shí)際操作時(shí)把netmask?和?ip報(bào)文內(nèi)的目的地址進(jìn)行按位與操???
??作,然后把結(jié)果同當(dāng)前的目的網(wǎng)絡(luò)號(hào)對(duì)比
??下面說(shuō)一下device[]這個(gè)數(shù)組,它用來(lái)存放路由的網(wǎng)卡信息的,比如說(shuō)你在終端中輸
??入ifconfig后,會(huì)出現(xiàn)一些網(wǎng)卡的信息,比如說(shuō)eth0,在里面找到MAC和IP,填入我
??的device[]數(shù)組中
*/

void?initial()
{
route_item_index?=?3;
route_info[0].destination?=?inet_addr(“192.168.2.0“);
route_info[0].gateway?=?inet_addr(“192.168.1.2“);
route_info[0].netmask?=?inet_addr(“255.255.255.0“);
strcpy(route_info[0].interface?“eth0“);

route_info[1].destination?=?inet_addr(“192.168.1.0“);
route_info[1].gateway?=?0;
route_info[1].netmask?=?inet_addr(“255.255.255.0“);
strcpy(route_info[1].interface?“eth0“);

route_info[2].destination?=?inet_addr(“192.168.0.0“);
route_info[2].gateway?=?0;
route_info[2].netmask?=?inet_addr(“255.255.255.0“);
strcpy(route_info[2].interface?“eth1“);


arp_item_index?=?0;

device_index?=?2;
strcpy(device[0].interface?“eth0“);
device[0].mac_addr[0]?=?0X00;
device[0].mac_addr[1]?=?0X0C;
device[0].mac_addr[2]?=?0X29;
device[0].mac_addr[3]?=?0XE3;
device[0].mac_addr[4]?=?0X25;
device[0].mac_addr[5]?=?0X86;
device[0].ip_addr?=?inet_addr(“192.168.1.1“);


strcpy(device[1].interface?“eth1“);
device[1].mac_addr[0]?=?0X00;
device[1].mac_addr[1]?=?0X0C;
device[1].mac_addr[2]?=?0X29;
device[1].mac_addr[3]?=?0XE3;
device[1].mac_addr[4]?=?0X25;
device[1].mac_addr[5]?=?0X90;
device[1].ip_addr?=?inet_addr(“192.168.0.1“);
};

void?UpdateArpTable(unsigned?char?Iface[]?int?n?unsigned?int?target)
{
int?sockfdij;
sockfd?=?socket(PF_INET?SOCK_PACKET?htons(ETH_P_ARP));

char?buffer[BUFFER_MAX];
struct?sockaddr?tofrom;
int?fromlen=sizeof(struct?sockaddr);
strcpy(to.sa_dataIface);
strcpy(from.sa_dataIface);
char?datagram[BUFFER_MAX];
struct?ethhdr?*eth_header?=?datagram;
struct?arphdr?*arp_header?=?datagram?+?sizeof(struct?ethhdr);
memset?(datagram?0?BUFFER_MAX);

for(i?=?0;i? eth_header->h_dest[i]?=?0XFF;
int?flag;
for(i?=?0;i? if(strcmp(Iface

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

????.CA....??????9148??2010-04-12?22:36??route.c

????.CA....?????65334??2009-12-14?02:19??實(shí)驗(yàn)4?靜態(tài)路由編程實(shí)現(xiàn).docx

-----------?---------??----------?-----??----

????????????????74482????????????????????2


評(píng)論

共有 條評(píng)論

相關(guān)資源