Changeset b4edc96 in mainline for uspace/lib/inet


Ignore:
Timestamp:
2021-08-08T09:20:20Z (4 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/lib/inet
Files:
10 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
Note: See TracChangeset for help on using the changeset viewer.