File: CPacket.h

package info (click to toggle)
fireflier 1.1.6-3etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 3,348 kB
  • ctags: 1,167
  • sloc: sh: 9,023; cpp: 8,370; makefile: 437; ansic: 300
file content (58 lines) | stat: -rw-r--r-- 1,489 bytes parent folder | download | duplicates (3)
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
#ifndef _CPACKET_H
#define _CPACKET_H

#include <net/if.h>
#include <string>
#include "CRefPtr.h"


class CPacket // implement reference counting
{
//fields
public:
    unsigned long packet_id; // unique packet id, needed for accepting or dropping a packet (libipq)
    unsigned long arrived; // time the packet arrived (in seconds)
    unsigned char interface_in[IFNAMSIZ]; // name of incoming interface
    unsigned char interface_out[IFNAMSIZ]; // name of outgoing interface
    unsigned short int len; // length of packet data
    unsigned long ip_src; // source ip
    unsigned long ip_dst; // destination ip
    unsigned int protocol:8; // protocol id (see rules.h)

    unsigned short int port_src; // source port
    unsigned short int port_dst; // destination port

    unsigned short int tcp_flags; // tcp flags: ACK, FIN, RST, SYN, ...

    unsigned int icmp_type:8; // type of icmp packet

    unsigned int mac_addrlen:8; // real length of mac address 
    unsigned char mac_addr[8]; // mac is maximum 8 bytes
    unsigned int hook; // chain (INPUT=1, FORWARD=2, OUTPUT=3)
    char* data; // packet data
    std::string programname; // program using this packets localport/localip


//constructors
protected:
	CPacket()
		: data(NULL)
		//, programname(char*())
	{}

public:
	~CPacket()
	{
/*		if (programname)
			delete[] programname;*/
		if (data)
			delete[] data;
	}
	
	
//methods
public:
	static CRefPtr <const CPacket> scanPacket(const unsigned char* buffer);
};

#endif