/* Returns NULL on failure */ hash_t* SMBCALL smb_hash(ulong msgnum, uint32_t t, unsigned source, unsigned flags ,const void* data, size_t length) { hash_t* hash; if(length==0) /* Don't hash 0-length sources (e.g. empty/blank message bodies) */ return(NULL); if((hash=(hash_t*)malloc(sizeof(hash_t)))==NULL) return(NULL); memset(hash,0,sizeof(hash_t)); hash->number=msgnum; hash->time=t; hash->length=length; hash->source=source; hash->flags=flags; if(flags&SMB_HASH_CRC16) hash->crc16=crc16((char*)data,length); if(flags&SMB_HASH_CRC32) hash->crc32=crc32((char*)data,length); if(flags&SMB_HASH_MD5) MD5_calc(hash->md5,data,length); return(hash); }
/* Returns NULL on failure */ hash_t* SMBCALL smb_hash(ulong msgnum, ulong t, unsigned source, unsigned flags ,const void* data, size_t length) { hash_t* hash; if((hash=(hash_t*)malloc(sizeof(hash_t)))==NULL) return(NULL); memset(hash,0,sizeof(hash_t)); hash->number=msgnum; hash->time=t; hash->length=length; hash->source=source; hash->flags=flags; if(flags&SMB_HASH_CRC16) hash->crc16=crc16((char*)data,length); if(flags&SMB_HASH_CRC32) hash->crc32=crc32((char*)data,length); if(flags&SMB_HASH_MD5) MD5_calc(hash->md5,data,length); return(hash); }