r6695 - in /trunk/libnet-sip-perl: Changes MANIFEST META.yml debian/changelog debian/copyright lib/Net/SIP.pm lib/Net/SIP/Registrar.pm samples/invite_and_recv.pl samples/invite_and_send.pl

rmayorga-guest at users.alioth.debian.org rmayorga-guest at users.alioth.debian.org
Thu Aug 16 02:19:48 UTC 2007


Author: rmayorga-guest
Date: Thu Aug 16 02:19:48 2007
New Revision: 6695

URL: http://svn.debian.org/wsvn/?sc=1&rev=6695
Log:
* New upstream version
* debian/changelog - added a pkg-perl copyright stanza

Modified:
    trunk/libnet-sip-perl/Changes
    trunk/libnet-sip-perl/MANIFEST
    trunk/libnet-sip-perl/META.yml
    trunk/libnet-sip-perl/debian/changelog
    trunk/libnet-sip-perl/debian/copyright
    trunk/libnet-sip-perl/lib/Net/SIP.pm
    trunk/libnet-sip-perl/lib/Net/SIP/Registrar.pm
    trunk/libnet-sip-perl/samples/invite_and_recv.pl
    trunk/libnet-sip-perl/samples/invite_and_send.pl

Modified: trunk/libnet-sip-perl/Changes
URL: http://svn.debian.org/wsvn/trunk/libnet-sip-perl/Changes?rev=6695&op=diff
==============================================================================
--- trunk/libnet-sip-perl/Changes (original)
+++ trunk/libnet-sip-perl/Changes Thu Aug 16 02:19:48 2007
@@ -1,4 +1,12 @@
 Revision history for Net::SIP
+
+0.32
+  - Net::SIP::Registrar checks on non-REGISTER requests if the
+    target it registered with itself and then rewrites the URI in
+    the packet. This can be used for a combined Registar+Proxy,
+    see samples/test_registrar_and_proxy.pl
+  - samples/invite_and_*.pl have now option -L|--leg to specify
+    a local address
 
 0.31
   - make it usable for perl5.9, tested with 5.9.5

Modified: trunk/libnet-sip-perl/MANIFEST
URL: http://svn.debian.org/wsvn/trunk/libnet-sip-perl/MANIFEST?rev=6695&op=diff
==============================================================================
--- trunk/libnet-sip-perl/MANIFEST (original)
+++ trunk/libnet-sip-perl/MANIFEST Thu Aug 16 02:19:48 2007
@@ -65,6 +65,7 @@
 t/testlib.pl
 samples/invite_and_recv.pl
 samples/invite_and_send.pl
+samples/test_registrar_and_proxy.pl
 samples/3pcc.pl
 bin/nathelper.pl
 bin/stateless_proxy.pl

Modified: trunk/libnet-sip-perl/META.yml
URL: http://svn.debian.org/wsvn/trunk/libnet-sip-perl/META.yml?rev=6695&op=diff
==============================================================================
--- trunk/libnet-sip-perl/META.yml (original)
+++ trunk/libnet-sip-perl/META.yml Thu Aug 16 02:19:48 2007
@@ -1,7 +1,7 @@
 # http://module-build.sourceforge.net/META-spec.html
 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
 name:         Net-SIP
-version:      0.31
+version:      0.32
 version_from: lib/Net/SIP.pm
 installdirs:  site
 requires:

Modified: trunk/libnet-sip-perl/debian/changelog
URL: http://svn.debian.org/wsvn/trunk/libnet-sip-perl/debian/changelog?rev=6695&op=diff
==============================================================================
--- trunk/libnet-sip-perl/debian/changelog (original)
+++ trunk/libnet-sip-perl/debian/changelog Thu Aug 16 02:19:48 2007
@@ -1,3 +1,9 @@
+libnet-sip-perl (0.32-1) unstable; urgency=low
+
+  * New upstream release 
+
+ -- Rene Mayorga <rmayorga at debian.org.sv>  Wed, 15 Aug 2007 20:05:00 -0600
+
 libnet-sip-perl (0.31-1) unstable; urgency=low
 
   * New upstream release

Modified: trunk/libnet-sip-perl/debian/copyright
URL: http://svn.debian.org/wsvn/trunk/libnet-sip-perl/debian/copyright?rev=6695&op=diff
==============================================================================
--- trunk/libnet-sip-perl/debian/copyright (original)
+++ trunk/libnet-sip-perl/debian/copyright Thu Aug 16 02:19:48 2007
@@ -1,5 +1,6 @@
 This package was debianized by Rene Mayorga <rmayorga at debian.org.sv> on
