int main()
{
char *su1_2;
char receive[1500];
int i,j;
int fd;
int fd_procaddr;
unsigned int size;
char addr[9];
unsigned long ADDR;
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);
}
五.参考文献
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 内核源代码情景分析》,浙江大学出版社 2001
关于作者:梁健,华北计算技术研究所在读硕士研究生,研究方向:信息安全。论文开题为《基于系统调用分析的主机异常入侵检测与防御》。对IDS有两年多的研究经验,熟悉linux内核,熟悉linux c/c++编程、win32 API编程,对网络和操作系统安全感兴趣。作者: allen 时间: 2005-3-4 14:12