my $dev = Net::Pcap::lookupdev(\$err);
if (defined $err) {
die 'Unable to determine network device for monitoring - ', $err;
exit;
}
my ($address, $netmask, $err);
if (Net::Pcap::lookupnet($dev, \$address, \$netmask, \$err)) {
die 'Unable to look up device information for ', $dev, ' - ', $err;
}
print STDOUT "Available interfaces; Please select one from the list below:\n\n\t$dev\n\n";
}
else
{
$device=$ARGV[0];
}
# Connect To Database
# Use your own hostname, database, username and password here
#
my $database = "iptraffic";
my $hostname = "localhost";
my $username = "root";
my $password = "";
my $dbh = DBI->connect("DBI:mysql:$database:$hostname", $username, $password);
die "Cannot log into database...\n" unless $dbh;
print "Connected to $database... \n";
pcapinit;
#Subfunctions only
# Initialize the sniffing
sub pcapinit
{
$cap_descrip=Net::Pcap::open_live($device, 2000, 1, 1000, \$err);
if (!$cap_descrip) # If something does not work correctly
{
print "\n Error: $err\n\n";
exit;
}
Net::Pcap::loop($cap_descrip, -1, \&read_packet, "test");
}
# Read and process packets.
# Currently all DATA fields are dropped to save spaces.
# All field definitions come directly from the PM documentation
上一页 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1819 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 下一页
| 论坛热门帖子: | [lch203] 写得蛮好的linux学习笔记(10-21) [黑马制造] 学习java的30个目标(10-19) [笑傲股林] 做测试半年了,有点迷茫,应该再学些什么提高自己的测试水平和测试能力呢?(10-19) [udp8589] 大家用google的来吱一声? 用百度的~~也来报道下?(10-18) [沂偌掳兆] 本人总结的一些认为C++比较经典的书籍,希望对大家有用(10-18) |
| TAG标签: | 格式 图解 my ip_obj- eth_obj- main::proto ip- tcp- |
注册
个人空间
