Changeset f05edcb in mainline


Ignore:
Timestamp:
2021-08-08T08:28:24Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d5ed54b
Parents:
98a935e
Message:

Make addr48_t a structure

Location:
uspace
Files:
2 added
26 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/inet/inet.c

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2013 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    370370                table_printf(table, "%02x:%02x:%02x:%02x:%02x:%02x\t"
    371371                    "%s\t" "%zu\n",
    372                     linfo.mac_addr[0], linfo.mac_addr[1],
    373                     linfo.mac_addr[2], linfo.mac_addr[3],
    374                     linfo.mac_addr[4], linfo.mac_addr[5],
     372                    linfo.mac_addr.b[0], linfo.mac_addr.b[1],
     373                    linfo.mac_addr.b[2], linfo.mac_addr.b[3],
     374                    linfo.mac_addr.b[4], linfo.mac_addr.b[5],
    375375                    linfo.name, linfo.def_mtu);
    376376
  • uspace/lib/drv/generic/remote_ieee80211.c

    r98a935e rf05edcb  
    109109                        return -1;
    110110
    111                 if (mac_matches(mac, link_info.mac_addr))
     111                if (mac_matches(mac, link_info.mac_addr.b))
    112112                        return link_list[i];
    113113        }
     
    229229                        return rc;
    230230
    231                 if (mac_matches(wifi_mac.address, link_info.mac_addr)) {
     231                if (mac_matches(wifi_mac.address, link_info.mac_addr.b)) {
    232232                        if (str_test_prefix(addr_info.name, "dhcp")) {
    233233                                rc = inetcfg_addr_delete(addr_list[i]);
  • uspace/lib/inet/include/inet/addr.h

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2013 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4040
    4141typedef uint32_t addr32_t;
    42 typedef uint8_t addr48_t[6];
     42
     43#define ETH_ADDR_SIZE 6
     44
     45typedef struct {
     46        uint8_t b[ETH_ADDR_SIZE];
     47} addr48_t;
     48
    4349typedef uint8_t addr128_t[16];
    4450
     
    8086extern const addr48_t addr48_broadcast;
    8187
    82 extern void addr48(const addr48_t, addr48_t);
     88extern void addr48(const addr48_t *, addr48_t *);
    8389extern void addr128(const addr128_t, addr128_t);
    8490
    85 extern int addr48_compare(const addr48_t, const addr48_t);
     91extern int addr48_compare(const addr48_t *, const addr48_t *);
    8692extern int addr128_compare(const addr128_t, const addr128_t);
    8793
    88 extern void addr48_solicited_node(const addr128_t, addr48_t);
     94extern void addr48_solicited_node(const addr128_t, addr48_t *);
    8995
    9096extern void host2addr128_t_be(const addr128_t, addr128_t);
  • uspace/lib/inet/include/inet/iplink.h

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    7979typedef struct iplink_ev_ops {
    8080        errno_t (*recv)(iplink_t *, iplink_recv_sdu_t *, ip_ver_t);
    81         errno_t (*change_addr)(iplink_t *, addr48_t);
     81        errno_t (*change_addr)(iplink_t *, addr48_t *);
    8282} iplink_ev_ops_t;
    8383
     
    9090extern errno_t iplink_get_mtu(iplink_t *, size_t *);
    9191extern errno_t iplink_get_mac48(iplink_t *, addr48_t *);
    92 extern errno_t iplink_set_mac48(iplink_t *, addr48_t);
     92extern errno_t iplink_set_mac48(iplink_t *, addr48_t *);
    9393extern void *iplink_get_userptr(iplink_t *);
    9494
  • uspace/lib/inet/meson.build

    r98a935e rf05edcb  
    3232        'src/dnsr.c',
    3333        'src/endpoint.c',
     34        'src/eth_addr.c',
    3435        'src/host.c',
    3536        'src/hostname.c',
  • uspace/lib/inet/src/addr.c

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2013 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * Copyright (c) 2013 Martin Decky
    44 * All rights reserved.
     
    7272};
    7373
    74 void addr48(const addr48_t src, addr48_t dst)
    75 {
    76         memcpy(dst, src, 6);
     74void addr48(const addr48_t *src, addr48_t *dst)
     75{
     76        memcpy(dst, src, sizeof(addr48_t));
    7777}
    7878
     
    8686 * @return Non-zero if equal, zero if not equal.
    8787 */
    88 int addr48_compare(const addr48_t a, const addr48_t b)
    89 {
    90         return memcmp(a, b, 6) == 0;
     88int addr48_compare(const addr48_t *a, const addr48_t *b)
     89{
     90        return memcmp(a->b, b->b, 6) == 0;
    9191}
    9292
     
    106106 *
    107107 */
    108 void addr48_solicited_node(const addr128_t ip, addr48_t mac)
    109 {
    110         memcpy(mac, inet_addr48_solicited_node, 3);
    111         memcpy(mac + 3, ip + 13, 3);
     108void addr48_solicited_node(const addr128_t ip, addr48_t *mac)
     109{
     110        memcpy(&mac->b[0], &inet_addr48_solicited_node.b[0], 3);
     111        memcpy(&mac->b[3], ip + 13, 3);
    112112}
    113113
  • uspace/lib/inet/src/iplink.c

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    175175}
    176176
    177 errno_t iplink_set_mac48(iplink_t *iplink, addr48_t mac)
     177errno_t iplink_set_mac48(iplink_t *iplink, addr48_t *mac)
    178178{
    179179        async_exch_t *exch = async_exchange_begin(iplink->sess);
     
    274274        }
    275275
    276         rc = iplink->ev_ops->change_addr(iplink, *addr);
     276        rc = iplink->ev_ops->change_addr(iplink, addr);
    277277        free(addr);
    278278        async_answer_0(icall, EOK);
  • uspace/srv/net/dhcp/dhcp.c

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2013 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    161161        hdr->flags = flag_broadcast;
    162162
    163         addr48(dlink->link_info.mac_addr, hdr->chaddr);
     163        memcpy(dlink->link_info.mac_addr.b, hdr->chaddr,
     164            sizeof(dlink->link_info.mac_addr.b));
    164165        hdr->opt_magic = host2uint32_t_be(dhcp_opt_magic);
    165166
     
    185186        hdr->flags = flag_broadcast;
    186187        hdr->ciaddr = host2uint32_t_be(offer->oaddr.addr);
    187         addr48(dlink->link_info.mac_addr, hdr->chaddr);
     188        memcpy(hdr->chaddr, dlink->link_info.mac_addr.b, 6);
    188189        hdr->opt_magic = host2uint32_t_be(dhcp_opt_magic);
    189190
  • uspace/srv/net/ethip/arp.c

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    7979
    8080        (void) atrans_add(packet.sender_proto_addr,
    81             packet.sender_hw_addr);
     81            &packet.sender_hw_addr);
    8282
    8383        if (packet.opcode == aop_request) {
     
    8585
    8686                reply.opcode = aop_reply;
    87                 addr48(nic->mac_addr, reply.sender_hw_addr);
     87                addr48(&nic->mac_addr, &reply.sender_hw_addr);
    8888                reply.sender_proto_addr = laddr_v4;
    89                 addr48(packet.sender_hw_addr, reply.target_hw_addr);
     89                addr48(&packet.sender_hw_addr, &reply.target_hw_addr);
    9090                reply.target_proto_addr = packet.sender_proto_addr;
    9191
     
    9595
    9696errno_t arp_translate(ethip_nic_t *nic, addr32_t src_addr, addr32_t ip_addr,
    97     addr48_t mac_addr)
     97    addr48_t *mac_addr)
    9898{
    9999        /* Broadcast address */
    100100        if (ip_addr == addr32_broadcast_all_hosts) {
    101                 addr48(addr48_broadcast, mac_addr);
     101                addr48(&addr48_broadcast, mac_addr);
    102102                return EOK;
    103103        }
     
    110110
    111111        packet.opcode = aop_request;
    112         addr48(nic->mac_addr, packet.sender_hw_addr);
     112        addr48(&nic->mac_addr, &packet.sender_hw_addr);
    113113        packet.sender_proto_addr = src_addr;
    114         addr48(addr48_broadcast, packet.target_hw_addr);
     114        addr48(&addr48_broadcast, &packet.target_hw_addr);
    115115        packet.target_proto_addr = ip_addr;
    116116
     
    138138                return rc;
    139139
    140         addr48(packet->target_hw_addr, frame.dest);
    141         addr48(packet->sender_hw_addr, frame.src);
     140        addr48(&packet->target_hw_addr, &frame.dest);
     141        addr48(&packet->sender_hw_addr, &frame.src);
    142142        frame.etype_len = ETYPE_ARP;
    143143        frame.data = pdata;
  • uspace/srv/net/ethip/arp.h

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4343
    4444extern void arp_received(ethip_nic_t *, eth_frame_t *);
    45 extern errno_t arp_translate(ethip_nic_t *, addr32_t, addr32_t, addr48_t);
     45extern errno_t arp_translate(ethip_nic_t *, addr32_t, addr32_t, addr48_t *);
    4646
    4747#endif
  • uspace/srv/net/ethip/atrans.c

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5959}
    6060
    61 errno_t atrans_add(addr32_t ip_addr, addr48_t mac_addr)
     61errno_t atrans_add(addr32_t ip_addr, addr48_t *mac_addr)
    6262{
    6363        ethip_atrans_t *atrans;
     
    6969
    7070        atrans->ip_addr = ip_addr;
    71         addr48(mac_addr, atrans->mac_addr);
     71        addr48(mac_addr, &atrans->mac_addr);
    7272
    7373        fibril_mutex_lock(&atrans_list_lock);
     
    103103}
    104104
    105 static errno_t atrans_lookup_locked(addr32_t ip_addr, addr48_t mac_addr)
     105static errno_t atrans_lookup_locked(addr32_t ip_addr, addr48_t *mac_addr)
    106106{
    107107        ethip_atrans_t *atrans = atrans_find(ip_addr);
     
    109109                return ENOENT;
    110110
    111         addr48(atrans->mac_addr, mac_addr);
     111        addr48(&atrans->mac_addr, mac_addr);
    112112        return EOK;
    113113}
    114114
    115 errno_t atrans_lookup(addr32_t ip_addr, addr48_t mac_addr)
     115errno_t atrans_lookup(addr32_t ip_addr, addr48_t *mac_addr)
    116116{
    117117        errno_t rc;
     
    135135
    136136errno_t atrans_lookup_timeout(addr32_t ip_addr, usec_t timeout,
    137     addr48_t mac_addr)
     137    addr48_t *mac_addr)
    138138{
    139139        fibril_timer_t *t;
  • uspace/srv/net/ethip/atrans.h

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4242#include "ethip.h"
    4343
    44 extern errno_t atrans_add(addr32_t, addr48_t);
     44extern errno_t atrans_add(addr32_t, addr48_t *);
    4545extern errno_t atrans_remove(addr32_t);
    46 extern errno_t atrans_lookup(addr32_t, addr48_t);
    47 extern errno_t atrans_lookup_timeout(addr32_t, usec_t, addr48_t);
     46extern errno_t atrans_lookup(addr32_t, addr48_t *);
     47extern errno_t atrans_lookup_timeout(addr32_t, usec_t, addr48_t *);
    4848
    4949#endif
  • uspace/srv/net/ethip/ethip.c

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    177177        eth_frame_t frame;
    178178
    179         errno_t rc = arp_translate(nic, sdu->src, sdu->dest, frame.dest);
     179        errno_t rc = arp_translate(nic, sdu->src, sdu->dest, &frame.dest);
    180180        if (rc != EOK) {
    181181                log_msg(LOG_DEFAULT, LVL_WARN, "Failed to look up IPv4 address 0x%"
     
    184184        }
    185185
    186         addr48(nic->mac_addr, frame.src);
     186        addr48(&nic->mac_addr, &frame.src);
    187187        frame.etype_len = ETYPE_IP;
    188188        frame.data = sdu->data;
     
    208208        eth_frame_t frame;
    209209
    210         addr48(sdu->dest, frame.dest);
    211         addr48(nic->mac_addr, frame.src);
     210        addr48(&sdu->dest, &frame.dest);
     211        addr48(&nic->mac_addr, &frame.src);
    212212        frame.etype_len = ETYPE_IPV6;
    213213        frame.data = sdu->data;
     
    281281
    282282        ethip_nic_t *nic = (ethip_nic_t *) srv->arg;
    283         addr48(nic->mac_addr, *mac);
     283        addr48(&nic->mac_addr, mac);
    284284
    285285        return EOK;
     
    291291
    292292        ethip_nic_t *nic = (ethip_nic_t *) srv->arg;
    293         addr48(*mac, nic->mac_addr);
     293        addr48(mac, &nic->mac_addr);
    294294
    295295        return EOK;
  • uspace/srv/net/ethip/ethip_nic.c

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    193193        }
    194194
    195         addr48(nic_address.address, nic->mac_addr);
     195        mac48_decode(nic_address.address, &nic->mac_addr);
    196196
    197197        rc = nic_set_state(nic->sess, NIC_STATE_ACTIVE);
     
    400400
    401401                addr48_t mac;
    402                 addr48_solicited_node(v6, mac);
     402                addr48_solicited_node(v6, &mac);
    403403
    404404                /* Avoid duplicate addresses in the list */
     
    407407
    408408                for (size_t j = 0; j < i; j++) {
    409                         if (addr48_compare(mac_list[j].address, mac)) {
     409                        addr48_t mac_entry;
     410                        mac48_decode(mac_list[j].address, &mac_entry);
     411                        if (addr48_compare(&mac_entry, &mac)) {
    410412                                found = true;
    411413                                break;
     
    414416
    415417                if (!found) {
    416                         addr48(mac, mac_list[i].address);
     418                        mac48_encode(&mac, mac_list[i].address);
    417419                        i++;
    418                 } else
     420                } else {
    419421                        count--;
     422                }
    420423        }
    421424
  • uspace/srv/net/ethip/pdu.c

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    6060
    6161        hdr = (eth_header_t *)data;
    62         addr48(frame->src, hdr->src);
    63         addr48(frame->dest, hdr->dest);
     62        mac48_encode(&frame->src, hdr->src);
     63        mac48_encode(&frame->dest, hdr->dest);
    6464        hdr->etype_len = host2uint16_t_be(frame->etype_len);
    6565
     
    9393                return ENOMEM;
    9494
    95         addr48(hdr->src, frame->src);
    96         addr48(hdr->dest, frame->dest);
     95        mac48_decode(hdr->src, &frame->src);
     96        mac48_decode(hdr->dest, &frame->dest);
    9797        frame->etype_len = uint16_t_be2host(hdr->etype_len);
    9898
     
    140140        pfmt->proto_addr_size = IPV4_ADDR_SIZE;
    141141        pfmt->opcode = host2uint16_t_be(fopcode);
    142         addr48(packet->sender_hw_addr, pfmt->sender_hw_addr);
     142        mac48_encode(&packet->sender_hw_addr, pfmt->sender_hw_addr);
    143143        pfmt->sender_proto_addr =
    144144            host2uint32_t_be(packet->sender_proto_addr);
    145         addr48(packet->target_hw_addr, pfmt->target_hw_addr);
     145        mac48_encode(&packet->target_hw_addr, pfmt->target_hw_addr);
    146146        pfmt->target_proto_addr =
    147147            host2uint32_t_be(packet->target_proto_addr);
     
    203203        }
    204204
    205         addr48(pfmt->sender_hw_addr, packet->sender_hw_addr);
     205        mac48_decode(pfmt->sender_hw_addr, &packet->sender_hw_addr);
    206206        packet->sender_proto_addr =
    207207            uint32_t_be2host(pfmt->sender_proto_addr);
    208         addr48(pfmt->target_hw_addr, packet->target_hw_addr);
     208        mac48_decode(pfmt->target_hw_addr, &packet->target_hw_addr);
    209209        packet->target_proto_addr =
    210210            uint32_t_be2host(pfmt->target_proto_addr);
  • uspace/srv/net/ethip/pdu.h

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4444extern errno_t arp_pdu_encode(arp_eth_packet_t *, void **, size_t *);
    4545extern errno_t arp_pdu_decode(void *, size_t, arp_eth_packet_t *);
     46extern void mac48_encode(addr48_t *, void *);
     47extern void mac48_decode(void *, addr48_t *);
    4648
    4749#endif
  • uspace/srv/net/ethip/std.h

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3939
    4040#include <stdint.h>
    41 #include <inet/addr.h>
    4241
    4342#define ETH_ADDR_SIZE       6
     
    4847typedef struct {
    4948        /** Destination Address */
    50         addr48_t dest;
     49        uint8_t dest[ETH_ADDR_SIZE];
    5150        /** Source Address */
    52         addr48_t src;
     51        uint8_t src[ETH_ADDR_SIZE];
    5352        /** Ethertype or Length */
    5453        uint16_t etype_len;
     
    6867        uint16_t opcode;
    6968        /** Sender hardware address */
    70         addr48_t sender_hw_addr;
     69        uint8_t sender_hw_addr[ETH_ADDR_SIZE];
    7170        /** Sender protocol address */
    72         addr32_t sender_proto_addr;
     71        uint32_t sender_proto_addr;
    7372        /** Target hardware address */
    74         addr48_t target_hw_addr;
     73        uint8_t target_hw_addr[ETH_ADDR_SIZE];
    7574        /** Target protocol address */
    76         addr32_t target_proto_addr;
     75        uint32_t target_proto_addr;
    7776} __attribute__((packed)) arp_eth_packet_fmt_t;
    7877
  • uspace/srv/net/inetsrv/addrobj.c

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    239239                 * Translate local destination IPv6 address.
    240240                 */
    241                 rc = ndp_translate(lsrc_v6, ldest_v6, ldest_mac, addr->ilink);
     241                rc = ndp_translate(lsrc_v6, ldest_v6, &ldest_mac, addr->ilink);
    242242                if (rc != EOK)
    243243                        return rc;
    244244
    245                 return inet_link_send_dgram6(addr->ilink, ldest_mac, dgram,
     245                return inet_link_send_dgram6(addr->ilink, &ldest_mac, dgram,
    246246                    proto, ttl, df);
    247247        default:
  • uspace/srv/net/inetsrv/inet_link.c

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5656
    5757static 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);
     58static errno_t inet_iplink_change_addr(iplink_t *, addr48_t *);
    5959static inet_link_t *inet_link_get_by_id_locked(sysarg_t);
    6060
     
    7070    { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xfe, 0, 0, 0 };
    7171
    72 static void inet_link_local_node_ip(addr48_t mac_addr,
     72static void inet_link_local_node_ip(addr48_t *mac_addr,
    7373    addr128_t ip_addr)
    7474{
    7575        memcpy(ip_addr, link_local_node_ip, 16);
    7676
    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];
     77        ip_addr[8] = mac_addr->b[0] ^ 0x02;
     78        ip_addr[9] = mac_addr->b[1];
     79        ip_addr[10] = mac_addr->b[2];
     80        ip_addr[13] = mac_addr->b[3];
     81        ip_addr[14] = mac_addr->b[4];
     82        ip_addr[15] = mac_addr->b[5];
    8383}
    8484
     
    121121}
    122122
    123 static errno_t inet_iplink_change_addr(iplink_t *iplink, addr48_t mac)
     123static errno_t inet_iplink_change_addr(iplink_t *iplink, addr48_t *mac)
    124124{
    125125        log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_iplink_change_addr(): "
    126126            "new addr=%02x:%02x:%02x:%02x:%02x:%02x",
    127             mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
     127            mac->b[0], mac->b[1], mac->b[2], mac->b[3], mac->b[4], mac->b[5]);
    128128
    129129        list_foreach(inet_links, link_list, inet_link_t, ilink) {
     
    261261
    262262                addr128_t link_local;
    263                 inet_link_local_node_ip(ilink->mac, link_local);
     263                inet_link_local_node_ip(&ilink->mac, link_local);
    264264
    265265                inet_naddr_set6(link_local, 64, &addr6->naddr);
     
    387387 *
    388388 */
    389 errno_t inet_link_send_dgram6(inet_link_t *ilink, addr48_t ldest,
     389errno_t inet_link_send_dgram6(inet_link_t *ilink, addr48_t *ldest,
    390390    inet_dgram_t *dgram, uint8_t proto, uint8_t ttl, int df)
    391391{
     
    401401
    402402        iplink_sdu6_t sdu6;
    403         addr48(ldest, sdu6.dest);
     403        addr48(ldest, &sdu6.dest);
    404404
    405405        /*
  • uspace/srv/net/inetsrv/inet_link.h

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4545extern errno_t inet_link_send_dgram(inet_link_t *, addr32_t,
    4646    addr32_t, inet_dgram_t *, uint8_t, uint8_t, int);
    47 extern errno_t inet_link_send_dgram6(inet_link_t *, addr48_t, inet_dgram_t *,
     47extern errno_t inet_link_send_dgram6(inet_link_t *, addr48_t *, inet_dgram_t *,
    4848    uint8_t, uint8_t, int);
    4949extern inet_link_t *inet_link_get_by_id(sysarg_t);
  • uspace/srv/net/inetsrv/inetcfg.c

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2013 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    177177        linfo->def_mtu = ilink->def_mtu;
    178178        if (ilink->mac_valid) {
    179                 addr48(ilink->mac, linfo->mac_addr);
     179                addr48(&ilink->mac, &linfo->mac_addr);
    180180        } else {
    181                 memset(linfo->mac_addr, 0, sizeof(linfo->mac_addr));
     181                memset(&linfo->mac_addr, 0, sizeof(linfo->mac_addr));
    182182        }
    183183
  • uspace/srv/net/inetsrv/ndp.c

    r98a935e rf05edcb  
    6969        ndp_pdu_encode(packet, &dgram);
    7070
    71         inet_link_send_dgram6(link, packet->target_hw_addr, &dgram,
     71        inet_link_send_dgram6(link, &packet->target_hw_addr, &dgram,
    7272            IP_PROTO_ICMPV6, INET6_HOP_LIMIT_MAX, 0);
    7373
     
    108108                if (laddr != NULL) {
    109109                        rc = ntrans_add(packet.sender_proto_addr,
    110                             packet.sender_hw_addr);
     110                            &packet.sender_hw_addr);
    111111                        if (rc != EOK)
    112112                                return rc;
     
    115115
    116116                        reply.opcode = ICMPV6_NEIGHBOUR_ADVERTISEMENT;
    117                         addr48(laddr->ilink->mac, reply.sender_hw_addr);
     117                        addr48(&laddr->ilink->mac, &reply.sender_hw_addr);
    118118                        addr128(packet.target_proto_addr, reply.sender_proto_addr);
    119                         addr48(packet.sender_hw_addr, reply.target_hw_addr);
     119                        addr48(&packet.sender_hw_addr, &reply.target_hw_addr);
    120120                        addr128(packet.sender_proto_addr, reply.target_proto_addr);
    121121
     
    128128                if (laddr != NULL)
    129129                        return ntrans_add(packet.sender_proto_addr,
    130                             packet.sender_hw_addr);
     130                            &packet.sender_hw_addr);
    131131
    132132                break;
     
    151151 *
    152152 */
    153 errno_t ndp_translate(addr128_t src_addr, addr128_t ip_addr, addr48_t mac_addr,
     153errno_t ndp_translate(addr128_t src_addr, addr128_t ip_addr, addr48_t *mac_addr,
    154154    inet_link_t *ilink)
    155155{
     
    167167
    168168        packet.opcode = ICMPV6_NEIGHBOUR_SOLICITATION;
    169         addr48(ilink->mac, packet.sender_hw_addr);
     169        addr48(&ilink->mac, &packet.sender_hw_addr);
    170170        addr128(src_addr, packet.sender_proto_addr);
    171171        addr128(ip_addr, packet.solicited_ip);
    172         addr48_solicited_node(ip_addr, packet.target_hw_addr);
     172        addr48_solicited_node(ip_addr, &packet.target_hw_addr);
    173173        ndp_solicited_node_ip(ip_addr, packet.target_proto_addr);
    174174
  • uspace/srv/net/inetsrv/ndp.h

    r98a935e rf05edcb  
    6464
    6565extern errno_t ndp_received(inet_dgram_t *);
    66 extern errno_t ndp_translate(addr128_t, addr128_t, addr48_t, inet_link_t *);
     66extern errno_t ndp_translate(addr128_t, addr128_t, addr48_t *, inet_link_t *);
    6767
    6868#endif
  • uspace/srv/net/inetsrv/ntrans.c

    r98a935e rf05edcb  
    7373 *
    7474 */
    75 errno_t ntrans_add(addr128_t ip_addr, addr48_t mac_addr)
     75errno_t ntrans_add(addr128_t ip_addr, addr48_t *mac_addr)
    7676{
    7777        inet_ntrans_t *ntrans;
     
    8383
    8484        addr128(ip_addr, ntrans->ip_addr);
    85         addr48(mac_addr, ntrans->mac_addr);
     85        addr48(mac_addr, &ntrans->mac_addr);
    8686
    8787        fibril_mutex_lock(&ntrans_list_lock);
     
    134134 *
    135135 */
    136 errno_t ntrans_lookup(addr128_t ip_addr, addr48_t mac_addr)
     136errno_t ntrans_lookup(addr128_t ip_addr, addr48_t *mac_addr)
    137137{
    138138        fibril_mutex_lock(&ntrans_list_lock);
     
    144144
    145145        fibril_mutex_unlock(&ntrans_list_lock);
    146         addr48(ntrans->mac_addr, mac_addr);
     146        addr48(&ntrans->mac_addr, mac_addr);
    147147        return EOK;
    148148}
  • uspace/srv/net/inetsrv/ntrans.h

    r98a935e rf05edcb  
    4848} inet_ntrans_t;
    4949
    50 extern errno_t ntrans_add(addr128_t, addr48_t);
     50extern errno_t ntrans_add(addr128_t, addr48_t *);
    5151extern errno_t ntrans_remove(addr128_t);
    52 extern errno_t ntrans_lookup(addr128_t, addr48_t);
     52extern errno_t ntrans_lookup(addr128_t, addr48_t *);
    5353extern errno_t ntrans_wait_timeout(usec_t);
    5454
  • uspace/srv/net/inetsrv/pdu.c

    r98a935e rf05edcb  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4040#include <errno.h>
    4141#include <fibril_synch.h>
     42#include <inet/eth_addr.h>
    4243#include <io/log.h>
    4344#include <macros.h>
     
    504505
    505506        message->length = 1;
    506         addr48(ndp->sender_hw_addr, message->mac);
     507        mac48_encode(&ndp->sender_hw_addr, message->mac);
    507508
    508509        icmpv6_phdr_t phdr;
     
    552553
    553554        addr128_t_be2host(message->target_address, ndp->target_proto_addr);
    554         addr48(message->mac, ndp->sender_hw_addr);
     555        mac48_decode(message->mac, &ndp->sender_hw_addr);
    555556
    556557        return EOK;
Note: See TracChangeset for help on using the changeset viewer.