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)  

asn1.c
Go to the documentation of this file.
1 /*
2  * asn1.c
3  *
4  * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
5  *
6  * $Id: asn1.c,v 1.4 2001/03/15 08:32:58 dugsong Exp $
7  */
8 
9 #include "config.h"
10 
11 #include <sys/types.h>
12 #include <arpa/nameser.h>
13 
14 #include <unistd.h>
15 
16 #include "buf.h"
17 #include "asn1.h"
18 
19 int
21 {
22  u_char c;
23 
24  if (buf_get(buf, &c, 1) != 1)
25  return (-1);
26 
27  return (c & 0x1f);
28 }
29 
30 int
32 {
33  u_char *p, c;
34  int num;
35 
36  if (buf_get(buf, &c, 1) != 1)
37  return (-1);
38 
39  if (c >= 128) {
40  c &= ~128;
41  p = buf_ptr(buf);
42 
43  if (buf_skip(buf, c) < 0)
44  return (-1);
45 
46  switch (c) {
47  case 1:
48  num = *p;
49  break;
50  case 2:
51  GETSHORT(num, p);
52  break;
53  case 3:
54  p--; GETLONG(num, p);
55  num &= 0xfff;
56  break;
57  case 4:
58  GETLONG(num, p);
59  break;
60  default:
61  return (-1);
62  }
63  }
64  else num = c;
65 
66  return (num);
67 }
buf.h
asn1_len
int asn1_len(buf_t buf)
Definition: asn1.c:31
buf
Definition: buf.h:14
buf_get
int buf_get(buf_t buf, void *dst, int len)
Definition: buf.c:74
buf_ptr
#define buf_ptr(b)
Definition: buf.h:31
asn1_type
int asn1_type(buf_t buf)
Definition: asn1.c:20
buf_skip
#define buf_skip(b, l)
Definition: buf.h:47
config.h
asn1.h