代码之家  ›  专栏  ›  技术社区  ›  Goz

IPv6 Zone index and scope_id

  •  2
  • Goz  · 技术社区  · 14 年前

    How does the zone index relate to the scope_id in the sockaddr_in6 structure?

    SCOPE_ID structure (以及32位值)。Mac OSX只有32位值。显然,32位值是一种可行的方法,但是它的布局到底是怎样的呢?它仍然是“级别”的前4位吗?网络字节顺序如何影响这一点?

    Also I assume that, under windows, the zone index given in the ip address (eg FF80::1%1) translates directly to the bottom 28 bits of the aforementioned structure. How does it work under Mac OSX that uses names rather than numbers (eg FF80::1%en0). Do I encode it as a four CC? Equally I seem to recall that linux uses 4 characters which couldn't possibly fit in 28-bits.

    So can someone explain this mess to me? I really am going to need to write a tutorial on all this when I'm finished because there is precious little info about ipv6 around the net.

    编辑:作用域ID是按网络字节顺序排列的吗?我只是在查看从recvfrom返回的作用域id,它似乎是以小尾数顺序…那不可能是对的,是吗?

    1 回复  |  直到 14 年前
        1
  •  1
  •   Steve-o    14 年前

    The index of zone and scope are the same and frequently interchanged, however the terms themselves are different.

    Scope is used as in "global scope", "local scope", "universal scope" and refer to how unique a particular IPv6 address is. Every interface has a local scope which is unique to the immediate LAN segment, which is say useful for automatic configuration and discovery of local devices, say a printer you just plugged into the network. Global scope IPv6 address may be provided by a DHCP server.

    区域是在本地范围内指定一个特定的有效接口。

    struct interface_req_t {
            uint32_t                                ir_interface;
            uint32_t                                ir_scope_id;
    };
    

    每个平台在解释值的方式上都是唯一的,Windows根据域对接口枚举进行了多次重新解释。Windows实现的缺点是,当您热交换适配器时,索引可能会改变。在Unix上,您通常会看到接口名 %qe0 , %eth0 , etc, that can be resolved to numeric form when required, e.g. if_nametoindex() . Windows Vista adds a compatible API.

    Only the local scope is identifiable by it's address prefix fe80::/10.

    Windows Scope_ID显示了在IPv4多播中也存在的过度设计,即拆分地址的管理域。这些都是纯可选的,经常被忽略。

    推荐文章