在 IPv4 客户端/服务器应用程序中添加对 IPv6 的支持 - sin6_flowinfo 和 sin6_scope_id 字段?
我致力于为多个应用程序实现 IPv6 支持,但我想知道这 2 个字段的用途。这里关于这个的问题很少,所以我不确定我是否正确。
- 关于作用域 ID (
sin6_scope_id
) - 嗯,第一季度 , 第二季度 , 第三季度 和第四季度 让我了解了范围 ID,我想我明白了。因此,我必须再添加一个配置参数,以使作用域 ID 可配置。 (我决定在这里添加这个,以防有人对此感兴趣)。很快 - 范围 ID 是唯一确定哪个设备应该处理流量所必需的 - 因为可能有多个接口,具有相同的 IP,但具有不同的(接口?)ID。到目前为止,一切都很好。 - 但是“流信息”(
sin6_flowinfo
)怎么样?- 它的用途是什么?我找不到任何有趣的事情。我阅读了 RFC 但它对我没有任何帮助。
sin6_flowinfo
是否有一些可能的值(例如 - 多个值,例如标志,它们表示某种含义),或者类似于sin6_scope_id
- 可能是任何值,具体取决于在我尝试连接的设备上?- 我是否应该担心它,或者我只是将其保留
0
(如Beej 网络编程指南 。是的,我尝试过,它有效,但我不确定它是否仅适用于这个案例(如果它取决于某些网络配置),或者如果设置为0
,它总是有效? - 或者,也许我应该使其可配置,我的意思是 - 添加一个配置选项并让用户定义它的值?
google
-ing“sin6_flowinfo”为我提供了结构定义和手册页,该字段没有任何用处。有什么有趣的来源吗? (可以理解……不是 RFC :D )
编辑:嗯,在@glglgl的回答和提示之后,sin6_flowinfo
可能已经过时了,我发现了一些有趣的来源:RFC:IPv6 流标签规范 , IETF 草案:流标签作为传输-层随机数,solaris 实用指南 和 <强>维基百科。
该字段并未过时(或者我找不到这样的来源,这证实了这一点),但它看起来像 0
因为值足够好。
I work on implementing IPv6 support for several applications, but I wondered what are these 2 fields for. There are so few questions about this here so I'm not sure I got it right.
- About scope ID (
sin6_scope_id
) - well, Q1 , Q2 , Q3 and Q4 gave me idea about the scope ID and I think I get it. So, I'll have to add one more config parameter, to make the scope-id configurable. (I decided to add this here, in case that someone is interested in this). Shortly - scope ID is necessary to uniquely determine which is the device, that should handle the traffic - because there may be several interfaces, with the same IP, but with different (interface?) ID. So far, so good. - But how about the "flow information" (
sin6_flowinfo
)- What is it for? I couldn't find anything interesting about that. I read the RFC but it didn't help me at all.
- Are there some possible values for
sin6_flowinfo
(like - several values, like flags, which mean something), or it's like thesin6_scope_id
- may be any value, depending on the device, I'm trying to connect to? - Should I worry about it at all, or I my just leave it
0
(as in Beej's Guide to Network Programming . And yes, I tried that, it works, but I'm not sure if it works only in this case (if it depends on some network configuration), or it will always work, if it's set to0
? - Or, maybe, I should make it configurable, I mean - add one more config option and let the user defines it's value?
google
-ing "sin6_flowinfo" gives me struct definitions and man pages, nothing useful about this field. Any interesting source? (understandable one..not RFC :D )
EDIT: Well, after @glglgl 's answer and after the hint, that sin6_flowinfo
may be obsolete, I found some interesting sources: RFC: IPv6 Flow Label Specification , IETF draft: Flow Label as Transport-Layer Nonce , Practical guide for solaris and wikipedia .
The field is not obsolete (or I couldn't find such source, that confirms this), but it looks like 0
as value is good enough.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最好的方法是使用
getaddrinfo()
< /a>.伪代码:
这将消除您对
sin6_scope_id
的担忧;通常为0
,除非您有像fe80::1234:56ff:fe78:9abc%eth2
这样的链接本地地址。此eth2
被转换为正确的作用域 ID。sin6_flowinfo
已过时(据我所知),因此在生成的struct addrinfo
的ai_addr
。The best way to go is to use
getaddrinfo()
.Pseudo code:
This will take the worry about
sin6_scope_id
from you; which is normally0
, except if you have link-local addresses likefe80::1234:56ff:fe78:9abc%eth2
. Thiseth2
is converted to the correct scope ID.sin6_flowinfo
is obsolete (AFAIK) and thus set to 0 in your resultingstruct addrinfo
'sai_addr
.