r56243 - in /branches/upstream/libnet-sip-perl/current: Changes META.yml lib/Net/SIP.pm lib/Net/SIP.pod lib/Net/SIP/Dispatcher.pm lib/Net/SIP/Endpoint/Context.pm lib/Net/SIP/Leg.pm lib/Net/SIP/Simple/Call.pm lib/Net/SIP/Simple/Call.pod lib/Net/SIP/Util.pm

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Fri Apr 16 20:47:08 UTC 2010


Author: gregoa
Date: Fri Apr 16 20:47:03 2010
New Revision: 56243

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=56243
Log:
[svn-upgrade] Integrating new upstream version, libnet-sip-perl (0.58)

Modified:
    branches/upstream/libnet-sip-perl/current/Changes
    branches/upstream/libnet-sip-perl/current/META.yml
    branches/upstream/libnet-sip-perl/current/lib/Net/SIP.pm
    branches/upstream/libnet-sip-perl/current/lib/Net/SIP.pod
    branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Dispatcher.pm
    branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Endpoint/Context.pm
    branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Leg.pm
    branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Simple/Call.pm
    branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Simple/Call.pod
    branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Util.pm

Modified: branches/upstream/libnet-sip-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-sip-perl/current/Changes?rev=56243&op=diff
==============================================================================
--- branches/upstream/libnet-sip-perl/current/Changes (original)
+++ branches/upstream/libnet-sip-perl/current/Changes Fri Apr 16 20:47:03 2010
@@ -1,4 +1,24 @@
 Revision history for Net::SIP
+
+0.58 2010-04-15
+- with 'perl -MNet::SIP=rtp:min-max' the ports to used for RTP can be
+  restricted, useful if behind firewall with limited forwarding.
+  See Net::SIP doku for more information.
+  Thanks to DetlefPilzecker[AT]web[DOT]de for pointing out the problem.
+0.57_4 2010-04-15
+- Net::SIP::Endpoint::Context - set context.to based on reply before
+  invoking callback. Thanks <vitspec[AT]gmail[DOT]com> for input.
+0.57_3 2010-04-15
+- Net::SIP::Leg::receive: ignore packets with len<13 because any valid
+  packet must be larger. Such packets are used for keep-alives.
+  Thanks to DetlefPilzecker[AT]web[DOT]de for pointing out the problem.
+0.57_2 2010-04-13
+- added Net::SIP::Simple::Call::get_param as pendant to set_param based
+  on patch from <dave[AT]3c[DOT]co[DOT]uk>
+0.57_1 2010-04-13
+- dispatcher calls receive callback with eval so that it does not 
+  die on bad or unexpected packets. Thanks to <vitspec[AT]gmail[DOT]com>
+  for pointing out the problem
 
 0.57 2010-03-19
 - save remote_contact from successful responses in context and use

Modified: branches/upstream/libnet-sip-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-sip-perl/current/META.yml?rev=56243&op=diff
==============================================================================
--- branches/upstream/libnet-sip-perl/current/META.yml (original)
+++ branches/upstream/libnet-sip-perl/current/META.yml Fri Apr 16 20:47:03 2010
@@ -1,13 +1,21 @@
 --- #YAML:1.0
-name:                Net-SIP
-version:             0.57
-abstract:            ~
-license:             ~
-author:              ~
-generated_by:        ExtUtils::MakeMaker version 6.42
-distribution_type:   module
-requires:     
-    Net::DNS:                      0.56
+name:               Net-SIP
+version:            0.58
+abstract:           ~
+author:  []
+license:            unknown
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+build_requires:
+    ExtUtils::MakeMaker:  0
+requires:
+    Net::DNS:  0.56
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.54
 meta-spec:
-    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
-    version: 1.3
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Modified: branches/upstream/libnet-sip-perl/current/lib/Net/SIP.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-sip-perl/current/lib/Net/SIP.pm?rev=56243&op=diff
==============================================================================
--- branches/upstream/libnet-sip-perl/current/lib/Net/SIP.pm (original)
+++ branches/upstream/libnet-sip-perl/current/lib/Net/SIP.pm Fri Apr 16 20:47:03 2010
@@ -4,7 +4,7 @@
 require 5.008;
 
 package Net::SIP;
-our $VERSION = '0.57';
+our $VERSION = '0.58';
 
 # this includes nearly everything else
 use Net::SIP::Simple ();