-Fri, 13 Jul 2007 00:32:54 -0600.
+Fri, 13 Jul 2007 00:32:54 -0600, and is Maintaining by the 
+Debian Perl Group (pkg-perl) 
 
 It was downloaded from:  http://search.cpan.org/~sullr/Net-SIP-0.30/
 

Modified: trunk/libnet-sip-perl/lib/Net/SIP.pm
URL: http://svn.debian.org/wsvn/trunk/libnet-sip-perl/lib/Net/SIP.pm?rev=6695&op=diff
==============================================================================
--- trunk/libnet-sip-perl/lib/Net/SIP.pm (original)
+++ trunk/libnet-sip-perl/lib/Net/SIP.pm Thu Aug 16 02:19:48 2007
@@ -4,7 +4,7 @@
 require 5.008;
 
 package Net::SIP;
-our $VERSION = '0.31';
+our $VERSION = '0.32';
 
 # this includes nearly everything else
 use Net::SIP::Simple ();

Modified: trunk/libnet-sip-perl/lib/Net/SIP/Registrar.pm
URL: http://svn.debian.org/wsvn/trunk/libnet-sip-perl/lib/Net/SIP/Registrar.pm?rev=6695&op=diff
==============================================================================
--- trunk/libnet-sip-perl/lib/Net/SIP/Registrar.pm (original)
+++ trunk/libnet-sip-perl/lib/Net/SIP/Registrar.pm Thu Aug 16 02:19:48 2007
@@ -62,7 +62,16 @@
 
 	# accept only REGISTER
 	$packet->is_request || return;
