]> git.pld-linux.org Git - packages/tcpdump.git/blob - tcpdump-giop.patch
- release 2,
[packages/tcpdump.git] / tcpdump-giop.patch
1 diff -ruN tcpdump_3_5rel2.old/Makefile.in tcpdump_3_5rel2/Makefile.in
2 --- tcpdump_3_5rel2.old/Makefile.in     Fri Jul 14 14:13:34 2000
3 +++ tcpdump_3_5rel2/Makefile.in Fri Jul 14 14:23:20 2000
4 @@ -66,7 +66,7 @@
5  CSRC = tcpdump.c \
6         print-arp.c print-atalk.c print-atm.c print-bootp.c \
7         print-decnet.c print-domain.c print-dvmrp.c print-egp.c \
8 -       print-ether.c print-fddi.c print-gre.c print-icmp.c \
9 +       print-ether.c print-fddi.c print-giop.c print-gre.c print-icmp.c \
10         print-igrp.c print-ip.c print-ipx.c print-isoclns.c print-krb.c \
11         print-llc.c print-nfs.c print-ntp.c print-null.c print-ospf.c \
12         print-pim.c print-ppp.c print-raw.c print-rip.c print-sl.c \
13 diff -ruN tcpdump_3_5rel2.old/interface.h tcpdump_3_5rel2/interface.h
14 --- tcpdump_3_5rel2.old/interface.h     Wed Dec 22 16:44:09 1999
15 +++ tcpdump_3_5rel2/interface.h Fri Jul 14 14:28:18 2000
16 @@ -38,6 +38,7 @@
17  extern int dflag;              /* print filter code */
18  extern int eflag;              /* print ethernet header */
19  extern int fflag;              /* don't translate "foreign" IP address */
20 +extern int gflag;              /* decode GIOP */
21  extern int nflag;              /* leave addresses as numbers */
22  extern int Nflag;              /* remove domains from printed host names */
23  extern int qflag;              /* quick (shorter) output */
24 @@ -261,3 +262,4 @@
25  extern void dhcp6_print(const u_char *, u_int, u_short, u_short);
26  #endif /*INET6*/
27  extern u_short in_cksum(const u_short *addr, register int len, u_short csum);
28 +extern void giop_print(const u_char *, u_int);
29 diff -ruN tcpdump_3_5rel2.old/print-giop.c tcpdump_3_5rel2/print-giop.c
30 --- tcpdump_3_5rel2.old/print-giop.c    Thu Jan  1 01:00:00 1970
31 +++ tcpdump_3_5rel2/print-giop.c        Fri Jul 14 14:23:20 2000
32 @@ -0,0 +1,477 @@
33 +#include <stdio.h>
34 +#include <stdlib.h>
35 +
36 +#include <netinet/in.h>
37 +#include "interface.h"
38 +
39 +enum {
40 +       GIOP_REQUEST,
41 +       GIOP_REPLY,
42 +       GIOP_CANCEL_REQUEST,
43 +       GIOP_LOCATE_REQUEST,
44 +       GIOP_LOCATE_REPLY,
45 +       GIOP_CLOSE_CONNECTION,
46 +       GIOP_MESSAGE_ERROR,
47 +       GIOP_FRAGMENT
48 +};
49 +
50 +static struct tok type2str[] = {
51 +       {GIOP_REQUEST, "Request"},
52 +       {GIOP_REPLY, "Reply"},
53 +       {GIOP_CANCEL_REQUEST, "Cancel Request"},
54 +       {GIOP_LOCATE_REQUEST, "Locate Request"},
55 +       {GIOP_LOCATE_REPLY, "Locate Reply"},
56 +       {GIOP_CLOSE_CONNECTION, "Close Connection"},
57 +       {GIOP_MESSAGE_ERROR, "Message Error"},
58 +       {GIOP_FRAGMENT, "Fragment"},
59 +       {0, NULL}
60 +};
61 +
62 +static const u_char *
63 +giop_get(const u_char *bp, void *val, int octets, int convert)
64 +{
65 +       u_char *align;
66 +       int i=octets;
67 +
68 +       if(bp>snapend || bp==NULL)
69 +               return(NULL);
70 +
71 +       align=(u_char *)(((long)bp+(octets-1))&~(octets-1));
72 +
73 +       while(i--)
74 +               if(convert)
75 +                       ((u_char *)val)[i]=(u_char)align[(octets-1)-i];
76 +               else
77 +                       ((u_char *)val)[i]=(u_char)align[i];
78 +       
79 +       return(align+octets);
80 +}
81 +
82 +static const u_char *
83 +giop_get_string(const u_char *bp, u_char *buf, int maxlen, int convert)
84 +{
85 +       u_int32_t len;
86 +
87 +       if(bp>snapend || bp==NULL)
88 +               return(NULL);
89 +
90 +       bp=giop_get(bp, &len, 4, convert);
91 +
92 +       if(buf==NULL)
93 +               return(bp+len);
94 +
95 +       if(len>maxlen)
96 +               memcpy(buf, bp, maxlen);
97 +       else
98 +               memcpy(buf, bp, len);
99 +
100 +       return(bp+len);
101 +}
102 +
103 +static void
104 +giop_print_request(const u_char *bp, u_int length, int version, int convert)
105 +{
106 +       u_char buf[256];
107 +       u_int32_t seqlen, request_id;
108 +       u_int8_t response;
109 +
110 +       /* IOP_ServiceContextList service context */
111 +       /* sequence<IOP_ServiceContext> */
112 +       bp=giop_get(bp, &seqlen, 4, convert);
113 +       if(bp==NULL) {
114 +               printf(" [|request]");
115 +               return;
116 +       }
117 +
118 +       if(seqlen)
119 +               printf(" context items: %d", seqlen);
120 +
121 +       /* unsigned long context id */
122 +       /* sequence<octet> data */
123 +       while(seqlen>0) {
124 +               u_int32_t context_id, datalen;
125 +
126 +               bp=giop_get(bp, &context_id, 4, convert);
127 +               if(bp==NULL) {
128 +                       printf(" [|request]");
129 +                       return;
130 +               }
131 +
132 +               printf(" ID: %d", context_id);
133 +
134 +               bp=giop_get_string(bp, buf, 255, convert);
135 +               if(bp==NULL) {
136 +                       printf(" [|request]");
137 +                       return;
138 +               }
139 +               printf(" data {%s}", buf);
140 +
141 +               seqlen--;
142 +       }
143 +       /* unsigned long request ID */
144 +
145 +       bp=giop_get(bp, &request_id, 4, convert);
146 +       if(bp==NULL) {
147 +               printf(" [|request]");
148 +               return;
149 +       }
150 +       printf(" request ID: %d", request_id);
151 +
152 +       /* boolean response expected */
153 +
154 +       bp=giop_get(bp, &response, 1, convert);
155 +       if(bp==NULL) {
156 +               printf(" [|request]");
157 +               return;
158 +       }
159 +       printf("%sresponse expected", response?" ":" no ");
160 +
161 +       /* in GIOP 1.1 there is an array "octet reserved[3]" here now. */
162 +       /* Alignment checks will skip it automatically */
163 +
164 +       /* sequence<octet> object key */
165 +       bp=giop_get_string(bp, buf, 255, convert);
166 +       if(bp==NULL) {
167 +               printf(" [|request]");
168 +               return;
169 +       }
170 +       printf(" %s", buf);
171 +
172 +       /* char * operation */
173 +       bp=giop_get_string(bp, buf, 255, convert);
174 +       if(bp==NULL) {
175 +               printf(" [|request]");
176 +               return;
177 +       }
178 +       printf("/%s", buf);
179 +
180 +       /* principal requesting principal */
181 +       /* is there anything interesting to print here? skip for now */
182 +       bp=giop_get_string(bp, NULL, 0, convert);
183 +       if(bp==NULL) {
184 +               printf(" [|request]");
185 +               return;
186 +       }
187 +
188 +       /* Now come the parameters, but we need to IDL (or IR) to know how to
189 +          decode them :-( */
190 +}
191 +
192 +enum {
193 +       GIOP_REPLY_NO_EXCEPTION,
194 +       GIOP_REPLY_USER_EXCEPTION,
195 +       GIOP_REPLY_SYSTEM_EXCEPTION,
196 +       GIOP_REPLY_LOCATION_FORWARD
197 +};
198 +
199 +static struct tok reply2str[] = {
200 +       {GIOP_REPLY_NO_EXCEPTION, "No Exception"},
201 +       {GIOP_REPLY_USER_EXCEPTION, "User Exception"},
202 +       {GIOP_REPLY_SYSTEM_EXCEPTION, "System Exception"},
203 +       {GIOP_REPLY_LOCATION_FORWARD, "Location Forward"},
204 +       {0, NULL}
205 +};
206 +
207 +enum {
208 +       GIOP_COMPLETION_YES,
209 +       GIOP_COMPLETION_NO,
210 +       GIOP_COMPLETION_MAYBE
211 +};
212 +
213 +static struct tok completion2str[] = {
214 +       {GIOP_COMPLETION_YES, "Yes"},
215 +       {GIOP_COMPLETION_NO, "No"},
216 +       {GIOP_COMPLETION_MAYBE, "Maybe"},
217 +       {0, NULL}
218 +};
219 +
220 +static void
221 +giop_print_reply(const u_char *bp, u_int length, int version, int convert)
222 +{
223 +       u_char buf[256];
224 +       u_int32_t seqlen, request_id, type;
225 +
226 +       /* IOP_ServiceContextList service context */
227 +       /* sequence<IOP_ServiceContext> */
228 +       bp=giop_get(bp, &seqlen, 4, convert);
229 +       if(bp==NULL) {
230 +               printf(" [|reply]");
231 +               return;
232 +       }
233 +
234 +       if(seqlen)
235 +               printf(" context items: %d", seqlen);
236 +
237 +       /* unsigned long context id */
238 +       /* sequence<octet> data */
239 +       while(seqlen>0) {
240 +               u_int32_t context_id, datalen;
241 +
242 +               bp=giop_get(bp, &context_id, 4, convert);
243 +               if(bp==NULL) {
244 +                       printf(" [|reply]");
245 +                       return;
246 +               }
247 +
248 +               printf(" ID: %d", context_id);
249 +
250 +               bp=giop_get_string(bp, buf, 255, convert);
251 +               if(bp==NULL) {
252 +                       printf(" [|reply]");
253 +                       return;
254 +               }
255 +               printf(" data {%s}", buf);
256 +
257 +               seqlen--;
258 +       }
259 +
260 +       /* unsigned long request id */
261 +
262 +       bp=giop_get(bp, &request_id, 4, convert);
263 +       if(bp==NULL) {
264 +               printf(" [|reply]");
265 +               return;
266 +       }
267 +       printf(" request ID: %d", request_id);
268 +
269 +       /* reply type */
270 +
271 +       bp=giop_get(bp, &type, 4, convert);
272 +       if(bp==NULL) {
273 +               printf(" [|reply]");
274 +               return;
275 +       }
276 +       printf(" status: %s", tok2str(reply2str, NULL, type));
277 +
278 +       /* for "no exception" returns, the encoded parameters come next */
279 +       /* for "user exception" and "system exception", the exception code
280 +          comes next */
281 +       if(type==GIOP_REPLY_SYSTEM_EXCEPTION) {
282 +               u_int32_t completion, minor;
283 +
284 +               bp=giop_get_string(bp, buf, 255, convert);
285 +               if(bp==NULL) {
286 +                       printf(" [|reply]");
287 +                       return;
288 +               }
289 +               printf(" System Exception {%s}", buf);
290 +               
291 +               bp=giop_get(bp, &minor, 4, convert);
292 +               bp=giop_get(bp, &completion, 4, convert);
293 +               if(bp==NULL) {
294 +                       printf(" [|reply]");
295 +                       return;
296 +               }
297 +
298 +               printf(" minor code %d", minor);
299 +               printf(" Completion: %s", tok2str(completion2str, NULL, completion));
300 +       } else if(type==GIOP_REPLY_LOCATION_FORWARD) {
301 +               bp=giop_get_string(bp, buf, 255, convert);
302 +               if(bp==NULL) {
303 +                       printf(" [|reply]");
304 +                       return;
305 +               }
306 +               printf(" Location: %s", buf);
307 +       }
308 +}
309 +
310 +static void
311 +giop_print_cancel_request(const u_char *bp, u_int length, int version, int convert)
312 +{
313 +       u_int32_t request_id;
314 +
315 +       /* unsigned long request id */
316 +
317 +       bp=giop_get(bp, &request_id, 4, convert);
318 +       if(bp==NULL) {
319 +               printf(" [|cancel request]");
320 +               return;
321 +       }
322 +       printf(" request ID: %d", request_id);
323 +}
324 +
325 +static void
326 +giop_print_locate_request(const u_char *bp, u_int length, int version, int convert)
327 +{
328 +       u_char buf[256];
329 +       u_int32_t request_id;
330 +
331 +       /* unsigned long request id */
332 +
333 +       bp=giop_get(bp, &request_id, 4, convert);
334 +       if(bp==NULL) {
335 +               printf(" [|locate request]");
336 +               return;
337 +       }
338 +       printf(" request ID: %d", request_id);
339 +
340 +       /* sequence<octet> object key */
341 +
342 +       bp=giop_get_string(bp, buf, 255, convert);
343 +       if(bp==NULL) {
344 +               printf(" [|locate request]");
345 +               return;
346 +       }
347 +       printf(" %s", buf);
348 +}
349 +
350 +enum {
351 +       GIOP_LOCATE_UNKNOWN_OBJECT,
352 +       GIOP_LOCATE_OBJECT_HERE,
353 +       GIOP_LOCATE_OBJECT_FORWARD
354 +};
355 +
356 +static struct tok locate2str[] = {
357 +       {GIOP_LOCATE_UNKNOWN_OBJECT, "Unknown Object"},
358 +       {GIOP_LOCATE_OBJECT_HERE, "Object Here"},
359 +       {GIOP_LOCATE_OBJECT_FORWARD, "Object Forward"},
360 +       {0, NULL}
361 +};
362 +
363 +static void
364 +giop_print_locate_reply(const u_char *bp, u_int length, int version, int convert)
365 +{
366 +       u_char buf[256];
367 +       u_int32_t request_id, status;
368 +
369 +       /* unsigned long request id */
370 +
371 +       bp=giop_get(bp, &request_id, 4, convert);
372 +       if(bp==NULL) {
373 +               printf(" [|locate reply]");
374 +               return;
375 +       }
376 +       printf(" request ID: %d", request_id);
377 +
378 +       /* locate status */
379 +
380 +       bp=giop_get(bp, &status, 4, convert);
381 +       if(bp==NULL) {
382 +               printf(" [|locate reply]");
383 +               return;
384 +       }
385 +       printf(" status: %s", tok2str(locate2str, NULL, status));
386 +
387 +       /* if status is "object forward", a objref follows here */
388 +       if(status==GIOP_LOCATE_OBJECT_FORWARD) {
389 +               bp=giop_get_string(bp, buf, 255, convert);
390 +               if(bp==NULL) {
391 +                       printf(" [|locate reply]");
392 +                       return;
393 +               }
394 +               printf(" Location: %s", buf);
395 +       }
396 +}
397 +
398 +static void
399 +giop_print_close_connection(const u_char *bp, u_int length, int version, int convert)
400 +{
401 +       /* emtpy */
402 +}
403 +
404 +static void
405 +giop_print_message_error(const u_char *bp, u_int length, int version, int convert)
406 +{
407 +       /* emtpy */
408 +}
409 +
410 +static void
411 +giop_print_fragment(const u_char *bp, u_int length, int version, int convert)
412 +{
413 +       /* not implemented yet */
414 +}
415 +
416 +struct _GIOP_header {
417 +       u_int8_t magic[4];
418 +       u_int8_t version[2];
419 +       u_int8_t flags;
420 +       u_int8_t type;
421 +       u_int32_t size;
422 +};
423 +
424 +void
425 +giop_print(const u_char *bp, u_int length)
426 +{
427 +       struct _GIOP_header *gp;
428 +       int version, byteorder, fragments;
429 +#ifdef WORDS_BIGENDIAN
430 +       int hostbyteorder=0;
431 +#else
432 +       int hostbyteorder=1;
433 +#endif
434 +
435 +       if(bp + sizeof(struct _GIOP_header) > snapend) {
436 +               printf(" [|GIOP]");
437 +               return;
438 +       }
439 +       printf(" [GIOP]");
440 +
441 +       gp=(struct _GIOP_header *)bp;
442 +       version=gp->version[0]*100 + gp->version[1];
443 +
444 +       printf(" v%d.%d", gp->version[0], gp->version[1]);
445 +       if(version!=100 && version!=101)
446 +               printf("!");
447 +
448 +       printf(" %s", tok2str(type2str, "Type %d", gp->type));
449 +
450 +       if(version==100 && gp->type==GIOP_FRAGMENT)
451 +               printf("!");
452 +       
453 +       if(version==100) {
454 +               byteorder=gp->flags;
455 +               fragments=0;
456 +       } else if(version==101) {
457 +               byteorder=gp->flags&0x1;
458 +               fragments=gp->flags&0x2;
459 +       }
460 +
461 +       if(byteorder) {
462 +               if(!hostbyteorder)
463 +                       printf(" (LE)");
464 +       } else {
465 +               if(hostbyteorder)
466 +                       printf(" (BE)");
467 +       }
468 +
469 +       if(fragments) {
470 +               printf(" +");
471 +       }
472 +
473 +       switch(gp->type) {
474 +       case GIOP_REQUEST:
475 +               giop_print_request((u_char *)(bp+sizeof(struct _GIOP_header)), gp->size, version, byteorder!=hostbyteorder);
476 +               break;
477 +
478 +       case GIOP_REPLY:
479 +               giop_print_reply((u_char *)(bp+sizeof(struct _GIOP_header)), gp->size, version, byteorder!=hostbyteorder);
480 +               break;
481 +
482 +       case GIOP_CANCEL_REQUEST:
483 +               giop_print_cancel_request((u_char *)(bp+sizeof(struct _GIOP_header)), gp->size, version, byteorder!=hostbyteorder);
484 +               break;
485 +
486 +       case GIOP_LOCATE_REQUEST:
487 +               giop_print_locate_request((u_char *)(bp+sizeof(struct _GIOP_header)), gp->size, version, byteorder!=hostbyteorder);
488 +               break;
489 +
490 +       case GIOP_LOCATE_REPLY:
491 +               giop_print_locate_reply((u_char *)(bp+sizeof(struct _GIOP_header)), gp->size, version, byteorder!=hostbyteorder);
492 +               break;
493 +
494 +       case GIOP_CLOSE_CONNECTION:
495 +               giop_print_close_connection((u_char *)(bp+sizeof(struct _GIOP_header)), gp->size, version, byteorder!=hostbyteorder);
496 +               break;
497 +
498 +       case GIOP_MESSAGE_ERROR:
499 +               giop_print_message_error((u_char *)(bp+sizeof(struct _GIOP_header)), gp->size, version, byteorder!=hostbyteorder);
500 +               break;
501 +
502 +       case GIOP_FRAGMENT:
503 +               giop_print_fragment((u_char *)(bp+sizeof(struct _GIOP_header)), gp->size, version, byteorder!=hostbyteorder);
504 +               break;
505 +
506 +       default:
507 +               break;
508 +       }
509 +}
510 diff -ruN tcpdump_3_5rel2.old/print-tcp.c tcpdump_3_5rel2/print-tcp.c
511 --- tcpdump_3_5rel2.old/print-tcp.c     Wed Dec 22 16:44:10 1999
512 +++ tcpdump_3_5rel2/print-tcp.c Fri Jul 14 14:32:18 2000
513 @@ -501,6 +501,13 @@
514                 bgp_print(bp, length);
515         else if (sport == NETBIOS_SSN_PORT || dport == NETBIOS_SSN_PORT)
516                 nbt_tcp_print(bp, length);
517 +       if(!gflag)
518 +                       return;
519 +       hlen = tp->th_off * 4;
520 +       if(length > 4 && !strncmp((u_char *)(bp + hlen), "GIOP", 4)) {
521 +                giop_print((u_char *)(bp + hlen), length);
522 +       }
523 +
524         return;
525  bad:
526         fputs("[bad opt]", stdout);
527 diff -ruN tcpdump_3_5rel2.old/tcpdump.1 tcpdump_3_5rel2/tcpdump.1
528 --- tcpdump_3_5rel2.old/tcpdump.1       Thu Jul 13 07:53:47 2000
529 +++ tcpdump_3_5rel2/tcpdump.1   Fri Jul 14 14:28:47 2000
530 @@ -27,7 +27,7 @@
531  .na
532  .B tcpdump
533  [
534 -.B \-adeflnNOpqRStvxX
535 +.B \-adefglnNOpqRStvxX
536  ] [
537  .B \-c
538  .I count
539 @@ -131,6 +131,9 @@
540  .B \-F
541  Use \fIfile\fP as input for the filter expression.
542  An additional expression given on the command line is ignored.
543 +.TP
544 +.B \-g
545 +Decode CORBA GIOP.
546  .TP
547  .B \-i
548  Listen on \fIinterface\fP.
549 diff -ruN tcpdump_3_5rel2.old/tcpdump.c tcpdump_3_5rel2/tcpdump.c
550 --- tcpdump_3_5rel2.old/tcpdump.c       Tue Jan 11 08:34:00 2000
551 +++ tcpdump_3_5rel2/tcpdump.c   Fri Jul 14 14:23:20 2000
552 @@ -65,6 +65,7 @@
553  int dflag;                     /* print filter code */
554  int eflag;                     /* print ethernet header */
555  int fflag;                     /* don't translate "foreign" IP address */
556 +int gflag;                     /* decode GIOP */
557  int nflag;                     /* leave addresses as numbers */
558  int Nflag;                     /* remove domains from printed host names */
559  int Oflag = 1;                 /* run filter code optimizer */
560 @@ -219,6 +220,10 @@
561  
562                 case 'F':
563                         infile = optarg;
564 +                       break;
565 +
566 +               case 'g':
567 +                       ++gflag;
568                         break;
569  
570                 case 'i':
This page took 0.088301 seconds and 3 git commands to generate.