Subject: | rfc 1179 compliance |
I'm able to use Net::Printer with non-RFC 1179 compliant printers. However, when I try to use the module with RFC 1179 compliant printers, I get a "malformed from address" error.
http://web.mit.edu/source/third/lprng/doc/LPRng-HOWTO-6.html
According to section 3.1 of the RFC, the source port of the LPD connection must be in the range 721 to 731. These ports require root access to bind to on unix since they are under 1024. Can there be an option for the module to be RFC 1179 compliant?
Please take a look at the attached patch. It adds a "rfc1179" option to the constructor to allow the user to specify that they want to follow the RFC. I also updated the docs for this new option. Please let me know what you think.
--- Printer.pm.orig Wed Feb 12 20:53:07 2003
+++ Printer.pm Thu Feb 13 05:45:22 2003
@@ -177,9 +177,20 @@
# Parameter(s)
my $self = shift;
- $sock = IO::Socket::INET->new(Proto => 'tcp',
- PeerAddr => $self->{server},
- PeerPort => $self->{port});
+ if (uc($self->{rfc1179}) eq "NO") {
+ $sock = IO::Socket::INET->new(Proto => 'tcp',
+ PeerAddr => $self->{server},
+ PeerPort => $self->{port});
+ } else {
+ # RFC 1179 says "source port be in the range 721-731"
+ foreach my $p (721 .. 731) {
+ $sock = IO::Socket::INET->new( PeerAddr => $self->{server},
+ PeerPort => $self->{port},
+ Proto => 'tcp',
+ LocalPort => $p
+ ) and last;
+ }
+ }
return $sock;
@@ -760,6 +771,7 @@
"printer" => "lp",
"server" => "localhost",
"port" => 515,
+ "rfc1179" => "No",
"debug" => "No" );
# Parameter(s);
@@ -854,6 +866,9 @@
Default "515".
lineconvert - [optional] Perform LF -> LF/CR translation.
+ Default "NO"
+
+ rfc1179 - [optional] Use RFC 1179 compliant source address.
Default "NO"
=head2 Functions