我参考了RFC3022的文档,找到这个函数,计算后数据不对,不知是不是参数传的不对,有哪位大侠能帮我详细的解释一下参数,最好是能有例子,重谢。void checksumadjust(unsigned char *chksum, unsigned char *optr,
int olen, unsigned char *nptr, int nlen)
/* assuming: unsigned char is 8 bits, long is 32 bits.
- chksum points to the chksum in the packet
- optr points to the old data in the packet
- nptr points to the new data in the packet
*/
{
long x, old, new;
x=chksum[0]*256+chksum[1];
x=~x&0xFFFF;
while(olen)
{
old=optr[0]*256+optr[1];
optr+=2;
x-=old&0xffff;
if(x<=0)
{
x--;
x&=0xffff;
}
olen-=2;
}
while(nlen)
{
new=nptr[0]*256+nptr[1];
nptr+=2;
x+=new&0xffff;
if(x&0x10000)
{
x++;
x&=0xffff;
}
nlen-=2;
}
x=~x&0xFFFF;
chksum[0]=x/256;
chksum[1]=x&0xff;
}
int olen, unsigned char *nptr, int nlen)
/* assuming: unsigned char is 8 bits, long is 32 bits.
- chksum points to the chksum in the packet
- optr points to the old data in the packet
- nptr points to the new data in the packet
*/
{
long x, old, new;
x=chksum[0]*256+chksum[1];
x=~x&0xFFFF;
while(olen)
{
old=optr[0]*256+optr[1];
optr+=2;
x-=old&0xffff;
if(x<=0)
{
x--;
x&=0xffff;
}
olen-=2;
}
while(nlen)
{
new=nptr[0]*256+nptr[1];
nptr+=2;
x+=new&0xffff;
if(x&0x10000)
{
x++;
x&=0xffff;
}
nlen-=2;
}
x=~x&0xFFFF;
chksum[0]=x/256;
chksum[1]=x&0xff;
}
解决方案 »
- 点击对话框的打开图片按钮后,用户可以选择输入bmp格式的图片,并在对话框中的picture显示出来
- 谁看过RealVNC4的代码,它的截屏是怎么实现的
- 我要做一个Web Server,并且要求把网页和图片都做成资源放在程序里面。纯文字的网页好办,图片怎么办?求高手支招!
- 做一个基于对话框的ActiveX控件。刚入门,请多指教!!
- 如何结帖?如何给分?
- 谁有处理打印的代码,share一下好么?分可以另加给大侠,亏血本大放分了,up者有分
- 怎样获得指定文件夹路径
- 关于用vc开发组件扩充asp功能的问题
- 请问AVI文件中关于视频定义的dwScale 和dwRate 是怎么定义的,虽然知道相除可以得到帧率,但怎么设定它
- 框架视中的线程问题?(在线)
- 请问大家,怎样获得文件的图标?
- vb改为vc的问题
但是我就是不知道怎么设置rfc3022里提供的一个函数的参数,希望做过这方面的给我指点指点。
这几个参数怎么构造,具体详细一点,谢谢了!!!!