⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 print-rx.c

📁 Windump3.6.2源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
			n1 = EXTRACT_32BITS(bp); \			bp += sizeof(int32_t); \			n2 = EXTRACT_32BITS(bp); \			bp += sizeof(int32_t); \			n3 = EXTRACT_32BITS(bp); \			bp += sizeof(int32_t); \			printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \		}#define STROUT(MAX) { int i; \			TCHECK2(bp[0], sizeof(int32_t)); \			i = (int) EXTRACT_32BITS(bp); \			bp += sizeof(int32_t); \			TCHECK2(bp[0], i); \			strncpy(s, (char *) bp, min(MAX, i)); \			s[i] = '\0'; \			printf(" \"%s\"", s); \			bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \		}#define INTOUT() { int i; \			TCHECK2(bp[0], sizeof(int32_t)); \			i = (int) EXTRACT_32BITS(bp); \			bp += sizeof(int32_t); \			printf(" %d", i); \		}#define UINTOUT() { unsigned long i; \			TCHECK2(bp[0], sizeof(int32_t)); \			i = EXTRACT_32BITS(bp); \			bp += sizeof(int32_t); \			printf(" %lu", i); \		}#define DATEOUT() { time_t t; struct tm *tm; char str[256]; \			TCHECK2(bp[0], sizeof(int32_t)); \			t = (time_t) EXTRACT_32BITS(bp); \			bp += sizeof(int32_t); \			tm = localtime(&t); \			strftime(str, 256, "%Y/%m/%d %T", tm); \			printf(" %s", str); \		}#define STOREATTROUT() { unsigned long mask, i; \			TCHECK2(bp[0], (sizeof(int32_t)*6)); \			mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \			if (mask) printf (" StoreStatus"); \  		        if (mask & 1) { printf(" date"); DATEOUT(); } \			else bp += sizeof(int32_t); \			i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \  		        if (mask & 2) printf(" owner %lu", i);  \			i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \  		        if (mask & 4) printf(" group %lu", i); \			i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \  		        if (mask & 8) printf(" mode %lo", i & 07777); \			i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \  		        if (mask & 16) printf(" segsize %lu", i); \			/* undocumented in 3.3 docu */ \  		        if (mask & 1024) printf(" fsync");  \		}#define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \			TCHECK2(bp[0], sizeof(int32_t) * 2); \			epoch = EXTRACT_32BITS(bp); \			bp += sizeof(int32_t); \			counter = EXTRACT_32BITS(bp); \			bp += sizeof(int32_t); \			printf(" %d.%d", epoch, counter); \		}#define AFSUUIDOUT() {u_int32_t temp; int i; \			TCHECK2(bp[0], 11*sizeof(u_int32_t)); \			temp = EXTRACT_32BITS(bp); \			bp += sizeof(u_int32_t); \			printf(" %08x", temp); \			temp = EXTRACT_32BITS(bp); \			bp += sizeof(u_int32_t); \			printf("%04x", temp); \			temp = EXTRACT_32BITS(bp); \			bp += sizeof(u_int32_t); \			printf("%04x", temp); \			for (i = 0; i < 8; i++) { \				temp = EXTRACT_32BITS(bp); \				bp += sizeof(u_int32_t); \				printf("%02x", (unsigned char) temp); \			} \		}/* * This is the sickest one of all */#define VECOUT(MAX) { char *sp; \			int k; \			TCHECK2(bp[0], MAX * sizeof(int32_t)); \			sp = s; \			for (k = 0; k < MAX; k++) { \				*sp++ = (char) EXTRACT_32BITS(bp); \				bp += sizeof(int32_t); \			} \			s[MAX] = '\0'; \			printf(" \"%s\"", s); \		}static voidack_print(register const u_char *bp, int length){        u_char nAcks;	int i;	if (vflag <= 1)	        return; 	if (length <= sizeof(struct rx_header))		return;	bp += sizeof(struct rx_header);	/*	 * Packets < firstPacket are implicitly acknowledged and may	 * be discarded by the sender.	 *	 * Packets >= firstPacket+nAcks are implicitly NOT acknowledged.	 *	 * No packets with sequence numbers >= firstPacket should be	 * discarded by the sender (they may thrown out at any time by	 * the receiver)	 */#define RX_ACK_REASONS "RDOXSprn"	/* Requested, Duplicate, Out_of_sequence, eXceeds_window, no_Space,	 * Ping, ping_Response, No_{progress, particular_reason}.	 */#if 0	struct rx_ackPacket {	  u_short bufferSpace;	/* Skip! */	  u_short maxSkew;	/* Skip! */	  u_long  firstPacket;	  u_long  previousPacket; /* Obsolete! */	  u_long  serial;	/* Serial that prompted the ack, */	  u_char  reason;	/* and the reason why. */	  u_char  nAcks;	  u_char  acks[RX_MAXACKS]; /* Selective acks (not a bitmap). */	};#endif#define RX_ACK_TYPE_NACK 0	TCHECK2(bp[0], 8);	/* bufferSpace and maxSkew */	bp += 4;	printf(" fir %u", (unsigned)EXTRACT_32BITS(bp));	bp += 4;	TCHECK2(bp[0], 8);	/* previousPacket and serial */	bp += 4;	printf(" %u", (unsigned)EXTRACT_32BITS(bp));	bp += 4;	TCHECK2(bp[0], 1);	printf("%c", RX_ACK_REASONS[(*bp - 1) & 07u]);	bp += 1;		/* reason */	TCHECK2(bp[0], 1);	nAcks = *bp;	bp += 1;		/* nAcks */	for (i = 0; i < nAcks; i++) {	    TCHECK2(bp[0], 1);	    putchar(*bp == RX_ACK_TYPE_NACK? '-' : '*');	    bp += 1;	}		return;trunc:	printf(" [|ack]");}/* * Handle calls to the AFS file service (fs) */static voidfs_print(register const u_char *bp, int length){	int fs_op;	unsigned long i;	char s[AFSNAMEMAX];	if (length <= sizeof(struct rx_header))		return;	if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) {		goto trunc;	}	/*	 * Print out the afs call we're invoking.  The table used here was	 * gleaned from fsint/afsint.xg	 */	fs_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));	printf(" fs call %s", tok2str(fs_req, "op#%d", fs_op));	/*	 * Print out arguments to some of the AFS calls.  This stuff is	 * all from afsint.xg	 */	bp += sizeof(struct rx_header) + 4;	/*	 * Sigh.  This is gross.  Ritchie forgive me.	 */	switch (fs_op) {		case 130:	/* Fetch data */			FIDOUT();			printf(" offset");			UINTOUT();			printf(" length");			UINTOUT();			break;		case 131:	/* Fetch ACL */		case 132:	/* Fetch Status */		case 143:	/* Old set lock */		case 144:	/* Old extend lock */		case 145:	/* Old release lock */		case 156:	/* Set lock */		case 157:	/* Extend lock */		case 158:	/* Release lock */			FIDOUT();			break;		case 135:	/* Store status */			FIDOUT();			STOREATTROUT();			break;		case 133:	/* Store data */			FIDOUT();			STOREATTROUT();			printf(" offset");			UINTOUT();			printf(" length");			UINTOUT();			printf(" flen");			UINTOUT();			break;		case 134:	/* Store ACL */		{			char a[AFSOPAQUEMAX+1];			FIDOUT();			TCHECK2(bp[0], 4);			i = EXTRACT_32BITS(bp);			bp += sizeof(int32_t);			TCHECK2(bp[0], i);			i = min(AFSOPAQUEMAX, i);			strncpy(a, (char *) bp, i);			a[i] = '\0';			acl_print((u_char *) a, sizeof(a), (u_char *) a + i);			break;		}		case 137:	/* Create file */		case 141:	/* MakeDir */			FIDOUT();			STROUT(AFSNAMEMAX);			STOREATTROUT();			break;		case 136:	/* Remove file */		case 142:	/* Remove directory */			FIDOUT();			STROUT(AFSNAMEMAX);			break;		case 138:	/* Rename file */			printf(" old");			FIDOUT();			STROUT(AFSNAMEMAX);			printf(" new");			FIDOUT();			STROUT(AFSNAMEMAX);			break;		case 139:	/* Symlink */			FIDOUT();			STROUT(AFSNAMEMAX);			printf(" link to");			STROUT(AFSNAMEMAX);			break;		case 140:	/* Link */			FIDOUT();			STROUT(AFSNAMEMAX);			printf(" link to");			FIDOUT();			break;		case 148:	/* Get volume info */			STROUT(AFSNAMEMAX);			break;		case 149:	/* Get volume stats */		case 150:	/* Set volume stats */			printf(" volid");			UINTOUT();			break;		case 154:	/* New get volume info */			printf(" volname");			STROUT(AFSNAMEMAX);			break;		case 155:	/* Bulk stat */		{			unsigned long j;			TCHECK2(bp[0], 4);			j = EXTRACT_32BITS(bp);			bp += sizeof(int32_t);			for (i = 0; i < j; i++) {				FIDOUT();				if (i != j - 1)					printf(",");			}			if (j == 0)				printf(" <none!>");		}		default:			;	}	return;trunc:	printf(" [|fs]");}/* * Handle replies to the AFS file service */static voidfs_reply_print(register const u_char *bp, int length, int32_t opcode){	unsigned long i;	char s[AFSNAMEMAX];	struct rx_header *rxh;	if (length <= 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 fsint/afsint.xg	 */	printf(" fs reply %s", tok2str(fs_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 131:	/* Fetch ACL */		{			char a[AFSOPAQUEMAX+1];			TCHECK2(bp[0], 4);			i = EXTRACT_32BITS(bp);			bp += sizeof(int32_t);			TCHECK2(bp[0], i);			i = min(AFSOPAQUEMAX, i);			strncpy(a, (char *) bp, i);			a[i] = '\0';			acl_print((u_char *) a, sizeof(a), (u_char *) a + i);			break;		}		case 137:	/* Create file */		case 141:	/* MakeDir */			printf(" new");			FIDOUT();			break;		case 151:	/* Get root volume */			printf(" root volume");			STROUT(AFSNAMEMAX);			break;		case 153:	/* Get time */			DATEOUT();			break;		default:			;		}	} else if (rxh->type == RX_PACKET_TYPE_ABORT) {		int i; 		/* 		 * Otherwise, just print out the return code 		 */		TCHECK2(bp[0], sizeof(int32_t)); 		i = (int) EXTRACT_32BITS(bp); 		bp += sizeof(int32_t); 		printf(" error %s", tok2str(afs_fs_errors, "#%d", i));	} else {		printf(" strange fs reply of type %d", rxh->type);	}	return;trunc:	printf(" [|fs]");}/* * Print out an AFS ACL string.  An AFS ACL is a string that has the * following format: * * <positive> <negative> * <uid1> <aclbits1> * .... *  * "positive" and "negative" are integers which contain the number of * positive and negative ACL's in the string.  The uid/aclbits pair are * ASCII strings containing the UID/PTS record and and a ascii number * representing a logical OR of all the ACL permission bits */static voidacl_print(u_char *s, int maxsize, u_char *end){	int pos, neg, acl;	int n, i;	char *user;	if ((user = (char *)malloc(maxsize)) == NULL)		return;	if (sscanf((char *) s, "%d %d\n%n", &pos, &neg, &n) != 2)		goto finish;		s += n;	if (s > end)		goto finish;	/*	 * This wacky order preserves the order used by the "fs" command	 */#define ACLOUT(acl) \	if (acl & PRSFS_READ) \		printf("r"); \	if (acl & PRSFS_LOOKUP) \		printf("l"); \	if (acl & PRSFS_INSERT) \		printf("i"); \	if (acl & PRSFS_DELETE) \		printf("d"); \	if (acl & PRSFS_WRITE) \		printf("w"); \	if (acl & PRSFS_LOCK) \		printf("k"); \	if (acl & PRSFS_ADMINISTER) \		printf("a");	for (i = 0; i < pos; i++) {		if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2)			goto finish;		s += n;		printf(" +{%s ", user);		ACLOUT(acl);		printf("}");		if (s > end)			goto finish;	}	for (i = 0; i < neg; i++) {		if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2)			goto finish;		s += n;		printf(" -{%s ", user);		ACLOUT(acl);		printf("}");		if (s > end)			goto finish;	}finish:	free(user);	return;}#undef ACLOUT/* * Handle calls to the AFS callback service */static voidcb_print(register const u_char *bp, int length){	int cb_op;	unsigned long i;	if (length <= sizeof(struct rx_header))		return;	if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) {		goto trunc;	}	/*	 * Print out the afs call we're invoking.  The table used here was	 * gleaned from fsint/afscbint.xg	 */	cb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));	printf(" cb call %s", tok2str(cb_req, "op#%d", cb_op));	bp += sizeof(struct rx_header) + 4;	/*	 * Print out the afs call we're invoking.  The table used here was	 * gleaned from fsint/afscbint.xg	 */	switch (cb_op) {		case 204:		/* Callback */		{			unsigned long j, t;			TCHECK2(bp[0], 4);			j = EXTRACT_32BITS(bp);			bp += sizeof(int32_t);			for (i = 0; i < j; i++) {				FIDOUT();				if (i != j - 1)					printf(",");			}			if (j == 0)				printf(" <none!>");			j = EXTRACT_32BITS(bp);			bp += sizeof(int32_t);			if (j != 0)				printf(";");			for (i = 0; i < j; i++) {				printf(" ver");				INTOUT();				printf(" expires");				DATEOUT();				TCHECK2(bp[0], 4);				t = EXTRACT_32BITS(bp);				bp += sizeof(int32_t);				tok2str(cb_types, "type %d", t);			}		}		case 214: {			printf(" afsuuid");			AFSUUIDOUT();			break;		}		default:			;	}	return;trunc:	printf(" [|cb]");}/* * Handle replies to the AFS Callback Service */static voidcb_reply_print(register const u_char *bp, int length, int32_t opcode){	struct rx_header *rxh;	if (length <= 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 fsint/afscbint.xg	 */		printf(" cb reply %s", tok2str(cb_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 213:	/* InitCallBackState3 */			AFSUUIDOUT();			break;		default:		;		}	else {		/*		 * Otherwise, just print out the return code		 */		printf(" errcode");		INTOUT();	}	return;trunc:	printf(" [|cb]");}/* * Handle calls to the AFS protection database server */static voidprot_print(register const u_char *bp, int length){	unsigned long i;	char s[AFSNAMEMAX];	int pt_op;	if (length <= sizeof(struct rx_header))		return;	if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) {		goto trunc;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -