epan/dissectors/pidl/ C99 drsuapi
[wireshark-sm.git] / epan / dissectors / asn1 / atn-ulcs / atn-ulcs.cnf
blob890436c31c903539da5781c52be5eda7d8fe185c
1 #.MODULE_IMPORT
3 #.FIELD_RENAME
4 AARQ-apdu/protocol-version  aarq-apdu_protocol-version
5 AARE-apdu/protocol-version  aare-apdu_protocol-version
6 RLRE-apdu/reason  rlre-apdu_response_reason
7 RLRQ-apdu/reason  rlrq-apdu_request_reason
8 EXTERNALt/encoding/single-ASN1-type externalt_encoding_single-asn1-type
9 EXTERNALt/encoding/arbitrary  externalt_encoding_arbitrary
10 EXTERNALt/encoding/octet-aligned  externalt_encoding_octet-aligned
11 PDV-list/presentation-data-values/single-ASN1-type  pdv-list_presentation-data-values_single-asn1-type
12 PDV-list/presentation-data-values/arbitrary pdv-list_presentation-data-values_arbitrary
13 #.END
15 #.PDU
16   Fully-encoded-data
17   ACSE-apdu
18 #.END
21 #.FN_PARS Release-request-reason
22   VAL_PTR=&reason
23 #.END
26 #.FN_BODY Presentation-context-identifier
28     offset = dissect_per_constrained_integer(
29         tvb,
30         offset,
31         actx,
32         tree,
33         hf_index,
34         1U,
35         127U,
36         &ulcs_context_value,
37         true);
39 #.END
41 #.FN_BODY PDV-list/presentation-data-values/arbitrary
43     packet_info * pinfo = actx->pinfo;
44     tvbuff_t *tvb_usr = NULL;
45     proto_tree *atn_ulcs_tree = NULL;
46     atn_conversation_t *atn_cv = NULL;
47     heur_dtbl_entry_t *hdtbl_entry;
49     /* extract bitstring into new tvb buffer */
50     offset = dissect_per_bit_string(
51         tvb,
52         offset,
53         actx,
54         tree,
55         hf_index,
56         NO_BOUND,
57         NO_BOUND,
58         false,
59         NULL,
60         0,
61         &tvb_usr,
62         NULL);
64     if (tvb_usr) {
65       /* call appropriate dissector for bitstring data */
66       switch(ulcs_context_value){
67           case  1: /* ACSE PDU*/
68               atn_ulcs_tree = proto_tree_add_subtree(
69                   root_tree, tvb, offset, 0,
70                   ett_atn_acse, NULL, ATN_ACSE_PROTO );
72               dissect_ACSE_apdu_PDU(
73                   tvb_new_subset_remaining(tvb_usr, 0),
74                   pinfo,
75                   atn_ulcs_tree, NULL);
76               break;
77             case  3: /* USER data; call subdissector for CM, CPDLC ...  */
79                 /* using dstref for PDV-list only occurs in DT */
80                 atn_cv = find_atn_conversation(
81                     &pinfo->dst,
82                     pinfo->clnp_dstref,
83                     &pinfo->src);
85                 if(atn_cv) {
86                     switch(atn_cv->ae_qualifier){
87                         case cma: /* contact management */
88                             call_dissector_with_data(
89                                 atn_cm_handle,
90                                 tvb_new_subset_remaining(tvb_usr, 0),
91                                 pinfo,
92                                 root_tree,
93                                 NULL);
94                             break;
95                         case cpdlc: /* plain old cpdlc */
96                         case pmcpdlc: /* protected mode cpdlc */
97                             call_dissector_with_data(
98                                 atn_cpdlc_handle,
99                                 tvb_new_subset_remaining(tvb_usr, 0),
100                                 pinfo,
101                                 root_tree,
102                                 NULL);
103                             break;
104                         default: /* unknown or unhandled datalink application */
105                             dissector_try_heuristic(
106                                 atn_ulcs_heur_subdissector_list,
107                                 tvb_new_subset_remaining(tvb_usr,0),
108                                 actx->pinfo,
109                                 root_tree,
110                                 &hdtbl_entry,
111                                 NULL);
112                             break;
113                     }
114                 }
115                 else{
116                     dissector_try_heuristic(
117                         atn_ulcs_heur_subdissector_list,
118                         tvb_new_subset_remaining(tvb_usr,0),
119                         actx->pinfo,
120                         root_tree,
121                         &hdtbl_entry,
122                         NULL);
123                 }
124                 break;
125             default:
126                 break;
127       } /* switch(ulcs_context_value) */
128     }
130 #.END
133 #.FN_BODY Authentication-value/other/other-mechanism-value
135     offset=call_ber_oid_callback(
136         object_identifier_id,
137         tvb,
138         offset,
139         actx->pinfo,
140         tree, NULL);
142 #.END
144 #.FN_BODY       Mechanism-name
146     offset = dissect_per_object_identifier(
147         tvb,
148         offset,
149         actx,
150         tree,
151         hf_index,
152         NULL);
154 #.END
157 #.FN_BODY Authentication-value/other/other-mechanism-value
159     offset=call_ber_oid_callback(
160         object_identifier_id,
161         tvb,
162         offset,
163         actx->pinfo,
164         tree, NULL);
166 #.END
168 #.FN_BODY AE-qualifier-form2
169     packet_info * pinfo = actx->pinfo;
170     atn_conversation_t *atn_cv = NULL;
171     uint32_t ae_qualifier = 0;
173     /* dissect  ae-qualifier */
174     offset = dissect_per_integer(
175         tvb,
176         offset,
177         actx,
178         tree,
179         hf_index,
180         &ae_qualifier);
183     /*note: */
184     /* the field "calling-AE-qualifier" is optional, */
185     /* which means that we can exploit it only if it is present. */
186     /* We still depend on heuristical decoding of CM, CPDLC PDU's otherwise. */
188     /* AARQ/DT: dstref present, srcref is always zero */
189     if((pinfo->clnp_dstref) && (!pinfo->clnp_srcref)){
190         atn_cv = find_atn_conversation(&pinfo->dst,
191             pinfo->clnp_dstref,
192             &pinfo->src );
193     }
195     /* AARQ/CR: srcref present, dstref is always zero */
196     if((!pinfo->clnp_dstref) && (pinfo->clnp_srcref)){
197         atn_cv = find_atn_conversation(&pinfo->src,
198             pinfo->clnp_srcref,
199             &pinfo->dst );
200   }
202   if(atn_cv){
203       atn_cv->ae_qualifier = ae_qualifier;
204   }
205 #.END
207 #.FN_BODY AARQ-apdu
208     packet_info * pinfo = actx->pinfo;
209     aarq_data_t *aarq_data = NULL;
210     atn_conversation_t *atn_cv = NULL;
211     uint32_t aircraft_24_bit_address = 0;
213     /* AARQ/DT: dstref present, srcref is always zero */
214     if((pinfo->clnp_dstref) && (!pinfo->clnp_srcref)){
216         atn_cv = find_atn_conversation(
217             &pinfo->dst,
218             pinfo->clnp_dstref,
219             &pinfo->src );
220         if(!atn_cv){
221             atn_cv = wmem_new(wmem_file_scope(), atn_conversation_t);
222             atn_cv->ae_qualifier = unknown;
223             create_atn_conversation(&pinfo->dst,
224                 pinfo->clnp_dstref,
225                 &pinfo->src ,
226                 atn_cv);
227         }
228     }
230   /* AARQ/CR: srcref present, dstref is always zero */
231     if((!pinfo->clnp_dstref) && (pinfo->clnp_srcref)){
232         atn_cv = find_atn_conversation(&pinfo->src,
233             pinfo->clnp_srcref,
234             &pinfo->dst );
235         if(!atn_cv){
236             atn_cv = wmem_new(wmem_file_scope(), atn_conversation_t);
237             atn_cv->ae_qualifier = unknown;
238             create_atn_conversation(&pinfo->src,
239                 pinfo->clnp_srcref,
240                 &pinfo->dst ,
241                 atn_cv);
242         }
243     }
245     /* conversation is to be created prior to decoding */
246     /* of "AE-qualifier-form2" which takes place here: */
247     %(DEFAULT_BODY)s
250     /* save AARQ packet data to create a conversation  */
251     /* when decoding the following AARE PDU */
252     /* ATN applications CM and CPDLC are air/ground applications */
253     /* so there is always an aircraft (with its 24-bit address) */
254     /* and a ground facility. */
255     /* the assumption is that there is only one open AARQ/AARE */
256     /* dialog per aircraft at a time. */
257     /* the aircraft's 24-bit address is used as a key to each AARQ */
258     /* data. AARQ data is used to create a conversation with */
259     /* air and ground endpoints (based on NSAP's and transport references) */
260     /* when decoding AARE.*/
261     /* note: */
262     /* it may be more robust to create the conversation */
263     /* in the "ositp" dissector an to merely use the conversation here */
264     aircraft_24_bit_address =
265         get_aircraft_24_bit_address_from_nsap(pinfo);
267     /* search for aarq entry */
268     aarq_data = (aarq_data_t *) wmem_tree_lookup32(
269         aarq_data_tree,
270         aircraft_24_bit_address);
272     if(!aarq_data){  /* aarq data not found, create new record */
274         /* alloc aarq data */
275         aarq_data = wmem_new(wmem_file_scope(), aarq_data_t);
276         aarq_data-> aarq_pending = false;
278         /* insert aarq data */
279         wmem_tree_insert32(aarq_data_tree ,aircraft_24_bit_address,(void*)aarq_data);
280     }
282     /* check for pending AARQ/AARE sequences */
283     /* if "aarq_data-> aarq_pending" is set this means that there is already one  */
284     /* AARQ/AARE sequence pending (is unwise to overwrite AARE/AARQ) */
285     if (aarq_data-> aarq_pending == false ) {
287       /* init aarq data */
288       memset(aarq_data,0,sizeof(aarq_data_t));
290       aarq_data->cv = atn_cv;
291       aarq_data-> aarq_pending = true;
292     }
294 #.END
297 #.FN_BODY AARE-apdu
298   packet_info * pinfo = actx->pinfo;
299   uint32_t aircraft_24_bit_address = 0 ;
300   atn_conversation_t *atn_cv = NULL;
301   aarq_data_t *aarq_data = NULL;
303   /* get AARQ data and use it to create a new conversation, */
304   /* the conversation is used along with  */
305   /* AARQ's "calling ae qualifier" to determine the */
306   /* type of air/ground application of each subsequent frame.*/
307   /* we use this information to invoke the correct application dissector. */
308   /* note: */
309   /* heuristical decoding of ASN1 will not work for all cases, */
310   /* for there may be CM PDU's which will exactly look like CPDLC PDU'S */
312   /* get 24-bit icao address */
313   aircraft_24_bit_address = get_aircraft_24_bit_address_from_nsap(pinfo);
315   /* search for aarq entry */
316   aarq_data = (aarq_data_t *) wmem_tree_lookup32(
317       aarq_data_tree,
318       aircraft_24_bit_address);
320   /* no aarq data present, do nothing  */
321   /* without both ends of the conversation and without */
322   /* the "calling ae-qualifier there is no point in setting up "*/
323   /* a conversation */
324   if(!aarq_data) {
326     return offset;
327   }
329   /* AARE/DT: dstref present, srcref is always zero */
330   if((pinfo->clnp_dstref) && (!pinfo->clnp_srcref)){
332     atn_cv = find_atn_conversation(&pinfo->dst,
333                           pinfo->clnp_dstref,
334                           &pinfo->src );
336     if(!atn_cv){ /* conversation not fond */
338       /* DT has only dstref - create new conversation */
339       create_atn_conversation(&pinfo->dst,
340                               pinfo->clnp_dstref,
341                               &pinfo->src ,
342                               aarq_data->cv);
343     }
344   }
346   /* AARE/CC: srcref and dstref present  */
347   if((pinfo->clnp_dstref) && (pinfo->clnp_srcref)){
349     atn_cv = find_atn_conversation(
350         &pinfo->src,
351         pinfo->clnp_srcref,
352         &pinfo->dst);
354     if(atn_cv){ /* conversation found. */
356       /* create new conversation for dstref */
357       create_atn_conversation(&pinfo->dst,
358                               pinfo->clnp_dstref,
359                               &pinfo->src ,
360                               aarq_data->cv);
362     }else { /* no conversation found  */
363       /* as CC contains srcref *and* dstref we use both to create new records  */
364       create_atn_conversation(&pinfo->src,
365                               pinfo->clnp_srcref,
366                               &pinfo->dst ,
367                               aarq_data->cv);
368       create_atn_conversation(&pinfo->dst,
369                               pinfo->clnp_dstref,
370                               &pinfo->src ,
371                               aarq_data->cv);
372     }
373   }
375   /* clear aarq data */
376   memset(aarq_data,0,sizeof(aarq_data_t));
377   aarq_data-> aarq_pending  =  false;
379   %(DEFAULT_BODY)s
382 #.END
385 #.FN_BODY Associate-result
386  /* extension present: last param set to true. asn2wrs didn't take notice of that */
387  offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
388                                                             0U, 2U, NULL, true);
389 #.END
391 #.FN_BODY Release-request-reason
392  /* extension present: last param set to true. asn2wrs didn't take notice of that */
393  offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
394                                                             0U, 30U, NULL, true);
395 #.END
397 #.FN_BODY Release-response-reason
399  /* extension present: last param set to true. asn2wrs didn't take notice of that */
400  offset = dissect_per_constrained_integer(
401     tvb,
402     offset,
403     actx,
404     tree,
405     hf_index,
406     0U,
407     30U,
408     NULL,
409     true);
411 #.END
413 #.FN_BODY Mechanism-name
415   offset = dissect_per_object_identifier(
416       tvb,
417       offset,
418       actx,
419       tree,
420       hf_index,
421       NULL);
423 #.END
425 #.FN_BODY RDNSequence
427   /*
428    * atn-ulcs.asn currently defines
429    *
430    * RDNSequence  ::= SEQUENCE OF RelativeDistinguishedName
431    * RelativeDistinguishedName ::= SET SIZE (1 .. MAX) OF AttributeTypeAndValue
432    * AttributeTypeAndValue ::= SEQUENCE { null NULL}
433    *
434    * which makes it easy to spam the dissection tree with null items. Dissect
435    * the first item only.
436    */
437   offset = dissect_per_constrained_sequence_of(tvb, offset, actx, tree, hf_index,
438                                       ett_atn_ulcs_RDNSequence, RDNSequence_sequence_of,
439                                       1, 1, false);
441 #.END
443 #.FN_BODY RelativeDistinguishedName
445   /*
446    * Dissect the first null item only, similar to RDNSequence.
447    */
448   offset = dissect_per_constrained_set_of(tvb, offset, actx, tree, hf_index,
449                                              ett_atn_ulcs_RelativeDistinguishedName, RelativeDistinguishedName_set_of,
450                                              1, 1, false);
452 #.END
454 #.FN_BODY EXTERNALt/data-value-descriptor
456   offset = dissect_per_octet_string(
457       tvb,
458       offset,
459       actx,
460       tree,
461       hf_index,
462       -1,
463       -1,
464       false,
465       &actx->external.data_value_descriptor);
466   actx->external.data_value_descr_present = true;
468 #.END
470 #.FN_BODY EXTERNALt/encoding/single-ASN1-type
472   %(DEFAULT_BODY)s
474 #.END
476 #.FN_BODY EXTERNALt/encoding/octet-aligned
478   %(DEFAULT_BODY)s
480 #.END
482 #.FN_BODY EXTERNALt/encoding/arbitrary
483   tvbuff_t *tvb_usr = NULL;
484   packet_info * pinfo = actx->pinfo;
485   atn_conversation_t *atn_cv = NULL;
486   heur_dtbl_entry_t *hdtbl_entry;
488   /* decode bit-string user data within ACSE  */
489   offset = dissect_per_bit_string(
490     tvb,
491     offset,
492     actx,
493     tree, hf_index,
494     NO_BOUND,
495     NO_BOUND,
496     false,
497     NULL,
498     0,
499     &tvb_usr,
500     NULL);
502   if (tvb_usr) {
503     /* DT: dstref present, srcref is always zero */
504     if((pinfo->clnp_dstref) && (!pinfo->clnp_srcref)){
506       atn_cv = find_atn_conversation(
507           &pinfo->dst,
508           pinfo->clnp_dstref,
509           &pinfo->src);
510     }
511     /* CR: srcref present, dstref always zero */
512     if((pinfo->clnp_srcref) && (!pinfo->clnp_dstref)){
514       atn_cv = find_atn_conversation(
515           &pinfo->src,
516           pinfo->clnp_srcref,
517           &pinfo->dst);
518     }
519     /* CC: srcref and dstref present */
520     if((pinfo->clnp_srcref) && (pinfo->clnp_dstref)){
522       atn_cv = find_atn_conversation(
523           &pinfo->src,
524           pinfo->clnp_srcref,
525           &pinfo->dst);
526     }
528     if(atn_cv) {
529         switch(atn_cv->ae_qualifier){
530           case cma: /* contact management */
532               call_dissector_with_data(
533                     atn_cm_handle,
534                     tvb_new_subset_remaining(tvb_usr, 0),
535                     pinfo,
536                     root_tree,
537                     NULL);
538               break;
539           case cpdlc: /* plain old cpdlc */
540           case pmcpdlc: /* protected mode cpdlc */
542               call_dissector_with_data(
543                     atn_cpdlc_handle,
544                     tvb_new_subset_remaining(tvb_usr, 0),
545                     pinfo,
546                     root_tree,
547                     NULL);
548               break;
549           default: /* unknown or unhandled datalink application */
551               dissector_try_heuristic(
552                   atn_ulcs_heur_subdissector_list,
553                   tvb_new_subset_remaining(tvb_usr,0),
554                   actx->pinfo,
555                   root_tree,
556                   &hdtbl_entry,
557                   NULL);
558                 break;
559           }
560     }else {
562       dissector_try_heuristic(
563               atn_ulcs_heur_subdissector_list,
564               tvb_new_subset_remaining(tvb_usr,0),
565               actx->pinfo,
566               root_tree,
567               &hdtbl_entry,
568               NULL);
569     }
570   }
572   offset += tvb_reported_length_remaining(tvb, offset);
574 #.END
577 # Editor modelines  -  https://www.wireshark.org/tools/modelines.html
579 # Local variables:
580 # c-basic-offset: 4
581 # tab-width: 8
582 # indent-tabs-mode: nil
583 # End:
585 # vi: set shiftwidth=4 tabstop=8 expandtab:
586 # :indentSize=4:tabSize=8:noTabs=true: