r48272 - in /branches/upstream/libpoe-component-pcap-perl: ./ current/ current/debian/ current/eg/ current/t/

opensides-guest at users.alioth.debian.org opensides-guest at users.alioth.debian.org
Sat Dec 5 19:35:39 UTC 2009


Author: opensides-guest
Date: Sat Dec  5 19:35:35 2009
New Revision: 48272

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=48272
Log:
[svn-inject] Installing original source of libpoe-component-pcap-perl

Added:
    branches/upstream/libpoe-component-pcap-perl/
    branches/upstream/libpoe-component-pcap-perl/current/
    branches/upstream/libpoe-component-pcap-perl/current/CHANGES
    branches/upstream/libpoe-component-pcap-perl/current/MANIFEST
    branches/upstream/libpoe-component-pcap-perl/current/Makefile.PL
    branches/upstream/libpoe-component-pcap-perl/current/Pcap.pm
    branches/upstream/libpoe-component-pcap-perl/current/README
    branches/upstream/libpoe-component-pcap-perl/current/debian/
    branches/upstream/libpoe-component-pcap-perl/current/debian/changelog
    branches/upstream/libpoe-component-pcap-perl/current/debian/compat
    branches/upstream/libpoe-component-pcap-perl/current/debian/control
    branches/upstream/libpoe-component-pcap-perl/current/debian/copyright
    branches/upstream/libpoe-component-pcap-perl/current/debian/rules   (with props)
    branches/upstream/libpoe-component-pcap-perl/current/debian/watch
    branches/upstream/libpoe-component-pcap-perl/current/eg/
    branches/upstream/libpoe-component-pcap-perl/current/eg/ArpWatch.pm
    branches/upstream/libpoe-component-pcap-perl/current/eg/awtest
    branches/upstream/libpoe-component-pcap-perl/current/t/
    branches/upstream/libpoe-component-pcap-perl/current/t/01basic.t