@@ -72,7 +72,10 @@
 			Net::SIP::Debug->export_to_level(1,$class,':DEFAULT')
 		} elsif ( $tag eq ':alias' ) {
 			$class->export_to_level(1,$class,$tag);
-		} elsif ( $tag =~m{^debug=(.*)}i ) {
+		} elsif ( $tag =~m{rtp[=:](\d+)-(\d+)}i ) {
+			$Net::SIP::Util::RTP_MIN_PORT = $1;
+			$Net::SIP::Util::RTP_MAX_PORT = $2;
+		} elsif ( $tag =~m{^debug[=:](.*)}i ) {
 			Net::SIP::Debug->level($1);
 		} elsif ( first { $_ eq $tag } @EXPORT_OK ) {
 			# from the predefined list

Modified: branches/upstream/libnet-sip-perl/current/lib/Net/SIP.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-sip-perl/current/lib/Net/SIP.pod?rev=56243&op=diff
==============================================================================
--- branches/upstream/libnet-sip-perl/current/lib/Net/SIP.pod (original)
+++ branches/upstream/libnet-sip-perl/current/lib/Net/SIP.pod Fri Apr 16 20:47:03 2010
@@ -144,6 +144,15 @@
 
 Everything from ':debug', ':util' and ':alias'.
 
+=item rtp=MINPORT-MAXPORT|rtp:MINPORT-MAXPORT
+
+Set the range of ports to be used for creating RTP sockets to MINPORT..MAXPORT.
+This affects L<Net::SIP::Util::create_rtp_sockets>.
+
+=item debug=LEVEL|debug:LEVEL
+
+Set Debugging level to LEVEL
+
 =item string
 
 Strings where the first character is upper case will be interpreted
@@ -163,6 +172,10 @@
   Packet->new( ... );             # Net::SIP::Packet->new( ... )
 
 
+  # restrict rtp sockets from command line
+  perl -MNet::SIP=rtp:4000-4010 program.pl
+
+
 =head1 COPYRIGHT
 
 This module and are modules in the Net::SIP Hierarchy distributed

Modified: branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Dispatcher.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Dispatcher.pm?rev=56243&op=diff
==============================================================================
--- branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Dispatcher.pm (original)
+++ branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Dispatcher.pm Fri Apr 16 20:47:03 2010
@@ -175,21 +175,27 @@
 
 		if ( my $fd = $leg->fd ) {
 			my $cb = sub {
-				my ($self,$leg) = @_;
-				$self || return;
-
-				# leg->receive might return undef if the packet wasnt
-				# read successfully. for tcp connections the receive
-				# on a listening socket might cause a new leg to be added
-				# which then will receive the packet (maybe over multiple
-				# read attempts)
-				my ($packet,$from) = $leg->receive or do {
-					DEBUG( 50,"failed to receive on leg" );
-					return;
+				# don't crash Dispatcher on bad or unexpected packets
+				eval {
+					my ($self,$leg) = @_;
+					$self || return;
+
+					# leg->receive might return undef if the packet wasnt
+					# read successfully. for tcp connections the receive
+					# on a listening socket might cause a new leg to be added
+					# which then will receive the packet (maybe over multiple
+					# read attempts)
+					my ($packet,$from) = $leg->receive or do {
+						DEBUG( 50,"failed to receive on leg" );
+						return;
+					};
+
+					# handle received packet
+					$self->receive( $packet,$leg,$from );
 				};
-
-				# handle received packet
-				$self->receive( $packet,$leg,$from );
+				if ($@) {
+					DEBUG(1,"dispatcher croaked: $@");
+				}
 			};
 			$cb = [ $cb,$self,$leg ];
 			weaken( $cb->[1] );

Modified: branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Endpoint/Context.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Endpoint/Context.pm?rev=56243&op=diff
==============================================================================
--- branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Endpoint/Context.pm (original)
+++ branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Endpoint/Context.pm Fri Apr 16 20:47:03 2010
@@ -361,17 +361,18 @@
 				$req->set_uri( $contact );
 			}
 
+			# use to-tag from this request to update 'to'
+			# FIXME: this should probably be better done by the upper layer
+			# which decides, which call to accept (in case of call-forking with
+			# multiple 2xx responses)
+			$self->{to} = $response->get_header( 'to' ) if ! $self->{incoming};
+
 			# create ACK
 			# if 2xx response changed contact use it as the new URI
 			my $ack = $req->create_ack( $response );
 			invoke_callback($cb, at arg,0,$code,$response,$leg,$from,$ack);
 			$endpoint->new_request( $ack,$self,undef,undef,leg => $leg, dst_addr => $from );
 
-			# use to-tag from this request to update 'to'
-			# FIXME: this should probably be better done by the upper layer
-			# which decides, which call to accept (in case of call-forking with
-			# multiple 2xx responses)
-			$self->{to} = $response->get_header( 'to' ) if ! $self->{incoming};
 
 		} else {
 			# response to ACK, REGISTER...

Modified: branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Leg.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Leg.pm?rev=56243&op=diff
==============================================================================
--- branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Leg.pm (original)
+++ branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Leg.pm Fri Apr 16 20:47:03 2010
@@ -404,6 +404,13 @@
 		return;
 	};
 
+	# packet must be at least 13 bytes big (first line incl version
+	# + final crlf crlf). Ignore anything smaller, probably keep-alives
+	if ( length($buf)<13 ) {
+		DEBUG(11,"ignored packet with len ".length($buf)." because to small (keep-alive?)");
+		return;
+	}
+
 	my $packet = eval { Net::SIP::Packet->new( $buf ) } or do {
 		DEBUG( 3,"cannot parse buf as SIP: $@\n$buf" );
 		return;

Modified: branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Simple/Call.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Simple/Call.pm?rev=56243&op=diff
==============================================================================
--- branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Simple/Call.pm (original)
+++ branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Simple/Call.pm Fri Apr 16 20:47:03 2010
@@ -144,6 +144,17 @@
 }
 
 ###########################################################################
+# get value for parameter(s)
+# Args: ($self, at keys)
+# Returns: @values|$value[0]
+###########################################################################
+sub get_param {
+	my Net::SIP::Simple::Call $self = shift;
+	my @v = @{$self->{param}}{@_};
+	return wantarray ? @v : $v[0];
+}
+
+###########################################################################
 # (Re-)Invite other party
 # Args: ($self;%param)
 #   %param: see description of field 'param', gets merged with param

Modified: branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Simple/Call.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Simple/Call.pod?rev=56243&op=diff
==============================================================================
--- branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Simple/Call.pod (original)
+++ branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Simple/Call.pod Fri Apr 16 20:47:03 2010
@@ -259,4 +259,10 @@
 constructor. This is useful if call consists of multiple invites with different
 features.
 
+=item get_param ( @KEYS )
+
+Returns values for parameter @KEYS, pendant to B<set_param>
+If there is only one key it will return the value as scalar, on multiple
+keys it returns an array with all values.
+
 =back

Modified: branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Util.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Util.pm?rev=56243&op=diff
==============================================================================
--- branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Util.pm (original)
+++ branches/upstream/libnet-sip-perl/current/lib/Net/SIP/Util.pm Fri Apr 16 20:47:03 2010
@@ -25,6 +25,9 @@
 	sip_uri_eq
 );
 our %EXPORT_TAGS = ( all => \@EXPORT_OK );
