SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.media.transform.zrtp
Class ZrtpRawPacket

java.lang.Object
  extended by net.java.sip.communicator.impl.media.RawPacket
      extended by net.java.sip.communicator.impl.media.transform.zrtp.ZrtpRawPacket

public class ZrtpRawPacket
extends RawPacket

ZRTP packet representation. This class extends the RawPacket class and adds some methods required by the ZRTP transformer.

Author:
Werner Dittmann

Field Summary
static byte[] zrtpMagic
          Each ZRTP packet conatins this magic number.
 
Fields inherited from class net.java.sip.communicator.impl.media.RawPacket
buffer, length, offset
 
Constructor Summary
ZrtpRawPacket(byte[] buf, int off, int len)
          Construct an output ZrtpRawPacket using specified value.
ZrtpRawPacket(RawPacket pkt)
          Construct an input ZrtpRawPacket using a received RTP raw packet.
 
Method Summary
protected  boolean checkCrc()
          Check if the CRC of this packet is ok.
protected  byte[] getMessagePart()
          Get the ZRTP message part from the ZRTP packet.
protected  int getSSRC()
          Read the SSRC data from packet.
protected  boolean hasMagic()
          Check if it is really a ZRTP packet.
protected  boolean isZrtpPacket()
          Check if it could be a ZRTP packet.
static void main(String[] argv)
           
protected  void setCrc()
          Set ZRTP CRC in this packet
protected  void setSeqNum(short seq)
          Set the sequence number in this packet.
protected  void setSSRC(int ssrc)
          Set SSRC in this packet
 
Methods inherited from class net.java.sip.communicator.impl.media.RawPacket
append, getBuffer, getLength, getOffset, readByte, readInt, readRegion, readRegionToBuff, readShort, readUnsignedIntAsLong, readUnsignedShortAsInt, shrink
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

zrtpMagic

public static byte[] zrtpMagic
Each ZRTP packet conatins this magic number.

Constructor Detail

ZrtpRawPacket

public ZrtpRawPacket(RawPacket pkt)
Construct an input ZrtpRawPacket using a received RTP raw packet.

Parameters:
pkt - a raw RTP packet as received

ZrtpRawPacket

public ZrtpRawPacket(byte[] buf,
                     int off,
                     int len)
Construct an output ZrtpRawPacket using specified value. Initialize this packet and set the ZRTP magic value to mark it as a ZRTP packet.

Parameters:
buf - Byte array holding the content of this Packet
off - Start offset of packet content inside buffer
len - Length of the packet's data
Method Detail

isZrtpPacket

protected boolean isZrtpPacket()
Check if it could be a ZRTP packet. The method checks if the first byte of the received data matches the defined ZRTP pattern 0x10

Returns:
true if could be a ZRTP packet, false otherwise.

hasMagic

protected boolean hasMagic()
Check if it is really a ZRTP packet. The method checks if the packet contains the ZRTP magic number.

Returns:
true if packet contains the magic number, false otherwise.

setSeqNum

protected void setSeqNum(short seq)
Set the sequence number in this packet.

Parameters:
seq -

setSSRC

protected void setSSRC(int ssrc)
Set SSRC in this packet

Parameters:
ssrc -

getSSRC

protected int getSSRC()
Read the SSRC data from packet.

Returns:
SSRC data

checkCrc

protected boolean checkCrc()
Check if the CRC of this packet is ok.

Returns:
true if the CRC is valid, false otherwise

setCrc

protected void setCrc()
Set ZRTP CRC in this packet


getMessagePart

protected byte[] getMessagePart()
Get the ZRTP message part from the ZRTP packet.

Returns:
The ZRTP message part.

main

public static void main(String[] argv)

SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.