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