print-rx.c
来自「TCPDUMP的C语言源代码,是在数据链路层的应用」· C语言 代码 · 共 2,799 行 · 第 1/4 页
C
2,799 行
default: ; } return;trunc: printf(" [|pt]");}/* * Handle replies to the AFS protection service */static voidprot_reply_print(register const u_char *bp, int length, int32_t opcode){ struct rx_header *rxh; unsigned long i; if (length < (int)sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from ptserver/ptint.xg. Check to see if it's a * Ubik call, however. */ printf(" pt"); if (is_ubik(opcode)) { ubik_reply_print(bp, length, opcode); return; } printf(" reply %s", tok2str(pt_req, "op#%d", opcode)); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response */ if (rxh->type == RX_PACKET_TYPE_DATA) switch (opcode) { case 504: /* Name to ID */ { unsigned long j; printf(" ids:"); TCHECK2(bp[0], 4); i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); for (j = 0; j < i; j++) INTOUT(); if (j == 0) printf(" <none!>"); } break; case 505: /* ID to name */ { unsigned long j; TCHECK2(bp[0], 4); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); /* * Who designed this chicken-shit protocol? * * Each character is stored as a 32-bit * integer! */ for (i = 0; i < j; i++) { VECOUT(PRNAMEMAX); } if (j == 0) printf(" <none!>"); } break; case 508: /* Get CPS */ case 514: /* List elements */ case 517: /* List owned */ case 518: /* Get CPS2 */ case 519: /* Get host CPS */ { unsigned long j; TCHECK2(bp[0], 4); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); for (i = 0; i < j; i++) { INTOUT(); } if (j == 0) printf(" <none!>"); } break; case 510: /* List max */ printf(" maxuid"); INTOUT(); printf(" maxgid"); INTOUT(); break; default: ; } else { /* * Otherwise, just print out the return code */ printf(" errcode"); INTOUT(); } return;trunc: printf(" [|pt]");}/* * Handle calls to the AFS volume location database service */static voidvldb_print(register const u_char *bp, int length){ int vldb_op; unsigned long i; if (length <= (int)sizeof(struct rx_header)) return; if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from vlserver/vldbint.xg */ vldb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); printf(" vldb"); if (is_ubik(vldb_op)) { ubik_print(bp); return; } printf(" call %s", tok2str(vldb_req, "op#%d", vldb_op)); /* * Decode some of the arguments to the VLDB calls */ bp += sizeof(struct rx_header) + 4; switch (vldb_op) { case 501: /* Create new volume */ case 517: /* Create entry N */ VECOUT(VLNAMEMAX); break; case 502: /* Delete entry */ case 503: /* Get entry by ID */ case 507: /* Update entry */ case 508: /* Set lock */ case 509: /* Release lock */ case 518: /* Get entry by ID N */ printf(" volid"); INTOUT(); TCHECK2(bp[0], sizeof(int32_t)); i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); if (i <= 2) printf(" type %s", voltype[i]); break; case 504: /* Get entry by name */ case 519: /* Get entry by name N */ case 524: /* Update entry by name */ case 527: /* Get entry by name U */ STROUT(VLNAMEMAX); break; case 505: /* Get new vol id */ printf(" bump"); INTOUT(); break; case 506: /* Replace entry */ case 520: /* Replace entry N */ printf(" volid"); INTOUT(); TCHECK2(bp[0], sizeof(int32_t)); i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); if (i <= 2) printf(" type %s", voltype[i]); VECOUT(VLNAMEMAX); break; case 510: /* List entry */ case 521: /* List entry N */ printf(" index"); INTOUT(); break; default: ; } return;trunc: printf(" [|vldb]");}/* * Handle replies to the AFS volume location database service */static voidvldb_reply_print(register const u_char *bp, int length, int32_t opcode){ struct rx_header *rxh; unsigned long i; if (length < (int)sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from vlserver/vldbint.xg. Check to see if it's a * Ubik call, however. */ printf(" vldb"); if (is_ubik(opcode)) { ubik_reply_print(bp, length, opcode); return; } printf(" reply %s", tok2str(vldb_req, "op#%d", opcode)); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response */ if (rxh->type == RX_PACKET_TYPE_DATA) switch (opcode) { case 510: /* List entry */ printf(" count"); INTOUT(); printf(" nextindex"); INTOUT(); case 503: /* Get entry by id */ case 504: /* Get entry by name */ { unsigned long nservers, j; VECOUT(VLNAMEMAX); TCHECK2(bp[0], sizeof(int32_t)); bp += sizeof(int32_t); printf(" numservers"); TCHECK2(bp[0], sizeof(int32_t)); nservers = EXTRACT_32BITS(bp); bp += sizeof(int32_t); printf(" %lu", nservers); printf(" servers"); for (i = 0; i < 8; i++) { TCHECK2(bp[0], sizeof(int32_t)); if (i < nservers) printf(" %s", intoa(((struct in_addr *) bp)->s_addr)); bp += sizeof(int32_t); } printf(" partitions"); for (i = 0; i < 8; i++) { TCHECK2(bp[0], sizeof(int32_t)); j = EXTRACT_32BITS(bp); if (i < nservers && j <= 26) printf(" %c", 'a' + (int)j); else if (i < nservers) printf(" %lu", j); bp += sizeof(int32_t); } TCHECK2(bp[0], 8 * sizeof(int32_t)); bp += 8 * sizeof(int32_t); printf(" rwvol"); UINTOUT(); printf(" rovol"); UINTOUT(); printf(" backup"); UINTOUT(); } break; case 505: /* Get new volume ID */ printf(" newvol"); UINTOUT(); break; case 521: /* List entry */ case 529: /* List entry U */ printf(" count"); INTOUT(); printf(" nextindex"); INTOUT(); case 518: /* Get entry by ID N */ case 519: /* Get entry by name N */ { unsigned long nservers, j; VECOUT(VLNAMEMAX); printf(" numservers"); TCHECK2(bp[0], sizeof(int32_t)); nservers = EXTRACT_32BITS(bp); bp += sizeof(int32_t); printf(" %lu", nservers); printf(" servers"); for (i = 0; i < 13; i++) { TCHECK2(bp[0], sizeof(int32_t)); if (i < nservers) printf(" %s", intoa(((struct in_addr *) bp)->s_addr)); bp += sizeof(int32_t); } printf(" partitions"); for (i = 0; i < 13; i++) { TCHECK2(bp[0], sizeof(int32_t)); j = EXTRACT_32BITS(bp); if (i < nservers && j <= 26) printf(" %c", 'a' + (int)j); else if (i < nservers) printf(" %lu", j); bp += sizeof(int32_t); } TCHECK2(bp[0], 13 * sizeof(int32_t)); bp += 13 * sizeof(int32_t); printf(" rwvol"); UINTOUT(); printf(" rovol"); UINTOUT(); printf(" backup"); UINTOUT(); } break; case 526: /* Get entry by ID U */ case 527: /* Get entry by name U */ { unsigned long nservers, j; VECOUT(VLNAMEMAX); printf(" numservers"); TCHECK2(bp[0], sizeof(int32_t)); nservers = EXTRACT_32BITS(bp); bp += sizeof(int32_t); printf(" %lu", nservers); printf(" servers"); for (i = 0; i < 13; i++) { if (i < nservers) { printf(" afsuuid"); AFSUUIDOUT(); } else { TCHECK2(bp[0], 44); bp += 44; } } TCHECK2(bp[0], 4 * 13); bp += 4 * 13; printf(" partitions"); for (i = 0; i < 13; i++) { TCHECK2(bp[0], sizeof(int32_t)); j = EXTRACT_32BITS(bp); if (i < nservers && j <= 26) printf(" %c", 'a' + (int)j); else if (i < nservers) printf(" %lu", j); bp += sizeof(int32_t); } TCHECK2(bp[0], 13 * sizeof(int32_t)); bp += 13 * sizeof(int32_t); printf(" rwvol"); UINTOUT(); printf(" rovol"); UINTOUT(); printf(" backup"); UINTOUT(); } default: ; } else { /* * Otherwise, just print out the return code */ printf(" errcode"); INTOUT(); } return;trunc: printf(" [|vldb]");}/* * Handle calls to the AFS Kerberos Authentication service */static voidkauth_print(register const u_char *bp, int length){ int kauth_op; if (length <= (int)sizeof(struct rx_header)) return; if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from kauth/kauth.rg */ kauth_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); printf(" kauth"); if (is_ubik(kauth_op)) { ubik_print(bp); return; } printf(" call %s", tok2str(kauth_req, "op#%d", kauth_op)); /* * Decode some of the arguments to the KA calls */ bp += sizeof(struct rx_header) + 4; switch (kauth_op) { case 1: /* Authenticate old */; case 21: /* Authenticate */ case 22: /* Authenticate-V2 */ case 2: /* Change PW */ case 5: /* Set fields */ case 6: /* Create user */ case 7: /* Delete user */ case 8: /* Get entry */ case 14: /* Unlock */ case 15: /* Lock status */ printf(" principal"); STROUT(KANAMEMAX); STROUT(KANAMEMAX); break; case 3: /* GetTicket-old */ case 23: /* GetTicket */ { int i; printf(" kvno"); INTOUT(); printf(" domain"); STROUT(KANAMEMAX); TCHECK2(bp[0], sizeof(int32_t)); i = (int) EXTRACT_32BITS(bp); bp += sizeof(int32_t); TCHECK2(bp[0], i); bp += i; printf(" principal"); STROUT(KANAMEMAX); STROUT(KANAMEMAX); break; } case 4: /* Set Password */ printf(" principal"); STROUT(KANAMEMAX); STROUT(KANAMEMAX); printf(" kvno"); INTOUT(); break; case 12: /* Get password */ printf(" name"); STROUT(KANAMEMAX); break; default: ; } return;trunc: printf(" [|kauth]");}/* * Handle replies to the AFS Kerberos Authentication Service */static voidkauth_reply_print(register const u_char *bp, int length, int32_t opcode){ struct rx_header *rxh; if (length <= (int)sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from kauth/kauth.rg */ printf(" kauth"); if (is_ubik(opcode)) { ubik_reply_print(bp, length, opcode); return; } printf(" reply %s", tok2str(kauth_req, "op#%d", opcode)); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response. */ if (rxh->type == RX_PACKET_TYPE_DATA) /* Well, no, not really. Leave this for later */ ; else { /* * Otherwise, just print out the return code */ printf(" errcode"); INTOUT(); } return;trunc: printf(" [|kauth]");}/* * Handle calls to the AFS Volume location service */static voidvol_print(register const u_char *bp, int length){ int vol_op; if (length <= (int)sizeof(struct rx_header)) return; if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from volser/volint.xg */ vol_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); printf(" vol call %s", tok2str(vol_req, "op#%d", vol_op)); bp += sizeof(struct rx_header) + 4; switch (vol_op) { case 100: /* Create volume */ printf(" partition"); UINTOUT(); printf(" name"); STROUT(AFSNAMEMAX); printf(" type"); UINTOUT(); printf(" parent"); UINTOUT(); break; case 101: /* Delete volume */ case 107: /* Get flags */ printf(" trans"); UINTOUT(); break; case 102: /* Restore */ printf(" totrans"); UINTOUT(); printf(" flags"); UINTOUT(); break; case 103: /* Forward */ printf(" fromtrans"); UINTOUT(); printf(" fromdate"); DATEOUT(); DESTSERVEROUT(); printf(" desttrans"); INTOUT(); break; case 104: /* End trans */ printf(" trans"); UINTOUT(); break; case 105: /* Clone */ printf(" trans"); UINTOUT(); printf(" purgevol"); UINTOUT(); printf(" newtype"); UINTOUT(); printf(" newname"); STROUT(AFSNAMEMAX); break; case 106: /* Set flags */ printf(" trans"); UINTOUT(); printf(" flags"); UINTOUT(); break; case 108: /* Trans create */ printf(" vol"); UINTOUT(); printf(" partition"); UINTOUT(); printf(" flags"); UINTOUT(); break; case 109: /* Dump */ case 655537: /* Get size */ printf(" fromtrans"); UINTOUT(); printf(" fromdate"); DATEOUT(); break; case 110: /* Get n-th volume */ printf(" index"); UINTOUT(); break; case 111: /* Set forwarding */ printf(" tid"); UINTOUT(); printf(" newsite"); UINTOUT(); break; case 112: /* Get name */ case 113: /* Get status */ printf(" tid"); break; case 114: /* Signal restore */ printf(" name"); STROUT(AFSNAMEMAX); printf(" type"); UINTOUT(); printf(" pid"); UINTOUT(); printf(" cloneid"); UINTOUT(); break; case 116: /* List volumes */ printf(" partition"); UINTOUT(); printf(" flags"); UINTOUT(); break; case 117: /* Set id types */ printf(" tid"); UINTOUT(); printf(" name"); STROUT(AFSNAMEMAX); printf(" type"); UINTOUT(); printf(" pid"); UINTOUT(); printf(" clone"); UINTOUT(); printf(" backup"); UINTOUT(); break; case 119: /* Partition info */ printf(" name"); STROUT(AFSNAMEMAX); break; case 120: /* Reclone */ printf(" tid"); UINTOUT(); break; case 121: /* List one volume */ case 122: /* Nuke volume */ case 124: /* Extended List volumes */ case 125: /* Extended List one volume */ case 65536: /* Convert RO to RW volume */ printf(" partid"); UINTOUT(); printf(" volid");
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?