Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/inet/src/addr.c

    rec7902d r1801005  
    11/*
    2  * Copyright (c) 2013 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * Copyright (c) 2013 Martin Decky
    44 * All rights reserved.
     
    2828 */
    2929
    30 /** @addtogroup libc
     30/** @addtogroup libinet
    3131 * @{
    3232 */
     
    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 = {
    61         0x33, 0x33, 0xff, 0, 0, 0
    62 };
     57static eth_addr_t inet_eth_addr_solicited_node =
     58    ETH_ADDR_INITIALIZER(0x33, 0x33, 0xff, 0, 0, 0);
    6359
    6460static const inet_addr_t inet_addr_any_addr = {
     
    7268};
    7369
    74 void addr48(const addr48_t src, addr48_t dst)
    75 {
    76         memcpy(dst, src, 6);
    77 }
    78 
    7970void addr128(const addr128_t src, addr128_t dst)
    8071{
    8172        memcpy(dst, src, 16);
    82 }
    83 
    84 /** Compare addr48.
    85  *
    86  * @return Non-zero if equal, zero if not equal.
    87  */
    88 int addr48_compare(const addr48_t a, const addr48_t b)
    89 {
    90         return memcmp(a, b, 6) == 0;
    9173}
    9274
     
    10688 *
    10789 */
    108 void addr48_solicited_node(const addr128_t ip, addr48_t mac)
    109 {
    110         memcpy(mac, inet_addr48_solicited_node, 3);
    111         memcpy(mac + 3, ip + 13, 3);
     90void eth_addr_solicited_node(const addr128_t ip, eth_addr_t *mac)
     91{
     92        uint8_t b[6];
     93        mac->a = inet_eth_addr_solicited_node.a;
     94
     95        eth_addr_encode(&inet_eth_addr_solicited_node, b);
     96        memcpy(&b[3], ip + 13, 3);
     97        eth_addr_decode(b, mac);
    11298}
    11399
     
    393379                                wildcard_size = 16 - i;
    394380                                cur = gend + 2;
     381                                continue;
    395382                        }
    396383                }
     384
     385                cur = gend + 1;
    397386        }
    398387
Note: See TracChangeset for help on using the changeset viewer.