summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-07-28 11:27:10 +0200
committerStefan Metzmacher <metze@samba.org>2011-08-10 11:14:55 +0200
commita7265675d5cd41f05a0ebaba43ad36a389419db2 (patch)
tree6913ad8275b37c09459a9044a197ded246cc0ea7 /source3
parentb65ea9faa8e775da9be976482cf1931456500355 (diff)
downloadsamba-a7265675d5cd41f05a0ebaba43ad36a389419db2.tar.gz
samba-a7265675d5cd41f05a0ebaba43ad36a389419db2.tar.bz2
samba-a7265675d5cd41f05a0ebaba43ad36a389419db2.zip
s3:smb_macros.h: simplify _smb_setlen() and _smb_setlen_large()
This also takes care of the correct casting. metze
Diffstat (limited to 'source3')
-rw-r--r--source3/include/smb_macros.h10
1 files 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)