package ip;

import pack.packHolder;
import addr.addrIP;

/**
 * ip core protocol
 *
 * @author matecsaba
 */
public interface ipCor {

    /**
     * get ip version info
     *
     * @return return ip version
     */
    public int getVersion();

    /**
     * get net layer protocol id
     *
     * @return return ip version
     */
    public int getNlpid();

    /**
     * get ip header size generated by create
     *
     * @return return ip header size
     */
    public int getHeaderSize();

    /**
     * parse ip header
     *
     * @param pck packet to parse
     * @param chksiz check size
     * @return false if successful, true if error happened
     */
    public boolean parseIPheader(packHolder pck, boolean chksiz);

    /**
     * test ip address
     *
     * @param pck packet to set in
     * @param test address to test
     */
    public void testIPaddress(packHolder pck, addrIP test);

    /**
     * create ip header
     *
     * @param pck packet to update
     */
    public void createIPheader(packHolder pck);

    /**
     * update ip header it works at data area, not at header area the neader
     * already have to be parsed and must not skipped over it
     *
     * @param pck packet to update
     * @param src new source address, null=don't set
     * @param trg new target address, null=don't set
     * @param prt new protocol value, -1=dont set
     * @param ttl new ttl value, -1=dont set, -2=decrement
     * @param tos new tos value, -1=dont set
     * @param len new payload length, -1=dont set
     */
    public void updateIPheader(packHolder pck, addrIP src, addrIP trg, int prt, int ttl, int tos, int len);

}
