Changeset 8a9a41e in mainline for uspace/srv/net/inetsrv/inet_link.c


Ignore:
Timestamp:
2021-10-24T08:28:43Z (3 years ago)
Author:
GitHub <noreply@…>
Children:
6855743
Parents:
2ce943a (diff), cd981f2a (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.
git-author:
Erik Kučák <35500848+Riko196@…> (2021-10-24 08:28:43)
git-committer:
GitHub <noreply@…> (2021-10-24 08:28:43)
Message:

Merge branch 'HelenOS:master' into master

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/inetsrv/inet_link.c

    r2ce943a r8a9a41e  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3535 */
    3636
    37 #include <stdbool.h>
    3837#include <errno.h>
    39 #include <str_error.h>
    4038#include <fibril_synch.h>
     39#include <inet/eth_addr.h>
    4140#include <inet/iplink.h>
    4241#include <io/log.h>
    4342#include <loc.h>
     43#include <stdbool.h>
    4444#include <stdlib.h>
    4545#include <str.h>
     46#include <str_error.h>
    4647#include "addrobj.h"
    4748#include "inetsrv.h"
     
    5657
    5758static errno_t inet_iplink_recv(iplink_t *, iplink_recv_sdu_t *, ip_ver_t);
    58 static errno_t inet_iplink_change_addr(iplink_t *, addr48_t);
     59static errno_t inet_iplink_change_addr(iplink_t *, eth_addr_t *);
    5960static inet_link_t *inet_link_get_by_id_locked(sysarg_t);
    6061
     
    7071    { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xfe, 0, 0, 0 };
    7172
    72 static void inet_link_local_node_ip(addr48_t mac_addr,
     73static void inet_link_local_node_ip(eth_addr_t *mac_addr,
    7374    addr128_t ip_addr)
    7475{
     76        uint8_t b[ETH_ADDR_SIZE];
     77
    7578        memcpy(ip_addr, link_local_node_ip, 16);
    76 
    77         ip_addr[8] = mac_addr[0] ^ 0x02;
    78         ip_addr[9] = mac_addr[1];
    79         ip_addr[10] = mac_addr[2];
    80         ip_addr[13] = mac_addr[3];
    81         ip_addr[14] = mac_addr[4];
    82         ip_addr[15] = mac_addr[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];
    8387}
    8488
     
    121125}
    122126
    123 static errno_t inet_iplink_change_addr(iplink_t *iplink, addr48_t mac)
    124 {
     127static errno_t inet_iplink_change_addr(iplink_t *iplink, eth_addr_t *mac)
     128{
     129        eth_addr_str_t saddr;
     130
     131        eth_addr_format(mac, &saddr);
    125132        log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_iplink_change_addr(): "
    126             "new addr=%02x:%02x:%02x:%02x:%02x:%02x",
    127             mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
     133            "new addr=%s", saddr.str);
    128134
    129135        list_foreach(inet_links, link_list, inet_link_t, ilink) {
    130136                if (ilink->sess == iplink->sess)
    131                         memcpy(&ilink->mac, mac, sizeof(addr48_t));
     137                        ilink->mac = *mac;
    132138        }
    133139
     
    261267
    262268                addr128_t link_local;
    263                 inet_link_local_node_ip(ilink->mac, link_local);
     269                inet_link_local_node_ip(&ilink->mac, link_local);
    264270
    265271                inet_naddr_set6(link_local, 64, &addr6->naddr);
     
    387393 *
    388394 */
    389 errno_t inet_link_send_dgram6(inet_link_t *ilink, addr48_t ldest,
     395errno_t inet_link_send_dgram6(inet_link_t *ilink, eth_addr_t *ldest,
    390396    inet_dgram_t *dgram, uint8_t proto, uint8_t ttl, int df)
    391397{
     
    401407
    402408        iplink_sdu6_t sdu6;
    403         addr48(ldest, sdu6.dest);
     409        sdu6.dest = *ldest;
    404410
    405411        /*
Note: See TracChangeset for help on using the changeset viewer.