📄 layer.pm
字号:
## $Id: Layer.pm,v 1.7 2006/05/06 16:07:48 gomor Exp $#package Net::Write::Layer;use strict;use warnings;use Carp;require Class::Gomor::Array;our @ISA = qw(Class::Gomor::Array);our @AS = qw( dev dst protocol family _io _sockaddr);__PACKAGE__->cgBuildIndices;__PACKAGE__->cgBuildAccessorsScalar(\@AS);sub send { my $self = shift; my ($raw) = @_; while (1) { my $ret = CORE::send($self->_io, $raw, 0, $self->_sockaddr); unless ($ret) { if ($!{ENOBUFS}) { $self->cgDebugPrint( 2, "send: ENOBUFS returned, sleeping for 1 second" ); sleep 1; next; } elsif ($!{EHOSTDOWN}) { $self->cgDebugPrint(2, "send: host is down"); last; } carp("@{[(caller(0))[3]]}: send: $!\n"); return undef; } last; } 1;}sub close { shift->_io->close }sub DESTROY { my $self = shift; if ($self->_io) { $self->close; $self->_io(undef); }}1;__END__=head1 NAMENet::Write::Layer - base class for all LayerN modules=head1 DESCRIPTIONThis is the base class for B<Net::Write::Layer2>, B<Net::Write::Layer3> and B<Net::Write::Layer4> modules.It just provides those layers with inheritable attributes and methods.A descriptor is required when you want to send frames over network, this module just create this descriptor, and give the programmer methods to write to the network.=head1 ATTRIBUTESAttributes are specific to each LayerN module. Just see perldoc for the wanted LayerN.=head1 METHODS=over 4=item B<new>Object constructor.=item B<send> (scalar)Send the raw data passed as a parameter. Returns undef on failure, true otherwise.=item B<close>Close the descriptor.=back=head1 AUTHORPatrice E<lt>GomoRE<gt> Auffret=head1 COPYRIGHT AND LICENSECopyright (c) 2006, Patrice E<lt>GomoRE<gt> AuffretYou may distribute this module under the terms of the Artistic license.See Copying file in the source distribution archive.=head1 RELATED MODULESL<Net::Packet>, L<Net::RawIP>, L<Net::RawSock>=cut
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -