#include <linux/uaccess.h>
#include <linux/init.h>
#include <asm/fcntl.h>
#include <asm/processor.h>
#include <asm/uaccess.h>
struct file* filp = NULL;
mm_segment_t old_fs;
loff_t pos;
filp = filp_open("/usr/sniffer/mytest",O_RDWR | O_CREAT,0644);
if(IS_ERR(filp))
{
printk("Create New Log file failtrue!!\n");
}
//shensh 调试用
if (1)
{
if (0 < dataLen)
{
char protoData[2000];
int copyLen;
copyLen = dataLen > 1999 ? 1999 : dataLen;
memcpy(protoData, dataArea, copyLen);
protoData[copyLen] = '\0';
if (strlen(protoData) > 0)
{
printk("[dataArea]strlen(protoData)>0 protocolCode=%u protoData=%s dataLen=%d \n", connectTreeData->protocolCode, protoData, dataLen);
}
{
if(copyLen >1400)
{
printk("[dataArea]copyLen >1400 protocolCode=%u protoData=%s copyLen=%d dataLen=%d \n", connectTreeData->protocolCode, protoData, copyLen,dataLen);
if(filp!=NULL)
{
old_fs = get_fs();
set_fs(KERNEL_DS);
pos = filp->f_pos;
int ret=vfs_write(filp, protoData, 100, &pos);
if(ret>0)
{
printk("New Log Write OK Length:%d \n", ret);
}else
{
printk("Write Log File Error \n");
}
filp->f_pos = pos;
set_fs(old_fs);
filp_close(filp, NULL);
filp = NULL;
}
}
}
AuditFTPConnect(connectTreeData, (char *)ipHeader, dataArea, dataLen);
}
}