1 /* 2 * Copyright: (c) 2000 United States Government as represented by the 3 * Secretary of the Navy. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in 13 * the documentation and/or other materials provided with the 14 * distribution. 15 * 3. The names of the authors may not be used to endorse or promote 16 * products derived from this software without specific prior 17 * written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22 */ 23 24 /* \summary: AFS RX printer */ 25 26 /* 27 * This code unmangles RX packets. RX is the mutant form of RPC that AFS 28 * uses to communicate between clients and servers. 29 * 30 * In this code, I mainly concern myself with decoding the AFS calls, not 31 * with the guts of RX, per se. 32 * 33 * Bah. If I never look at rx_packet.h again, it will be too soon. 34 * 35 * Ken Hornstein <kenh@cmf.nrl.navy.mil> 36 */ 37 38 #include <sys/cdefs.h> 39 #ifndef lint 40 __RCSID("$NetBSD: print-rx.c,v 1.7 2017/02/05 04:05:05 spz Exp $"); 41 #endif 42 43 #ifdef HAVE_CONFIG_H 44 #include "config.h" 45 #endif 46 47 #include <stdio.h> 48 #include <stdlib.h> 49 #include <string.h> 50 #include <netdissect-stdinc.h> 51 52 #include "netdissect.h" 53 #include "addrtoname.h" 54 #include "extract.h" 55 56 #include "ip.h" 57 58 #define FS_RX_PORT 7000 59 #define CB_RX_PORT 7001 60 #define PROT_RX_PORT 7002 61 #define VLDB_RX_PORT 7003 62 #define KAUTH_RX_PORT 7004 63 #define VOL_RX_PORT 7005 64 #define ERROR_RX_PORT 7006 /* Doesn't seem to be used */ 65 #define BOS_RX_PORT 7007 66 67 #define AFSNAMEMAX 256 68 #define AFSOPAQUEMAX 1024 69 #define PRNAMEMAX 64 70 #define VLNAMEMAX 65 71 #define KANAMEMAX 64 72 #define BOSNAMEMAX 256 73 74 #define PRSFS_READ 1 /* Read files */ 75 #define PRSFS_WRITE 2 /* Write files */ 76 #define PRSFS_INSERT 4 /* Insert files into a directory */ 77 #define PRSFS_LOOKUP 8 /* Lookup files into a directory */ 78 #define PRSFS_DELETE 16 /* Delete files */ 79 #define PRSFS_LOCK 32 /* Lock files */ 80 #define PRSFS_ADMINISTER 64 /* Change ACL's */ 81 82 struct rx_header { 83 uint32_t epoch; 84 uint32_t cid; 85 uint32_t callNumber; 86 uint32_t seq; 87 uint32_t serial; 88 uint8_t type; 89 #define RX_PACKET_TYPE_DATA 1 90 #define RX_PACKET_TYPE_ACK 2 91 #define RX_PACKET_TYPE_BUSY 3 92 #define RX_PACKET_TYPE_ABORT 4 93 #define RX_PACKET_TYPE_ACKALL 5 94 #define RX_PACKET_TYPE_CHALLENGE 6 95 #define RX_PACKET_TYPE_RESPONSE 7 96 #define RX_PACKET_TYPE_DEBUG 8 97 #define RX_PACKET_TYPE_PARAMS 9 98 #define RX_PACKET_TYPE_VERSION 13 99 uint8_t flags; 100 #define RX_CLIENT_INITIATED 1 101 #define RX_REQUEST_ACK 2 102 #define RX_LAST_PACKET 4 103 #define RX_MORE_PACKETS 8 104 #define RX_FREE_PACKET 16 105 #define RX_SLOW_START_OK 32 106 #define RX_JUMBO_PACKET 32 107 uint8_t userStatus; 108 uint8_t securityIndex; 109 uint16_t spare; /* How clever: even though the AFS */ 110 uint16_t serviceId; /* header files indicate that the */ 111 }; /* serviceId is first, it's really */ 112 /* encoded _after_ the spare field */ 113 /* I wasted a day figuring that out! */ 114 115 #define NUM_RX_FLAGS 7 116 117 #define RX_MAXACKS 255 118 119 struct rx_ackPacket { 120 uint16_t bufferSpace; /* Number of packet buffers available */ 121 uint16_t maxSkew; /* Max diff between ack'd packet and */ 122 /* highest packet received */ 123 uint32_t firstPacket; /* The first packet in ack list */ 124 uint32_t previousPacket; /* Previous packet recv'd (obsolete) */ 125 uint32_t serial; /* # of packet that prompted the ack */ 126 uint8_t reason; /* Reason for acknowledgement */ 127 uint8_t nAcks; /* Number of acknowledgements */ 128 uint8_t acks[RX_MAXACKS]; /* Up to RX_MAXACKS acknowledgements */ 129 }; 130 131 /* 132 * Values for the acks array 133 */ 134 135 #define RX_ACK_TYPE_NACK 0 /* Don't have this packet */ 136 #define RX_ACK_TYPE_ACK 1 /* I have this packet */ 137 138 static const struct tok rx_types[] = { 139 { RX_PACKET_TYPE_DATA, "data" }, 140 { RX_PACKET_TYPE_ACK, "ack" }, 141 { RX_PACKET_TYPE_BUSY, "busy" }, 142 { RX_PACKET_TYPE_ABORT, "abort" }, 143 { RX_PACKET_TYPE_ACKALL, "ackall" }, 144 { RX_PACKET_TYPE_CHALLENGE, "challenge" }, 145 { RX_PACKET_TYPE_RESPONSE, "response" }, 146 { RX_PACKET_TYPE_DEBUG, "debug" }, 147 { RX_PACKET_TYPE_PARAMS, "params" }, 148 { RX_PACKET_TYPE_VERSION, "version" }, 149 { 0, NULL }, 150 }; 151 152 static const struct double_tok { 153 int flag; /* Rx flag */ 154 int packetType; /* Packet type */ 155 const char *s; /* Flag string */ 156 } rx_flags[] = { 157 { RX_CLIENT_INITIATED, 0, "client-init" }, 158 { RX_REQUEST_ACK, 0, "req-ack" }, 159 { RX_LAST_PACKET, 0, "last-pckt" }, 160 { RX_MORE_PACKETS, 0, "more-pckts" }, 161 { RX_FREE_PACKET, 0, "free-pckt" }, 162 { RX_SLOW_START_OK, RX_PACKET_TYPE_ACK, "slow-start" }, 163 { RX_JUMBO_PACKET, RX_PACKET_TYPE_DATA, "jumbogram" } 164 }; 165 166 static const struct tok fs_req[] = { 167 { 130, "fetch-data" }, 168 { 131, "fetch-acl" }, 169 { 132, "fetch-status" }, 170 { 133, "store-data" }, 171 { 134, "store-acl" }, 172 { 135, "store-status" }, 173 { 136, "remove-file" }, 174 { 137, "create-file" }, 175 { 138, "rename" }, 176 { 139, "symlink" }, 177 { 140, "link" }, 178 { 141, "makedir" }, 179 { 142, "rmdir" }, 180 { 143, "oldsetlock" }, 181 { 144, "oldextlock" }, 182 { 145, "oldrellock" }, 183 { 146, "get-stats" }, 184 { 147, "give-cbs" }, 185 { 148, "get-vlinfo" }, 186 { 149, "get-vlstats" }, 187 { 150, "set-vlstats" }, 188 { 151, "get-rootvl" }, 189 { 152, "check-token" }, 190 { 153, "get-time" }, 191 { 154, "nget-vlinfo" }, 192 { 155, "bulk-stat" }, 193 { 156, "setlock" }, 194 { 157, "extlock" }, 195 { 158, "rellock" }, 196 { 159, "xstat-ver" }, 197 { 160, "get-xstat" }, 198 { 161, "dfs-lookup" }, 199 { 162, "dfs-flushcps" }, 200 { 163, "dfs-symlink" }, 201 { 220, "residency" }, 202 { 65536, "inline-bulk-status" }, 203 { 65537, "fetch-data-64" }, 204 { 65538, "store-data-64" }, 205 { 65539, "give-up-all-cbs" }, 206 { 65540, "get-caps" }, 207 { 65541, "cb-rx-conn-addr" }, 208 { 0, NULL }, 209 }; 210 211 static const struct tok cb_req[] = { 212 { 204, "callback" }, 213 { 205, "initcb" }, 214 { 206, "probe" }, 215 { 207, "getlock" }, 216 { 208, "getce" }, 217 { 209, "xstatver" }, 218 { 210, "getxstat" }, 219 { 211, "initcb2" }, 220 { 212, "whoareyou" }, 221 { 213, "initcb3" }, 222 { 214, "probeuuid" }, 223 { 215, "getsrvprefs" }, 224 { 216, "getcellservdb" }, 225 { 217, "getlocalcell" }, 226 { 218, "getcacheconf" }, 227 { 65536, "getce64" }, 228 { 65537, "getcellbynum" }, 229 { 65538, "tellmeaboutyourself" }, 230 { 0, NULL }, 231 }; 232 233 static const struct tok pt_req[] = { 234 { 500, "new-user" }, 235 { 501, "where-is-it" }, 236 { 502, "dump-entry" }, 237 { 503, "add-to-group" }, 238 { 504, "name-to-id" }, 239 { 505, "id-to-name" }, 240 { 506, "delete" }, 241 { 507, "remove-from-group" }, 242 { 508, "get-cps" }, 243 { 509, "new-entry" }, 244 { 510, "list-max" }, 245 { 511, "set-max" }, 246 { 512, "list-entry" }, 247 { 513, "change-entry" }, 248 { 514, "list-elements" }, 249 { 515, "same-mbr-of" }, 250 { 516, "set-fld-sentry" }, 251 { 517, "list-owned" }, 252 { 518, "get-cps2" }, 253 { 519, "get-host-cps" }, 254 { 520, "update-entry" }, 255 { 521, "list-entries" }, 256 { 530, "list-super-groups" }, 257 { 0, NULL }, 258 }; 259 260 static const struct tok vldb_req[] = { 261 { 501, "create-entry" }, 262 { 502, "delete-entry" }, 263 { 503, "get-entry-by-id" }, 264 { 504, "get-entry-by-name" }, 265 { 505, "get-new-volume-id" }, 266 { 506, "replace-entry" }, 267 { 507, "update-entry" }, 268 { 508, "setlock" }, 269 { 509, "releaselock" }, 270 { 510, "list-entry" }, 271 { 511, "list-attrib" }, 272 { 512, "linked-list" }, 273 { 513, "get-stats" }, 274 { 514, "probe" }, 275 { 515, "get-addrs" }, 276 { 516, "change-addr" }, 277 { 517, "create-entry-n" }, 278 { 518, "get-entry-by-id-n" }, 279 { 519, "get-entry-by-name-n" }, 280 { 520, "replace-entry-n" }, 281 { 521, "list-entry-n" }, 282 { 522, "list-attrib-n" }, 283 { 523, "linked-list-n" }, 284 { 524, "update-entry-by-name" }, 285 { 525, "create-entry-u" }, 286 { 526, "get-entry-by-id-u" }, 287 { 527, "get-entry-by-name-u" }, 288 { 528, "replace-entry-u" }, 289 { 529, "list-entry-u" }, 290 { 530, "list-attrib-u" }, 291 { 531, "linked-list-u" }, 292 { 532, "regaddr" }, 293 { 533, "get-addrs-u" }, 294 { 534, "list-attrib-n2" }, 295 { 0, NULL }, 296 }; 297 298 static const struct tok kauth_req[] = { 299 { 1, "auth-old" }, 300 { 21, "authenticate" }, 301 { 22, "authenticate-v2" }, 302 { 2, "change-pw" }, 303 { 3, "get-ticket-old" }, 304 { 23, "get-ticket" }, 305 { 4, "set-pw" }, 306 { 5, "set-fields" }, 307 { 6, "create-user" }, 308 { 7, "delete-user" }, 309 { 8, "get-entry" }, 310 { 9, "list-entry" }, 311 { 10, "get-stats" }, 312 { 11, "debug" }, 313 { 12, "get-pw" }, 314 { 13, "get-random-key" }, 315 { 14, "unlock" }, 316 { 15, "lock-status" }, 317 { 0, NULL }, 318 }; 319 320 static const struct tok vol_req[] = { 321 { 100, "create-volume" }, 322 { 101, "delete-volume" }, 323 { 102, "restore" }, 324 { 103, "forward" }, 325 { 104, "end-trans" }, 326 { 105, "clone" }, 327 { 106, "set-flags" }, 328 { 107, "get-flags" }, 329 { 108, "trans-create" }, 330 { 109, "dump" }, 331 { 110, "get-nth-volume" }, 332 { 111, "set-forwarding" }, 333 { 112, "get-name" }, 334 { 113, "get-status" }, 335 { 114, "sig-restore" }, 336 { 115, "list-partitions" }, 337 { 116, "list-volumes" }, 338 { 117, "set-id-types" }, 339 { 118, "monitor" }, 340 { 119, "partition-info" }, 341 { 120, "reclone" }, 342 { 121, "list-one-volume" }, 343 { 122, "nuke" }, 344 { 123, "set-date" }, 345 { 124, "x-list-volumes" }, 346 { 125, "x-list-one-volume" }, 347 { 126, "set-info" }, 348 { 127, "x-list-partitions" }, 349 { 128, "forward-multiple" }, 350 { 65536, "convert-ro" }, 351 { 65537, "get-size" }, 352 { 65538, "dump-v2" }, 353 { 0, NULL }, 354 }; 355 356 static const struct tok bos_req[] = { 357 { 80, "create-bnode" }, 358 { 81, "delete-bnode" }, 359 { 82, "set-status" }, 360 { 83, "get-status" }, 361 { 84, "enumerate-instance" }, 362 { 85, "get-instance-info" }, 363 { 86, "get-instance-parm" }, 364 { 87, "add-superuser" }, 365 { 88, "delete-superuser" }, 366 { 89, "list-superusers" }, 367 { 90, "list-keys" }, 368 { 91, "add-key" }, 369 { 92, "delete-key" }, 370 { 93, "set-cell-name" }, 371 { 94, "get-cell-name" }, 372 { 95, "get-cell-host" }, 373 { 96, "add-cell-host" }, 374 { 97, "delete-cell-host" }, 375 { 98, "set-t-status" }, 376 { 99, "shutdown-all" }, 377 { 100, "restart-all" }, 378 { 101, "startup-all" }, 379 { 102, "set-noauth-flag" }, 380 { 103, "re-bozo" }, 381 { 104, "restart" }, 382 { 105, "start-bozo-install" }, 383 { 106, "uninstall" }, 384 { 107, "get-dates" }, 385 { 108, "exec" }, 386 { 109, "prune" }, 387 { 110, "set-restart-time" }, 388 { 111, "get-restart-time" }, 389 { 112, "start-bozo-log" }, 390 { 113, "wait-all" }, 391 { 114, "get-instance-strings" }, 392 { 115, "get-restricted" }, 393 { 116, "set-restricted" }, 394 { 0, NULL }, 395 }; 396 397 static const struct tok ubik_req[] = { 398 { 10000, "vote-beacon" }, 399 { 10001, "vote-debug-old" }, 400 { 10002, "vote-sdebug-old" }, 401 { 10003, "vote-getsyncsite" }, 402 { 10004, "vote-debug" }, 403 { 10005, "vote-sdebug" }, 404 { 10006, "vote-xdebug" }, 405 { 10007, "vote-xsdebug" }, 406 { 20000, "disk-begin" }, 407 { 20001, "disk-commit" }, 408 { 20002, "disk-lock" }, 409 { 20003, "disk-write" }, 410 { 20004, "disk-getversion" }, 411 { 20005, "disk-getfile" }, 412 { 20006, "disk-sendfile" }, 413 { 20007, "disk-abort" }, 414 { 20008, "disk-releaselocks" }, 415 { 20009, "disk-truncate" }, 416 { 20010, "disk-probe" }, 417 { 20011, "disk-writev" }, 418 { 20012, "disk-interfaceaddr" }, 419 { 20013, "disk-setversion" }, 420 { 0, NULL }, 421 }; 422 423 #define VOTE_LOW 10000 424 #define VOTE_HIGH 10007 425 #define DISK_LOW 20000 426 #define DISK_HIGH 20013 427 428 static const struct tok cb_types[] = { 429 { 1, "exclusive" }, 430 { 2, "shared" }, 431 { 3, "dropped" }, 432 { 0, NULL }, 433 }; 434 435 static const struct tok ubik_lock_types[] = { 436 { 1, "read" }, 437 { 2, "write" }, 438 { 3, "wait" }, 439 { 0, NULL }, 440 }; 441 442 static const char *voltype[] = { "read-write", "read-only", "backup" }; 443 444 static const struct tok afs_fs_errors[] = { 445 { 101, "salvage volume" }, 446 { 102, "no such vnode" }, 447 { 103, "no such volume" }, 448 { 104, "volume exist" }, 449 { 105, "no service" }, 450 { 106, "volume offline" }, 451 { 107, "voline online" }, 452 { 108, "diskfull" }, 453 { 109, "diskquota exceeded" }, 454 { 110, "volume busy" }, 455 { 111, "volume moved" }, 456 { 112, "AFS IO error" }, 457 { 0xffffff9c, "restarting fileserver" }, /* -100, sic! */ 458 { 0, NULL } 459 }; 460 461 /* 462 * Reasons for acknowledging a packet 463 */ 464 465 static const struct tok rx_ack_reasons[] = { 466 { 1, "ack requested" }, 467 { 2, "duplicate packet" }, 468 { 3, "out of sequence" }, 469 { 4, "exceeds window" }, 470 { 5, "no buffer space" }, 471 { 6, "ping" }, 472 { 7, "ping response" }, 473 { 8, "delay" }, 474 { 9, "idle" }, 475 { 0, NULL }, 476 }; 477 478 /* 479 * Cache entries we keep around so we can figure out the RX opcode 480 * numbers for replies. This allows us to make sense of RX reply packets. 481 */ 482 483 struct rx_cache_entry { 484 uint32_t callnum; /* Call number (net order) */ 485 struct in_addr client; /* client IP address (net order) */ 486 struct in_addr server; /* server IP address (net order) */ 487 int dport; /* server port (host order) */ 488 u_short serviceId; /* Service identifier (net order) */ 489 uint32_t opcode; /* RX opcode (host order) */ 490 }; 491 492 #define RX_CACHE_SIZE 64 493 494 static struct rx_cache_entry rx_cache[RX_CACHE_SIZE]; 495 496 static int rx_cache_next = 0; 497 static int rx_cache_hint = 0; 498 static void rx_cache_insert(netdissect_options *, const u_char *, const struct ip *, int); 499 static int rx_cache_find(const struct rx_header *, const struct ip *, 500 int, int32_t *); 501 502 static void fs_print(netdissect_options *, const u_char *, int); 503 static void fs_reply_print(netdissect_options *, const u_char *, int, int32_t); 504 static void acl_print(netdissect_options *, u_char *, int, u_char *); 505 static void cb_print(netdissect_options *, const u_char *, int); 506 static void cb_reply_print(netdissect_options *, const u_char *, int, int32_t); 507 static void prot_print(netdissect_options *, const u_char *, int); 508 static void prot_reply_print(netdissect_options *, const u_char *, int, int32_t); 509 static void vldb_print(netdissect_options *, const u_char *, int); 510 static void vldb_reply_print(netdissect_options *, const u_char *, int, int32_t); 511 static void kauth_print(netdissect_options *, const u_char *, int); 512 static void kauth_reply_print(netdissect_options *, const u_char *, int, int32_t); 513 static void vol_print(netdissect_options *, const u_char *, int); 514 static void vol_reply_print(netdissect_options *, const u_char *, int, int32_t); 515 static void bos_print(netdissect_options *, const u_char *, int); 516 static void bos_reply_print(netdissect_options *, const u_char *, int, int32_t); 517 static void ubik_print(netdissect_options *, const u_char *); 518 static void ubik_reply_print(netdissect_options *, const u_char *, int, int32_t); 519 520 static void rx_ack_print(netdissect_options *, const u_char *, int); 521 522 static int is_ubik(uint32_t); 523 524 /* 525 * Handle the rx-level packet. See if we know what port it's going to so 526 * we can peek at the afs call inside 527 */ 528 529 void 530 rx_print(netdissect_options *ndo, 531 register const u_char *bp, int length, int sport, int dport, 532 const u_char *bp2) 533 { 534 register const struct rx_header *rxh; 535 int i; 536 int32_t opcode; 537 538 if (ndo->ndo_snapend - bp < (int)sizeof (struct rx_header)) { 539 ND_PRINT((ndo, " [|rx] (%d)", length)); 540 return; 541 } 542 543 rxh = (const struct rx_header *) bp; 544 545 ND_PRINT((ndo, " rx %s", tok2str(rx_types, "type %d", rxh->type))); 546 547 if (ndo->ndo_vflag) { 548 int firstflag = 0; 549 550 if (ndo->ndo_vflag > 1) 551 ND_PRINT((ndo, " cid %08x call# %d", 552 (int) EXTRACT_32BITS(&rxh->cid), 553 (int) EXTRACT_32BITS(&rxh->callNumber))); 554 555 ND_PRINT((ndo, " seq %d ser %d", 556 (int) EXTRACT_32BITS(&rxh->seq), 557 (int) EXTRACT_32BITS(&rxh->serial))); 558 559 if (ndo->ndo_vflag > 2) 560 ND_PRINT((ndo, " secindex %d serviceid %hu", 561 (int) rxh->securityIndex, 562 EXTRACT_16BITS(&rxh->serviceId))); 563 564 if (ndo->ndo_vflag > 1) 565 for (i = 0; i < NUM_RX_FLAGS; i++) { 566 if (rxh->flags & rx_flags[i].flag && 567 (!rx_flags[i].packetType || 568 rxh->type == rx_flags[i].packetType)) { 569 if (!firstflag) { 570 firstflag = 1; 571 ND_PRINT((ndo, " ")); 572 } else { 573 ND_PRINT((ndo, ",")); 574 } 575 ND_PRINT((ndo, "<%s>", rx_flags[i].s)); 576 } 577 } 578 } 579 580 /* 581 * Try to handle AFS calls that we know about. Check the destination 582 * port and make sure it's a data packet. Also, make sure the 583 * seq number is 1 (because otherwise it's a continuation packet, 584 * and we can't interpret that). Also, seems that reply packets 585 * do not have the client-init flag set, so we check for that 586 * as well. 587 */ 588 589 if (rxh->type == RX_PACKET_TYPE_DATA && 590 EXTRACT_32BITS(&rxh->seq) == 1 && 591 rxh->flags & RX_CLIENT_INITIATED) { 592 593 /* 594 * Insert this call into the call cache table, so we 595 * have a chance to print out replies 596 */ 597 598 rx_cache_insert(ndo, bp, (const struct ip *) bp2, dport); 599 600 switch (dport) { 601 case FS_RX_PORT: /* AFS file service */ 602 fs_print(ndo, bp, length); 603 break; 604 case CB_RX_PORT: /* AFS callback service */ 605 cb_print(ndo, bp, length); 606 break; 607 case PROT_RX_PORT: /* AFS protection service */ 608 prot_print(ndo, bp, length); 609 break; 610 case VLDB_RX_PORT: /* AFS VLDB service */ 611 vldb_print(ndo, bp, length); 612 break; 613 case KAUTH_RX_PORT: /* AFS Kerberos auth service */ 614 kauth_print(ndo, bp, length); 615 break; 616 case VOL_RX_PORT: /* AFS Volume service */ 617 vol_print(ndo, bp, length); 618 break; 619 case BOS_RX_PORT: /* AFS BOS service */ 620 bos_print(ndo, bp, length); 621 break; 622 default: 623 ; 624 } 625 626 /* 627 * If it's a reply (client-init is _not_ set, but seq is one) 628 * then look it up in the cache. If we find it, call the reply 629 * printing functions Note that we handle abort packets here, 630 * because printing out the return code can be useful at times. 631 */ 632 633 } else if (((rxh->type == RX_PACKET_TYPE_DATA && 634 EXTRACT_32BITS(&rxh->seq) == 1) || 635 rxh->type == RX_PACKET_TYPE_ABORT) && 636 (rxh->flags & RX_CLIENT_INITIATED) == 0 && 637 rx_cache_find(rxh, (const struct ip *) bp2, 638 sport, &opcode)) { 639 640 switch (sport) { 641 case FS_RX_PORT: /* AFS file service */ 642 fs_reply_print(ndo, bp, length, opcode); 643 break; 644 case CB_RX_PORT: /* AFS callback service */ 645 cb_reply_print(ndo, bp, length, opcode); 646 break; 647 case PROT_RX_PORT: /* AFS PT service */ 648 prot_reply_print(ndo, bp, length, opcode); 649 break; 650 case VLDB_RX_PORT: /* AFS VLDB service */ 651 vldb_reply_print(ndo, bp, length, opcode); 652 break; 653 case KAUTH_RX_PORT: /* AFS Kerberos auth service */ 654 kauth_reply_print(ndo, bp, length, opcode); 655 break; 656 case VOL_RX_PORT: /* AFS Volume service */ 657 vol_reply_print(ndo, bp, length, opcode); 658 break; 659 case BOS_RX_PORT: /* AFS BOS service */ 660 bos_reply_print(ndo, bp, length, opcode); 661 break; 662 default: 663 ; 664 } 665 666 /* 667 * If it's an RX ack packet, then use the appropriate ack decoding 668 * function (there isn't any service-specific information in the 669 * ack packet, so we can use one for all AFS services) 670 */ 671 672 } else if (rxh->type == RX_PACKET_TYPE_ACK) 673 rx_ack_print(ndo, bp, length); 674 675 676 ND_PRINT((ndo, " (%d)", length)); 677 } 678 679 /* 680 * Insert an entry into the cache. Taken from print-nfs.c 681 */ 682 683 static void 684 rx_cache_insert(netdissect_options *ndo, 685 const u_char *bp, const struct ip *ip, int dport) 686 { 687 struct rx_cache_entry *rxent; 688 const struct rx_header *rxh = (const struct rx_header *) bp; 689 690 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) 691 return; 692 693 rxent = &rx_cache[rx_cache_next]; 694 695 if (++rx_cache_next >= RX_CACHE_SIZE) 696 rx_cache_next = 0; 697 698 rxent->callnum = rxh->callNumber; 699 UNALIGNED_MEMCPY(&rxent->client, &ip->ip_src, sizeof(uint32_t)); 700 UNALIGNED_MEMCPY(&rxent->server, &ip->ip_dst, sizeof(uint32_t)); 701 rxent->dport = dport; 702 rxent->serviceId = rxh->serviceId; 703 rxent->opcode = EXTRACT_32BITS(bp + sizeof(struct rx_header)); 704 } 705 706 /* 707 * Lookup an entry in the cache. Also taken from print-nfs.c 708 * 709 * Note that because this is a reply, we're looking at the _source_ 710 * port. 711 */ 712 713 static int 714 rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport, 715 int32_t *opcode) 716 { 717 int i; 718 struct rx_cache_entry *rxent; 719 uint32_t clip; 720 uint32_t sip; 721 722 UNALIGNED_MEMCPY(&clip, &ip->ip_dst, sizeof(uint32_t)); 723 UNALIGNED_MEMCPY(&sip, &ip->ip_src, sizeof(uint32_t)); 724 725 /* Start the search where we last left off */ 726 727 i = rx_cache_hint; 728 do { 729 rxent = &rx_cache[i]; 730 if (rxent->callnum == rxh->callNumber && 731 rxent->client.s_addr == clip && 732 rxent->server.s_addr == sip && 733 rxent->serviceId == rxh->serviceId && 734 rxent->dport == sport) { 735 736 /* We got a match! */ 737 738 rx_cache_hint = i; 739 *opcode = rxent->opcode; 740 return(1); 741 } 742 if (++i >= RX_CACHE_SIZE) 743 i = 0; 744 } while (i != rx_cache_hint); 745 746 /* Our search failed */ 747 return(0); 748 } 749 750 /* 751 * These extrememly grody macros handle the printing of various AFS stuff. 752 */ 753 754 #define FIDOUT() { unsigned long n1, n2, n3; \ 755 ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \ 756 n1 = EXTRACT_32BITS(bp); \ 757 bp += sizeof(int32_t); \ 758 n2 = EXTRACT_32BITS(bp); \ 759 bp += sizeof(int32_t); \ 760 n3 = EXTRACT_32BITS(bp); \ 761 bp += sizeof(int32_t); \ 762 ND_PRINT((ndo, " fid %d/%d/%d", (int) n1, (int) n2, (int) n3)); \ 763 } 764 765 #define STROUT(MAX) { unsigned int _i; \ 766 ND_TCHECK2(bp[0], sizeof(int32_t)); \ 767 _i = EXTRACT_32BITS(bp); \ 768 if (_i > (MAX)) \ 769 goto trunc; \ 770 bp += sizeof(int32_t); \ 771 ND_PRINT((ndo, " \"")); \ 772 if (fn_printn(ndo, bp, _i, ndo->ndo_snapend)) \ 773 goto trunc; \ 774 ND_PRINT((ndo, "\"")); \ 775 bp += ((_i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \ 776 } 777 778 #define INTOUT() { int _i; \ 779 ND_TCHECK2(bp[0], sizeof(int32_t)); \ 780 _i = (int) EXTRACT_32BITS(bp); \ 781 bp += sizeof(int32_t); \ 782 ND_PRINT((ndo, " %d", _i)); \ 783 } 784 785 #define UINTOUT() { unsigned long _i; \ 786 ND_TCHECK2(bp[0], sizeof(int32_t)); \ 787 _i = EXTRACT_32BITS(bp); \ 788 bp += sizeof(int32_t); \ 789 ND_PRINT((ndo, " %lu", _i)); \ 790 } 791 792 #define UINT64OUT() { uint64_t _i; \ 793 ND_TCHECK2(bp[0], sizeof(uint64_t)); \ 794 _i = EXTRACT_64BITS(bp); \ 795 bp += sizeof(uint64_t); \ 796 ND_PRINT((ndo, " %" PRIu64, _i)); \ 797 } 798 799 #define DATEOUT() { time_t _t; struct tm *tm; char str[256]; \ 800 ND_TCHECK2(bp[0], sizeof(int32_t)); \ 801 _t = (time_t) EXTRACT_32BITS(bp); \ 802 bp += sizeof(int32_t); \ 803 tm = localtime(&_t); \ 804 strftime(str, 256, "%Y/%m/%d %H:%M:%S", tm); \ 805 ND_PRINT((ndo, " %s", str)); \ 806 } 807 808 #define STOREATTROUT() { unsigned long mask, _i; \ 809 ND_TCHECK2(bp[0], (sizeof(int32_t)*6)); \ 810 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ 811 if (mask) ND_PRINT((ndo, " StoreStatus")); \ 812 if (mask & 1) { ND_PRINT((ndo, " date")); DATEOUT(); } \ 813 else bp += sizeof(int32_t); \ 814 _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ 815 if (mask & 2) ND_PRINT((ndo, " owner %lu", _i)); \ 816 _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ 817 if (mask & 4) ND_PRINT((ndo, " group %lu", _i)); \ 818 _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ 819 if (mask & 8) ND_PRINT((ndo, " mode %lo", _i & 07777)); \ 820 _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ 821 if (mask & 16) ND_PRINT((ndo, " segsize %lu", _i)); \ 822 /* undocumented in 3.3 docu */ \ 823 if (mask & 1024) ND_PRINT((ndo, " fsync")); \ 824 } 825 826 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \ 827 ND_TCHECK2(bp[0], sizeof(int32_t) * 2); \ 828 epoch = EXTRACT_32BITS(bp); \ 829 bp += sizeof(int32_t); \ 830 counter = EXTRACT_32BITS(bp); \ 831 bp += sizeof(int32_t); \ 832 ND_PRINT((ndo, " %d.%d", epoch, counter)); \ 833 } 834 835 #define AFSUUIDOUT() {uint32_t temp; int _i; \ 836 ND_TCHECK2(bp[0], 11*sizeof(uint32_t)); \ 837 temp = EXTRACT_32BITS(bp); \ 838 bp += sizeof(uint32_t); \ 839 ND_PRINT((ndo, " %08x", temp)); \ 840 temp = EXTRACT_32BITS(bp); \ 841 bp += sizeof(uint32_t); \ 842 ND_PRINT((ndo, "%04x", temp)); \ 843 temp = EXTRACT_32BITS(bp); \ 844 bp += sizeof(uint32_t); \ 845 ND_PRINT((ndo, "%04x", temp)); \ 846 for (_i = 0; _i < 8; _i++) { \ 847 temp = EXTRACT_32BITS(bp); \ 848 bp += sizeof(uint32_t); \ 849 ND_PRINT((ndo, "%02x", (unsigned char) temp)); \ 850 } \ 851 } 852 853 /* 854 * This is the sickest one of all 855 */ 856 857 #define VECOUT(MAX) { u_char *sp; \ 858 u_char s[AFSNAMEMAX]; \ 859 int k; \ 860 if ((MAX) + 1 > sizeof(s)) \ 861 goto trunc; \ 862 ND_TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \ 863 sp = s; \ 864 for (k = 0; k < (MAX); k++) { \ 865 *sp++ = (u_char) EXTRACT_32BITS(bp); \ 866 bp += sizeof(int32_t); \ 867 } \ 868 s[(MAX)] = '\0'; \ 869 ND_PRINT((ndo, " \"")); \ 870 fn_print(ndo, s, NULL); \ 871 ND_PRINT((ndo, "\"")); \ 872 } 873 874 #define DESTSERVEROUT() { unsigned long n1, n2, n3; \ 875 ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \ 876 n1 = EXTRACT_32BITS(bp); \ 877 bp += sizeof(int32_t); \ 878 n2 = EXTRACT_32BITS(bp); \ 879 bp += sizeof(int32_t); \ 880 n3 = EXTRACT_32BITS(bp); \ 881 bp += sizeof(int32_t); \ 882 ND_PRINT((ndo, " server %d:%d:%d", (int) n1, (int) n2, (int) n3)); \ 883 } 884 885 /* 886 * Handle calls to the AFS file service (fs) 887 */ 888 889 static void 890 fs_print(netdissect_options *ndo, 891 register const u_char *bp, int length) 892 { 893 int fs_op; 894 unsigned long i; 895 896 if (length <= (int)sizeof(struct rx_header)) 897 return; 898 899 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { 900 goto trunc; 901 } 902 903 /* 904 * Print out the afs call we're invoking. The table used here was 905 * gleaned from fsint/afsint.xg 906 */ 907 908 fs_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); 909 910 ND_PRINT((ndo, " fs call %s", tok2str(fs_req, "op#%d", fs_op))); 911 912 /* 913 * Print out arguments to some of the AFS calls. This stuff is 914 * all from afsint.xg 915 */ 916 917 bp += sizeof(struct rx_header) + 4; 918 919 /* 920 * Sigh. This is gross. Ritchie forgive me. 921 */ 922 923 switch (fs_op) { 924 case 130: /* Fetch data */ 925 FIDOUT(); 926 ND_PRINT((ndo, " offset")); 927 UINTOUT(); 928 ND_PRINT((ndo, " length")); 929 UINTOUT(); 930 break; 931 case 131: /* Fetch ACL */ 932 case 132: /* Fetch Status */ 933 case 143: /* Old set lock */ 934 case 144: /* Old extend lock */ 935 case 145: /* Old release lock */ 936 case 156: /* Set lock */ 937 case 157: /* Extend lock */ 938 case 158: /* Release lock */ 939 FIDOUT(); 940 break; 941 case 135: /* Store status */ 942 FIDOUT(); 943 STOREATTROUT(); 944 break; 945 case 133: /* Store data */ 946 FIDOUT(); 947 STOREATTROUT(); 948 ND_PRINT((ndo, " offset")); 949 UINTOUT(); 950 ND_PRINT((ndo, " length")); 951 UINTOUT(); 952 ND_PRINT((ndo, " flen")); 953 UINTOUT(); 954 break; 955 case 134: /* Store ACL */ 956 { 957 char a[AFSOPAQUEMAX+1]; 958 FIDOUT(); 959 ND_TCHECK2(bp[0], 4); 960 i = EXTRACT_32BITS(bp); 961 bp += sizeof(int32_t); 962 ND_TCHECK2(bp[0], i); 963 i = min(AFSOPAQUEMAX, i); 964 strncpy(a, (const char *) bp, i); 965 a[i] = '\0'; 966 acl_print(ndo, (u_char *) a, sizeof(a), (u_char *) a + i); 967 break; 968 } 969 case 137: /* Create file */ 970 case 141: /* MakeDir */ 971 FIDOUT(); 972 STROUT(AFSNAMEMAX); 973 STOREATTROUT(); 974 break; 975 case 136: /* Remove file */ 976 case 142: /* Remove directory */ 977 FIDOUT(); 978 STROUT(AFSNAMEMAX); 979 break; 980 case 138: /* Rename file */ 981 ND_PRINT((ndo, " old")); 982 FIDOUT(); 983 STROUT(AFSNAMEMAX); 984 ND_PRINT((ndo, " new")); 985 FIDOUT(); 986 STROUT(AFSNAMEMAX); 987 break; 988 case 139: /* Symlink */ 989 FIDOUT(); 990 STROUT(AFSNAMEMAX); 991 ND_PRINT((ndo, " link to")); 992 STROUT(AFSNAMEMAX); 993 break; 994 case 140: /* Link */ 995 FIDOUT(); 996 STROUT(AFSNAMEMAX); 997 ND_PRINT((ndo, " link to")); 998 FIDOUT(); 999 break; 1000 case 148: /* Get volume info */ 1001 STROUT(AFSNAMEMAX); 1002 break; 1003 case 149: /* Get volume stats */ 1004 case 150: /* Set volume stats */ 1005 ND_PRINT((ndo, " volid")); 1006 UINTOUT(); 1007 break; 1008 case 154: /* New get volume info */ 1009 ND_PRINT((ndo, " volname")); 1010 STROUT(AFSNAMEMAX); 1011 break; 1012 case 155: /* Bulk stat */ 1013 case 65536: /* Inline bulk stat */ 1014 { 1015 unsigned long j; 1016 ND_TCHECK2(bp[0], 4); 1017 j = EXTRACT_32BITS(bp); 1018 bp += sizeof(int32_t); 1019 1020 for (i = 0; i < j; i++) { 1021 FIDOUT(); 1022 if (i != j - 1) 1023 ND_PRINT((ndo, ",")); 1024 } 1025 if (j == 0) 1026 ND_PRINT((ndo, " <none!>")); 1027 } 1028 case 65537: /* Fetch data 64 */ 1029 FIDOUT(); 1030 ND_PRINT((ndo, " offset")); 1031 UINT64OUT(); 1032 ND_PRINT((ndo, " length")); 1033 UINT64OUT(); 1034 break; 1035 case 65538: /* Store data 64 */ 1036 FIDOUT(); 1037 STOREATTROUT(); 1038 ND_PRINT((ndo, " offset")); 1039 UINT64OUT(); 1040 ND_PRINT((ndo, " length")); 1041 UINT64OUT(); 1042 ND_PRINT((ndo, " flen")); 1043 UINT64OUT(); 1044 break; 1045 case 65541: /* CallBack rx conn address */ 1046 ND_PRINT((ndo, " addr")); 1047 UINTOUT(); 1048 default: 1049 ; 1050 } 1051 1052 return; 1053 1054 trunc: 1055 ND_PRINT((ndo, " [|fs]")); 1056 } 1057 1058 /* 1059 * Handle replies to the AFS file service 1060 */ 1061 1062 static void 1063 fs_reply_print(netdissect_options *ndo, 1064 register const u_char *bp, int length, int32_t opcode) 1065 { 1066 unsigned long i; 1067 const struct rx_header *rxh; 1068 1069 if (length <= (int)sizeof(struct rx_header)) 1070 return; 1071 1072 rxh = (const struct rx_header *) bp; 1073 1074 /* 1075 * Print out the afs call we're invoking. The table used here was 1076 * gleaned from fsint/afsint.xg 1077 */ 1078 1079 ND_PRINT((ndo, " fs reply %s", tok2str(fs_req, "op#%d", opcode))); 1080 1081 bp += sizeof(struct rx_header); 1082 1083 /* 1084 * If it was a data packet, interpret the response 1085 */ 1086 1087 if (rxh->type == RX_PACKET_TYPE_DATA) { 1088 switch (opcode) { 1089 case 131: /* Fetch ACL */ 1090 { 1091 char a[AFSOPAQUEMAX+1]; 1092 ND_TCHECK2(bp[0], 4); 1093 i = EXTRACT_32BITS(bp); 1094 bp += sizeof(int32_t); 1095 ND_TCHECK2(bp[0], i); 1096 i = min(AFSOPAQUEMAX, i); 1097 strncpy(a, (const char *) bp, i); 1098 a[i] = '\0'; 1099 acl_print(ndo, (u_char *) a, sizeof(a), (u_char *) a + i); 1100 break; 1101 } 1102 case 137: /* Create file */ 1103 case 141: /* MakeDir */ 1104 ND_PRINT((ndo, " new")); 1105 FIDOUT(); 1106 break; 1107 case 151: /* Get root volume */ 1108 ND_PRINT((ndo, " root volume")); 1109 STROUT(AFSNAMEMAX); 1110 break; 1111 case 153: /* Get time */ 1112 DATEOUT(); 1113 break; 1114 default: 1115 ; 1116 } 1117 } else if (rxh->type == RX_PACKET_TYPE_ABORT) { 1118 /* 1119 * Otherwise, just print out the return code 1120 */ 1121 ND_TCHECK2(bp[0], sizeof(int32_t)); 1122 i = (int) EXTRACT_32BITS(bp); 1123 bp += sizeof(int32_t); 1124 1125 ND_PRINT((ndo, " error %s", tok2str(afs_fs_errors, "#%d", i))); 1126 } else { 1127 ND_PRINT((ndo, " strange fs reply of type %d", rxh->type)); 1128 } 1129 1130 return; 1131 1132 trunc: 1133 ND_PRINT((ndo, " [|fs]")); 1134 } 1135 1136 /* 1137 * Print out an AFS ACL string. An AFS ACL is a string that has the 1138 * following format: 1139 * 1140 * <positive> <negative> 1141 * <uid1> <aclbits1> 1142 * .... 1143 * 1144 * "positive" and "negative" are integers which contain the number of 1145 * positive and negative ACL's in the string. The uid/aclbits pair are 1146 * ASCII strings containing the UID/PTS record and and a ascii number 1147 * representing a logical OR of all the ACL permission bits 1148 */ 1149 1150 static void 1151 acl_print(netdissect_options *ndo, 1152 u_char *s, int maxsize, u_char *end) 1153 { 1154 int pos, neg, acl; 1155 int n, i; 1156 char *user; 1157 char fmt[1024]; 1158 1159 if ((user = (char *)malloc(maxsize)) == NULL) 1160 return; 1161 1162 if (sscanf((char *) s, "%d %d\n%n", &pos, &neg, &n) != 2) 1163 goto finish; 1164 1165 s += n; 1166 1167 if (s > end) 1168 goto finish; 1169 1170 /* 1171 * This wacky order preserves the order used by the "fs" command 1172 */ 1173 1174 #define ACLOUT(acl) \ 1175 ND_PRINT((ndo, "%s%s%s%s%s%s%s", \ 1176 acl & PRSFS_READ ? "r" : "", \ 1177 acl & PRSFS_LOOKUP ? "l" : "", \ 1178 acl & PRSFS_INSERT ? "i" : "", \ 1179 acl & PRSFS_DELETE ? "d" : "", \ 1180 acl & PRSFS_WRITE ? "w" : "", \ 1181 acl & PRSFS_LOCK ? "k" : "", \ 1182 acl & PRSFS_ADMINISTER ? "a" : "")); 1183 1184 for (i = 0; i < pos; i++) { 1185 snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1); 1186 if (sscanf((char *) s, fmt, user, &acl, &n) != 2) 1187 goto finish; 1188 s += n; 1189 ND_PRINT((ndo, " +{")); 1190 fn_print(ndo, (u_char *)user, NULL); 1191 ND_PRINT((ndo, " ")); 1192 ACLOUT(acl); 1193 ND_PRINT((ndo, "}")); 1194 if (s > end) 1195 goto finish; 1196 } 1197 1198 for (i = 0; i < neg; i++) { 1199 snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1); 1200 if (sscanf((char *) s, fmt, user, &acl, &n) != 2) 1201 goto finish; 1202 s += n; 1203 ND_PRINT((ndo, " -{")); 1204 fn_print(ndo, (u_char *)user, NULL); 1205 ND_PRINT((ndo, " ")); 1206 ACLOUT(acl); 1207 ND_PRINT((ndo, "}")); 1208 if (s > end) 1209 goto finish; 1210 } 1211 1212 finish: 1213 free(user); 1214 return; 1215 } 1216 1217 #undef ACLOUT 1218 1219 /* 1220 * Handle calls to the AFS callback service 1221 */ 1222 1223 static void 1224 cb_print(netdissect_options *ndo, 1225 register const u_char *bp, int length) 1226 { 1227 int cb_op; 1228 unsigned long i; 1229 1230 if (length <= (int)sizeof(struct rx_header)) 1231 return; 1232 1233 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { 1234 goto trunc; 1235 } 1236 1237 /* 1238 * Print out the afs call we're invoking. The table used here was 1239 * gleaned from fsint/afscbint.xg 1240 */ 1241 1242 cb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); 1243 1244 ND_PRINT((ndo, " cb call %s", tok2str(cb_req, "op#%d", cb_op))); 1245 1246 bp += sizeof(struct rx_header) + 4; 1247 1248 /* 1249 * Print out the afs call we're invoking. The table used here was 1250 * gleaned from fsint/afscbint.xg 1251 */ 1252 1253 switch (cb_op) { 1254 case 204: /* Callback */ 1255 { 1256 unsigned long j, t; 1257 ND_TCHECK2(bp[0], 4); 1258 j = EXTRACT_32BITS(bp); 1259 bp += sizeof(int32_t); 1260 1261 for (i = 0; i < j; i++) { 1262 FIDOUT(); 1263 if (i != j - 1) 1264 ND_PRINT((ndo, ",")); 1265 } 1266 1267 if (j == 0) 1268 ND_PRINT((ndo, " <none!>")); 1269 1270 j = EXTRACT_32BITS(bp); 1271 bp += sizeof(int32_t); 1272 1273 if (j != 0) 1274 ND_PRINT((ndo, ";")); 1275 1276 for (i = 0; i < j; i++) { 1277 ND_PRINT((ndo, " ver")); 1278 INTOUT(); 1279 ND_PRINT((ndo, " expires")); 1280 DATEOUT(); 1281 ND_TCHECK2(bp[0], 4); 1282 t = EXTRACT_32BITS(bp); 1283 bp += sizeof(int32_t); 1284 tok2str(cb_types, "type %d", t); 1285 } 1286 } 1287 case 214: { 1288 ND_PRINT((ndo, " afsuuid")); 1289 AFSUUIDOUT(); 1290 break; 1291 } 1292 default: 1293 ; 1294 } 1295 1296 return; 1297 1298 trunc: 1299 ND_PRINT((ndo, " [|cb]")); 1300 } 1301 1302 /* 1303 * Handle replies to the AFS Callback Service 1304 */ 1305 1306 static void 1307 cb_reply_print(netdissect_options *ndo, 1308 register const u_char *bp, int length, int32_t opcode) 1309 { 1310 const struct rx_header *rxh; 1311 1312 if (length <= (int)sizeof(struct rx_header)) 1313 return; 1314 1315 rxh = (const struct rx_header *) bp; 1316 1317 /* 1318 * Print out the afs call we're invoking. The table used here was 1319 * gleaned from fsint/afscbint.xg 1320 */ 1321 1322 ND_PRINT((ndo, " cb reply %s", tok2str(cb_req, "op#%d", opcode))); 1323 1324 bp += sizeof(struct rx_header); 1325 1326 /* 1327 * If it was a data packet, interpret the response. 1328 */ 1329 1330 if (rxh->type == RX_PACKET_TYPE_DATA) 1331 switch (opcode) { 1332 case 213: /* InitCallBackState3 */ 1333 AFSUUIDOUT(); 1334 break; 1335 default: 1336 ; 1337 } 1338 else { 1339 /* 1340 * Otherwise, just print out the return code 1341 */ 1342 ND_PRINT((ndo, " errcode")); 1343 INTOUT(); 1344 } 1345 1346 return; 1347 1348 trunc: 1349 ND_PRINT((ndo, " [|cb]")); 1350 } 1351 1352 /* 1353 * Handle calls to the AFS protection database server 1354 */ 1355 1356 static void 1357 prot_print(netdissect_options *ndo, 1358 register const u_char *bp, int length) 1359 { 1360 unsigned long i; 1361 int pt_op; 1362 1363 if (length <= (int)sizeof(struct rx_header)) 1364 return; 1365 1366 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { 1367 goto trunc; 1368 } 1369 1370 /* 1371 * Print out the afs call we're invoking. The table used here was 1372 * gleaned from ptserver/ptint.xg 1373 */ 1374 1375 pt_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); 1376 1377 ND_PRINT((ndo, " pt")); 1378 1379 if (is_ubik(pt_op)) { 1380 ubik_print(ndo, bp); 1381 return; 1382 } 1383 1384 ND_PRINT((ndo, " call %s", tok2str(pt_req, "op#%d", pt_op))); 1385 1386 /* 1387 * Decode some of the arguments to the PT calls 1388 */ 1389 1390 bp += sizeof(struct rx_header) + 4; 1391 1392 switch (pt_op) { 1393 case 500: /* I New User */ 1394 STROUT(PRNAMEMAX); 1395 ND_PRINT((ndo, " id")); 1396 INTOUT(); 1397 ND_PRINT((ndo, " oldid")); 1398 INTOUT(); 1399 break; 1400 case 501: /* Where is it */ 1401 case 506: /* Delete */ 1402 case 508: /* Get CPS */ 1403 case 512: /* List entry */ 1404 case 514: /* List elements */ 1405 case 517: /* List owned */ 1406 case 518: /* Get CPS2 */ 1407 case 519: /* Get host CPS */ 1408 case 530: /* List super groups */ 1409 ND_PRINT((ndo, " id")); 1410 INTOUT(); 1411 break; 1412 case 502: /* Dump entry */ 1413 ND_PRINT((ndo, " pos")); 1414 INTOUT(); 1415 break; 1416 case 503: /* Add to group */ 1417 case 507: /* Remove from group */ 1418 case 515: /* Is a member of? */ 1419 ND_PRINT((ndo, " uid")); 1420 INTOUT(); 1421 ND_PRINT((ndo, " gid")); 1422 INTOUT(); 1423 break; 1424 case 504: /* Name to ID */ 1425 { 1426 unsigned long j; 1427 ND_TCHECK2(bp[0], 4); 1428 j = EXTRACT_32BITS(bp); 1429 bp += sizeof(int32_t); 1430 1431 /* 1432 * Who designed this chicken-shit protocol? 1433 * 1434 * Each character is stored as a 32-bit 1435 * integer! 1436 */ 1437 1438 for (i = 0; i < j; i++) { 1439 VECOUT(PRNAMEMAX); 1440 } 1441 if (j == 0) 1442 ND_PRINT((ndo, " <none!>")); 1443 } 1444 break; 1445 case 505: /* Id to name */ 1446 { 1447 unsigned long j; 1448 ND_PRINT((ndo, " ids:")); 1449 ND_TCHECK2(bp[0], 4); 1450 i = EXTRACT_32BITS(bp); 1451 bp += sizeof(int32_t); 1452 for (j = 0; j < i; j++) 1453 INTOUT(); 1454 if (j == 0) 1455 ND_PRINT((ndo, " <none!>")); 1456 } 1457 break; 1458 case 509: /* New entry */ 1459 STROUT(PRNAMEMAX); 1460 ND_PRINT((ndo, " flag")); 1461 INTOUT(); 1462 ND_PRINT((ndo, " oid")); 1463 INTOUT(); 1464 break; 1465 case 511: /* Set max */ 1466 ND_PRINT((ndo, " id")); 1467 INTOUT(); 1468 ND_PRINT((ndo, " gflag")); 1469 INTOUT(); 1470 break; 1471 case 513: /* Change entry */ 1472 ND_PRINT((ndo, " id")); 1473 INTOUT(); 1474 STROUT(PRNAMEMAX); 1475 ND_PRINT((ndo, " oldid")); 1476 INTOUT(); 1477 ND_PRINT((ndo, " newid")); 1478 INTOUT(); 1479 break; 1480 case 520: /* Update entry */ 1481 ND_PRINT((ndo, " id")); 1482 INTOUT(); 1483 STROUT(PRNAMEMAX); 1484 break; 1485 default: 1486 ; 1487 } 1488 1489 1490 return; 1491 1492 trunc: 1493 ND_PRINT((ndo, " [|pt]")); 1494 } 1495 1496 /* 1497 * Handle replies to the AFS protection service 1498 */ 1499 1500 static void 1501 prot_reply_print(netdissect_options *ndo, 1502 register const u_char *bp, int length, int32_t opcode) 1503 { 1504 const struct rx_header *rxh; 1505 unsigned long i; 1506 1507 if (length < (int)sizeof(struct rx_header)) 1508 return; 1509 1510 rxh = (const struct rx_header *) bp; 1511 1512 /* 1513 * Print out the afs call we're invoking. The table used here was 1514 * gleaned from ptserver/ptint.xg. Check to see if it's a 1515 * Ubik call, however. 1516 */ 1517 1518 ND_PRINT((ndo, " pt")); 1519 1520 if (is_ubik(opcode)) { 1521 ubik_reply_print(ndo, bp, length, opcode); 1522 return; 1523 } 1524 1525 ND_PRINT((ndo, " reply %s", tok2str(pt_req, "op#%d", opcode))); 1526 1527 bp += sizeof(struct rx_header); 1528 1529 /* 1530 * If it was a data packet, interpret the response 1531 */ 1532 1533 if (rxh->type == RX_PACKET_TYPE_DATA) 1534 switch (opcode) { 1535 case 504: /* Name to ID */ 1536 { 1537 unsigned long j; 1538 ND_PRINT((ndo, " ids:")); 1539 ND_TCHECK2(bp[0], 4); 1540 i = EXTRACT_32BITS(bp); 1541 bp += sizeof(int32_t); 1542 for (j = 0; j < i; j++) 1543 INTOUT(); 1544 if (j == 0) 1545 ND_PRINT((ndo, " <none!>")); 1546 } 1547 break; 1548 case 505: /* ID to name */ 1549 { 1550 unsigned long j; 1551 ND_TCHECK2(bp[0], 4); 1552 j = EXTRACT_32BITS(bp); 1553 bp += sizeof(int32_t); 1554 1555 /* 1556 * Who designed this chicken-shit protocol? 1557 * 1558 * Each character is stored as a 32-bit 1559 * integer! 1560 */ 1561 1562 for (i = 0; i < j; i++) { 1563 VECOUT(PRNAMEMAX); 1564 } 1565 if (j == 0) 1566 ND_PRINT((ndo, " <none!>")); 1567 } 1568 break; 1569 case 508: /* Get CPS */ 1570 case 514: /* List elements */ 1571 case 517: /* List owned */ 1572 case 518: /* Get CPS2 */ 1573 case 519: /* Get host CPS */ 1574 { 1575 unsigned long j; 1576 ND_TCHECK2(bp[0], 4); 1577 j = EXTRACT_32BITS(bp); 1578 bp += sizeof(int32_t); 1579 for (i = 0; i < j; i++) { 1580 INTOUT(); 1581 } 1582 if (j == 0) 1583 ND_PRINT((ndo, " <none!>")); 1584 } 1585 break; 1586 case 510: /* List max */ 1587 ND_PRINT((ndo, " maxuid")); 1588 INTOUT(); 1589 ND_PRINT((ndo, " maxgid")); 1590 INTOUT(); 1591 break; 1592 default: 1593 ; 1594 } 1595 else { 1596 /* 1597 * Otherwise, just print out the return code 1598 */ 1599 ND_PRINT((ndo, " errcode")); 1600 INTOUT(); 1601 } 1602 1603 return; 1604 1605 trunc: 1606 ND_PRINT((ndo, " [|pt]")); 1607 } 1608 1609 /* 1610 * Handle calls to the AFS volume location database service 1611 */ 1612 1613 static void 1614 vldb_print(netdissect_options *ndo, 1615 register const u_char *bp, int length) 1616 { 1617 int vldb_op; 1618 unsigned long i; 1619 1620 if (length <= (int)sizeof(struct rx_header)) 1621 return; 1622 1623 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { 1624 goto trunc; 1625 } 1626 1627 /* 1628 * Print out the afs call we're invoking. The table used here was 1629 * gleaned from vlserver/vldbint.xg 1630 */ 1631 1632 vldb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); 1633 1634 ND_PRINT((ndo, " vldb")); 1635 1636 if (is_ubik(vldb_op)) { 1637 ubik_print(ndo, bp); 1638 return; 1639 } 1640 ND_PRINT((ndo, " call %s", tok2str(vldb_req, "op#%d", vldb_op))); 1641 1642 /* 1643 * Decode some of the arguments to the VLDB calls 1644 */ 1645 1646 bp += sizeof(struct rx_header) + 4; 1647 1648 switch (vldb_op) { 1649 case 501: /* Create new volume */ 1650 case 517: /* Create entry N */ 1651 VECOUT(VLNAMEMAX); 1652 break; 1653 case 502: /* Delete entry */ 1654 case 503: /* Get entry by ID */ 1655 case 507: /* Update entry */ 1656 case 508: /* Set lock */ 1657 case 509: /* Release lock */ 1658 case 518: /* Get entry by ID N */ 1659 ND_PRINT((ndo, " volid")); 1660 INTOUT(); 1661 ND_TCHECK2(bp[0], sizeof(int32_t)); 1662 i = EXTRACT_32BITS(bp); 1663 bp += sizeof(int32_t); 1664 if (i <= 2) 1665 ND_PRINT((ndo, " type %s", voltype[i])); 1666 break; 1667 case 504: /* Get entry by name */ 1668 case 519: /* Get entry by name N */ 1669 case 524: /* Update entry by name */ 1670 case 527: /* Get entry by name U */ 1671 STROUT(VLNAMEMAX); 1672 break; 1673 case 505: /* Get new vol id */ 1674 ND_PRINT((ndo, " bump")); 1675 INTOUT(); 1676 break; 1677 case 506: /* Replace entry */ 1678 case 520: /* Replace entry N */ 1679 ND_PRINT((ndo, " volid")); 1680 INTOUT(); 1681 ND_TCHECK2(bp[0], sizeof(int32_t)); 1682 i = EXTRACT_32BITS(bp); 1683 bp += sizeof(int32_t); 1684 if (i <= 2) 1685 ND_PRINT((ndo, " type %s", voltype[i])); 1686 VECOUT(VLNAMEMAX); 1687 break; 1688 case 510: /* List entry */ 1689 case 521: /* List entry N */ 1690 ND_PRINT((ndo, " index")); 1691 INTOUT(); 1692 break; 1693 default: 1694 ; 1695 } 1696 1697 return; 1698 1699 trunc: 1700 ND_PRINT((ndo, " [|vldb]")); 1701 } 1702 1703 /* 1704 * Handle replies to the AFS volume location database service 1705 */ 1706 1707 static void 1708 vldb_reply_print(netdissect_options *ndo, 1709 register const u_char *bp, int length, int32_t opcode) 1710 { 1711 const struct rx_header *rxh; 1712 unsigned long i; 1713 1714 if (length < (int)sizeof(struct rx_header)) 1715 return; 1716 1717 rxh = (const struct rx_header *) bp; 1718 1719 /* 1720 * Print out the afs call we're invoking. The table used here was 1721 * gleaned from vlserver/vldbint.xg. Check to see if it's a 1722 * Ubik call, however. 1723 */ 1724 1725 ND_PRINT((ndo, " vldb")); 1726 1727 if (is_ubik(opcode)) { 1728 ubik_reply_print(ndo, bp, length, opcode); 1729 return; 1730 } 1731 1732 ND_PRINT((ndo, " reply %s", tok2str(vldb_req, "op#%d", opcode))); 1733 1734 bp += sizeof(struct rx_header); 1735 1736 /* 1737 * If it was a data packet, interpret the response 1738 */ 1739 1740 if (rxh->type == RX_PACKET_TYPE_DATA) 1741 switch (opcode) { 1742 case 510: /* List entry */ 1743 ND_PRINT((ndo, " count")); 1744 INTOUT(); 1745 ND_PRINT((ndo, " nextindex")); 1746 INTOUT(); 1747 case 503: /* Get entry by id */ 1748 case 504: /* Get entry by name */ 1749 { unsigned long nservers, j; 1750 VECOUT(VLNAMEMAX); 1751 ND_TCHECK2(bp[0], sizeof(int32_t)); 1752 bp += sizeof(int32_t); 1753 ND_PRINT((ndo, " numservers")); 1754 ND_TCHECK2(bp[0], sizeof(int32_t)); 1755 nservers = EXTRACT_32BITS(bp); 1756 bp += sizeof(int32_t); 1757 ND_PRINT((ndo, " %lu", nservers)); 1758 ND_PRINT((ndo, " servers")); 1759 for (i = 0; i < 8; i++) { 1760 ND_TCHECK2(bp[0], sizeof(int32_t)); 1761 if (i < nservers) 1762 ND_PRINT((ndo, " %s", 1763 intoa(((const struct in_addr *) bp)->s_addr))); 1764 bp += sizeof(int32_t); 1765 } 1766 ND_PRINT((ndo, " partitions")); 1767 for (i = 0; i < 8; i++) { 1768 ND_TCHECK2(bp[0], sizeof(int32_t)); 1769 j = EXTRACT_32BITS(bp); 1770 if (i < nservers && j <= 26) 1771 ND_PRINT((ndo, " %c", 'a' + (int)j)); 1772 else if (i < nservers) 1773 ND_PRINT((ndo, " %lu", j)); 1774 bp += sizeof(int32_t); 1775 } 1776 ND_TCHECK2(bp[0], 8 * sizeof(int32_t)); 1777 bp += 8 * sizeof(int32_t); 1778 ND_PRINT((ndo, " rwvol")); 1779 UINTOUT(); 1780 ND_PRINT((ndo, " rovol")); 1781 UINTOUT(); 1782 ND_PRINT((ndo, " backup")); 1783 UINTOUT(); 1784 } 1785 break; 1786 case 505: /* Get new volume ID */ 1787 ND_PRINT((ndo, " newvol")); 1788 UINTOUT(); 1789 break; 1790 case 521: /* List entry */ 1791 case 529: /* List entry U */ 1792 ND_PRINT((ndo, " count")); 1793 INTOUT(); 1794 ND_PRINT((ndo, " nextindex")); 1795 INTOUT(); 1796 case 518: /* Get entry by ID N */ 1797 case 519: /* Get entry by name N */ 1798 { unsigned long nservers, j; 1799 VECOUT(VLNAMEMAX); 1800 ND_PRINT((ndo, " numservers")); 1801 ND_TCHECK2(bp[0], sizeof(int32_t)); 1802 nservers = EXTRACT_32BITS(bp); 1803 bp += sizeof(int32_t); 1804 ND_PRINT((ndo, " %lu", nservers)); 1805 ND_PRINT((ndo, " servers")); 1806 for (i = 0; i < 13; i++) { 1807 ND_TCHECK2(bp[0], sizeof(int32_t)); 1808 if (i < nservers) 1809 ND_PRINT((ndo, " %s", 1810 intoa(((const struct in_addr *) bp)->s_addr))); 1811 bp += sizeof(int32_t); 1812 } 1813 ND_PRINT((ndo, " partitions")); 1814 for (i = 0; i < 13; i++) { 1815 ND_TCHECK2(bp[0], sizeof(int32_t)); 1816 j = EXTRACT_32BITS(bp); 1817 if (i < nservers && j <= 26) 1818 ND_PRINT((ndo, " %c", 'a' + (int)j)); 1819 else if (i < nservers) 1820 ND_PRINT((ndo, " %lu", j)); 1821 bp += sizeof(int32_t); 1822 } 1823 ND_TCHECK2(bp[0], 13 * sizeof(int32_t)); 1824 bp += 13 * sizeof(int32_t); 1825 ND_PRINT((ndo, " rwvol")); 1826 UINTOUT(); 1827 ND_PRINT((ndo, " rovol")); 1828 UINTOUT(); 1829 ND_PRINT((ndo, " backup")); 1830 UINTOUT(); 1831 } 1832 break; 1833 case 526: /* Get entry by ID U */ 1834 case 527: /* Get entry by name U */ 1835 { unsigned long nservers, j; 1836 VECOUT(VLNAMEMAX); 1837 ND_PRINT((ndo, " numservers")); 1838 ND_TCHECK2(bp[0], sizeof(int32_t)); 1839 nservers = EXTRACT_32BITS(bp); 1840 bp += sizeof(int32_t); 1841 ND_PRINT((ndo, " %lu", nservers)); 1842 ND_PRINT((ndo, " servers")); 1843 for (i = 0; i < 13; i++) { 1844 if (i < nservers) { 1845 ND_PRINT((ndo, " afsuuid")); 1846 AFSUUIDOUT(); 1847 } else { 1848 ND_TCHECK2(bp[0], 44); 1849 bp += 44; 1850 } 1851 } 1852 ND_TCHECK2(bp[0], 4 * 13); 1853 bp += 4 * 13; 1854 ND_PRINT((ndo, " partitions")); 1855 for (i = 0; i < 13; i++) { 1856 ND_TCHECK2(bp[0], sizeof(int32_t)); 1857 j = EXTRACT_32BITS(bp); 1858 if (i < nservers && j <= 26) 1859 ND_PRINT((ndo, " %c", 'a' + (int)j)); 1860 else if (i < nservers) 1861 ND_PRINT((ndo, " %lu", j)); 1862 bp += sizeof(int32_t); 1863 } 1864 ND_TCHECK2(bp[0], 13 * sizeof(int32_t)); 1865 bp += 13 * sizeof(int32_t); 1866 ND_PRINT((ndo, " rwvol")); 1867 UINTOUT(); 1868 ND_PRINT((ndo, " rovol")); 1869 UINTOUT(); 1870 ND_PRINT((ndo, " backup")); 1871 UINTOUT(); 1872 } 1873 default: 1874 ; 1875 } 1876 1877 else { 1878 /* 1879 * Otherwise, just print out the return code 1880 */ 1881 ND_PRINT((ndo, " errcode")); 1882 INTOUT(); 1883 } 1884 1885 return; 1886 1887 trunc: 1888 ND_PRINT((ndo, " [|vldb]")); 1889 } 1890 1891 /* 1892 * Handle calls to the AFS Kerberos Authentication service 1893 */ 1894 1895 static void 1896 kauth_print(netdissect_options *ndo, 1897 register const u_char *bp, int length) 1898 { 1899 int kauth_op; 1900 1901 if (length <= (int)sizeof(struct rx_header)) 1902 return; 1903 1904 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { 1905 goto trunc; 1906 } 1907 1908 /* 1909 * Print out the afs call we're invoking. The table used here was 1910 * gleaned from kauth/kauth.rg 1911 */ 1912 1913 kauth_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); 1914 1915 ND_PRINT((ndo, " kauth")); 1916 1917 if (is_ubik(kauth_op)) { 1918 ubik_print(ndo, bp); 1919 return; 1920 } 1921 1922 1923 ND_PRINT((ndo, " call %s", tok2str(kauth_req, "op#%d", kauth_op))); 1924 1925 /* 1926 * Decode some of the arguments to the KA calls 1927 */ 1928 1929 bp += sizeof(struct rx_header) + 4; 1930 1931 switch (kauth_op) { 1932 case 1: /* Authenticate old */ 1933 case 21: /* Authenticate */ 1934 case 22: /* Authenticate-V2 */ 1935 case 2: /* Change PW */ 1936 case 5: /* Set fields */ 1937 case 6: /* Create user */ 1938 case 7: /* Delete user */ 1939 case 8: /* Get entry */ 1940 case 14: /* Unlock */ 1941 case 15: /* Lock status */ 1942 ND_PRINT((ndo, " principal")); 1943 STROUT(KANAMEMAX); 1944 STROUT(KANAMEMAX); 1945 break; 1946 case 3: /* GetTicket-old */ 1947 case 23: /* GetTicket */ 1948 { 1949 int i; 1950 ND_PRINT((ndo, " kvno")); 1951 INTOUT(); 1952 ND_PRINT((ndo, " domain")); 1953 STROUT(KANAMEMAX); 1954 ND_TCHECK2(bp[0], sizeof(int32_t)); 1955 i = (int) EXTRACT_32BITS(bp); 1956 bp += sizeof(int32_t); 1957 ND_TCHECK2(bp[0], i); 1958 bp += i; 1959 ND_PRINT((ndo, " principal")); 1960 STROUT(KANAMEMAX); 1961 STROUT(KANAMEMAX); 1962 break; 1963 } 1964 case 4: /* Set Password */ 1965 ND_PRINT((ndo, " principal")); 1966 STROUT(KANAMEMAX); 1967 STROUT(KANAMEMAX); 1968 ND_PRINT((ndo, " kvno")); 1969 INTOUT(); 1970 break; 1971 case 12: /* Get password */ 1972 ND_PRINT((ndo, " name")); 1973 STROUT(KANAMEMAX); 1974 break; 1975 default: 1976 ; 1977 } 1978 1979 return; 1980 1981 trunc: 1982 ND_PRINT((ndo, " [|kauth]")); 1983 } 1984 1985 /* 1986 * Handle replies to the AFS Kerberos Authentication Service 1987 */ 1988 1989 static void 1990 kauth_reply_print(netdissect_options *ndo, 1991 register const u_char *bp, int length, int32_t opcode) 1992 { 1993 const struct rx_header *rxh; 1994 1995 if (length <= (int)sizeof(struct rx_header)) 1996 return; 1997 1998 rxh = (const struct rx_header *) bp; 1999 2000 /* 2001 * Print out the afs call we're invoking. The table used here was 2002 * gleaned from kauth/kauth.rg 2003 */ 2004 2005 ND_PRINT((ndo, " kauth")); 2006 2007 if (is_ubik(opcode)) { 2008 ubik_reply_print(ndo, bp, length, opcode); 2009 return; 2010 } 2011 2012 ND_PRINT((ndo, " reply %s", tok2str(kauth_req, "op#%d", opcode))); 2013 2014 bp += sizeof(struct rx_header); 2015 2016 /* 2017 * If it was a data packet, interpret the response. 2018 */ 2019 2020 if (rxh->type == RX_PACKET_TYPE_DATA) 2021 /* Well, no, not really. Leave this for later */ 2022 ; 2023 else { 2024 /* 2025 * Otherwise, just print out the return code 2026 */ 2027 ND_PRINT((ndo, " errcode")); 2028 INTOUT(); 2029 } 2030 2031 return; 2032 2033 trunc: 2034 ND_PRINT((ndo, " [|kauth]")); 2035 } 2036 2037 /* 2038 * Handle calls to the AFS Volume location service 2039 */ 2040 2041 static void 2042 vol_print(netdissect_options *ndo, 2043 register const u_char *bp, int length) 2044 { 2045 int vol_op; 2046 2047 if (length <= (int)sizeof(struct rx_header)) 2048 return; 2049 2050 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { 2051 goto trunc; 2052 } 2053 2054 /* 2055 * Print out the afs call we're invoking. The table used here was 2056 * gleaned from volser/volint.xg 2057 */ 2058 2059 vol_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); 2060 2061 ND_PRINT((ndo, " vol call %s", tok2str(vol_req, "op#%d", vol_op))); 2062 2063 bp += sizeof(struct rx_header) + 4; 2064 2065 switch (vol_op) { 2066 case 100: /* Create volume */ 2067 ND_PRINT((ndo, " partition")); 2068 UINTOUT(); 2069 ND_PRINT((ndo, " name")); 2070 STROUT(AFSNAMEMAX); 2071 ND_PRINT((ndo, " type")); 2072 UINTOUT(); 2073 ND_PRINT((ndo, " parent")); 2074 UINTOUT(); 2075 break; 2076 case 101: /* Delete volume */ 2077 case 107: /* Get flags */ 2078 ND_PRINT((ndo, " trans")); 2079 UINTOUT(); 2080 break; 2081 case 102: /* Restore */ 2082 ND_PRINT((ndo, " totrans")); 2083 UINTOUT(); 2084 ND_PRINT((ndo, " flags")); 2085 UINTOUT(); 2086 break; 2087 case 103: /* Forward */ 2088 ND_PRINT((ndo, " fromtrans")); 2089 UINTOUT(); 2090 ND_PRINT((ndo, " fromdate")); 2091 DATEOUT(); 2092 DESTSERVEROUT(); 2093 ND_PRINT((ndo, " desttrans")); 2094 INTOUT(); 2095 break; 2096 case 104: /* End trans */ 2097 ND_PRINT((ndo, " trans")); 2098 UINTOUT(); 2099 break; 2100 case 105: /* Clone */ 2101 ND_PRINT((ndo, " trans")); 2102 UINTOUT(); 2103 ND_PRINT((ndo, " purgevol")); 2104 UINTOUT(); 2105 ND_PRINT((ndo, " newtype")); 2106 UINTOUT(); 2107 ND_PRINT((ndo, " newname")); 2108 STROUT(AFSNAMEMAX); 2109 break; 2110 case 106: /* Set flags */ 2111 ND_PRINT((ndo, " trans")); 2112 UINTOUT(); 2113 ND_PRINT((ndo, " flags")); 2114 UINTOUT(); 2115 break; 2116 case 108: /* Trans create */ 2117 ND_PRINT((ndo, " vol")); 2118 UINTOUT(); 2119 ND_PRINT((ndo, " partition")); 2120 UINTOUT(); 2121 ND_PRINT((ndo, " flags")); 2122 UINTOUT(); 2123 break; 2124 case 109: /* Dump */ 2125 case 655537: /* Get size */ 2126 ND_PRINT((ndo, " fromtrans")); 2127 UINTOUT(); 2128 ND_PRINT((ndo, " fromdate")); 2129 DATEOUT(); 2130 break; 2131 case 110: /* Get n-th volume */ 2132 ND_PRINT((ndo, " index")); 2133 UINTOUT(); 2134 break; 2135 case 111: /* Set forwarding */ 2136 ND_PRINT((ndo, " tid")); 2137 UINTOUT(); 2138 ND_PRINT((ndo, " newsite")); 2139 UINTOUT(); 2140 break; 2141 case 112: /* Get name */ 2142 case 113: /* Get status */ 2143 ND_PRINT((ndo, " tid")); 2144 break; 2145 case 114: /* Signal restore */ 2146 ND_PRINT((ndo, " name")); 2147 STROUT(AFSNAMEMAX); 2148 ND_PRINT((ndo, " type")); 2149 UINTOUT(); 2150 ND_PRINT((ndo, " pid")); 2151 UINTOUT(); 2152 ND_PRINT((ndo, " cloneid")); 2153 UINTOUT(); 2154 break; 2155 case 116: /* List volumes */ 2156 ND_PRINT((ndo, " partition")); 2157 UINTOUT(); 2158 ND_PRINT((ndo, " flags")); 2159 UINTOUT(); 2160 break; 2161 case 117: /* Set id types */ 2162 ND_PRINT((ndo, " tid")); 2163 UINTOUT(); 2164 ND_PRINT((ndo, " name")); 2165 STROUT(AFSNAMEMAX); 2166 ND_PRINT((ndo, " type")); 2167 UINTOUT(); 2168 ND_PRINT((ndo, " pid")); 2169 UINTOUT(); 2170 ND_PRINT((ndo, " clone")); 2171 UINTOUT(); 2172 ND_PRINT((ndo, " backup")); 2173 UINTOUT(); 2174 break; 2175 case 119: /* Partition info */ 2176 ND_PRINT((ndo, " name")); 2177 STROUT(AFSNAMEMAX); 2178 break; 2179 case 120: /* Reclone */ 2180 ND_PRINT((ndo, " tid")); 2181 UINTOUT(); 2182 break; 2183 case 121: /* List one volume */ 2184 case 122: /* Nuke volume */ 2185 case 124: /* Extended List volumes */ 2186 case 125: /* Extended List one volume */ 2187 case 65536: /* Convert RO to RW volume */ 2188 ND_PRINT((ndo, " partid")); 2189 UINTOUT(); 2190 ND_PRINT((ndo, " volid")); 2191 UINTOUT(); 2192 break; 2193 case 123: /* Set date */ 2194 ND_PRINT((ndo, " tid")); 2195 UINTOUT(); 2196 ND_PRINT((ndo, " date")); 2197 DATEOUT(); 2198 break; 2199 case 126: /* Set info */ 2200 ND_PRINT((ndo, " tid")); 2201 UINTOUT(); 2202 break; 2203 case 128: /* Forward multiple */ 2204 ND_PRINT((ndo, " fromtrans")); 2205 UINTOUT(); 2206 ND_PRINT((ndo, " fromdate")); 2207 DATEOUT(); 2208 { 2209 unsigned long i, j; 2210 ND_TCHECK2(bp[0], 4); 2211 j = EXTRACT_32BITS(bp); 2212 bp += sizeof(int32_t); 2213 for (i = 0; i < j; i++) { 2214 DESTSERVEROUT(); 2215 if (i != j - 1) 2216 ND_PRINT((ndo, ",")); 2217 } 2218 if (j == 0) 2219 ND_PRINT((ndo, " <none!>")); 2220 } 2221 break; 2222 case 65538: /* Dump version 2 */ 2223 ND_PRINT((ndo, " fromtrans")); 2224 UINTOUT(); 2225 ND_PRINT((ndo, " fromdate")); 2226 DATEOUT(); 2227 ND_PRINT((ndo, " flags")); 2228 UINTOUT(); 2229 break; 2230 default: 2231 ; 2232 } 2233 return; 2234 2235 trunc: 2236 ND_PRINT((ndo, " [|vol]")); 2237 } 2238 2239 /* 2240 * Handle replies to the AFS Volume Service 2241 */ 2242 2243 static void 2244 vol_reply_print(netdissect_options *ndo, 2245 register const u_char *bp, int length, int32_t opcode) 2246 { 2247 const struct rx_header *rxh; 2248 2249 if (length <= (int)sizeof(struct rx_header)) 2250 return; 2251 2252 rxh = (const struct rx_header *) bp; 2253 2254 /* 2255 * Print out the afs call we're invoking. The table used here was 2256 * gleaned from volser/volint.xg 2257 */ 2258 2259 ND_PRINT((ndo, " vol reply %s", tok2str(vol_req, "op#%d", opcode))); 2260 2261 bp += sizeof(struct rx_header); 2262 2263 /* 2264 * If it was a data packet, interpret the response. 2265 */ 2266 2267 if (rxh->type == RX_PACKET_TYPE_DATA) { 2268 switch (opcode) { 2269 case 100: /* Create volume */ 2270 ND_PRINT((ndo, " volid")); 2271 UINTOUT(); 2272 ND_PRINT((ndo, " trans")); 2273 UINTOUT(); 2274 break; 2275 case 104: /* End transaction */ 2276 UINTOUT(); 2277 break; 2278 case 105: /* Clone */ 2279 ND_PRINT((ndo, " newvol")); 2280 UINTOUT(); 2281 break; 2282 case 107: /* Get flags */ 2283 UINTOUT(); 2284 break; 2285 case 108: /* Transaction create */ 2286 ND_PRINT((ndo, " trans")); 2287 UINTOUT(); 2288 break; 2289 case 110: /* Get n-th volume */ 2290 ND_PRINT((ndo, " volume")); 2291 UINTOUT(); 2292 ND_PRINT((ndo, " partition")); 2293 UINTOUT(); 2294 break; 2295 case 112: /* Get name */ 2296 STROUT(AFSNAMEMAX); 2297 break; 2298 case 113: /* Get status */ 2299 ND_PRINT((ndo, " volid")); 2300 UINTOUT(); 2301 ND_PRINT((ndo, " nextuniq")); 2302 UINTOUT(); 2303 ND_PRINT((ndo, " type")); 2304 UINTOUT(); 2305 ND_PRINT((ndo, " parentid")); 2306 UINTOUT(); 2307 ND_PRINT((ndo, " clone")); 2308 UINTOUT(); 2309 ND_PRINT((ndo, " backup")); 2310 UINTOUT(); 2311 ND_PRINT((ndo, " restore")); 2312 UINTOUT(); 2313 ND_PRINT((ndo, " maxquota")); 2314 UINTOUT(); 2315 ND_PRINT((ndo, " minquota")); 2316 UINTOUT(); 2317 ND_PRINT((ndo, " owner")); 2318 UINTOUT(); 2319 ND_PRINT((ndo, " create")); 2320 DATEOUT(); 2321 ND_PRINT((ndo, " access")); 2322 DATEOUT(); 2323 ND_PRINT((ndo, " update")); 2324 DATEOUT(); 2325 ND_PRINT((ndo, " expire")); 2326 DATEOUT(); 2327 ND_PRINT((ndo, " backup")); 2328 DATEOUT(); 2329 ND_PRINT((ndo, " copy")); 2330 DATEOUT(); 2331 break; 2332 case 115: /* Old list partitions */ 2333 break; 2334 case 116: /* List volumes */ 2335 case 121: /* List one volume */ 2336 { 2337 unsigned long i, j; 2338 ND_TCHECK2(bp[0], 4); 2339 j = EXTRACT_32BITS(bp); 2340 bp += sizeof(int32_t); 2341 for (i = 0; i < j; i++) { 2342 ND_PRINT((ndo, " name")); 2343 VECOUT(32); 2344 ND_PRINT((ndo, " volid")); 2345 UINTOUT(); 2346 ND_PRINT((ndo, " type")); 2347 bp += sizeof(int32_t) * 21; 2348 if (i != j - 1) 2349 ND_PRINT((ndo, ",")); 2350 } 2351 if (j == 0) 2352 ND_PRINT((ndo, " <none!>")); 2353 } 2354 break; 2355 2356 2357 default: 2358 ; 2359 } 2360 } else { 2361 /* 2362 * Otherwise, just print out the return code 2363 */ 2364 ND_PRINT((ndo, " errcode")); 2365 INTOUT(); 2366 } 2367 2368 return; 2369 2370 trunc: 2371 ND_PRINT((ndo, " [|vol]")); 2372 } 2373 2374 /* 2375 * Handle calls to the AFS BOS service 2376 */ 2377 2378 static void 2379 bos_print(netdissect_options *ndo, 2380 register const u_char *bp, int length) 2381 { 2382 int bos_op; 2383 2384 if (length <= (int)sizeof(struct rx_header)) 2385 return; 2386 2387 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { 2388 goto trunc; 2389 } 2390 2391 /* 2392 * Print out the afs call we're invoking. The table used here was 2393 * gleaned from bozo/bosint.xg 2394 */ 2395 2396 bos_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); 2397 2398 ND_PRINT((ndo, " bos call %s", tok2str(bos_req, "op#%d", bos_op))); 2399 2400 /* 2401 * Decode some of the arguments to the BOS calls 2402 */ 2403 2404 bp += sizeof(struct rx_header) + 4; 2405 2406 switch (bos_op) { 2407 case 80: /* Create B node */ 2408 ND_PRINT((ndo, " type")); 2409 STROUT(BOSNAMEMAX); 2410 ND_PRINT((ndo, " instance")); 2411 STROUT(BOSNAMEMAX); 2412 break; 2413 case 81: /* Delete B node */ 2414 case 83: /* Get status */ 2415 case 85: /* Get instance info */ 2416 case 87: /* Add super user */ 2417 case 88: /* Delete super user */ 2418 case 93: /* Set cell name */ 2419 case 96: /* Add cell host */ 2420 case 97: /* Delete cell host */ 2421 case 104: /* Restart */ 2422 case 106: /* Uninstall */ 2423 case 108: /* Exec */ 2424 case 112: /* Getlog */ 2425 case 114: /* Get instance strings */ 2426 STROUT(BOSNAMEMAX); 2427 break; 2428 case 82: /* Set status */ 2429 case 98: /* Set T status */ 2430 STROUT(BOSNAMEMAX); 2431 ND_PRINT((ndo, " status")); 2432 INTOUT(); 2433 break; 2434 case 86: /* Get instance parm */ 2435 STROUT(BOSNAMEMAX); 2436 ND_PRINT((ndo, " num")); 2437 INTOUT(); 2438 break; 2439 case 84: /* Enumerate instance */ 2440 case 89: /* List super users */ 2441 case 90: /* List keys */ 2442 case 91: /* Add key */ 2443 case 92: /* Delete key */ 2444 case 95: /* Get cell host */ 2445 INTOUT(); 2446 break; 2447 case 105: /* Install */ 2448 STROUT(BOSNAMEMAX); 2449 ND_PRINT((ndo, " size")); 2450 INTOUT(); 2451 ND_PRINT((ndo, " flags")); 2452 INTOUT(); 2453 ND_PRINT((ndo, " date")); 2454 INTOUT(); 2455 break; 2456 default: 2457 ; 2458 } 2459 2460 return; 2461 2462 trunc: 2463 ND_PRINT((ndo, " [|bos]")); 2464 } 2465 2466 /* 2467 * Handle replies to the AFS BOS Service 2468 */ 2469 2470 static void 2471 bos_reply_print(netdissect_options *ndo, 2472 register const u_char *bp, int length, int32_t opcode) 2473 { 2474 const struct rx_header *rxh; 2475 2476 if (length <= (int)sizeof(struct rx_header)) 2477 return; 2478 2479 rxh = (const struct rx_header *) bp; 2480 2481 /* 2482 * Print out the afs call we're invoking. The table used here was 2483 * gleaned from volser/volint.xg 2484 */ 2485 2486 ND_PRINT((ndo, " bos reply %s", tok2str(bos_req, "op#%d", opcode))); 2487 2488 bp += sizeof(struct rx_header); 2489 2490 /* 2491 * If it was a data packet, interpret the response. 2492 */ 2493 2494 if (rxh->type == RX_PACKET_TYPE_DATA) 2495 /* Well, no, not really. Leave this for later */ 2496 ; 2497 else { 2498 /* 2499 * Otherwise, just print out the return code 2500 */ 2501 ND_PRINT((ndo, " errcode")); 2502 INTOUT(); 2503 } 2504 2505 return; 2506 2507 trunc: 2508 ND_PRINT((ndo, " [|bos]")); 2509 } 2510 2511 /* 2512 * Check to see if this is a Ubik opcode. 2513 */ 2514 2515 static int 2516 is_ubik(uint32_t opcode) 2517 { 2518 if ((opcode >= VOTE_LOW && opcode <= VOTE_HIGH) || 2519 (opcode >= DISK_LOW && opcode <= DISK_HIGH)) 2520 return(1); 2521 else 2522 return(0); 2523 } 2524 2525 /* 2526 * Handle Ubik opcodes to any one of the replicated database services 2527 */ 2528 2529 static void 2530 ubik_print(netdissect_options *ndo, 2531 register const u_char *bp) 2532 { 2533 int ubik_op; 2534 int32_t temp; 2535 2536 /* 2537 * Print out the afs call we're invoking. The table used here was 2538 * gleaned from ubik/ubik_int.xg 2539 */ 2540 2541 ubik_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); 2542 2543 ND_PRINT((ndo, " ubik call %s", tok2str(ubik_req, "op#%d", ubik_op))); 2544 2545 /* 2546 * Decode some of the arguments to the Ubik calls 2547 */ 2548 2549 bp += sizeof(struct rx_header) + 4; 2550 2551 switch (ubik_op) { 2552 case 10000: /* Beacon */ 2553 ND_TCHECK2(bp[0], 4); 2554 temp = EXTRACT_32BITS(bp); 2555 bp += sizeof(int32_t); 2556 ND_PRINT((ndo, " syncsite %s", temp ? "yes" : "no")); 2557 ND_PRINT((ndo, " votestart")); 2558 DATEOUT(); 2559 ND_PRINT((ndo, " dbversion")); 2560 UBIK_VERSIONOUT(); 2561 ND_PRINT((ndo, " tid")); 2562 UBIK_VERSIONOUT(); 2563 break; 2564 case 10003: /* Get sync site */ 2565 ND_PRINT((ndo, " site")); 2566 UINTOUT(); 2567 break; 2568 case 20000: /* Begin */ 2569 case 20001: /* Commit */ 2570 case 20007: /* Abort */ 2571 case 20008: /* Release locks */ 2572 case 20010: /* Writev */ 2573 ND_PRINT((ndo, " tid")); 2574 UBIK_VERSIONOUT(); 2575 break; 2576 case 20002: /* Lock */ 2577 ND_PRINT((ndo, " tid")); 2578 UBIK_VERSIONOUT(); 2579 ND_PRINT((ndo, " file")); 2580 INTOUT(); 2581 ND_PRINT((ndo, " pos")); 2582 INTOUT(); 2583 ND_PRINT((ndo, " length")); 2584 INTOUT(); 2585 temp = EXTRACT_32BITS(bp); 2586 bp += sizeof(int32_t); 2587 tok2str(ubik_lock_types, "type %d", temp); 2588 break; 2589 case 20003: /* Write */ 2590 ND_PRINT((ndo, " tid")); 2591 UBIK_VERSIONOUT(); 2592 ND_PRINT((ndo, " file")); 2593 INTOUT(); 2594 ND_PRINT((ndo, " pos")); 2595 INTOUT(); 2596 break; 2597 case 20005: /* Get file */ 2598 ND_PRINT((ndo, " file")); 2599 INTOUT(); 2600 break; 2601 case 20006: /* Send file */ 2602 ND_PRINT((ndo, " file")); 2603 INTOUT(); 2604 ND_PRINT((ndo, " length")); 2605 INTOUT(); 2606 ND_PRINT((ndo, " dbversion")); 2607 UBIK_VERSIONOUT(); 2608 break; 2609 case 20009: /* Truncate */ 2610 ND_PRINT((ndo, " tid")); 2611 UBIK_VERSIONOUT(); 2612 ND_PRINT((ndo, " file")); 2613 INTOUT(); 2614 ND_PRINT((ndo, " length")); 2615 INTOUT(); 2616 break; 2617 case 20012: /* Set version */ 2618 ND_PRINT((ndo, " tid")); 2619 UBIK_VERSIONOUT(); 2620 ND_PRINT((ndo, " oldversion")); 2621 UBIK_VERSIONOUT(); 2622 ND_PRINT((ndo, " newversion")); 2623 UBIK_VERSIONOUT(); 2624 break; 2625 default: 2626 ; 2627 } 2628 2629 return; 2630 2631 trunc: 2632 ND_PRINT((ndo, " [|ubik]")); 2633 } 2634 2635 /* 2636 * Handle Ubik replies to any one of the replicated database services 2637 */ 2638 2639 static void 2640 ubik_reply_print(netdissect_options *ndo, 2641 register const u_char *bp, int length, int32_t opcode) 2642 { 2643 const struct rx_header *rxh; 2644 2645 if (length < (int)sizeof(struct rx_header)) 2646 return; 2647 2648 rxh = (const struct rx_header *) bp; 2649 2650 /* 2651 * Print out the ubik call we're invoking. This table was gleaned 2652 * from ubik/ubik_int.xg 2653 */ 2654 2655 ND_PRINT((ndo, " ubik reply %s", tok2str(ubik_req, "op#%d", opcode))); 2656 2657 bp += sizeof(struct rx_header); 2658 2659 /* 2660 * If it was a data packet, print out the arguments to the Ubik calls 2661 */ 2662 2663 if (rxh->type == RX_PACKET_TYPE_DATA) 2664 switch (opcode) { 2665 case 10000: /* Beacon */ 2666 ND_PRINT((ndo, " vote no")); 2667 break; 2668 case 20004: /* Get version */ 2669 ND_PRINT((ndo, " dbversion")); 2670 UBIK_VERSIONOUT(); 2671 break; 2672 default: 2673 ; 2674 } 2675 2676 /* 2677 * Otherwise, print out "yes" it it was a beacon packet (because 2678 * that's how yes votes are returned, go figure), otherwise 2679 * just print out the error code. 2680 */ 2681 2682 else 2683 switch (opcode) { 2684 case 10000: /* Beacon */ 2685 ND_PRINT((ndo, " vote yes until")); 2686 DATEOUT(); 2687 break; 2688 default: 2689 ND_PRINT((ndo, " errcode")); 2690 INTOUT(); 2691 } 2692 2693 return; 2694 2695 trunc: 2696 ND_PRINT((ndo, " [|ubik]")); 2697 } 2698 2699 /* 2700 * Handle RX ACK packets. 2701 */ 2702 2703 static void 2704 rx_ack_print(netdissect_options *ndo, 2705 register const u_char *bp, int length) 2706 { 2707 const struct rx_ackPacket *rxa; 2708 int i, start, last; 2709 uint32_t firstPacket; 2710 2711 if (length < (int)sizeof(struct rx_header)) 2712 return; 2713 2714 bp += sizeof(struct rx_header); 2715 2716 /* 2717 * This may seem a little odd .... the rx_ackPacket structure 2718 * contains an array of individual packet acknowledgements 2719 * (used for selective ack/nack), but since it's variable in size, 2720 * we don't want to truncate based on the size of the whole 2721 * rx_ackPacket structure. 2722 */ 2723 2724 ND_TCHECK2(bp[0], sizeof(struct rx_ackPacket) - RX_MAXACKS); 2725 2726 rxa = (const struct rx_ackPacket *) bp; 2727 bp += (sizeof(struct rx_ackPacket) - RX_MAXACKS); 2728 2729 /* 2730 * Print out a few useful things from the ack packet structure 2731 */ 2732 2733 if (ndo->ndo_vflag > 2) 2734 ND_PRINT((ndo, " bufspace %d maxskew %d", 2735 (int) EXTRACT_16BITS(&rxa->bufferSpace), 2736 (int) EXTRACT_16BITS(&rxa->maxSkew))); 2737 2738 firstPacket = EXTRACT_32BITS(&rxa->firstPacket); 2739 ND_PRINT((ndo, " first %d serial %d reason %s", 2740 firstPacket, EXTRACT_32BITS(&rxa->serial), 2741 tok2str(rx_ack_reasons, "#%d", (int) rxa->reason))); 2742 2743 /* 2744 * Okay, now we print out the ack array. The way _this_ works 2745 * is that we start at "first", and step through the ack array. 2746 * If we have a contiguous range of acks/nacks, try to 2747 * collapse them into a range. 2748 * 2749 * If you're really clever, you might have noticed that this 2750 * doesn't seem quite correct. Specifically, due to structure 2751 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually 2752 * yield the start of the ack array (because RX_MAXACKS is 255 2753 * and the structure will likely get padded to a 2 or 4 byte 2754 * boundary). However, this is the way it's implemented inside 2755 * of AFS - the start of the extra fields are at 2756 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_ 2757 * the exact start of the ack array. Sigh. That's why we aren't 2758 * using bp, but instead use rxa->acks[]. But nAcks gets added 2759 * to bp after this, so bp ends up at the right spot. Go figure. 2760 */ 2761 2762 if (rxa->nAcks != 0) { 2763 2764 ND_TCHECK2(bp[0], rxa->nAcks); 2765 2766 /* 2767 * Sigh, this is gross, but it seems to work to collapse 2768 * ranges correctly. 2769 */ 2770 2771 for (i = 0, start = last = -2; i < rxa->nAcks; i++) 2772 if (rxa->acks[i] == RX_ACK_TYPE_ACK) { 2773 2774 /* 2775 * I figured this deserved _some_ explanation. 2776 * First, print "acked" and the packet seq 2777 * number if this is the first time we've 2778 * seen an acked packet. 2779 */ 2780 2781 if (last == -2) { 2782 ND_PRINT((ndo, " acked %d", firstPacket + i)); 2783 start = i; 2784 } 2785 2786 /* 2787 * Otherwise, if there is a skip in 2788 * the range (such as an nacked packet in 2789 * the middle of some acked packets), 2790 * then print the current packet number 2791 * seperated from the last number by 2792 * a comma. 2793 */ 2794 2795 else if (last != i - 1) { 2796 ND_PRINT((ndo, ",%d", firstPacket + i)); 2797 start = i; 2798 } 2799 2800 /* 2801 * We always set last to the value of 2802 * the last ack we saw. Conversely, start 2803 * is set to the value of the first ack 2804 * we saw in a range. 2805 */ 2806 2807 last = i; 2808 2809 /* 2810 * Okay, this bit a code gets executed when 2811 * we hit a nack ... in _this_ case we 2812 * want to print out the range of packets 2813 * that were acked, so we need to print 2814 * the _previous_ packet number seperated 2815 * from the first by a dash (-). Since we 2816 * already printed the first packet above, 2817 * just print the final packet. Don't 2818 * do this if there will be a single-length 2819 * range. 2820 */ 2821 } else if (last == i - 1 && start != last) 2822 ND_PRINT((ndo, "-%d", firstPacket + i - 1)); 2823 2824 /* 2825 * So, what's going on here? We ran off the end of the 2826 * ack list, and if we got a range we need to finish it up. 2827 * So we need to determine if the last packet in the list 2828 * was an ack (if so, then last will be set to it) and 2829 * we need to see if the last range didn't start with the 2830 * last packet (because if it _did_, then that would mean 2831 * that the packet number has already been printed and 2832 * we don't need to print it again). 2833 */ 2834 2835 if (last == i - 1 && start != last) 2836 ND_PRINT((ndo, "-%d", firstPacket + i - 1)); 2837 2838 /* 2839 * Same as above, just without comments 2840 */ 2841 2842 for (i = 0, start = last = -2; i < rxa->nAcks; i++) 2843 if (rxa->acks[i] == RX_ACK_TYPE_NACK) { 2844 if (last == -2) { 2845 ND_PRINT((ndo, " nacked %d", firstPacket + i)); 2846 start = i; 2847 } else if (last != i - 1) { 2848 ND_PRINT((ndo, ",%d", firstPacket + i)); 2849 start = i; 2850 } 2851 last = i; 2852 } else if (last == i - 1 && start != last) 2853 ND_PRINT((ndo, "-%d", firstPacket + i - 1)); 2854 2855 if (last == i - 1 && start != last) 2856 ND_PRINT((ndo, "-%d", firstPacket + i - 1)); 2857 2858 bp += rxa->nAcks; 2859 } 2860 2861 2862 /* 2863 * These are optional fields; depending on your version of AFS, 2864 * you may or may not see them 2865 */ 2866 2867 #define TRUNCRET(n) if (ndo->ndo_snapend - bp + 1 <= n) return; 2868 2869 if (ndo->ndo_vflag > 1) { 2870 TRUNCRET(4); 2871 ND_PRINT((ndo, " ifmtu")); 2872 INTOUT(); 2873 2874 TRUNCRET(4); 2875 ND_PRINT((ndo, " maxmtu")); 2876 INTOUT(); 2877 2878 TRUNCRET(4); 2879 ND_PRINT((ndo, " rwind")); 2880 INTOUT(); 2881 2882 TRUNCRET(4); 2883 ND_PRINT((ndo, " maxpackets")); 2884 INTOUT(); 2885 } 2886 2887 return; 2888 2889 trunc: 2890 ND_PRINT((ndo, " [|ack]")); 2891 } 2892 #undef TRUNCRET 2893