6373db5a94558f60bee3cd742112e8419a6d6912
[obnox/wireshark/wip.git] / plugins / giop / packet-coseventcomm.c
1 /* packet-coseventcomm.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 prototype declaration End */
66
67
68 /* Union prototype declaration Start */
69
70
71 /* Union prototype declaration End */
72
73
74
75 /* Initialise the protocol and subtree pointers */
76
77 static int proto_coseventcomm = -1;
78
79 static gint ett_coseventcomm = -1;
80
81
82 /* Initialise the initial Alignment */
83
84 static guint32  boundary = GIOP_HEADER_SIZE;  /* initial value */
85
86
87
88 /* Initialise the Registered fields */
89
90 /* TODO - Use registered fields */
91
92 /*
93  * IDL Operations Start
94  */
95  
96 static const char CosEventComm_PushConsumer_push_op[] = "push" ;
97 static const char CosEventComm_PushConsumer_disconnect_push_consumer_op[] = "disconnect_push_consumer" ;
98 static const char CosEventComm_PushSupplier_disconnect_push_supplier_op[] = "disconnect_push_supplier" ;
99 static const char CosEventComm_PullSupplier_pull_op[] = "pull" ;
100 static const char CosEventComm_PullSupplier_try_pull_op[] = "try_pull" ;
101 static const char CosEventComm_PullSupplier_disconnect_pull_supplier_op[] = "disconnect_pull_supplier" ;
102 static const char CosEventComm_PullConsumer_disconnect_pull_consumer_op[] = "disconnect_pull_consumer" ;
103
104 /*
105  * IDL Operations End
106  */
107
108 /*  Begin Exception (containing members) String  Declare  */
109
110
111
112 /*  End Exception (containing members) String Declare  */
113
114 /*
115  * IDL Attributes Start
116  */
117  
118
119 /*
120  * IDL Attributes End
121  */
122
123 /*
124  * IDL Enums Start
125  */
126  
127 /*
128  * IDL Enums End
129  */
130  
131 /*  Begin Exception Helper Functions  */
132
133
134
135 /*  End Exception Helper Functions  */
136
137 /*
138  * Main delegator for exception handling
139  *
140  */
141
142 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_ ) {
143
144     gboolean be _U_;                        /* big endianess */
145     proto_tree *tree _U_;
146
147     if (!header->exception_id)
148         return FALSE;
149
150
151
152     return FALSE;    /* user exception not found */
153
154 }
155
156 /*  Begin Attribute Helper Functions  */
157
158
159 /*  End Attribute Helper Functions  */
160
161 /*
162  * IDL:omg.org/CosEventComm/PushConsumer/push:1.0
163  */
164
165 static void decode_CosEventComm_PushConsumer_push(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
166
167     gboolean stream_is_big_endian;          /* big endianess */
168
169     
170     /* Operation specific Variable declarations Begin */
171
172     
173     /* Operation specific Variable declarations End */
174
175     stream_is_big_endian = is_big_endian(header);
176
177     switch(header->message_type) {
178
179     case Request:
180
181         get_CDR_any(tvb,tree,offset,stream_is_big_endian, boundary, header);
182
183         break;
184
185     case Reply:
186
187         switch(header->rep_status) {
188
189         case NO_EXCEPTION:
190
191             /* Function returns void */
192
193             break;
194
195         case USER_EXCEPTION:
196
197             break;
198
199         default:
200
201             /* Unknown Exception */
202
203             g_warning("Unknown Exception ");
204
205             break;
206
207         
208         }   /* switch(header->message_type) */
209
210         break;
211
212     default:
213
214         /* Unknown GIOP Message */
215
216         g_warning("Unknown GIOP Message");
217
218         break;
219
220     } /* switch(header->message_type) */
221
222 }
223
224 /*
225  * IDL:omg.org/CosEventComm/PushConsumer/disconnect_push_consumer:1.0
226  */
227
228 static void decode_CosEventComm_PushConsumer_disconnect_push_consumer(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
229
230     gboolean stream_is_big_endian;          /* big endianess */
231
232     
233     /* Operation specific Variable declarations Begin */
234
235     
236     /* Operation specific Variable declarations End */
237
238     stream_is_big_endian = is_big_endian(header);
239
240     switch(header->message_type) {
241
242     case Request:
243
244         break;
245
246     case Reply:
247
248         switch(header->rep_status) {
249
250         case NO_EXCEPTION:
251
252             /* Function returns void */
253
254             break;
255
256         case USER_EXCEPTION:
257
258             break;
259
260         default:
261
262             /* Unknown Exception */
263
264             g_warning("Unknown Exception ");
265
266             break;
267
268         
269         }   /* switch(header->message_type) */
270
271         break;
272
273     default:
274
275         /* Unknown GIOP Message */
276
277         g_warning("Unknown GIOP Message");
278
279         break;
280
281     } /* switch(header->message_type) */
282
283 }
284
285 /*
286  * IDL:omg.org/CosEventComm/PushSupplier/disconnect_push_supplier:1.0
287  */
288
289 static void decode_CosEventComm_PushSupplier_disconnect_push_supplier(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
290
291     gboolean stream_is_big_endian;          /* big endianess */
292
293     
294     /* Operation specific Variable declarations Begin */
295
296     
297     /* Operation specific Variable declarations End */
298
299     stream_is_big_endian = is_big_endian(header);
300
301     switch(header->message_type) {
302
303     case Request:
304
305         break;
306
307     case Reply:
308
309         switch(header->rep_status) {
310
311         case NO_EXCEPTION:
312
313             /* Function returns void */
314
315             break;
316
317         case USER_EXCEPTION:
318
319             break;
320
321         default:
322
323             /* Unknown Exception */
324
325             g_warning("Unknown Exception ");
326
327             break;
328
329         
330         }   /* switch(header->message_type) */
331
332         break;
333
334     default:
335
336         /* Unknown GIOP Message */
337
338         g_warning("Unknown GIOP Message");
339
340         break;
341
342     } /* switch(header->message_type) */
343
344 }
345
346 /*
347  * IDL:omg.org/CosEventComm/PullSupplier/pull:1.0
348  */
349
350 static void decode_CosEventComm_PullSupplier_pull(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
351
352     gboolean stream_is_big_endian;          /* big endianess */
353
354     
355     /* Operation specific Variable declarations Begin */
356
357     
358     /* Operation specific Variable declarations End */
359
360     stream_is_big_endian = is_big_endian(header);
361
362     switch(header->message_type) {
363
364     case Request:
365
366         break;
367
368     case Reply:
369
370         switch(header->rep_status) {
371
372         case NO_EXCEPTION:
373
374             get_CDR_any(tvb,tree,offset,stream_is_big_endian, boundary, header);
375
376             break;
377
378         case USER_EXCEPTION:
379
380             break;
381
382         default:
383
384             /* Unknown Exception */
385
386             g_warning("Unknown Exception ");
387
388             break;
389
390         
391         }   /* switch(header->message_type) */
392
393         break;
394
395     default:
396
397         /* Unknown GIOP Message */
398
399         g_warning("Unknown GIOP Message");
400
401         break;
402
403     } /* switch(header->message_type) */
404
405 }
406
407 /*
408  * IDL:omg.org/CosEventComm/PullSupplier/try_pull:1.0
409  */
410
411 static void decode_CosEventComm_PullSupplier_try_pull(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
412
413     gboolean stream_is_big_endian;          /* big endianess */
414
415     
416     /* Operation specific Variable declarations Begin */
417
418     guint8    u_octet1;
419     
420     /* Operation specific Variable declarations End */
421
422     stream_is_big_endian = is_big_endian(header);
423
424     switch(header->message_type) {
425
426     case Request:
427
428         break;
429
430     case Reply:
431
432         switch(header->rep_status) {
433
434         case NO_EXCEPTION:
435
436             get_CDR_any(tvb,tree,offset,stream_is_big_endian, boundary, header);
437
438             u_octet1 = get_CDR_boolean(tvb,offset);
439             if (tree) {
440                proto_tree_add_text(tree,tvb,*offset-1,1,"has_event = %u",u_octet1);
441             }
442
443             break;
444
445         case USER_EXCEPTION:
446
447             break;
448
449         default:
450
451             /* Unknown Exception */
452
453             g_warning("Unknown Exception ");
454
455             break;
456
457         
458         }   /* switch(header->message_type) */
459
460         break;
461
462     default:
463
464         /* Unknown GIOP Message */
465
466         g_warning("Unknown GIOP Message");
467
468         break;
469
470     } /* switch(header->message_type) */
471
472 }
473
474 /*
475  * IDL:omg.org/CosEventComm/PullSupplier/disconnect_pull_supplier:1.0
476  */
477
478 static void decode_CosEventComm_PullSupplier_disconnect_pull_supplier(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
479
480     gboolean stream_is_big_endian;          /* big endianess */
481
482     
483     /* Operation specific Variable declarations Begin */
484
485     
486     /* Operation specific Variable declarations End */
487
488     stream_is_big_endian = is_big_endian(header);
489
490     switch(header->message_type) {
491
492     case Request:
493
494         break;
495
496     case Reply:
497
498         switch(header->rep_status) {
499
500         case NO_EXCEPTION:
501
502             /* Function returns void */
503
504             break;
505
506         case USER_EXCEPTION:
507
508             break;
509
510         default:
511
512             /* Unknown Exception */
513
514             g_warning("Unknown Exception ");
515
516             break;
517
518         
519         }   /* switch(header->message_type) */
520
521         break;
522
523     default:
524
525         /* Unknown GIOP Message */
526
527         g_warning("Unknown GIOP Message");
528
529         break;
530
531     } /* switch(header->message_type) */
532
533 }
534
535 /*
536  * IDL:omg.org/CosEventComm/PullConsumer/disconnect_pull_consumer:1.0
537  */
538
539 static void decode_CosEventComm_PullConsumer_disconnect_pull_consumer(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_) {
540
541     gboolean stream_is_big_endian;          /* big endianess */
542
543     
544     /* Operation specific Variable declarations Begin */
545
546     
547     /* Operation specific Variable declarations End */
548
549     stream_is_big_endian = is_big_endian(header);
550
551     switch(header->message_type) {
552
553     case Request:
554
555         break;
556
557     case Reply:
558
559         switch(header->rep_status) {
560
561         case NO_EXCEPTION:
562
563             /* Function returns void */
564
565             break;
566
567         case USER_EXCEPTION:
568
569             break;
570
571         default:
572
573             /* Unknown Exception */
574
575             g_warning("Unknown Exception ");
576
577             break;
578
579         
580         }   /* switch(header->message_type) */
581
582         break;
583
584     default:
585
586         /* Unknown GIOP Message */
587
588         g_warning("Unknown GIOP Message");
589
590         break;
591
592     } /* switch(header->message_type) */
593
594 }
595
596 /*
597  * Called once we accept the packet as being for us; it sets the
598  * Protocol and Info columns and creates the top-level protocol
599  * tree item.
600  */
601 static proto_tree *start_dissecting(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset) {
602
603     proto_item *ti = NULL;
604     proto_tree *tree = NULL;            /* init later, inside if(tree) */
605
606     col_set_str(pinfo->cinfo, COL_PROTOCOL, "COSEVENTCOMM");
607
608     /*
609      * Do not clear COL_INFO, as nothing is being written there by
610      * this dissector yet. So leave it as is from the GIOP dissector.
611      * TODO: add something useful to COL_INFO
612      *     col_clear(pinfo->cinfo, COL_INFO);
613      */
614
615     if (ptree) {
616         ti = proto_tree_add_item(ptree, proto_coseventcomm, tvb, *offset, -1, ENC_NA);
617         tree = proto_item_add_subtree(ti, ett_coseventcomm);
618     }
619     return tree;
620 }
621
622 static gboolean dissect_coseventcomm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset, MessageHeader *header, gchar *operation, gchar *idlname) {
623
624     gboolean be;                        /* big endianess */
625     proto_tree *tree _U_;
626
627     be = is_big_endian(header);         /* get endianess - TODO use passed in stream_is_big_endian instead ? */
628
629     /* If we have a USER Exception, then decode it and return */
630
631     if ((header->message_type == Reply) && (header->rep_status == USER_EXCEPTION)) {
632
633        return decode_user_exception(tvb, pinfo, ptree, offset, header, operation);
634
635     }
636
637     switch(header->message_type) {
638
639     case Request:
640     case Reply:
641
642         if (strcmp(operation, CosEventComm_PushConsumer_push_op) == 0
643             && (!idlname || strcmp(idlname, "CosEventComm/PushConsumer") == 0)) {
644            tree = start_dissecting(tvb, pinfo, ptree, offset);
645            decode_CosEventComm_PushConsumer_push(tvb, pinfo, tree, offset, header, operation);
646            return TRUE;
647         }
648
649         if (strcmp(operation, CosEventComm_PushConsumer_disconnect_push_consumer_op) == 0
650             && (!idlname || strcmp(idlname, "CosEventComm/PushConsumer") == 0)) {
651            tree = start_dissecting(tvb, pinfo, ptree, offset);
652            decode_CosEventComm_PushConsumer_disconnect_push_consumer(tvb, pinfo, tree, offset, header, operation);
653            return TRUE;
654         }
655
656         if (strcmp(operation, CosEventComm_PushSupplier_disconnect_push_supplier_op) == 0
657             && (!idlname || strcmp(idlname, "CosEventComm/PushSupplier") == 0)) {
658            tree = start_dissecting(tvb, pinfo, ptree, offset);
659            decode_CosEventComm_PushSupplier_disconnect_push_supplier(tvb, pinfo, tree, offset, header, operation);
660            return TRUE;
661         }
662
663         if (strcmp(operation, CosEventComm_PullSupplier_pull_op) == 0
664             && (!idlname || strcmp(idlname, "CosEventComm/PullSupplier") == 0)) {
665            tree = start_dissecting(tvb, pinfo, ptree, offset);
666            decode_CosEventComm_PullSupplier_pull(tvb, pinfo, tree, offset, header, operation);
667            return TRUE;
668         }
669
670         if (strcmp(operation, CosEventComm_PullSupplier_try_pull_op) == 0
671             && (!idlname || strcmp(idlname, "CosEventComm/PullSupplier") == 0)) {
672            tree = start_dissecting(tvb, pinfo, ptree, offset);
673            decode_CosEventComm_PullSupplier_try_pull(tvb, pinfo, tree, offset, header, operation);
674            return TRUE;
675         }
676
677         if (strcmp(operation, CosEventComm_PullSupplier_disconnect_pull_supplier_op) == 0
678             && (!idlname || strcmp(idlname, "CosEventComm/PullSupplier") == 0)) {
679            tree = start_dissecting(tvb, pinfo, ptree, offset);
680            decode_CosEventComm_PullSupplier_disconnect_pull_supplier(tvb, pinfo, tree, offset, header, operation);
681            return TRUE;
682         }
683
684         if (strcmp(operation, CosEventComm_PullConsumer_disconnect_pull_consumer_op) == 0
685             && (!idlname || strcmp(idlname, "CosEventComm/PullConsumer") == 0)) {
686            tree = start_dissecting(tvb, pinfo, ptree, offset);
687            decode_CosEventComm_PullConsumer_disconnect_pull_consumer(tvb, pinfo, tree, offset, header, operation);
688            return TRUE;
689         }
690
691         
692         break;
693
694     case CancelRequest:
695     case LocateRequest:
696     case LocateReply:
697     case CloseConnection:
698     case MessageError:
699     case Fragment:
700        return FALSE;      /* not handled yet */
701
702     default:
703        return FALSE;      /* not handled yet */
704
705     }   /* switch */
706
707
708     return FALSE;
709
710 }  /* End of main dissector  */
711
712
713
714 /* Register the protocol with Wireshark */
715
716 void proto_register_giop_coseventcomm(void) {
717
718    /* setup list of header fields */
719
720 #if 0
721    static hf_register_info hf[] = {
722
723       /* no fields yet */
724
725    };
726 #endif
727
728    /* setup protocol subtree array */
729
730    static gint *ett[] = {
731       &ett_coseventcomm,
732    };
733
734    /* Register the protocol name and description */
735
736    proto_coseventcomm = proto_register_protocol("Coseventcomm Dissector Using GIOP API" , "COSEVENTCOMM", "giop-coseventcomm" );
737
738 #if 0
739    proto_register_field_array(proto_coseventcomm, hf, array_length(hf));
740 #endif
741    proto_register_subtree_array(ett,array_length(ett));
742
743 }
744
745
746 /* register me as handler for these interfaces */
747
748 void proto_register_handoff_giop_coseventcomm(void) {
749
750
751     
752     /* Register for Explicit Dissection */
753
754     register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PullConsumer", proto_coseventcomm );     /* explicit dissector */
755
756     
757     /* Register for Explicit Dissection */
758
759     register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PullSupplier", proto_coseventcomm );     /* explicit dissector */
760
761     
762     /* Register for Explicit Dissection */
763
764     register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PushConsumer", proto_coseventcomm );     /* explicit dissector */
765
766     
767     /* Register for Explicit Dissection */
768
769     register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PushSupplier", proto_coseventcomm );     /* explicit dissector */
770
771     
772     /* Register for Heuristic Dissection */
773
774     register_giop_user(dissect_coseventcomm, "COSEVENTCOMM" ,proto_coseventcomm);     /* heuristic dissector */
775
776
777 }
778
779
780 #ifndef ENABLE_STATIC
781
782 G_MODULE_EXPORT void
783 plugin_register(void)
784 {
785    if (proto_coseventcomm == -1) {
786      proto_register_giop_coseventcomm();
787    }
788 }
789
790 G_MODULE_EXPORT void
791 plugin_reg_handoff(void){
792    proto_register_handoff_giop_coseventcomm();
793 }
794 #endif
795