Move /asn1 to /epan/dissectors
[metze/wireshark/wip.git] / epan / dissectors / asn1 / mms / mms.cnf
1 # mms.cnf
2 # mms conformation file
3
4 #.MODULE_IMPORT
5 ISO-8650-ACSE-1 acse
6
7 #.IMPORT ../acse/acse-exp.cnf
8
9 #.EXPORTS
10 MMSpdu
11
12 #.PDU
13
14 #.NO_EMIT
15
16 #.TYPE_RENAME
17
18 #.TYPE_ATTR
19 TimeOfDay       TYPE = FT_STRING DISPLAY = BASE_NONE
20 UtcTime TYPE = FT_STRING DISPLAY = BASE_NONE
21
22 #.FIELD_RENAME
23
24 #.FN_BODY ApplicationReference/ap-title
25   offset=dissect_acse_AP_title(FALSE, tvb, offset, actx, tree, hf_mms_ap_title);
26
27 #.FN_BODY ApplicationReference/ap-invocation-id
28   offset=dissect_acse_AP_invocation_identifier(FALSE, tvb, offset, actx, tree, hf_mms_ap_invocation_id);
29
30 #.FN_BODY ApplicationReference/ae-qualifier
31   offset=dissect_acse_AE_qualifier(FALSE, tvb, offset, actx, tree, hf_mms_ae_qualifier);
32
33 #.FN_BODY ApplicationReference/ae-invocation-id
34   offset=dissect_acse_AE_invocation_identifier(FALSE, tvb, offset, actx, tree, hf_mms_ae_invocation_id);
35
36 #.FN_BODY MMSpdu VAL_PTR=&branch_taken
37   gint branch_taken;
38
39 %(DEFAULT_BODY)s
40
41   if( (branch_taken!=-1) && mms_MMSpdu_vals[branch_taken].strptr ){
42     col_append_fstr(actx->pinfo->cinfo, COL_INFO, "%%s ", mms_MMSpdu_vals[branch_taken].strptr);
43   }
44
45
46
47 #.FN_BODY TimeOfDay
48
49         guint32 len;
50         guint32 milliseconds;
51         guint16 days;
52         gchar * ptime;
53         nstime_t ts;
54
55         len = tvb_reported_length_remaining(tvb, offset);
56
57         if(len == 4)
58         {
59                 milliseconds = tvb_get_ntohl(tvb, offset);
60                 ptime = time_msecs_to_str(wmem_packet_scope(), milliseconds);
61
62                 if(hf_index >= 0)
63                 {
64                         proto_tree_add_string(tree, hf_index, tvb, offset, len, ptime);
65                 }
66                 return offset;
67         }
68
69         if(len == 6)
70         {
71                 milliseconds = tvb_get_ntohl(tvb, offset);
72                 days = tvb_get_ntohs(tvb, offset+4);
73
74                 /* 5113 days between 01-01-1970 and 01-01-1984 */
75                 /* 86400 seconds in one day */
76
77                 ts.secs = (days + 5113) * 86400 + milliseconds / 1000;
78                 ts.nsecs = (milliseconds %% 1000) * 1000000U;
79
80                 ptime = abs_time_to_str(wmem_packet_scope(), &ts, ABSOLUTE_TIME_UTC, TRUE);
81                 if(hf_index >= 0)
82                 {
83                         proto_tree_add_string(tree, hf_index, tvb, offset, len, ptime);
84                 }
85
86                 return offset;
87         }
88
89         proto_tree_add_expert_format(tree, actx->pinfo, &ei_mms_mal_timeofday_encoding,
90                         tvb, offset, len, "BER Error: malformed TimeOfDay encoding, length must be 4 or 6 bytes");
91         if(hf_index >= 0)
92         {
93                 proto_tree_add_string(tree, hf_index, tvb, offset, len, "????");
94         }
95         return offset;
96
97
98 #.FN_BODY UtcTime
99
100         guint32 len;
101         guint32 seconds;
102         guint32 fraction;
103         guint32 nanoseconds;
104         nstime_t ts;
105         gchar * ptime;
106
107         len = tvb_reported_length_remaining(tvb, offset);
108
109         if(len != 8)
110         {
111                 proto_tree_add_expert_format(tree, actx->pinfo, &ei_mms_mal_utctime_encoding,
112                                 tvb, offset, len, "BER Error: malformed IEC61850 UTCTime encoding, length must be 8 bytes");
113                 if(hf_index >= 0)
114                 {
115                         proto_tree_add_string(tree, hf_index, tvb, offset, len, "????");
116                 }
117                 return offset;
118         }
119
120         seconds = tvb_get_ntohl(tvb, offset);
121         fraction = tvb_get_ntoh24(tvb, offset+4) * 0x100; /* Only 3 bytes are recommended */
122         nanoseconds = (guint32)( ((guint64)fraction * G_GUINT64_CONSTANT(1000000000)) / G_GUINT64_CONSTANT(0x100000000) ) ;
123
124         ts.secs = seconds;
125         ts.nsecs = nanoseconds;
126
127         ptime = abs_time_to_str(wmem_packet_scope(), &ts, ABSOLUTE_TIME_UTC, TRUE);
128
129         if(hf_index >= 0)
130         {
131                 proto_tree_add_string(tree, hf_index, tvb, offset, len, ptime);
132         }
133
134         return offset;