JML

net.sf.jqql.packets
Class _03InPacket

java.lang.Object
  extended by net.sf.jqql.packets.Packet
      extended by net.sf.jqql.packets.InPacket
          extended by net.sf.jqql.packets._03InPacket
Direct Known Subclasses:
GetCustomHeadDataReplyPacket, GetCustomHeadInfoReplyPacket, Unknown03InPacket

public abstract class _03InPacket
extends InPacket

 03 protocol family input packet base class(as same as output packet), 
 this protocol family format is:
 1. protocol family packet header, 1 byte, 0x03
 2. command, 1 byte
 3. packet sequence, 2 byte
 4. unknown 4 byte
 5. unknown 4 byte
 6. unknown 4 byte
 7. unknown 4 byte
 8. unknown 4 byte
 9. unknown 4 byte
 10. unknown 4 byte
 11. unknown 4 byte
 12. unknown 4 byte
 13. fragment amount, 1 byte
 Note: for a received packet, it may be greater than 1
 14. current fragment, 1 byte, from 0 begin
 15. unnkown 1 byte
 16. sender version number, 2 byte
 17. unkown 1 byte
 18. packet body
 
 Note: this protocol family haven't encrypt,haven't packet tail
  
 03协议族输入包基类(其实和输出包一样),这个协议族的格式为
 1. 协议族包头,1字节,0x03
 2. 命令,1字节
 3. 包序号,2字节
 4. 未知的4字节
 5. 未知的4字节
 6. 未知的4字节
 7. 未知的4字节
 8. 未知的4字节
 9. 未知的4字节
 10. 未知的4字节
 11. 未知的4字节
 12. 未知的4字节
 13. 分片数,1字节
 Note: 对于一个收到的包来说,13部分可能大于1
 14. 当前分片,1字节,从0开始
 15. 未知1字节
 16. 发送者版本号,2字节
 17. 未知1字节
 18. 包体
 
 Note: 此协议族无加密,无包尾
 

Author:
luma

Field Summary
 byte currentFragment
           
 int serialNumber
           
 byte totalFragment
           
 
Fields inherited from class net.sf.jqql.packets.Packet
bodyBuf, bodyDecrypted, command, crypter, ds, duplicated, header, log, sequence, source, user
 
Constructor Summary
_03InPacket(ByteBuffer buf, int length, QQUser user)
           
_03InPacket(char command, QQUser user)
           
 
Method Summary
protected  byte[] decryptBody(byte[] body, int offset, int length)
          decrypt packet body 解密包体
protected  byte[] encryptBody(byte[] b, int offset, int length)
          encrypt packet body 加密包体
 boolean equals(Object obj)
           
protected  byte[] getBodyBytes(ByteBuffer buf, int length)
          get byte array of packet body 得到包体的字节数组
protected  int getCryptographStart()
           
 int getFamily()
           
protected  int getHeadLength()
           
protected  int getLength(int bodyLength)
          get total length of UDP form packet, rule out TCP form 得到UDP形式包的总长度,不考虑TCP形式
protected  int getTailLength()
           
protected  void parseHeader(ByteBuffer buf)
          parse packet header from current position of buf 从buf的当前位置解析包头
protected  void parseTail(ByteBuffer buf)
          parse packet tail from current position of buf 从buf的当前未知解析包尾
protected  void putBody(ByteBuffer buf)
          initialize packet body 初始化包体
protected  void putHead(ByteBuffer buf)
          change packet header to byte stream, and write into appointed ByteBuffer object.
protected  void putTail(ByteBuffer buf)
          change packet tail to byte stream, and write into appointed ByteBuffer object.
 String toString()
           
 
Methods inherited from class net.sf.jqql.packets.InPacket
validateHeader
 
Methods inherited from class net.sf.jqql.packets.Packet
dump, getCommand, getHeader, getPacketName, getSequence, getSource, hash, hashCode, isDuplicated, parseBody, setDuplicated, setHeader, setSequence
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

totalFragment

public byte totalFragment

currentFragment

public byte currentFragment

serialNumber

public int serialNumber
Constructor Detail

_03InPacket

public _03InPacket(char command,
                   QQUser user)

