From ee68aa36460d7efeca48747f33b7f2adc0900bfb Mon Sep 17 00:00:00 2001 From: Francois-Xavier Le Bail Date: Sat, 16 Jun 2018 17:23:21 +0200 Subject: Use the new GET_ macros instead of the EXTRACT_ ones The exceptions are currently: Some EXTRACT_ in print-juniper.c, not used on packet buffer pointer. An EXTRACT_BE_U_3 in addrtoname.c, not always used on packet buffer pointer. --- print-fr.c | 106 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 53 insertions(+), 53 deletions(-) (limited to 'print-fr.c') diff --git a/print-fr.c b/print-fr.c index 8565dae5..5a736547 100644 --- a/print-fr.c +++ b/print-fr.c @@ -104,18 +104,18 @@ static int parse_q922_header(netdissect_options *ndo, { if (!ND_TTEST_1(p) || length < 1) return -1; - if ((EXTRACT_U_1(p) & FR_EA_BIT)) + if ((GET_U_1(p) & FR_EA_BIT)) return 0; if (!ND_TTEST_1(p + 1) || length < 2) return -1; *addr_len = 2; - *dlci = ((EXTRACT_U_1(p) & 0xFC) << 2) | ((EXTRACT_U_1(p + 1) & 0xF0) >> 4); + *dlci = ((GET_U_1(p) & 0xFC) << 2) | ((GET_U_1(p + 1) & 0xF0) >> 4); - *flags = ((EXTRACT_U_1(p) & 0x02) << 24) | /* CR flag */ - ((EXTRACT_U_1(p + 1) & 0x0e) << 16); /* FECN,BECN,DE flags */ + *flags = ((GET_U_1(p) & 0x02) << 24) | /* CR flag */ + ((GET_U_1(p + 1) & 0x0e) << 16); /* FECN,BECN,DE flags */ - if (EXTRACT_U_1(p + 1) & FR_EA_BIT) + if (GET_U_1(p + 1) & FR_EA_BIT) return 1; /* 2-byte Q.922 address */ p += 2; @@ -123,8 +123,8 @@ static int parse_q922_header(netdissect_options *ndo, if (!ND_TTEST_1(p) || length < 1) return -1; (*addr_len)++; /* 3- or 4-byte Q.922 address */ - if ((EXTRACT_U_1(p) & FR_EA_BIT) == 0) { - *dlci = (*dlci << 7) | (EXTRACT_U_1(p) >> 1); + if ((GET_U_1(p) & FR_EA_BIT) == 0) { + *dlci = (*dlci << 7) | (GET_U_1(p) >> 1); (*addr_len)++; /* 4-byte Q.922 address */ p++; length--; @@ -132,12 +132,12 @@ static int parse_q922_header(netdissect_options *ndo, if (!ND_TTEST_1(p) || length < 1) return -1; - if ((EXTRACT_U_1(p) & FR_EA_BIT) == 0) + if ((GET_U_1(p) & FR_EA_BIT) == 0) return 0; /* more than 4 bytes of Q.922 address? */ - *flags = *flags | (EXTRACT_U_1(p) & 0x02); /* SDLC flag */ + *flags = *flags | (GET_U_1(p) & 0x02); /* SDLC flag */ - *dlci = (*dlci << 6) | (EXTRACT_U_1(p) >> 2); + *dlci = (*dlci << 6) | (GET_U_1(p) >> 2); return 1; } @@ -257,7 +257,7 @@ fr_print(netdissect_options *ndo, if (length < addr_len + 1) goto trunc; - if (EXTRACT_U_1(p + addr_len) != LLC_UI && dlci != 0) { + if (GET_U_1(p + addr_len) != LLC_UI && dlci != 0) { /* * Let's figure out if we have Cisco-style encapsulation, * with an Ethernet type (Cisco HDLC type?) following the @@ -265,9 +265,9 @@ fr_print(netdissect_options *ndo, */ if (!ND_TTEST_2(p + addr_len) || length < addr_len + 2) { /* no Ethertype */ - ND_PRINT("UI %02x! ", EXTRACT_U_1(p + addr_len)); + ND_PRINT("UI %02x! ", GET_U_1(p + addr_len)); } else { - extracted_ethertype = EXTRACT_BE_U_2(p + addr_len); + extracted_ethertype = GET_BE_U_2(p + addr_len); if (ndo->ndo_eflag) fr_hdr_print(ndo, length, addr_len, dlci, @@ -279,7 +279,7 @@ fr_print(netdissect_options *ndo, ndo->ndo_snapend-p-addr_len-ETHERTYPE_LEN, NULL, NULL) == 0) /* ether_type not known, probably it wasn't one */ - ND_PRINT("UI %02x! ", EXTRACT_U_1(p + addr_len)); + ND_PRINT("UI %02x! ", GET_U_1(p + addr_len)); else return addr_len + 2; } @@ -289,7 +289,7 @@ fr_print(netdissect_options *ndo, if (length < addr_len + 2) goto trunc; - if (EXTRACT_U_1(p + addr_len + 1) == 0) { + if (GET_U_1(p + addr_len + 1) == 0) { /* * Assume a pad byte after the control (UI) byte. * A pad byte should only be used with 3-byte Q.922. @@ -310,7 +310,7 @@ fr_print(netdissect_options *ndo, ND_TCHECK_1(p + hdr_len - 1); if (length < hdr_len) goto trunc; - nlpid = EXTRACT_U_1(p + hdr_len - 1); + nlpid = GET_U_1(p + hdr_len - 1); if (ndo->ndo_eflag) fr_hdr_print(ndo, length, addr_len, dlci, flags, nlpid); @@ -460,10 +460,10 @@ mfr_print(netdissect_options *ndo, ndo->ndo_protocol = "mfr"; ND_TCHECK_4(p); /* minimum frame header length */ - if ((EXTRACT_U_1(p) & MFR_BEC_MASK) == MFR_CTRL_FRAME && EXTRACT_U_1(p + 1) == 0) { + if ((GET_U_1(p) & MFR_BEC_MASK) == MFR_CTRL_FRAME && GET_U_1(p + 1) == 0) { ND_PRINT("FRF.16 Control, Flags [%s], %s, length %u", - bittok2str(frf_flag_values,"none",(EXTRACT_U_1(p) & MFR_BEC_MASK)), - tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",EXTRACT_U_1(p + 2)), + bittok2str(frf_flag_values,"none",(GET_U_1(p) & MFR_BEC_MASK)), + tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",GET_U_1(p + 2)), length); tptr = p + 3; tlen = length -3; @@ -474,8 +474,8 @@ mfr_print(netdissect_options *ndo, while (tlen>sizeof(struct ie_tlv_header_t)) { ND_TCHECK_LEN(tptr, sizeof(struct ie_tlv_header_t)); - ie_type=EXTRACT_U_1(tptr); - ie_len=EXTRACT_U_1(tptr + 1); + ie_type=GET_U_1(tptr); + ie_len=GET_U_1(tptr + 1); ND_PRINT("\n\tIE %s (%u), length %u: ", tok2str(mfr_ctrl_ie_values,"Unknown",ie_type), @@ -495,14 +495,14 @@ mfr_print(netdissect_options *ndo, switch (ie_type) { case MFR_CTRL_IE_MAGIC_NUM: - ND_PRINT("0x%08x", EXTRACT_BE_U_4(tptr)); + ND_PRINT("0x%08x", GET_BE_U_4(tptr)); break; case MFR_CTRL_IE_BUNDLE_ID: /* same message format */ case MFR_CTRL_IE_LINK_ID: for (idx = 0; idx < ie_len && idx < MFR_ID_STRING_MAXLEN; idx++) { - if (EXTRACT_U_1(tptr + idx) != 0) /* don't print null termination */ - fn_print_char(ndo, EXTRACT_U_1(tptr + idx)); + if (GET_U_1(tptr + idx) != 0) /* don't print null termination */ + fn_print_char(ndo, GET_U_1(tptr + idx)); else break; } @@ -554,13 +554,13 @@ mfr_print(netdissect_options *ndo, * +----+----+----+----+----+----+----+----+ */ - sequence_num = (EXTRACT_U_1(p)&0x1e)<<7 | EXTRACT_U_1(p + 1); + sequence_num = (GET_U_1(p)&0x1e)<<7 | GET_U_1(p + 1); /* whole packet or first fragment ? */ - if ((EXTRACT_U_1(p) & MFR_BEC_MASK) == MFR_FRAG_FRAME || - (EXTRACT_U_1(p) & MFR_BEC_MASK) == MFR_B_BIT) { + if ((GET_U_1(p) & MFR_BEC_MASK) == MFR_FRAG_FRAME || + (GET_U_1(p) & MFR_BEC_MASK) == MFR_B_BIT) { ND_PRINT("FRF.16 Frag, seq %u, Flags [%s], ", sequence_num, - bittok2str(frf_flag_values,"none",(EXTRACT_U_1(p) & MFR_BEC_MASK))); + bittok2str(frf_flag_values,"none",(GET_U_1(p) & MFR_BEC_MASK))); hdr_len = 2; fr_print(ndo, p+hdr_len,length-hdr_len); return hdr_len; @@ -569,7 +569,7 @@ mfr_print(netdissect_options *ndo, /* must be a middle or the last fragment */ ND_PRINT("FRF.16 Frag, seq %u, Flags [%s]", sequence_num, - bittok2str(frf_flag_values,"none",(EXTRACT_U_1(p) & MFR_BEC_MASK))); + bittok2str(frf_flag_values,"none",(GET_U_1(p) & MFR_BEC_MASK))); print_unknown_data(ndo, p, "\n\t", length); return hdr_len; @@ -606,13 +606,13 @@ frf15_print(netdissect_options *ndo, goto trunc; ND_TCHECK_2(p); - flags = EXTRACT_U_1(p)&MFR_BEC_MASK; - sequence_num = (EXTRACT_U_1(p)&0x1e)<<7 | EXTRACT_U_1(p + 1); + flags = GET_U_1(p)&MFR_BEC_MASK; + sequence_num = (GET_U_1(p)&0x1e)<<7 | GET_U_1(p + 1); ND_PRINT("FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u", sequence_num, bittok2str(frf_flag_values,"none",flags), - EXTRACT_U_1(p)&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End", + GET_U_1(p)&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End", length); /* TODO: @@ -816,7 +816,7 @@ q933_print(netdissect_options *ndo, * Get the length of the call reference value. */ olen = length; /* preserve the original length for display */ - call_ref_length = EXTRACT_U_1(p) & 0x0f; + call_ref_length = GET_U_1(p) & 0x0f; p++; length--; @@ -830,7 +830,7 @@ q933_print(netdissect_options *ndo, ND_PRINT("length %u", olen); goto trunc; } - call_ref[i] = EXTRACT_U_1(p); + call_ref[i] = GET_U_1(p); p++; length--; } @@ -844,7 +844,7 @@ q933_print(netdissect_options *ndo, ND_PRINT("length %u", olen); goto trunc; } - msgtype = EXTRACT_U_1(p); + msgtype = GET_U_1(p); p++; length--; @@ -860,7 +860,7 @@ q933_print(netdissect_options *ndo, ND_PRINT("length %u", olen); goto trunc; } - iecode = EXTRACT_U_1(p); + iecode = GET_U_1(p); if (IE_IS_SHIFT(iecode)) { /* * It's a shift. Skip over it. @@ -911,7 +911,7 @@ q933_print(netdissect_options *ndo, if (call_ref_length != 0) { ND_TCHECK_1(p); - if (call_ref_length > 1 || EXTRACT_U_1(p) != 0) { + if (call_ref_length > 1 || GET_U_1(p) != 0) { /* * Not a dummy call reference. */ @@ -961,7 +961,7 @@ q933_print(netdissect_options *ndo, } goto trunc; } - iecode = EXTRACT_U_1(p); + iecode = GET_U_1(p); p++; length--; @@ -1004,7 +1004,7 @@ q933_print(netdissect_options *ndo, } goto trunc; } - ielength = EXTRACT_U_1(p); + ielength = GET_U_1(p); p++; length--; @@ -1086,8 +1086,8 @@ fr_q933_print_ie_codeset_0_5(netdissect_options *ndo, u_int iecode, } if (ndo->ndo_vflag) { ND_PRINT("%s (%u)", - tok2str(fr_lmi_report_type_ie_values,"unknown",EXTRACT_U_1(p)), - EXTRACT_U_1(p)); + tok2str(fr_lmi_report_type_ie_values,"unknown",GET_U_1(p)), + GET_U_1(p)); } return 1; @@ -1101,7 +1101,7 @@ fr_q933_print_ie_codeset_0_5(netdissect_options *ndo, u_int iecode, ND_PRINT("Invalid LINK VERIFY IE"); return 1; } - ND_PRINT("TX Seq: %3d, RX Seq: %3d", EXTRACT_U_1(p), EXTRACT_U_1(p + 1)); + ND_PRINT("TX Seq: %3d, RX Seq: %3d", GET_U_1(p), GET_U_1(p + 1)); return 1; case FR_LMI_ANSI_PVC_STATUS_IE: /* fall through */ @@ -1111,30 +1111,30 @@ fr_q933_print_ie_codeset_0_5(netdissect_options *ndo, u_int iecode, } /* now parse the DLCI information element. */ if ((ielength < 3) || - (EXTRACT_U_1(p) & 0x80) || - ((ielength == 3) && !(EXTRACT_U_1(p + 1) & 0x80)) || + (GET_U_1(p) & 0x80) || + ((ielength == 3) && !(GET_U_1(p + 1) & 0x80)) || ((ielength == 4) && - ((EXTRACT_U_1(p + 1) & 0x80) || !(EXTRACT_U_1(p + 2) & 0x80))) || + ((GET_U_1(p + 1) & 0x80) || !(GET_U_1(p + 2) & 0x80))) || ((ielength == 5) && - ((EXTRACT_U_1(p + 1) & 0x80) || (EXTRACT_U_1(p + 2) & 0x80) || - !(EXTRACT_U_1(p + 3) & 0x80))) || + ((GET_U_1(p + 1) & 0x80) || (GET_U_1(p + 2) & 0x80) || + !(GET_U_1(p + 3) & 0x80))) || (ielength > 5) || - !(EXTRACT_U_1(p + ielength - 1) & 0x80)) { + !(GET_U_1(p + ielength - 1) & 0x80)) { ND_PRINT("Invalid DLCI in PVC STATUS IE"); return 1; } - dlci = ((EXTRACT_U_1(p) & 0x3F) << 4) | ((EXTRACT_U_1(p + 1) & 0x78) >> 3); + dlci = ((GET_U_1(p) & 0x3F) << 4) | ((GET_U_1(p + 1) & 0x78) >> 3); if (ielength == 4) { - dlci = (dlci << 6) | ((EXTRACT_U_1(p + 2) & 0x7E) >> 1); + dlci = (dlci << 6) | ((GET_U_1(p + 2) & 0x7E) >> 1); } else if (ielength == 5) { - dlci = (dlci << 13) | (EXTRACT_U_1(p + 2) & 0x7F) | ((EXTRACT_U_1(p + 3) & 0x7E) >> 1); + dlci = (dlci << 13) | (GET_U_1(p + 2) & 0x7F) | ((GET_U_1(p + 3) & 0x7E) >> 1); } ND_PRINT("DLCI %u: status %s%s", dlci, - EXTRACT_U_1(p + ielength - 1) & 0x8 ? "New, " : "", - EXTRACT_U_1(p + ielength - 1) & 0x2 ? "Active" : "Inactive"); + GET_U_1(p + ielength - 1) & 0x8 ? "New, " : "", + GET_U_1(p + ielength - 1) & 0x2 ? "Active" : "Inactive"); return 1; } -- cgit v1.2.1