dsniff  2.4b2
About: A collection of tools for network auditing
  Fossies Dox: dsniff-2.4b2.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

decode_sniffer.c
Go to the documentation of this file.
1 /*
2  * decode_sniffer.c
3  *
4  * Network Associates Sniffer.
5  *
6  * Copyright (c) 2000 Anonymous <nobody@localhost>
7  * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
8  *
9  * $Id: decode_sniffer.c,v 1.4 2001/03/15 08:33:02 dugsong Exp $
10  */
11 
12 #include "config.h"
13 
14 #include <sys/types.h>
15 
16 #include <stdio.h>
17 #include <string.h>
18 
19 #include "base64.h"
20 #include "decode.h"
21 
22 int
23 decode_sniffer(u_char *buf, int len, u_char *obuf, int olen)
24 {
25  u_int i, opcode;
26 
27  if (len < 36 || buf[0] != 5)
28  return (0);
29 
30  opcode = pletohs(&buf[6]);
31 
32  if (opcode == 260) {
33  if (buf[32] == 0)
34  return (strlcpy(obuf, "[]\n", olen));
35  }
36  else if (opcode == 261) {
37  if (pletohl(&buf[32]) == -1)
38  return (strlcpy(obuf, "[]\n", olen));
39  }
40  else return (0);
41 
42  buf[len - 3]= '\0'; strtok(&buf[32], "\r\n");
43  snprintf(obuf, olen, "%s [", &buf[32]);
44  len = strlen(obuf);
45  i = base64_pton(&buf[32], &obuf[len], olen - len - 3);
46  obuf[len + i] = '\0';
47  strlcat(obuf, "]\n", olen);
48 
49  return (strlen(obuf));
50 }
51 
strlcpy
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:43
decode_sniffer
int decode_sniffer(u_char *buf, int len, u_char *obuf, int olen)
Definition: decode_sniffer.c:23
decode.h
pletohl
#define pletohl(p)
Definition: decode.h:28
buf
Definition: buf.h:14
base64.h
base64_pton
int base64_pton(char const *src, u_char *target, size_t targsize)
Definition: base64.c:128
config.h
obuf
static char obuf[4096]
Definition: trigger.c:43
strlcat
size_t strlcat(char *dst, const char *src, size_t siz)
Definition: strlcat.c:44
pletohs
#define pletohs(p)
Definition: decode.h:24