+ atm_llc_print(ndo, p, length, caplen);
+ return (hdrlen);
+}
+
+/*
+ * ATM signalling.
+ */
+static const struct tok msgtype2str[] = {
+ { CALL_PROCEED, "Call_proceeding" },
+ { CONNECT, "Connect" },
+ { CONNECT_ACK, "Connect_ack" },
+ { SETUP, "Setup" },
+ { RELEASE, "Release" },
+ { RELEASE_DONE, "Release_complete" },
+ { RESTART, "Restart" },
+ { RESTART_ACK, "Restart_ack" },
+ { STATUS, "Status" },
+ { STATUS_ENQ, "Status_enquiry" },
+ { ADD_PARTY, "Add_party" },
+ { ADD_PARTY_ACK, "Add_party_ack" },
+ { ADD_PARTY_REJ, "Add_party_reject" },
+ { DROP_PARTY, "Drop_party" },
+ { DROP_PARTY_ACK, "Drop_party_ack" },
+ { 0, NULL }
+};
+
+static void
+sig_print(netdissect_options *ndo,
+ const u_char *p, int caplen)
+{
+ uint32_t call_ref;
+
+ if (caplen < PROTO_POS) {
+ ND_PRINT((ndo, "%s", tstr));
+ return;
+ }
+ if (p[PROTO_POS] == Q2931) {
+ /*
+ * protocol:Q.2931 for User to Network Interface
+ * (UNI 3.1) signalling
+ */
+ ND_PRINT((ndo, "Q.2931"));
+ if (caplen < MSG_TYPE_POS) {
+ ND_PRINT((ndo, " %s", tstr));
+ return;
+ }
+ ND_PRINT((ndo, ":%s ",
+ tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS])));
+
+ /*
+ * The call reference comes before the message type,
+ * so if we know we have the message type, which we
+ * do from the caplen test above, we also know we have
+ * the call reference.
+ */
+ call_ref = EXTRACT_24BITS(&p[CALL_REF_POS]);
+ ND_PRINT((ndo, "CALL_REF:0x%06x", call_ref));
+ } else {
+ /* SCCOP with some unknown protocol atop it */
+ ND_PRINT((ndo, "SSCOP, proto %d ", p[PROTO_POS]));
+ }
+}
+
+/*
+ * Print an ATM PDU (such as an AAL5 PDU).
+ */
+void
+atm_print(netdissect_options *ndo,
+ u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
+ u_int caplen)
+{
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "VPI:%u VCI:%u ", vpi, vci));
+
+ if (vpi == 0) {
+ switch (vci) {
+
+ case VCI_PPC:
+ sig_print(ndo, p, caplen);
+ return;
+
+ case VCI_BCC:
+ ND_PRINT((ndo, "broadcast sig: "));
+ return;
+
+ case VCI_OAMF4SC: /* fall through */
+ case VCI_OAMF4EC:
+ oam_print(ndo, p, length, ATM_OAM_HEC);
+ return;
+
+ case VCI_METAC:
+ ND_PRINT((ndo, "meta: "));
+ return;
+
+ case VCI_ILMIC:
+ ND_PRINT((ndo, "ilmi: "));
+ snmp_print(ndo, p, length);
+ return;
+ }
+ }
+
+ switch (traftype) {
+
+ case ATM_LLC:
+ default:
+ /*
+ * Assumes traffic is LLC if unknown.
+ */
+ atm_llc_print(ndo, p, length, caplen);
+ break;
+
+ case ATM_LANE:
+ lane_print(ndo, p, length, caplen);
+ break;
+ }
+}
+
+struct oam_fm_loopback_t {
+ uint8_t loopback_indicator;
+ uint8_t correlation_tag[4];
+ uint8_t loopback_id[12];
+ uint8_t source_id[12];
+ uint8_t unused[16];
+};
+
+struct oam_fm_ais_rdi_t {
+ uint8_t failure_type;
+ uint8_t failure_location[16];
+ uint8_t unused[28];
+};
+
+int
+oam_print (netdissect_options *ndo,
+ const u_char *p, u_int length, u_int hec) {
+
+ uint32_t cell_header;
+ uint16_t vpi, vci, cksum, cksum_shouldbe, idx;
+ uint8_t cell_type, func_type, payload, clp;
+
+ union {
+ const struct oam_fm_loopback_t *oam_fm_loopback;
+ const struct oam_fm_ais_rdi_t *oam_fm_ais_rdi;
+ } oam_ptr;
+
+
+ cell_header = EXTRACT_32BITS(p+hec);
+ cell_type = ((*(p+ATM_HDR_LEN_NOHEC+hec))>>4) & 0x0f;
+ func_type = (*(p+ATM_HDR_LEN_NOHEC+hec)) & 0x0f;
+
+ vpi = (cell_header>>20)&0xff;
+ vci = (cell_header>>4)&0xffff;
+ payload = (cell_header>>1)&0x7;
+ clp = cell_header&0x1;
+
+ ND_PRINT((ndo, "%s, vpi %u, vci %u, payload [ %s ], clp %u, length %u",
+ tok2str(oam_f_values, "OAM F5", vci),
+ vpi, vci,
+ tok2str(atm_pty_values, "Unknown", payload),
+ clp, length));
+
+ if (!ndo->ndo_vflag) {
+ return 1;
+ }
+
+ ND_PRINT((ndo, "\n\tcell-type %s (%u)",
+ tok2str(oam_celltype_values, "unknown", cell_type),
+ cell_type));
+
+ if (oam_functype_values[cell_type] == NULL)
+ ND_PRINT((ndo, ", func-type unknown (%u)", func_type));
+ else
+ ND_PRINT((ndo, ", func-type %s (%u)",
+ tok2str(oam_functype_values[cell_type],"none",func_type),
+ func_type));
+
+ p += ATM_HDR_LEN_NOHEC + hec;
+
+ switch (cell_type << 4 | func_type) {
+ case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_LOOPBACK):
+ oam_ptr.oam_fm_loopback = (const struct oam_fm_loopback_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN);
+ ND_PRINT((ndo, "\n\tLoopback-Indicator %s, Correlation-Tag 0x%08x",
+ tok2str(oam_fm_loopback_indicator_values,
+ "Unknown",
+ oam_ptr.oam_fm_loopback->loopback_indicator & OAM_FM_LOOPBACK_INDICATOR_MASK),
+ EXTRACT_32BITS(&oam_ptr.oam_fm_loopback->correlation_tag)));
+ ND_PRINT((ndo, "\n\tLocation-ID "));
+ for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->loopback_id); idx++) {
+ if (idx % 2) {
+ ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->loopback_id[idx])));
+ }
+ }
+ ND_PRINT((ndo, "\n\tSource-ID "));
+ for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->source_id); idx++) {
+ if (idx % 2) {
+ ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->source_id[idx])));
+ }
+ }
+ break;
+
+ case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_AIS):
+ case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_RDI):
+ oam_ptr.oam_fm_ais_rdi = (const struct oam_fm_ais_rdi_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN);
+ ND_PRINT((ndo, "\n\tFailure-type 0x%02x", oam_ptr.oam_fm_ais_rdi->failure_type));
+ ND_PRINT((ndo, "\n\tLocation-ID "));
+ for (idx = 0; idx < sizeof(oam_ptr.oam_fm_ais_rdi->failure_location); idx++) {
+ if (idx % 2) {
+ ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_ais_rdi->failure_location[idx])));
+ }
+ }
+ break;
+
+ case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_CONTCHECK):
+ /* FIXME */
+ break;
+
+ default:
+ break;
+ }
+
+ /* crc10 checksum verification */
+ cksum = EXTRACT_16BITS(p + OAM_CELLTYPE_FUNCTYPE_LEN + OAM_FUNCTION_SPECIFIC_LEN)
+ & OAM_CRC10_MASK;
+ cksum_shouldbe = verify_crc10_cksum(0, p, OAM_PAYLOAD_LEN);
+
+ ND_PRINT((ndo, "\n\tcksum 0x%03x (%scorrect)",
+ cksum,
+ cksum_shouldbe == 0 ? "" : "in"));
+
+ return 1;