/* * Print AppleTalk LLAP packets. */ u_int llap_print(netdissect_options *ndo, register const u_char *bp, u_int length) { register const struct LAP *lp; register const struct atDDP *dp; register const struct atShortDDP *sdp; u_short snet; u_int hdrlen; if (length < sizeof(*lp)) { ND_PRINT((ndo, " [|llap %u]", length)); return (length); } lp = (const struct LAP *)bp; bp += sizeof(*lp); length -= sizeof(*lp); hdrlen = sizeof(*lp); switch (lp->type) { case lapShortDDP: if (length < ddpSSize) { ND_PRINT((ndo, " [|sddp %u]", length)); return (length); } sdp = (const struct atShortDDP *)bp; ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, 0, lp->src), ddpskt_string(ndo, sdp->srcSkt))); ND_PRINT((ndo, " > %s.%s:", ataddr_string(ndo, 0, lp->dst), ddpskt_string(ndo, sdp->dstSkt))); bp += ddpSSize; length -= ddpSSize; hdrlen += ddpSSize; ddp_print(ndo, bp, length, sdp->type, 0, lp->src, sdp->srcSkt); break; case lapDDP: if (length < ddpSize) { ND_PRINT((ndo, " [|ddp %u]", length)); return (length); } dp = (const struct atDDP *)bp; snet = EXTRACT_16BITS(&dp->srcNet); ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, snet, dp->srcNode), ddpskt_string(ndo, dp->srcSkt))); ND_PRINT((ndo, " > %s.%s:", ataddr_string(ndo, EXTRACT_16BITS(&dp->dstNet), dp->dstNode), ddpskt_string(ndo, dp->dstSkt))); bp += ddpSize; length -= ddpSize; hdrlen += ddpSize; ddp_print(ndo, bp, length, dp->type, snet, dp->srcNode, dp->srcSkt); break; #ifdef notdef case lapKLAP: klap_print(bp, length); break; #endif default: ND_PRINT((ndo, "%d > %d at-lap#%d %u", lp->src, lp->dst, lp->type, length)); break; } return (hdrlen); }
/* * Print AppleTalk LLAP packets. */ u_int llap_print(register const u_char *bp, u_int length) { register const struct LAP *lp; register const struct atDDP *dp; register const struct atShortDDP *sdp; u_short snet; u_int hdrlen; /* * Our packet is on a 4-byte boundary, as we're either called * directly from a top-level link-layer printer (ltalk_if_print) * or from the UDP printer. The LLAP+DDP header is a multiple * of 4 bytes in length, so the DDP payload is also on a 4-byte * boundary, and we don't need to align it before calling * "ddp_print()". */ lp = (const struct LAP *)bp; bp += sizeof(*lp); length -= sizeof(*lp); hdrlen = sizeof(*lp); switch (lp->type) { case lapShortDDP: if (length < ddpSSize) { (void)printf(" [|sddp %d]", length); return (length); } sdp = (const struct atShortDDP *)bp; printf("%s.%s", ataddr_string(0, lp->src), ddpskt_string(sdp->srcSkt)); printf(" > %s.%s:", ataddr_string(0, lp->dst), ddpskt_string(sdp->dstSkt)); bp += ddpSSize; length -= ddpSSize; hdrlen += ddpSSize; ddp_print(bp, length, sdp->type, 0, lp->src, sdp->srcSkt); break; case lapDDP: if (length < ddpSize) { (void)printf(" [|ddp %d]", length); return (length); } dp = (const struct atDDP *)bp; snet = EXTRACT_16BITS(&dp->srcNet); printf("%s.%s", ataddr_string(snet, dp->srcNode), ddpskt_string(dp->srcSkt)); printf(" > %s.%s:", ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode), ddpskt_string(dp->dstSkt)); bp += ddpSize; length -= ddpSize; hdrlen += ddpSize; ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt); break; #ifdef notdef case lapKLAP: klap_print(bp, length); break; #endif default: printf("%d > %d at-lap#%d %d", lp->src, lp->dst, lp->type, length); break; } return (hdrlen); }
/* * Print AppleTalk LLAP packets. */ u_int llap_print(netdissect_options *ndo, const u_char *bp, u_int length) { const struct LAP *lp; const struct atDDP *dp; const struct atShortDDP *sdp; u_short snet; u_int hdrlen; ndo->ndo_protocol = "llap"; if (length < sizeof(*lp)) { ND_PRINT(" [|llap %u]", length); return (length); } if (!ND_TTEST_LEN(bp, sizeof(*lp))) { nd_print_trunc(ndo); return (0); /* cut short by the snapshot length */ } lp = (const struct LAP *)bp; bp += sizeof(*lp); length -= sizeof(*lp); hdrlen = sizeof(*lp); switch (EXTRACT_U_1(lp->type)) { case lapShortDDP: if (length < ddpSSize) { ND_PRINT(" [|sddp %u]", length); return (length); } if (!ND_TTEST_LEN(bp, ddpSSize)) { ND_PRINT(" [|sddp]"); return (0); /* cut short by the snapshot length */ } sdp = (const struct atShortDDP *)bp; ND_PRINT("%s.%s", ataddr_string(ndo, 0, EXTRACT_U_1(lp->src)), ddpskt_string(ndo, EXTRACT_U_1(sdp->srcSkt))); ND_PRINT(" > %s.%s:", ataddr_string(ndo, 0, EXTRACT_U_1(lp->dst)), ddpskt_string(ndo, EXTRACT_U_1(sdp->dstSkt))); bp += ddpSSize; length -= ddpSSize; hdrlen += ddpSSize; ddp_print(ndo, bp, length, EXTRACT_U_1(sdp->type), 0, EXTRACT_U_1(lp->src), EXTRACT_U_1(sdp->srcSkt)); break; case lapDDP: if (length < ddpSize) { ND_PRINT(" [|ddp %u]", length); return (length); } if (!ND_TTEST_LEN(bp, ddpSize)) { ND_PRINT(" [|ddp]"); return (0); /* cut short by the snapshot length */ } dp = (const struct atDDP *)bp; snet = EXTRACT_BE_U_2(dp->srcNet); ND_PRINT("%s.%s", ataddr_string(ndo, snet, EXTRACT_U_1(dp->srcNode)), ddpskt_string(ndo, EXTRACT_U_1(dp->srcSkt))); ND_PRINT(" > %s.%s:", ataddr_string(ndo, EXTRACT_BE_U_2(dp->dstNet), EXTRACT_U_1(dp->dstNode)), ddpskt_string(ndo, EXTRACT_U_1(dp->dstSkt))); bp += ddpSize; length -= ddpSize; hdrlen += ddpSize; ddp_print(ndo, bp, length, EXTRACT_U_1(dp->type), snet, EXTRACT_U_1(dp->srcNode), EXTRACT_U_1(dp->srcSkt)); break; #ifdef notdef case lapKLAP: klap_print(bp, length); break; #endif default: ND_PRINT("%u > %u at-lap#%u %u", EXTRACT_U_1(lp->src), EXTRACT_U_1(lp->dst), EXTRACT_U_1(lp->type), length); break; } return (hdrlen); }