4a09e3fedae4a80eec0ed06148689a47c10c3b4d
[obnox/wireshark/wip.git] / plugins / giop / packet-cosnaming.c
1 /* packet-cosnaming.c
2  *
3  * $Id$
4  *
5  * Routines for IDL dissection
6  *
7  * Autogenerated from idl2wrs
8  * Copyright 2001 Frank Singleton <frank.singleton@ericsson.com>
9  */
10
11
12 /*
13  * Wireshark - Network traffic analyzer
14  * By Gerald Combs
15  * Copyright 1999 - 2006 Gerald Combs
16  */
17
18
19 /*
20  * This program is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU General Public License
22  * as published by the Free Software Foundation; either version 2
23  * of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28  * GNU General Public License for more details.
29  *
30  * You should have received a copy of the GNU General Public License
31  * along with this program; if not, write to the Free Software
32  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
33  */
34
35
36 #ifdef HAVE_CONFIG_H
37 # include "config.h"
38 #endif
39
40 #include <gmodule.h>
41
42 #include <string.h>
43 #include <glib.h>
44 #include <epan/packet.h>
45 #include <epan/proto.h>
46 #include <epan/dissectors/packet-giop.h>
47
48 #ifndef ENABLE_STATIC
49 G_MODULE_EXPORT const gchar version[] = "0.0.1";
50 #endif
51
52 #ifdef _MSC_VER
53 /* disable warning: "unreference local variable" */
54 #pragma warning(disable:4101)
55 #endif
56
57
58 static proto_tree *start_dissecting(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset);
59
60
61
62 /* Struct prototype declaration Start */
63
64
65 /* Struct = IDL:omg.org/CosNaming/NameComponent:1.0 */
66
67 static void decode_CosNaming_NameComponent_st(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header _U_, gchar *operation _U_);
68
69
70 /* Struct = IDL:omg.org/CosNaming/Binding:1.0 */
71
72 static void decode_CosNaming_Binding_st(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header _U_, gchar *operation _U_);
73
74
75 /* Struct prototype declaration End */
76
77
78 /* Union prototype declaration Start */
79
80
81 /* Union prototype declaration End */
82
83
84
85 /* Initialise the protocol and subtree pointers */
86
87 static int proto_cosnaming = -1;
88
89 static gint ett_cosnaming = -1;
90
91
92 /* Initialise the initial Alignment */
93
94 static guint32  boundary = GIOP_HEADER_SIZE;  /* initial value */
95
96
97
98 /* Initialise the Registered fields */
99
100 /* TODO - Use registered fields */
101
102 /*
103  * IDL Operations Start
104  */
105  
106 static const char CosNaming_NamingContext_bind_op[] = "bind" ;
107 static const char CosNaming_NamingContext_rebind_op[] = "rebind" ;
108 static const char CosNaming_NamingContext_bind_context_op[] = "bind_context" ;
109 static const char CosNaming_NamingContext_rebind_context_op[] = "rebind_context" ;
110 static const char CosNaming_NamingContext_resolve_op[] = "resolve" ;
111 static const char CosNaming_NamingContext_unbind_op[] = "unbind" ;
112 static const char CosNaming_NamingContext_new_context_op[] = "new_context" ;
113 static const char CosNaming_NamingContext_bind_new_context_op[] = "bind_new_context" ;
114 static const char CosNaming_NamingContext_destroy_op[] = "destroy" ;
115 static const char CosNaming_NamingContext_list_op[] = "list" ;
116 static const char CosNaming_BindingIterator_next_one_op[] = "next_one" ;
117 static const char CosNaming_BindingIterator_next_n_op[] = "next_n" ;
118 static const char CosNaming_BindingIterator_destroy_op[] = "destroy" ;
119
120 /*
121  * IDL Operations End
122  */
123
124 /*  Begin Exception (containing members) String  Declare  */
125
126
127 static const char user_exception_CosNaming_NamingContext_NotFound[] = "IDL:omg.org/CosNaming/NamingContext/NotFound:1.0" ; 
128 static const char user_exception_CosNaming_NamingContext_CannotProceed[] = "IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0" ; 
129
130 /*  End Exception (containing members) String Declare  */
131
132 /*
133  * IDL Attributes Start
134  */
135  
136
137 /*
138  * IDL Attributes End
139  */
140
141 /*
142  * IDL Enums Start
143  */
144  
145 /*
146  * Enum = IDL:omg.org/CosNaming/BindingType:1.0
147  */
148  
149 static const value_string CosNaming_BindingType[] = {
150
151    { 0, "nobject" }, 
152    { 1, "ncontext" }, 
153    { 0,       NULL },
154 };
155
156 /*
157  * Enum = IDL:omg.org/CosNaming/NamingContext/NotFoundReason:1.0
158  */
159  
160 static const value_string CosNaming_NamingContext_NotFoundReason[] = {
161
162    { 0, "missing_node" }, 
163    { 1, "not_context" }, 
164    { 2, "not_object" }, 
165    { 0,       NULL },
166 };
167
168 /*
169  * IDL Enums End
170  */
171  
172 /*  Begin Exception Helper Functions  */
173
174
175 /* Exception = IDL:omg.org/CosNaming/NamingContext/NotFound:1.0 */
176
177 static void decode_ex_CosNaming_NamingContext_NotFound(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header _U_, gchar *operation _U_) {
178
179     gboolean stream_is_big_endian;          /* big endianess */
180
181     
182     /* Operation specific Variable declarations Begin */
183
184     guint32   u_octet4;
185     guint32   u_octet4_loop_NotFound_rest_of_name;
186     guint32   i_NotFound_rest_of_name;
187     
188     /* Operation specific Variable declarations End */
189
190     stream_is_big_endian = is_big_endian(header);  /* get stream endianess */
191
192     
193     u_octet4 = get_CDR_enum(tvb,offset,stream_is_big_endian, boundary);
194     if (tree) {
195        proto_tree_add_text(tree,tvb,*offset-4,4,"Enum value = %u (%s)",u_octet4,val_to_str(u_octet4,CosNaming_NamingContext_NotFoundReason,"Unknown Enum Value"));
196     }
197
198     u_octet4_loop_NotFound_rest_of_name = get_CDR_ulong(tvb, offset, stream_is_big_endian, boundary);
199     if (tree) {
200        proto_tree_add_text(tree,tvb,*offset-4, 4 ,"Seq length of NotFound_rest_of_name = %u",u_octet4_loop_NotFound_rest_of_name);
201     }
202
203     for (i_NotFound_rest_of_name=0; i_NotFound_rest_of_name < u_octet4_loop_NotFound_rest_of_name; i_NotFound_rest_of_name++) {
204
205         /*  Begin struct "CosNaming_NameComponent"  */
206
207         
208
209         decode_CosNaming_NameComponent_st(tvb, pinfo, tree, offset, header, operation);
210
211         /*  End struct "CosNaming_NameComponent"  */
212
213     }
214
215 }
216
217 /* Exception = IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0 */
218
219 static void decode_ex_CosNaming_NamingContext_CannotProceed(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header _U_, gchar *operation _U_) {
220
221     gboolean stream_is_big_endian;          /* big endianess */
222
223     
224     /* Operation specific Variable declarations Begin */
225
226     guint32   u_octet4_loop_CannotProceed_rest_of_name;
227     guint32   i_CannotProceed_rest_of_name;
228     
229     /* Operation specific Variable declarations End */
230
231     stream_is_big_endian = is_big_endian(header);  /* get stream endianess */
232
233     get_CDR_object(tvb, pinfo, tree, offset, stream_is_big_endian, boundary);
234
235
236     u_octet4_loop_CannotProceed_rest_of_name = get_CDR_ulong(tvb, offset, stream_is_big_endian, boundary);
237     if (tree) {
238        proto_tree_add_text(tree,tvb,*offset-4, 4 ,"Seq length of CannotProceed_rest_of_name = %u",u_octet4_loop_CannotProceed_rest_of_name);
239     }
240
241     for (i_CannotProceed_rest_of_name=0; i_CannotProceed_rest_of_name < u_octet4_loop_CannotProceed_rest_of_name; i_CannotProceed_rest_of_name++) {
242
243         /*  Begin struct "CosNaming_NameComponent"  */
244
245         
246
247         decode_CosNaming_NameComponent_st(tvb, pinfo, tree, offset, header, operation);
248
249         /*  End struct "CosNaming_NameComponent"  */
250
251     }
252
253 }
254
255
256 /*  End Exception Helper Functions  */
257
258 /*
259  * Main delegator for exception handling
260  *
261  */
262
263 static gboolean decode_user_exception(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *ptree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_ ) {
264
265     gboolean be _U_;                        /* big endianess */
266     proto_tree *tree _U_;
267
268     if (!header->exception_id)
269         return FALSE;
270
271     if (strcmp(header->exception_id, user_exception_CosNaming_NamingContext_NotFound) == 0) {
272        tree = start_dissecting(tvb, pinfo, ptree, offset);
273        decode_ex_CosNaming_NamingContext_NotFound(tvb, pinfo, tree, offset, header, operation);   /*  IDL:omg.org/CosNaming/NamingContext/NotFound:1.0  */
274        return TRUE;
275     }
276
277     if (strcmp(header->exception_id, user_exception_CosNaming_NamingContext_CannotProceed) == 0) {
278        tree = start_dissecting(tvb, pinfo, ptree, offset);
279        decode_ex_CosNaming_NamingContext_CannotProceed(tvb, pinfo, tree, offset, header, operation);   /*  IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0  */
280        return TRUE;
281     }
282
283
284
285     return FALSE;    /* user exception not found */
286
287 }
288
289 /*  Begin Attribute Helper Functions  */
290
291
292 /*  End Attribute Helper Functions  */
293
294 /*
295  * IDL:omg.org/CosNaming/NamingContext/bind:1.0
296  */
297
298 static void decode_CosNaming_NamingContext_bind(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
299
300     gboolean stream_is_big_endian;          /* big endianess */
301
302     
303     /* Operation specific Variable declarations Begin */
304
305     guint32   u_octet4_loop_n;
306     guint32   i_n;
307     
308     /* Operation specific Variable declarations End */
309
310     stream_is_big_endian = is_big_endian(header);
311
312     switch(header->message_type) {
313
314     case Request:
315
316         u_octet4_loop_n = get_CDR_ulong(tvb, offset, stream_is_big_endian, boundary);
317         if (tree) {
318            proto_tree_add_text(tree,tvb,*offset-4, 4 ,"Seq length of n = %u",u_octet4_loop_n);
319         }
320
321         for (i_n=0; i_n < u_octet4_loop_n; i_n++) {
322
323             /*  Begin struct "CosNaming_NameComponent"  */
324
325             
326
327             decode_CosNaming_NameComponent_st(tvb, pinfo, tree, offset, header, operation);
328
329             /*  End struct "CosNaming_NameComponent"  */
330
331         }
332
333         get_CDR_object(tvb, pinfo, tree, offset, stream_is_big_endian, boundary);
334
335
336         break;
337
338     case Reply:
339
340         switch(header->rep_status) {
341
342         case NO_EXCEPTION:
343
344             /* Function returns void */
345
346             break;
347
348         case USER_EXCEPTION:
349
350             break;
351
352         default:
353
354             /* Unknown Exception */
355
356             g_warning("Unknown Exception ");
357
358             break;
359
360         
361         }   /* switch(header->message_type) */
362
363         break;
364
365     default:
366
367         /* Unknown GIOP Message */
368
369         g_warning("Unknown GIOP Message");
370
371         break;
372
373     } /* switch(header->message_type) */
374
375 }
376
377 /*
378  * IDL:omg.org/CosNaming/NamingContext/rebind:1.0
379  */
380
381 static void decode_CosNaming_NamingContext_rebind(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
382
383     gboolean stream_is_big_endian;          /* big endianess */
384
385     
386     /* Operation specific Variable declarations Begin */
387
388     guint32   u_octet4_loop_n;
389     guint32   i_n;
390     
391     /* Operation specific Variable declarations End */
392
393     stream_is_big_endian = is_big_endian(header);
394
395     switch(header->message_type) {
396
397     case Request:
398
399         u_octet4_loop_n = get_CDR_ulong(tvb, offset, stream_is_big_endian, boundary);
400         if (tree) {
401            proto_tree_add_text(tree,tvb,*offset-4, 4 ,"Seq length of n = %u",u_octet4_loop_n);
402         }
403
404         for (i_n=0; i_n < u_octet4_loop_n; i_n++) {
405
406             /*  Begin struct "CosNaming_NameComponent"  */
407
408             
409
410             decode_CosNaming_NameComponent_st(tvb, pinfo, tree, offset, header, operation);
411
412             /*  End struct "CosNaming_NameComponent"  */
413
414         }
415
416         get_CDR_object(tvb, pinfo, tree, offset, stream_is_big_endian, boundary);
417
418
419         break;
420
421     case Reply:
422
423         switch(header->rep_status) {
424
425         case NO_EXCEPTION:
426
427             /* Function returns void */
428
429             break;
430
431         case USER_EXCEPTION:
432
433             break;
434
435         default:
436
437             /* Unknown Exception */
438
439             g_warning("Unknown Exception ");
440
441             break;
442
443         
444         }   /* switch(header->message_type) */
445
446         break;
447
448     default:
449
450         /* Unknown GIOP Message */
451
452         g_warning("Unknown GIOP Message");
453
454         break;
455
456     } /* switch(header->message_type) */
457
458 }
459
460 /*
461  * IDL:omg.org/CosNaming/NamingContext/bind_context:1.0
462  */
463
464 static void decode_CosNaming_NamingContext_bind_context(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
465
466     gboolean stream_is_big_endian;          /* big endianess */
467
468     
469     /* Operation specific Variable declarations Begin */
470
471     guint32   u_octet4_loop_n;
472     guint32   i_n;
473     
474     /* Operation specific Variable declarations End */
475
476     stream_is_big_endian = is_big_endian(header);
477
478     switch(header->message_type) {
479
480     case Request:
481
482         u_octet4_loop_n = get_CDR_ulong(tvb, offset, stream_is_big_endian, boundary);
483         if (tree) {
484            proto_tree_add_text(tree,tvb,*offset-4, 4 ,"Seq length of n = %u",u_octet4_loop_n);
485         }
486
487         for (i_n=0; i_n < u_octet4_loop_n; i_n++) {
488
489             /*  Begin struct "CosNaming_NameComponent"  */
490
491             
492
493             decode_CosNaming_NameComponent_st(tvb, pinfo, tree, offset, header, operation);
494
495             /*  End struct "CosNaming_NameComponent"  */
496
497         }
498
499         get_CDR_object(tvb, pinfo, tree, offset, stream_is_big_endian, boundary);
500
501
502         break;
503
504     case Reply:
505
506         switch(header->rep_status) {
507
508         case NO_EXCEPTION:
509
510             /* Function returns void */
511
512             break;
513
514         case USER_EXCEPTION:
515
516             break;
517
518         default:
519
520             /* Unknown Exception */
521
522             g_warning("Unknown Exception ");
523
524             break;
525
526         
527         }   /* switch(header->message_type) */
528
529         break;
530
531     default:
532
533         /* Unknown GIOP Message */
534
535         g_warning("Unknown GIOP Message");
536
537         break;
538
539     } /* switch(header->message_type) */
540
541 }
542
543 /*
544  * IDL:omg.org/CosNaming/NamingContext/rebind_context:1.0
545  */
546
547 static void decode_CosNaming_NamingContext_rebind_context(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
548
549     gboolean stream_is_big_endian;          /* big endianess */
550
551     
552     /* Operation specific Variable declarations Begin */
553
554     guint32   u_octet4_loop_n;
555     guint32   i_n;
556     
557     /* Operation specific Variable declarations End */
558
559     stream_is_big_endian = is_big_endian(header);
560
561     switch(header->message_type) {
562
563     case Request:
564
565         u_octet4_loop_n = get_CDR_ulong(tvb, offset, stream_is_big_endian, boundary);
566         if (tree) {
567            proto_tree_add_text(tree,tvb,*offset-4, 4 ,"Seq length of n = %u",u_octet4_loop_n);
568         }
569
570         for (i_n=0; i_n < u_octet4_loop_n; i_n++) {
571
572             /*  Begin struct "CosNaming_NameComponent"  */
573
574             
575
576             decode_CosNaming_NameComponent_st(tvb, pinfo, tree, offset, header, operation);
577
578             /*  End struct "CosNaming_NameComponent"  */
579
580         }
581
582         get_CDR_object(tvb, pinfo, tree, offset, stream_is_big_endian, boundary);
583
584
585         break;
586
587     case Reply:
588
589         switch(header->rep_status) {
590
591         case NO_EXCEPTION:
592
593             /* Function returns void */
594
595             break;
596
597         case USER_EXCEPTION:
598
599             break;
600
601         default:
602
603             /* Unknown Exception */
604
605             g_warning("Unknown Exception ");
606
607             break;
608
609         
610         }   /* switch(header->message_type) */
611
612         break;
613
614     default:
615
616         /* Unknown GIOP Message */
617
618         g_warning("Unknown GIOP Message");
619
620         break;
621
622     } /* switch(header->message_type) */
623
624 }
625
626 /*
627  * IDL:omg.org/CosNaming/NamingContext/resolve:1.0
628  */
629
630 static void decode_CosNaming_NamingContext_resolve(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
631
632     gboolean stream_is_big_endian;          /* big endianess */
633
634     
635     /* Operation specific Variable declarations Begin */
636
637     guint32   u_octet4_loop_n;
638     guint32   i_n;
639     
640     /* Operation specific Variable declarations End */
641
642     stream_is_big_endian = is_big_endian(header);
643
644     switch(header->message_type) {
645
646     case Request:
647
648         u_octet4_loop_n = get_CDR_ulong(tvb, offset, stream_is_big_endian, boundary);
649         if (tree) {
650            proto_tree_add_text(tree,tvb,*offset-4, 4 ,"Seq length of n = %u",u_octet4_loop_n);
651         }
652
653         for (i_n=0; i_n < u_octet4_loop_n; i_n++) {
654
655             /*  Begin struct "CosNaming_NameComponent"  */
656
657             
658
659             decode_CosNaming_NameComponent_st(tvb, pinfo, tree, offset, header, operation);
660
661             /*  End struct "CosNaming_NameComponent"  */
662
663         }
664
665         break;
666
667     case Reply:
668
669         switch(header->rep_status) {
670
671         case NO_EXCEPTION:
672
673             get_CDR_object(tvb, pinfo, tree, offset, stream_is_big_endian, boundary);
674
675
676             break;
677
678         case USER_EXCEPTION:
679
680             break;
681
682         default:
683
684             /* Unknown Exception */
685
686             g_warning("Unknown Exception ");
687
688             break;
689
690         
691         }   /* switch(header->message_type) */
692
693         break;
694
695     default:
696
697         /* Unknown GIOP Message */
698
699         g_warning("Unknown GIOP Message");
700
701         break;
702
703     } /* switch(header->message_type) */
704
705 }
706
707 /*
708  * IDL:omg.org/CosNaming/NamingContext/unbind:1.0
709  */
710
711 static void decode_CosNaming_NamingContext_unbind(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
712
713     gboolean stream_is_big_endian;          /* big endianess */
714
715     
716     /* Operation specific Variable declarations Begin */
717
718     guint32   u_octet4_loop_n;
719     guint32   i_n;
720     
721     /* Operation specific Variable declarations End */
722
723     stream_is_big_endian = is_big_endian(header);
724
725     switch(header->message_type) {
726
727     case Request:
728
729         u_octet4_loop_n = get_CDR_ulong(tvb, offset, stream_is_big_endian, boundary);
730         if (tree) {
731            proto_tree_add_text(tree,tvb,*offset-4, 4 ,"Seq length of n = %u",u_octet4_loop_n);
732         }
733
734         for (i_n=0; i_n < u_octet4_loop_n; i_n++) {
735
736             /*  Begin struct "CosNaming_NameComponent"  */
737
738             
739
740             decode_CosNaming_NameComponent_st(tvb, pinfo, tree, offset, header, operation);
741
742             /*  End struct "CosNaming_NameComponent"  */
743
744         }
745
746         break;
747
748     case Reply:
749
750         switch(header->rep_status) {
751
752         case NO_EXCEPTION:
753
754             /* Function returns void */
755
756             break;
757
758         case USER_EXCEPTION:
759
760             break;
761
762         default:
763
764             /* Unknown Exception */
765
766             g_warning("Unknown Exception ");
767
768             break;
769
770         
771         }   /* switch(header->message_type) */
772
773         break;
774
775     default:
776
777         /* Unknown GIOP Message */
778
779         g_warning("Unknown GIOP Message");
780
781         break;
782
783     } /* switch(header->message_type) */
784
785 }
786
787 /*
788  * IDL:omg.org/CosNaming/NamingContext/new_context:1.0
789  */
790
791 static void decode_CosNaming_NamingContext_new_context(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
792
793     gboolean stream_is_big_endian;          /* big endianess */
794
795     
796     /* Operation specific Variable declarations Begin */
797
798     
799     /* Operation specific Variable declarations End */
800
801     stream_is_big_endian = is_big_endian(header);
802
803     switch(header->message_type) {
804
805     case Request:
806
807         break;
808
809     case Reply:
810
811         switch(header->rep_status) {
812
813         case NO_EXCEPTION:
814
815             get_CDR_object(tvb, pinfo, tree, offset, stream_is_big_endian, boundary);
816
817
818             break;
819
820         case USER_EXCEPTION:
821
822             break;
823
824         default:
825
826             /* Unknown Exception */
827
828             g_warning("Unknown Exception ");
829
830             break;
831
832         
833         }   /* switch(header->message_type) */
834
835         break;
836
837     default:
838
839         /* Unknown GIOP Message */
840
841         g_warning("Unknown GIOP Message");
842
843         break;
844
845     } /* switch(header->message_type) */
846
847 }
848
849 /*
850  * IDL:omg.org/CosNaming/NamingContext/bind_new_context:1.0
851  */
852
853 static void decode_CosNaming_NamingContext_bind_new_context(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
854
855     gboolean stream_is_big_endian;          /* big endianess */
856
857     
858     /* Operation specific Variable declarations Begin */
859
860     guint32   u_octet4_loop_n;
861     guint32   i_n;
862     
863     /* Operation specific Variable declarations End */
864
865     stream_is_big_endian = is_big_endian(header);
866
867     switch(header->message_type) {
868
869     case Request:
870
871         u_octet4_loop_n = get_CDR_ulong(tvb, offset, stream_is_big_endian, boundary);
872         if (tree) {
873            proto_tree_add_text(tree,tvb,*offset-4, 4 ,"Seq length of n = %u",u_octet4_loop_n);
874         }
875
876         for (i_n=0; i_n < u_octet4_loop_n; i_n++) {
877
878             /*  Begin struct "CosNaming_NameComponent"  */
879
880             
881
882             decode_CosNaming_NameComponent_st(tvb, pinfo, tree, offset, header, operation);
883
884             /*  End struct "CosNaming_NameComponent"  */
885
886         }
887
888         break;
889
890     case Reply:
891
892         switch(header->rep_status) {
893
894         case NO_EXCEPTION:
895
896             get_CDR_object(tvb, pinfo, tree, offset, stream_is_big_endian, boundary);
897
898
899             break;
900
901         case USER_EXCEPTION:
902
903             break;
904
905         default:
906
907             /* Unknown Exception */
908
909             g_warning("Unknown Exception ");
910
911             break;
912
913         
914         }   /* switch(header->message_type) */
915
916         break;
917
918     default:
919
920         /* Unknown GIOP Message */
921
922         g_warning("Unknown GIOP Message");
923
924         break;
925
926     } /* switch(header->message_type) */
927
928 }
929
930 /*
931  * IDL:omg.org/CosNaming/NamingContext/destroy:1.0
932  */
933
934 static void decode_CosNaming_NamingContext_destroy(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
935
936     gboolean stream_is_big_endian;          /* big endianess */
937
938     
939     /* Operation specific Variable declarations Begin */
940
941     
942     /* Operation specific Variable declarations End */
943
944     stream_is_big_endian = is_big_endian(header);
945
946     switch(header->message_type) {
947
948     case Request:
949
950         break;
951
952     case Reply:
953
954         switch(header->rep_status) {
955
956         case NO_EXCEPTION:
957
958             /* Function returns void */
959
960             break;
961
962         case USER_EXCEPTION:
963
964             break;
965
966         default:
967
968             /* Unknown Exception */
969
970             g_warning("Unknown Exception ");
971
972             break;
973
974         
975         }   /* switch(header->message_type) */
976
977         break;
978
979     default:
980
981         /* Unknown GIOP Message */
982
983         g_warning("Unknown GIOP Message");
984
985         break;
986
987     } /* switch(header->message_type) */
988
989 }
990
991 /*
992  * IDL:omg.org/CosNaming/NamingContext/list:1.0
993  */
994
995 static void decode_CosNaming_NamingContext_list(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
996
997     gboolean stream_is_big_endian;          /* big endianess */
998
999     
1000     /* Operation specific Variable declarations Begin */
1001
1002     guint32   u_octet4;
1003     guint32   u_octet4_loop_bl;
1004     guint32   i_bl;
1005     
1006     /* Operation specific Variable declarations End */
1007
1008     stream_is_big_endian = is_big_endian(header);
1009
1010     switch(header->message_type) {
1011
1012     case Request:
1013
1014         u_octet4 = get_CDR_ulong(tvb,offset,stream_is_big_endian, boundary);
1015         if (tree) {
1016            proto_tree_add_text(tree,tvb,*offset-4,4,"how_many = %u",u_octet4);
1017         }
1018
1019         break;
1020
1021     case Reply:
1022
1023         switch(header->rep_status) {
1024
1025         case NO_EXCEPTION:
1026
1027             /* Function returns void */
1028
1029             u_octet4_loop_bl = get_CDR_ulong(tvb, offset, stream_is_big_endian, boundary);
1030             if (tree) {
1031                proto_tree_add_text(tree,tvb,*offset-4, 4 ,"Seq length of bl = %u",u_octet4_loop_bl);
1032             }
1033
1034             for (i_bl=0; i_bl < u_octet4_loop_bl; i_bl++) {
1035
1036                 /*  Begin struct "CosNaming_Binding"  */
1037
1038                 
1039
1040                 decode_CosNaming_Binding_st(tvb, pinfo, tree, offset, header, operation);
1041
1042                 /*  End struct "CosNaming_Binding"  */
1043
1044             }
1045
1046             get_CDR_object(tvb, pinfo, tree, offset, stream_is_big_endian, boundary);
1047
1048
1049             break;
1050
1051         case USER_EXCEPTION:
1052
1053             break;
1054
1055         default:
1056
1057             /* Unknown Exception */
1058
1059             g_warning("Unknown Exception ");
1060
1061             break;
1062
1063         
1064         }   /* switch(header->message_type) */
1065
1066         break;
1067
1068     default:
1069
1070         /* Unknown GIOP Message */
1071
1072         g_warning("Unknown GIOP Message");
1073
1074         break;
1075
1076     } /* switch(header->message_type) */
1077
1078 }
1079
1080 /*
1081  * IDL:omg.org/CosNaming/BindingIterator/next_one:1.0
1082  */
1083
1084 static void decode_CosNaming_BindingIterator_next_one(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
1085
1086     gboolean stream_is_big_endian;          /* big endianess */
1087
1088     
1089     /* Operation specific Variable declarations Begin */
1090
1091     guint8    u_octet1;
1092     
1093     /* Operation specific Variable declarations End */
1094
1095     stream_is_big_endian = is_big_endian(header);
1096
1097     switch(header->message_type) {
1098
1099     case Request:
1100
1101         break;
1102
1103     case Reply:
1104
1105         switch(header->rep_status) {
1106
1107         case NO_EXCEPTION:
1108
1109             u_octet1 = get_CDR_boolean(tvb,offset);
1110             if (tree) {
1111                proto_tree_add_text(tree,tvb,*offset-1,1,"Operation_Return_Value = %u",u_octet1);
1112             }
1113
1114             /*  Begin struct "CosNaming_Binding"  */
1115
1116             
1117
1118             decode_CosNaming_Binding_st(tvb, pinfo, tree, offset, header, operation);
1119
1120             /*  End struct "CosNaming_Binding"  */
1121
1122             break;
1123
1124         case USER_EXCEPTION:
1125
1126             break;
1127
1128         default:
1129
1130             /* Unknown Exception */
1131
1132             g_warning("Unknown Exception ");
1133
1134             break;
1135
1136         
1137         }   /* switch(header->message_type) */
1138
1139         break;
1140
1141     default:
1142
1143         /* Unknown GIOP Message */
1144
1145         g_warning("Unknown GIOP Message");
1146
1147         break;
1148
1149     } /* switch(header->message_type) */
1150
1151 }
1152
1153 /*
1154  * IDL:omg.org/CosNaming/BindingIterator/next_n:1.0
1155  */
1156
1157 static void decode_CosNaming_BindingIterator_next_n(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
1158
1159     gboolean stream_is_big_endian;          /* big endianess */
1160
1161     
1162     /* Operation specific Variable declarations Begin */
1163
1164     guint32   u_octet4;
1165     guint8    u_octet1;
1166     guint32   u_octet4_loop_bl;
1167     guint32   i_bl;
1168     
1169     /* Operation specific Variable declarations End */
1170
1171     stream_is_big_endian = is_big_endian(header);
1172
1173     switch(header->message_type) {
1174
1175     case Request:
1176
1177         u_octet4 = get_CDR_ulong(tvb,offset,stream_is_big_endian, boundary);
1178         if (tree) {
1179            proto_tree_add_text(tree,tvb,*offset-4,4,"how_many = %u",u_octet4);
1180         }
1181
1182         break;
1183
1184     case Reply:
1185
1186         switch(header->rep_status) {
1187
1188         case NO_EXCEPTION:
1189
1190             u_octet1 = get_CDR_boolean(tvb,offset);
1191             if (tree) {
1192                proto_tree_add_text(tree,tvb,*offset-1,1,"Operation_Return_Value = %u",u_octet1);
1193             }
1194
1195             u_octet4_loop_bl = get_CDR_ulong(tvb, offset, stream_is_big_endian, boundary);
1196             if (tree) {
1197                proto_tree_add_text(tree,tvb,*offset-4, 4 ,"Seq length of bl = %u",u_octet4_loop_bl);
1198             }
1199
1200             for (i_bl=0; i_bl < u_octet4_loop_bl; i_bl++) {
1201
1202                 /*  Begin struct "CosNaming_Binding"  */
1203
1204                 
1205
1206                 decode_CosNaming_Binding_st(tvb, pinfo, tree, offset, header, operation);
1207
1208                 /*  End struct "CosNaming_Binding"  */
1209
1210             }
1211
1212             break;
1213
1214         case USER_EXCEPTION:
1215
1216             break;
1217
1218         default:
1219
1220             /* Unknown Exception */
1221
1222             g_warning("Unknown Exception ");
1223
1224             break;
1225
1226         
1227         }   /* switch(header->message_type) */
1228
1229         break;
1230
1231     default:
1232
1233         /* Unknown GIOP Message */
1234
1235         g_warning("Unknown GIOP Message");
1236
1237         break;
1238
1239     } /* switch(header->message_type) */
1240
1241 }
1242
1243 /*
1244  * IDL:omg.org/CosNaming/BindingIterator/destroy:1.0
1245  */
1246
1247 static void decode_CosNaming_BindingIterator_destroy(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
1248
1249     gboolean stream_is_big_endian;          /* big endianess */
1250
1251     
1252     /* Operation specific Variable declarations Begin */
1253
1254     
1255     /* Operation specific Variable declarations End */
1256
1257     stream_is_big_endian = is_big_endian(header);
1258
1259     switch(header->message_type) {
1260
1261     case Request:
1262
1263         break;
1264
1265     case Reply:
1266
1267         switch(header->rep_status) {
1268
1269         case NO_EXCEPTION:
1270
1271             /* Function returns void */
1272
1273             break;
1274
1275         case USER_EXCEPTION:
1276
1277             break;
1278
1279         default:
1280
1281             /* Unknown Exception */
1282
1283             g_warning("Unknown Exception ");
1284
1285             break;
1286
1287         
1288         }   /* switch(header->message_type) */
1289
1290         break;
1291
1292     default:
1293
1294         /* Unknown GIOP Message */
1295
1296         g_warning("Unknown GIOP Message");
1297
1298         break;
1299
1300     } /* switch(header->message_type) */
1301
1302 }
1303
1304 /* Struct = IDL:omg.org/CosNaming/NameComponent:1.0 */
1305
1306 static void decode_CosNaming_NameComponent_st(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header _U_, gchar *operation _U_) {
1307
1308     gboolean stream_is_big_endian;          /* big endianess */
1309
1310     
1311     /* Operation specific Variable declarations Begin */
1312
1313     guint32   u_octet4;
1314     gchar   *seq = NULL;
1315     
1316     /* Operation specific Variable declarations End */
1317
1318     stream_is_big_endian = is_big_endian(header);  /* get stream endianess */
1319
1320     u_octet4 = get_CDR_string(tvb, &seq, offset, stream_is_big_endian, boundary);
1321     if (tree) {
1322        proto_tree_add_text(tree,tvb,*offset-u_octet4,u_octet4,"NameComponent_id (%u) = %s",
1323           u_octet4, (u_octet4 > 0) ? seq : "");
1324     }
1325
1326     g_free(seq);          /*  free buffer  */
1327     seq = NULL;
1328
1329     u_octet4 = get_CDR_string(tvb, &seq, offset, stream_is_big_endian, boundary);
1330     if (tree) {
1331        proto_tree_add_text(tree,tvb,*offset-u_octet4,u_octet4,"NameComponent_kind (%u) = %s",
1332           u_octet4, (u_octet4 > 0) ? seq : "");
1333     }
1334
1335     g_free(seq);          /*  free buffer  */
1336     seq = NULL;
1337
1338 }
1339
1340 /* Struct = IDL:omg.org/CosNaming/Binding:1.0 */
1341
1342 static void decode_CosNaming_Binding_st(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header _U_, gchar *operation _U_) {
1343
1344     gboolean stream_is_big_endian;          /* big endianess */
1345
1346     
1347     /* Operation specific Variable declarations Begin */
1348
1349     guint32   u_octet4_loop_Binding_binding_name;
1350     guint32   i_Binding_binding_name;
1351     guint32   u_octet4;
1352     
1353     /* Operation specific Variable declarations End */
1354
1355     stream_is_big_endian = is_big_endian(header);  /* get stream endianess */
1356
1357     u_octet4_loop_Binding_binding_name = get_CDR_ulong(tvb, offset, stream_is_big_endian, boundary);
1358     if (tree) {
1359        proto_tree_add_text(tree,tvb,*offset-4, 4 ,"Seq length of Binding_binding_name = %u",u_octet4_loop_Binding_binding_name);
1360     }
1361
1362     for (i_Binding_binding_name=0; i_Binding_binding_name < u_octet4_loop_Binding_binding_name; i_Binding_binding_name++) {
1363
1364         /*  Begin struct "CosNaming_NameComponent"  */
1365
1366         
1367
1368         decode_CosNaming_NameComponent_st(tvb, pinfo, tree, offset, header, operation);
1369
1370         /*  End struct "CosNaming_NameComponent"  */
1371
1372     }
1373
1374     
1375     u_octet4 = get_CDR_enum(tvb,offset,stream_is_big_endian, boundary);
1376     if (tree) {
1377        proto_tree_add_text(tree,tvb,*offset-4,4,"Enum value = %u (%s)",u_octet4,val_to_str(u_octet4,CosNaming_BindingType,"Unknown Enum Value"));
1378     }
1379
1380 }
1381
1382 /*
1383  * Called once we accept the packet as being for us; it sets the
1384  * Protocol and Info columns and creates the top-level protocol
1385  * tree item.
1386  */
1387 static proto_tree *start_dissecting(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset) {
1388
1389     proto_item *ti = NULL;
1390     proto_tree *tree = NULL;            /* init later, inside if(tree) */
1391
1392     col_set_str(pinfo->cinfo, COL_PROTOCOL, "COSNAMING");
1393
1394     /*
1395      * Do not clear COL_INFO, as nothing is being written there by
1396      * this dissector yet. So leave it as is from the GIOP dissector.
1397      * TODO: add something useful to COL_INFO
1398      *     col_clear(pinfo->cinfo, COL_INFO);
1399      */
1400
1401     if (ptree) {
1402         ti = proto_tree_add_item(ptree, proto_cosnaming, tvb, *offset, -1, ENC_NA);
1403         tree = proto_item_add_subtree(ti, ett_cosnaming);
1404     }
1405     return tree;
1406 }
1407
1408 static gboolean dissect_cosnaming(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset, MessageHeader *header, gchar *operation, gchar *idlname) {
1409
1410     gboolean be;                        /* big endianess */
1411     proto_tree *tree _U_;
1412
1413     be = is_big_endian(header);         /* get endianess - TODO use passed in stream_is_big_endian instead ? */
1414
1415     /* If we have a USER Exception, then decode it and return */
1416
1417     if ((header->message_type == Reply) && (header->rep_status == USER_EXCEPTION)) {
1418
1419        return decode_user_exception(tvb, pinfo, ptree, offset, header, operation);
1420
1421     }
1422
1423     switch(header->message_type) {
1424
1425     case Request:
1426     case Reply:
1427
1428         if (strcmp(operation, CosNaming_NamingContext_bind_op) == 0
1429             && (!idlname || strcmp(idlname, "CosNaming/NamingContext") == 0)) {
1430            tree = start_dissecting(tvb, pinfo, ptree, offset);
1431            decode_CosNaming_NamingContext_bind(tvb, pinfo, tree, offset, header, operation);
1432            return TRUE;
1433         }
1434
1435         if (strcmp(operation, CosNaming_NamingContext_rebind_op) == 0
1436             && (!idlname || strcmp(idlname, "CosNaming/NamingContext") == 0)) {
1437            tree = start_dissecting(tvb, pinfo, ptree, offset);
1438            decode_CosNaming_NamingContext_rebind(tvb, pinfo, tree, offset, header, operation);
1439            return TRUE;
1440         }
1441
1442         if (strcmp(operation, CosNaming_NamingContext_bind_context_op) == 0
1443             && (!idlname || strcmp(idlname, "CosNaming/NamingContext") == 0)) {
1444            tree = start_dissecting(tvb, pinfo, ptree, offset);
1445            decode_CosNaming_NamingContext_bind_context(tvb, pinfo, tree, offset, header, operation);
1446            return TRUE;
1447         }
1448
1449         if (strcmp(operation, CosNaming_NamingContext_rebind_context_op) == 0
1450             && (!idlname || strcmp(idlname, "CosNaming/NamingContext") == 0)) {
1451            tree = start_dissecting(tvb, pinfo, ptree, offset);
1452            decode_CosNaming_NamingContext_rebind_context(tvb, pinfo, tree, offset, header, operation);
1453            return TRUE;
1454         }
1455
1456         if (strcmp(operation, CosNaming_NamingContext_resolve_op) == 0
1457             && (!idlname || strcmp(idlname, "CosNaming/NamingContext") == 0)) {
1458            tree = start_dissecting(tvb, pinfo, ptree, offset);
1459            decode_CosNaming_NamingContext_resolve(tvb, pinfo, tree, offset, header, operation);
1460            return TRUE;
1461         }
1462
1463         if (strcmp(operation, CosNaming_NamingContext_unbind_op) == 0
1464             && (!idlname || strcmp(idlname, "CosNaming/NamingContext") == 0)) {
1465            tree = start_dissecting(tvb, pinfo, ptree, offset);
1466            decode_CosNaming_NamingContext_unbind(tvb, pinfo, tree, offset, header, operation);
1467            return TRUE;
1468         }
1469
1470         if (strcmp(operation, CosNaming_NamingContext_new_context_op) == 0
1471             && (!idlname || strcmp(idlname, "CosNaming/NamingContext") == 0)) {
1472            tree = start_dissecting(tvb, pinfo, ptree, offset);
1473            decode_CosNaming_NamingContext_new_context(tvb, pinfo, tree, offset, header, operation);
1474            return TRUE;
1475         }
1476
1477         if (strcmp(operation, CosNaming_NamingContext_bind_new_context_op) == 0
1478             && (!idlname || strcmp(idlname, "CosNaming/NamingContext") == 0)) {
1479            tree = start_dissecting(tvb, pinfo, ptree, offset);
1480            decode_CosNaming_NamingContext_bind_new_context(tvb, pinfo, tree, offset, header, operation);
1481            return TRUE;
1482         }
1483
1484         if (strcmp(operation, CosNaming_NamingContext_destroy_op) == 0
1485             && (!idlname || strcmp(idlname, "CosNaming/NamingContext") == 0)) {
1486            tree = start_dissecting(tvb, pinfo, ptree, offset);
1487            decode_CosNaming_NamingContext_destroy(tvb, pinfo, tree, offset, header, operation);
1488            return TRUE;
1489         }
1490
1491         if (strcmp(operation, CosNaming_NamingContext_list_op) == 0
1492             && (!idlname || strcmp(idlname, "CosNaming/NamingContext") == 0)) {
1493            tree = start_dissecting(tvb, pinfo, ptree, offset);
1494            decode_CosNaming_NamingContext_list(tvb, pinfo, tree, offset, header, operation);
1495            return TRUE;
1496         }
1497
1498         if (strcmp(operation, CosNaming_BindingIterator_next_one_op) == 0
1499             && (!idlname || strcmp(idlname, "CosNaming/BindingIterator") == 0)) {
1500            tree = start_dissecting(tvb, pinfo, ptree, offset);
1501            decode_CosNaming_BindingIterator_next_one(tvb, pinfo, tree, offset, header, operation);
1502            return TRUE;
1503         }
1504
1505         if (strcmp(operation, CosNaming_BindingIterator_next_n_op) == 0
1506             && (!idlname || strcmp(idlname, "CosNaming/BindingIterator") == 0)) {
1507            tree = start_dissecting(tvb, pinfo, ptree, offset);
1508            decode_CosNaming_BindingIterator_next_n(tvb, pinfo, tree, offset, header, operation);
1509            return TRUE;
1510         }
1511
1512         if (strcmp(operation, CosNaming_BindingIterator_destroy_op) == 0
1513             && (!idlname || strcmp(idlname, "CosNaming/BindingIterator") == 0)) {
1514            tree = start_dissecting(tvb, pinfo, ptree, offset);
1515            decode_CosNaming_BindingIterator_destroy(tvb, pinfo, tree, offset, header, operation);
1516            return TRUE;
1517         }
1518
1519         
1520         break;
1521
1522     case CancelRequest:
1523     case LocateRequest:
1524     case LocateReply:
1525     case CloseConnection:
1526     case MessageError:
1527     case Fragment:
1528        return FALSE;      /* not handled yet */
1529
1530     default:
1531        return FALSE;      /* not handled yet */
1532
1533     }   /* switch */
1534
1535
1536     return FALSE;
1537
1538 }  /* End of main dissector  */
1539
1540
1541
1542 /* Register the protocol with Wireshark */
1543
1544 void proto_register_giop_cosnaming(void) {
1545
1546    /* setup list of header fields */
1547
1548 #if 0
1549    static hf_register_info hf[] = {
1550
1551       /* no fields yet */
1552
1553    };
1554 #endif
1555
1556    /* setup protocol subtree array */
1557
1558    static gint *ett[] = {
1559       &ett_cosnaming,
1560    };
1561
1562    /* Register the protocol name and description */
1563
1564    proto_cosnaming = proto_register_protocol("Cosnaming Dissector Using GIOP API" , "COSNAMING", "giop-cosnaming" );
1565
1566 #if 0
1567    proto_register_field_array(proto_cosnaming, hf, array_length(hf));
1568 #endif
1569    proto_register_subtree_array(ett,array_length(ett));
1570
1571 }
1572
1573
1574 /* register me as handler for these interfaces */
1575
1576 void proto_register_handoff_giop_cosnaming(void) {
1577
1578
1579     
1580     /* Register for Explicit Dissection */
1581
1582     register_giop_user_module(dissect_cosnaming, "COSNAMING", "CosNaming/BindingIterator", proto_cosnaming );     /* explicit dissector */
1583
1584     
1585     /* Register for Explicit Dissection */
1586
1587     register_giop_user_module(dissect_cosnaming, "COSNAMING", "CosNaming/NamingContext", proto_cosnaming );     /* explicit dissector */
1588
1589     
1590     /* Register for Heuristic Dissection */
1591
1592     register_giop_user(dissect_cosnaming, "COSNAMING" ,proto_cosnaming);     /* heuristic dissector */
1593
1594
1595 }
1596
1597
1598 #ifndef ENABLE_STATIC
1599
1600 G_MODULE_EXPORT void
1601 plugin_register(void)
1602 {
1603    if (proto_cosnaming == -1) {
1604      proto_register_giop_cosnaming();
1605    }
1606 }
1607
1608 G_MODULE_EXPORT void
1609 plugin_reg_handoff(void){
1610    proto_register_handoff_giop_cosnaming();
1611 }
1612 #endif
1613