⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plugins-wimax-msg_ulmap.c

📁 Intel的WIMAX代码,主要是mac层code
💻 C
📖 第 1 页 / 共 5 页
字号:
            }
            XBIT(data, 3, "Sounding symbol index");
            XBIT(ncid, 7, "Number of CIDs");
            XBIT(data, 1, "Reserved");
            for (j = 0; j < ncid; j++) {
                XBIT(data,12, "Shorted Basic CID");
                XBIT(data, 2, "Power Assignment Method");
                XBIT(data, 1, "Power boost");
                XBIT(data, 1, "Multi-Antenna Flag");
                XBIT(amod, 1, "Allocation Mode");
                if (amod == 1) {
                    XBIT(data,12, "Band bit map");
                    XBIT(data, 2, "Reserved");
                } else {
                    XBIT(data, 7, "Starting frequency band");
                    XBIT(data, 7, "Number of frequency bands");
                }
                if (srlf == 1) {
                    XBIT(data, 1, "Sounding_Relevance");
                } else {
                    XBIT(data, 1, "Reserved");
                }
                if (sept == 0) {
                    XBIT(data, 5, "Cyclic time shift index m");
                } else {
                    XBIT(data, 6, "Decimation offset d");
                    if (iafb == 1) {
                        XBIT(data, 1, "Use same symbol for additional feedback");
                        XBIT(data, 2, "Reserved");
                    } else {
                        XBIT(data, 3, "Reserved");
                    }
                }
                XBIT(data, 3, "Periodicity");
            }
        }
    } else {
        XBIT(data, 3, "Permutation");
        XBIT(data, 6, "DL_PermBase");
        XBIT(nssym, 3, "Num_Sounding_symbols");
        for (i = 0; i < nssym; i++) {
            XBIT(ncid, 7, "Number of CIDs");
            XBIT(data, 1, "Reserved");
            for (j = 0; j < ncid; j++) {
                XBIT(data, 12, "Shortened basic CID");
                if (srlf) {
                    XBIT(data, 1, "Sounding_Relevance");
                    XBIT(data, 3, "Reserved");
                }
                XBIT(data, 7, "Subchannel offset");
                XBIT(data, 1, "Power boost");
                XBIT(data, 3, "Number of subchannels");
                XBIT(data, 3, "Periodicity");
                XBIT(data, 2, "Power assignment method");
            }
        }
    }
    pad = BIT_PADDING(bit,8);
    if (pad) {
        proto_tree_add_text(tree, tvb, BITHI(bit,pad), "Padding: %d bits",pad);
        bit += pad;
    }
    return BIT_TO_NIB(bit);
}

gint MIMO_UL_Enhanced_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
{
    /* UL-MAP Extended-2 IE = 6 */
    /* 8.4.5.4.20 [2] MIMO_UL_Enhanced_IE (not implemented) */
    /* offset of TLV in nibbles, length of TLV in nibbles */
    gint nib;
    gint data;
    proto_item *ti = NULL;
    proto_item *tree = NULL;

    nib = offset;

    ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "MIMO_UL_Enhanced_IE");
    tree = proto_item_add_subtree(ti, ett_302f);

    XNIB(data, 1, "Extended-2 UIUC");
    XNIB(data, 2, "Length");
    proto_tree_add_text(tree, tvb, NIBHI(nib,length-3), "(not implemented)");
    return nib;
}

