tf6Eui48SetInterfaceId

Jump to: navigation, search

Table of Contents >> IPv6 Programmer's Reference


#include <trsocket.h>


int tf6Eui48SetInterfaceId (
ttUserInterface interfaceHandle,
const ttUser8Bit * macAddrPtr,
int calledFromFlag
);


Function Description

This function sets or resets the IPv6 interface ID using the specified 48-bit MAC address to build the interface ID in EUI-64 format (i.e. 64-bit IEEE global identifier). This function may only be called on an interface that is closed or that has IPv6 disabled. When the Treck stack is running in dual IP layer mode, "IPv6 disabled" means that the interface is opened for IPv4,and therefore the link-layer and device driver are open (i.e. IPv4 and IPv6 share the same link-layer and device driver on the interface). However, there is no link-local IPv6 address configured on the interface so the IPv6 part of the interface cannot be used by the application. Typically, this is the case when you have not yet opened the interface for IPv6 by calling tfNgOpenInterface() specifying an IPv6 address to configure. When the Treck stack is running in IPv6-only mode, "IPv6 disabled" means that you opened the interface for IPv6, however either the link-local address generated by IPv6 stateless address auto-configuration was detected to be in use by a different node (i.e. Duplicate Address Detection failed), or you intentionally unconfigured the link-local address by calling tfNgUnConfigInterface(). In any case, there is no link-local IPv6 address configured on the interface, so the IPv6 part of the interface cannot be used by the application.

When the interface has IPv6 disabled, recovery usually entails either setting a different interface ID by calling tf6Eui64SetInterfaceId() or tf6Eui48SetInterfaceId() and then attempting to restart the IPv6 part of the interface by calling tfNgOpenInterface() specifying an IPv6 address of all 0's (i.e. the IPv6 unspecified address), or by manually configuring a link-local IPv6 address on the interface. However, it is possible that you get this failure because your network controller hardware does not support filtering of its own multicasts but instead does loopback of its own multicasts, which would cause Duplicate Address Detection to always fail. If this is the case, then you must specify the IPv6-specific device flag TM_6_DEV_MCAST_HW_LOOPBACK when you open the interface. (RFC 2373)

The IPv6 interface ID is used to generate tentatively unique IPv6 addresses to assign to the interface during stateless address auto-configuration, which occurs when the interface is opened. Part of stateless address auto-configuration is Duplicate Address Detection, which is done to ensure that the auto-configured IPv6 addresses are unique. If you are using the null link-layer and you want to use IPv6 on the interface, then you should call tf6Eui64SetInterfaceId() or tf6Eui48SetInterfaceId(), typically done in your device driver open function in which case calledFromFlag is set to TM_6_DEV_CALLED_FROM_DRIVER. Otherwise, if the interface ID is not set before the interface is opened, then IPv6 stateless address auto-configuration will not be performed, which may result in the IPv6 interface not being opened depending on what IPv6 addresses have been manually configured on the interface (i.e. at least one link-local IPv6 address is required). (RFC 2373)

If your interface link-layer type is Ethernet, then you should not call this function, since the stack will call the internal version of this function to set the interface ID using the IEEE 48-bit MAC address you provide via your driverGetPhysicalAddress function (refer to the drvGetPhysAddrFuncPtr parameter of the function tfAddInterface()).


Parameters

  • interfaceHandle
    Interface handle of an interface for which we want to get the interface ID.
  • macAddrPtr
    Pointer to the IEEE 48-bit MAC address.
  • calledFromFlag
    Specifies whether this function is being called from the device driver, typically from the device driver open function. If you are calling this function from the device driver, set calledFromFlag to TM_6_DEV_CALLED_FROM_DRIVER, otherwise set it to TM_6_DEV_CALLED_FROM_APP.


Returns

  • 0
    Success. eui64IdPtr now points to the interface ID.
  • TM_EINVAL
    Invalid parameter value. Either interfaceHandle does not point to a valid interface, or eui64IdPtr is a NULL pointer.
  • TM_EPERM
    The interface specified by interfaceHandle was open for IPv6, and the IPv6 part was not disabled. This function may only be called on an interface that is closed or that has IPv6 disabled.


Table of Contents >> IPv6 Programmer's Reference