root/trunk/tool/CaNA.h

Revision 156, 3.0 KB (checked in by andreu, 11 years ago)

CaNA tool for renetcol

Line 
1/*
2 * File: CaNA.h
3 *
4 * Authors: ANDREU Francois-Xavier
5 *
6 * Copyright (C) 2011 GIP RENATER
7 *
8 * CaNA : Catalyst for NetFlow Analyser
9 */
10
11/*  This file is part of renetcol.
12 *
13 *  renetcol is free software; you can redistribute it and/or modify
14 *  it under the terms of the GNU General Public License as published by
15 *  the Free Software Foundation; either version 2 of the License, or
16 *  (at your option) any later version.
17 *
18 *  renetcol is distributed in the hope that it will be useful,
19 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 *  GNU General Public License for more details.
22 *
23 *  You should have received a copy of the GNU General Public License
24 *  along with renetcol; if not, write to the Free Software
25 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
26 */
27
28#define _GNU_SOURCE
29
30#include <unistd.h>
31#include <stdio.h>
32#include <string.h>
33#include <stdlib.h>
34#include <syslog.h>
35#include <sys/types.h>
36#include <sys/socket.h>
37#include <netinet/in.h>
38#include <netinet/ip.h>
39#include <netinet/udp.h>
40#include <net/if.h>
41#include <arpa/inet.h>
42#include <time.h>
43#include <errno.h>
44#include <search.h>
45#include <sys/ioctl.h>
46
47#define MAX_ROUTERS_NB 60
48#define NB_ENTRY 600
49#define RECEPTION_ADDRESS ""
50#define RECEPTION_PORT 9999
51#define SOCKET_BUFFER_SIZE 1500
52
53typedef int           s32;
54typedef unsigned int  u32;
55typedef char          s8;
56typedef unsigned char u8;
57typedef unsigned short u16;
58typedef signed short s16;
59
60typedef struct Filter * FilterPtr;
61typedef struct Filter {
62  s8 nb_filters;
63  u32 new_router_ip;
64  u32 new_destination_ip;
65  u16 new_dest_udp_port;
66  u32 second_router_ip;
67  u32 second_destination_ip;
68  u16 second_dest_udp_port;
69  u32 third_router_ip;
70  u32 third_destination_ip;
71  u16 third_dest_udp_port;
72  u32 fourth_router_ip;
73  u32 fourth_destination_ip;
74  u16 fourth_dest_udp_port;
75  u32 five_router_ip;
76  u32 five_destination_ip;
77  u16 five_dest_udp_port;
78  u32 six_router_ip;
79  u32 six_destination_ip;
80  u16 six_dest_udp_port;
81} FilterType;
82
83typedef struct IpHeader * IpHeaderPtr;
84typedef struct IpHeader {
85  unsigned short versionAndLength;
86  unsigned short tos;
87  unsigned short length;
88  unsigned short ident;
89  unsigned short flagsAndOffset;
90  unsigned short ttl;
91  unsigned short protocol;
92  unsigned short checksum;
93  unsigned long srcAdd;
94  unsigned long dstAdd;
95} IpHeaderType;
96
97typedef struct UdpHeader * UdpHeaderPtr;
98typedef struct UdpHeader {
99  unsigned short srcPort;
100  unsigned short dstPort;
101  unsigned short length;
102  unsigned short checksum;
103} UdpHeaderType;
104
105typedef struct Datagram * DatagramPtr;
106typedef struct Datagram {
107  IpHeaderPtr ipH;
108  UdpHeaderPtr udp_header;
109} DatagramType;
110
111struct toCkSum_UdpHeader {
112        struct in_addr srcIP;
113        struct in_addr dstIP;
114        unsigned char padding;
115        unsigned char protocol;
116        unsigned short udp_length;
117        struct udphdr udp;
118};
Note: See TracBrowser for help on using the browser.