|
JML | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.jqql.packets.Packet
public abstract class Packet
base class of all QQ packet object QQ所有包对象的基类
| Field Summary | |
|---|---|
protected static ByteBuffer |
bodyBuf
packet buffer, with back array, use to save unencrypted packet body, subcalss should use this buffer in putBody method. |
protected byte[] |
bodyDecrypted
明文包体 |
protected char |
command
packet command, 0x03~0x)4. |
protected static Crypter |
crypter
crypter. |
protected static DebugSwitch |
ds
调试模式开关 |
protected boolean |
duplicated
true means this packet is a duplicated packet, duplicated packet doesn't need to deal with, but cause LumaQQ often happen ack packet miss problem, so here add a field to show that coming message packet is duplicated. |
protected byte |
header
包头字节 |
protected static org.apache.commons.logging.Log |
log
logger. |
protected char |
sequence
packet sequence, 0x05~0x06. |
protected char |
source
source sign, 0x01~0x02. |
protected QQUser |
user
QQUser for creating multiple QQClient in a JVM, packet need to keep a QQuser reference to meake sure relevant field of packet user how to fill. |
| Constructor Summary | |
|---|---|
protected |
Packet()
create a packet object, don't fill any field, only use by subclass 构造一个包对象,什么字段也不填,仅限于子类使用 |
protected |
Packet(ByteBuffer buf,
int length,
QQUser user)
create a outPacket from buf, use to debug. |
protected |
Packet(ByteBuffer buf,
QQUser user)
从buf中构造一个OutPacket,用于调试。这个buf里面可能包含了抓包软件抓来的数据 |
|
Packet(byte header,
char source,
char command,
char sequence,
QQUser user)
create a specify parameters packet 构造一个指定参数的包 |
| Method Summary | |
|---|---|
protected abstract byte[] |
decryptBody(byte[] body,
int offset,
int length)
decrypt packet body 解密包体 |
byte[] |
dump()
export all content of packet to a byte array, mostly use to debug 导出包的全部内容到一个字节数组中,主要用于调试 |
protected abstract byte[] |
encryptBody(byte[] b,
int offset,
int length)
encrypt packet body 加密包体 |
boolean |
equals(Object obj)
|
protected abstract byte[] |
getBodyBytes(ByteBuffer buf,
int length)
get byte array of packet body 得到包体的字节数组 |
char |
getCommand()
|
protected abstract int |
getCryptographStart()
|
abstract int |
getFamily()
|
byte |
getHeader()
|
protected abstract int |
getHeadLength()
|
protected abstract int |
getLength(int bodyLength)
get total length of UDP form packet, rule out TCP form 得到UDP形式包的总长度,不考虑TCP形式 |
String |
getPacketName()
|
char |
getSequence()
|
char |
getSource()
|
protected abstract int |
getTailLength()
|
static int |
hash(char sequence,
char command)
get hash value 得到hash值 |
int |
hashCode()
make up sequence number and command as hash code. |
boolean |
isDuplicated()
|
protected abstract void |
parseBody(ByteBuffer buf)
parse packet body, from begin position of buf 解析包体,从buf的开头位置解析起 |
protected abstract void |
parseHeader(ByteBuffer buf)
parse packet header from current position of buf 从buf的当前位置解析包头 |
protected abstract void |
parseTail(ByteBuffer buf)
parse packet tail from current position of buf 从buf的当前未知解析包尾 |
protected abstract void |
putBody(ByteBuffer buf)
initialize packet body 初始化包体 |
protected abstract void |
putHead(ByteBuffer buf)
change packet header to byte stream, and write into appointed ByteBuffer object. |
protected abstract void |
putTail(ByteBuffer buf)
change packet tail to byte stream, and write into appointed ByteBuffer object. |
void |
setDuplicated(boolean duplicated)
|
void |
setHeader(byte header)
|
void |
setSequence(char sequence)
|
protected abstract boolean |
validateHeader()
checkout header 校验头部 |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static org.apache.commons.logging.Log log
protected static final Crypter crypter
protected static final ByteBuffer bodyBuf
protected static DebugSwitch ds
protected char command
protected char source
protected char sequence
protected byte header
protected QQUser user
protected boolean duplicated
protected byte[] bodyDecrypted
| Constructor Detail |
|---|
public Packet(byte header,
char source,
char command,
char sequence,
QQUser user)
header - packet header
包头source - packet source
包源command - packet command
包命令sequence - packet sequence number
包序号user - QQ user object
QQ用户对象
protected Packet(ByteBuffer buf,
QQUser user)
throws PacketParseException
buf - ByteBuffer
PacketParseException - 解析出错
protected Packet(ByteBuffer buf,
int length,
QQUser user)
throws PacketParseException
buf - ByteBufferlength - parsing content length
要解析的内容长度
PacketParseException - if parse error
如果解析出错protected Packet()
| Method Detail |
|---|
public byte[] dump()
protected abstract int getLength(int bodyLength)
bodyLength - packet body length
包体长度
protected abstract boolean validateHeader()
protected abstract int getHeadLength()
protected abstract int getTailLength()
protected abstract void putHead(ByteBuffer buf)
buf - ByteBuffer object whicn packet need to write into
写入的ByteBuffer对象.protected abstract void putBody(ByteBuffer buf)
buf - ByteBuffer
protected abstract byte[] getBodyBytes(ByteBuffer buf,
int length)
buf - ByteBufferlength - packet total length
包总长度
public abstract int getFamily()
protected abstract void putTail(ByteBuffer buf)
buf - ByteBuffer object whicn packet need to write into
写入的ByteBuffer对象.
protected abstract byte[] encryptBody(byte[] b,
int offset,
int length)
b - unencrypt byte array
未加密的字节数组offset - offset of packet body begin
包体开始的偏移length - packet body length
包体长度
protected abstract byte[] decryptBody(byte[] body,
int offset,
int length)
body - byte array of packet body
包体字节数组offset - offset of packet body begin
包体开始偏移length - packet length
包体长度
protected abstract int getCryptographStart()
protected abstract void parseBody(ByteBuffer buf)
throws PacketParseException
buf - ByteBuffer
PacketParseException - if parse error
如果解析出错
protected abstract void parseHeader(ByteBuffer buf)
throws PacketParseException
buf - ByteBuffer
PacketParseException - if parse error
如果解析出错
protected abstract void parseTail(ByteBuffer buf)
throws PacketParseException
buf - ByteBuffer
PacketParseException - if parse error
如果解析出错public boolean equals(Object obj)
equals in class Objectpublic int hashCode()
hashCode in class Object
public static int hash(char sequence,
char command)
header - sequence - command -
public char getCommand()
public char getSequence()
public void setSequence(char sequence)
sequence - The sequence to set.public String getPacketName()
public char getSource()
public boolean isDuplicated()
public void setDuplicated(boolean duplicated)
duplicated - The duplicated to set.public byte getHeader()
public void setHeader(byte header)
header - The header to set.
|
JML | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||