gint HARQ_ULMAP_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
{
    /* UL-MAP Extended-2 IE = 7 */
    /* 8.4.5.4.24 HARQ_ULMAP_IE */
    /* offset of TLV in nibbles, length of TLV in nibbles */
    gint bit;
    gint data;
    proto_item *ti = NULL;
    proto_item *tree = NULL;
    gint bitlength;
    gint lastbit;
    gint pad, mode, alsi, nsub;
    gint i;

    bit = NIB_TO_BIT(offset);
    bitlength = NIB_TO_BIT(length);

    ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "HARQ_ULMAP_IE");
    tree = proto_item_add_subtree(ti, ett_302j);

    XBIT(data, 4, "Extended-2 UIUC");
    XBIT(data, 8, "Length");

    XBIT(RCID_Type, 2, "RCID_Type");
    XBIT(data, 2, "Reserved");
    lastbit = bit + bitlength -16 - 4;
    while (bit < lastbit) {
        XBIT(mode, 3, "Mode");
        XBIT(alsi, 1, "Allocation Start Indication");
        if (alsi == 1) {
            XBIT(data, 8, "OFDMA Symbol offset");
            XBIT(data, 7, "Subchannel offset");
            XBIT(data, 1, "Reserved");
        }
        XBIT(nsub, 4, "N sub Burst");
        for (i = 0; i < nsub; i++) {
            if (mode == 0) {
                bit += UL_HARQ_Chase_Sub_Burst_IE(tree, bufptr, bit, bitlength, tvb);
            } else if (mode == 1) {
               bit +=  UL_HARQ_IR_CTC_Sub_Burst_IE(tree, bufptr, bit, bitlength, tvb);
            } else if (mode == 2) {
                bit += UL_HARQ_IR_CC_Sub_Burst_IE(tree, bufptr, bit, bitlength, tvb);
            } else if (mode == 3) {
                bit += MIMO_UL_Chase_HARQ_Sub_Burst_IE(tree, bufptr, bit, bitlength, tvb);
            } else if (mode == 4) {
                bit += MIMO_UL_IR_HARQ__Sub_Burst_IE(tree, bufptr, bit, bitlength, tvb);
            } else if (mode == 5) {
                bit += MIMO_UL_IR_HARQ_for_CC_Sub_Burst_UIE(tree, bufptr, bit, bitlength, tvb);
            } else if (mode == 6) {
                bit += MIMO_UL_STC_HARQ_Sub_Burst_IE(tree, bufptr, bit, bitlength, tvb);
            }
        }
    }

    pad = NIB_TO_BIT(offset) + bitlength - bit;
    if (pad) {
        proto_tree_add_text(tree, tvb, BITHI(bit,pad), "Padding: %d bits",pad);
        bit += pad;
    }
    return BIT_TO_NIB(bit);
}

gint HARQ_ACKCH_Region_Allocation_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
{
    /* UL-MAP Extended-2 IE = 8 */
    /* 8.4.5.4.25 [2] HARQ_ACKCH_Region_Allocation_IE */
    /* offset of TLV in nibbles, length of TLV in nibbles */
    gint bit;
    gint data;
    proto_item *ti = NULL;
    proto_item *tree = NULL;

    bit = NIB_TO_BIT(offset);

    ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "HARQ_ACKCH_Region_IE");
    tree = proto_item_add_subtree(ti, ett_302t);

    XBIT(data, 4, "Extended-2 UIUC");
    XBIT(data, 8, "Length");

    XBIT(data, 8, "OFDMA Symbol Offset");
    XBIT(data, 7, "Subchannel Offset");
    XBIT(data, 5, "No. OFDMA Symbols");
    XBIT(data, 4, "No. Subchannels");
    return BIT_TO_NIB(bit);
}

