print-rx.c (56893) | print-rx.c (75115) |
---|---|
1/* 2 * This code unmangles RX packets. RX is the mutant form of RPC that AFS 3 * uses to communicate between clients and servers. 4 * 5 * In this code, I mainly concern myself with decoding the AFS calls, not 6 * with the guts of RX, per se. 7 * 8 * Bah. If I never look at rx_packet.h again, it will be too soon. 9 * 10 * Ken Hornstein <kenh@cmf.nrl.navy.mil> 11 * 12 */ 13 14#ifndef lint 15static const char rcsid[] = | 1/* 2 * This code unmangles RX packets. RX is the mutant form of RPC that AFS 3 * uses to communicate between clients and servers. 4 * 5 * In this code, I mainly concern myself with decoding the AFS calls, not 6 * with the guts of RX, per se. 7 * 8 * Bah. If I never look at rx_packet.h again, it will be too soon. 9 * 10 * Ken Hornstein <kenh@cmf.nrl.navy.mil> 11 * 12 */ 13 14#ifndef lint 15static const char rcsid[] = |
16 "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.5.2.1 2000/01/11 06:58:27 fenner Exp $"; | 16 "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.20 2001/01/10 08:12:01 fenner Exp $"; |
17#endif 18 19#ifdef HAVE_CONFIG_H 20#include "config.h" 21#endif 22 23#include <stdio.h> | 17#endif 18 19#ifdef HAVE_CONFIG_H 20#include "config.h" 21#endif 22 23#include <stdio.h> |
24#include <stdlib.h> |
|
24#include <string.h> | 25#include <string.h> |
26#include <time.h> |
|
25#include <sys/param.h> 26#include <sys/time.h> 27#include <sys/types.h> 28#include <sys/socket.h> 29#include <netinet/in.h> | 27#include <sys/param.h> 28#include <sys/time.h> 29#include <sys/types.h> 30#include <sys/socket.h> 31#include <netinet/in.h> |
30#include <netinet/in_systm.h> 31#include <netinet/ip.h> | |
32#include <arpa/inet.h> 33 34#include "interface.h" 35#include "addrtoname.h" | 32#include <arpa/inet.h> 33 34#include "interface.h" 35#include "addrtoname.h" |
36#include "extract.h" |
|
36 37#undef NOERROR /* Solaris sucks */ 38#include <arpa/nameser.h> 39 40#include "rx.h" 41 | 37 38#undef NOERROR /* Solaris sucks */ 39#include <arpa/nameser.h> 40 41#include "rx.h" 42 |
43#include "ip.h" 44 |
|
42static struct tok rx_types[] = { 43 { RX_PACKET_TYPE_DATA, "data" }, 44 { RX_PACKET_TYPE_ACK, "ack" }, 45 { RX_PACKET_TYPE_BUSY, "busy" }, 46 { RX_PACKET_TYPE_ABORT, "abort" }, 47 { RX_PACKET_TYPE_ACKALL, "ackall" }, 48 { RX_PACKET_TYPE_CHALLENGE, "challenge" }, 49 { RX_PACKET_TYPE_RESPONSE, "response" }, --- 260 unchanged lines hidden (view full) --- 310 { 1, "read" }, 311 { 2, "write" }, 312 { 3, "wait" }, 313 { 0, NULL }, 314}; 315 316static char *voltype[] = { "read-write", "read-only", "backup" }; 317 | 45static struct tok rx_types[] = { 46 { RX_PACKET_TYPE_DATA, "data" }, 47 { RX_PACKET_TYPE_ACK, "ack" }, 48 { RX_PACKET_TYPE_BUSY, "busy" }, 49 { RX_PACKET_TYPE_ABORT, "abort" }, 50 { RX_PACKET_TYPE_ACKALL, "ackall" }, 51 { RX_PACKET_TYPE_CHALLENGE, "challenge" }, 52 { RX_PACKET_TYPE_RESPONSE, "response" }, --- 260 unchanged lines hidden (view full) --- 313 { 1, "read" }, 314 { 2, "write" }, 315 { 3, "wait" }, 316 { 0, NULL }, 317}; 318 319static char *voltype[] = { "read-write", "read-only", "backup" }; 320 |
321static struct tok afs_fs_errors[] = { 322 { 101, "salvage volume" }, 323 { 102, "no such vnode" }, 324 { 103, "no such volume" }, 325 { 104, "volume exist" }, 326 { 105, "no service" }, 327 { 106, "volume offline" }, 328 { 107, "voline online" }, 329 { 108, "diskfull" }, 330 { 109, "diskquota exceeded" }, 331 { 110, "volume busy" }, 332 { 111, "volume moved" }, 333 { 112, "AFS IO error" }, 334 { -100, "restarting fileserver" }, 335 { 0, NULL } 336}; 337 |
|
318/* | 338/* |
339 * Reasons for acknowledging a packet 340 */ 341 342static struct tok rx_ack_reasons[] = { 343 { 1, "ack requested" }, 344 { 2, "duplicate packet" }, 345 { 3, "out of sequence" }, 346 { 4, "exceeds window" }, 347 { 5, "no buffer space" }, 348 { 6, "ping" }, 349 { 7, "ping response" }, 350 { 8, "delay" }, 351 { 0, NULL }, 352}; 353 354/* |
|
319 * Cache entries we keep around so we can figure out the RX opcode 320 * numbers for replies. This allows us to make sense of RX reply packets. 321 */ 322 323struct rx_cache_entry { 324 u_int32_t callnum; /* Call number (net order) */ 325 struct in_addr client; /* client IP address (net order) */ 326 struct in_addr server; /* server IP address (net order) */ --- 7 unchanged lines hidden (view full) --- 334static struct rx_cache_entry rx_cache[RX_CACHE_SIZE]; 335 336static int rx_cache_next = 0; 337static int rx_cache_hint = 0; 338static void rx_cache_insert(const u_char *, const struct ip *, int, int); 339static int rx_cache_find(const struct rx_header *, const struct ip *, 340 int, int32_t *); 341 | 355 * Cache entries we keep around so we can figure out the RX opcode 356 * numbers for replies. This allows us to make sense of RX reply packets. 357 */ 358 359struct rx_cache_entry { 360 u_int32_t callnum; /* Call number (net order) */ 361 struct in_addr client; /* client IP address (net order) */ 362 struct in_addr server; /* server IP address (net order) */ --- 7 unchanged lines hidden (view full) --- 370static struct rx_cache_entry rx_cache[RX_CACHE_SIZE]; 371 372static int rx_cache_next = 0; 373static int rx_cache_hint = 0; 374static void rx_cache_insert(const u_char *, const struct ip *, int, int); 375static int rx_cache_find(const struct rx_header *, const struct ip *, 376 int, int32_t *); 377 |
378static void ack_print(const u_char *, int); |
|
342static void fs_print(const u_char *, int); 343static void fs_reply_print(const u_char *, int, int32_t); | 379static void fs_print(const u_char *, int); 380static void fs_reply_print(const u_char *, int, int32_t); |
344static void acl_print(u_char *, u_char *); | 381static void acl_print(u_char *, int, u_char *); |
345static void cb_print(const u_char *, int); 346static void cb_reply_print(const u_char *, int, int32_t); 347static void prot_print(const u_char *, int); 348static void prot_reply_print(const u_char *, int, int32_t); 349static void vldb_print(const u_char *, int); 350static void vldb_reply_print(const u_char *, int, int32_t); 351static void kauth_print(const u_char *, int); 352static void kauth_reply_print(const u_char *, int, int32_t); 353static void vol_print(const u_char *, int); 354static void vol_reply_print(const u_char *, int, int32_t); 355static void bos_print(const u_char *, int); 356static void bos_reply_print(const u_char *, int, int32_t); 357static void ubik_print(const u_char *, int); 358static void ubik_reply_print(const u_char *, int, int32_t); 359 | 382static void cb_print(const u_char *, int); 383static void cb_reply_print(const u_char *, int, int32_t); 384static void prot_print(const u_char *, int); 385static void prot_reply_print(const u_char *, int, int32_t); 386static void vldb_print(const u_char *, int); 387static void vldb_reply_print(const u_char *, int, int32_t); 388static void kauth_print(const u_char *, int); 389static void kauth_reply_print(const u_char *, int, int32_t); 390static void vol_print(const u_char *, int); 391static void vol_reply_print(const u_char *, int, int32_t); 392static void bos_print(const u_char *, int); 393static void bos_reply_print(const u_char *, int, int32_t); 394static void ubik_print(const u_char *, int); 395static void ubik_reply_print(const u_char *, int, int32_t); 396 |
397static void rx_ack_print(const u_char *, int); 398 |
|
360static int is_ubik(u_int32_t); 361 362/* 363 * Handle the rx-level packet. See if we know what port it's going to so 364 * we can peek at the afs call inside 365 */ 366 367void --- 8 unchanged lines hidden (view full) --- 376 printf(" [|rx] (%d)", length); 377 return; 378 } 379 380 rxh = (struct rx_header *) bp; 381 382 printf(" rx %s", tok2str(rx_types, "type %d", rxh->type)); 383 | 399static int is_ubik(u_int32_t); 400 401/* 402 * Handle the rx-level packet. See if we know what port it's going to so 403 * we can peek at the afs call inside 404 */ 405 406void --- 8 unchanged lines hidden (view full) --- 415 printf(" [|rx] (%d)", length); 416 return; 417 } 418 419 rxh = (struct rx_header *) bp; 420 421 printf(" rx %s", tok2str(rx_types, "type %d", rxh->type)); 422 |
384 if (vflag > 1) { | 423 if (vflag) { |
385 int firstflag = 0; | 424 int firstflag = 0; |
386 printf(" cid %08x call# %d seq %d ser %d", 387 (int) ntohl(rxh->cid), 388 (int) ntohl(rxh->callNumber), 389 (int) ntohl(rxh->seq), 390 (int) ntohl(rxh->serial)); | 425 426 if (vflag > 1) 427 printf(" cid %08x call# %d", 428 (int) EXTRACT_32BITS(&rxh->cid), 429 (int) EXTRACT_32BITS(&rxh->callNumber)); 430 431 printf(" seq %d ser %d", 432 (int) EXTRACT_32BITS(&rxh->seq), 433 (int) EXTRACT_32BITS(&rxh->serial)); 434 |
391 if (vflag > 2) 392 printf(" secindex %d serviceid %hu", 393 (int) rxh->securityIndex, | 435 if (vflag > 2) 436 printf(" secindex %d serviceid %hu", 437 (int) rxh->securityIndex, |
394 ntohs(rxh->serviceId)); 395 for (i = 0; i < NUM_RX_FLAGS; i++) { 396 if (rxh->flags & rx_flags[i].v) { 397 if (!firstflag) { 398 firstflag = 1; 399 printf(" "); 400 } else { 401 printf(","); | 438 EXTRACT_16BITS(&rxh->serviceId)); 439 440 if (vflag > 1) 441 for (i = 0; i < NUM_RX_FLAGS; i++) { 442 if (rxh->flags & rx_flags[i].v) { 443 if (!firstflag) { 444 firstflag = 1; 445 printf(" "); 446 } else { 447 printf(","); 448 } 449 printf("<%s>", rx_flags[i].s); |
402 } | 450 } |
403 printf("<%s>", rx_flags[i].s); | |
404 } | 451 } |
405 } | |
406 } 407 408 /* 409 * Try to handle AFS calls that we know about. Check the destination 410 * port and make sure it's a data packet. Also, make sure the 411 * seq number is 1 (because otherwise it's a continuation packet, 412 * and we can't interpret that). Also, seems that reply packets 413 * do not have the client-init flag set, so we check for that 414 * as well. 415 */ 416 | 452 } 453 454 /* 455 * Try to handle AFS calls that we know about. Check the destination 456 * port and make sure it's a data packet. Also, make sure the 457 * seq number is 1 (because otherwise it's a continuation packet, 458 * and we can't interpret that). Also, seems that reply packets 459 * do not have the client-init flag set, so we check for that 460 * as well. 461 */ 462 |
417 if (rxh->type == RX_PACKET_TYPE_DATA && ntohl(rxh->seq) == 1 && | 463 if (rxh->type == RX_PACKET_TYPE_ACK) 464 ack_print(bp, length); 465 else if (rxh->type == RX_PACKET_TYPE_DATA && 466 EXTRACT_32BITS(&rxh->seq) == 1 && |
418 rxh->flags & RX_CLIENT_INITIATED) { 419 420 /* 421 * Insert this call into the call cache table, so we 422 * have a chance to print out replies 423 */ 424 425 rx_cache_insert(bp, (const struct ip *) bp2, dport, length); --- 27 unchanged lines hidden (view full) --- 453 /* 454 * If it's a reply (client-init is _not_ set, but seq is one) 455 * then look it up in the cache. If we find it, call the reply 456 * printing functions Note that we handle abort packets here, 457 * because printing out the return code can be useful at times. 458 */ 459 460 } else if (((rxh->type == RX_PACKET_TYPE_DATA && | 467 rxh->flags & RX_CLIENT_INITIATED) { 468 469 /* 470 * Insert this call into the call cache table, so we 471 * have a chance to print out replies 472 */ 473 474 rx_cache_insert(bp, (const struct ip *) bp2, dport, length); --- 27 unchanged lines hidden (view full) --- 502 /* 503 * If it's a reply (client-init is _not_ set, but seq is one) 504 * then look it up in the cache. If we find it, call the reply 505 * printing functions Note that we handle abort packets here, 506 * because printing out the return code can be useful at times. 507 */ 508 509 } else if (((rxh->type == RX_PACKET_TYPE_DATA && |
461 ntohl(rxh->seq) == 1) || | 510 EXTRACT_32BITS(&rxh->seq) == 1) || |
462 rxh->type == RX_PACKET_TYPE_ABORT) && 463 (rxh->flags & RX_CLIENT_INITIATED) == 0 && 464 rx_cache_find(rxh, (const struct ip *) bp2, 465 sport, &opcode)) { 466 467 switch (sport) { 468 case FS_RX_PORT: /* AFS file service */ 469 fs_reply_print(bp, length, opcode); --- 14 unchanged lines hidden (view full) --- 484 vol_reply_print(bp, length, opcode); 485 break; 486 case BOS_RX_PORT: /* AFS BOS service */ 487 bos_reply_print(bp, length, opcode); 488 break; 489 default: 490 ; 491 } | 511 rxh->type == RX_PACKET_TYPE_ABORT) && 512 (rxh->flags & RX_CLIENT_INITIATED) == 0 && 513 rx_cache_find(rxh, (const struct ip *) bp2, 514 sport, &opcode)) { 515 516 switch (sport) { 517 case FS_RX_PORT: /* AFS file service */ 518 fs_reply_print(bp, length, opcode); --- 14 unchanged lines hidden (view full) --- 533 vol_reply_print(bp, length, opcode); 534 break; 535 case BOS_RX_PORT: /* AFS BOS service */ 536 bos_reply_print(bp, length, opcode); 537 break; 538 default: 539 ; 540 } |
492 } | |
493 | 541 |
542 /* 543 * If it's an RX ack packet, then use the appropriate ack decoding 544 * function (there isn't any service-specific information in the 545 * ack packet, so we can use one for all AFS services) 546 */ |
|
494 | 547 |
548 } else if (rxh->type == RX_PACKET_TYPE_ACK) 549 rx_ack_print(bp, length); 550 551 |
|
495 printf(" (%d)", length); 496} 497 498/* 499 * Insert an entry into the cache. Taken from print-nfs.c 500 */ 501 502static void --- 11 unchanged lines hidden (view full) --- 514 if (++rx_cache_next >= RX_CACHE_SIZE) 515 rx_cache_next = 0; 516 517 rxent->callnum = rxh->callNumber; 518 rxent->client = ip->ip_src; 519 rxent->server = ip->ip_dst; 520 rxent->dport = dport; 521 rxent->serviceId = rxh->serviceId; | 552 printf(" (%d)", length); 553} 554 555/* 556 * Insert an entry into the cache. Taken from print-nfs.c 557 */ 558 559static void --- 11 unchanged lines hidden (view full) --- 571 if (++rx_cache_next >= RX_CACHE_SIZE) 572 rx_cache_next = 0; 573 574 rxent->callnum = rxh->callNumber; 575 rxent->client = ip->ip_src; 576 rxent->server = ip->ip_dst; 577 rxent->dport = dport; 578 rxent->serviceId = rxh->serviceId; |
522 rxent->opcode = ntohl(*((int *) (bp + sizeof(struct rx_header)))); | 579 rxent->opcode = EXTRACT_32BITS(bp + sizeof(struct rx_header)); |
523} 524 525/* 526 * Lookup an entry in the cache. Also taken from print-nfs.c 527 * 528 * Note that because this is a reply, we're looking at the _source_ 529 * port. 530 */ --- 31 unchanged lines hidden (view full) --- 562 /* Our search failed */ 563 return(0); 564} 565 566/* 567 * These extrememly grody macros handle the printing of various AFS stuff. 568 */ 569 | 580} 581 582/* 583 * Lookup an entry in the cache. Also taken from print-nfs.c 584 * 585 * Note that because this is a reply, we're looking at the _source_ 586 * port. 587 */ --- 31 unchanged lines hidden (view full) --- 619 /* Our search failed */ 620 return(0); 621} 622 623/* 624 * These extrememly grody macros handle the printing of various AFS stuff. 625 */ 626 |
570#define TRUNC(n) if (snapend - bp + 1 <= n) goto trunc; | |
571#define FIDOUT() { unsigned long n1, n2, n3; \ | 627#define FIDOUT() { unsigned long n1, n2, n3; \ |
572 TRUNC(sizeof(int32_t) * 3); \ 573 n1 = ntohl(*((int *) bp)); \ | 628 TCHECK2(bp[0], sizeof(int32_t) * 3); \ 629 n1 = EXTRACT_32BITS(bp); \ |
574 bp += sizeof(int32_t); \ | 630 bp += sizeof(int32_t); \ |
575 n2 = ntohl(*((int *) bp)); \ | 631 n2 = EXTRACT_32BITS(bp); \ |
576 bp += sizeof(int32_t); \ | 632 bp += sizeof(int32_t); \ |
577 n3 = ntohl(*((int *) bp)); \ | 633 n3 = EXTRACT_32BITS(bp); \ |
578 bp += sizeof(int32_t); \ 579 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \ 580 } 581 582#define STROUT(MAX) { int i; \ | 634 bp += sizeof(int32_t); \ 635 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \ 636 } 637 638#define STROUT(MAX) { int i; \ |
583 TRUNC(sizeof(int32_t)); \ 584 i = (int) ntohl(*((int *) bp)); \ | 639 TCHECK2(bp[0], sizeof(int32_t)); \ 640 i = (int) EXTRACT_32BITS(bp); \ |
585 bp += sizeof(int32_t); \ | 641 bp += sizeof(int32_t); \ |
586 TRUNC(i); \ 587 strncpy(s, bp, min(MAX, i)); \ | 642 TCHECK2(bp[0], i); \ 643 strncpy(s, (char *) bp, min(MAX, i)); \ |
588 s[i] = '\0'; \ 589 printf(" \"%s\"", s); \ 590 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \ 591 } 592 593#define INTOUT() { int i; \ | 644 s[i] = '\0'; \ 645 printf(" \"%s\"", s); \ 646 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \ 647 } 648 649#define INTOUT() { int i; \ |
594 TRUNC(sizeof(int32_t)); \ 595 i = (int) ntohl(*((int *) bp)); \ | 650 TCHECK2(bp[0], sizeof(int32_t)); \ 651 i = (int) EXTRACT_32BITS(bp); \ |
596 bp += sizeof(int32_t); \ 597 printf(" %d", i); \ 598 } 599 600#define UINTOUT() { unsigned long i; \ | 652 bp += sizeof(int32_t); \ 653 printf(" %d", i); \ 654 } 655 656#define UINTOUT() { unsigned long i; \ |
601 TRUNC(sizeof(int32_t)); \ 602 i = ntohl(*((int *) bp)); \ | 657 TCHECK2(bp[0], sizeof(int32_t)); \ 658 i = EXTRACT_32BITS(bp); \ |
603 bp += sizeof(int32_t); \ 604 printf(" %lu", i); \ 605 } 606 607#define DATEOUT() { time_t t; struct tm *tm; char str[256]; \ | 659 bp += sizeof(int32_t); \ 660 printf(" %lu", i); \ 661 } 662 663#define DATEOUT() { time_t t; struct tm *tm; char str[256]; \ |
608 TRUNC(sizeof(int32_t)); \ 609 t = (time_t) ntohl(*((int *) bp)); \ | 664 TCHECK2(bp[0], sizeof(int32_t)); \ 665 t = (time_t) EXTRACT_32BITS(bp); \ |
610 bp += sizeof(int32_t); \ 611 tm = localtime(&t); \ 612 strftime(str, 256, "%Y/%m/%d %T", tm); \ 613 printf(" %s", str); \ 614 } 615 616#define STOREATTROUT() { unsigned long mask, i; \ | 666 bp += sizeof(int32_t); \ 667 tm = localtime(&t); \ 668 strftime(str, 256, "%Y/%m/%d %T", tm); \ 669 printf(" %s", str); \ 670 } 671 672#define STOREATTROUT() { unsigned long mask, i; \ |
617 TRUNC((sizeof(int32_t)*6)); \ 618 mask = ntohl(*((int *) bp)); bp += sizeof(int32_t); \ | 673 TCHECK2(bp[0], (sizeof(int32_t)*6)); \ 674 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ |
619 if (mask) printf (" StoreStatus"); \ 620 if (mask & 1) { printf(" date"); DATEOUT(); } \ 621 else bp += sizeof(int32_t); \ | 675 if (mask) printf (" StoreStatus"); \ 676 if (mask & 1) { printf(" date"); DATEOUT(); } \ 677 else bp += sizeof(int32_t); \ |
622 i = ntohl(*((int *) bp)); bp += sizeof(int32_t); \ | 678 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ |
623 if (mask & 2) printf(" owner %lu", i); \ | 679 if (mask & 2) printf(" owner %lu", i); \ |
624 i = ntohl(*((int32_t *) bp)); bp += sizeof(int32_t); \ | 680 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ |
625 if (mask & 4) printf(" group %lu", i); \ | 681 if (mask & 4) printf(" group %lu", i); \ |
626 i = ntohl(*((int32_t *) bp)); bp += sizeof(int32_t); \ | 682 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ |
627 if (mask & 8) printf(" mode %lo", i & 07777); \ | 683 if (mask & 8) printf(" mode %lo", i & 07777); \ |
628 i = ntohl(*((int32_t *) bp)); bp += sizeof(int32_t); \ | 684 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ |
629 if (mask & 16) printf(" segsize %lu", i); \ 630 /* undocumented in 3.3 docu */ \ 631 if (mask & 1024) printf(" fsync"); \ 632 } 633 634#define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \ | 685 if (mask & 16) printf(" segsize %lu", i); \ 686 /* undocumented in 3.3 docu */ \ 687 if (mask & 1024) printf(" fsync"); \ 688 } 689 690#define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \ |
635 TRUNC(sizeof(int32_t) * 2); \ 636 epoch = ntohl(*((int *) bp)); \ | 691 TCHECK2(bp[0], sizeof(int32_t) * 2); \ 692 epoch = EXTRACT_32BITS(bp); \ |
637 bp += sizeof(int32_t); \ | 693 bp += sizeof(int32_t); \ |
638 counter = ntohl(*((int *) bp)); \ | 694 counter = EXTRACT_32BITS(bp); \ |
639 bp += sizeof(int32_t); \ 640 printf(" %d.%d", epoch, counter); \ 641 } 642 643#define AFSUUIDOUT() {u_int32_t temp; int i; \ | 695 bp += sizeof(int32_t); \ 696 printf(" %d.%d", epoch, counter); \ 697 } 698 699#define AFSUUIDOUT() {u_int32_t temp; int i; \ |
644 TRUNC(11*sizeof(u_int32_t)); \ 645 temp = ntohl(*((int *) bp)); \ | 700 TCHECK2(bp[0], 11*sizeof(u_int32_t)); \ 701 temp = EXTRACT_32BITS(bp); \ |
646 bp += sizeof(u_int32_t); \ 647 printf(" %08x", temp); \ | 702 bp += sizeof(u_int32_t); \ 703 printf(" %08x", temp); \ |
648 temp = ntohl(*((int *) bp)); \ | 704 temp = EXTRACT_32BITS(bp); \ |
649 bp += sizeof(u_int32_t); \ 650 printf("%04x", temp); \ | 705 bp += sizeof(u_int32_t); \ 706 printf("%04x", temp); \ |
651 temp = ntohl(*((int *) bp)); \ | 707 temp = EXTRACT_32BITS(bp); \ |
652 bp += sizeof(u_int32_t); \ 653 printf("%04x", temp); \ 654 for (i = 0; i < 8; i++) { \ | 708 bp += sizeof(u_int32_t); \ 709 printf("%04x", temp); \ 710 for (i = 0; i < 8; i++) { \ |
655 temp = ntohl(*((int *) bp)); \ | 711 temp = EXTRACT_32BITS(bp); \ |
656 bp += sizeof(u_int32_t); \ 657 printf("%02x", (unsigned char) temp); \ 658 } \ 659 } 660 661/* 662 * This is the sickest one of all 663 */ 664 665#define VECOUT(MAX) { char *sp; \ 666 int k; \ | 712 bp += sizeof(u_int32_t); \ 713 printf("%02x", (unsigned char) temp); \ 714 } \ 715 } 716 717/* 718 * This is the sickest one of all 719 */ 720 721#define VECOUT(MAX) { char *sp; \ 722 int k; \ |
667 TRUNC(MAX * sizeof(int32_t)); \ | 723 TCHECK2(bp[0], MAX * sizeof(int32_t)); \ |
668 sp = s; \ 669 for (k = 0; k < MAX; k++) { \ | 724 sp = s; \ 725 for (k = 0; k < MAX; k++) { \ |
670 *sp++ = (char) ntohl(*((int *) bp)); \ | 726 *sp++ = (char) EXTRACT_32BITS(bp); \ |
671 bp += sizeof(int32_t); \ 672 } \ 673 s[MAX] = '\0'; \ 674 printf(" \"%s\"", s); \ 675 } 676 | 727 bp += sizeof(int32_t); \ 728 } \ 729 s[MAX] = '\0'; \ 730 printf(" \"%s\"", s); \ 731 } 732 |
733static void 734ack_print(register const u_char *bp, int length) 735{ 736 u_char nAcks; 737 int i; 738 739 if (vflag <= 1) 740 return; 741 742 if (length <= sizeof(struct rx_header)) 743 return; 744 745 bp += sizeof(struct rx_header); 746 747 /* 748 * Packets < firstPacket are implicitly acknowledged and may 749 * be discarded by the sender. 750 * 751 * Packets >= firstPacket+nAcks are implicitly NOT acknowledged. 752 * 753 * No packets with sequence numbers >= firstPacket should be 754 * discarded by the sender (they may thrown out at any time by 755 * the receiver) 756 */ 757#define RX_ACK_REASONS "RDOXSprn" 758 /* Requested, Duplicate, Out_of_sequence, eXceeds_window, no_Space, 759 * Ping, ping_Response, No_{progress, particular_reason}. 760 */ 761#if 0 762 struct rx_ackPacket { 763 u_short bufferSpace; /* Skip! */ 764 u_short maxSkew; /* Skip! */ 765 u_long firstPacket; 766 u_long previousPacket; /* Obsolete! */ 767 u_long serial; /* Serial that prompted the ack, */ 768 u_char reason; /* and the reason why. */ 769 u_char nAcks; 770 u_char acks[RX_MAXACKS]; /* Selective acks (not a bitmap). */ 771 }; 772#endif 773#define RX_ACK_TYPE_NACK 0 774 775 TCHECK2(bp[0], 8); /* bufferSpace and maxSkew */ 776 bp += 4; 777 printf(" fir %u", (unsigned)EXTRACT_32BITS(bp)); 778 bp += 4; 779 TCHECK2(bp[0], 8); /* previousPacket and serial */ 780 bp += 4; 781 printf(" %u", (unsigned)EXTRACT_32BITS(bp)); 782 bp += 4; 783 TCHECK2(bp[0], 1); 784 printf("%c", RX_ACK_REASONS[(*bp - 1) & 07u]); 785 bp += 1; /* reason */ 786 TCHECK2(bp[0], 1); 787 nAcks = *bp; 788 bp += 1; /* nAcks */ 789 790 for (i = 0; i < nAcks; i++) { 791 TCHECK2(bp[0], 1); 792 putchar(*bp == RX_ACK_TYPE_NACK? '-' : '*'); 793 bp += 1; 794 } 795 796 return; 797 798trunc: 799 printf(" [|ack]"); 800} 801 |
|
677/* 678 * Handle calls to the AFS file service (fs) 679 */ 680 | 802/* 803 * Handle calls to the AFS file service (fs) 804 */ 805 |
681void | 806static void |
682fs_print(register const u_char *bp, int length) 683{ 684 int fs_op; 685 unsigned long i; 686 char s[AFSNAMEMAX]; 687 688 if (length <= sizeof(struct rx_header)) 689 return; 690 691 if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { 692 goto trunc; 693 } 694 695 /* 696 * Print out the afs call we're invoking. The table used here was 697 * gleaned from fsint/afsint.xg 698 */ 699 | 807fs_print(register const u_char *bp, int length) 808{ 809 int fs_op; 810 unsigned long i; 811 char s[AFSNAMEMAX]; 812 813 if (length <= sizeof(struct rx_header)) 814 return; 815 816 if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { 817 goto trunc; 818 } 819 820 /* 821 * Print out the afs call we're invoking. The table used here was 822 * gleaned from fsint/afsint.xg 823 */ 824 |
700 fs_op = ntohl(*((int *) (bp + sizeof(struct rx_header)))); | 825 fs_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); |
701 702 printf(" fs call %s", tok2str(fs_req, "op#%d", fs_op)); 703 704 /* 705 * Print out arguments to some of the AFS calls. This stuff is 706 * all from afsint.xg 707 */ 708 --- 32 unchanged lines hidden (view full) --- 741 UINTOUT(); 742 printf(" length"); 743 UINTOUT(); 744 printf(" flen"); 745 UINTOUT(); 746 break; 747 case 134: /* Store ACL */ 748 { | 826 827 printf(" fs call %s", tok2str(fs_req, "op#%d", fs_op)); 828 829 /* 830 * Print out arguments to some of the AFS calls. This stuff is 831 * all from afsint.xg 832 */ 833 --- 32 unchanged lines hidden (view full) --- 866 UINTOUT(); 867 printf(" length"); 868 UINTOUT(); 869 printf(" flen"); 870 UINTOUT(); 871 break; 872 case 134: /* Store ACL */ 873 { |
749 char a[AFSOPAQUEMAX]; | 874 char a[AFSOPAQUEMAX+1]; |
750 FIDOUT(); | 875 FIDOUT(); |
751 TRUNC(4); 752 i = ntohl(*((int *) bp)); | 876 TCHECK2(bp[0], 4); 877 i = EXTRACT_32BITS(bp); |
753 bp += sizeof(int32_t); | 878 bp += sizeof(int32_t); |
754 TRUNC(i); 755 strncpy(a, bp, min(AFSOPAQUEMAX, i)); | 879 TCHECK2(bp[0], i); 880 i = min(AFSOPAQUEMAX, i); 881 strncpy(a, (char *) bp, i); |
756 a[i] = '\0'; | 882 a[i] = '\0'; |
757 acl_print((u_char *) a, (u_char *) a + i); | 883 acl_print((u_char *) a, sizeof(a), (u_char *) a + i); |
758 break; 759 } 760 case 137: /* Create file */ 761 case 141: /* MakeDir */ 762 FIDOUT(); 763 STROUT(AFSNAMEMAX); 764 STOREATTROUT(); 765 break; --- 32 unchanged lines hidden (view full) --- 798 break; 799 case 154: /* New get volume info */ 800 printf(" volname"); 801 STROUT(AFSNAMEMAX); 802 break; 803 case 155: /* Bulk stat */ 804 { 805 unsigned long j; | 884 break; 885 } 886 case 137: /* Create file */ 887 case 141: /* MakeDir */ 888 FIDOUT(); 889 STROUT(AFSNAMEMAX); 890 STOREATTROUT(); 891 break; --- 32 unchanged lines hidden (view full) --- 924 break; 925 case 154: /* New get volume info */ 926 printf(" volname"); 927 STROUT(AFSNAMEMAX); 928 break; 929 case 155: /* Bulk stat */ 930 { 931 unsigned long j; |
806 TRUNC(4); 807 j = ntohl(*((int *) bp)); | 932 TCHECK2(bp[0], 4); 933 j = EXTRACT_32BITS(bp); |
808 bp += sizeof(int32_t); 809 810 for (i = 0; i < j; i++) { 811 FIDOUT(); 812 if (i != j - 1) 813 printf(","); 814 } 815 if (j == 0) --- 33 unchanged lines hidden (view full) --- 849 printf(" fs reply %s", tok2str(fs_req, "op#%d", opcode)); 850 851 bp += sizeof(struct rx_header); 852 853 /* 854 * If it was a data packet, interpret the response 855 */ 856 | 934 bp += sizeof(int32_t); 935 936 for (i = 0; i < j; i++) { 937 FIDOUT(); 938 if (i != j - 1) 939 printf(","); 940 } 941 if (j == 0) --- 33 unchanged lines hidden (view full) --- 975 printf(" fs reply %s", tok2str(fs_req, "op#%d", opcode)); 976 977 bp += sizeof(struct rx_header); 978 979 /* 980 * If it was a data packet, interpret the response 981 */ 982 |
857 if (rxh->type == RX_PACKET_TYPE_DATA) | 983 if (rxh->type == RX_PACKET_TYPE_DATA) { |
858 switch (opcode) { 859 case 131: /* Fetch ACL */ 860 { | 984 switch (opcode) { 985 case 131: /* Fetch ACL */ 986 { |
861 char a[AFSOPAQUEMAX]; 862 TRUNC(4); 863 i = ntohl(*((int *) bp)); | 987 char a[AFSOPAQUEMAX+1]; 988 TCHECK2(bp[0], 4); 989 i = EXTRACT_32BITS(bp); |
864 bp += sizeof(int32_t); | 990 bp += sizeof(int32_t); |
865 TRUNC(i); 866 strncpy(a, bp, min(AFSOPAQUEMAX, i)); | 991 TCHECK2(bp[0], i); 992 i = min(AFSOPAQUEMAX, i); 993 strncpy(a, (char *) bp, i); |
867 a[i] = '\0'; | 994 a[i] = '\0'; |
868 acl_print((u_char *) a, (u_char *) a + i); | 995 acl_print((u_char *) a, sizeof(a), (u_char *) a + i); |
869 break; 870 } 871 case 137: /* Create file */ 872 case 141: /* MakeDir */ 873 printf(" new"); 874 FIDOUT(); 875 break; 876 case 151: /* Get root volume */ 877 printf(" root volume"); 878 STROUT(AFSNAMEMAX); 879 break; 880 case 153: /* Get time */ 881 DATEOUT(); 882 break; 883 default: 884 ; 885 } | 996 break; 997 } 998 case 137: /* Create file */ 999 case 141: /* MakeDir */ 1000 printf(" new"); 1001 FIDOUT(); 1002 break; 1003 case 151: /* Get root volume */ 1004 printf(" root volume"); 1005 STROUT(AFSNAMEMAX); 1006 break; 1007 case 153: /* Get time */ 1008 DATEOUT(); 1009 break; 1010 default: 1011 ; 1012 } |
886 else { 887 /* 888 * Otherwise, just print out the return code 889 */ 890 printf(" errcode"); 891 INTOUT(); | 1013 } else if (rxh->type == RX_PACKET_TYPE_ABORT) { 1014 int i; 1015 1016 /* 1017 * Otherwise, just print out the return code 1018 */ 1019 TCHECK2(bp[0], sizeof(int32_t)); 1020 i = (int) EXTRACT_32BITS(bp); 1021 bp += sizeof(int32_t); 1022 1023 printf(" error %s", tok2str(afs_fs_errors, "#%d", i)); 1024 } else { 1025 printf(" strange fs reply of type %d", rxh->type); |
892 } 893 894 return; 895 896trunc: 897 printf(" [|fs]"); 898} 899 --- 7 unchanged lines hidden (view full) --- 907 * 908 * "positive" and "negative" are integers which contain the number of 909 * positive and negative ACL's in the string. The uid/aclbits pair are 910 * ASCII strings containing the UID/PTS record and and a ascii number 911 * representing a logical OR of all the ACL permission bits 912 */ 913 914static void | 1026 } 1027 1028 return; 1029 1030trunc: 1031 printf(" [|fs]"); 1032} 1033 --- 7 unchanged lines hidden (view full) --- 1041 * 1042 * "positive" and "negative" are integers which contain the number of 1043 * positive and negative ACL's in the string. The uid/aclbits pair are 1044 * ASCII strings containing the UID/PTS record and and a ascii number 1045 * representing a logical OR of all the ACL permission bits 1046 */ 1047 1048static void |
915acl_print(u_char *s, u_char *end) | 1049acl_print(u_char *s, int maxsize, u_char *end) |
916{ 917 int pos, neg, acl; 918 int n, i; | 1050{ 1051 int pos, neg, acl; 1052 int n, i; |
919 char user[128]; | 1053 char *user; |
920 | 1054 |
921 if (sscanf((char *) s, "%d %d\n%n", &pos, &neg, &n) != 2) | 1055 if ((user = (char *)malloc(maxsize)) == NULL) |
922 return; | 1056 return; |
1057 1058 if (sscanf((char *) s, "%d %d\n%n", &pos, &neg, &n) != 2) 1059 goto finish; |
|
923 924 s += n; 925 926 if (s > end) | 1060 1061 s += n; 1062 1063 if (s > end) |
927 return; | 1064 goto finish; |
928 929 /* 930 * This wacky order preserves the order used by the "fs" command 931 */ 932 933#define ACLOUT(acl) \ 934 if (acl & PRSFS_READ) \ 935 printf("r"); \ --- 7 unchanged lines hidden (view full) --- 943 printf("w"); \ 944 if (acl & PRSFS_LOCK) \ 945 printf("k"); \ 946 if (acl & PRSFS_ADMINISTER) \ 947 printf("a"); 948 949 for (i = 0; i < pos; i++) { 950 if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2) | 1065 1066 /* 1067 * This wacky order preserves the order used by the "fs" command 1068 */ 1069 1070#define ACLOUT(acl) \ 1071 if (acl & PRSFS_READ) \ 1072 printf("r"); \ --- 7 unchanged lines hidden (view full) --- 1080 printf("w"); \ 1081 if (acl & PRSFS_LOCK) \ 1082 printf("k"); \ 1083 if (acl & PRSFS_ADMINISTER) \ 1084 printf("a"); 1085 1086 for (i = 0; i < pos; i++) { 1087 if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2) |
951 return; | 1088 goto finish; |
952 s += n; 953 printf(" +{%s ", user); 954 ACLOUT(acl); 955 printf("}"); 956 if (s > end) | 1089 s += n; 1090 printf(" +{%s ", user); 1091 ACLOUT(acl); 1092 printf("}"); 1093 if (s > end) |
957 return; | 1094 goto finish; |
958 } 959 960 for (i = 0; i < neg; i++) { 961 if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2) | 1095 } 1096 1097 for (i = 0; i < neg; i++) { 1098 if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2) |
962 return; | 1099 goto finish; |
963 s += n; 964 printf(" -{%s ", user); 965 ACLOUT(acl); 966 printf("}"); 967 if (s > end) | 1100 s += n; 1101 printf(" -{%s ", user); 1102 ACLOUT(acl); 1103 printf("}"); 1104 if (s > end) |
968 return; | 1105 goto finish; |
969 } | 1106 } |
1107 1108finish: 1109 free(user); 1110 return; |
|
970} 971 972#undef ACLOUT 973 974/* 975 * Handle calls to the AFS callback service 976 */ 977 --- 10 unchanged lines hidden (view full) --- 988 goto trunc; 989 } 990 991 /* 992 * Print out the afs call we're invoking. The table used here was 993 * gleaned from fsint/afscbint.xg 994 */ 995 | 1111} 1112 1113#undef ACLOUT 1114 1115/* 1116 * Handle calls to the AFS callback service 1117 */ 1118 --- 10 unchanged lines hidden (view full) --- 1129 goto trunc; 1130 } 1131 1132 /* 1133 * Print out the afs call we're invoking. The table used here was 1134 * gleaned from fsint/afscbint.xg 1135 */ 1136 |
996 cb_op = ntohl(*((int *) (bp + sizeof(struct rx_header)))); | 1137 cb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); |
997 998 printf(" cb call %s", tok2str(cb_req, "op#%d", cb_op)); 999 1000 bp += sizeof(struct rx_header) + 4; 1001 1002 /* 1003 * Print out the afs call we're invoking. The table used here was 1004 * gleaned from fsint/afscbint.xg 1005 */ 1006 1007 switch (cb_op) { 1008 case 204: /* Callback */ 1009 { 1010 unsigned long j, t; | 1138 1139 printf(" cb call %s", tok2str(cb_req, "op#%d", cb_op)); 1140 1141 bp += sizeof(struct rx_header) + 4; 1142 1143 /* 1144 * Print out the afs call we're invoking. The table used here was 1145 * gleaned from fsint/afscbint.xg 1146 */ 1147 1148 switch (cb_op) { 1149 case 204: /* Callback */ 1150 { 1151 unsigned long j, t; |
1011 TRUNC(4); 1012 j = ntohl(*((int *) bp)); | 1152 TCHECK2(bp[0], 4); 1153 j = EXTRACT_32BITS(bp); |
1013 bp += sizeof(int32_t); 1014 1015 for (i = 0; i < j; i++) { 1016 FIDOUT(); 1017 if (i != j - 1) 1018 printf(","); 1019 } 1020 1021 if (j == 0) 1022 printf(" <none!>"); 1023 | 1154 bp += sizeof(int32_t); 1155 1156 for (i = 0; i < j; i++) { 1157 FIDOUT(); 1158 if (i != j - 1) 1159 printf(","); 1160 } 1161 1162 if (j == 0) 1163 printf(" <none!>"); 1164 |
1024 j = ntohl(*((int *) bp)); | 1165 j = EXTRACT_32BITS(bp); |
1025 bp += sizeof(int32_t); 1026 1027 if (j != 0) 1028 printf(";"); 1029 1030 for (i = 0; i < j; i++) { 1031 printf(" ver"); 1032 INTOUT(); 1033 printf(" expires"); 1034 DATEOUT(); | 1166 bp += sizeof(int32_t); 1167 1168 if (j != 0) 1169 printf(";"); 1170 1171 for (i = 0; i < j; i++) { 1172 printf(" ver"); 1173 INTOUT(); 1174 printf(" expires"); 1175 DATEOUT(); |
1035 TRUNC(4); 1036 t = ntohl(*((int *) bp)); | 1176 TCHECK2(bp[0], 4); 1177 t = EXTRACT_32BITS(bp); |
1037 bp += sizeof(int32_t); 1038 tok2str(cb_types, "type %d", t); 1039 } 1040 } 1041 case 214: { 1042 printf(" afsuuid"); 1043 AFSUUIDOUT(); 1044 break; --- 75 unchanged lines hidden (view full) --- 1120 goto trunc; 1121 } 1122 1123 /* 1124 * Print out the afs call we're invoking. The table used here was 1125 * gleaned from ptserver/ptint.xg 1126 */ 1127 | 1178 bp += sizeof(int32_t); 1179 tok2str(cb_types, "type %d", t); 1180 } 1181 } 1182 case 214: { 1183 printf(" afsuuid"); 1184 AFSUUIDOUT(); 1185 break; --- 75 unchanged lines hidden (view full) --- 1261 goto trunc; 1262 } 1263 1264 /* 1265 * Print out the afs call we're invoking. The table used here was 1266 * gleaned from ptserver/ptint.xg 1267 */ 1268 |
1128 pt_op = ntohl(*((int *) (bp + sizeof(struct rx_header)))); | 1269 pt_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); |
1129 1130 printf(" pt"); 1131 1132 if (is_ubik(pt_op)) { 1133 ubik_print(bp, length); 1134 return; 1135 } 1136 --- 34 unchanged lines hidden (view full) --- 1171 printf(" uid"); 1172 INTOUT(); 1173 printf(" gid"); 1174 INTOUT(); 1175 break; 1176 case 504: /* Name to ID */ 1177 { 1178 unsigned long j; | 1270 1271 printf(" pt"); 1272 1273 if (is_ubik(pt_op)) { 1274 ubik_print(bp, length); 1275 return; 1276 } 1277 --- 34 unchanged lines hidden (view full) --- 1312 printf(" uid"); 1313 INTOUT(); 1314 printf(" gid"); 1315 INTOUT(); 1316 break; 1317 case 504: /* Name to ID */ 1318 { 1319 unsigned long j; |
1179 TRUNC(4); 1180 j = ntohl(*((int *) bp)); | 1320 TCHECK2(bp[0], 4); 1321 j = EXTRACT_32BITS(bp); |
1181 bp += sizeof(int32_t); 1182 1183 /* 1184 * Who designed this chicken-shit protocol? 1185 * 1186 * Each character is stored as a 32-bit 1187 * integer! 1188 */ --- 4 unchanged lines hidden (view full) --- 1193 if (j == 0) 1194 printf(" <none!>"); 1195 } 1196 break; 1197 case 505: /* Id to name */ 1198 { 1199 unsigned long j; 1200 printf(" ids:"); | 1322 bp += sizeof(int32_t); 1323 1324 /* 1325 * Who designed this chicken-shit protocol? 1326 * 1327 * Each character is stored as a 32-bit 1328 * integer! 1329 */ --- 4 unchanged lines hidden (view full) --- 1334 if (j == 0) 1335 printf(" <none!>"); 1336 } 1337 break; 1338 case 505: /* Id to name */ 1339 { 1340 unsigned long j; 1341 printf(" ids:"); |
1201 TRUNC(4); 1202 i = ntohl(*((int *) bp)); | 1342 TCHECK2(bp[0], 4); 1343 i = EXTRACT_32BITS(bp); |
1203 bp += sizeof(int32_t); 1204 for (j = 0; j < i; j++) 1205 INTOUT(); 1206 if (j == 0) 1207 printf(" <none!>"); 1208 } 1209 break; 1210 case 509: /* New entry */ --- 72 unchanged lines hidden (view full) --- 1283 */ 1284 1285 if (rxh->type == RX_PACKET_TYPE_DATA) 1286 switch (opcode) { 1287 case 504: /* Name to ID */ 1288 { 1289 unsigned long j; 1290 printf(" ids:"); | 1344 bp += sizeof(int32_t); 1345 for (j = 0; j < i; j++) 1346 INTOUT(); 1347 if (j == 0) 1348 printf(" <none!>"); 1349 } 1350 break; 1351 case 509: /* New entry */ --- 72 unchanged lines hidden (view full) --- 1424 */ 1425 1426 if (rxh->type == RX_PACKET_TYPE_DATA) 1427 switch (opcode) { 1428 case 504: /* Name to ID */ 1429 { 1430 unsigned long j; 1431 printf(" ids:"); |
1291 TRUNC(4); 1292 i = ntohl(*((int *) bp)); | 1432 TCHECK2(bp[0], 4); 1433 i = EXTRACT_32BITS(bp); |
1293 bp += sizeof(int32_t); 1294 for (j = 0; j < i; j++) 1295 INTOUT(); 1296 if (j == 0) 1297 printf(" <none!>"); 1298 } 1299 break; 1300 case 505: /* ID to name */ 1301 { 1302 unsigned long j; | 1434 bp += sizeof(int32_t); 1435 for (j = 0; j < i; j++) 1436 INTOUT(); 1437 if (j == 0) 1438 printf(" <none!>"); 1439 } 1440 break; 1441 case 505: /* ID to name */ 1442 { 1443 unsigned long j; |
1303 TRUNC(4); 1304 j = ntohl(*((int *) bp)); | 1444 TCHECK2(bp[0], 4); 1445 j = EXTRACT_32BITS(bp); |
1305 bp += sizeof(int32_t); 1306 1307 /* 1308 * Who designed this chicken-shit protocol? 1309 * 1310 * Each character is stored as a 32-bit 1311 * integer! 1312 */ --- 7 unchanged lines hidden (view full) --- 1320 break; 1321 case 508: /* Get CPS */ 1322 case 514: /* List elements */ 1323 case 517: /* List owned */ 1324 case 518: /* Get CPS2 */ 1325 case 519: /* Get host CPS */ 1326 { 1327 unsigned long j; | 1446 bp += sizeof(int32_t); 1447 1448 /* 1449 * Who designed this chicken-shit protocol? 1450 * 1451 * Each character is stored as a 32-bit 1452 * integer! 1453 */ --- 7 unchanged lines hidden (view full) --- 1461 break; 1462 case 508: /* Get CPS */ 1463 case 514: /* List elements */ 1464 case 517: /* List owned */ 1465 case 518: /* Get CPS2 */ 1466 case 519: /* Get host CPS */ 1467 { 1468 unsigned long j; |
1328 TRUNC(4); 1329 j = ntohl(*((int *) bp)); | 1469 TCHECK2(bp[0], 4); 1470 j = EXTRACT_32BITS(bp); |
1330 bp += sizeof(int32_t); 1331 for (i = 0; i < j; i++) { 1332 INTOUT(); 1333 } 1334 if (j == 0) 1335 printf(" <none!>"); 1336 } 1337 break; --- 38 unchanged lines hidden (view full) --- 1376 goto trunc; 1377 } 1378 1379 /* 1380 * Print out the afs call we're invoking. The table used here was 1381 * gleaned from vlserver/vldbint.xg 1382 */ 1383 | 1471 bp += sizeof(int32_t); 1472 for (i = 0; i < j; i++) { 1473 INTOUT(); 1474 } 1475 if (j == 0) 1476 printf(" <none!>"); 1477 } 1478 break; --- 38 unchanged lines hidden (view full) --- 1517 goto trunc; 1518 } 1519 1520 /* 1521 * Print out the afs call we're invoking. The table used here was 1522 * gleaned from vlserver/vldbint.xg 1523 */ 1524 |
1384 vldb_op = ntohl(*((int *) (bp + sizeof(struct rx_header)))); | 1525 vldb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); |
1385 1386 printf(" vldb"); 1387 1388 if (is_ubik(vldb_op)) { 1389 ubik_print(bp, length); 1390 return; 1391 } 1392 printf(" call %s", tok2str(vldb_req, "op#%d", vldb_op)); --- 12 unchanged lines hidden (view full) --- 1405 case 502: /* Delete entry */ 1406 case 503: /* Get entry by ID */ 1407 case 507: /* Update entry */ 1408 case 508: /* Set lock */ 1409 case 509: /* Release lock */ 1410 case 518: /* Get entry by ID N */ 1411 printf(" volid"); 1412 INTOUT(); | 1526 1527 printf(" vldb"); 1528 1529 if (is_ubik(vldb_op)) { 1530 ubik_print(bp, length); 1531 return; 1532 } 1533 printf(" call %s", tok2str(vldb_req, "op#%d", vldb_op)); --- 12 unchanged lines hidden (view full) --- 1546 case 502: /* Delete entry */ 1547 case 503: /* Get entry by ID */ 1548 case 507: /* Update entry */ 1549 case 508: /* Set lock */ 1550 case 509: /* Release lock */ 1551 case 518: /* Get entry by ID N */ 1552 printf(" volid"); 1553 INTOUT(); |
1413 TRUNC(sizeof(int32_t)); 1414 i = ntohl(*((int *) bp)); | 1554 TCHECK2(bp[0], sizeof(int32_t)); 1555 i = EXTRACT_32BITS(bp); |
1415 bp += sizeof(int32_t); 1416 if (i <= 2) 1417 printf(" type %s", voltype[i]); 1418 break; 1419 case 504: /* Get entry by name */ 1420 case 519: /* Get entry by name N */ 1421 case 524: /* Update entry by name */ 1422 case 527: /* Get entry by name U */ 1423 STROUT(VLNAMEMAX); 1424 break; 1425 case 505: /* Get new vol id */ 1426 printf(" bump"); 1427 INTOUT(); 1428 break; 1429 case 506: /* Replace entry */ 1430 case 520: /* Replace entry N */ 1431 printf(" volid"); 1432 INTOUT(); | 1556 bp += sizeof(int32_t); 1557 if (i <= 2) 1558 printf(" type %s", voltype[i]); 1559 break; 1560 case 504: /* Get entry by name */ 1561 case 519: /* Get entry by name N */ 1562 case 524: /* Update entry by name */ 1563 case 527: /* Get entry by name U */ 1564 STROUT(VLNAMEMAX); 1565 break; 1566 case 505: /* Get new vol id */ 1567 printf(" bump"); 1568 INTOUT(); 1569 break; 1570 case 506: /* Replace entry */ 1571 case 520: /* Replace entry N */ 1572 printf(" volid"); 1573 INTOUT(); |
1433 TRUNC(sizeof(int32_t)); 1434 i = ntohl(*((int *) bp)); | 1574 TCHECK2(bp[0], sizeof(int32_t)); 1575 i = EXTRACT_32BITS(bp); |
1435 bp += sizeof(int32_t); 1436 if (i <= 2) 1437 printf(" type %s", voltype[i]); 1438 VECOUT(VLNAMEMAX); 1439 break; 1440 case 510: /* List entry */ 1441 case 521: /* List entry N */ 1442 printf(" index"); --- 52 unchanged lines hidden (view full) --- 1495 printf(" count"); 1496 INTOUT(); 1497 printf(" nextindex"); 1498 INTOUT(); 1499 case 503: /* Get entry by id */ 1500 case 504: /* Get entry by name */ 1501 { unsigned long nservers, j; 1502 VECOUT(VLNAMEMAX); | 1576 bp += sizeof(int32_t); 1577 if (i <= 2) 1578 printf(" type %s", voltype[i]); 1579 VECOUT(VLNAMEMAX); 1580 break; 1581 case 510: /* List entry */ 1582 case 521: /* List entry N */ 1583 printf(" index"); --- 52 unchanged lines hidden (view full) --- 1636 printf(" count"); 1637 INTOUT(); 1638 printf(" nextindex"); 1639 INTOUT(); 1640 case 503: /* Get entry by id */ 1641 case 504: /* Get entry by name */ 1642 { unsigned long nservers, j; 1643 VECOUT(VLNAMEMAX); |
1503 TRUNC(sizeof(int32_t)); | 1644 TCHECK2(bp[0], sizeof(int32_t)); |
1504 bp += sizeof(int32_t); 1505 printf(" numservers"); | 1645 bp += sizeof(int32_t); 1646 printf(" numservers"); |
1506 TRUNC(sizeof(int32_t)); 1507 nservers = ntohl(*((int *) bp)); | 1647 TCHECK2(bp[0], sizeof(int32_t)); 1648 nservers = EXTRACT_32BITS(bp); |
1508 bp += sizeof(int32_t); 1509 printf(" %lu", nservers); 1510 printf(" servers"); 1511 for (i = 0; i < 8; i++) { | 1649 bp += sizeof(int32_t); 1650 printf(" %lu", nservers); 1651 printf(" servers"); 1652 for (i = 0; i < 8; i++) { |
1512 TRUNC(sizeof(int32_t)); | 1653 TCHECK2(bp[0], sizeof(int32_t)); |
1513 if (i < nservers) 1514 printf(" %s", 1515 inet_ntoa(*((struct in_addr *) bp))); 1516 bp += sizeof(int32_t); 1517 } 1518 printf(" partitions"); 1519 for (i = 0; i < 8; i++) { | 1654 if (i < nservers) 1655 printf(" %s", 1656 inet_ntoa(*((struct in_addr *) bp))); 1657 bp += sizeof(int32_t); 1658 } 1659 printf(" partitions"); 1660 for (i = 0; i < 8; i++) { |
1520 TRUNC(sizeof(int32_t)); 1521 j = ntohl(*((int *) bp)); | 1661 TCHECK2(bp[0], sizeof(int32_t)); 1662 j = EXTRACT_32BITS(bp); |
1522 if (i < nservers && j <= 26) 1523 printf(" %c", 'a' + (int)j); 1524 else if (i < nservers) 1525 printf(" %lu", j); 1526 bp += sizeof(int32_t); 1527 } | 1663 if (i < nservers && j <= 26) 1664 printf(" %c", 'a' + (int)j); 1665 else if (i < nservers) 1666 printf(" %lu", j); 1667 bp += sizeof(int32_t); 1668 } |
1528 TRUNC(8 * sizeof(int32_t)); | 1669 TCHECK2(bp[0], 8 * sizeof(int32_t)); |
1529 bp += 8 * sizeof(int32_t); 1530 printf(" rwvol"); 1531 UINTOUT(); 1532 printf(" rovol"); 1533 UINTOUT(); 1534 printf(" backup"); 1535 UINTOUT(); 1536 } --- 8 unchanged lines hidden (view full) --- 1545 INTOUT(); 1546 printf(" nextindex"); 1547 INTOUT(); 1548 case 518: /* Get entry by ID N */ 1549 case 519: /* Get entry by name N */ 1550 { unsigned long nservers, j; 1551 VECOUT(VLNAMEMAX); 1552 printf(" numservers"); | 1670 bp += 8 * sizeof(int32_t); 1671 printf(" rwvol"); 1672 UINTOUT(); 1673 printf(" rovol"); 1674 UINTOUT(); 1675 printf(" backup"); 1676 UINTOUT(); 1677 } --- 8 unchanged lines hidden (view full) --- 1686 INTOUT(); 1687 printf(" nextindex"); 1688 INTOUT(); 1689 case 518: /* Get entry by ID N */ 1690 case 519: /* Get entry by name N */ 1691 { unsigned long nservers, j; 1692 VECOUT(VLNAMEMAX); 1693 printf(" numservers"); |
1553 TRUNC(sizeof(int32_t)); 1554 nservers = ntohl(*((int *) bp)); | 1694 TCHECK2(bp[0], sizeof(int32_t)); 1695 nservers = EXTRACT_32BITS(bp); |
1555 bp += sizeof(int32_t); 1556 printf(" %lu", nservers); 1557 printf(" servers"); 1558 for (i = 0; i < 13; i++) { | 1696 bp += sizeof(int32_t); 1697 printf(" %lu", nservers); 1698 printf(" servers"); 1699 for (i = 0; i < 13; i++) { |
1559 TRUNC(sizeof(int32_t)); | 1700 TCHECK2(bp[0], sizeof(int32_t)); |
1560 if (i < nservers) 1561 printf(" %s", 1562 inet_ntoa(*((struct in_addr *) bp))); 1563 bp += sizeof(int32_t); 1564 } 1565 printf(" partitions"); 1566 for (i = 0; i < 13; i++) { | 1701 if (i < nservers) 1702 printf(" %s", 1703 inet_ntoa(*((struct in_addr *) bp))); 1704 bp += sizeof(int32_t); 1705 } 1706 printf(" partitions"); 1707 for (i = 0; i < 13; i++) { |
1567 TRUNC(sizeof(int32_t)); 1568 j = ntohl(*((int *) bp)); | 1708 TCHECK2(bp[0], sizeof(int32_t)); 1709 j = EXTRACT_32BITS(bp); |
1569 if (i < nservers && j <= 26) 1570 printf(" %c", 'a' + (int)j); 1571 else if (i < nservers) 1572 printf(" %lu", j); 1573 bp += sizeof(int32_t); 1574 } | 1710 if (i < nservers && j <= 26) 1711 printf(" %c", 'a' + (int)j); 1712 else if (i < nservers) 1713 printf(" %lu", j); 1714 bp += sizeof(int32_t); 1715 } |
1575 TRUNC(13 * sizeof(int32_t)); | 1716 TCHECK2(bp[0], 13 * sizeof(int32_t)); |
1576 bp += 13 * sizeof(int32_t); 1577 printf(" rwvol"); 1578 UINTOUT(); 1579 printf(" rovol"); 1580 UINTOUT(); 1581 printf(" backup"); 1582 UINTOUT(); 1583 } 1584 break; 1585 case 526: /* Get entry by ID U */ 1586 case 527: /* Get entry by name U */ 1587 { unsigned long nservers, j; 1588 VECOUT(VLNAMEMAX); 1589 printf(" numservers"); | 1717 bp += 13 * sizeof(int32_t); 1718 printf(" rwvol"); 1719 UINTOUT(); 1720 printf(" rovol"); 1721 UINTOUT(); 1722 printf(" backup"); 1723 UINTOUT(); 1724 } 1725 break; 1726 case 526: /* Get entry by ID U */ 1727 case 527: /* Get entry by name U */ 1728 { unsigned long nservers, j; 1729 VECOUT(VLNAMEMAX); 1730 printf(" numservers"); |
1590 TRUNC(sizeof(int32_t)); 1591 nservers = ntohl(*((int *) bp)); | 1731 TCHECK2(bp[0], sizeof(int32_t)); 1732 nservers = EXTRACT_32BITS(bp); |
1592 bp += sizeof(int32_t); 1593 printf(" %lu", nservers); 1594 printf(" servers"); 1595 for (i = 0; i < 13; i++) { 1596 if (i < nservers) { 1597 printf(" afsuuid"); 1598 AFSUUIDOUT(); 1599 } else { | 1733 bp += sizeof(int32_t); 1734 printf(" %lu", nservers); 1735 printf(" servers"); 1736 for (i = 0; i < 13; i++) { 1737 if (i < nservers) { 1738 printf(" afsuuid"); 1739 AFSUUIDOUT(); 1740 } else { |
1600 TRUNC(44); | 1741 TCHECK2(bp[0], 44); |
1601 bp += 44; 1602 } 1603 } | 1742 bp += 44; 1743 } 1744 } |
1604 TRUNC(4 * 13); | 1745 TCHECK2(bp[0], 4 * 13); |
1605 bp += 4 * 13; 1606 printf(" partitions"); 1607 for (i = 0; i < 13; i++) { | 1746 bp += 4 * 13; 1747 printf(" partitions"); 1748 for (i = 0; i < 13; i++) { |
1608 TRUNC(sizeof(int32_t)); 1609 j = ntohl(*((int *) bp)); | 1749 TCHECK2(bp[0], sizeof(int32_t)); 1750 j = EXTRACT_32BITS(bp); |
1610 if (i < nservers && j <= 26) 1611 printf(" %c", 'a' + (int)j); 1612 else if (i < nservers) 1613 printf(" %lu", j); 1614 bp += sizeof(int32_t); 1615 } | 1751 if (i < nservers && j <= 26) 1752 printf(" %c", 'a' + (int)j); 1753 else if (i < nservers) 1754 printf(" %lu", j); 1755 bp += sizeof(int32_t); 1756 } |
1616 TRUNC(13 * sizeof(int32_t)); | 1757 TCHECK2(bp[0], 13 * sizeof(int32_t)); |
1617 bp += 13 * sizeof(int32_t); 1618 printf(" rwvol"); 1619 UINTOUT(); 1620 printf(" rovol"); 1621 UINTOUT(); 1622 printf(" backup"); 1623 UINTOUT(); 1624 } --- 32 unchanged lines hidden (view full) --- 1657 goto trunc; 1658 } 1659 1660 /* 1661 * Print out the afs call we're invoking. The table used here was 1662 * gleaned from kauth/kauth.rg 1663 */ 1664 | 1758 bp += 13 * sizeof(int32_t); 1759 printf(" rwvol"); 1760 UINTOUT(); 1761 printf(" rovol"); 1762 UINTOUT(); 1763 printf(" backup"); 1764 UINTOUT(); 1765 } --- 32 unchanged lines hidden (view full) --- 1798 goto trunc; 1799 } 1800 1801 /* 1802 * Print out the afs call we're invoking. The table used here was 1803 * gleaned from kauth/kauth.rg 1804 */ 1805 |
1665 kauth_op = ntohl(*((int *) (bp + sizeof(struct rx_header)))); | 1806 kauth_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); |
1666 1667 printf(" kauth"); 1668 1669 if (is_ubik(kauth_op)) { 1670 ubik_print(bp, length); 1671 return; 1672 } 1673 --- 24 unchanged lines hidden (view full) --- 1698 case 3: /* GetTicket-old */ 1699 case 23: /* GetTicket */ 1700 { 1701 int i; 1702 printf(" kvno"); 1703 INTOUT(); 1704 printf(" domain"); 1705 STROUT(KANAMEMAX); | 1807 1808 printf(" kauth"); 1809 1810 if (is_ubik(kauth_op)) { 1811 ubik_print(bp, length); 1812 return; 1813 } 1814 --- 24 unchanged lines hidden (view full) --- 1839 case 3: /* GetTicket-old */ 1840 case 23: /* GetTicket */ 1841 { 1842 int i; 1843 printf(" kvno"); 1844 INTOUT(); 1845 printf(" domain"); 1846 STROUT(KANAMEMAX); |
1706 TRUNC(sizeof(int32_t)); 1707 i = (int) ntohl(*((int *) bp)); | 1847 TCHECK2(bp[0], sizeof(int32_t)); 1848 i = (int) EXTRACT_32BITS(bp); |
1708 bp += sizeof(int32_t); | 1849 bp += sizeof(int32_t); |
1709 TRUNC(i); | 1850 TCHECK2(bp[0], i); |
1710 bp += i; 1711 printf(" principal"); 1712 STROUT(KANAMEMAX); 1713 STROUT(KANAMEMAX); 1714 break; 1715 } 1716 case 4: /* Set Password */ 1717 printf(" principal"); --- 83 unchanged lines hidden (view full) --- 1801 goto trunc; 1802 } 1803 1804 /* 1805 * Print out the afs call we're invoking. The table used here was 1806 * gleaned from volser/volint.xg 1807 */ 1808 | 1851 bp += i; 1852 printf(" principal"); 1853 STROUT(KANAMEMAX); 1854 STROUT(KANAMEMAX); 1855 break; 1856 } 1857 case 4: /* Set Password */ 1858 printf(" principal"); --- 83 unchanged lines hidden (view full) --- 1942 goto trunc; 1943 } 1944 1945 /* 1946 * Print out the afs call we're invoking. The table used here was 1947 * gleaned from volser/volint.xg 1948 */ 1949 |
1809 vol_op = ntohl(*((int *) (bp + sizeof(struct rx_header)))); | 1950 vol_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); |
1810 1811 printf(" vol call %s", tok2str(vol_req, "op#%d", vol_op)); 1812 1813 /* 1814 * Normally there would be a switch statement here to decode the 1815 * arguments to the AFS call, but since I don't have access to 1816 * an AFS server (yet) and I'm not an AFS admin, I can't 1817 * test any of these calls. Leave this blank for now. --- 66 unchanged lines hidden (view full) --- 1884 goto trunc; 1885 } 1886 1887 /* 1888 * Print out the afs call we're invoking. The table used here was 1889 * gleaned from bozo/bosint.xg 1890 */ 1891 | 1951 1952 printf(" vol call %s", tok2str(vol_req, "op#%d", vol_op)); 1953 1954 /* 1955 * Normally there would be a switch statement here to decode the 1956 * arguments to the AFS call, but since I don't have access to 1957 * an AFS server (yet) and I'm not an AFS admin, I can't 1958 * test any of these calls. Leave this blank for now. --- 66 unchanged lines hidden (view full) --- 2025 goto trunc; 2026 } 2027 2028 /* 2029 * Print out the afs call we're invoking. The table used here was 2030 * gleaned from bozo/bosint.xg 2031 */ 2032 |
1892 bos_op = ntohl(*((int *) (bp + sizeof(struct rx_header)))); | 2033 bos_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); |
1893 1894 printf(" bos call %s", tok2str(bos_req, "op#%d", bos_op)); 1895 1896 /* 1897 * Decode some of the arguments to the BOS calls 1898 */ 1899 1900 bp += sizeof(struct rx_header) + 4; --- 126 unchanged lines hidden (view full) --- 2027 int ubik_op; 2028 int32_t temp; 2029 2030 /* 2031 * Print out the afs call we're invoking. The table used here was 2032 * gleaned from ubik/ubik_int.xg 2033 */ 2034 | 2034 2035 printf(" bos call %s", tok2str(bos_req, "op#%d", bos_op)); 2036 2037 /* 2038 * Decode some of the arguments to the BOS calls 2039 */ 2040 2041 bp += sizeof(struct rx_header) + 4; --- 126 unchanged lines hidden (view full) --- 2168 int ubik_op; 2169 int32_t temp; 2170 2171 /* 2172 * Print out the afs call we're invoking. The table used here was 2173 * gleaned from ubik/ubik_int.xg 2174 */ 2175 |
2035 ubik_op = ntohl(*((int *) (bp + sizeof(struct rx_header)))); | 2176 ubik_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); |
2036 2037 printf(" ubik call %s", tok2str(ubik_req, "op#%d", ubik_op)); 2038 2039 /* 2040 * Decode some of the arguments to the Ubik calls 2041 */ 2042 2043 bp += sizeof(struct rx_header) + 4; 2044 2045 switch (ubik_op) { 2046 case 10000: /* Beacon */ | 2177 2178 printf(" ubik call %s", tok2str(ubik_req, "op#%d", ubik_op)); 2179 2180 /* 2181 * Decode some of the arguments to the Ubik calls 2182 */ 2183 2184 bp += sizeof(struct rx_header) + 4; 2185 2186 switch (ubik_op) { 2187 case 10000: /* Beacon */ |
2047 TRUNC(4); 2048 temp = ntohl(*((int *) bp)); | 2188 TCHECK2(bp[0], 4); 2189 temp = EXTRACT_32BITS(bp); |
2049 bp += sizeof(int32_t); 2050 printf(" syncsite %s", temp ? "yes" : "no"); 2051 printf(" votestart"); 2052 DATEOUT(); 2053 printf(" dbversion"); 2054 UBIK_VERSIONOUT(); 2055 printf(" tid"); 2056 UBIK_VERSIONOUT(); --- 14 unchanged lines hidden (view full) --- 2071 printf(" tid"); 2072 UBIK_VERSIONOUT(); 2073 printf(" file"); 2074 INTOUT(); 2075 printf(" pos"); 2076 INTOUT(); 2077 printf(" length"); 2078 INTOUT(); | 2190 bp += sizeof(int32_t); 2191 printf(" syncsite %s", temp ? "yes" : "no"); 2192 printf(" votestart"); 2193 DATEOUT(); 2194 printf(" dbversion"); 2195 UBIK_VERSIONOUT(); 2196 printf(" tid"); 2197 UBIK_VERSIONOUT(); --- 14 unchanged lines hidden (view full) --- 2212 printf(" tid"); 2213 UBIK_VERSIONOUT(); 2214 printf(" file"); 2215 INTOUT(); 2216 printf(" pos"); 2217 INTOUT(); 2218 printf(" length"); 2219 INTOUT(); |
2079 temp = ntohl(*((int *) bp)); | 2220 temp = EXTRACT_32BITS(bp); |
2080 bp += sizeof(int32_t); 2081 tok2str(ubik_lock_types, "type %d", temp); 2082 break; 2083 case 20003: /* Write */ 2084 printf(" tid"); 2085 UBIK_VERSIONOUT(); 2086 printf(" file"); 2087 INTOUT(); --- 95 unchanged lines hidden (view full) --- 2183 INTOUT(); 2184 } 2185 2186 return; 2187 2188trunc: 2189 printf(" [|ubik]"); 2190} | 2221 bp += sizeof(int32_t); 2222 tok2str(ubik_lock_types, "type %d", temp); 2223 break; 2224 case 20003: /* Write */ 2225 printf(" tid"); 2226 UBIK_VERSIONOUT(); 2227 printf(" file"); 2228 INTOUT(); --- 95 unchanged lines hidden (view full) --- 2324 INTOUT(); 2325 } 2326 2327 return; 2328 2329trunc: 2330 printf(" [|ubik]"); 2331} |
2332 2333/* 2334 * Handle RX ACK packets. 2335 */ 2336 2337static void 2338rx_ack_print(register const u_char *bp, int length) 2339{ 2340 struct rx_ackPacket *rxa; 2341 int i, start, last; 2342 2343 if (length < sizeof(struct rx_header)) 2344 return; 2345 2346 bp += sizeof(struct rx_header); 2347 2348 /* 2349 * This may seem a little odd .... the rx_ackPacket structure 2350 * contains an array of individual packet acknowledgements 2351 * (used for selective ack/nack), but since it's variable in size, 2352 * we don't want to truncate based on the size of the whole 2353 * rx_ackPacket structure. 2354 */ 2355 2356 TCHECK2(bp[0], sizeof(struct rx_ackPacket) - RX_MAXACKS); 2357 2358 rxa = (struct rx_ackPacket *) bp; 2359 bp += (sizeof(struct rx_ackPacket) - RX_MAXACKS); 2360 2361 /* 2362 * Print out a few useful things from the ack packet structure 2363 */ 2364 2365 if (vflag > 2) 2366 printf(" bufspace %d maxskew %d", 2367 (int) EXTRACT_16BITS(&rxa->bufferSpace), 2368 (int) EXTRACT_16BITS(&rxa->maxSkew)); 2369 2370 printf(" first %d serial %d reason %s", 2371 EXTRACT_32BITS(&rxa->firstPacket), EXTRACT_32BITS(&rxa->serial), 2372 tok2str(rx_ack_reasons, "#%d", (int) rxa->reason)); 2373 2374 /* 2375 * Okay, now we print out the ack array. The way _this_ works 2376 * is that we start at "first", and step through the ack array. 2377 * If we have a contiguous range of acks/nacks, try to 2378 * collapse them into a range. 2379 * 2380 * If you're really clever, you might have noticed that this 2381 * doesn't seem quite correct. Specifically, due to structure 2382 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually 2383 * yield the start of the ack array (because RX_MAXACKS is 255 2384 * and the structure will likely get padded to a 2 or 4 byte 2385 * boundary). However, this is the way it's implemented inside 2386 * of AFS - the start of the extra fields are at 2387 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_ 2388 * the exact start of the ack array. Sigh. That's why we aren't 2389 * using bp, but instead use rxa->acks[]. But nAcks gets added 2390 * to bp after this, so bp ends up at the right spot. Go figure. 2391 */ 2392 2393 if (rxa->nAcks != 0) { 2394 2395 TCHECK2(bp[0], rxa->nAcks); 2396 2397 /* 2398 * Sigh, this is gross, but it seems to work to collapse 2399 * ranges correctly. 2400 */ 2401 2402 for (i = 0, start = last = -2; i < rxa->nAcks; i++) 2403 if (rxa->acks[i] == RX_ACK_TYPE_ACK) { 2404 2405 /* 2406 * I figured this deserved _some_ explanation. 2407 * First, print "acked" and the packet seq 2408 * number if this is the first time we've 2409 * seen an acked packet. 2410 */ 2411 2412 if (last == -2) { 2413 printf(" acked %d", 2414 rxa->firstPacket + i); 2415 start = i; 2416 } 2417 2418 /* 2419 * Otherwise, if the there is a skip in 2420 * the range (such as an nacked packet in 2421 * the middle of some acked packets), 2422 * then print the current packet number 2423 * seperated from the last number by 2424 * a comma. 2425 */ 2426 2427 else if (last != i - 1) { 2428 printf(",%d", rxa->firstPacket + i); 2429 start = i; 2430 } 2431 2432 /* 2433 * We always set last to the value of 2434 * the last ack we saw. Conversely, start 2435 * is set to the value of the first ack 2436 * we saw in a range. 2437 */ 2438 2439 last = i; 2440 2441 /* 2442 * Okay, this bit a code gets executed when 2443 * we hit a nack ... in _this_ case we 2444 * want to print out the range of packets 2445 * that were acked, so we need to print 2446 * the _previous_ packet number seperated 2447 * from the first by a dash (-). Since we 2448 * already printed the first packet above, 2449 * just print the final packet. Don't 2450 * do this if there will be a single-length 2451 * range. 2452 */ 2453 } else if (last == i - 1 && start != last) 2454 printf("-%d", rxa->firstPacket + i - 1); 2455 2456 /* 2457 * So, what's going on here? We ran off the end of the 2458 * ack list, and if we got a range we need to finish it up. 2459 * So we need to determine if the last packet in the list 2460 * was an ack (if so, then last will be set to it) and 2461 * we need to see if the last range didn't start with the 2462 * last packet (because if it _did_, then that would mean 2463 * that the packet number has already been printed and 2464 * we don't need to print it again). 2465 */ 2466 2467 if (last == i - 1 && start != last) 2468 printf("-%d", rxa->firstPacket + i - 1); 2469 2470 /* 2471 * Same as above, just without comments 2472 */ 2473 2474 for (i = 0, start = last = -2; i < rxa->nAcks; i++) 2475 if (rxa->acks[i] == RX_ACK_TYPE_NACK) { 2476 if (last == -2) { 2477 printf(" nacked %d", 2478 rxa->firstPacket + i); 2479 start = i; 2480 } else if (last != i - 1) { 2481 printf(",%d", rxa->firstPacket + i); 2482 start = i; 2483 } 2484 last = i; 2485 } else if (last == i - 1 && start != last) 2486 printf("-%d", rxa->firstPacket + i - 1); 2487 2488 if (last == i - 1 && start != last) 2489 printf("-%d", rxa->firstPacket + i - 1); 2490 2491 bp += rxa->nAcks; 2492 } 2493 2494 2495 /* 2496 * These are optional fields; depending on your version of AFS, 2497 * you may or may not see them 2498 */ 2499 2500#define TRUNCRET(n) if (snapend - bp + 1 <= n) return; 2501 2502 if (vflag > 1) { 2503 TRUNCRET(4); 2504 printf(" ifmtu"); 2505 INTOUT(); 2506 2507 TRUNCRET(4); 2508 printf(" maxmtu"); 2509 INTOUT(); 2510 2511 TRUNCRET(4); 2512 printf(" rwind"); 2513 INTOUT(); 2514 2515 TRUNCRET(4); 2516 printf(" maxpackets"); 2517 INTOUT(); 2518 } 2519 2520 return; 2521 2522trunc: 2523 printf(" [|ack]"); 2524} 2525#undef TRUNCRET |
|