Rev

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

Rev Author Line No. Line
1665 garciay 1
/**
2
 * @author      ETSI / STF481 / Yann Garcia
3
 * @version     $URL: file:///D:/RepositoriesNew/ITS/trunk/javasrc/codec/org/etsi/ttcn/codec/its/security/TrailerField.java $
4
 *              $Id: TrailerField.java 2655 2017-01-26 10:46:08Z filatov $
5
 */
1494 garciay 6
package org.etsi.ttcn.codec.its.security;
7
 
8
import org.etsi.ttcn.codec.CodecBuffer;
9
import org.etsi.ttcn.codec.MainCodec;
10
import org.etsi.ttcn.codec.generic.Record;
11
import org.etsi.ttcn.tci.RecordValue;
12
import org.etsi.ttcn.tci.Type;
13
 
14
/**
15
 * @desc Information used by the security layer after processing the payload
1789 garciay 16
 * @see Draft ETSI TS 103 097 V1.1.14 Clause 5.6    TrailerField
1494 garciay 17
 */
18
public class TrailerField extends Record {
19
 
20
    final byte c_signature = 0x01;
21
 
22
    /**
23
     * Constructor
24
     * @param mainCodec MainCodec reference
25
     */
26
    public TrailerField(MainCodec mainCodec) {
27
        super(mainCodec);
28
        setLengths();
29
    }
30
 
31
    /**
32
     * @desc Predefined field lengths
33
     */
34
    private void setLengths() {
35
        mainCodec.setHint("TrailerFieldTypeLen", "8");
36
    }
37
 
38
    /**
39
     * @desc Set the variant according to the TrailerField type
1789 garciay 40
     * @see See Draft ETSI TS 103 097 V1.1.14 Clause 5.7    TrailerFieldType
1494 garciay 41
     */
42
    @Override
43
    protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
2655 filatov 44
//        TERFactory.getInstance().logDebug(">>> TrailerField.preDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName());
1731 garciay 45
 
1494 garciay 46
        if (fieldName.equals("type_")) {
47
            byte type_ = buf.getBytes(0, 1)[0];
48
            switch (type_) {
49
                case (byte)c_signature:
50
                    mainCodec.setHint("TrailerFieldContainer", "signature_");
51
                    break;
52
                default:
53
                    mainCodec.setHint("TrailerFieldContainer", "security_field");
54
                    break;
55
            } // End of 'switch' statement
56
        }
57
    }
58
 
59
} // End of class TrailerField