📄 tcpcksum.c,v
字号:
head 1.2;access;symbols;locks dls:1.2; strict;comment @ * @;1.2date 97.09.21.19.29.52; author dls; state Dist;branches;next 1.1;1.1date 94.01.14.03.51.20; author dls; state v2e1;branches;next ;desc@@1.2log@pre-3e code@text@/* tcpcksum.c - tcpcksum */#include <conf.h>#include <kernel.h>#include <network.h>/*------------------------------------------------------------------------ * tcpcksum - compute a TCP pseudo-header checksum *------------------------------------------------------------------------ */unsigned short tcpcksum(pep, len)struct ep *pep;int len;{ struct ip *pip = (struct ip *)pep->ep_data; struct tcp *ptcp = (struct tcp *)pip->ip_data; unsigned short *sptr; unsigned long tcksum; int i; tcksum = 0; sptr = (unsigned short *) &pip->ip_src; /* 2*IP_ALEN octets = IP_ALEN shorts... */ /* they are in net order. */ for (i=0; i<IP_ALEN; ++i) tcksum += *sptr++; sptr = (unsigned short *)ptcp;#ifdef notnowkprintf("tcpcksum: pep %X order %x len %u (swapped %u)\n", pep, pep->ep_order,len, net2hs(len));#endif tcksum += hs2net(IPT_TCP + len); if (len % 2) { ((char *)ptcp)[len] = 0; /* pad */ len += 1; /* for the following division */ } len >>= 1; /* convert to length in shorts */ for (i=0; i<len; ++i) tcksum += *sptr++; tcksum = (tcksum >> 16) + (tcksum & 0xffff); tcksum += (tcksum >> 16); return (short)(~tcksum & 0xffff);}@1.1log@Initial revision@text@d11 3a13 2unsigned short tcpcksum(pip)struct ip *pip;d15 1d17 1a17 1 unsigned short *sptr, len;d23 1a23 1 sptr = (unsigned short *) pip->ip_src;d29 4a32 1 len = pip->ip_len - IP_HLEN(pip);@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -