j = 0;
/*open device 'mem' as a media to access the RAM*/
fd=open("/dev/mem",O_RDWR);
fd_procaddr = open("/proc/nf_addr",O_RDONLY);
read(fd_procaddr,addr,9);
ADDR = atol(addr);
close(fd_procaddr);
printf("%u[%8lx]\n",ADDR,ADDR);
/*Map the address in kernel to user space, use mmap function*/
su1_2 = mmap(0,PAGES*4*1024, PROT_READ PROT_WRITE, MAP_SHARED, fd, ADDR);
perror("mmap");
while(1)
{
bzero(receive,1500);
i = get_mem(su1_2,receive,&size);
if (i != 0)
{
j++;
printf("%d:%s[size = %d]\n",j,receive,size);
}
else
{
printf("there have no data\n");
munmap(su1_2,PAGES*4*1024);
close(fd);
break;
}
}
while(1);
}
五.參考文獻(xiàn)
1.CHRISTIAN KURMANN, FELIX RAUCH ,THOMAS M. STRICKER.
Speculative Defragmentation - Leading Gigabit Ethernet to True Zero-Copy Communication
2.ALESSANDRO RUBINI,JONATHAN CORBET.《LINUX DEVICE DRIVERS 2》,O’Reilly & Associates 2002.
3.胡希明,毛德操.《LINUX 內(nèi)核源代碼情景分析》,浙江大學(xué)出版社 2001
關(guān)于作者:梁健,華北計(jì)算技術(shù)研究所在讀碩士研究生,研究方向:信息安全。論文開(kāi)題為《基于系統(tǒng)調(diào)用分析的主機(jī)異常入侵檢測(cè)與防御》。對(duì)IDS有兩年多的研究經(jīng)驗(yàn),熟悉linux內(nèi)核,熟悉linux c/c++編程、win32 API編程,對(duì)網(wǎng)絡(luò)和操作系統(tǒng)安全感興趣。