GnIndReq.java 2.25 KB
Newer Older
filatov's avatar
filatov committed
/**
 * @author      ETSI / STF462 / Alexandre Berge
 * @version     $URL: $
 *              $Id: $
 */
package org.etsi.ttcn.codec.its.geonetworking;

import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.tci.RecordValue;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
filatov's avatar
filatov committed

public class GnIndReq extends Record {

    public GnIndReq(MainCodec mainCodec) {
        super(mainCodec);
    }

    @Override
    protected void preDecode(CodecBuffer buf, Type decodingHypothesis) {
garciay's avatar
garciay committed
//        TERFactory.getInstance().logDebug(">>> GnIndReq.preDecode: " + decodingHypothesis);
garciay's avatar
garciay committed
        int msgLen = buf.getNbBits() - 48 - 128/*SSP*/ - 32/*ItsAid*/;
        
        messageBuffer = buf.getBuffer(0, msgLen);
        macBuffer = buf.getBuffer(msgLen, 48);
garciay's avatar
garciay committed
        sspBuffer = buf.getBuffer(msgLen + 48, 128/*SSP*/);
        itsaidBuffer = buf.getBuffer(msgLen + 48 + 128/*SSP*/, 32/*ItsAid*/);
filatov's avatar
filatov committed
    @Override
    protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
garciay's avatar
garciay committed
//        TERFactory.getInstance().logDebug(">>> GnIndReq.preDecodeField: " + fieldName + ", " + decodingHypothesis);
filatov's avatar
filatov committed

        if(fieldName.equals("macDestinationAddress")) {
            buf.overwriteWith(macBuffer);
garciay's avatar
garciay committed
        } else if(fieldName.equals("ssp")) {
            buf.overwriteWith(sspBuffer);
        } else if(fieldName.equals("its_aid")) {
            buf.overwriteWith(itsaidBuffer);
filatov's avatar
filatov committed
        }
        else {
            buf.overwriteWith(messageBuffer);
        }
    }

    @Override
    protected void postDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
garciay's avatar
garciay committed
//        TERFactory.getInstance().logDebug(">>> GnIndReq.postDecodeField: " + fieldName + ", " + decodingHypothesis);
    @Override
    public CodecBuffer encode(Value value) {
garciay's avatar
garciay committed
//        TERFactory.getInstance().logDebug("GnIndReq.encode: " + value);

        return super.encode(value);
    }

filatov's avatar
filatov committed
    private CodecBuffer messageBuffer = null;
    private CodecBuffer macBuffer = null;
garciay's avatar
garciay committed
    private CodecBuffer sspBuffer = null;
    private CodecBuffer itsaidBuffer = null;