-
Notifications
You must be signed in to change notification settings - Fork 6
/
alignsmb.c
57 lines (45 loc) · 1.19 KB
/
alignsmb.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>
typedef unsigned __u32;
typedef unsigned char __u8;
typedef unsigned short __u16;
#pragma pack(1)
# define offsetof(T,F) ((unsigned int)((char *)&((T *)0L)->F - (char *)0L))
struct smb_hdr {
__u32 smb_buf_length; /* big endian on wire *//* BB length is only two or three bytes - with one or two byte type preceding it but that is always zero - we could mask the type byte off just in case BB */
__u8 Protocol[4];
__u8 Command;
union {
struct {
__u8 ErrorClass;
__u8 Reserved;
__u16 Error; /* note: treated as little endian (le) on wire */
} DosError;
__u32 CifsError; /* note: le */
} Status;
__u8 Flags;
__u16 Flags2; /* note: le */
__u16 PidHigh; /* note: le */
union {
struct {
__u32 SequenceNumber; /* le */
__u32 Reserved; /* zero */
} Sequence;
__u8 SecuritySignature[8]; /* le */
} Signature;
__u8 pad[2];
__u16 Tid;
__u16 Pid; /* note: le */
__u16 Uid;
__u16 Mid;
__u8 WordCount;
};
struct smb_hdr h;
int main(void)
{
printf("size is %d\n", sizeof(h));
h.Status.CifsError = 3;
printf("error is at %d\n", offsetof(struct smb_hdr, Status.CifsError));
h.Status.CifsError++;
printf("error is %d\n", h.Status.CifsError++);
return 0;
}