Changeset 8a9a41e in mainline for uspace/srv


Ignore:
Timestamp:
2021-10-24T08:28:43Z (4 years ago)
Author:
GitHub <noreply@…>
Children:
08d81ae
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

Location:
uspace/srv
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/console/console.c

    r2ce943a r8a9a41e  
    6363typedef struct {
    6464        atomic_flag refcnt;      /**< Connection reference count */
    65         prodcons_t input_pc;  /**< Incoming keyboard events */
     65        prodcons_t input_pc;  /**< Incoming console events */
    6666
    6767        /**
     
    9999static sysarg_t cols;
    100100static sysarg_t rows;
     101
     102/** Mouse pointer X coordinate */
     103static int pointer_x;
     104/** Mouse pointer Y coordinate */
     105static int pointer_y;
     106/** Character under mouse cursor */
     107static charfield_t pointer_bg;
     108
     109static int mouse_scale_x = 4;
     110static int mouse_scale_y = 8;
    101111
    102112/** Array of data for virtual consoles */
     
    166176};
    167177
     178static void pointer_draw(void);
     179static void pointer_undraw(void);
     180
    168181static console_t *srv_to_console(con_srv_t *srv)
    169182{
     
    231244
    232245        fibril_mutex_lock(&switch_mtx);
     246        pointer_undraw();
    233247
    234248        if (cons == active_console) {
     
    239253        active_console = cons;
    240254
     255        pointer_draw();
    241256        fibril_mutex_unlock(&switch_mtx);
    242257
    243258        cons_damage(cons);
     259}
     260
     261/** Draw mouse pointer. */
     262static void pointer_draw(void)
     263{
     264        charfield_t *ch;
     265        int col, row;
     266
     267        /* Downscale coordinates to text resolution */
     268        col = pointer_x / mouse_scale_x;
     269        row = pointer_y / mouse_scale_y;
     270
     271        /* Make sure they are in range */
     272        if (col < 0 || row < 0 || col >= (int)cols || row >= (int)rows)
     273                return;
     274
     275        ch = chargrid_charfield_at(active_console->frontbuf, col, row);
     276
     277        /*
     278         * Store background attributes for undrawing the pointer.
     279         * This is necessary as styles cannot be inverted with
     280         * round trip (unlike RGB or INDEX)
     281         */
     282        pointer_bg = *ch;
     283
     284        /* In general the color should be a one's complement of the background */
     285        if (ch->attrs.type == CHAR_ATTR_INDEX) {
     286                ch->attrs.val.index.bgcolor ^= 0xf;
     287                ch->attrs.val.index.fgcolor ^= 0xf;
     288        } else if (ch->attrs.type == CHAR_ATTR_RGB) {
     289                ch->attrs.val.rgb.fgcolor ^= 0xffffff;
     290                ch->attrs.val.rgb.bgcolor ^= 0xffffff;
     291        } else if (ch->attrs.type == CHAR_ATTR_STYLE) {
     292                /* Don't have a proper inverse for each style */
     293                if (ch->attrs.val.style == STYLE_INVERTED)
     294                        ch->attrs.val.style = STYLE_NORMAL;
     295                else
     296                        ch->attrs.val.style = STYLE_INVERTED;
     297        }
     298
     299        /* Make sure the cell gets updated */
     300        ch->flags |= CHAR_FLAG_DIRTY;
     301}
     302
     303/** Undraw mouse pointer. */
     304static void pointer_undraw(void)
     305{
     306        charfield_t *ch;
     307        int col, row;
     308
     309        col = pointer_x / mouse_scale_x;
     310        row = pointer_y / mouse_scale_y;
     311        if (col < 0 || row < 0 || col >= (int)cols || row >= (int)rows)
     312                return;
     313
     314        ch = chargrid_charfield_at(active_console->frontbuf, col, row);
     315        *ch = pointer_bg;
     316        ch->flags |= CHAR_FLAG_DIRTY;
     317}
     318
     319/** Queue console event.
     320 *
     321 * @param cons Console
     322 * @param ev Console event
     323 */
     324static void console_queue_cons_event(console_t *cons, cons_event_t *ev)
     325{
     326        /* Got key press/release event */
     327        cons_event_t *event =
     328            (cons_event_t *) malloc(sizeof(cons_event_t));
     329        if (event == NULL)
     330                return;
     331
     332        *event = *ev;
     333        link_initialize(&event->link);
     334
     335        prodcons_produce(&cons->input_pc, &event->link);
    244336}
    245337
     
    264356    keymod_t mods, char32_t c)
    265357{
     358        cons_event_t event;
     359
    266360        if ((key >= KC_F1) && (key <= KC_F1 + CONSOLE_COUNT) &&
    267361            ((mods & KM_CTRL) == 0)) {
     
    269363        } else {
    270364                /* Got key press/release event */
    271                 kbd_event_t *event =
    272                     (kbd_event_t *) malloc(sizeof(kbd_event_t));
    273                 if (event == NULL) {
    274                         return ENOMEM;
    275                 }
    276 
    277                 link_initialize(&event->link);
    278                 event->type = type;
    279                 event->key = key;
    280                 event->mods = mods;
    281                 event->c = c;
    282 
    283                 prodcons_produce(&active_console->input_pc,
    284                     &event->link);
    285         }
    286 
    287         return EOK;
     365                event.type = CEV_KEY;
     366
     367                event.ev.key.type = type;
     368                event.ev.key.key = key;
     369                event.ev.key.mods = mods;
     370                event.ev.key.c = c;
     371
     372                console_queue_cons_event(active_console, &event);
     373        }
     374
     375        return EOK;
     376}
     377
     378/** Update pointer position.
     379 *
     380 * @param new_x New X coordinate (in pixels)
     381 * @param new_y New Y coordinate (in pixels)
     382 */
     383static void pointer_update(int new_x, int new_y)
     384{
     385        bool upd_pointer;
     386
     387        /* Make sure coordinates are in range */
     388
     389        if (new_x < 0)
     390                new_x = 0;
     391        if (new_x >= (int)cols * mouse_scale_x)
     392                new_x = cols * mouse_scale_x - 1;
     393        if (new_y < 0)
     394                new_y = 0;
     395        if (new_y >= (int)rows * mouse_scale_y)
     396                new_y = rows * mouse_scale_y - 1;
     397
     398        /* Determine if pointer moved to a different character cell */
     399        upd_pointer = (new_x / mouse_scale_x != pointer_x / mouse_scale_x) ||
     400            (new_y / mouse_scale_y != pointer_y / mouse_scale_y);
     401
     402        if (upd_pointer)
     403                pointer_undraw();
     404
     405        /* Store new pointer position */
     406        pointer_x = new_x;
     407        pointer_y = new_y;
     408
     409        if (upd_pointer) {
     410                pointer_draw();
     411                cons_update(active_console);
     412        }
    288413}
    289414
    290415static errno_t input_ev_move(input_t *input, int dx, int dy)
    291416{
     417        pointer_update(pointer_x + dx, pointer_y + dy);
    292418        return EOK;
    293419}
     
    296422    unsigned max_x, unsigned max_y)
    297423{
     424        pointer_update(mouse_scale_x * cols * x / max_x, mouse_scale_y * rows * y / max_y);
    298425        return EOK;
    299426}
     
    301428static errno_t input_ev_button(input_t *input, int bnum, int bpress)
    302429{
     430        cons_event_t event;
     431
     432        event.type = CEV_POS;
     433        event.ev.pos.type = bpress ? POS_PRESS : POS_RELEASE;
     434        event.ev.pos.btn_num = bnum;
     435        event.ev.pos.hpos = pointer_x / mouse_scale_x;
     436        event.ev.pos.vpos = pointer_y / mouse_scale_y;
     437
     438        console_queue_cons_event(active_console, &event);
    303439        return EOK;
    304440}
     
    310446
    311447        fibril_mutex_lock(&cons->mtx);
     448        pointer_undraw();
    312449
    313450        switch (ch) {
     
    327464        }
    328465
     466        pointer_draw();
    329467        fibril_mutex_unlock(&cons->mtx);
    330468
     
    336474{
    337475        fibril_mutex_lock(&cons->mtx);
     476        pointer_undraw();
    338477        chargrid_set_cursor_visibility(cons->frontbuf, visible);
     478        pointer_draw();
    339479        fibril_mutex_unlock(&cons->mtx);
    340480
     
    379519                if (pos < size) {
    380520                        link_t *link = prodcons_consume(&cons->input_pc);
    381                         kbd_event_t *event = list_get_instance(link, kbd_event_t, link);
     521                        cons_event_t *event = list_get_instance(link,
     522                            cons_event_t, link);
    382523
    383524                        /* Accept key presses of printable chars only. */
    384                         if ((event->type == KEY_PRESS) && (event->c != 0)) {
    385                                 char32_t tmp[2] = { event->c, 0 };
     525                        if (event->type == CEV_KEY && event->ev.key.type == KEY_PRESS &&
     526                            (event->ev.key.c != 0)) {
     527                                char32_t tmp[2] = { event->ev.key.c, 0 };
    386528                                wstr_to_str(cons->char_remains, UTF8_CHAR_BUFFER_SIZE, tmp);
    387529                                cons->char_remains_len = str_size(cons->char_remains);
     
    420562
    421563        fibril_mutex_lock(&cons->mtx);
     564        pointer_undraw();
    422565        chargrid_clear(cons->frontbuf);
     566        pointer_draw();
    423567        fibril_mutex_unlock(&cons->mtx);
    424568
     
    431575
    432576        fibril_mutex_lock(&cons->mtx);
     577        pointer_undraw();
    433578        chargrid_set_cursor(cons->frontbuf, col, row);
     579        pointer_draw();
    434580        fibril_mutex_unlock(&cons->mtx);
    435581
     
    511657        console_t *cons = srv_to_console(srv);
    512658        link_t *link = prodcons_consume(&cons->input_pc);
    513         kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link);
    514 
    515         event->type = CEV_KEY;
    516         event->ev.key = *kevent;
    517 
    518         free(kevent);
     659        cons_event_t *cevent = list_get_instance(link, cons_event_t, link);
     660
     661        *event = *cevent;
     662        free(cevent);
    519663        return EOK;
    520664}
     
    621765        /* Update front buffer from user buffer */
    622766
     767        pointer_undraw();
     768
    623769        for (row = r0; row < r1; row++) {
    624770                for (col = c0; col < c1; col++) {
     
    628774        }
    629775
     776        pointer_draw();
    630777        fibril_mutex_unlock(&cons->mtx);
    631778
  • uspace/srv/hid/display/display.c

    r2ce943a r8a9a41e  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5353static void ds_display_update_cb(void *);
    5454
     55static mem_gc_cb_t ds_display_mem_gc_cb = {
     56        .invalidate = ds_display_invalidate_cb,
     57        .update = ds_display_update_cb
     58};
     59
    5560/** Create display.
    5661 *
     
    459464                goto error;
    460465
    461         rc = mem_gc_create(&disp->rect, &alloc,
    462             ds_display_invalidate_cb, ds_display_update_cb, (void *) disp,
    463             &disp->bbgc);
     466        rc = mem_gc_create(&disp->rect, &alloc, &ds_display_mem_gc_cb,
     467            (void *) disp, &disp->bbgc);
    464468        if (rc != EOK)
    465469                goto error;
  • uspace/srv/hid/display/window.c

    r2ce943a r8a9a41e  
    5353static void ds_window_get_preview_rect(ds_window_t *, gfx_rect_t *);
    5454
     55static mem_gc_cb_t ds_window_mem_gc_cb = {
     56        .invalidate = ds_window_invalidate_cb,
     57        .update = ds_window_update_cb
     58};
     59
    5560/** Create window.
    5661 *
     
    108113        }
    109114
    110         rc = mem_gc_create(&params->rect, &alloc, ds_window_invalidate_cb,
    111             ds_window_update_cb, (void *)wnd, &wnd->mgc);
     115        rc = mem_gc_create(&params->rect, &alloc, &ds_window_mem_gc_cb,
     116            (void *)wnd, &wnd->mgc);
    112117        if (rc != EOK)
    113118                goto error;
  • uspace/srv/hid/input/input.c

    r2ce943a r8a9a41e  
    641641        kbd_add_dev(&chardev_port, &stty_ctl);
    642642#endif
     643#if defined(UARCH_arm64) && defined(MACHINE_hikey960)
     644        kbd_add_dev(&chardev_port, &stty_ctl);
     645#endif
    643646        /* Silence warning on abs32le about kbd_add_dev() being unused */
    644647        (void) kbd_add_dev;
  • uspace/srv/hid/output/meson.build

    r2ce943a r8a9a41e  
    2828#
    2929
    30 deps = [ 'drv', 'fbfont', 'pixconv', 'ddev' ]
     30deps = [ 'codepage', 'drv', 'fbfont', 'pixconv', 'ddev' ]
    3131src = files(
    3232        'ctl/serial.c',
  • uspace/srv/hid/output/port/chardev.c

    r2ce943a r8a9a41e  
    7878}
    7979
    80 static void chardev_putuchar(char32_t ch)
     80static void chardev_putchar(char ch)
    8181{
    8282        if (chardev_bused == chardev_buf_size)
    8383                chardev_flush();
    84         if (!ascii_check(ch))
    85                 ch = '?';
    8684        chardev_buf[chardev_bused++] = (uint8_t) ch;
     85}
     86
     87static void chardev_putuchar(char32_t ch)
     88{
     89        char buf[STR_BOUNDS(1)];
     90        size_t off;
     91        size_t i;
     92        errno_t rc;
     93
     94        off = 0;
     95        rc = chr_encode(ch, buf, &off, sizeof(buf));
     96        if (rc != EOK)
     97                return;
     98
     99        for (i = 0; i < off; i++)
     100                chardev_putchar(buf[i]);
    87101}
    88102
     
    218232#elif defined(UARCH_arm64) && defined(MACHINE_virt)
    219233                /* OK */
     234#elif defined(UARCH_arm64) && defined(MACHINE_hikey960)
     235                /* OK */
    220236#else
    221237                return EOK;
  • uspace/srv/hid/output/port/ega.c

    r2ce943a r8a9a41e  
    11/*
     2 * Copyright (c) 2021 Jiri Svoboda
    23 * Copyright (c) 2011 Martin Decky
    34 * All rights reserved.
     
    3132 */
    3233
     34#include <codepage/cp437.h>
    3335#include <errno.h>
    3436#include <sysinfo.h>
     
    106108{
    107109        uint8_t glyph;
    108 
    109         if (ascii_check(field->ch))
    110                 glyph = field->ch;
    111         else
     110        errno_t rc;
     111
     112        rc = cp437_encode(field->ch, &glyph);
     113        if (rc != EOK)
    112114                glyph = '?';
    113115
  • uspace/srv/hid/output/proto/vt100.c

    r2ce943a r8a9a41e  
    11/*
     2 * Copyright (c) 2021 Jiri Svoboda
    23 * Copyright (c) 2011 Martin Decky
    34 * All rights reserved.
     
    6566static sgr_color_index_t color_map[] = {
    6667        [COLOR_BLACK]   = CI_BLACK,
    67         [COLOR_BLUE]    = CI_RED,
     68        [COLOR_BLUE]    = CI_BLUE,
    6869        [COLOR_GREEN]   = CI_GREEN,
    6970        [COLOR_CYAN]    = CI_CYAN,
  • uspace/srv/net/dhcp/dhcp.c

    r2ce943a r8a9a41e  
    11/*
    2  * Copyright (c) 2013 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    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;
    162163
    163         addr48(dlink->link_info.mac_addr, hdr->chaddr);
     164        eth_addr_encode(&dlink->link_info.mac_addr, hdr->chaddr);
    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        eth_addr_encode(&dlink->link_info.mac_addr, hdr->chaddr);
    188189        hdr->opt_magic = host2uint32_t_be(dhcp_opt_magic);
    189190
  • uspace/srv/net/ethip/arp.c

    r2ce943a r8a9a41e  
    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 <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"
     
    7980
    8081        (void) atrans_add(packet.sender_proto_addr,
    81             packet.sender_hw_addr);
     82            &packet.sender_hw_addr);
    8283
    8384        if (packet.opcode == aop_request) {
     
    8586
    8687                reply.opcode = aop_reply;
    87                 addr48(nic->mac_addr, reply.sender_hw_addr);
     88                reply.sender_hw_addr = nic->mac_addr;
    8889                reply.sender_proto_addr = laddr_v4;
    89                 addr48(packet.sender_hw_addr, reply.target_hw_addr);
     90                reply.target_hw_addr = packet.sender_hw_addr;
    9091                reply.target_proto_addr = packet.sender_proto_addr;
    9192
     
    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                 addr48(addr48_broadcast, mac_addr);
     102                *mac_addr = eth_addr_broadcast;
    102103                return EOK;
    103104        }
     
    110111
    111112        packet.opcode = aop_request;
    112         addr48(nic->mac_addr, packet.sender_hw_addr);
     113        packet.sender_hw_addr = nic->mac_addr;
    113114        packet.sender_proto_addr = src_addr;
    114         addr48(addr48_broadcast, packet.target_hw_addr);
     115        packet.target_hw_addr = eth_addr_broadcast;
    115116        packet.target_proto_addr = ip_addr;
    116117
     
    138139                return rc;
    139140
    140         addr48(packet->target_hw_addr, frame.dest);
    141         addr48(packet->sender_hw_addr, frame.src);
     141        frame.dest = packet->target_hw_addr;
     142        frame.src = packet->sender_hw_addr;
    142143        frame.etype_len = ETYPE_ARP;
    143144        frame.data = pdata;
  • uspace/srv/net/ethip/arp.h

    r2ce943a r8a9a41e  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    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

    r2ce943a r8a9a41e  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    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;
     
    6970
    7071        atrans->ip_addr = ip_addr;
    71         addr48(mac_addr, atrans->mac_addr);
     72        atrans->mac_addr = *mac_addr;
    7273
    7374        fibril_mutex_lock(&atrans_list_lock);
     
    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);
     
    109110                return ENOENT;
    110111
    111         addr48(atrans->mac_addr, mac_addr);
     112        *mac_addr = atrans->mac_addr;
    112113        return EOK;
    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

    r2ce943a r8a9a41e  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    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

    r2ce943a r8a9a41e  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    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);
     
    177178        eth_frame_t frame;
    178179
    179         errno_t rc = arp_translate(nic, sdu->src, sdu->dest, frame.dest);
     180        errno_t rc = arp_translate(nic, sdu->src, sdu->dest, &frame.dest);
    180181        if (rc != EOK) {
    181182                log_msg(LOG_DEFAULT, LVL_WARN, "Failed to look up IPv4 address 0x%"
     
    184185        }
    185186
    186         addr48(nic->mac_addr, frame.src);
     187        frame.src = nic->mac_addr;
    187188        frame.etype_len = ETYPE_IP;
    188189        frame.data = sdu->data;
     
    208209        eth_frame_t frame;
    209210
    210         addr48(sdu->dest, frame.dest);
    211         addr48(nic->mac_addr, frame.src);
     211        frame.dest = sdu->dest;
     212        frame.src = nic->mac_addr;
    212213        frame.etype_len = ETYPE_IPV6;
    213214        frame.data = sdu->data;
     
    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()");
    281282
    282283        ethip_nic_t *nic = (ethip_nic_t *) srv->arg;
    283         addr48(nic->mac_addr, *mac);
    284 
    285         return EOK;
    286 }
    287 
    288 static errno_t ethip_set_mac48(iplink_srv_t *srv, addr48_t *mac)
     284        *mac = nic->mac_addr;
     285
     286        return EOK;
     287}
     288
     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()");
    291292
    292293        ethip_nic_t *nic = (ethip_nic_t *) srv->arg;
    293         addr48(*mac, nic->mac_addr);
     294        nic->mac_addr = *mac;
    294295
    295296        return EOK;
  • uspace/srv/net/ethip/ethip.h

    r2ce943a r8a9a41e  
    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

    r2ce943a r8a9a41e  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    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         addr48(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                         if (addr48_compare(mac_list[j].address, 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)) {
    410413                                found = true;
    411414                                break;
     
    414417
    415418                if (!found) {
    416                         addr48(mac, mac_list[i].address);
     419                        eth_addr_encode(&mac, mac_list[i].address);
    417420                        i++;
    418                 } else
     421                } else {
    419422                        count--;
     423                }
    420424        }
    421425
  • uspace/srv/net/ethip/pdu.c

    r2ce943a r8a9a41e  
    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        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         addr48(hdr->src, frame->src);
    96         addr48(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         addr48(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         addr48(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         addr48(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         addr48(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

    r2ce943a r8a9a41e  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
  • uspace/srv/net/ethip/std.h

    r2ce943a r8a9a41e  
    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

    r2ce943a r8a9a41e  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    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) {
     
    239240                 * Translate local destination IPv6 address.
    240241                 */
    241                 rc = ndp_translate(lsrc_v6, ldest_v6, ldest_mac, addr->ilink);
     242                rc = ndp_translate(lsrc_v6, ldest_v6, &ldest_mac, addr->ilink);
    242243                if (rc != EOK)
    243244                        return rc;
    244245
    245                 return inet_link_send_dgram6(addr->ilink, ldest_mac, dgram,
     246                return inet_link_send_dgram6(addr->ilink, &ldest_mac, dgram,
    246247                    proto, ttl, df);
    247248        default:
  • 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        /*
  • uspace/srv/net/inetsrv/inet_link.h

    r2ce943a r8a9a41e  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    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/inetcfg.c

    r2ce943a r8a9a41e  
    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                linfo->mac_addr = ilink->mac;
    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/inetsrv.h

    r2ce943a r8a9a41e  
    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

    r2ce943a r8a9a41e  
    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"
     
    6971        ndp_pdu_encode(packet, &dgram);
    7072
    71         inet_link_send_dgram6(link, packet->target_hw_addr, &dgram,
     73        inet_link_send_dgram6(link, &packet->target_hw_addr, &dgram,
    7274            IP_PROTO_ICMPV6, INET6_HOP_LIMIT_MAX, 0);
    7375
     
    108110                if (laddr != NULL) {
    109111                        rc = ntrans_add(packet.sender_proto_addr,
    110                             packet.sender_hw_addr);
     112                            &packet.sender_hw_addr);
    111113                        if (rc != EOK)
    112114                                return rc;
     
    115117
    116118                        reply.opcode = ICMPV6_NEIGHBOUR_ADVERTISEMENT;
    117                         addr48(laddr->ilink->mac, reply.sender_hw_addr);
     119                        reply.sender_hw_addr = laddr->ilink->mac;
    118120                        addr128(packet.target_proto_addr, reply.sender_proto_addr);
    119                         addr48(packet.sender_hw_addr, reply.target_hw_addr);
     121                        reply.target_hw_addr = packet.sender_hw_addr;
    120122                        addr128(packet.sender_proto_addr, reply.target_proto_addr);
    121123
     
    128130                if (laddr != NULL)
    129131                        return ntrans_add(packet.sender_proto_addr,
    130                             packet.sender_hw_addr);
     132                            &packet.sender_hw_addr);
    131133
    132134                break;
     
    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{
     
    167169
    168170        packet.opcode = ICMPV6_NEIGHBOUR_SOLICITATION;
    169         addr48(ilink->mac, packet.sender_hw_addr);
     171        packet.sender_hw_addr = ilink->mac;
    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

    r2ce943a r8a9a41e  
    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

    r2ce943a r8a9a41e  
    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;
     
    8385
    8486        addr128(ip_addr, ntrans->ip_addr);
    85         addr48(mac_addr, ntrans->mac_addr);
     87        ntrans->mac_addr = *mac_addr;
    8688
    8789        fibril_mutex_lock(&ntrans_list_lock);
     
    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);
     
    144146
    145147        fibril_mutex_unlock(&ntrans_list_lock);
    146         addr48(ntrans->mac_addr, mac_addr);
     148        *mac_addr = ntrans->mac_addr;
    147149        return EOK;
    148150}
  • uspace/srv/net/inetsrv/ntrans.h

    r2ce943a r8a9a41e  
    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

    r2ce943a r8a9a41e  
    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        eth_addr_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        eth_addr_decode(message->mac, &ndp->sender_hw_addr);
    555556
    556557        return EOK;
  • uspace/srv/net/loopip/loopip.c

    r2ce943a r8a9a41e  
    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

    r2ce943a r8a9a41e  
    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.