static void krb4_print(netdissect_options *ndo, const u_char *cp) { register const struct krb *kp; u_char type; u_short len; #define PRINT if ((cp = c_print(ndo, cp, ndo->ndo_snapend)) == NULL) goto trunc /* True if struct krb is little endian */ #define IS_LENDIAN(kp) (((kp)->type & 0x01) != 0) #define KTOHSP(kp, cp) (IS_LENDIAN(kp) ? EXTRACT_LE_16BITS(cp) : EXTRACT_16BITS(cp)) kp = (const struct krb *)cp; if ((&kp->type) >= ndo->ndo_snapend) { ND_PRINT((ndo, "%s", tstr)); return; } type = kp->type & (0xFF << 1); ND_PRINT((ndo, " %s %s: ", IS_LENDIAN(kp) ? "le" : "be", tok2str(type2str, NULL, type))); switch (type) { case AUTH_MSG_KDC_REQUEST: if ((cp = krb4_print_hdr(ndo, cp)) == NULL) return; cp += 4; /* ctime */ ND_TCHECK(*cp); ND_PRINT((ndo, " %dmin ", *cp++ * 5)); PRINT; ND_PRINT((ndo, ".")); PRINT; break; case AUTH_MSG_APPL_REQUEST: cp += 2; ND_TCHECK(*cp); ND_PRINT((ndo, "v%d ", *cp++)); PRINT; ND_TCHECK(*cp); ND_PRINT((ndo, " (%d)", *cp++)); ND_TCHECK(*cp); ND_PRINT((ndo, " (%d)", *cp)); break; case AUTH_MSG_KDC_REPLY: if ((cp = krb4_print_hdr(ndo, cp)) == NULL) return; cp += 10; /* timestamp + n + exp + kvno */ ND_TCHECK2(*cp, sizeof(short)); len = KTOHSP(kp, cp); ND_PRINT((ndo, " (%d)", len)); break; case AUTH_MSG_ERR_REPLY: if ((cp = krb4_print_hdr(ndo, cp)) == NULL) return; cp += 4; /* timestamp */ ND_TCHECK2(*cp, sizeof(short)); ND_PRINT((ndo, " %s ", tok2str(kerr2str, NULL, KTOHSP(kp, cp)))); cp += 4; PRINT; break; default: ND_PRINT((ndo, "(unknown)")); break; } return; trunc: ND_PRINT((ndo, "%s", tstr)); }
void krb4_print(const u_char *cp) { register const struct krb *kp; u_char type; u_short len; #define PRINT if ((cp = c_print(cp, snapend)) == NULL) goto trunc /* True if struct krb is little endian */ #define IS_LENDIAN(kp) (((kp)->type & 0x01) != 0) #define KTOHSP(kp, cp) (IS_LENDIAN(kp) ? vtohsp(cp) : ntohsp(cp)) kp = (struct krb *)cp; if ((&kp->type) >= snapend) { fputs(tstr, stdout); return; } type = kp->type & (0xFF << 1); printf(" %s %s: ", IS_LENDIAN(kp) ? "le" : "be", tok2str(type2str, NULL, type)); switch (type) { case AUTH_MSG_KDC_REQUEST: if ((cp = krb4_print_hdr(cp)) == NULL) return; cp += 4; /* ctime */ TCHECK2(cp, 0); printf(" %dmin ", *cp++ * 5); TCHECK2(cp, 0); PRINT; TCHECK2(cp, 0); putchar('.'); PRINT; break; case AUTH_MSG_APPL_REQUEST: cp += 2; TCHECK2(cp, 0); printf("v%d ", *cp++); TCHECK2(cp, 0); PRINT; TCHECK2(cp, 0); printf(" (%d)", *cp++); TCHECK2(cp, 0); printf(" (%d)", *cp); TCHECK2(cp, 0); break; case AUTH_MSG_KDC_REPLY: if ((cp = krb4_print_hdr(cp)) == NULL) return; cp += 10; /* timestamp + n + exp + kvno */ TCHECK2(cp, 0); len = KTOHSP(kp, cp); printf(" (%d)", len); TCHECK2(cp, 0); break; case AUTH_MSG_ERR_REPLY: if ((cp = krb4_print_hdr(cp)) == NULL) return; cp += 4; /* timestamp */ TCHECK2(cp, 0); printf(" %s ", tok2str(kerr2str, NULL, KTOHSP(kp, cp))); cp += 4; TCHECK2(cp, 0); PRINT; break; default: fputs("(unknown)", stdout); break; } return; trunc: fputs(tstr, stdout); }
static void krb4_print(packetbody_t cp) { __capability const struct krb *kp; u_char type; u_short len; #define PRINT if ((cp = c_print(cp, snapend)) == NULL) goto trunc /* True if struct krb is little endian */ #define IS_LENDIAN(kp) (((kp)->type & 0x01) != 0) #define KTOHSP(kp, cp) (IS_LENDIAN(kp) ? EXTRACT_LE_16BITS(cp) : EXTRACT_16BITS(cp)) kp = (__capability const struct krb *)cp; if (!PACKET_HAS_ELEMENT(kp, type)) { fputs(tstr, stdout); return; } type = kp->type & (0xFF << 1); printf(" %s %s: ", IS_LENDIAN(kp) ? "le" : "be", tok2str(type2str, NULL, type)); switch (type) { case AUTH_MSG_KDC_REQUEST: if ((cp = krb4_print_hdr(cp)) == NULL) return; cp += 4; /* ctime */ PACKET_HAS_ONE_OR_TRUNC(cp); printf(" %dmin ", *cp++ * 5); PRINT; putchar('.'); PRINT; break; case AUTH_MSG_APPL_REQUEST: cp += 2; PACKET_HAS_ONE_OR_TRUNC(cp); printf("v%d ", *cp++); PRINT; PACKET_HAS_ONE_OR_TRUNC(cp); printf(" (%d)", *cp++); PACKET_HAS_ONE_OR_TRUNC(cp); printf(" (%d)", *cp); break; case AUTH_MSG_KDC_REPLY: if ((cp = krb4_print_hdr(cp)) == NULL) return; cp += 10; /* timestamp + n + exp + kvno */ PACKET_HAS_SPACE_OR_TRUNC(cp, sizeof(short)); len = KTOHSP(kp, cp); printf(" (%d)", len); break; case AUTH_MSG_ERR_REPLY: if ((cp = krb4_print_hdr(cp)) == NULL) return; cp += 4; /* timestamp */ PACKET_HAS_SPACE_OR_TRUNC(cp, sizeof(short)); printf(" %s ", tok2str(kerr2str, NULL, KTOHSP(kp, cp))); cp += 4; PRINT; break; default: fputs("(unknown)", stdout); break; } return; trunc: fputs(tstr, stdout); }