static void atmarp_addr_print(netdissect_options *ndo, const u_char *ha, u_int ha_len, const u_char *srca, u_int srca_len) { if (ha_len == 0) ND_PRINT((ndo, "<No address>")); else { ND_PRINT((ndo, "%s", linkaddr_string(ha, LINKADDR_ATM, ha_len))); if (srca_len != 0) ND_PRINT((ndo, ",%s", linkaddr_string(srca, LINKADDR_ATM, srca_len))); } }
static void print_long_pos_vector(netdissect_options *ndo, const u_char *bp) { u_int32_t lat, lon; ND_PRINT((ndo, "GN_ADDR:%s ", linkaddr_string (ndo, bp, 0, GEONET_ADDR_LEN))); lat = EXTRACT_32BITS(bp+12); ND_PRINT((ndo, "lat:%d ", lat)); lon = EXTRACT_32BITS(bp+16); ND_PRINT((ndo, "lon:%d", lon)); }
static inline void ap1394_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int length) { register const struct firewire_header *fp; u_int16_t firewire_type; fp = (const struct firewire_header *)bp; ND_PRINT((ndo, "%s > %s", linkaddr_string(ndo, fp->firewire_dhost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN), linkaddr_string(ndo, fp->firewire_shost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN))); firewire_type = EXTRACT_16BITS(&fp->firewire_type); if (!ndo->ndo_qflag) { ND_PRINT((ndo, ", ethertype %s (0x%04x)", tok2str(ethertype_values,"Unknown", firewire_type), firewire_type)); } else { ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", firewire_type))); } ND_PRINT((ndo, ", length %u: ", length)); }
static inline void ap1394_hdr_print(register const u_char *bp, u_int length) { register const struct firewire_header *fp; u_int16_t firewire_type; fp = (const struct firewire_header *)bp; (void)printf("%s > %s", linkaddr_string(fp->firewire_dhost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN), linkaddr_string(fp->firewire_shost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN)); firewire_type = EXTRACT_16BITS(&fp->firewire_type); if (!qflag) { (void)printf(", ethertype %s (0x%04x)", tok2str(ethertype_values,"Unknown", firewire_type), firewire_type); } else { (void)printf(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", firewire_type)); } (void)printf(", length %u: ", length); }
static int print_long_pos_vector(netdissect_options *ndo, const u_char *bp) { uint32_t lat, lon; ND_PRINT((ndo, "GN_ADDR:%s ", linkaddr_string (ndo, bp, 0, GEONET_ADDR_LEN))); if (!ND_TTEST2(*(bp+12), 8)) return (-1); lat = EXTRACT_32BITS(bp+12); ND_PRINT((ndo, "lat:%d ", lat)); lon = EXTRACT_32BITS(bp+16); ND_PRINT((ndo, "lon:%d", lon)); return (0); }
void arp_print(netdissect_options *ndo, const u_char *bp, u_int length, u_int caplen) { const struct arp_pkthdr *ap; u_short pro, hrd, op, linkaddr; ap = (const struct arp_pkthdr *)bp; ND_TCHECK(*ap); hrd = HRD(ap); pro = PRO(ap); op = OP(ap); /* if its ATM then call the ATM ARP printer for Frame-relay ARP most of the fields are similar to Ethernet so overload the Ethernet Printer and set the linkaddr type for linkaddr_string() accordingly */ switch(hrd) { case ARPHRD_ATM2225: atmarp_print(ndo, bp, length, caplen); return; case ARPHRD_FRELAY: linkaddr = LINKADDR_FRELAY; break; default: linkaddr = LINKADDR_ETHER; break; } if (!ND_TTEST2(*ar_tpa(ap), PROTO_LEN(ap))) { ND_PRINT((ndo, "[|ARP]")); ND_DEFAULTPRINT((const u_char *)ap, length); return; } if (!ndo->ndo_eflag) { ND_PRINT((ndo, "ARP, ")); } /* print hardware type/len and proto type/len */ if ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) || PROTO_LEN(ap) != 4 || HRD_LEN(ap) == 0 || ndo->ndo_vflag) { ND_PRINT((ndo, "%s (len %u), %s (len %u)", tok2str(arphrd_values, "Unknown Hardware (%u)", hrd), HRD_LEN(ap), tok2str(ethertype_values, "Unknown Protocol (0x%04x)", pro), PROTO_LEN(ap))); /* don't know know about the address formats */ if (!ndo->ndo_vflag) { goto out; } } /* print operation */ printf("%s%s ", ndo->ndo_vflag ? ", " : "", tok2str(arpop_values, "Unknown (%u)", op)); switch (op) { case ARPOP_REQUEST: ND_PRINT((ndo, "who-has %s", ipaddr_string(TPA(ap)))); if (memcmp((const char *)ezero, (const char *)THA(ap), HRD_LEN(ap)) != 0) ND_PRINT((ndo, " (%s)", linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)))); ND_PRINT((ndo, " tell %s", ipaddr_string(SPA(ap)))); break; case ARPOP_REPLY: ND_PRINT((ndo, "%s is-at %s", ipaddr_string(SPA(ap)), linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap)))); break; case ARPOP_REVREQUEST: ND_PRINT((ndo, "who-is %s tell %s", linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)), linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap)))); break; case ARPOP_REVREPLY: ND_PRINT((ndo, "%s at %s", linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)), ipaddr_string(TPA(ap)))); break; case ARPOP_INVREQUEST: ND_PRINT((ndo, "who-is %s tell %s", linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)), linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap)))); break; case ARPOP_INVREPLY: ND_PRINT((ndo,"%s at %s", linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)), ipaddr_string(TPA(ap)))); break; default: ND_DEFAULTPRINT((const u_char *)ap, caplen); return; } out: ND_PRINT((ndo, ", length %u", length)); return; trunc: ND_PRINT((ndo, "[|ARP]")); }
static const char * fwaddr_string(netdissect_options *ndo, const u_char *addr) { return (linkaddr_string(ndo, addr, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN)); }
void ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len) { const u_char *ep = cp + len; uint8_t version; ND_PRINT((ndo, "AHCP")); if (len < 2) goto invalid; /* Magic */ ND_TCHECK2(*cp, 1); if (*cp != AHCP_MAGIC_NUMBER) goto invalid; cp += 1; /* Version */ ND_TCHECK2(*cp, 1); version = *cp; cp += 1; switch (version) { case AHCP_VERSION_1: { ND_PRINT((ndo, " Version 1")); if (len < AHCP1_HEADER_FIX_LEN) goto invalid; if (!ndo->ndo_vflag) { ND_TCHECK2(*cp, AHCP1_HEADER_FIX_LEN - 2); cp += AHCP1_HEADER_FIX_LEN - 2; } else { /* Hopcount */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, "\n\tHopcount %u", *cp)); cp += 1; /* Original Hopcount */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, ", Original Hopcount %u", *cp)); cp += 1; /* Nonce */ ND_TCHECK2(*cp, 4); ND_PRINT((ndo, ", Nonce 0x%08x", EXTRACT_32BITS(cp))); cp += 4; /* Source Id */ ND_TCHECK2(*cp, 8); ND_PRINT((ndo, ", Source Id %s", linkaddr_string(ndo, cp, 0, 8))); cp += 8; /* Destination Id */ ND_TCHECK2(*cp, 8); ND_PRINT((ndo, ", Destination Id %s", linkaddr_string(ndo, cp, 0, 8))); cp += 8; } /* Body */ ahcp1_body_print(ndo, cp, ep); break; } default: ND_PRINT((ndo, " Version %u (unknown)", version)); break; } return; invalid: ND_PRINT((ndo, "%s", istr)); ND_TCHECK2(*cp, ep - cp); return; trunc: ND_PRINT((ndo, "%s", tstr)); }
void ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len) { const u_char *ep = ndo->ndo_snapend; uint8_t version; ndo->ndo_protocol = "ahcp"; ND_PRINT("AHCP"); if (len < 2) goto invalid; /* Magic */ ND_TCHECK_1(cp); if (EXTRACT_U_1(cp) != AHCP_MAGIC_NUMBER) goto invalid; cp += 1; /* Version */ ND_TCHECK_1(cp); version = EXTRACT_U_1(cp); cp += 1; switch (version) { case AHCP_VERSION_1: { ND_PRINT(" Version 1"); if (len < AHCP1_HEADER_FIX_LEN) goto invalid; if (!ndo->ndo_vflag) { ND_TCHECK_LEN(cp, AHCP1_HEADER_FIX_LEN - 2); cp += AHCP1_HEADER_FIX_LEN - 2; } else { /* Hopcount */ ND_TCHECK_1(cp); ND_PRINT("\n\tHopcount %u", EXTRACT_U_1(cp)); cp += 1; /* Original Hopcount */ ND_TCHECK_1(cp); ND_PRINT(", Original Hopcount %u", EXTRACT_U_1(cp)); cp += 1; /* Nonce */ ND_TCHECK_4(cp); ND_PRINT(", Nonce 0x%08x", EXTRACT_BE_U_4(cp)); cp += 4; /* Source Id */ ND_TCHECK_8(cp); ND_PRINT(", Source Id %s", linkaddr_string(ndo, cp, 0, 8)); cp += 8; /* Destination Id */ ND_TCHECK_8(cp); ND_PRINT(", Destination Id %s", linkaddr_string(ndo, cp, 0, 8)); cp += 8; } /* Body */ ahcp1_body_print(ndo, cp, ep); break; } default: ND_PRINT(" Version %u (unknown)", version); break; } return; invalid: ND_PRINT("%s", istr); ND_TCHECK_LEN(cp, ep - cp); return; trunc: nd_print_trunc(ndo); }