tcpdump  4.99.1
About: tcpdump is a tool for network monitoring and data acquisition.
  Fossies Dox: tcpdump-4.99.1.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

smbutil.c File Reference
#include "netdissect-stdinc.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "netdissect-ctype.h"
#include "netdissect.h"
#include "extract.h"
#include "smb.h"
Include dependency graph for smbutil.c:

Go to the source code of this file.

Data Structures

struct  err_code_struct
 
struct  nt_err_code_struct
 

Macros

#define MAX_UNISTR_SIZE   1000
 

Functions

void smb_reset (void)
 
static void interpret_dos_date (uint32_t date, struct tm *tp)
 
static time_t int_unix_date (uint32_t dos_date)
 
static time_t make_unix_date (netdissect_options *ndo, const u_char *date_ptr)
 
static time_t make_unix_date2 (netdissect_options *ndo, const u_char *date_ptr)
 
static time_t interpret_long_date (netdissect_options *ndo, const u_char *p)
 
static int name_interpret (netdissect_options *ndo, const u_char *in, const u_char *maxbuf, char *out)
 
static const u_char * name_ptr (netdissect_options *ndo, const u_char *buf, u_int ofs, const u_char *maxbuf)
 
static int name_extract (netdissect_options *ndo, const u_char *buf, u_int ofs, const u_char *maxbuf, char *name)
 
static int name_len (netdissect_options *ndo, const u_char *s, const u_char *maxbuf)
 
static void print_asc (netdissect_options *ndo, const u_char *buf, u_int len)
 
static const char * name_type_str (int name_type)
 
void smb_data_print (netdissect_options *ndo, const u_char *buf, u_int len)
 
static void write_bits (netdissect_options *ndo, unsigned int val, const char *fmt)
 
static const u_char * unistr (netdissect_options *ndo, char(*buf)[1000+1], const u_char *s, uint32_t strsize, int is_null_terminated, int use_unicode)
 
static const u_char * smb_fdata1 (netdissect_options *ndo, const u_char *buf, const char *fmt, const u_char *maxbuf, int unicodestr)
 
const u_char * smb_fdata (netdissect_options *ndo, const u_char *buf, const char *fmt, const u_char *maxbuf, int unicodestr)
 
const char * smb_errstr (int class, int num)
 
const char * nt_errstr (uint32_t err)
 

Variables

static int stringlen_is_set
 
static uint32_t stringlen
 
const u_char * startbuf
 
static const err_code_struct dos_msgs []
 
static const err_code_struct server_msgs []
 
static const err_code_struct hard_msgs []
 
struct {
   int   code
 
   const char *   class
 