-	$packet->method eq 'REGISTER' || return;
+	if ( $packet->method ne 'REGISTER' ) {
+		# if we know the target rewrite the destination URI
+		my $uri = $packet->uri;
+		DEBUG( 1,"method ".$packet->method." uri=<$uri>" );
+		my @found = $self->query( $uri );
+		@found or return;
+		DEBUG( 1,"rewrite URI $uri in ".$packet->method." to $found[0]" );
+		$packet->set_uri( $found[0] );
+		return; # propagate to next in chain
+	}
 
 	my $from = $packet->get_header( 'from' ) or do {
 		DEBUG( 1,"no from in register request. DROP" );

Modified: trunk/libnet-sip-perl/samples/invite_and_recv.pl
URL: http://svn.debian.org/wsvn/trunk/libnet-sip-perl/samples/invite_and_recv.pl?rev=6695&op=diff
==============================================================================
--- trunk/libnet-sip-perl/samples/invite_and_recv.pl (original)
+++ trunk/libnet-sip-perl/samples/invite_and_recv.pl Thu Aug 16 02:19:48 2007
@@ -29,6 +29,7 @@
   -R|--registrar host[:port]   register at given address
   -O|--outfile filename        write received RTP data to file
   -T|--time interval           hang up after interval seconds
+  -L|--leg ip[:port]           use given local ip[:port] for outgoing leg
   --username name              username for authorization
   --password pass              password for authorization
   --route host[:port]          add SIP route, can be specified multiple times
@@ -36,6 +37,7 @@
 Examples:
   $0 -T 10 -O record.data sip:30\@192.168.178.4 sip:31\@192.168.178.1
   $0 --username 30 --password secret --proxy=192.168.178.3 sip:30\@example.com 31
+  $0 --username 30 --password secret --leg 192.168.178.4 sip:30\@example.com 31
 
 EOS
 	exit( @_ ? 1:0 );
@@ -46,7 +48,7 @@
 # Get options
 ###################################################
 
-my ($proxy,$outfile,$registrar,$username,$password,$hangup);
+my ($proxy,$outfile,$registrar,$username,$password,$hangup,$local_leg);
 my (@routes,$debug);
 GetOptions(
 	'd|debug:i' => \$debug,
@@ -55,6 +57,7 @@
 	'R|registrar=s' => \$registrar,
 	'O|outfile=s' => \$outfile,
 	'T|time=i' => \$hangup,
+	'L|leg=s' => \$local_leg,
 	'username=s' =>\$username,
 	'password=s' =>\$password,
 	'route=s' => \@routes,
@@ -69,25 +72,32 @@
 $registrar ||= $proxy;
 
 ###################################################
-# if no proxy is given we need to find out
-# about the leg using the IP given from FROM
+# find local leg
 ###################################################
+my ($local_host,$local_port);
+if ( $local_leg ) {
+	($local_host,$local_port) = split( m/:/,$local_leg,2 );
+} elsif ( ! $proxy ) {
+	# if no proxy is given we need to find out
+	# about the leg using the IP given from FROM
+	($local_host,$local_port) = $from =~m{\@([\w\-\.]+)(?::(\d+))?}
+		or die "cannot find SIP domain in '$from'";
+}
+
 my $leg;
-if ( !$proxy ) {
-	my ($host,$port) = $from =~m{\@([\w\-\.]+)(?::(\d+))?}
-		or die "cannot find SIP domain in '$from'";
-	my $addr = gethostbyname( $host )
-		|| die "cannot get IP from SIP domain '$host'";
+if ( $local_host ) {
+	my $addr = gethostbyname( $local_host )
+		|| die "cannot get IP from SIP domain '$local_host'";
 	$addr = inet_ntoa( $addr );
 
 	$leg = IO::Socket::INET->new(
 		Proto => 'udp',
 		LocalAddr => $addr,
-		LocalPort => $port || 5060,
+		LocalPort => $local_port || 5060,
 	);
 
 	# if no port given and port 5060 is already used try another one
-	if ( !$leg && !$port ) {
+	if ( !$leg && !$local_port ) {
 		$leg = IO::Socket::INET->new(
 			Proto => 'udp',
 			LocalAddr => $addr,

Modified: trunk/libnet-sip-perl/samples/invite_and_send.pl
URL: http://svn.debian.org/wsvn/trunk/libnet-sip-perl/samples/invite_and_send.pl?rev=6695&op=diff
==============================================================================
--- trunk/libnet-sip-perl/samples/invite_and_send.pl (original)
+++ trunk/libnet-sip-perl/samples/invite_and_send.pl Thu Aug 16 02:19:48 2007
@@ -32,6 +32,7 @@
   -P|--proxy host[:port]       use outgoing proxy, register there unless registrar given
   -R|--registrar host[:port]   register at given address
   -S|--send filename           send content of file, can be given multiple times
+  -L|--leg ip[:port]           use given local ip[:port] for outgoing leg
   --username name              username for authorization
   --password pass              password for authorization
 
@@ -49,7 +50,7 @@
 # Get options
 ###################################################
 
-my ($proxy, at files,$registrar,$username,$password);
+my ($proxy, at files,$registrar,$username,$password,$local_leg);
 my ($debug,$hangup);
 GetOptions(
 	'd|debug:i' => \$debug,
@@ -57,6 +58,7 @@
 	'P|proxy=s' => \$proxy,
 	'R|registrar=s' => \$registrar,
 	'S|send=s' => \@files,
+	'L|leg=s' => \$local_leg,
 	'username=s' =>\$username,
 	'password=s' =>\$password,
 ) || usage( "bad option" );
@@ -70,33 +72,42 @@
 $registrar ||= $proxy;
 
 ###################################################
-# if no proxy is given we need to find out
-# about the leg using the IP given from FROM
+# find local leg
 ###################################################
+my ($local_host,$local_port);
+if ( $local_leg ) {
+	($local_host,$local_port) = split( m/:/,$local_leg,2 );
+} elsif ( ! $proxy ) {
+	# if no proxy is given we need to find out
+	# about the leg using the IP given from FROM
+	($local_host,$local_port) = $from =~m{\@([\w\-\.]+)(?::(\d+))?}
+		or die "cannot find SIP domain in '$from'";
+}
+
 my $leg;
-if ( !$proxy ) {
-	my ($host,$port) = $from =~m{\@([\w\-\.]+)(?::(\d+))?}
-		or die "cannot find SIP domain in '$from'";
-	my $addr = gethostbyname( $host )
-		|| die "cannot get IP from SIP domain '$host'";
+if ( $local_host ) {
+	my $addr = gethostbyname( $local_host )
+		|| die "cannot get IP from SIP domain '$local_host'";
 	$addr = inet_ntoa( $addr );
 
 	$leg = IO::Socket::INET->new(
 		Proto => 'udp',
 		LocalAddr => $addr,
-		LocalPort => $port || 5060,
+		LocalPort => $local_port || 5060,
 	);
 
 	# if no port given and port 5060 is already used try another one
-	if ( !$leg && !$port ) {
+	if ( !$leg && !$local_port ) {
 		$leg = IO::Socket::INET->new(
 			Proto => 'udp',
 			LocalAddr => $addr,
 			LocalPort => 0
 		) || die "cannot create leg at $addr: $!";
 	}
+
 	$leg = Net::SIP::Leg->new( sock => $leg );
 }
+
 
 ###################################################
 # SIP code starts here




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