Ignore:
File:
1 edited

Legend:

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

    redeee9f rec7902d  
    11/*
    2  * Copyright (c) 2021 Jiri Svoboda
     2 * Copyright (c) 2013 Jiri Svoboda
    33 * Copyright (c) 2013 Martin Decky
    44 * All rights reserved.
     
    2828 */
    2929
    30 /** @addtogroup libinet
     30/** @addtogroup libc
    3131 * @{
    3232 */
     
    3737#include <errno.h>
    3838#include <inet/addr.h>
    39 #include <inet/eth_addr.h>
    4039#include <stdio.h>
    4140#include <stddef.h>
     
    5554const addr32_t addr32_broadcast_all_hosts = 0xffffffff;
    5655
    57 static eth_addr_t inet_eth_addr_solicited_node =
    58     ETH_ADDR_INITIALIZER(0x33, 0x33, 0xff, 0, 0, 0);
     56const addr48_t addr48_broadcast = {
     57        0xff, 0xff, 0xff, 0xff, 0xff, 0xff
     58};
     59
     60static const addr48_t inet_addr48_solicited_node = {
     61        0x33, 0x33, 0xff, 0, 0, 0
     62};
    5963
    6064static const inet_addr_t inet_addr_any_addr = {
     
    6872};
    6973
     74void addr48(const addr48_t src, addr48_t dst)
     75{
     76        memcpy(dst, src, 6);
     77}
     78
    7079void addr128(const addr128_t src, addr128_t dst)
    7180{
    7281        memcpy(dst, src, 16);
     82}
     83
     84/** Compare addr48.
     85 *
     86 * @return Non-zero if equal, zero if not equal.
     87 */
     88int addr48_compare(const addr48_t a, const addr48_t b)
     89{
     90        return memcmp(a, b, 6) == 0;
    7391}
    7492
     
    88106 *
    89107 */
    90 void 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);
     108void 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);
    98112}
    99113
Note: See TracChangeset for help on using the changeset viewer.