Remove port 445 so NBT works correctly.
[Samba.git] / examples / pcap2nbench / ntcreateandxrequest.cpp
blobd7024611f6b45bc6689363e124e0f8652fe71f9b
1 /*\
2 * pcap2nbench - Converts libpcap network traces to nbench input
3 * Copyright (C) 2004 Jim McDonough <jmcd@us.ibm.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 * Written by Anthony Liguori <aliguori@us.ibm.com>
20 \*/
22 #include <netinet/in.h>
24 #include "ntcreateandxrequest.hpp"
26 NtCreateAndXRequest::NtCreateAndXRequest(const uint8_t *data, size_t size)
28 if (size < 52) {
29 std::cerr << "Invalid NtCreateAndX Request" << std::endl;
30 return;
33 word_count = data[0];
34 and_x_command = data[1];
35 reserved = data[2];
36 memcpy(&and_x_offset, data + 3, 2);
37 reserved1 = data[5];
38 memcpy(&file_name_len, data + 6, 2);
39 memcpy(&create_flags, data + 8, 4);
40 memcpy(&root_fid, data + 12, 4);
41 memcpy(&access_mask, data + 16, 4);
42 memcpy(&allocation_size, data + 20, 8);
43 memcpy(&file_attributes, data + 28, 4);
44 memcpy(&share_access, data + 32, 4);
45 memcpy(&disposition, data + 36, 4);
46 memcpy(&create_options, data + 40, 4);
47 memcpy(&impersonation, data + 44, 4);
48 security_flags = data[48];
49 memcpy(&byte_count, data + 49, 2);
50 file_name = (const char *)(data + 51);
53 std::ostream &operator<<(std::ostream &lhs, const NtCreateAndXRequest &rhs)
55 lhs << "Word Count: " << (uint16_t)rhs.word_count << std::endl
56 << "AndXCommand: " << (uint16_t)rhs.and_x_command << std::endl
57 << "Reserved: " << (uint16_t)rhs.reserved << std::endl
58 << "AndXOffset: " << rhs.and_x_offset << std::endl
59 << "Reserved: " << (uint16_t)rhs.reserved1 << std::endl
60 << "File Name Len: " << rhs.file_name_len << std::endl
61 << "Create Flags: " << rhs.create_flags << std::endl
62 << "Root FID: " << rhs.root_fid << std::endl
63 << "Access Mask: " << rhs.access_mask << std::endl
64 << "Allocation Size: " << rhs.allocation_size << std::endl
65 << "File Attributes: " << rhs.file_attributes << std::endl
66 << "Share Access: " << rhs.share_access << std::endl
67 << "Disposition: " << rhs.disposition << std::endl
68 << "Create Options: " << rhs.create_options << std::endl
69 << "Impersonation: " << rhs.impersonation << std::endl
70 << "Security Flags: " << (uint16_t)rhs.security_flags << std::endl
71 << "Byte Count: " << rhs.byte_count << std::endl
72 << "File Name: " << rhs.file_name << std::endl;
73 return lhs;