_03InPacket

public _03InPacket(ByteBuffer buf,
                   int length,
                   QQUser user)
            throws PacketParseException
Throws:
PacketParseException
Method Detail

getLength

protected int getLength(int bodyLength)
Description copied from class: Packet
get total length of UDP form packet, rule out TCP form 得到UDP形式包的总长度,不考虑TCP形式

Specified by:
getLength in class Packet
Parameters:
bodyLength - packet body length 包体长度
Returns:
packet length 包长度

getHeadLength

protected int getHeadLength()
Specified by:
getHeadLength in class Packet
Returns:
packet header length 包头长度

getTailLength

protected int getTailLength()
Specified by:
getTailLength in class Packet
Returns:
packet tail length 包尾长度

putHead

protected void putHead(ByteBuffer buf)
Description copied from class: Packet
change packet header to byte stream, and write into appointed ByteBuffer object. 将包头部转化为字节流, 写入指定的ByteBuffer对象.

Specified by:
putHead in class Packet
Parameters:
buf - ByteBuffer object whicn packet need to write into 写入的ByteBuffer对象.

getBodyBytes

protected byte[] getBodyBytes(ByteBuffer buf,
                              int length)
Description copied from class: Packet
get byte array of packet body 得到包体的字节数组

Specified by:
getBodyBytes in class Packet
Parameters:
buf - ByteBuffer
length - packet total length 包总长度
Returns:
byte array of packet body 包体字节数组

putTail

protected void putTail(ByteBuffer buf)
Description copied from class: Packet
change packet tail to byte stream, and write into appointed ByteBuffer object. 将包尾部转化为字节流, 写入指定的ByteBuffer对象.

Specified by:
putTail in class Packet
Parameters:
buf - ByteBuffer object whicn packet need to write into 写入的ByteBuffer对象.

putBody

protected void putBody(ByteBuffer buf)
Description copied from class: Packet
initialize packet body 初始化包体

Specified by:
putBody in class Packet
Parameters:
buf - ByteBuffer

encryptBody

protected byte[] encryptBody(byte[] b,
                             int offset,
                             int length)
Description copied from class: Packet
encrypt packet body 加密包体

Specified by:
encryptBody in class Packet
Parameters:
b - unencrypt byte array 未加密的字节数组
offset - offset of packet body begin 包体开始的偏移
length - packet body length 包体长度
Returns:
encrypted packet body 加密的包体

decryptBody

protected byte[] decryptBody(byte[] body,
                             int offset,
                             int length)
Description copied from class: Packet
decrypt packet body 解密包体

Specified by:
decryptBody in class Packet
Parameters:
body - byte array of packet body 包体字节数组
offset - offset of packet body begin 包体开始偏移
length - packet length 包体长度
Returns:
解密的包体字节数组 // byte array of decrypted packet body

getCryptographStart

protected int getCryptographStart()
Specified by:
getCryptographStart in class Packet
Returns:
start position of cryptograph, relative to the first byte of packet body. if this packet is unknown packet, return -1, this method only available to some protocol family. 密文的起始位置,这个位置是相对于包体的第一个字节来说的,如果这个包是未知包, 返回-1,这个方法只对某些协议族有意义

parseHeader

protected void parseHeader(ByteBuffer buf)
                    throws PacketParseException
Description copied from class: Packet
parse packet header from current position of buf 从buf的当前位置解析包头

Specified by:
parseHeader in class Packet
Parameters:
buf - ByteBuffer
Throws:
PacketParseException - if parse error 如果解析出错

parseTail

protected void parseTail(ByteBuffer buf)
                  throws PacketParseException
Description copied from class: Packet
parse packet tail from current position of buf 从buf的当前未知解析包尾

Specified by:
parseTail in class Packet
Parameters:
buf - ByteBuffer
Throws:
PacketParseException - if parse error 如果解析出错

equals

public boolean equals(Object obj)
Overrides:
equals in class Packet

toString

public String toString()
Overrides:
toString in class Object

getFamily

public int getFamily()
Specified by:
getFamily in class Packet
Returns:
sign this packet belong which protocol family 标识这个包属于哪个协议族

JML