root/examples/pcap2nbench/ntcreateandxrequest.cpp

/* [<][>][^][v][top][bottom][index][help] */
   1 /*\
   2  *  pcap2nbench - Converts libpcap network traces to nbench input
   3  *  Copyright (C) 2004  Jim McDonough <jmcd@us.ibm.com>
   4  *
   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 3 of the License, or
   8  *  (at your option) any later version.
   9  *
  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.
  14  *
  15  *  You should have received a copy of the GNU General Public License
  16  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  17  *
  18  *  Written by Anthony Liguori <aliguori@us.ibm.com>
  19 \*/
  20 
  21 #include <netinet/in.h>
  22 
  23 #include "ntcreateandxrequest.hpp"
  24 
  25 NtCreateAndXRequest::NtCreateAndXRequest(const uint8_t *data, size_t size)
  26 {
  27   if (size < 52) {
  28     std::cerr << "Invalid NtCreateAndX Request" << std::endl;
  29     return;
  30   }
  31 
  32   word_count = data[0];
  33   and_x_command = data[1];
  34   reserved = data[2];
  35   memcpy(&and_x_offset, data + 3, 2);
  36   reserved1 = data[5];
  37   memcpy(&file_name_len, data + 6, 2);
  38   memcpy(&create_flags, data + 8, 4);
  39   memcpy(&root_fid, data + 12, 4);
  40   memcpy(&access_mask, data + 16, 4);
  41   memcpy(&allocation_size, data + 20, 8);
  42   memcpy(&file_attributes, data + 28, 4);
  43   memcpy(&share_access, data + 32, 4);
  44   memcpy(&disposition, data + 36, 4);
  45   memcpy(&create_options, data + 40, 4);
  46   memcpy(&impersonation, data + 44, 4);
  47   security_flags = data[48];
  48   memcpy(&byte_count, data + 49, 2);
  49   file_name = (const char *)(data + 51);
  50 }
  51 
  52 std::ostream &operator<<(std::ostream &lhs, const NtCreateAndXRequest &rhs)
  53 {
  54   lhs << "Word Count: " << (uint16_t)rhs.word_count << std::endl
  55       << "AndXCommand: " << (uint16_t)rhs.and_x_command << std::endl
  56       << "Reserved: " << (uint16_t)rhs.reserved << std::endl
  57       << "AndXOffset: " << rhs.and_x_offset << std::endl
  58       << "Reserved: " << (uint16_t)rhs.reserved1 << std::endl
  59       << "File Name Len: " << rhs.file_name_len << std::endl
  60       << "Create Flags: " << rhs.create_flags << std::endl
  61       << "Root FID: " << rhs.root_fid << std::endl
  62       << "Access Mask: " << rhs.access_mask << std::endl
  63       << "Allocation Size: " << rhs.allocation_size << std::endl
  64       << "File Attributes: " << rhs.file_attributes << std::endl
  65       << "Share Access: " << rhs.share_access << std::endl
  66       << "Disposition: " << rhs.disposition << std::endl
  67       << "Create Options: " << rhs.create_options << std::endl
  68       << "Impersonation: " << rhs.impersonation << std::endl
  69       << "Security Flags: " << (uint16_t)rhs.security_flags << std::endl
  70       << "Byte Count: " << rhs.byte_count << std::endl
  71       << "File Name: " << rhs.file_name << std::endl;
  72   return lhs;
  73 }

/* [<][>][^][v][top][bottom][index][help] */