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