Added: branches/upstream/libpoe-component-pcap-perl/current/CHANGES
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-pcap-perl/current/CHANGES?rev=48272&op=file
==============================================================================
--- branches/upstream/libpoe-component-pcap-perl/current/CHANGES (added)
+++ branches/upstream/libpoe-component-pcap-perl/current/CHANGES Sat Dec  5 19:35:35 2009
@@ -1,0 +1,65 @@
+$Id: CHANGES,v 1.3 2003/07/08 15:19:53 fletch Exp $
+
+============
+Things to do
+============
+
+Fix / figure out why setting O_NONBLOCK confuzzles pcap on OpenBSD.
+
+================================================
+Revision history for POE::Component::Pcap
+================================================
+
+Changes marked with "(!!!)" may break backward compatibility.  Changes
+marked with "(???)" are just information.
+
+Note to self: Don't forget to tag the version after a new distribution
+is released.  For example: `cvs tag -Rc v1_00 .'
+
+---------------
+0.04 2003.07.08
+---------------
+
+Fixed bugs.cpan.org #1663 (a while back actually, just got around to
+packaging).
+
+Updated things to work with POE 0.26 (removed _signal).
+
+Tested (minimally :) on:
+
+FreeBSD i386 5.0, perl 5.6.1 
+Linux i386 RH9.0, perl 5.8.0 
+
+---------------
+0.03 2001.03.06
+---------------
+
+Michael Stevens noticed that NetPacket::Ethernet wasn't in the list of
+required packages.  D'oh.
+
+---------------
+0.02 2001.02.16
+---------------
+
+First Public Release.  Has an actual working test script.
+
+OpenBSD i386 2.8
+Linux i386 RH6.2
+Solaris Sparc 2.7
+
+---------------
+0.01 2000.11.28
+---------------
+
+Initial version.  Versioned at 0.01 because it's relatively untested.
+Has at least been run on (and seen packets :) the following:
+
+OpenBSD i386 2.7 
+Linux i386 RH6.2
+Solaris Sparc 2.7
+
+Additions to the list are welcome.
+
+===========================
+EOF: Thank you for reading.
+===========================

Added: branches/upstream/libpoe-component-pcap-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-pcap-perl/current/MANIFEST?rev=48272&op=file
==============================================================================
--- branches/upstream/libpoe-component-pcap-perl/current/MANIFEST (added)
+++ branches/upstream/libpoe-component-pcap-perl/current/MANIFEST Sat Dec  5 19:35:35 2009
@@ -1,0 +1,9 @@
+# $Id: MANIFEST,v 1.1.1.1 2001/02/16 14:35:51 fletch Exp $
+CHANGES
+Pcap.pm
+MANIFEST
+Makefile.PL
+README
+t/01basic.t
+eg/ArpWatch.pm
+eg/awtest

Added: branches/upstream/libpoe-component-pcap-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-pcap-perl/current/Makefile.PL?rev=48272&op=file
==============================================================================
--- branches/upstream/libpoe-component-pcap-perl/current/Makefile.PL (added)
+++ branches/upstream/libpoe-component-pcap-perl/current/Makefile.PL Sat Dec  5 19:35:35 2009
@@ -1,0 +1,20 @@
+#!/usr/bin/perl
+# $Id: Makefile.PL,v 1.3 2003/07/08 15:39:01 fletch Exp $
+
+use ExtUtils::MakeMaker;
+
+WriteMakefile
+  ( NAME         => 'POE::Component::Pcap',
+    AUTHOR       => 'Mike Fletcher <fletch+poe at phydeaux.org>',
+    ABSTRACT     => 'POE component for non-blocking use of Net::Pcap.',
+    VERSION_FROM => 'Pcap.pm',
+
+    PM           => { 'Pcap.pm' => '$(INST_LIBDIR)/Pcap.pm' },
+    PREREQ_PM    => { POE      => 0.26,
+                      Net::Pcap => 0.04,
+		      NetPacket::Ethernet => 0.01,
+                    },
+    dist         => { COMPRESS => 'gzip -9f',
+                      SUFFIX   => 'gz',
+                    },
+  );

Added: branches/upstream/libpoe-component-pcap-perl/current/Pcap.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-pcap-perl/current/Pcap.pm?rev=48272&op=file
==============================================================================
--- branches/upstream/libpoe-component-pcap-perl/current/Pcap.pm (added)
+++ branches/upstream/libpoe-component-pcap-perl/current/Pcap.pm Sat Dec  5 19:35:35 2009
@@ -1,0 +1,405 @@
+#!/usr/bin/perl
+##
+## $Id: Pcap.pm,v 1.3 2003/07/08 15:09:54 fletch Exp $
+##
+package POE::Component::Pcap;
+
+use strict;
+use Carp qw( croak carp );
+
+$POE::Component::Pcap::VERSION = q{0.04};
+
+use POE;
+
+use Symbol qw( gensym );
+
+use IO::Handle;
+use Fcntl qw( F_GETFL F_SETFL O_NONBLOCK );
+
+use Net::Pcap;
+
+##
+## POE::Component::Pcap->spawn(
+##			       [ Alias => 'pcap' ],
+##			       [ Device => 'eth0' ],
+##			       [ Filter => 'pcap filter' ],
+##			       [ Dispatch => dispatch_state ],
+##			       [ Session => dispatch_session ],
+##			      )
+##
+sub spawn {
+  my $class = shift;
+  my %args = @_;
+
+  ## Set default alias if none was given
+  $args{ Alias } ||= 'pcap';
+
+  POE::Session->create(
+		       inline_states => {
+					 _start => \&_start,
+					 _stop => \&_stop,
+#					 _signal => \&_signal,
+					 open_live => \&open_live,
+					 set_filter => \&set_filter,
+					 set_dispatch => \&set_dispatch,
+					 run => \&run,
+					 pause => \&pause,
+					 _dispatch => \&_dispatch,
+					 shutdown => \&shutdown,
+					},
+		       args => [
+				$args{Alias},	# ARG0
+				$args{Filter},	# ARG1
+				$args{Session}, # ARG2
+				$args{Dispatch},# ARG3
+				$args{Device},	# ARG4
+			       ],
+		      );
+
+  return $args{ Alias };
+}
+
+sub _start {
+  my ($kernel, $heap, $session,
+      $alias, $filter, $target_session, $target_state, $device )
+    = @_[ KERNEL, HEAP, SESSION, ARG0..ARG4 ];
+
+#  print "In state_start for sid ", $session->ID, ", alias $alias\n";
+
+  ## Set alias for ourselves and remember it
+  $kernel->alias_set( $alias );
+  $heap->{Alias} = $alias;
+
+
+  ## Set dispatch target session and state if it was given
+  if( defined( $target_state ) ) {
+    $heap->{'target_session'} = $target_session;
+    $heap->{'target_state'} = $target_state;
+  }
+
+  ## Post an open_live event if device was passed
+  $kernel->post( $session => open_live => $device )
+    if defined( $device );
+
+  ## Set filter if it was given
+  $kernel->post( $session => set_filter => $filter )
+    if defined( $filter );
+
+#  print "Out state_start for sid ", $session->ID, ", alias $alias\n";
+}
+
+##
+## $kernel->post( pcap => open_live =>
+##		  [device], [snaplen], [promisc?], [timeout] )
+##
+sub open_live {
+  my ( $kernel, $heap,
+       $device, $snaplen, $promisc, $timeout,
+     ) = @_[ KERNEL, HEAP, ARG0..ARG3 ];
+
+  my $err;
+
+  ## Lookup default device if undef was passed
+  unless( $device ) {
+    $device = Net::Pcap::lookupdev( \$err )
+      or croak "Can't lookupdev: $err\n";
+  }
+
+  ## Set `reasonable' defaults for other values
+  $snaplen = 80 unless defined( $snaplen );
+  $promisc = 1 unless defined( $promisc );
+  $timeout = 100 unless defined( $timeout );
+
+  $heap->{'pcap_t'} = Net::Pcap::open_live( $device, $snaplen,
+					    $promisc, $timeout, \$err )
+    or croak "Can't Net::Pcap::open_live $device: $err\n";
+
+  @{$heap}{ qw/device snaplen
+	       promisc timeout fd/ } =
+		 (
+		  $device, $snaplen, $promisc,
+		  $timeout,
+		  Net::Pcap::fileno( $heap->{'pcap_t'} ),
+		 );
+
+=pod
+
+  ## Need an IO::Handle to $kernel->select_read() upon
+  $heap->{fdh} = IO::Handle->new_from_fd( $heap->{fd}, "r" )
+    or die "Can't create IO::Handle from pcap fd: $!\n";
+
+=cut
+
+  $heap->{fdh} = gensym;
+  open( $heap->{fdh}, "<&".$heap->{fd} )
+    or die "Can't dup handle from pcap fd: $!\n";
+
+  1;
+}
+
+sub set_filter {
+  my ( $kernel, $heap, $filter ) = @_[ KERNEL, HEAP, ARG0 ];
+
+  croak "open must be called before set_filter \n"
+    unless exists $heap->{'pcap_t'};
+
+  my( $net, $netmask, $err );
+  Net::Pcap::lookupnet( $heap->{'device'}, \$net, \$netmask, \$err );
+
+  my $filter_t;
+  Net::Pcap::compile( $heap->{'pcap_t'},
+		      \$filter_t, $filter, 1, $netmask ) == 0
+			or die "Can't compile filter `$filter'\n";
+
+  Net::Pcap::setfilter( $heap->{'pcap_t'}, $filter_t );
+}
+
+##
+## $kernel->post( pcap => set_dispatch =>
+##		  'target_state', 'target_session' )
+##
+sub set_dispatch {
+  my ( $heap, $sender, $target_state, $target_session )
+    = @_[ HEAP, SENDER, ARG0, ARG1 ];
+
+  ## Target session defaults to the sender
+  $target_session ||= $sender;
+
+  if( defined( $target_state ) ) {
+    ## Remember whom to forward packets to
+    $heap->{'target_session'} = $target_session;
+    $heap->{'target_state'} = $target_state;
+  } else {
+    ## Clear target
+    delete $heap->{'target_session'};
+    delete $heap->{'target_state'};
+  }
+}
+
+sub run {
+  my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
+
+  my $flags;
+
+  ## Can't run unless we've got a pcap_t to work with
+  croak "open must be called before run \n"
+    unless exists $heap->{'pcap_t'};
+
+  ## XXX Need to save off flags for OpenBSD
+  if( $^O eq 'openbsd' ) {
+    $flags = fcntl($heap->{fdh}, F_GETFL, 0)
+      or croak "fcntl fails with F_GETFL: $!\n";
+  }
+
+  $kernel->select_read( $heap->{fdh} => '_dispatch' );
+
+  ## XXX OpenBSD's pcap / bpf devices don't like being set to
+  ## non-blocking for some reason, so restore the saved flags
+  if( $^O eq 'openbsd' ) {
+    $flags = fcntl($heap->{fdh}, F_SETFL, $flags )
+      or croak "fcntl fails with F_SETFL: $!\n";
+  }
+
+}
+
+sub _dispatch {
+  my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
+
+  if( exists $heap->{'target_session'} ) {
+    my @pending;
+
+    ## Get Pcap to pass us any pending packets
+    Net::Pcap::dispatch( $heap->{'pcap_t'}, -1,
+			 sub {
+			   push @{$_[0]}, [ @_[1,2] ]
+			 },
+			 \@pending
+		       );
+
+    $kernel->post( $heap->{'target_session'},
+		   $heap->{'target_state'},
+		   \@pending,
+		 );
+  }
+}
+
+sub pause {
+  ## Remove read select on pcap handle
+  $_[KERNEL]->select_read( $_[HEAP]->{fdh} ) if exists $_[HEAP]->{fdh};
+}
+
+sub shutdown {
+  my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
+
+  ## Remove read select on pcap handle
+  $kernel->select_read( $heap->{fdh} ) if exists $heap->{fdh};
+
+  ## Get Net::Pcap to shut down pcap_t
+  if( exists $heap->{'pcap_t'} ) {
+    Net::Pcap::close( $heap->{'pcap_t'} );
+    delete @{$heap}{qw/pcap_t fd fdh/}
+  }
+
+  $kernel->alias_remove( $heap->{Alias} );
+}
+
+sub _stop {
+  my ( $kernel, $heap, $session ) = @_[ KERNEL, HEAP, SESSION ];
+  my $alias = $heap->{Alias};
+
+#  print "In state_stop for sid ", $session->ID, ", alias $alias\n";
+
+#  print "Out state_stop for sid ", $session->ID, ", alias $alias\n";
+}
+
+sub _signal {
+  my ( $kernel, $heap, $session ) = @_[ KERNEL, HEAP, SESSION ];
+
+#  print "Got signal ", $_[ARG0], "\n";
+
+  return 1;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+POE::Component::Pcap - POE Interface to Net::Pcap
+
+=head1 SYNOPSIS
+
+  use POE::Component::Pcap;
+
+  POE::Component::Pcap->spawn(
+			      Alias => 'pcap',
+			      Device => 'eth0',
+			      Filter => 'host fooble or host blort',
+			      Dispatch => 'got_packet',
+			      Session => $my_session_id,
+			     );
+
+  $poe_kernel->post( pcap => open_live =>
+		     'eth0', 80, 1, 100 );
+
+  $poe_kernel->post( pcap => set_filter => 'arp or host zooble' );
+
+  $poe_kernel->post( pcap => set_dispatch => 'target_state' );
+
+  $poe_kernel->post( pcap => 'run' );
+
+  $poe_kernel->post( pcap => 'shutdown' );
+
+=head1 DESCRIPTION
+
+POE::Component::Pcap provides a wrapper for using the Net::Pcap module
+from POE programs.  The component creates a separate session which
+posts events to a specified session and state when packets are
+available.
+
+=head2 ARGUMENTS
+
+=over 4
+
+=item Alias
+
+The alias for the Pcap session.  Used to post events such as C<run>
+and C<shutdown> to control the component.  Defaults to C<pcap> if not
+specified.
+
+=item Device
+
+As a shortcut, the device for Net::Pcap to watch may be specified when
+creating the component.  If this argument is used,
+Net::Pcap::open_live will be called with a snaplen of 80 octets, a
+timeout of 100ms, and the interface will be put in promiscuous mode.
+If these values are not suitable, post an C<open_live> event instead.
+
+=item Filter
+
+Another shortcut, calls Net::Pcap::compile and Net::Pcap::setfilter to
+set a packet filter.  This can only be used if the B<Device> argument
+is also given; otherwise a C<set_filter> event should be posted after
+an C<open_live> event (since Net::Pcap must have a C<pcap_t>
+descriptor to work with).
+
+=item Dispatch
+
+=item Session
+
+These specify the session and state to which events should be posted
+when packets are received.
+
+=back
+
+=head2 EVENTS
+
+The following examples assume that the component's alias has been set
+to the default value of B<pcap>.
+
+=over 4
+
+=item open_live
+
+  $_[KERNEL]->post( pcap => open_live
+		    => 'device', [snaplen], [promsic?], [timeout] );
+
+Calls Net::Pcap::open_live.  The device name must be specified.  The
+snaplen, promiscuous, and timeout parameters default to 80, 1, and 100
+respectively.  This event must be posted (or the B<Device> argument
+must have been passed to spawn()) before anything else can be done
+with the component.
+
+=item set_filter
+
+  $_[KERNEL]->post( pcap => set_filter
+		    => 'host fooble or host blort' )
+
+Sets the Net::Pcap capture filter.  See tcpdump(8) for details on the
+filter language used by pcap(3).
+
+=item set_dispatch
+
+  $_[KERNEL]->post( pcap => set_dispatch
+		    => 'target_state', 'target_session' );
+
+Sets the state and session to which events are sent when packets are
+recevied.  The target session will default to the sender of the event
+if not specified.
+
+The event posted will have a single argument (available as B<ARG0>)
+which will be an array reference containing the C<$hdr> and C<$pkt>
+parameters from Net::Pcap.  See the Net::Pcap(3) documentation for
+more details.
+
+=item run
+
+  $_[KERNEL]->post( pcap => 'run' );
+
+Causes the component to register a select_read and start watching for
+packets.
+
+=item shutdown
+
+  $_[KERNEL]->post( pcap => 'shutdown' );
+
+Shuts the component down.  Causes Net::Pcap::close to be called.
+
+=back
+
+=head1 SEE ALSO
+
+Net::Pcap(3), pcap(3), tcpdump(8), POE(3), POE::Component(3)
+
+=head1 AUTHOR
+
+Mike Fletcher, <fletch at phydeaux.org>
+
+=head1 COPYRIGHT
+
+Copyright 2000-2001, Mike Fletcher.  All Rights Reserved.  This is
+free software; you may redistribute it and/or modify it under the same
+terms as Perl itself.
+
+=cut

Added: branches/upstream/libpoe-component-pcap-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-pcap-perl/current/README?rev=48272&op=file
==============================================================================
--- branches/upstream/libpoe-component-pcap-perl/current/README (added)
+++ branches/upstream/libpoe-component-pcap-perl/current/README Sat Dec  5 19:35:35 2009
@@ -1,0 +1,61 @@
+$Id: README,v 1.2 2003/07/08 15:21:35 fletch Exp $
+
+--------
+Abstract
+--------
+
+POE::Component::Pcap is a POE wrapper for the Net::Pcap wrapper for
+libpcap.  It exists as a separate session which sends events back to a
+specified session when packets are ready.
+
+------------
+Requirements
+------------
+
+This module requires POE and Net::Pcap.  The requirements are encoded
+in Makefile.PL.  The NetPacket::* modules are also probably useful.
+
+------------------
+Basic Installation
+------------------
+
+POE::Component::Pcap may be installed through the CPAN shell in the
+usual CPAN shell manner.  This typically is:
+
+  $ perl -MCPAN -e 'intstall POE::Component::Pcap'
+
+You can also read this README from the CPAN shell:
+
+  $ perl -MCPAN -e shell
+  cpan> readme POE::Component::Pcap
+
+And you can install the component from the CPAN prompt as well:
+
+  cpan> install POE::Component::Pcap
+
+-------------------
+Manual Installation
+-------------------
+
+POE::Component::Pcap can also be installed manually.  The latest CPAN
+version can be found at
+<ftp://ftp.cpan.org/pub/CPAN/authors/id/F/FL/FLETCH/> or in a
+similarly named directory at your favorite CPAN mirror.  The most
+recent development snapshot, which only rarely contains hideous
+show-stopping bugs, is available from <http://phydeaux.org/>.
+
+Downloading and unpacking the distribution are left as exercises for
+the reader.  To build and test it:
+
+  perl Makefile.PL
+  make test
+
+When you're ready to install the component:
+
+  make install
+
+It should now be ready to use.
+
+---------------------------
+EOF: Thank you for reading.
+---------------------------

Added: branches/upstream/libpoe-component-pcap-perl/current/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-pcap-perl/current/debian/changelog?rev=48272&op=file
==============================================================================
--- branches/upstream/libpoe-component-pcap-perl/current/debian/changelog (added)
+++ branches/upstream/libpoe-component-pcap-perl/current/debian/changelog Sat Dec  5 19:35:35 2009
@@ -1,0 +1,5 @@
+libpoe-component-pcap-perl (0.04-1) unstable; urgency=low
+
+  * Initial upload (Closes: #532681)
+
+ -- Cajus Pollmeier <cajus at debian.org>  Tue, 24 Jun 2009 10:17:00 +0200

Added: branches/upstream/libpoe-component-pcap-perl/current/debian/compat
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-pcap-perl/current/debian/compat?rev=48272&op=file
==============================================================================
--- branches/upstream/libpoe-component-pcap-perl/current/debian/compat (added)
+++ branches/upstream/libpoe-component-pcap-perl/current/debian/compat Sat Dec  5 19:35:35 2009
@@ -1,0 +1,1 @@
+5

Added: branches/upstream/libpoe-component-pcap-perl/current/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-pcap-perl/current/debian/control?rev=48272&op=file
==============================================================================
--- branches/upstream/libpoe-component-pcap-perl/current/debian/control (added)
+++ branches/upstream/libpoe-component-pcap-perl/current/debian/control Sat Dec  5 19:35:35 2009
@@ -1,0 +1,21 @@
+Source: libpoe-component-pcap-perl
+Section: perl
+Priority: optional
+Build-Depends: debhelper (>= 5.0.0), libpoe-perl
+Build-Depends-Indep: perl (>= 5.8.8)
+Maintainer: GOsa packages mainteners group <gosa-pkg at oss.gonicus.de>
+Uploaders: Cajus Pollmeier <cajus at debian.org>, Benoit Mortier <benoit.mortier at opensides.be>
+Standards-Version: 3.8.2
+Homepage: http://search.cpan.org/dist/POE::Component::Pcap/
+Vcs-Browser: https://oss.gonicus.de/repositories/goto/trunk/libpoe-component-pcap-perl
+Vcs-Svn: https://oss.gonicus.de/repositories/goto/trunk/libpoe-component-pcap-perl
+
+Package: libpoe-component-pcap-perl
+Architecture: all
+Depends: ${perl:Depends}, ${misc:Depends}, libnet-pcap-perl, libnetpacket-perl 
+Description:  POE Interface to Net::Pcap
+ POE::Component::Pcap provides a wrapper for using the Net::Pcap module
+ from POE programs.  The component creates a separate session which
+ posts events to a specified session and state when packets are
+ available.
+ .

Added: branches/upstream/libpoe-component-pcap-perl/current/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-pcap-perl/current/debian/copyright?rev=48272&op=file
==============================================================================
--- branches/upstream/libpoe-component-pcap-perl/current/debian/copyright (added)
+++ branches/upstream/libpoe-component-pcap-perl/current/debian/copyright Sat Dec  5 19:35:35 2009
@@ -1,0 +1,22 @@
+This is the debian package for the POE::Component::Pcap module.
+It was created by Cajus Pollmeier <pollmeier at gonicus.de>
+
+It was downloaded from http://search.cpan.org/dist/POE::Component::Pcap/
+
+The upstream author is: 
+
+Mike Fletcher, <fletch at phydeaux.org>.
+
+
+Copyright 2000-2001, Mike Fletcher.  All Rights Reserved.  This is
+free software; you may redistribute it and/or modify it under the same
+terms as Perl itself.
+
+Perl is distributed under your choice of the GNU General Public License or
+the Artistic License.  On Debian GNU/Linux systems, the complete text of the
+GNU General Public License can be found in `/usr/share/common-licenses/GPL'
+and the Artistic Licence in `/usr/share/common-licenses/Artistic'.
+
+
+The Debian packaging is (C) 2008, Cajus Pollmeier <pollmeier at gonicus.de> and
+is licensed under the same terms as the software itself (see above).

Added: branches/upstream/libpoe-component-pcap-perl/current/debian/rules
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-pcap-perl/current/debian/rules?rev=48272&op=file
==============================================================================
--- branches/upstream/libpoe-component-pcap-perl/current/debian/rules (added)
+++ branches/upstream/libpoe-component-pcap-perl/current/debian/rules Sat Dec  5 19:35:35 2009
@@ -1,0 +1,75 @@
+#!/usr/bin/make -f
+# This debian/rules file is provided as a template for normal perl
+# packages. It was created by Marc Brockschmidt <marc at dch-faq.de> for
+# the Debian Perl Group (http://pkg-perl.alioth.debian.org/) but may
+# be used freely wherever it is useful.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# If set to a true value then MakeMaker's prompt function will
+# always return the default without waiting for user input.
+export PERL_MM_USE_DEFAULT=1
+
+PACKAGE=$(shell dh_listpackages)
+
+ifndef PERL
+PERL = /usr/bin/perl
+endif
+
+TMP     =$(CURDIR)/debian/$(PACKAGE)
+
+build: build-stamp
+build-stamp:
+	dh_testdir
+
+	# Add commands to compile the package here
+	$(PERL) Makefile.PL INSTALLDIRS=vendor
+	$(MAKE)
+
+	touch $@
+
+clean:
+	dh_testdir
+	dh_testroot
+
+	dh_clean build-stamp install-stamp
+
+	# Add commands to clean up after the build process here
+	[ ! -f Makefile ] || $(MAKE) realclean
+
+install: install-stamp
+install-stamp: build-stamp
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+
+	# Add commands to install the package into $(TMP) here
+	$(MAKE) install DESTDIR=$(TMP) PREFIX=/usr
+
+	[ ! -d $(TMP)/usr/lib/perl5 ] || rmdir --ignore-fail-on-non-empty --parents --verbose $(TMP)/usr/lib/perl5
+
+	touch $@
+
+binary-arch:
+# We have nothing to do here for an architecture-independent package
+
+binary-indep: build install
+	dh_testdir
+	dh_testroot
+	dh_installexamples
+	dh_installdocs README
+	dh_installchangelogs CHANGES
+	dh_perl
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+source diff:
+	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary

Propchange: branches/upstream/libpoe-component-pcap-perl/current/debian/rules
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libpoe-component-pcap-perl/current/debian/watch
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-pcap-perl/current/debian/watch?rev=48272&op=file
==============================================================================
--- branches/upstream/libpoe-component-pcap-perl/current/debian/watch (added)
+++ branches/upstream/libpoe-component-pcap-perl/current/debian/watch Sat Dec  5 19:35:35 2009
@@ -1,0 +1,3 @@
+# format version number, currently 3; this line is compulsory!
+version=3
+http://search.cpan.org/dist/POE::Component::Pcap/ .*/POE::Component::Pcap-v?(\d[\d_.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$

Added: branches/upstream/libpoe-component-pcap-perl/current/eg/ArpWatch.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-pcap-perl/current/eg/ArpWatch.pm?rev=48272&op=file
==============================================================================
--- branches/upstream/libpoe-component-pcap-perl/current/eg/ArpWatch.pm (added)
+++ branches/upstream/libpoe-component-pcap-perl/current/eg/ArpWatch.pm Sat Dec  5 19:35:35 2009
@@ -1,0 +1,172 @@
+#!/usr/bin/perl
+package POE::Component::ArpWatch;
+
+use strict;
+
+use POE;
+
+use Pcap;
+
+use NetPacket::Ethernet qw( :types );
+use NetPacket::ARP qw( :opcodes );
+
+## Map arp opcode #'s to strings
+my %arp_opcodes = (
+		   NetPacket::ARP::ARP_OPCODE_REQUEST, 'ARP Request',
+		   NetPacket::ARP::ARP_OPCODE_REPLY, 'ARP Reply',
+		   NetPacket::ARP::RARP_OPCODE_REQUEST, 'RARP Request',
+		   NetPacket::ARP::RARP_OPCODE_REPLY, 'RARP Reply',
+		  );
+
+##
+## POE::Component::ArpWatch->spawn(
+##				   [ Alias => 'arp_watch' ],
+##				   [ Device => 'eth0' ],
+##				   [ Dispatch => dispatch_state ],
+##				   [ Session => dispatch_session ],
+##				  )
+##
+sub spawn {
+  my $class = shift;
+  my %args = @_;
+
+  $args{ Alias } ||= 'arp_watch';
+
+  POE::Session->create( 
+		       inline_states => {
+					 _start => \&_start,
+#					 _signal => \&_signal,
+					 _stop => \&_stop,,
+					 _dispatch => \&_dispatch,
+					 set_dispatch => \&set_dispatch,
+					 run => \&run,
+					 pause => \&pause,
+					 shutdown => \&shutdown,
+					},
+		       args => [
+				$args{ Alias },   # ARG0
+				$args{ Device },  # ARG1
+				$args{ Dispatch },# ARG2
+				$args{ Session }, # ARG3
+			       ],
+		      );
+
+  return $args{ Alias };
+}
+
+sub _start {
+  my ($kernel, $heap, $session, 
+      $alias, $device, $target_state, $target_session ) 
+    = @_[ KERNEL, HEAP, SESSION, ARG0..ARG3 ];
+
+  POE::Component::Pcap->spawn( 
+			      Alias => $alias . '_pcap',
+			      Device => $device, 
+			      Filter => 'arp',
+			      Dispatch => '_dispatch',
+			      Session => $session,
+			     );
+
+  $heap->{'pcap_session'} = $kernel->alias_resolve( $alias . '_pcap' );
+
+  ## Set alias for ourselves and remember it
+  $kernel->alias_set( $alias );
+  $heap->{Alias} = $alias;
+
+  ## Set dispatch target session and state if it was given
+  if( defined( $target_session ) ) {
+    $heap->{'target_session'} = $target_session;
+    $heap->{'target_state'} = $target_state;
+  }
+}
+
+sub set_dispatch {
+  my( $heap, $sender, $target ) = @_[ HEAP, SENDER, ARG0 ];
+
+  if( defined $target ) {
+    ## Remember whome to forward results to
+    $heap->{'target_session'} = $sender;
+    $heap->{'target_state'} = $target;
+  } else {
+    ## Clear target
+    delete $heap->{'target_session'};
+    delete $heap->{'target_state'};
+  }
+}
+
+sub run {
+  $_[KERNEL]->post( $_[HEAP]->{'pcap_session'} => 'run' );
+}
+
+sub pause {
+  $_[KERNEL]->post( $_[HEAP]->{'pcap_session'} => 'pause' );
+}
+
+sub _dispatch {
+  my( $kernel, $heap, $packets ) =
+    @_[ KERNEL, HEAP, ARG0 ];
+
+  if( exists $heap->{'target_session'} ) {
+    $kernel->post( $heap->{'target_session'}, 
+		   $heap->{'target_state'}, 
+		   _process_packet( @{ $_ } ) ) foreach( @{$packets} );
+  }
+}
+
+sub _signal {
+  # print "Got signal ", $_[ARG0], "\n";
+
+  $_[KERNEL]->post( pcap => 'shutdown' );
+
+  return 1
+}
+
+sub shutdown {
+  my ( $kernel, $heap, $session, $sender ) 
+    = @_[ KERNEL, HEAP, SESSION, SENDER ];
+  my $alias = $heap->{Alias};
+
+#  print "In shutdown for sid ", $session->ID, ", alias $alias\n"; 
+#  print "shutdown by ", $sender->ID, "\n";
+
+  $kernel->post( $heap->{'pcap_session'} => 'shutdown' );
+
+  $kernel->alias_remove( $alias );
+
+#  print "Out shutdown for sid ", $session->ID, ", alias $alias\n"; 
+}
+
+sub _stop {
+  my ( $kernel, $heap, $session ) = @_[ KERNEL, HEAP, SESSION ];
+  my $alias = $heap->{Alias};
+
+#  print "In state_stop for sid ", $session->ID, ", alias $alias\n"; 
+
+#  print "Out state_stop for sid ", $session->ID, ", alias $alias\n"; 
+}
+
+sub _process_packet {
+  my( $hdr, $pkt ) = @_;
+
+  my $arp = 
+    NetPacket::ARP->decode( NetPacket::Ethernet->decode($pkt)->{data} );
+
+  ## Return hashref with apropriate fields
+  return { 
+	  type => $arp_opcodes{ $arp->{opcode} },
+	  tv_sec => $hdr->{tv_sec},
+	  tv_usec => $hdr->{tv_usec},
+	  source_haddr => _phys( $arp->{sha} ), 
+	  source_ipaddr => _ipaddr( $arp->{spa} ),
+	  target_haddr => _phys( $arp->{tha} ),
+	  target_ipaddr => _ipaddr( $arp->{tpa} ),
+	 }
+}
+
+## Pretty printing subs for addresses
+sub _ipaddr { join( ".", unpack( "C4", pack( "N", oct( "0x". shift ) ) ) ) }
+sub _phys { join( ":", grep {length} split( /(..)/, shift ) ) }
+
+1;
+
+__END__

Added: branches/upstream/libpoe-component-pcap-perl/current/eg/awtest
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-pcap-perl/current/eg/awtest?rev=48272&op=file
==============================================================================
--- branches/upstream/libpoe-component-pcap-perl/current/eg/awtest (added)
+++ branches/upstream/libpoe-component-pcap-perl/current/eg/awtest Sat Dec  5 19:35:35 2009
@@ -1,0 +1,64 @@
+#!/usr/bin/perl
+
+use strict;
+
+#BEGIN { sub POE::Kernel::TRACE_DEFAULT { 0 } }
+use POE;
+
+use Pcap;
+use ArpWatch;
+
+my $device = shift || 'wi0';
+
+POE::Session->create( 
+		     inline_states => {
+				       _start => \&start,
+				       _stop => sub {
+					 $_[KERNEL]->post( arp_watch => 
+							   'shutdown' )
+				       },
+				       got_packet => \&got_packet,
+				       signal => \&signal,
+				      },
+		    );
+
+$poe_kernel->run;
+
+exit 0;
+
+sub start {
+  POE::Component::ArpWatch->spawn( 
+				  Alias => 'arp_watch',
+				  Device => $device, 
+				  Dispatch => 'got_packet',
+				  Session => $_[SESSION],
+			         );
+
+  $_[KERNEL]->sig( $_ => 'signal' ) for qw( INT HUP TERM QUIT );
+
+  $_[KERNEL]->post( arp_watch => 'run' );
+
+  print "Waiting for packets . . .\n";
+}
+
+sub signal {
+  print "Got signal ", $_[ARG0], ", exiting\n";
+
+  $_[KERNEL]->post( arp_watch => 'shutdown' );
+
+  $_[KERNEL]->sig_handled();
+}
+
+sub got_packet {
+  my $packet = $_[ARG0];
+
+  print join( ':', (localtime( $packet->{tv_sec} ))[2,1,0]), 
+        '.', $packet->{tv_usec}, ': ',
+        $packet->{type}, "\n";
+
+  print "\tsha: ", $packet->{source_haddr}, 
+        "\tspa: ", $packet->{source_ipaddr}, "\n",
+        "\ttha: ", $packet->{target_haddr}, 
+        "\ttpa: ", $packet->{target_ipaddr}, "\n";
+}
+

Added: branches/upstream/libpoe-component-pcap-perl/current/t/01basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-pcap-perl/current/t/01basic.t?rev=48272&op=file
==============================================================================
--- branches/upstream/libpoe-component-pcap-perl/current/t/01basic.t (added)
+++ branches/upstream/libpoe-component-pcap-perl/current/t/01basic.t Sat Dec  5 19:35:35 2009
@@ -1,0 +1,116 @@
+#!/usr/bin/perl
+##
+## 01basic.t -- Basic testing.  Watches for a single ARP packet
+##
+
+use strict;
+use Test;
+
+BEGIN { plan tests => 2, }
+
+use POE;
+
+use Net::Pcap ();
+use NetPacket::Ethernet qw( :types );
+use NetPacket::ARP qw( :opcodes );
+
+use POE::Component::Pcap;
+
+if( $> ) {
+  print <<EOT;
+##
+## WARNING:
+## Not running as root; probably won't be able to open the
+## capture device.
+##
+EOT
+}
+
+my( $device, $err );
+$device = Net::Pcap::lookupdev( \$err )
+  or die "Can't lookup default device: $err\n";
+
+ok( 1 );
+
+POE::Session->create(
+		     inline_states => {
+				       _start => \&start,
+				       _stop => sub {
+					 $_[KERNEL]->post( pcap => 'shutdown' )
+				       },
+				       got_packet => \&got_packet,
+#				       _signal => \&_signal,
+				      },
+		    );
+
+$poe_kernel->run;
+
+exit 0;
+
+sub start {
+  POE::Component::Pcap->spawn(
+			      Alias => 'pcap',
+			      Device => $device,
+			      Filter => 'arp',
+			      Dispatch => 'got_packet',
+			      Session => $_[SESSION],
+			     );
+
+  $_[KERNEL]->post( pcap => 'run' );
+
+  print STDERR "\n## Waiting for one ARP packet on $device. . .\n";
+}
+
+sub _signal {
+  print STDERR "\n## Got signal ", $_[ARG0], "\n";
+
+  $_[KERNEL]->post( pcap => 'shutdown' );
+
+  return 1
+}
+
+sub got_packet {
+  my $packets = $_[ARG0];
+
+  process_packet( @{ $_ } ) foreach( @{$packets} );
+
+  print STDERR "\n## Saw an ARP packet.\n";
+  ok( 1 );
+
+  $_[KERNEL]->post( pcap => 'shutdown' );
+}
+
+sub process_packet {
+  my( $hdr, $pkt ) = @_;
+
+  ## Map arp opcode #'s to strings
+  my %arp_opcodes = (
+		     ARP_OPCODE_REQUEST, 'ARP Request',
+		     ARP_OPCODE_REPLY, 'ARP Reply',
+		     RARP_OPCODE_REQUEST, 'RARP Request',
+		     RARP_OPCODE_REPLY, 'RARP Reply',
+		    );
+
+  my $eth = NetPacket::Ethernet->decode($pkt);
+  my $arp =
+    NetPacket::ARP->decode( $eth->{data} );
+
+  print STDERR
+        join(":", (localtime($hdr->{tv_sec}))[2,1,0]),
+        ".", $hdr->{tv_usec}, ": ",
+	$arp_opcodes{ $arp->{opcode} }, " ",
+        $hdr->{caplen}, " bytes (of ", $hdr->{len}, ")\n";
+
+  print STDERR
+        "\tsha: ", _phys( $arp->{sha} ), "\tspa: ", _ipaddr( $arp->{spa} ),
+        "\n\ttha: ", _phys( $arp->{tha} ), "\ttpa: ", _ipaddr( $arp->{tpa} ),
+	"\n";
+}
+
+
+
+## Pretty printing subs
+sub _ipaddr { join( ".", unpack( "C4", pack( "N", oct( "0x". shift ) ) ) ) }
+sub _phys { join( ":", grep {length} split( /(..)/, shift ) ) }
+
+__END__




More information about the Pkg-perl-cvs-commits mailing list