gint AAS_SDMA_UL_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
{
    /* UL-MAP Extended-2 IE = 0xE */
    /* 8.4.5.4.27 [2] AAS_SDMA_UL_IE  */
    /* offset of TLV in nibbles, length of TLV in nibbles */
    gint bit;
    gint data;
    proto_item *ti = NULL;
    proto_item *tree = NULL;
    gint nreg, pad, user, encm, ppmd, padj;
    gint aasp = 0; /* TODO AAS UL preamble used */
    gint ii, jj;

    bit = NIB_TO_BIT(offset);

    ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "AAS_SDMA_UL_IE");
    tree = proto_item_add_subtree(ti, ett_302u);

    XBIT(data, 4, "Extended-2 UIUC");
    XBIT(data, 8, "Length");

    XBIT(RCID_Type, 2, "RCID_Type");
    XBIT(nreg, 4, "Num Burst Region");
    XBIT(data, 2, "Reserved");
    for (ii = 0; ii < nreg; ii++) {
        XBIT(data,12, "Slot offset");
        XBIT(data,10, "Slot duration");
        XBIT(user, 3, "Number of users");
        XBIT(data, 3, "Reserved");
        for (jj = 0; jj < user; jj++) {
            bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
            XBIT(encm, 2, "Encoding Mode");
            XBIT(padj, 1, "Power Adjust");
            XBIT(ppmd, 1, "Pilot Pattern Modifier");
            if (aasp) {
                XBIT(data, 4, "Preamble Modifier Index");
            }
            if (ppmd) {
                XBIT(data, 2, "Pilot Pattern");
                XBIT(data, 2, "Reserved");
            }
            if (encm == 0) {
                XBIT(data, 4, "DIUC");
                XBIT(data, 2, "Repetition Coding Indication");
                XBIT(data, 2, "Reserved");
            }
            if (encm == 1) {
                XBIT(data, 4, "DIUC");
                XBIT(data, 2, "Repetition Coding Indication");
                XBIT(data, 4, "ACID");
                XBIT(data, 1, "AI_SN");
                XBIT(data, 1, "Reserved");
            }
            if (encm == 2) {
                XBIT(data, 4, "N(EP)");
                XBIT(data, 4, "N(SCH)");
                XBIT(data, 2, "SPID");
                XBIT(data, 4, "ACID");
                XBIT(data, 1, "AI_SN");
                XBIT(data, 1, "Reserved");
            }
            if (encm == 3) {
                XBIT(data, 4, "DIUC");
                XBIT(data, 2, "Repetition Coding Indication");
                XBIT(data, 2, "SPID");
                XBIT(data, 4, "ACID");
                XBIT(data, 1, "AI_SN");
                XBIT(data, 3, "Reserved");
            }
            if (padj) {
                XBIT(data, 8, "Power Adjustment");

            }
        }
    }

    pad = BIT_PADDING(bit,8);
    if (pad) {
        proto_tree_add_text(tree, tvb, BITHI(bit, pad), "Padding: %d bits", pad);
        bit += pad;
    }
    return BIT_TO_NIB(bit);
}

gint Feedback_Polling_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
{
    /* UL-MAP Extended-2 IE = 0xF */
    /* 8.4.5.4.28 [2] Feedback_Polling_IE */
    /* offset of TLV in nibbles, length of TLV in nibbles */
    gint bit;
    gint data;
    proto_item *ti = NULL;
    proto_item *tree = NULL;
    gint nalloc, dula, pad, adur;
    gint i;

    bit = NIB_TO_BIT(offset);

    ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "Feedback_Polling_IE");
    tree = proto_item_add_subtree(ti, ett_302v);

    XBIT(data, 4, "Extended-2 UIUC");
    XBIT(data, 8, "Length");

    XBIT(nalloc, 4, "Num_Allocation");
    XBIT(dula, 1, "Dedicated UL Allocation included");
    XBIT(data, 3, "Reserved");
    for (i = 0; i < nalloc; i++) {
        XBIT(data,16, "Basic CID");
        XBIT(adur, 3, "Allocation Duration (d)");
        if (adur != 0) {
            XBIT(data, 4, "Feedback type");
            XBIT(data, 3, "Frame Offset");
            XBIT(data, 2, "Period (p)");
            if (dula == 1) {
                XBIT(data, 4, "UIUC");
                XBIT(data, 8, "OFDMA Symbol Offset");
                XBIT(data, 7, "Subchannel offset");
                XBIT(data, 3, "Duration");
                XBIT(data, 2, "Repetition coding indication");
            }
        }
    }
    pad = BIT_PADDING(bit,8);
    if (pad) {
        proto_tree_add_text(tree, tvb, BITHI(bit, pad), "Padding: %d bits", pad);
        bit += pad;
    }
    return BIT_TO_NIB(bit);
}


/********************************************************************
 * UL-MAP Miscellany
 *******************************************************************/


void lshift_bits(guint8 *buffer, gint bytes, gint bits)
{
    /* left shift a buffer by specified number of bits */
    /* used for ULMAP ExtIE CQICH alloc IE */
    gint i;
    gint xbits;

    while (bits >= 8) {
        for (i=1; i<bytes; i++)
            buffer[i-1] = buffer[i];
        bits -= 8;
        bytes--;
    }
    if (bits > 0)
    {
        xbits = 8 - bits;
        for (i = 0; i < (bytes-1); i++) {
            buffer[i] <<= bits;
            buffer[i] |= (buffer[i+1] >> xbits);
        }
        buffer[bytes-1] <<= bits;
    }
}


