From a7265675d5cd41f05a0ebaba43ad36a389419db2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 28 Jul 2011 11:27:10 +0200 Subject: s3:smb_macros.h: simplify _smb_setlen() and _smb_setlen_large() This also takes care of the correct casting. metze --- source3/include/smb_macros.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 957db5b8d6..3be02243e9 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -132,13 +132,11 @@ /* Note that chain_size must be available as an extern int to this macro. */ #define smb_offset(p,buf) (PTR_DIFF(p,buf+4)) -#define smb_len(buf) (PVAL(buf,3)|(PVAL(buf,2)<<8)|((PVAL(buf,1)&1)<<16)) -#define _smb_setlen(buf,len) do { buf[0] = 0; buf[1] = ((len)&0x10000)>>16; \ - buf[2] = ((len)&0xFF00)>>8; buf[3] = (len)&0xFF; } while (0) +#define smb_len(buf) (RIVAL(buf, 0) & 0x1FFFF) +#define _smb_setlen(buf,len) RSIVAL(buf, 0, (len) & 0x1FFFF) -#define smb_len_large(buf) (PVAL(buf,3)|(PVAL(buf,2)<<8)|(PVAL(buf,1)<<16)) -#define _smb_setlen_large(buf,len) do { buf[0] = 0; buf[1] = ((len)&0xFF0000)>>16; \ - buf[2] = ((len)&0xFF00)>>8; buf[3] = (len)&0xFF; } while (0) +#define smb_len_large(buf) (RIVAL(buf, 0) & 0xFFFFFF) +#define _smb_setlen_large(buf,len) RSIVAL(buf, 0, (len) & 0xFFFFFF) #define ENCRYPTION_REQUIRED(conn) ((conn) ? ((conn)->encrypt_level == Required) : false) #define IS_CONN_ENCRYPTED(conn) ((conn) ? (conn)->encrypted_tid : false) -- cgit