ip-addresscontikidata-link-layer

Is it possible to get the link address if given the uip address in Contiki-NG


I'm developing a project using Contiki-NG and I was working on something somehow similiar to a firewall. I have a function that receives a IP Address (uip_ipaddr_t) and I was wondering if it is possible to get the link address (linkaddr_t ) of this mote, if it checked out to be a neighbor.

Thank you in advance.


Solution

  • If there is an IPv6 neighbor with a given IP address (const uip_ipaddr_t *ipaddr), then its simply a matter of calling this function:

    const linkaddr_t *lla = (const linkaddr_t *)uip_ds6_nbr_lladdr_from_ipaddr(ipaddr);
    

    See the documentation of uip_ds6_nbr_lladdr_from_ipaddr().