/* Register Wimax Mac Payload Protocol and Dissector */
void proto_register_mac_mgmt_msg_ulmap(void)
{
    if (proto_mac_mgmt_msg_ulmap_decoder == -1)
    {
	proto_mac_mgmt_msg_ulmap_decoder = proto_mac_mgmt_msg_dlmap_decoder;

        proto_register_field_array(proto_mac_mgmt_msg_ulmap_decoder, hf, array_length(hf));
        proto_register_subtree_array(ett, array_length(ett));
    }
}


gint dissect_ulmap_ie( proto_tree *ie_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
{
    /* decode a single UL-MAP IE and return the
     * length of the IE in nibbles
     * offset = start of IE (nibbles)
     * length = total length of bufptr (nibbles) */
    proto_item *ti = NULL;
    proto_tree *tree = NULL;
    gint nibble;
    gint uiuc, ext_uiuc, ext2_uiuc, len, aas_or_amc;
    guint cid;
    guint data;
    guint32 data32;

    nibble = offset;

    UNREFERENCED_PARAMETER(length);

    /* 8.4.5.4 UL-MAP IE format - table 287 */
    cid = NIB_WORD(nibble, bufptr);
    uiuc = NIB_NIBBLE(nibble + 4, bufptr);

    if (uiuc == 0)
    {
        /* 8.4.5.4.9 FAST-FEEDBACK channel */
        ti = proto_tree_add_text(ie_tree, tvb, NIBHI(nibble, 5+8), "FAST FEEDBACK Allocation IE");
        tree = proto_item_add_subtree(ti, ett_ulmap_ffb);

        proto_tree_add_uint(tree, hf_ulmap_ie_cid, tvb, NIBHI(nibble, 4), cid);
        nibble += 4;
        proto_tree_add_uint(tree, hf_ulmap_ie_uiuc, tvb, NIBHI(nibble, 1), uiuc);
        nibble += 1;

        data = NIB_LONG(nibble, bufptr);
        proto_tree_add_uint(tree, hf_ulmap_uiuc0_symofs, tvb, NIBHI(nibble, 8), data);
        proto_tree_add_uint(tree, hf_ulmap_uiuc0_subofs, tvb, NIBHI(nibble, 8), data);
        proto_tree_add_uint(tree, hf_ulmap_uiuc0_numsym, tvb, NIBHI(nibble, 8), data);
        proto_tree_add_uint(tree, hf_ulmap_uiuc0_numsub, tvb, NIBHI(nibble, 8), data);
        proto_tree_add_uint(tree, hf_ulmap_uiuc0_rsv,    tvb, NIBHI(nibble, 8), data);
        nibble += 8;
    }
    else if (uiuc == 11)
    {
        /* 8.4.5.4.4.2 [2] extended-2 UIUC IE table 290b */
        ext2_uiuc = NIB_NIBBLE(5+nibble, bufptr);
        len = NIB_BYTE(5+nibble+1, bufptr);

        ti = proto_tree_add_text(ie_tree, tvb, NIBHI(nibble, 5+3+len*2), "UIUC: %d (Extended-2 IE)", uiuc);
        tree = proto_item_add_subtree(ti, ett_290b);

        proto_tree_add_uint(tree, hf_ulmap_ie_cid, tvb, NIBHI(nibble, 4), cid);
        nibble += 4;
        proto_tree_add_uint(tree, hf_ulmap_ie_uiuc, tvb, NIBHI(nibble, 1), uiuc);
        nibble += 1;

        /*
        proto_tree_add_uint(tree, hf_ulmap_uiuc11_ext, tvb, NIBHI(nibble, 1), ext2_uiuc);
        nibble += 1;
        proto_tree_add_uint(tree, hf_ulmap_uiuc11_len, tvb, NIBHI(nibble, 2), len);
        nibble += 2;
        */

        len = 4 + BYTE_TO_NIB(len); /* length in nibbles */

        /* data table 290c 8.4.5.4.4.2 */
        switch (ext2_uiuc) {
            case 0x00:
                /* 8.4.5.4.16 CQICH_Enhanced_Allocation_IE */
                nibble = CQICH_Enhance

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -