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