Changeset df15e5f in mainline for uspace/srv/ethip/pdu.c


Ignore:
Timestamp:
2012-02-12T20:09:36Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bd8bfc5a
Parents:
4f64a523
Message:

Fix bug in MAC address decoding.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/ethip/pdu.c

    r4f64a523 rdf15e5f  
    7676}
    7777
     78#include <stdio.h>
    7879/** Decode Ethernet PDU. */
    7980int eth_pdu_decode(void *data, size_t size, eth_frame_t *frame)
     
    102103            frame->size);
    103104
     105        log_msg(LVL_DEBUG, "Ethernet frame src=%llx dest=%llx etype=%x",
     106            frame->src, frame->dest, frame->etype_len);
     107        log_msg(LVL_DEBUG, "Ethernet frame payload (%zu bytes)", frame->size);
     108        size_t i;
     109        for (i = 0; i < frame->size; i++) {
     110                printf("%02x ", ((uint8_t *)(frame->data))[i]);
     111        }
     112        printf("\n");
     113
    104114        return EOK;
    105115}
     
    113123        val = addr->addr;
    114124        for (i = 0; i < MAC48_BYTES; i++) {
    115                 bbuf[i] = (val >> 8*(MAC48_BYTES - i - 1)) & 0xff;
     125                bbuf[i] = (val >> (8 * (MAC48_BYTES - i - 1))) & 0xff;
    116126                val = val >> 8;
    117127        }
     
    126136        val = 0;
    127137        for (i = 0; i < MAC48_BYTES; i++)
    128                 val |= ((uint64_t)bdata[i]) << (MAC48_BYTES - i - 1);
     138                val |= (uint64_t)bdata[i] << (8 * (MAC48_BYTES - i - 1));
    129139
    130140        addr->addr = val;
Note: See TracChangeset for help on using the changeset viewer.