+ return (hdrlen);
+}
+
+/*
+ * ATM signalling.
+ */
+static 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(const u_char *p, int caplen)
+{
+ bpf_u_int32 call_ref;
+
+ if (caplen < PROTO_POS) {
+ printf("[|atm]");
+ return;
+ }
+ if (p[PROTO_POS] == Q2931) {
+ /*
+ * protocol:Q.2931 for User to Network Interface
+ * (UNI 3.1) signalling
+ */
+ printf("Q.2931");
+ if (caplen < MSG_TYPE_POS) {
+ printf(" [|atm]");
+ return;
+ }
+ printf(":%s ",
+ tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS]));
+
+ if (caplen < CALL_REF_POS+3) {
+ printf("[|atm]");
+ return;
+ }
+ call_ref = EXTRACT_24BITS(&p[CALL_REF_POS]);
+ printf("CALL_REF:0x%06x", call_ref);
+ } else {
+ /* SCCOP with some unknown protocol atop it */
+ printf("SSCOP, proto %d ", p[PROTO_POS]);
+ }
+}
+
+/*
+ * Print an ATM PDU (such as an AAL5 PDU).
+ */
+void
+atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
+ u_int caplen)
+{
+ if (eflag)
+ printf("VPI:%u VCI:%u ", vpi, vci);
+
+ if (vpi == 0) {
+ switch (vci) {
+
+ case PPC:
+ sig_print(p, caplen);
+ return;
+
+ case BCC:
+ printf("broadcast sig: ");
+ return;
+
+ case OAMF4SC: /* fall through */
+ case OAMF4EC:
+ oam_print(p, length);
+ return;
+
+ case METAC:
+ printf("meta: ");
+ return;
+
+ case ILMIC:
+ printf("ilmi: ");
+ snmp_print(p, length);
+ return;
+ }
+ }
+
+ switch (traftype) {
+
+ case ATM_LLC:
+ default:
+ /*
+ * Assumes traffic is LLC if unknown.
+ */
+ atm_llc_print(p, length, caplen);
+ break;
+
+ case ATM_LANE:
+ lane_print(p, length, caplen);
+ break;
+ }
+}
+
+int
+oam_print (const u_char *p, u_int length) {
+
+ u_int16_t cell_header, cell_type, func_type,vpi,vci,payload,clp;
+
+ cell_header = EXTRACT_32BITS(p);
+ cell_type = ((*(p+4))>>4) & 0x0f;
+ func_type = *(p) & 0x0f;
+
+ vpi = (cell_header>>20)&0xff;
+ vci = (cell_header>>4)&0xffff;
+ payload = (cell_header>>1)&0x7;
+ clp = cell_header&0x1;
+
+ switch (vci) {
+ case OAMF4SC:
+ printf("OAM F4 (segment), ");
+ break;
+ case OAMF4EC:
+ printf("OAM F4 (end), ");
+ break;
+ default:
+ printf("OAM F5, ");
+ break;
+ }
+
+ if (eflag)
+ printf("vpi %u, vci %u, payload %u, clp %u, ",vpi,vci,payload,clp);
+
+ printf("cell-type %s (%u)",
+ tok2str(oam_celltype_values, "unknown", cell_type),
+ cell_type);
+
+ if (oam_functype_values[cell_type] == NULL)
+ printf(", func-type unknown (%u)", func_type);
+ else
+ printf(", func-type %s (%u)",
+ bittok2str(oam_functype_values[cell_type],"none",func_type),
+ func_type);
+
+ printf(", length %u",length);
+ return 1;