summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/asn1/sv/sv.cnf
blob: fd2634e0f525e68f906b1f982f17cc9553bc4f05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# sv.cnf
# SampledValue conformation file

#.MODULE_IMPORT

#.EXPORTS

#.PDU

#.NO_EMIT ONLY_VALS
SampledValues

#.TYPE_RENAME

#.FIELD_RENAME

#.FN_BODY ASDU/smpCnt VAL_PTR = &value
	uint32_t value;
%(DEFAULT_BODY)s
	sv_data.smpCnt = value;
#.END

#.FN_BODY UtcTime
	uint32_t len;
	uint32_t seconds;
	uint32_t	fraction;
	uint32_t nanoseconds;
	nstime_t ts;
	char *	ptime;

	len = tvb_reported_length_remaining(tvb, offset);

	if(len != 8)
	{
		proto_tree_add_expert_format(tree, actx->pinfo, &ei_sv_mal_utctime, tvb, offset, len,
				"BER Error: malformed UTCTime encoding, length must be 8 bytes");
		if(hf_index > 0)
		{
			proto_tree_add_string(tree, hf_index, tvb, offset, len, "????");
		}
		return offset;
	}

	seconds = tvb_get_ntohl(tvb, offset);
	fraction = tvb_get_ntoh24(tvb, offset+4) * 0x100; /* Only 3 bytes are recommended */
	nanoseconds = (uint32_t)( ((uint64_t)fraction * UINT64_C(1000000000)) / UINT64_C(0x100000000) ) ;

	ts.secs = seconds;
	ts.nsecs = nanoseconds;

	ptime = abs_time_to_str(actx->pinfo->pool, &ts, ABSOLUTE_TIME_UTC, true);

	if(hf_index > 0)
	{
		proto_tree_add_string(tree, hf_index, tvb, offset, len, ptime);
	}
	offset += 8;
#.END

#.TYPE_ATTR
UtcTime	TYPE = FT_STRING DISPLAY = BASE_NONE

#.FN_BODY ASDU/smpSynch VAL_PTR = &value
	uint32_t value;
%(DEFAULT_BODY)s
	sv_data.smpSynch = value;
#.END

#.FN_BODY ASDU/smpMod  VAL_PTR = &value
	uint32_t value;
%(DEFAULT_BODY)s
	sv_data.smpMod = value;
#.END

#.FN_BODY Data
	if (sv_decode_data_as_phsmeas) {
		offset = dissect_PhsMeas1(implicit_tag, actx->pinfo, tree, tvb, offset, hf_index);
	} else {
		offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
	}
#.END

#.FN_BODY GmidData
	uint32_t len;
	proto_item  *gmidentity_ti;
	proto_tree  *gmidentity_tree;
	const char *manuf_name;

	len = tvb_reported_length_remaining(tvb, offset);

	if(len != 8)
	{
		proto_tree_add_expert_format(tree, actx->pinfo, &ei_sv_mal_gmidentity, tvb, offset, len,
				"BER Error: malformed gmIdentity encoding, length must be 8 bytes");
		if(hf_index > 0)
		{
			proto_tree_add_string(tree, hf_index, tvb, offset, len, "????");
		}
		return offset;
	}

	gmidentity_ti = proto_tree_add_item(tree, hf_sv_gmidentity, tvb, offset, 8, ENC_BIG_ENDIAN);

	/* EUI-64: vendor ID | 0xFF - 0xFE | card ID */
	if (tvb_get_ntohs(tvb, offset + 3) == 0xFFFE) {
		gmidentity_tree = proto_item_add_subtree(gmidentity_ti, ett_gmidentity);

		manuf_name = tvb_get_manuf_name(tvb, offset);
		proto_tree_add_bytes_format_value(gmidentity_tree, hf_sv_gmidentity_manuf, tvb, offset, 3, NULL, "%%s", manuf_name);
	}

	offset += 8;
#.END

#.END_OF_CNF