Changeset 3e6bca8 in mainline for uspace/srv/net/inetsrv/inet_link.c


Ignore:
Timestamp:
2021-08-08T17:30:29Z (4 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/srv/net/inetsrv/inet_link.c

    rb4edc96 r3e6bca8  
    7474    addr128_t ip_addr)
    7575{
     76        uint8_t b[ETH_ADDR_SIZE];
     77
    7678        memcpy(ip_addr, link_local_node_ip, 16);
    77 
    78         ip_addr[8] = mac_addr->b[0] ^ 0x02;
    79         ip_addr[9] = mac_addr->b[1];
    80         ip_addr[10] = mac_addr->b[2];
    81         ip_addr[13] = mac_addr->b[3];
    82         ip_addr[14] = mac_addr->b[4];
    83         ip_addr[15] = mac_addr->b[5];
     79        eth_addr_encode(mac_addr, b);
     80
     81        ip_addr[8] = b[0] ^ 0x02;
     82        ip_addr[9] = b[1];
     83        ip_addr[10] = b[2];
     84        ip_addr[13] = b[3];
     85        ip_addr[14] = b[4];
     86        ip_addr[15] = b[5];
    8487}
    8588
     
    124127static errno_t inet_iplink_change_addr(iplink_t *iplink, eth_addr_t *mac)
    125128{
     129        eth_addr_str_t saddr;
     130
     131        eth_addr_format(mac, &saddr);
    126132        log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_iplink_change_addr(): "
    127             "new addr=%02x:%02x:%02x:%02x:%02x:%02x",
    128             mac->b[0], mac->b[1], mac->b[2], mac->b[3], mac->b[4], mac->b[5]);
     133            "new addr=%s", saddr.str);
    129134
    130135        list_foreach(inet_links, link_list, inet_link_t, ilink) {
Note: See TracChangeset for help on using the changeset viewer.