Changeset b4edc96 in mainline


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

Rename and move addr48_t to eth_addr_t

Location:
uspace
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/inet/include/inet/addr.h

    rd5ed54b rb4edc96  
    3737
    3838#include <errno.h>
     39#include <inet/eth_addr.h>
    3940#include <stdint.h>
    4041
    4142typedef uint32_t addr32_t;
    42 
    43 #define ETH_ADDR_SIZE 6
    44 
    45 typedef struct {
    46         uint8_t b[ETH_ADDR_SIZE];
    47 } addr48_t;
    4843
    4944typedef uint8_t addr128_t[16];
     
    8479
    8580extern const addr32_t addr32_broadcast_all_hosts;
    86 extern const addr48_t addr48_broadcast;
    8781
    8882extern void addr128(const addr128_t, addr128_t);
    8983
    90 extern int addr48_compare(const addr48_t *, const addr48_t *);
    9184extern int addr128_compare(const addr128_t, const addr128_t);
    92 
    93 extern void addr48_solicited_node(const addr128_t, addr48_t *);
     85extern void eth_addr_solicited_node(const addr128_t, eth_addr_t *);
    9486
    9587extern void host2addr128_t_be(const addr128_t, addr128_t);
  • uspace/lib/inet/include/inet/eth_addr.h

    rd5ed54b rb4edc96  
    3838#define _LIBC_INET_ETH_ADDR_H_
    3939
    40 // XXX Move addr48 here
    41 #include <inet/addr.h>
     40#include <stdint.h>
    4241
    43 extern void mac48_encode(addr48_t *, void *);
    44 extern void mac48_decode(const void *, addr48_t *);
     42#define ETH_ADDR_SIZE 6
     43
     44typedef struct {
     45        uint8_t b[ETH_ADDR_SIZE];
     46} eth_addr_t;
     47
     48extern const eth_addr_t eth_addr_broadcast;
     49
     50extern void eth_addr_encode(eth_addr_t *, void *);
     51extern void eth_addr_decode(const void *, eth_addr_t *);
     52
     53extern int eth_addr_compare(const eth_addr_t *, const eth_addr_t *);
    4554
    4655#endif
  • uspace/lib/inet/include/inet/iplink.h

    rd5ed54b rb4edc96  
    3838#include <async.h>
    3939#include <inet/addr.h>
     40#include <inet/eth_addr.h>
    4041
    4142struct iplink_ev_ops;
     
    6263typedef struct {
    6364        /** Local MAC destination address */
    64         addr48_t dest;
     65        eth_addr_t dest;
    6566        /** Serialized IP packet */
    6667        void *data;
     
    7980typedef struct iplink_ev_ops {
    8081        errno_t (*recv)(iplink_t *, iplink_recv_sdu_t *, ip_ver_t);
    81         errno_t (*change_addr)(iplink_t *, addr48_t *);
     82        errno_t (*change_addr)(iplink_t *, eth_addr_t *);
    8283} iplink_ev_ops_t;
    8384
     
    8990extern errno_t iplink_addr_remove(iplink_t *, inet_addr_t *);
    9091extern errno_t iplink_get_mtu(iplink_t *, size_t *);
    91 extern errno_t iplink_get_mac48(iplink_t *, addr48_t *);
    92 extern errno_t iplink_set_mac48(iplink_t *, addr48_t *);
     92extern errno_t iplink_get_mac48(iplink_t *, eth_addr_t *);
     93extern errno_t iplink_set_mac48(iplink_t *, eth_addr_t *);
    9394extern void *iplink_get_userptr(iplink_t *);
    9495
  • uspace/lib/inet/include/inet/iplink_srv.h

    rd5ed54b rb4edc96  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3838#include <async.h>
    3939#include <fibril_synch.h>
     40#include <inet/addr.h>
     41#include <inet/eth_addr.h>
     42#include <inet/iplink.h>
    4043#include <stdbool.h>
    41 #include <inet/addr.h>
    42 #include <inet/iplink.h>
    4344
    4445struct iplink_ops;
     
    5859        errno_t (*send6)(iplink_srv_t *, iplink_sdu6_t *);
    5960        errno_t (*get_mtu)(iplink_srv_t *, size_t *);
    60         errno_t (*get_mac48)(iplink_srv_t *, addr48_t *);
    61         errno_t (*set_mac48)(iplink_srv_t *, addr48_t *);
     61        errno_t (*get_mac48)(iplink_srv_t *, eth_addr_t *);
     62        errno_t (*set_mac48)(iplink_srv_t *, eth_addr_t *);
    6263        errno_t (*addr_add)(iplink_srv_t *, inet_addr_t *);
    6364        errno_t (*addr_remove)(iplink_srv_t *, inet_addr_t *);
     
    6869extern errno_t iplink_conn(ipc_call_t *, void *);
    6970extern errno_t iplink_ev_recv(iplink_srv_t *, iplink_recv_sdu_t *, ip_ver_t);
    70 extern errno_t iplink_ev_change_addr(iplink_srv_t *, addr48_t *);
     71extern errno_t iplink_ev_change_addr(iplink_srv_t *, eth_addr_t *);
    7172
    7273#endif
  • uspace/lib/inet/include/types/inetcfg.h

    rd5ed54b rb4edc96  
    11/*
    2  * Copyright (c) 2013 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3636#define _LIBC_TYPES_INETCFG_H_
    3737
     38#include <inet/eth_addr.h>
    3839#include <inet/inet.h>
    3940#include <stddef.h>
     
    5657        size_t def_mtu;
    5758        /** Link layer address */
    58         addr48_t mac_addr;
     59        eth_addr_t mac_addr;
    5960} inet_link_info_t;
    6061
  • uspace/lib/inet/src/addr.c

    rd5ed54b rb4edc96  
    3737#include <errno.h>
    3838#include <inet/addr.h>
     39#include <inet/eth_addr.h>
    3940#include <stdio.h>
    4041#include <stddef.h>
     
    5455const addr32_t addr32_broadcast_all_hosts = 0xffffffff;
    5556
    56 const addr48_t addr48_broadcast = {
    57         0xff, 0xff, 0xff, 0xff, 0xff, 0xff
    58 };
    59 
    60 static const addr48_t inet_addr48_solicited_node = {
     57static const eth_addr_t inet_eth_addr_solicited_node = {
    6158        0x33, 0x33, 0xff, 0, 0, 0
    6259};
     
    7774}
    7875
    79 /** Compare addr48.
    80  *
    81  * @return Non-zero if equal, zero if not equal.
    82  */
    83 int addr48_compare(const addr48_t *a, const addr48_t *b)
    84 {
    85         return memcmp(a->b, b->b, 6) == 0;
    86 }
    87 
    8876/** Compare addr128.
    8977 *
     
    10189 *
    10290 */
    103 void addr48_solicited_node(const addr128_t ip, addr48_t *mac)
    104 {
    105         memcpy(&mac->b[0], &inet_addr48_solicited_node.b[0], 3);
     91void eth_addr_solicited_node(const addr128_t ip, eth_addr_t *mac)
     92{
     93        memcpy(&mac->b[0], &inet_eth_addr_solicited_node.b[0], 3);
    10694        memcpy(&mac->b[3], ip + 13, 3);
    10795}
  • uspace/lib/inet/src/eth_addr.c

    rd5ed54b rb4edc96  
    3838#include <mem.h>
    3939
    40 void mac48_encode(addr48_t *addr, void *buf)
     40const eth_addr_t eth_addr_broadcast = {
     41        0xff, 0xff, 0xff, 0xff, 0xff, 0xff
     42};
     43
     44void eth_addr_encode(eth_addr_t *addr, void *buf)
    4145{
    4246        uint8_t *bp = (uint8_t *)buf;
     
    4549}
    4650
    47 void mac48_decode(const void *buf, addr48_t *addr)
     51void eth_addr_decode(const void *buf, eth_addr_t *addr)
    4852{
    4953        const uint8_t *bp = (uint8_t *)buf;
     
    5256}
    5357
     58/** Compare ethernet addresses.
     59 *
     60 * @return Non-zero if equal, zero if not equal.
     61 */
     62int eth_addr_compare(const eth_addr_t *a, const eth_addr_t *b)
     63{
     64        return memcmp(a->b, b->b, ETH_ADDR_SIZE) == 0;
     65}
     66
    5467/** @}
    5568 */
  • uspace/lib/inet/src/inetcfg.c

    rd5ed54b rb4edc96  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3030#include <assert.h>
    3131#include <errno.h>
     32#include <inet/eth_addr.h>
    3233#include <inet/inetcfg.h>
    3334#include <ipc/inet.h>
     
    292293        aid_t req = async_send_1(exch, INETCFG_LINK_GET, link_id, &answer);
    293294        aid_t dreq = async_data_read(exch, name_buf, LOC_NAME_MAXLEN, &dreply);
    294         errno_t rc = async_data_read_start(exch, &linfo->mac_addr, sizeof(addr48_t));
     295        errno_t rc = async_data_read_start(exch, &linfo->mac_addr, sizeof(eth_addr_t));
    295296        async_wait_for(dreq, &dretval);
    296297
  • uspace/lib/inet/src/iplink.c

    rd5ed54b rb4edc96  
    3838#include <assert.h>
    3939#include <errno.h>
     40#include <inet/addr.h>
     41#include <inet/eth_addr.h>
    4042#include <inet/iplink.h>
    41 #include <inet/addr.h>
    4243#include <ipc/iplink.h>
    4344#include <ipc/services.h>
     
    115116        aid_t req = async_send_0(exch, IPLINK_SEND6, &answer);
    116117
    117         errno_t rc = async_data_write_start(exch, &sdu->dest, sizeof(addr48_t));
     118        errno_t rc = async_data_write_start(exch, &sdu->dest, sizeof(eth_addr_t));
    118119        if (rc != EOK) {
    119120                async_exchange_end(exch);
     
    153154}
    154155
    155 errno_t iplink_get_mac48(iplink_t *iplink, addr48_t *mac)
     156errno_t iplink_get_mac48(iplink_t *iplink, eth_addr_t *mac)
    156157{
    157158        async_exch_t *exch = async_exchange_begin(iplink->sess);
     
    160161        aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer);
    161162
    162         errno_t rc = async_data_read_start(exch, mac, sizeof(addr48_t));
     163        errno_t rc = async_data_read_start(exch, mac, sizeof(eth_addr_t));
    163164
    164165        loc_exchange_end(exch);
     
    175176}
    176177
    177 errno_t iplink_set_mac48(iplink_t *iplink, addr48_t *mac)
     178errno_t iplink_set_mac48(iplink_t *iplink, eth_addr_t *mac)
    178179{
    179180        async_exch_t *exch = async_exchange_begin(iplink->sess);
     
    182183        aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer);
    183184
    184         errno_t rc = async_data_read_start(exch, mac, sizeof(addr48_t));
     185        errno_t rc = async_data_read_start(exch, mac, sizeof(eth_addr_t));
    185186
    186187        loc_exchange_end(exch);
     
    264265static void iplink_ev_change_addr(iplink_t *iplink, ipc_call_t *icall)
    265266{
    266         addr48_t *addr;
     267        eth_addr_t *addr;
    267268        size_t size;
    268269
    269270        errno_t rc = async_data_write_accept((void **) &addr, false,
    270             sizeof(addr48_t), sizeof(addr48_t), 0, &size);
     271            sizeof(eth_addr_t), sizeof(eth_addr_t), 0, &size);
    271272        if (rc != EOK) {
    272273                async_answer_0(icall, rc);
  • uspace/lib/inet/src/iplink_srv.c

    rd5ed54b rb4edc96  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3636
    3737#include <errno.h>
     38#include <inet/eth_addr.h>
    3839#include <ipc/iplink.h>
    3940#include <stdlib.h>
     
    5152static void iplink_get_mac48_srv(iplink_srv_t *srv, ipc_call_t *icall)
    5253{
    53         addr48_t mac;
     54        eth_addr_t mac;
    5455        errno_t rc = srv->ops->get_mac48(srv, &mac);
    5556        if (rc != EOK) {
     
    6667        }
    6768
    68         if (size != sizeof(addr48_t)) {
     69        if (size != sizeof(eth_addr_t)) {
    6970                async_answer_0(&call, EINVAL);
    7071                async_answer_0(icall, EINVAL);
     
    8384        errno_t rc;
    8485        size_t size;
    85         addr48_t mac;
     86        eth_addr_t mac;
    8687
    8788        ipc_call_t call;
     
    9798        }
    9899
    99         rc = async_data_read_finalize(&call, &mac, sizeof(addr48_t));
     100        rc = async_data_read_finalize(&call, &mac, sizeof(eth_addr_t));
    100101        if (rc != EOK)
    101102                async_answer_0(&call, rc);
     
    189190        }
    190191
    191         if (size != sizeof(addr48_t)) {
     192        if (size != sizeof(eth_addr_t)) {
    192193                async_answer_0(&call, EINVAL);
    193194                async_answer_0(icall, EINVAL);
     
    322323}
    323324
    324 errno_t iplink_ev_change_addr(iplink_srv_t *srv, addr48_t *addr)
     325errno_t iplink_ev_change_addr(iplink_srv_t *srv, eth_addr_t *addr)
    325326{
    326327        if (srv->client_sess == NULL)
     
    332333        aid_t req = async_send_0(exch, IPLINK_EV_CHANGE_ADDR, &answer);
    333334
    334         errno_t rc = async_data_write_start(exch, addr, sizeof(addr48_t));
     335        errno_t rc = async_data_write_start(exch, addr, sizeof(eth_addr_t));
    335336        async_exchange_end(exch);
    336337
  • uspace/srv/net/dhcp/dhcp.c

    rd5ed54b rb4edc96  
    4242#include <fibril_synch.h>
    4343#include <inet/addr.h>
     44#include <inet/eth_addr.h>
    4445#include <inet/dnsr.h>
    4546#include <inet/inetcfg.h>
     
    157158        hdr->op = op_bootrequest;
    158159        hdr->htype = 1; /* AHRD_ETHERNET */
    159         hdr->hlen = sizeof(addr48_t);
     160        hdr->hlen = ETH_ADDR_SIZE;
    160161        hdr->xid = host2uint32_t_be(42);
    161162        hdr->flags = flag_broadcast;
  • uspace/srv/net/ethip/arp.c

    rd5ed54b rb4edc96  
    3636
    3737#include <errno.h>
    38 #include <io/log.h>
    3938#include <inet/iplink_srv.h>
    4039#include <inet/addr.h>
     40#include <inet/eth_addr.h>
     41#include <io/log.h>
    4142#include <stdlib.h>
    4243#include "arp.h"
     
    9596
    9697errno_t arp_translate(ethip_nic_t *nic, addr32_t src_addr, addr32_t ip_addr,
    97     addr48_t *mac_addr)
     98    eth_addr_t *mac_addr)
    9899{
    99100        /* Broadcast address */
    100101        if (ip_addr == addr32_broadcast_all_hosts) {
    101                 *mac_addr = addr48_broadcast;
     102                *mac_addr = eth_addr_broadcast;
    102103                return EOK;
    103104        }
     
    112113        packet.sender_hw_addr = nic->mac_addr;
    113114        packet.sender_proto_addr = src_addr;
    114         packet.target_hw_addr = addr48_broadcast;
     115        packet.target_hw_addr = eth_addr_broadcast;
    115116        packet.target_proto_addr = ip_addr;
    116117
  • uspace/srv/net/ethip/arp.h

    rd5ed54b rb4edc96  
    3838#define ARP_H_
    3939
     40#include <inet/addr.h>
     41#include <inet/eth_addr.h>
    4042#include <inet/iplink_srv.h>
    41 #include <inet/addr.h>
    4243#include "ethip.h"
    4344
    4445extern void arp_received(ethip_nic_t *, eth_frame_t *);
    45 extern errno_t arp_translate(ethip_nic_t *, addr32_t, addr32_t, addr48_t *);
     46extern errno_t arp_translate(ethip_nic_t *, addr32_t, addr32_t, eth_addr_t *);
    4647
    4748#endif
  • uspace/srv/net/ethip/atrans.c

    rd5ed54b rb4edc96  
    3838#include <errno.h>
    3939#include <fibril_synch.h>
     40#include <inet/eth_addr.h>
    4041#include <inet/iplink_srv.h>
    4142#include <stdlib.h>
     
    5960}
    6061
    61 errno_t atrans_add(addr32_t ip_addr, addr48_t *mac_addr)
     62errno_t atrans_add(addr32_t ip_addr, eth_addr_t *mac_addr)
    6263{
    6364        ethip_atrans_t *atrans;
     
    103104}
    104105
    105 static errno_t atrans_lookup_locked(addr32_t ip_addr, addr48_t *mac_addr)
     106static errno_t atrans_lookup_locked(addr32_t ip_addr, eth_addr_t *mac_addr)
    106107{
    107108        ethip_atrans_t *atrans = atrans_find(ip_addr);
     
    113114}
    114115
    115 errno_t atrans_lookup(addr32_t ip_addr, addr48_t *mac_addr)
     116errno_t atrans_lookup(addr32_t ip_addr, eth_addr_t *mac_addr)
    116117{
    117118        errno_t rc;
     
    135136
    136137errno_t atrans_lookup_timeout(addr32_t ip_addr, usec_t timeout,
    137     addr48_t *mac_addr)
     138    eth_addr_t *mac_addr)
    138139{
    139140        fibril_timer_t *t;
  • uspace/srv/net/ethip/atrans.h

    rd5ed54b rb4edc96  
    3838#define ATRANS_H_
    3939
     40#include <inet/addr.h>
     41#include <inet/eth_addr.h>
    4042#include <inet/iplink_srv.h>
    41 #include <inet/addr.h>
    4243#include "ethip.h"
    4344
    44 extern errno_t atrans_add(addr32_t, addr48_t *);
     45extern errno_t atrans_add(addr32_t, eth_addr_t *);
    4546extern 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 *);
     47extern errno_t atrans_lookup(addr32_t, eth_addr_t *);
     48extern errno_t atrans_lookup_timeout(addr32_t, usec_t, eth_addr_t *);
    4849
    4950#endif
  • uspace/srv/net/ethip/ethip.c

    rd5ed54b rb4edc96  
    3939#include <async.h>
    4040#include <errno.h>
     41#include <inet/eth_addr.h>
    4142#include <inet/iplink_srv.h>
    4243#include <io/log.h>
     
    5859static errno_t ethip_send6(iplink_srv_t *srv, iplink_sdu6_t *sdu);
    5960static errno_t ethip_get_mtu(iplink_srv_t *srv, size_t *mtu);
    60 static errno_t ethip_get_mac48(iplink_srv_t *srv, addr48_t *mac);
    61 static errno_t ethip_set_mac48(iplink_srv_t *srv, addr48_t *mac);
     61static errno_t ethip_get_mac48(iplink_srv_t *srv, eth_addr_t *mac);
     62static errno_t ethip_set_mac48(iplink_srv_t *srv, eth_addr_t *mac);
    6263static errno_t ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr);
    6364static errno_t ethip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr);
     
    276277}
    277278
    278 static errno_t ethip_get_mac48(iplink_srv_t *srv, addr48_t *mac)
     279static errno_t ethip_get_mac48(iplink_srv_t *srv, eth_addr_t *mac)
    279280{
    280281        log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_get_mac48()");
     
    286287}
    287288
    288 static errno_t ethip_set_mac48(iplink_srv_t *srv, addr48_t *mac)
     289static errno_t ethip_set_mac48(iplink_srv_t *srv, eth_addr_t *mac)
    289290{
    290291        log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_set_mac48()");
  • uspace/srv/net/ethip/ethip.h

    rd5ed54b rb4edc96  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4040#include <adt/list.h>
    4141#include <async.h>
     42#include <inet/addr.h>
     43#include <inet/eth_addr.h>
    4244#include <inet/iplink_srv.h>
    43 #include <inet/addr.h>
    4445#include <loc.h>
    4546#include <stddef.h>
     
    6162
    6263        /** MAC address */
    63         addr48_t mac_addr;
     64        eth_addr_t mac_addr;
    6465
    6566        /**
     
    7374typedef struct {
    7475        /** Destination Address */
    75         addr48_t dest;
     76        eth_addr_t dest;
    7677        /** Source Address */
    77         addr48_t src;
     78        eth_addr_t src;
    7879        /** Ethertype or Length */
    7980        uint16_t etype_len;
     
    100101        arp_opcode_t opcode;
    101102        /** Sender hardware address */
    102         addr48_t sender_hw_addr;
     103        eth_addr_t sender_hw_addr;
    103104        /** Sender protocol address */
    104105        addr32_t sender_proto_addr;
    105106        /** Target hardware address */
    106         addr48_t target_hw_addr;
     107        eth_addr_t target_hw_addr;
    107108        /** Target protocol address */
    108109        addr32_t target_proto_addr;
     
    113114        link_t atrans_list;
    114115        addr32_t ip_addr;
    115         addr48_t mac_addr;
     116        eth_addr_t mac_addr;
    116117} ethip_atrans_t;
    117118
  • uspace/srv/net/ethip/ethip_nic.c

    rd5ed54b rb4edc96  
    3737#include <adt/list.h>
    3838#include <async.h>
    39 #include <stdbool.h>
    4039#include <errno.h>
    41 #include <str_error.h>
    4240#include <fibril_synch.h>
     41#include <inet/eth_addr.h>
    4342#include <inet/iplink_srv.h>
    4443#include <io/log.h>
    4544#include <loc.h>
     45#include <mem.h>
    4646#include <nic_iface.h>
     47#include <stdbool.h>
    4748#include <stdlib.h>
    48 #include <mem.h>
     49#include <str_error.h>
    4950#include "ethip.h"
    5051#include "ethip_nic.h"
     
    193194        }
    194195
    195         mac48_decode(nic_address.address, &nic->mac_addr);
     196        eth_addr_decode(nic_address.address, &nic->mac_addr);
    196197
    197198        rc = nic_set_state(nic->sess, NIC_STATE_ACTIVE);
     
    399400                assert(i < count);
    400401
    401                 addr48_t mac;
    402                 addr48_solicited_node(v6, &mac);
     402                eth_addr_t mac;
     403                eth_addr_solicited_node(v6, &mac);
    403404
    404405                /* Avoid duplicate addresses in the list */
     
    407408
    408409                for (size_t j = 0; j < i; j++) {
    409                         addr48_t mac_entry;
    410                         mac48_decode(mac_list[j].address, &mac_entry);
    411                         if (addr48_compare(&mac_entry, &mac)) {
     410                        eth_addr_t mac_entry;
     411                        eth_addr_decode(mac_list[j].address, &mac_entry);
     412                        if (eth_addr_compare(&mac_entry, &mac)) {
    412413                                found = true;
    413414                                break;
     
    416417
    417418                if (!found) {
    418                         mac48_encode(&mac, mac_list[i].address);
     419                        eth_addr_encode(&mac, mac_list[i].address);
    419420                        i++;
    420421                } else {
  • uspace/srv/net/ethip/pdu.c

    rd5ed54b rb4edc96  
    6060
    6161        hdr = (eth_header_t *)data;
    62         mac48_encode(&frame->src, hdr->src);
    63         mac48_encode(&frame->dest, hdr->dest);
     62        eth_addr_encode(&frame->src, hdr->src);
     63        eth_addr_encode(&frame->dest, hdr->dest);
    6464        hdr->etype_len = host2uint16_t_be(frame->etype_len);
    6565
     
    9393                return ENOMEM;
    9494
    95         mac48_decode(hdr->src, &frame->src);
    96         mac48_decode(hdr->dest, &frame->dest);
     95        eth_addr_decode(hdr->src, &frame->src);
     96        eth_addr_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         mac48_encode(&packet->sender_hw_addr, pfmt->sender_hw_addr);
     142        eth_addr_encode(&packet->sender_hw_addr, pfmt->sender_hw_addr);
    143143        pfmt->sender_proto_addr =
    144144            host2uint32_t_be(packet->sender_proto_addr);
    145         mac48_encode(&packet->target_hw_addr, pfmt->target_hw_addr);
     145        eth_addr_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         mac48_decode(pfmt->sender_hw_addr, &packet->sender_hw_addr);
     205        eth_addr_decode(pfmt->sender_hw_addr, &packet->sender_hw_addr);
    206206        packet->sender_proto_addr =
    207207            uint32_t_be2host(pfmt->sender_proto_addr);
    208         mac48_decode(pfmt->target_hw_addr, &packet->target_hw_addr);
     208        eth_addr_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

    rd5ed54b rb4edc96  
    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 *);
    46 extern void mac48_encode(addr48_t *, void *);
    47 extern void mac48_decode(void *, addr48_t *);
    4846
    4947#endif
  • uspace/srv/net/inetsrv/addrobj.c

    rd5ed54b rb4edc96  
    3838#include <errno.h>
    3939#include <fibril_synch.h>
     40#include <inet/eth_addr.h>
    4041#include <io/log.h>
    4142#include <ipc/loc.h>
     
    229230
    230231        errno_t rc;
    231         addr48_t ldest_mac;
     232        eth_addr_t ldest_mac;
    232233
    233234        switch (ldest_ver) {
  • uspace/srv/net/inetsrv/inet_link.c

    rd5ed54b rb4edc96  
    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{
     
    121122}
    122123
    123 static errno_t inet_iplink_change_addr(iplink_t *iplink, addr48_t *mac)
     124static errno_t inet_iplink_change_addr(iplink_t *iplink, eth_addr_t *mac)
    124125{
    125126        log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_iplink_change_addr(): "
     
    129130        list_foreach(inet_links, link_list, inet_link_t, ilink) {
    130131                if (ilink->sess == iplink->sess)
    131                         memcpy(&ilink->mac, mac, sizeof(addr48_t));
     132                        ilink->mac = *mac;
    132133        }
    133134
     
    387388 *
    388389 */
    389 errno_t inet_link_send_dgram6(inet_link_t *ilink, addr48_t *ldest,
     390errno_t inet_link_send_dgram6(inet_link_t *ilink, eth_addr_t *ldest,
    390391    inet_dgram_t *dgram, uint8_t proto, uint8_t ttl, int df)
    391392{
  • uspace/srv/net/inetsrv/inet_link.h

    rd5ed54b rb4edc96  
    3838#define INET_LINK_H_
    3939
     40#include <inet/eth_addr.h>
    4041#include <stddef.h>
    4142#include <stdint.h>
     
    4546extern errno_t inet_link_send_dgram(inet_link_t *, addr32_t,
    4647    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 *,
     48extern errno_t inet_link_send_dgram6(inet_link_t *, eth_addr_t *, inet_dgram_t *,
    4849    uint8_t, uint8_t, int);
    4950extern inet_link_t *inet_link_get_by_id(sysarg_t);
  • uspace/srv/net/inetsrv/inetsrv.h

    rd5ed54b rb4edc96  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4141#include <stdbool.h>
    4242#include <inet/addr.h>
     43#include <inet/eth_addr.h>
    4344#include <inet/iplink.h>
    4445#include <ipc/loc.h>
     
    109110        iplink_t *iplink;
    110111        size_t def_mtu;
    111         addr48_t mac;
     112        eth_addr_t mac;
    112113        bool mac_valid;
    113114} inet_link_t;
  • uspace/srv/net/inetsrv/ndp.c

    rd5ed54b rb4edc96  
    11/*
     2 * Copyright (c) 2021 Jiri Svoboda
    23 * Copyright (c) 2013 Antonin Steinhauser
    34 * All rights reserved.
     
    3637
    3738#include <errno.h>
     39#include <inet/eth_addr.h>
     40#include <io/log.h>
    3841#include <mem.h>
    3942#include <stdlib.h>
    40 #include <io/log.h>
    4143#include "ntrans.h"
    4244#include "addrobj.h"
     
    151153 *
    152154 */
    153 errno_t ndp_translate(addr128_t src_addr, addr128_t ip_addr, addr48_t *mac_addr,
     155errno_t ndp_translate(addr128_t src_addr, addr128_t ip_addr, eth_addr_t *mac_addr,
    154156    inet_link_t *ilink)
    155157{
     
    170172        addr128(src_addr, packet.sender_proto_addr);
    171173        addr128(ip_addr, packet.solicited_ip);
    172         addr48_solicited_node(ip_addr, &packet.target_hw_addr);
     174        eth_addr_solicited_node(ip_addr, &packet.target_hw_addr);
    173175        ndp_solicited_node_ip(ip_addr, packet.target_proto_addr);
    174176
  • uspace/srv/net/inetsrv/ndp.h

    rd5ed54b rb4edc96  
    11/*
     2 * Copyright (c) 2021 Jiri Svoboda
    23 * Copyright (c) 2013 Antonin Steinhauser
    34 * All rights reserved.
     
    3940
    4041#include <inet/addr.h>
     42#include <inet/eth_addr.h>
    4143#include "inetsrv.h"
    4244#include "icmpv6_std.h"
     
    5254        ndp_opcode_t opcode;
    5355        /** Sender hardware address */
    54         addr48_t sender_hw_addr;
     56        eth_addr_t sender_hw_addr;
    5557        /** Sender protocol address */
    5658        addr128_t sender_proto_addr;
    5759        /** Target hardware address */
    58         addr48_t target_hw_addr;
     60        eth_addr_t target_hw_addr;
    5961        /** Target protocol address */
    6062        addr128_t target_proto_addr;
     
    6466
    6567extern errno_t ndp_received(inet_dgram_t *);
    66 extern errno_t ndp_translate(addr128_t, addr128_t, addr48_t *, inet_link_t *);
     68extern errno_t ndp_translate(addr128_t, addr128_t, eth_addr_t *, inet_link_t *);
    6769
    6870#endif
  • uspace/srv/net/inetsrv/ntrans.c

    rd5ed54b rb4edc96  
    11/*
     2 * Copyright (c) 2021 Jiri Svoboda
    23 * Copyright (c) 2013 Antonin Steinhauser
    34 * All rights reserved.
     
    3839#include <errno.h>
    3940#include <fibril_synch.h>
     41#include <inet/eth_addr.h>
    4042#include <inet/iplink_srv.h>
    4143#include <stdlib.h>
     
    7375 *
    7476 */
    75 errno_t ntrans_add(addr128_t ip_addr, addr48_t *mac_addr)
     77errno_t ntrans_add(addr128_t ip_addr, eth_addr_t *mac_addr)
    7678{
    7779        inet_ntrans_t *ntrans;
     
    134136 *
    135137 */
    136 errno_t ntrans_lookup(addr128_t ip_addr, addr48_t *mac_addr)
     138errno_t ntrans_lookup(addr128_t ip_addr, eth_addr_t *mac_addr)
    137139{
    138140        fibril_mutex_lock(&ntrans_list_lock);
  • uspace/srv/net/inetsrv/ntrans.h

    rd5ed54b rb4edc96  
    11/*
     2 * Copyright (c) 2021 Jiri Svoboda
    23 * Copyright (c) 2013 Antonin Steinhauser
    34 * All rights reserved.
     
    3839#define NTRANS_H_
    3940
     41#include <inet/addr.h>
     42#include <inet/eth_addr.h>
    4043#include <inet/iplink_srv.h>
    41 #include <inet/addr.h>
    4244
    4345/** Address translation table element */
     
    4547        link_t ntrans_list;
    4648        addr128_t ip_addr;
    47         addr48_t mac_addr;
     49        eth_addr_t mac_addr;
    4850} inet_ntrans_t;
    4951
    50 extern errno_t ntrans_add(addr128_t, addr48_t *);
     52extern errno_t ntrans_add(addr128_t, eth_addr_t *);
    5153extern errno_t ntrans_remove(addr128_t);
    52 extern errno_t ntrans_lookup(addr128_t, addr48_t *);
     54extern errno_t ntrans_lookup(addr128_t, eth_addr_t *);
    5355extern errno_t ntrans_wait_timeout(usec_t);
    5456
  • uspace/srv/net/inetsrv/pdu.c

    rd5ed54b rb4edc96  
    505505
    506506        message->length = 1;
    507         mac48_encode(&ndp->sender_hw_addr, message->mac);
     507        eth_addr_encode(&ndp->sender_hw_addr, message->mac);
    508508
    509509        icmpv6_phdr_t phdr;
     
    553553
    554554        addr128_t_be2host(message->target_address, ndp->target_proto_addr);
    555         mac48_decode(message->mac, &ndp->sender_hw_addr);
     555        eth_addr_decode(message->mac, &ndp->sender_hw_addr);
    556556
    557557        return EOK;
  • uspace/srv/net/loopip/loopip.c

    rd5ed54b rb4edc96  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4141#include <inet/iplink_srv.h>
    4242#include <inet/addr.h>
     43#include <inet/eth_addr.h>
    4344#include <io/log.h>
    4445#include <loc.h>
     
    5556static errno_t loopip_send6(iplink_srv_t *srv, iplink_sdu6_t *sdu);
    5657static errno_t loopip_get_mtu(iplink_srv_t *srv, size_t *mtu);
    57 static errno_t loopip_get_mac48(iplink_srv_t *srv, addr48_t *mac);
     58static errno_t loopip_get_mac48(iplink_srv_t *srv, eth_addr_t *mac);
    5859static errno_t loopip_addr_add(iplink_srv_t *srv, inet_addr_t *addr);
    5960static errno_t loopip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr);
     
    231232}
    232233
    233 static errno_t loopip_get_mac48(iplink_srv_t *src, addr48_t *mac)
     234static errno_t loopip_get_mac48(iplink_srv_t *src, eth_addr_t *mac)
    234235{
    235236        log_msg(LOG_DEFAULT, LVL_DEBUG, "loopip_get_mac48()");
  • uspace/srv/net/slip/slip.c

    rd5ed54b rb4edc96  
    11/*
     2 * Copyright (c) 2021 Jiri Svoboda
    23 * Copyright (c) 2013 Jakub Jermar
    34 * All rights reserved.
     
    4041#include <loc.h>
    4142#include <inet/addr.h>
     43#include <inet/eth_addr.h>
    4244#include <inet/iplink_srv.h>
    4345#include <io/chardev.h>
     
    6264static errno_t slip_send6(iplink_srv_t *, iplink_sdu6_t *);
    6365static errno_t slip_get_mtu(iplink_srv_t *, size_t *);
    64 static errno_t slip_get_mac48(iplink_srv_t *, addr48_t *);
     66static errno_t slip_get_mac48(iplink_srv_t *, eth_addr_t *);
    6567static errno_t slip_addr_add(iplink_srv_t *, inet_addr_t *);
    6668static errno_t slip_addr_remove(iplink_srv_t *, inet_addr_t *);
     
    176178}
    177179
    178 errno_t slip_get_mac48(iplink_srv_t *src, addr48_t *mac)
     180errno_t slip_get_mac48(iplink_srv_t *src, eth_addr_t *mac)
    179181{
    180182        log_msg(LOG_DEFAULT, LVL_DEBUG, "slip_get_mac48()");
Note: See TracChangeset for help on using the changeset viewer.