Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/utils/log2pcaphex.c

    r740 r988  
    1 /* 
     1/*
    22   Unix SMB/CIFS implementation.
    33   Utility to extract pcap files from samba (log level 10) log files
     
    7575/* tcpdump file format */
    7676struct tcpdump_file_header {
    77         uint32 magic;
    78         uint16 major;
    79         uint16 minor;
    80         int32 zone;
    81         uint32 sigfigs;
    82         uint32 snaplen;
    83         uint32 linktype;
     77        uint32_t magic;
     78        uint16_t major;
     79        uint16_t minor;
     80        int32_t zone;
     81        uint32_t sigfigs;
     82        uint32_t snaplen;
     83        uint32_t linktype;
    8484};
    8585
    8686struct tcpdump_packet {
    8787        struct timeval ts;
    88         uint32 caplen;
    89         uint32 len;
     88        uint32_t caplen;
     89        uint32_t len;
    9090};
    9191
    9292typedef struct {
    93     uint8  ver_hdrlen;
    94     uint8  dscp;
    95     uint16 packet_length;
    96     uint16 identification;
    97     uint8  flags;
    98     uint8  fragment;
    99     uint8  ttl;
    100     uint8  protocol;
    101     uint16 hdr_checksum;
    102     uint32 src_addr;
    103     uint32 dest_addr;
     93    uint8_t  ver_hdrlen;
     94    uint8_t  dscp;
     95    uint16_t packet_length;
     96    uint16_t identification;
     97    uint8_t  flags;
     98    uint8_t  fragment;
     99    uint8_t  ttl;
     100    uint8_t  protocol;
     101    uint16_t hdr_checksum;
     102    uint32_t src_addr;
     103    uint32_t dest_addr;
    104104} hdr_ip_t;
    105105
     
    107107
    108108typedef struct {
    109     uint16 source_port;
    110     uint16 dest_port;
    111     uint32 seq_num;
    112     uint32 ack_num;
    113     uint8  hdr_length;
    114     uint8  flags;
    115     uint16 window;
    116     uint16 checksum;
    117     uint16 urg;
     109    uint16_t source_port;
     110    uint16_t dest_port;
     111    uint32_t seq_num;
     112    uint32_t ack_num;
     113    uint8_t  hdr_length;
     114    uint8_t  flags;
     115    uint16_t window;
     116    uint16_t checksum;
     117    uint16_t urg;
    118118} hdr_tcp_t;
    119119
     
    155155                        fprintf(out, "%02x ", data[i]);
    156156                }
    157        
    158157                cur = i;
    159158                fprintf(out, "\n");
     
    163162static void print_netbios_packet(FILE *out, unsigned char *data, long length,
    164163                                 long actual_length)
    165 {       
     164{
    166165        unsigned char *newdata; long offset = 0;
    167166        long newlen;
    168        
     167
    169168        newlen = length+sizeof(HDR_IP)+sizeof(HDR_TCP);
    170169        newdata = (unsigned char *)malloc(newlen);
     
    177176        memcpy(newdata+offset, &HDR_TCP, sizeof(HDR_TCP));offset+=sizeof(HDR_TCP);
    178177        memcpy(newdata+offset,data,length);
    179        
     178
    180179        print_pcap_packet(out, newdata, newlen, actual_length+offset);
    181180        free(newdata);
     
    297296}
    298297
    299 int main (int argc, char **argv)
     298int main(int argc, const char **argv)
    300299{
    301300        const char *infile, *outfile;
     
    313312                POPT_TABLEEND
    314313        };
    315        
    316         pc = poptGetContext(NULL, argc, (const char **) argv, long_options,
     314
     315        pc = poptGetContext(NULL, argc, argv, long_options,
    317316                            POPT_CONTEXT_KEEP_FIRST);
    318317        poptSetOtherOptionHelp(pc, "[<infile> [<outfile>]]");
    319        
    320        
     318
     319
    321320        while((opt = poptGetNextOpt(pc)) != -1) {
    322321                switch (opt) {
     
    335334                }
    336335        } else in = stdin;
    337        
     336
    338337        outfile = poptGetArg(pc);
    339338
    340339        if(outfile) {
    341340                out = fopen(outfile, "w+");
    342                 if(!out) { 
    343                         perror("fopen"); 
     341                if(!out) {
     342                        perror("fopen");
    344343                        fprintf(stderr, "Can't find %s, using stdout...\n", outfile);
    345344                        return 1;
     
    360359                        } else if(in_packet && strstr(buffer, "dump_data")) {
    361360                                data_bytes_read = read_log_data(in, curpacket+data_offset, data_length);
    362                         }  else { 
    363                                 if(in_packet){ 
    364                                         if(hexformat) print_hex_packet(out, curpacket, curpacket_len); 
     361                        }  else {
     362                                if(in_packet){
     363                                        if(hexformat) print_hex_packet(out, curpacket, curpacket_len);
    365364                                        else print_netbios_packet(out, curpacket, curpacket_len, data_bytes_read+data_offset);
    366                                         free(curpacket); 
     365                                        free(curpacket);
    367366                                }
    368367                                in_packet = 0;
    369368                        }
    370                 } 
     369                }
    371370        }
    372371
Note: See TracChangeset for help on using the changeset viewer.