File: leaktest6.pl

package info (click to toggle)
libnet-pcap-perl 0.21-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 636 kB
  • sloc: perl: 2,155; pascal: 830; ansic: 5; makefile: 3
file content (39 lines) | stat: -rw-r--r-- 705 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/perl -w
#
# Test for memory leaks in stats() function
#
# $Id: leaktest6.pl,v 1.3 1999/05/05 02:11:59 tpot Exp $
#

use strict;
use English;

use ExtUtils::testlib;
use Net::Pcap;

die("Must run as root!\n"), if ($UID != 0);

my($dev, $err, $pcap_t);

$dev = Net::Pcap::lookupdev(\$err);
$pcap_t = Net::Pcap::open_live($dev, 1024, 1, 0, \$err);

if (!defined($pcap_t)) {
    die("Net::Pcap::open_live returned error $err");
}

my $count;

sub process_pkt {
    my($user, $hdr, $pkt) = @_;
    my(%stats);

    $count++;

    Net::Pcap::stats($pcap_t, \%stats);

    print("$count\n"), if (($count % 1000) == 0);
}

Net::Pcap::loop($pcap_t, 0, \&process_pkt, "1234");
Net::Pcap::close($pcap_t);