Changeset 98abd40 in mainline for uspace/srv/net/ethip/pdu.c
- Timestamp:
- 2013-07-06T21:57:22Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c8bb1633, cdc8a391
- Parents:
- b8e72fd1 (diff), 507c6f3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/ethip/pdu.c
rb8e72fd1 r98abd40 62 62 63 63 hdr = (eth_header_t *)data; 64 mac48_encode(&frame->src, hdr->src);65 mac48_encode(&frame->dest, hdr->dest);64 addr48(frame->src, hdr->src); 65 addr48(frame->dest, hdr->dest); 66 66 hdr->etype_len = host2uint16_t_be(frame->etype_len); 67 67 … … 69 69 frame->size); 70 70 71 log_msg(LOG_DEFAULT, LVL_DEBUG, "Encoding Ethernet frame "72 "src=%" PRIx64 " dest=%" PRIx64 " etype=%x",73 frame->src.addr, frame->dest.addr, frame->etype_len);74 71 log_msg(LOG_DEFAULT, LVL_DEBUG, "Encoded Ethernet frame (%zu bytes)", size); 75 72 … … 98 95 return ENOMEM; 99 96 100 mac48_decode(hdr->src, &frame->src);101 mac48_decode(hdr->dest, &frame->dest);97 addr48(hdr->src, frame->src); 98 addr48(hdr->dest, frame->dest); 102 99 frame->etype_len = uint16_t_be2host(hdr->etype_len); 103 100 … … 105 102 frame->size); 106 103 107 log_msg(LOG_DEFAULT, LVL_DEBUG, "Decoding Ethernet frame "108 "src=%" PRIx64 " dest=%" PRIx64 " etype=%x",109 frame->src.addr, frame->dest.addr, frame->etype_len);110 104 log_msg(LOG_DEFAULT, LVL_DEBUG, "Decoded Ethernet frame payload (%zu bytes)", frame->size); 111 105 112 106 return EOK; 113 }114 115 void mac48_encode(mac48_addr_t *addr, void *buf)116 {117 uint64_t val;118 uint8_t *bbuf = (uint8_t *)buf;119 int i;120 121 val = addr->addr;122 for (i = 0; i < MAC48_BYTES; i++)123 bbuf[i] = (val >> (8 * (MAC48_BYTES - i - 1))) & 0xff;124 }125 126 void mac48_decode(void *data, mac48_addr_t *addr)127 {128 uint64_t val;129 uint8_t *bdata = (uint8_t *)data;130 int i;131 132 val = 0;133 for (i = 0; i < MAC48_BYTES; i++)134 val |= (uint64_t)bdata[i] << (8 * (MAC48_BYTES - i - 1));135 136 addr->addr = val;137 107 } 138 108 … … 168 138 pfmt->proto_addr_size = IPV4_ADDR_SIZE; 169 139 pfmt->opcode = host2uint16_t_be(fopcode); 170 mac48_encode(&packet->sender_hw_addr, pfmt->sender_hw_addr);140 addr48(packet->sender_hw_addr, pfmt->sender_hw_addr); 171 141 pfmt->sender_proto_addr = 172 host2uint32_t_be(packet->sender_proto_addr .ipv4);173 mac48_encode(&packet->target_hw_addr, pfmt->target_hw_addr);142 host2uint32_t_be(packet->sender_proto_addr); 143 addr48(packet->target_hw_addr, pfmt->target_hw_addr); 174 144 pfmt->target_proto_addr = 175 host2uint32_t_be(packet->target_proto_addr .ipv4);145 host2uint32_t_be(packet->target_proto_addr); 176 146 177 147 *rdata = data; … … 227 197 } 228 198 229 mac48_decode(pfmt->sender_hw_addr, &packet->sender_hw_addr);230 packet->sender_proto_addr .ipv4=199 addr48(pfmt->sender_hw_addr, packet->sender_hw_addr); 200 packet->sender_proto_addr = 231 201 uint32_t_be2host(pfmt->sender_proto_addr); 232 mac48_decode(pfmt->target_hw_addr, &packet->target_hw_addr);233 packet->target_proto_addr .ipv4=202 addr48(pfmt->target_hw_addr, packet->target_hw_addr); 203 packet->target_proto_addr = 234 204 uint32_t_be2host(pfmt->target_proto_addr); 235 205 log_msg(LOG_DEFAULT, LVL_DEBUG, "packet->tpa = %x\n", pfmt->target_proto_addr); … … 238 208 } 239 209 240 241 210 /** @} 242 211 */
Note:
See TracChangeset
for help on using the changeset viewer.