func NewPacket(r io.Reader) (packet Packet, err error) {
	if err = binary.Read(r, binary.BigEndian, &packet.Header); err != nil {
		return
	}

	if packet.Header.Type == EchoRequestType && packet.Header.Code == EchoRequestCode {
		packet.Data, err = NewEcho(r)
	} else if packet.Header.Type == EchoReplyType && packet.Header.Code == EchoReplyType {
		packet.Data, err = NewEcho(r)
	} else {
		err = ErrUnsupportedICMPPacket
	}

	return
}
// NewPacket will read a packet from a reader.
NewPacket will read a packet from a reader.
// NewPacket will read a packet from a reader .
func NewPacket(r io.Reader) (packet Packet, err error) {
	if err = binary.Read(r, binary.BigEndian, &packet.Header); err != nil {
		return
	}
	if packet.Header.Type == EchoRequestType && packet.Header.Code == EchoRequestCode {
		packet.Data, err = NewEcho(r)
	} else if packet.Header.Type == EchoReplyType && packet.Header.Code == EchoReplyType {
		packet.Data, err = NewEcho(r)
	} else {
		err = ErrUnsupportedICMPPacket
	}
	return
}
func NewPacket ( r io . Reader ) ( packet Packet , err error ) { if err = binary . Read ( r , binary . BigEndian , & packet . Header ) ; err != nil { return } if packet . Header . Type == EchoRequestType && packet . Header . Code == EchoRequestCode { packet . Data , err = NewEcho ( r ) } else if packet . Header . Type == EchoReplyType && packet . Header . Code == EchoReplyType { packet . Data , err = NewEcho ( r ) } else { err = ErrUnsupportedICMPPacket } return }
NewPacket will read a packet from a reader.
NewPacket will read a packet from a reader .