QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2181|回复: 12

请教:关于ipv6校验和的计算

[复制链接]
发表于 2003-5-20 11:41:29 | 显示全部楼层 |阅读模式
我最近在写一些网络方面的程序,需要截获一个ipv6数据包,然后修改其目的地址,再将包转发出去,修改包以后需要对其进行一次校验和的重算,我使用的是icmpv6的数据包,不知道要怎么去计算。

请各位高手帮忙。
发表于 2003-5-20 11:51:53 | 显示全部楼层
it seems to be an ipv6 protocol problem, not a kernel related problem. i believe this can be easily found from the ipv6 rfc.
of course u can check the code under net/ipv6/ to see how to compute.
回复

使用道具 举报

 楼主| 发表于 2003-5-21 10:50:06 | 显示全部楼层
yes, it's a protocol problem, but the ipv6 rfcs do not mention the details of calculating checksum of a ipv6 packet, they only said that use the same way which ipv4 used and plus some additional fileds such as psudo-header.

And in kernel source code, we can find some functions about calculating checksum of ipv6 packet, but there are many parameters we should give, and in different functions, the parameters are different too, I don't know how to set them to meet my requirement.
回复

使用道具 举报

发表于 2003-5-21 11:11:56 | 显示全部楼层
then u can read ipv4 rfc and ipv4 code.

list the fn name u find here. save me some time,  
回复

使用道具 举报

 楼主| 发表于 2003-5-21 13:14:37 | 显示全部楼层
net\ipv6\icmp.c
include\net\checksum.h:csum_ipv6_magic()
net\core\skbuff.c:skb_checksum()


thanks. :->
回复

使用道具 举报

发表于 2003-5-21 22:31:58 | 显示全部楼层
my feeling is to use that csum_ipv6_magic. but i am not sure. i do not have ipv6 doc at hand.
回复

使用道具 举报

 楼主| 发表于 2003-5-22 21:08:54 | 显示全部楼层
yes, but there are two checksums in ipv6, one is the upper protocals', like tcp/udp, and another is the hardwares'.

I can recalculate the protocals' checksum, but I don't know how to calculate the other checksum, because in ipv4 an ip packet has a checksum field in its packet head, I can calculate a checksum and then put it in checksum field in packet head,  ipv6 packet does not have that field, where can I put the checksum in?
回复

使用道具 举报

发表于 2003-5-22 23:36:22 | 显示全部楼层
u have to check where it is referenced,

Referenced (in 20 files total) in:
    * include/asm-x86_64/checksum.h, line 179
    * include/asm-i386/checksum.h, line 154
    * include/asm-mips/checksum.h:
          o line 199
          o line 206
    * include/asm-alpha/checksum.h, line 84
    * include/asm-m68k/checksum.h, line 125
    * include/asm-sparc/checksum.h, line 212
    * include/net/checksum.h, line 37
    * include/asm-sparc64/checksum.h, line 169
    * include/asm-arm/checksum.h, line 152
    * include/asm-sh/checksum.h, line 173
    * include/asm-mips64/checksum.h:
          o line 201
          o line 208
    * include/asm-parisc/checksum.h, line 148
    * net/ipv6/udp.c:
          o line 642
          o line 748
    * net/ipv6/tcp_ipv6.c:
          o line 400
          o line 925
          o line 928
          o line 981
          o line 1048
    * net/ipv6/ndisc.c:
          o line 424
          o line 485
          o line 537
          o line 975
    * net/ipv6/icmp.c:
          o line 159
          o line 510
          o line 518
    * net/ipv6/raw.c:
          o line 318
          o line 481
    * net/ipv6/mcast.c, line 550
    * arch/x86_64/lib/csum-wrappers.c:
          o line 93
          o line 109
    * arch/alpha/kernel/alpha_ksyms.c, line 174

but base on my check, it only handle the tcp/udp/icmp header. so i am also confused. i know little about ipv6, so i can not go deeper.
btw, i think there must be similar code existed on web. modify the address and resend is a common use. a kernel lever nat or proxy is an example.
回复

使用道具 举报

发表于 2003-5-23 03:02:40 | 显示全部楼层
http://www.balabit.com/products/oss/tproxy/ is a possible one.
netfilter code is also readable.
回复

使用道具 举报

 楼主| 发表于 2003-5-26 15:12:47 | 显示全部楼层
[quote:4985790278="Dragonfly"]http://www.balabit.com/products/oss/tproxy/ is a possible one.
netfilter code is also readable.[/quote]

tproxy only supports ipv4, I think ipv4 is esier than ipv6, and in kernel 2.4.x, only supports parts of ipv6 functions, such as unicast, and not supports multicast, anycast etc.

so there are many things should to do.
回复

使用道具 举报

发表于 2003-5-26 21:33:05 | 显示全部楼层
o, ic. so i am afraid u question is beyond my current understanding. none of my research is on ipv6.
回复

使用道具 举报

 楼主| 发表于 2003-5-27 18:30:22 | 显示全部楼层
ipv6 is better than ipv4, i think ipv6 need very long time to replace ipv4, and ipv4 can also extend to meet the new requirements and applications, but my major is cs network, i have to finish this project, or else i couldn't obtain my master's degree.

who can help me :-<
回复

使用道具 举报

发表于 2003-5-27 22:05:33 | 显示全部楼层
admire, u master can do such interesting work. my master project is a stupid simple one.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-12-3 07:50 , Processed in 0.037361 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表