summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2013-08-18 17:19:14 +0000
committerAndrew Bartlett <abartlet@samba.org>2013-08-19 11:08:13 +1200
commit817e0ae6875676c8d46b63539fe805ba215d2d6b (patch)
tree27131d11d808a2981a2df434c91f56999173ab28 /source3/utils
parent06273504586733ac548ddadad6c7bc757d2d5e25 (diff)
downloadsamba-817e0ae6875676c8d46b63539fe805ba215d2d6b.tar.gz
samba-817e0ae6875676c8d46b63539fe805ba215d2d6b.tar.bz2
samba-817e0ae6875676c8d46b63539fe805ba215d2d6b.zip
log2pcaphex: Fix nonempty line endings
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/log2pcaphex.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/source3/utils/log2pcaphex.c b/source3/utils/log2pcaphex.c
index 0b1230efe7..8425a5e71d 100644
--- a/source3/utils/log2pcaphex.c
+++ b/source3/utils/log2pcaphex.c
@@ -1,4 +1,4 @@
-/*
+/*
Unix SMB/CIFS implementation.
Utility to extract pcap files from samba (log level 10) log files
@@ -154,7 +154,6 @@ static void print_hex_packet(FILE *out, unsigned char *data, long length)
for(i = cur; i < length && i < cur + 16; i++) {
fprintf(out, "%02x ", data[i]);
}
-
cur = i;
fprintf(out, "\n");
}
@@ -162,10 +161,10 @@ static void print_hex_packet(FILE *out, unsigned char *data, long length)
static void print_netbios_packet(FILE *out, unsigned char *data, long length,
long actual_length)
-{
+{
unsigned char *newdata; long offset = 0;
long newlen;
-
+
newlen = length+sizeof(HDR_IP)+sizeof(HDR_TCP);
newdata = (unsigned char *)malloc(newlen);
@@ -176,7 +175,7 @@ static void print_netbios_packet(FILE *out, unsigned char *data, long length,
memcpy(newdata+offset, &HDR_IP, sizeof(HDR_IP));offset+=sizeof(HDR_IP);
memcpy(newdata+offset, &HDR_TCP, sizeof(HDR_TCP));offset+=sizeof(HDR_TCP);
memcpy(newdata+offset,data,length);
-
+
print_pcap_packet(out, newdata, newlen, actual_length+offset);
free(newdata);
}
@@ -312,12 +311,12 @@ int main (int argc, char **argv)
{ "hex", 'h', POPT_ARG_NONE, &hexformat, 0, "Output format readable by text2pcap" },
POPT_TABLEEND
};
-
+
pc = poptGetContext(NULL, argc, (const char **) argv, long_options,
POPT_CONTEXT_KEEP_FIRST);
poptSetOtherOptionHelp(pc, "[<infile> [<outfile>]]");
-
-
+
+
while((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
}
@@ -334,13 +333,13 @@ int main (int argc, char **argv)
return 1;
}
} else in = stdin;
-
+
outfile = poptGetArg(pc);
if(outfile) {
out = fopen(outfile, "w+");
- if(!out) {
- perror("fopen");
+ if(!out) {
+ perror("fopen");
fprintf(stderr, "Can't find %s, using stdout...\n", outfile);
return 1;
}
@@ -359,15 +358,15 @@ int main (int argc, char **argv)
read_log_msg(in, &curpacket, &curpacket_len, &data_offset, &data_length);
} else if(in_packet && strstr(buffer, "dump_data")) {
data_bytes_read = read_log_data(in, curpacket+data_offset, data_length);
- } else {
- if(in_packet){
- if(hexformat) print_hex_packet(out, curpacket, curpacket_len);
+ } else {
+ if(in_packet){
+ if(hexformat) print_hex_packet(out, curpacket, curpacket_len);
else print_netbios_packet(out, curpacket, curpacket_len, data_bytes_read+data_offset);
- free(curpacket);
+ free(curpacket);
}
in_packet = 0;
}
- }
+ }
}
if (in != stdin) {