Rev

Rev 1822 | Details | Compare with Previous | Last modification | View Log | SVN | Bug Tracker

Rev Author Line No. Line
1133 berge 1
package org.etsi.ttcn.codec.ipv6;
2
 
3
import org.etsi.ttcn.tci.Type;
4
import org.etsi.ttcn.tci.RecordValue;
5
import org.etsi.ttcn.tci.IntegerValue;
6
import org.etsi.ttcn.codec.generic.Record;
7
import org.etsi.ttcn.codec.MainCodec;
8
import org.etsi.ttcn.codec.CodecBuffer;
9
 
2655 filatov 10
import org.etsi.common.ByteHelper;
1133 berge 11
 
12
public class Ipv6ExtHdr extends Record {
13
 
14
    public Ipv6ExtHdr(MainCodec mainCodec) {
15
        super(mainCodec);
16
    }
17
 
18
    @Override
19
    protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
20
 
21
        if(fieldName.equals("data")) {
22
            mainCodec.setHint("octetstringLen", mainCodec.getHint("Ipv6ExtHdrLen"));
23
        }
24
    }
25
 
26
    @Override
27
    protected void postDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
28
 
29
        if(fieldName.equals("hdrLen")) {
1822 berge 30
//            int len = ((IntegerValue)(rv.getField(fieldName))).getInteger(); TTWB iterface is getInt, TCI shall be getInteger
31
            int len = mainCodec.getTciCDRequired().getInteger((IntegerValue)(rv.getField(fieldName)));
1133 berge 32
            mainCodec.setHint("Ipv6ExtHdrLen", Integer.toString(len));
33
        }
34
    }
35
 
36
    @Override
37
    protected void postEncodeField(String fieldName, CodecBuffer buf) {
38
 
39
        if(fieldName.equals("nextHeader")) {
40
            mainCodec.setHint("Ipv6NextHeader", Integer.toString(ByteHelper.byteArrayToInt(buf.getBytes(0, 1))));
41
        }
42
    }
43
}