⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 icmpv4.pm

📁 SinFP是一种新的识别对方计算机操作系统类型的工具
💻 PM
📖 第 1 页 / 共 2 页
字号:
   $self->[$__type]     = $type;   $self->[$__code]     = $code;   $self->[$__checksum] = $checksum;   $self->[$__payload]  = $payload;   # unpack specific ICMPv4 types   my $sub = $unpackTypes->{$self->[$__type]} || \&_decodeError;   my $href = $self->$sub or return undef;   $self->$_($href->{$_}) for keys %$href;   #爌ayload has been handled by previous chunk of code   $self->[$__payload] = undef;   1;}sub computeChecksums {   my $self = shift;   my $sub = $packTypes->{$self->[$__type]} || \&_decodeError;   my $raw = $self->$sub or return undef;   if (my $data = $self->[$__data]) {      $raw .= $self->SUPER::pack('a*', $data)         or return undef;   }   my $packed = $self->SUPER::pack('CCn', $self->[$__type], $self->[$__code], 0)      or return undef;   $self->[$__checksum] = inetChecksum($packed.$raw);   1;}sub encapsulate { NP_LAYER_NONE }sub print {   my $self = shift;   my $i = $self->is;   my $l = $self->layer;   my $buf = sprintf      "$l:+$i: type:%d  code:%d  checksum:0x%.4x  size:%d",         $self->type,         $self->code,         $self->checksum,         $self->getLength,   ;   if ($self->data) {      $buf .= sprintf("\n$l: $i: dataLength:%d  data:%s",                      $self->getDataLength,                      $self->SUPER::unpack('H*', $self->data))         or return undef;   }   $buf;}## Helpers#sub _isType                { shift->[$__type] == shift()                 }sub isTypeEchoRequest      { shift->_isType(NP_ICMPv4_TYPE_ECHO_REQUEST) }sub isTypeEchoReply        { shift->_isType(NP_ICMPv4_TYPE_ECHO_REPLY)   }sub isTypeTimestampRequest {   shift->_isType(NP_ICMPv4_TYPE_TIMESTAMP_REQUEST);}sub isTypeTimestampReply {   shift->_isType(NP_ICMPv4_TYPE_TIMESTAMP_REPLY);}sub isTypeInformationRequest {   shift->_isType(NP_ICMPv4_TYPE_INFORMATION_REQUEST);}sub isTypeInformationReply {   shift->_isType(NP_ICMPv4_TYPE_INFORMATION_REPLY);}sub isTypeAddressMaskRequest {   shift->_isType(NP_ICMPv4_TYPE_ADDRESS_MASK_REQUEST);}sub isTypeAddressMaskReply {   shift->_isType(NP_ICMPv4_TYPE_ADDRESS_MASK_REPLY);}sub isTypeDestinationUnreachable {   shift->_isType(NP_ICMPv4_TYPE_DESTINATION_UNREACHABLE);}1;__END__=head1 NAMENet::Packet::ICMPv4 - Internet Control Message Protocol v4 layer 4 object=head1 SYNOPSIS   use Net::Packet::ICMPv4;   use Net::Packet::Consts qw(:icmpv4);   # Build echo-request header   my $echo = Net::Packet::ICMPv4->new(data => '0123456789');   # Build information-request header   my $info = Net::Packet::ICMPv4->new(      type => NP_ICMPv4_TYPE_INFORMATION_REQUEST,      data => '0123456789',   );   # Build address-mask request header   my $mask = Net::Packet::ICMPv4->new(      type => NP_ICMPv4_TYPE_ADDRESS_MASK_REQUEST,      data => '0123456789',   );   # Build timestamp request header   my $timestamp = Net::Packet::ICMPv4->new(      type => NP_ICMPv4_TYPE_TIMESTAMP_REQUEST,      data => '0123456789',   );   # Decode from network to create the object   # Usually, you do not use this, it is used by Net::Packet::Frame   my $decode = Net::Packet::ICMPv4->new(raw => $rawFromNetwork);   print $echo->print, "\n";=head1 DESCRIPTIONThis modules implements the encoding and decoding of the ICMPv4 layer.RFC: ftp://ftp.rfc-editor.org/in-notes/rfc792.txtSee also B<Net::Packet::Layer> and B<Net::Packet::Layer4> for other attributes and methods.=head1 ATTRIBUTES=over 4=item B<type>=item B<code>Type and code fields. See B<CONSTANTS>.=item B<checksum>The checksum of ICMPv4 header.=item B<identifier>Identification number.=item B<sequenceNumber>Sequence number.=item B<originateTimestamp>=item B<receiveTimestamp>=item B<transmitTimestamp>Three timestamps used by the B<NP_ICMPv4_TYPE_TIMESTAMP_REQUEST> message.=item B<addressMask>Used by the B<NP_ICMPv4_TYPE_ADDRESS_MASK_REQUEST> message.=item B<gateway>Used by the B<NP_ICMPv4_TYPE_REDIRECT> message.=item B<unused>Zero value field used in various ICMP messages.=item B<error>A pointer to a B<Net::Packet::Frame> object, usually set when an ICMP error message has been returned.=item B<data>Additionnal data can be added to an ICMP message, traditionnaly used in B<NP_ICMPv4_TYPE_ECHO_REQUEST>.=back=head1 METHODS=over 4=item B<new>Object constructor. You can pass attributes that will overwrite default ones. Default values:type:               NP_ICMPv4_TYPE_ECHO_REQUESTcode:               NP_ICMPv4_CODE_ZEROchecksum:           0identifier:         getRandom16bitsInt()sequenceNumber:     getRandom16bitsInt()originateTimestamp: time()receiveTimestamp:   0transmitTimestamp:  0addressMask:        0gateway:            "127.0.0.1"unused:             0data:               ""=item B<recv>Will search for a matching replies in B<framesSorted> or B<frames> from a B<Net::Packet::Dump> object.=item B<getDataLength>Returns the length in bytes of B<data> attribute.=item B<pack>Packs all attributes into a raw format, in order to inject to network. Returns 1 on success, undef otherwise.=item B<unpack>Unpacks raw data from network and stores attributes into the object. Returns 1 on success, undef otherwise.=item B<isTypeEchoRequest>=item B<isTypeEchoReply>=item B<isTypeTimestampRequest>=item B<isTypeTimestampReply>=item B<isTypeInformationRequest>=item B<isTypeInformationReply>=item B<isTypeAddressMaskRequest>=item B<isTypeAddressMaskReply>=item B<isTypeDestinationUnreachable>Returns 1 if the B<type> attribute is of specified type.=back=head1 CONSTANTSLoad them: use Net::Packet::Consts qw(:icmpv4);=over 4=item B<NP_ICMPv4_CODE_ZERO>ICMP code zero, used by various ICMP messages.=item B<NP_ICMPv4_TYPE_DESTINATION_UNREACHABLE>=item B<NP_ICMPv4_CODE_NETWORK>=item B<NP_ICMPv4_CODE_HOST>=item B<NP_ICMPv4_CODE_PROTOCOL>=item B<NP_ICMPv4_CODE_PORT>=item B<NP_ICMPv4_CODE_FRAGMENTATION_NEEDED>=item B<NP_ICMPv4_CODE_SOURCE_ROUTE_FAILED>Destination unreachable type, with possible code numbers.=item B<NP_ICMPv4_TYPE_REDIRECT>=item B<NP_ICMPv4_CODE_FOR_NETWORK>=item B<NP_ICMPv4_CODE_FOR_HOST>=item B<NP_ICMPv4_CODE_FOR_TOS_AND_NETWORK>=item B<NP_ICMPv4_CODE_FOR_TOS_AND_HOST>Redirect type message, with possible code numbers.=item B<NP_ICMPv4_TYPE_TIME_EXCEEDED>=item B<NP_ICMPv4_CODE_TTL_IN_TRANSIT>=item B<NP_ICMPv4_CODE_FRAGMENT_REASSEMBLY>Time exceeded message, with possible code numbers.=item B<NP_ICMPv4_TYPE_ECHO_REQUEST>=item B<NP_ICMPv4_TYPE_ECHO_REPLY>=item B<NP_ICMPv4_TYPE_TIMESTAMP_REQUEST>=item B<NP_ICMPv4_TYPE_TIMESTAMP_REPLY>=item B<NP_ICMPv4_TYPE_INFORMATION_REQUEST>=item B<NP_ICMPv4_TYPE_INFORMATION_REPLY>=item B<NP_ICMPv4_TYPE_ADDRESS_MASK_REQUEST>=item B<NP_ICMPv4_TYPE_ADDRESS_MASK_REPLY>Other request/reply ICMP messages types.=back=head1 AUTHORPatrice E<lt>GomoRE<gt> Auffret=head1 COPYRIGHT AND LICENSECopyright (c) 2004-2006, Patrice E<lt>GomoRE<gt> AuffretYou may distribute this module under the terms of the Artistic license.See LICENSE.Artistic file in the source distribution archive.=head1 RELATED MODULESL<NetPacket>, L<Net::RawIP>, L<Net::RawSock>=cut

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -