File: tcpip-mod.h

package info (click to toggle)
cheops 0.61-15.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,272 kB
  • ctags: 1,312
  • sloc: ansic: 12,731; sh: 155; makefile: 151
file content (120 lines) | stat: -rw-r--r-- 2,419 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#ifndef _TCPIP_MOD_H
#define _TCPIP_MOD_H
#include <time.h>

typedef struct
  {
    unsigned char vh;
    unsigned char stype;
    unsigned short length;
    unsigned short ident;
    unsigned short frag;
    unsigned char ttl;
    unsigned char protocol;
    unsigned short cksum;
    struct in_addr sip;
    struct in_addr dip;
  }
iprec;

typedef struct
  {
    unsigned short sport;
    unsigned short dport;
    unsigned int seqnum;
    unsigned int acknum;
    unsigned char txoff;
    unsigned char flags;
    unsigned short window;
    unsigned short cksum;
    unsigned short urgentptr;
  }
tcprec;

typedef struct
  {
    struct in_addr sip;
    struct in_addr dip;
    unsigned char zero;
    unsigned char proto;
    unsigned short tcplen;
  }
tcpsrec;

typedef struct
  {
    unsigned char type;
    unsigned char code;
    unsigned short cksum;
    unsigned int zero;
    iprec ip;
    unsigned short sport;
    unsigned short dport;
    unsigned int seq;
  }
icmprec;

#define ACK_HACK  1000
#define RANDOM_ACK (ACK_HACK+666)
#define MAXPKT 6

/* 3 seconds of life to reply */
#define LIFE 3

/* Maximum retries before giving up on
   knowing the OS */
#define MAX_RETRIES 2

/* #define's for the TCP flags */
#define YYY 0x80
#define XXX 0x40
#define URG 0x20
#define ACK 0x10
#define PSH 0x08
#define RST 0x04
#define SYN 0x02
#define FIN 0x01

typedef struct
{
  unsigned short set;
  unsigned int seq;
  unsigned int ack;
  unsigned short urg;
  unsigned short win;
  unsigned short flag;
}
OSRES;

/* Structure for a spoofed connection */
typedef struct _spoofrec spoofrec;
struct _spoofrec
  {
    void *data;
    struct sockaddr_in from;
    struct sockaddr_in dest;
    unsigned short sport;
    unsigned short dport;
    unsigned int seq;
    unsigned int ack;
    int retries;
    time_t timeout;
    spoofrec *next;
    OSRES r[MAXPKT + 1];
  };



/* -------------- Prototiping --------------- */
void init_tcpip(void);
int init_pcap(char*);
unsigned short in_cksum (unsigned short *, int);  
void sendip (spoofrec *, char *, short, short *, short *, short);
unsigned short tcpcksum (spoofrec *, char *, short);
short resolve_host (char *, struct sockaddr_in *);
unsigned int gettcp (tcprec *);
void sendtcp (spoofrec *, unsigned short, short); 
struct in_addr getlocalip (unsigned int dest);
char *tcpip_id(void);
extern char *ident_os(unsigned int dest_addr, short dport, OSRES *r);
#endif