package cz.vutbr.feec.packets;

/**
 * The Interface IPacket.
 */
public interface IPacket {
	
	/**
	 * Generate the packet to the buffer.
	 * 
	 * @param buffer the buffer to be parsed
	 * @param offset the start position
	 * 
	 * @return the number of generated bytes
	 * 
	 * @throws PacketGenerateException the packet generate exception
	 */
	public int generate(byte[] buffer, int offset)
			throws PacketGenerateException;

	/**
	 * Parses the packet.
	 * 
	 * @param buffer the buffer to be written
	 * @param offset the start position
	 * @param length the length
	 * 
	 * @return the number of parsed bytes
	 * 
	 * @throws PacketParseException the packet parse exception
	 */
	public int parse(byte[] buffer, int offset, int length)
			throws PacketParseException;
}