+
+our $RTP_MIN_PORT = 2000;
+our $RTP_MAX_PORT = 12000;
 
 ###########################################################################
 # creates hash from header val, e.g.
@@ -250,8 +253,9 @@
 # Args: ($laddr;$range,$min,$max,$tries)
 #   $laddr: local addr
 #   $range: how many sockets, 2 if not defined
-#   $min: minimal port number, default 2000
+#   $min: minimal port number, default $RTP_MIN_PORT
 #   $max: maximal port number, default 10000 more than $min
+#      or $RTP_MAX_PORT if $min not given
 #   $tries: how many tries, default 100
 # Returns: ($port,$rtp_sock,$rtcp_sock, at more_socks)
 #   $port:      port of RTP socket, port for RTCP is port+1
@@ -262,9 +266,13 @@
 sub create_rtp_sockets {
 	my ($laddr,$range,$min,$max,$tries) = @_;
 	$range ||= 2;
-	$min ||= 2000;
+	if ( ! $min ) {
+		$min = $RTP_MIN_PORT;
+		$max ||= $RTP_MAX_PORT;
+	} else {
+		$max ||= $min+10000;
+	}
 	$min += $min%2; # make even
-	$max ||= $min+10000;
 	$tries ||= 1000;
 
 	my $diff2 = int(($max-$min)/2) - $range +1;




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