Changeset 3e6bca8 in mainline for uspace/lib/inet/src/addr.c


Ignore:
Timestamp:
2021-08-08T17:30:29Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a7f7b9c3
Parents:
b4edc96
Message:

Represent Ethernet address as a number instead of an array

Carefully document the design since this breaks the principle of least
surprise. Also add unit tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/inet/src/addr.c

    rb4edc96 r3e6bca8  
    5555const addr32_t addr32_broadcast_all_hosts = 0xffffffff;
    5656
    57 static const eth_addr_t inet_eth_addr_solicited_node = {
    58         0x33, 0x33, 0xff, 0, 0, 0
    59 };
     57static eth_addr_t inet_eth_addr_solicited_node =
     58    ETH_ADDR_INITIALIZER(0x33, 0x33, 0xff, 0, 0, 0);
    6059
    6160static const inet_addr_t inet_addr_any_addr = {
     
    9190void eth_addr_solicited_node(const addr128_t ip, eth_addr_t *mac)
    9291{
    93         memcpy(&mac->b[0], &inet_eth_addr_solicited_node.b[0], 3);
    94         memcpy(&mac->b[3], ip + 13, 3);
     92        uint8_t b[6];
     93        mac->a = inet_eth_addr_solicited_node.a;
     94
     95        eth_addr_encode(&inet_eth_addr_solicited_node, b);
     96        memcpy(&b[3], ip + 13, 3);
     97        eth_addr_decode(b, mac);
    9598}
    9699
Note: See TracChangeset for help on using the changeset viewer.