|
JML | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jqql.obsolete.FilePacket
public abstract class FilePacket
base class of sent packet in file transfer, packet header of packet in file transfer in 12 byte, format is 1. a byte mean packet type, since control data is 0x00, file data is 0x03 2. sender QQ version, or server version, this field is same as common-use pakcet of QQ 3. random cipher code, 1 byte, if this byte is 0x25, then cipher code is 0x23232323, this cipher code is use to encrypt sender and receiver QQ number 4. encrypt form of sender QQ number, 4 byte. encrypt arithmetic: QQ number negate then XOR with cipher code 5. encrypt form of receiver QQ number, 4 byte 文件传输时发送的包的基类,文件传送的包的包头为12个字节,格式为 1. 一个字节表示包的类型,似乎控制数据是0x00,文件数据是0x03 2. 发送方QQ版本,或者是服务器版本,这个字段和QQ的普通用途包是一样的 3. 随机密钥,1字节,如果这个字节是0x23,那么密钥就是0x23232323,这个密钥用来加密 发送者和接受者的QQ号 4. 发送者QQ号的加密形式,4字节。加密算法: QQ号取反再与密钥异或 5. 接受者QQ号的加密形式,4字节* @author luma
Field Summary | |
---|---|
protected static Crypter |
crypter
|
protected int |
key
|
protected static org.apache.commons.logging.Log |
log
|
protected static Random |
random
|
protected int |
receiver
|
protected int |
sender
|
protected char |
source
|
protected byte |
tag
|
protected FileWatcher |
watcher
|
Constructor Summary | |
---|---|
protected |
FilePacket(FileWatcher watcher)
create a FilePacket 构造一个FilePacket |
Method Summary | |
---|---|
protected int |
decryptQQ(int qq,
int key)
decrypt QQ number 解密QQ号 |
protected int |
encryptQQ(int qq,
int key)
encrypt QQ number 加密QQ号 |
protected void |
fill(ByteBuffer out)
initialize packet content, subclass should overide this method, and first use this method in super class × content of input ByteBuffer will be clear, after complete, buffer position equal to packet length 初始化包内容,子类应该覆盖这个方法,并首先调用父类的这个方法 输入ByteBuffer原来的内容将被清空,完成后,buffer的position 等于包长 |
protected void |
fill(ByteBuffer out,
int from)
initialize packet content, subclass should overide this method, and first use this method in super class content of input ByteBuffer won't be clear, new content start fill from from position, after complete, buffer position = packet length + from 初始化包内容,子类应该覆盖这个方法,并首先调用父类的这个方法 输入ByteBuffer的原来内容不被清空,新的内容从from位置开始 填充,完成后,buffer的position等于包长加上from |
protected int |
generateKey(byte b)
base on seed create a new key, inside key won't be refreshed 根据种子生成一个新的Key,内部的Key不会被刷新 |
int |
getKey()
method for debugg 调试用方法 |
int |
getReceiver()
|
int |
getSender()
|
char |
getSource()
|
byte |
getTag()
|
protected abstract void |
initFixedFields()
init some fixed field toward fixed type packet 初始化一些对于固定类型的包来说固定值的字段 |
protected void |
parse(ByteBuffer in)
parse packet header, subclass should overide this method, and first use this method in super class parse start from current position of in, after parse complete, position of in will be after this packet 解析包头,子类应该覆盖该方法,并首先调用父类的这个方法 解析从in的当前位置开始,解析完毕后in的position将位于 这个包之后 |
protected int |
refreshKey()
inside refresh key 内部刷新Key |
void |
setReceiver(int receiver)
|
void |
setSender(int sender)
|
void |
setSource(char source)
|
void |
setTag(byte type)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static org.apache.commons.logging.Log log
protected char source
protected byte tag
protected static Crypter crypter
protected static Random random
protected int key
protected int sender
protected int receiver
protected FileWatcher watcher
Constructor Detail |
---|
protected FilePacket(FileWatcher watcher)
watcher
- FileWatcher对象 // FileWatcher objectMethod Detail |
---|
protected int refreshKey()
protected int generateKey(byte b)
b
- 种子 // seedprotected void parse(ByteBuffer in) throws PacketParseException
in
- ByteBuffer对象,做为输入缓冲区 // ByteBuffer object, as input buffer
BadQQPacketException
- 如果包的长度不对 // if packet length wrong
PacketParseException
protected void fill(ByteBuffer out)
initialize packet content, subclass should overide this method, and first use this method in super class × content of input ByteBuffer will be clear, after complete, buffer position equal to packet length 初始化包内容,子类应该覆盖这个方法,并首先调用父类的这个方法 输入ByteBuffer原来的内容将被清空,完成后,buffer的position 等于包长
out
- ByteBuffer对象,做为输出缓冲区 // ByteBuffer object, use to output bufferprotected void fill(ByteBuffer out, int from)
initialize packet content, subclass should overide this method, and first use this method in super class content of input ByteBuffer won't be clear, new content start fill from from position, after complete, buffer position = packet length + from 初始化包内容,子类应该覆盖这个方法,并首先调用父类的这个方法 输入ByteBuffer的原来内容不被清空,新的内容从from位置开始 填充,完成后,buffer的position等于包长加上from
out
- ByteBuffer对象,做为输出缓冲区 // ByteBuffer object, use to output bufferfrom
- 开始填充的位置 //start fill positionprotected abstract void initFixedFields()
protected int encryptQQ(int qq, int key)
qq
- QQ号 // QQ numberkey
- 密钥
protected int decryptQQ(int qq, int key)
qq
- QQ号 // QQ numberkey
- 密钥 // cipher code
public char getSource()
public void setSource(char source)
source
- The source to set.public byte getTag()
public void setTag(byte type)
type
- The type to set.public int getKey()
public int getReceiver()
public void setReceiver(int receiver)
receiver
- The receiver to set.public int getSender()
public void setSender(int sender)
sender
- The sender to set.
|
JML | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |