+static const struct tok arpop_values[] = {
+ { ARPOP_REQUEST, "Request" },
+ { ARPOP_REPLY, "Reply" },
+ { ARPOP_REVREQUEST, "Reverse Request" },
+ { ARPOP_REVREPLY, "Reverse Reply" },
+ { ARPOP_INVREQUEST, "Inverse Request" },
+ { ARPOP_INVREPLY, "Inverse Reply" },
+ { ARPOP_NAK, "NACK Reply" },
+ { 0, NULL }
+};
+
+static const struct tok arphrd_values[] = {
+ { ARPHRD_ETHER, "Ethernet" },
+ { ARPHRD_IEEE802, "TokenRing" },
+ { ARPHRD_ARCNET, "ArcNet" },
+ { ARPHRD_FRELAY, "FrameRelay" },
+ { ARPHRD_STRIP, "Strip" },
+ { ARPHRD_IEEE1394, "IEEE 1394" },
+ { ARPHRD_ATM2225, "ATM" },
+ { ARPHRD_INFINIBAND, "InfiniBand" },
+ { 0, NULL }
+};
+
+/*
+ * ATM Address Resolution Protocol.
+ *
+ * See RFC 2225 for protocol description. ATMARP packets are similar
+ * to ARP packets, except that there are no length fields for the
+ * protocol address - instead, there are type/length fields for
+ * the ATM number and subaddress - and the hardware addresses consist
+ * of an ATM number and an ATM subaddress.
+ */
+struct atmarp_pkthdr {
+ nd_uint16_t aar_hrd; /* format of hardware address */
+ nd_uint16_t aar_pro; /* format of protocol address */
+ nd_uint8_t aar_shtl; /* length of source ATM number */
+ nd_uint8_t aar_sstl; /* length of source ATM subaddress */
+#define ATMARP_IS_E164 0x40 /* bit in type/length for E.164 format */
+#define ATMARP_LEN_MASK 0x3F /* length of {sub}address in type/length */
+ nd_uint16_t aar_op; /* same as regular ARP */
+ nd_uint8_t aar_spln; /* length of source protocol address */
+ nd_uint8_t aar_thtl; /* length of target ATM number */
+ nd_uint8_t aar_tstl; /* length of target ATM subaddress */
+ nd_uint8_t aar_tpln; /* length of target protocol address */
+/*
+ * The remaining fields are variable in size,
+ * according to the sizes above.
+ */
+#ifdef COMMENT_ONLY
+ nd_byte aar_sha[]; /* source ATM number */
+ nd_byte aar_ssa[]; /* source ATM subaddress */
+ nd_byte aar_spa[]; /* sender protocol address */
+ nd_byte aar_tha[]; /* target ATM number */
+ nd_byte aar_tsa[]; /* target ATM subaddress */
+ nd_byte aar_tpa[]; /* target protocol address */
+#endif
+
+#define ATMHRD(ap) GET_BE_U_2((ap)->aar_hrd)
+#define ATMSHRD_LEN(ap) (GET_U_1((ap)->aar_shtl) & ATMARP_LEN_MASK)
+#define ATMSSLN(ap) (GET_U_1((ap)->aar_sstl) & ATMARP_LEN_MASK)
+#define ATMSPROTO_LEN(ap) GET_U_1((ap)->aar_spln)
+#define ATMOP(ap) GET_BE_U_2((ap)->aar_op)
+#define ATMPRO(ap) GET_BE_U_2((ap)->aar_pro)
+#define ATMTHRD_LEN(ap) (GET_U_1((ap)->aar_thtl) & ATMARP_LEN_MASK)
+#define ATMTSLN(ap) (GET_U_1((ap)->aar_tstl) & ATMARP_LEN_MASK)
+#define ATMTPROTO_LEN(ap) GET_U_1((ap)->aar_tpln)
+#define aar_sha(ap) ((const u_char *)((ap)+1))
+#define aar_ssa(ap) (aar_sha(ap) + ATMSHRD_LEN(ap))
+#define aar_spa(ap) (aar_ssa(ap) + ATMSSLN(ap))
+#define aar_tha(ap) (aar_spa(ap) + ATMSPROTO_LEN(ap))
+#define aar_tsa(ap) (aar_tha(ap) + ATMTHRD_LEN(ap))
+#define aar_tpa(ap) (aar_tsa(ap) + ATMTSLN(ap))
+};
+
+#define ATMSHA(ap) (aar_sha(ap))
+#define ATMSSA(ap) (aar_ssa(ap))
+#define ATMSPA(ap) (aar_spa(ap))
+#define ATMTHA(ap) (aar_tha(ap))
+#define ATMTSA(ap) (aar_tsa(ap))
+#define ATMTPA(ap) (aar_tpa(ap))
+
+static int
+isnonzero(netdissect_options *ndo, const u_char *a, size_t len)
+{
+ while (len != 0) {
+ if (GET_U_1(a) != 0)
+ return (1);
+ a++;
+ len--;
+ }
+ return (0);
+}
+
+static void
+tpaddr_print_ip(netdissect_options *ndo,
+ const struct arp_pkthdr *ap, u_short pro)
+{
+ if (pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL)
+ ND_PRINT("<wrong proto type>");
+ else if (PROTO_LEN(ap) != 4)
+ ND_PRINT("<wrong len>");
+ else
+ ND_PRINT("%s", GET_IPADDR_STRING(TPA(ap)));
+}
+
+static void
+spaddr_print_ip(netdissect_options *ndo,
+ const struct arp_pkthdr *ap, u_short pro)
+{
+ if (pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL)
+ ND_PRINT("<wrong proto type>");
+ else if (PROTO_LEN(ap) != 4)
+ ND_PRINT("<wrong len>");
+ else
+ ND_PRINT("%s", GET_IPADDR_STRING(SPA(ap)));
+}
+
+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("<No address>");
+ else {
+ ND_PRINT("%s", GET_LINKADDR_STRING(ha, LINKADDR_ATM, ha_len));
+ if (srca_len != 0)
+ ND_PRINT(",%s",
+ GET_LINKADDR_STRING(srca, LINKADDR_ATM, srca_len));
+ }
+}
+
+static void
+atmarp_tpaddr_print(netdissect_options *ndo,
+ const struct atmarp_pkthdr *ap, u_short pro)
+{
+ if (pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL)
+ ND_PRINT("<wrong proto type>");
+ else if (ATMTPROTO_LEN(ap) != 4)
+ ND_PRINT("<wrong tplen>");
+ else
+ ND_PRINT("%s", GET_IPADDR_STRING(ATMTPA(ap)));
+}
+
+static void
+atmarp_spaddr_print(netdissect_options *ndo,
+ const struct atmarp_pkthdr *ap, u_short pro)
+{
+ if (pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL)
+ ND_PRINT("<wrong proto type>");
+ else if (ATMSPROTO_LEN(ap) != 4)
+ ND_PRINT("<wrong splen>");
+ else
+ ND_PRINT("%s", GET_IPADDR_STRING(ATMSPA(ap)));
+}
+
+static void
+atmarp_print(netdissect_options *ndo,
+ const u_char *bp, u_int length, u_int caplen)