IPv6 hton layout does not match ipv6_mreq

未关闭
#63 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
46/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
c, ruby
领域
networking

调研方向

该 issue 提到了 IPAddr#hton 和 C 的 ipv6_mreq 结构体;首先在 ipaddr 仓库中找到 hton 的实现和现有测试,然后比较这两种表示的字节长度和布局。完成的标准是确定 hton 与 ipv6_mreq 之间预期的关系,并通过回归测试或有明确理由支持的行为变更加以记录。

由索引模型根据 Issue 内容生成。

描述

Given this C program:

#include <netinet/in.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char * argv[])
{
        struct ipv6_mreq req;
        memset(&req, 0, sizeof(req));
	req.ipv6mr_multiaddr.s6_addr[0] = 0xFF;
	req.ipv6mr_multiaddr.s6_addr[1] = 0x02;
	req.ipv6mr_multiaddr.s6_addr[15] = 0xFB;

        uint8_t * ptr = (uint8_t *)&req;
        for(int i = 0; i < sizeof(req); i++) {
                fprintf(stderr, "\\%#02x", ptr[i]);
        }

        fprintf(stderr, "\n");
        return 0;
}

The bytes of the ipv6_mreq struct are: \0xff\0x2\00\00\00\00\00\00\00\00\00\00\00\00\00\0xfb\00\00\00\00

However, if I use this Ruby program:

require "ipaddr"

p IPAddr.new("ff02::fb").hton

The bytes are: "\xFF\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFB"

I think hton should match the ipv6_mreq layout.

主要语言
Ruby
星标
83
派生
50
平均合并
1 天 2 小时
30 天内合并 PR
8

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/ipaddr 的其他 Issue

查看 ruby/ipaddr 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。