#define IP_MSS 576 /* default maximum segment size */
/* in print-ip.c */
-extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int);
+extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int, u_int);
register const u_char *, u_int);
extern void igrp_print(netdissect_options *,const u_char *, u_int,
const u_char *);
-extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int);
extern void ipN_print(netdissect_options *,const u_char *, u_int);
extern void ipx_print(netdissect_options *,const u_char *, u_int);
extern void isoclns_print(netdissect_options *,const u_char *,
static int dccp_cksum(const struct ip *ip,
const struct dccp_hdr *dh, u_int len)
{
- return nextproto4_cksum(ip, (const u_int8_t *)(void *)dh,
- dccp_csum_coverage(dh, len), IPPROTO_DCCP);
+ return nextproto4_cksum(ip, (const u_int8_t *)(void *)dh, len,
+ dccp_csum_coverage(dh, len), IPPROTO_DCCP);
}
#ifdef INET6
*/
int
nextproto4_cksum(const struct ip *ip, const u_int8_t *data,
- u_int len, u_int next_proto)
+ u_int len, u_int covlen, u_int next_proto)
{
struct phdr {
u_int32_t src;
vec[0].ptr = (const u_int8_t *)(void *)&ph;
vec[0].len = sizeof(ph);
vec[1].ptr = data;
- vec[1].len = len;
+ vec[1].len = covlen;
return (in_cksum(vec, 2));
}
register const struct tcphdr *tp,
register u_int len)
{
- return (nextproto4_cksum(ip, (const u_int8_t *)tp, len,
- IPPROTO_TCP));
+ return nextproto4_cksum(ip, (const u_int8_t *)tp, len, len,
+ IPPROTO_TCP);
}
void
register const struct udphdr *up,
register u_int len)
{
- return (nextproto4_cksum(ip, (const u_int8_t *)(void *)up, len,
- IPPROTO_UDP));
+ return nextproto4_cksum(ip, (const u_int8_t *)(void *)up, len, len,
+ IPPROTO_UDP);
}
#ifdef INET6
# Loopback/CTP test case
loopback loopback.pcap loopback.out -t
+
+# DCCP partial checksums tests
+dccp_partial_csum_v4_simple dccp_partial_csum_v4_simple.pcap dccp_partial_csum_v4_simple.out -t -v
+dccp_partial_csum_v4_longer dccp_partial_csum_v4_longer.pcap dccp_partial_csum_v4_longer.out -t -v
--- /dev/null
+IP (tos 0x0, ttl 64, id 65312, offset 0, flags [DF], proto DCCP (33), length 52)
+ 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xaaf3 (correct), request (service=0)
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto DCCP (33), length 68)
+ 139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xb04b (correct), response (service=0) (ack=38464816766)
+IP (tos 0x0, ttl 64, id 65313, offset 0, flags [DF], proto DCCP (33), length 56)
+ 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xf53a (correct), ack (ack=1960341146)
+IP (tos 0x0, ttl 64, id 65314, offset 0, flags [DF], proto DCCP (33), length 152)
+ 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 6, cksum 0x7d28 (correct), dataack (ack=1960341146)
+IP (tos 0x0, ttl 64, id 3176, offset 0, flags [DF], proto DCCP (33), length 52)
+ 139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xfc63 (correct), ack (ack=38464816768)
+IP (tos 0x0, ttl 64, id 65315, offset 0, flags [DF], proto DCCP (33), length 148)
+ 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 6, cksum 0x5e05 (correct), dataack (ack=1960341147)
+IP (tos 0x0, ttl 64, id 3177, offset 0, flags [DF], proto DCCP (33), length 52)
+ 139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0x0165 (correct), ack (ack=38464816769)
+IP (tos 0x0, ttl 64, id 65316, offset 0, flags [DF], proto DCCP (33), length 148)
+ 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 6, cksum 0x5e1e (correct), dataack (ack=1960341148)
+IP (tos 0x0, ttl 64, id 65317, offset 0, flags [DF], proto DCCP (33), length 148)
+ 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 6, cksum 0x5e15 (correct), dataack (ack=1960341148)
+IP (tos 0x0, ttl 64, id 3178, offset 0, flags [DF], proto DCCP (33), length 56)
+ 139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xfb32 (correct), ack (ack=38464816770)
+IP (tos 0x0, ttl 64, id 3179, offset 0, flags [DF], proto DCCP (33), length 56)
+ 139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xfa2f (correct), ack (ack=38464816771)
+IP (tos 0x0, ttl 64, id 65318, offset 0, flags [DF], proto DCCP (33), length 148)
+ 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 6, cksum 0x5e35 (correct), dataack (ack=1960341150)
+IP (tos 0x0, ttl 64, id 65319, offset 0, flags [DF], proto DCCP (33), length 52)
+ 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xf638 (correct), close (ack=1960341150)
+IP (tos 0x0, ttl 64, id 3180, offset 0, flags [DF], proto DCCP (33), length 56)
+ 139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xfb2c (correct), ack (ack=38464816772)
+IP (tos 0x0, ttl 64, id 3181, offset 0, flags [DF], proto DCCP (33), length 60)
+ 139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xef25 (correct), reset (code=closed) (ack=38464816773)
--- /dev/null
+IP (tos 0x0, ttl 64, id 30095, offset 0, flags [DF], proto DCCP (33), length 52)
+ 139.133.209.176.52667 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xa766 (correct), request (service=0)
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto DCCP (33), length 68)
+ 139.133.209.65.5001 > 139.133.209.176.52667: CCVal 0, CsCov 0, cksum 0x9a1a (correct), response (service=0) (ack=33164071488)
+IP (tos 0x0, ttl 64, id 30096, offset 0, flags [DF], proto DCCP (33), length 56)
+ 139.133.209.176.52667 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xdf09 (correct), ack (ack=1925546833)
+IP (tos 0x0, ttl 64, id 30097, offset 0, flags [DF], proto DCCP (33), length 68)
+ 139.133.209.176.52667 > 139.133.209.65.5001: CCVal 0, CsCov 1, cksum 0x9dfa (correct), dataack (ack=1925546833)
+IP (tos 0x0, ttl 64, id 24713, offset 0, flags [DF], proto DCCP (33), length 52)
+ 139.133.209.65.5001 > 139.133.209.176.52667: CCVal 0, CsCov 0, cksum 0xe632 (correct), ack (ack=33164071490)
+IP (tos 0x0, ttl 64, id 30098, offset 0, flags [DF], proto DCCP (33), length 52)
+ 139.133.209.176.52667 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xdf8d (correct), close (ack=1925546834)
+IP (tos 0x0, ttl 64, id 24714, offset 0, flags [DF], proto DCCP (33), length 60)
+ 139.133.209.65.5001 > 139.133.209.176.52667: CCVal 0, CsCov 0, cksum 0xd900 (correct), reset (code=closed) (ack=33164071491)