   const err_code_struct *   err_msgs
 
err_classes []
 
static const nt_err_code_struct nt_errors []
 

Macro Definition Documentation

◆ MAX_UNISTR_SIZE

#define MAX_UNISTR_SIZE   1000

Definition at line 346 of file smbutil.c.

Function Documentation

◆ int_unix_date()

static time_t int_unix_date ( uint32_t  dos_date)
static

Definition at line 65 of file smbutil.c.

References interpret_dos_date().

Referenced by make_unix_date(), and make_unix_date2().

◆ interpret_dos_date()

static void interpret_dos_date ( uint32_t  date,
struct tm *  tp 
)
static

Definition at line 43 of file smbutil.c.

Referenced by int_unix_date().

◆ interpret_long_date()

static time_t interpret_long_date ( netdissect_options ndo,
const u_char *  p 
)
static

Definition at line 113 of file smbutil.c.

References GET_LE_U_4, and GET_U_1.

Referenced by smb_fdata1().

◆ make_unix_date()

static time_t make_unix_date ( netdissect_options ndo,
const u_char *  date_ptr 
)
static

Definition at line 85 of file smbutil.c.

References GET_LE_U_4, and int_unix_date().

Referenced by smb_fdata1().

◆ make_unix_date2()

static time_t make_unix_date2 ( netdissect_options ndo,
const u_char *  date_ptr 
)
static

Definition at line 99 of file smbutil.c.

References GET_LE_U_4, and int_unix_date().

Referenced by smb_fdata1().

◆ name_extract()

static int name_extract ( netdissect_options ndo,
const u_char *  buf,
u_int  ofs,
const u_char *  maxbuf,
char *  name 
)
static

Definition at line 222 of file smbutil.c.

References name, name_interpret(), and name_ptr().

Referenced by smb_fdata1().

◆ name_interpret()

static int name_interpret ( netdissect_options ndo,
const u_char *  in,
const u_char *  maxbuf,
char *  out 
)
static

Definition at line 140 of file smbutil.c.

References GET_U_1, and ND_TCHECK_2.

Referenced by name_extract().

◆ name_len()

static int name_len ( netdissect_options ndo,
const u_char *  s,
const u_char *  maxbuf 
)
static

Definition at line 237 of file smbutil.c.

References GET_U_1, ND_BYTES_BETWEEN, and ND_TCHECK_1.

Referenced by smb_fdata1(), and vtp_print().

◆ name_ptr()

static const u_char* name_ptr ( netdissect_options ndo,
const u_char *  buf,
u_int  ofs,
const u_char *  maxbuf 
)
static

Definition at line 183 of file smbutil.c.

References GET_BE_U_2, GET_U_1, ND_TCHECK_1, and ND_TCHECK_2.

Referenced by name_extract().

◆ name_type_str()

static const char* name_type_str ( int  name_type)
static

Definition at line 270 of file smbutil.c.

Referenced by smb_fdata1().

◆ nt_errstr()

const char* nt_errstr ( uint32_t  err)

Definition at line 1957 of file smbutil.c.

References code, nt_err_code_struct::name, nt_errors, and snprintf().

Referenced by print_smb().

◆ print_asc()

static void print_asc ( netdissect_options ndo,
const u_char *  buf,
u_int  len 
)
static

Definition at line 261 of file smbutil.c.

References fn_print_char(), and GET_U_1.

Referenced by smb_data_print().

◆ smb_data_print()

void smb_data_print ( netdissect_options ndo,
const u_char *  buf,
u_int  len 
)

◆ smb_errstr()

const char* smb_errstr ( int  class,
int  num 
)

Definition at line 1065 of file smbutil.c.

References code, err_classes, err_msgs, name, err_code_struct::name, and snprintf().

Referenced by print_smb().

◆ smb_fdata()

const u_char* smb_fdata ( netdissect_options ndo,
const u_char *  buf,
const char *  fmt,
const u_char *  maxbuf,
int  unicodestr 
)

◆ smb_fdata1()

◆ smb_reset()

void smb_reset ( void  )

Definition at line 33 of file smbutil.c.

References stringlen, and stringlen_is_set.

Referenced by print_smb().

◆ unistr()

static const u_char* unistr ( netdissect_options ndo,
char(*)  buf[1000+1],
const u_char *  s,
uint32_t  strsize,
int  is_null_terminated,
int  use_unicode 
)
static

Definition at line 348 of file smbutil.c.

References GET_LE_U_2, GET_U_1, MAX_UNISTR_SIZE, ND_ASCII_ISPRINT, ND_TCHECK_1, ND_TCHECK_LEN, and startbuf.

Referenced by smb_fdata1().

◆ write_bits()

static void write_bits ( netdissect_options ndo,
unsigned int  val,
const char *  fmt 
)
static

Definition at line 330 of file smbutil.c.

References ND_BYTES_BETWEEN, and ND_PRINT.

Referenced by smb_fdata1().

Variable Documentation

◆ class

const char* class

Definition at line 1046 of file smbutil.c.

◆ code

◆ dos_msgs

const err_code_struct dos_msgs[]
static
Initial value:
= {
{ "ERRbadfunc", 1, "Invalid function." },
{ "ERRbadfile", 2, "File not found." },
{ "ERRbadpath", 3, "Directory invalid." },
{ "ERRnofids", 4, "No file descriptors available" },
{ "ERRnoaccess", 5, "Access denied." },
{ "ERRbadfid", 6, "Invalid file handle." },
{ "ERRbadmcb", 7, "Memory control blocks destroyed." },
{ "ERRnomem", 8, "Insufficient server memory to perform the requested function." },
{ "ERRbadmem", 9, "Invalid memory block address." },
{ "ERRbadenv", 10, "Invalid environment." },
{ "ERRbadformat", 11, "Invalid format." },
{ "ERRbadaccess", 12, "Invalid open mode." },
{ "ERRbaddata", 13, "Invalid data." },
{ "ERR", 14, "reserved." },
{ "ERRbaddrive", 15, "Invalid drive specified." },
{ "ERRremcd", 16, "A Delete Directory request attempted to remove the server's current directory." },
{ "ERRdiffdevice", 17, "Not same device." },
{ "ERRnofiles", 18, "A File Search command can find no more files matching the specified criteria." },
{ "ERRbadshare", 32, "The sharing mode specified for an Open conflicts with existing FIDs on the file." },
{ "ERRlock", 33, "A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process." },
{ "ERRfilexists", 80, "The file named in a Create Directory, Make New File or Link request already exists." },
{ "ERRbadpipe", 230, "Pipe invalid." },
{ "ERRpipebusy", 231, "All instances of the requested pipe are busy." },
{ "ERRpipeclosing", 232, "Pipe close in progress." },
{ "ERRnotconnected", 233, "No process on other end of pipe." },
{ "ERRmoredata", 234, "There is more data to be returned." },
{ NULL, -1, NULL }
}

Definition at line 954 of file smbutil.c.

◆ 

err_classes[] { ... } const struct
Initial value:
= {
{ 0, "SUCCESS", NULL },
{ 0x01, "ERRDOS", dos_msgs },
{ 0x02, "ERRSRV", server_msgs },
{ 0x03, "ERRHRD", hard_msgs },
{ 0x04, "ERRXOS", NULL },
{ 0xE1, "ERRRMX1", NULL },
{ 0xE2, "ERRRMX2", NULL },
{ 0xE3, "ERRRMX3", NULL },
{ 0xFF, "ERRCMD", NULL },
{ -1, NULL, NULL }
}
static const err_code_struct server_msgs[]
Definition: smbutil.c:985
static const err_code_struct hard_msgs[]
Definition: smbutil.c:1022
static const err_code_struct dos_msgs[]
Definition: smbutil.c:954

Referenced by smb_errstr().

◆ err_msgs

const err_code_struct* err_msgs

Definition at line 1047 of file smbutil.c.

Referenced by smb_errstr().

◆ hard_msgs

const err_code_struct hard_msgs[]
static
Initial value:
= {
{ "ERRnowrite", 19, "Attempt to write on write-protected diskette." },
{ "ERRbadunit", 20, "Unknown unit." },
{ "ERRnotready", 21, "Drive not ready." },
{ "ERRbadcmd", 22, "Unknown command." },
{ "ERRdata", 23, "Data error (CRC)." },
{ "ERRbadreq", 24, "Bad request structure length." },
{ "ERRseek", 25 , "Seek error." },
{ "ERRbadmedia", 26, "Unknown media type." },
{ "ERRbadsector", 27, "Sector not found." },
{ "ERRnopaper", 28, "Printer out of paper." },
{ "ERRwrite", 29, "Write fault." },
{ "ERRread", 30, "Read fault." },
{ "ERRgeneral", 31, "General failure." },
{ "ERRbadshare", 32, "A open conflicts with an existing open." },
{ "ERRlock", 33, "A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process." },
{ "ERRwrongdisk", 34, "The wrong disk was found in a drive." },
{ "ERRFCBUnavail", 35, "No FCBs are available to process request." },
{ "ERRsharebufexc", 36, "A sharing buffer has been exceeded." },
{ NULL, -1, NULL }
}

Definition at line 1022 of file smbutil.c.

◆ nt_errors

const nt_err_code_struct nt_errors[]
static

Definition at line 1100 of file smbutil.c.

Referenced by nt_errstr().

◆ server_msgs

const err_code_struct server_msgs[]
static

Definition at line 985 of file smbutil.c.

◆ startbuf

const u_char* startbuf
extern

◆ stringlen

uint32_t stringlen
static

Definition at line 26 of file smbutil.c.

Referenced by decode_labeled_vpn_l2(), nfs_printfh(), smb_fdata1(), and smb_reset().

◆ stringlen_is_set

int stringlen_is_set
static

Definition at line 25 of file smbutil.c.

Referenced by smb_fdata1(), and smb_reset().